Commit f3ddcdb1 authored by Krzysztof Nowinski's avatar Krzysztof Nowinski

Volume renderer module accepts now all types of fields with 3D cells (e.g. bluntfin

regular, non-affine field, fields read by Fluent reader etc.) Volume rendering is created from the 
input field automatically interpolated to regular mesh.
This regular field can be cropped and "output cropped field" outputs cropped regular affine field.
parents 1cab3496 a2188599
......@@ -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>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment