...
 
Commits (2)
......@@ -58,7 +58,6 @@ import static org.apache.commons.math3.util.FastMath.*;
import org.bouncycastle.util.Arrays;
import pl.edu.icm.jlargearrays.ByteLargeArray;
import pl.edu.icm.jlargearrays.LargeArrayUtils;
import pl.edu.icm.jlargearrays.LogicLargeArray;
import pl.edu.icm.jlargearrays.ObjectLargeArray;
import pl.edu.icm.jlargearrays.StringLargeArray;
import pl.edu.icm.jscic.dataarrays.ComplexDataArray;
......@@ -78,7 +77,6 @@ public class GlyphsObject extends DataMappedGeometryObject
private Field inField = null;
private OpenBranchGroup outGroup = null;
private DataArray glyphDataArray, thresholdDataArray;
private LogicLargeArray mask = null;
private float thrLow = -Float.MAX_VALUE, thrUp = Float.MAX_VALUE;
private float[] baseCoords = null;
private long[] glyphIn = null;
......@@ -108,8 +106,6 @@ public class GlyphsObject extends DataMappedGeometryObject
private boolean isValid(long i)
{
if (mask != null && !mask.getBoolean(i))
return false;
double t;
if (thresholdDataArray == null)
return true;
......@@ -175,8 +171,6 @@ public class GlyphsObject extends DataMappedGeometryObject
glyphDataArray = inField.getComponent(params.getComponent());
if (glyphDataArray == null)
return;
if (inField.hasMask())
mask = inField.getCurrentMask();
thrLow = params.getThreshold().getLow();
thrUp = params.getThreshold().getUp();
thresholdDataArray = inField.getComponent(params.getThreshold().getComponentName());
......
......@@ -40,6 +40,29 @@
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
<SubComponents>
<Component class="pl.edu.icm.visnow.geometries.gui.DataMappingGUI" name="dataMappingGUI">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="Center"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JSlider" name="globalResSlider">
<Properties>
<Property name="majorTickSpacing" type="int" value="10"/>
<Property name="maximum" type="int" value="50"/>
<Property name="minorTickSpacing" type="int" value="2"/>
<Property name="paintLabels" type="boolean" value="true"/>
<Property name="paintTicks" type="boolean" value="true"/>
<Property name="value" type="int" value="20"/>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="resolution"/>
</Border>
</Property>
</Properties>
<Events>
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="globalResSliderStateChanged"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="North"/>
......
......@@ -40,6 +40,8 @@
package pl.edu.icm.visnow.lib.basic.mappers.VolumeRenderer;
import java.util.Hashtable;
import javax.swing.JLabel;
import javax.swing.JPanel;
import pl.edu.icm.jscic.RegularField;
import pl.edu.icm.visnow.geometries.events.ColorListener;
......@@ -60,7 +62,7 @@ public class GUI extends JPanel
private Params params = new Params();
protected DataMappingParams dataMappingParams;
protected RegularField field = null;
private boolean syncing = false;
private final String[] densities = {"<html>very<p>coarse</html>", "coarse", "std", "fine", "<html>very<p>fine</html>", "<html>super<p>fine</html>"};
/**
* Creates new form VolRenderUI
......@@ -72,6 +74,10 @@ public class GUI extends JPanel
dataMappingGUI.setStartNullTransparencyComponent(false);
dataMappingGUI.setShowNodeCellPanel(false);
dataMappingGUI.panelFold(DataMappingGUI.FoldablePanel.Transparency, true);
Hashtable labelTable = new Hashtable();
for (int i = 0; i < densities.length; i++)
labelTable.put( new Integer(10 * i), new JLabel(densities[i]) );
globalResSlider.setLabelTable(labelTable);
}
/**
......@@ -81,13 +87,15 @@ public class GUI extends JPanel
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
private void initComponents()
{
java.awt.GridBagConstraints gridBagConstraints;
buttonGroup1 = new javax.swing.ButtonGroup();
mainPane = new javax.swing.JTabbedPane();
jPanel1 = new javax.swing.JPanel();
dataMappingGUI = new pl.edu.icm.visnow.geometries.gui.DataMappingGUI();
globalResSlider = new javax.swing.JSlider();
jPanel2 = new javax.swing.JPanel();
volumeShadingPanel = new pl.edu.icm.visnow.geometries.gui.VolumeShadingGUI();
jPanel3 = new javax.swing.JPanel();
......@@ -99,7 +107,23 @@ public class GUI extends JPanel
setLayout(new java.awt.GridBagLayout());
jPanel1.setLayout(new java.awt.BorderLayout());
jPanel1.add(dataMappingGUI, java.awt.BorderLayout.NORTH);
jPanel1.add(dataMappingGUI, java.awt.BorderLayout.CENTER);
globalResSlider.setMajorTickSpacing(10);
globalResSlider.setMaximum(50);
globalResSlider.setMinorTickSpacing(2);
globalResSlider.setPaintLabels(true);
globalResSlider.setPaintTicks(true);
globalResSlider.setValue(20);
globalResSlider.setBorder(javax.swing.BorderFactory.createTitledBorder("resolution"));
globalResSlider.addChangeListener(new javax.swing.event.ChangeListener()
{
public void stateChanged(javax.swing.event.ChangeEvent evt)
{
globalResSliderStateChanged(evt);
}
});
jPanel1.add(globalResSlider, java.awt.BorderLayout.NORTH);
mainPane.addTab("data mapping", jPanel1);
......@@ -127,8 +151,10 @@ public class GUI extends JPanel
outButton.setText("output cropped field");
outButton.setName(""); // NOI18N
outButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
outButton.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
outButtonActionPerformed(evt);
}
});
......@@ -158,11 +184,15 @@ public class GUI extends JPanel
params.setOutCroppedField();
}//GEN-LAST:event_outButtonActionPerformed
boolean silent = false;
private void globalResSliderStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_globalResSliderStateChanged
if (!globalResSlider.getValueIsAdjusting()) {
int res = (int)(64 * Math.pow(2, globalResSlider.getValue() / 10.));
params.setResolution(res);
}
}//GEN-LAST:event_globalResSliderStateChanged
public void setInField(RegularField inField, DataMappingParams mapParams)
{
silent = true;
this.field = inField;
if (inField == null) {
int[] tmp = {10, 10, 10};
......@@ -171,11 +201,9 @@ public class GUI extends JPanel
dataMappingGUI.setInData(null, mapParams);
return;
}
cropUI.setNewExtents(inField.getDims());
cropUI.setEnabled(true);
dataMappingGUI.setInData(inField, mapParams);
silent = false;
}
public CropUI getCropUI()
......@@ -199,6 +227,11 @@ public class GUI extends JPanel
dataMappingParams = params;
dataMappingGUI.setParams(dataMappingParams);
}
public void setVisibleResSlider(boolean visibleResSlider)
{
globalResSlider.setVisible(visibleResSlider);
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.ButtonGroup buttonGroup1;
......@@ -206,6 +239,7 @@ public class GUI extends JPanel
private pl.edu.icm.visnow.lib.gui.cropUI.CropUI cropUI;
private pl.edu.icm.visnow.geometries.gui.DataMappingGUI dataMappingGUI;
private javax.swing.Box.Filler filler;
private javax.swing.JSlider globalResSlider;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
......
......@@ -51,6 +51,7 @@ public class Params extends Parameters
{
public static final String OUTPUT = "output";
public static final String RESOLUTION = "resolution";
private VolumeShadingParams shadingParams = new VolumeShadingParams();
@SuppressWarnings("unchecked")
......@@ -60,7 +61,9 @@ public class Params extends Parameters
}
private static ParameterEgg[] eggs = new ParameterEgg[]{
new ParameterEgg<Boolean>(OUTPUT, ParameterType.dependent, false)};
new ParameterEgg<Boolean>(OUTPUT, ParameterType.dependent, false),
new ParameterEgg<Integer>(RESOLUTION, ParameterType.dependent, 256)
};
public void setOutCroppedField()
......@@ -72,4 +75,15 @@ public class Params extends Parameters
return shadingParams;
}
public int getResolution()
{
return (Integer)(getValue(RESOLUTION));
}
public void setResolution(int resolution)
{
setValue(RESOLUTION, resolution);
fireParameterChanged(RESOLUTION);
}
}
......@@ -70,12 +70,18 @@ import pl.edu.icm.visnow.lib.templates.visualization.modules.VisualizationModule
import pl.edu.icm.visnow.lib.types.VNRegularField;
import static pl.edu.icm.jscic.utils.CropDownUtils.*;
import pl.edu.icm.jlargearrays.FloatLargeArray;
import pl.edu.icm.jscic.Field;
import pl.edu.icm.visnow.engine.core.ParameterChangeListener;
import pl.edu.icm.visnow.geometries.events.LightDirectionEvent;
import pl.edu.icm.visnow.geometries.events.LightDirectionListener;
import pl.edu.icm.visnow.geometries.parameters.DataMappingParams;
import pl.edu.icm.visnow.geometries.parameters.VolumeShadingParams;
import pl.edu.icm.visnow.lib.basic.filters.ConvexHull.ConvexHullCore;
import static pl.edu.icm.visnow.lib.basic.mappers.VolumeRenderer.Params.*;
import pl.edu.icm.visnow.lib.types.VNField;
import pl.edu.icm.visnow.lib.utils.SwingInstancer;
import pl.edu.icm.visnow.lib.utils.interpolation.OptimizedBox;
import pl.edu.icm.visnow.lib.utils.interpolation.RegularInterpolation;
import pl.edu.icm.visnow.system.main.VisNow;
/**
......@@ -93,7 +99,13 @@ public class VolumeRenderer extends VisualizationModule
protected GUI ui = null;
protected Params params = new Params();
private VolumeShadingParams shadingParams = params.getShadingParams();
protected Field rawInField;
protected RegularField inField;
protected RegularField in = null;
protected int trueDim;
protected FloatLargeArray inCoords = null;
private float[][] outAffine;
protected int[] inDims = null;
protected float[][] af = null;
......@@ -134,7 +146,14 @@ public class VolumeRenderer extends VisualizationModule
@Override
public void parameterChanged(String name)
{
outCroppedField = true;
switch (name) {
case OUTPUT:
outCroppedField = true;
break;
case RESOLUTION:
in = null;
break;
}
startAction();
}
});
......@@ -355,7 +374,18 @@ public class VolumeRenderer extends VisualizationModule
setOutputValue("croppedField", new VNRegularField(outField));
return;
}
RegularField in = ((VNRegularField) getInputFirstValue("inField")).getField();
Field rawIn = ((VNField) getInputFirstValue("inField")).getField();
if (rawIn != rawInField || in == null) {
rawInField = rawIn;
ui.setVisibleResSlider(rawIn.hasCoords());
if (rawInField.hasCoords()){
inCoords = new FloatLargeArray(ConvexHullCore.convexHullCoords(rawIn));
outAffine = OptimizedBox.optimizeInitBox(inCoords, 3, null);
in = RegularInterpolation.interpolate(rawInField, outAffine, params.getResolution());
}
else
in = ((VNRegularField) getInputFirstValue("inField")).getField();
}
if (in == null) {
clearAll();
return;
......
......@@ -2,11 +2,10 @@
<module name="volume renderer" class="VolumeRenderer">
<inputs>
<input name="inField" type="pl.edu.icm.visnow.lib.types.VNRegularField" modifiers="NECESSARY:TRIGGERING">
<input name="inField" type="pl.edu.icm.visnow.lib.types.VNField" modifiers="NECESSARY:TRIGGERING">
<description value="Input for volume data to render"/>
<acceptor>
<param name="NDIMS" value="3"/>
<param name="AFFINE" value="true"/>
<param name="TRUENSPACE" value="3"/>
<param name="LARGE" value="true"/>
</acceptor>
</input>
......
......@@ -207,17 +207,14 @@ public class ComponentSubrangeUI extends ComponentFeatureUI
if (param != null) {
symmetricBox.setSelected(false);
updateSymmetricUI();
float physMin = param.getComponentPhysMin();
float physMax = param.getComponentPhysMax();
float physD = .01f * (physMax - physMin);
rangeSlider.setMinMax(physMin - physD, physMax + physD);
rangeSlider.setMinMax(param.getComponentPhysMin(), param.getComponentPhysMax());
float maxV = Math.max(Math.abs(rangeSlider.getMin()), Math.abs(rangeSlider.getMin()));
symmetricRangeSlider.setMax(maxV);
if (logBox.isSelected())
symmetricRangeSlider.setMin(maxV / 1e-4f);
else
symmetricRangeSlider.setMin(0);
param.setLowUp(physMin - physD, physMax + physD);
}
userUpdate = true;
}
......@@ -226,17 +223,14 @@ public class ComponentSubrangeUI extends ComponentFeatureUI
{
userUpdate = false;
{
float physMin = param.getComponentPhysMin();
float physMax = param.getComponentPhysMax();
float physD = .01f * (physMax - physMin);
if (symmetricBox.isSelected()) {
float maxV = Math.max(Math.abs(physMin - physD), Math.abs(physMax + physD));
float maxV = Math.max(Math.abs(param.getPhysicalLow()), Math.abs(param.getPhysicalUp()));
symmetricRangeSlider.setValue(maxV);
rangeSlider.setLow(Math.max(-maxV, rangeSlider.getMin()));
rangeSlider.setUp(Math.min(maxV, rangeSlider.getMax()));
} else {
rangeSlider.setLow(physMin - physD);
rangeSlider.setUp(physMax + physD);
rangeSlider.setLow(param.getPhysicalLow());
rangeSlider.setUp(param.getPhysicalUp());
}
}
userUpdate = true;
......