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