...
 
Commits (28)
This diff is collapsed.
......@@ -40,6 +40,7 @@
<core package="pl.edu.icm.visnow.lib.basic.testdata.TestIrregularFieldFlow"/>
<core package="pl.edu.icm.visnow.lib.basic.testdata.ColorCube"/>
<core package="pl.edu.icm.visnow.lib.basic.testdata.VNLogo"/>
<core package="pl.edu.icm.visnow.geometries.interactiveGlyphs.TestInteractiveGlyph"/>
</folder>
<folder name="utilities" autohelpfile="pl.edu.icm.visnow.lib.basic.utilities.help_folder.html" autosort="yes">
<core package="pl.edu.icm.visnow.lib.basic.filters.FieldCombiner"/>
......@@ -66,6 +67,7 @@
<core package="pl.edu.icm.visnow.lib.basic.filters.RegularToIrregularField"/>
<core package="pl.edu.icm.visnow.lib.basic.filters.Triangulation"/>
<core package="pl.edu.icm.visnow.lib.basic.filters.Boundaries"/>
<core package="pl.edu.icm.visnow.lib.basic.filters.ConvexHull"/>
<core package="pl.edu.icm.visnow.lib.basic.filters.ClearMaskedOutNodes"/>
<core package="pl.edu.icm.visnow.lib.basic.filters.GeometricCrop"/>
</folder>
......@@ -102,7 +104,7 @@
<core package="pl.edu.icm.visnow.lib.basic.mappers.Isosurface"/>
<core package="pl.edu.icm.visnow.lib.basic.mappers.Isovolume"/>
<core package="pl.edu.icm.visnow.lib.basic.mappers.LineSlice"/>
<core package="pl.edu.icm.visnow.lib.basic.mappers.SurfaceComponents"/>
<core package="pl.edu.icm.visnow.lib.basic.mappers.ConnectedComponents"/>
<core package="pl.edu.icm.visnow.lib.basic.mappers.VolumeRenderer"/>
<core package="pl.edu.icm.visnow.lib.basic.mappers.PlanarSlice"/>
<core package="pl.edu.icm.visnow.lib.basic.mappers.RegularFieldSlice"/>
......
......@@ -62,9 +62,6 @@ import pl.edu.icm.visnow.gui.widgets.SectionHeader;
*/
public class DataMappingGUI extends javax.swing.JPanel
{
private static final Logger LOGGER = Logger.getLogger(DataMappingGUI.class);
private boolean debug = VisNow.isDebug();
protected Field inField = null;
protected CellSet inCellSet = null;
protected DataMappingParams params = null;
......
......@@ -62,6 +62,7 @@ import pl.edu.icm.visnow.geometries.parameters.RegularField3DParams;
import pl.edu.icm.visnow.geometries.parameters.RenderingParams;
import pl.edu.icm.visnow.gui.icons.IconsContainer;
import pl.edu.icm.visnow.lib.utils.SwingInstancer;
import pl.edu.icm.visnow.system.main.VisNow;
/**
*
......@@ -858,7 +859,7 @@ public class RenderingGUI extends javax.swing.JPanel
private void toFrontBoxActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_toFrontBoxActionPerformed
{//GEN-HEADEREND:event_toFrontBoxActionPerformed
renderingParams.setSurfaceOffset(toFrontBox.isSelected() ? -1000000 : 0);
renderingParams.setSurfaceOffset(toFrontBox.isSelected() ? -1000000 : VisNow.get().getMainConfig().getRenderingSurfaceOffset());
}//GEN-LAST:event_toFrontBoxActionPerformed
private void imageBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_imageBoxActionPerformed
......
......@@ -59,28 +59,30 @@ public class BoxGlyph extends Glyph
super(params);
setName("box glyph");
type = BOX;
glyphVerts = new float[]{-1, -1, -1, -1, -1, 1,
1, -1, -1, 1, -1, 1,
1, 1, -1, 1, 1, 1,
-1, 1, -1, -1, 1, 1,
-1, -1, -1, 1, -1, -1,
-1, 1, -1, 1, 1, -1,
-1, 1, 1, 1, 1, 1,
-1, -1, 1, 1, -1, 1,
-1, -1, -1, -1, 1, -1,
1, -1, -1, 1, 1, -1,
1, -1, 1, 1, 1, 1,
-1, -1, 1, -1, 1, 1};
glyphVerts = new float[]{-1, -1, -1, -1, -1, 1,
1, -1, -1, 1, -1, 1,
1, 1, -1, 1, 1, 1,
-1, 1, -1, -1, 1, 1,
-1, -1, -1, 1, -1, -1,
-1, 1, -1, 1, 1, -1,
-1, 1, 1, 1, 1, 1,
-1, -1, 1, 1, -1, 1,
-1, -1, -1, -1, 1, -1,
1, -1, -1, 1, 1, -1,
1, -1, 1, 1, 1, 1,
-1, -1, 1, -1, 1, 1};
visibleWidgets = U_ROT_VIS | V_ROT_VIS | W_ROT_VIS |
U_RANGE_VIS | V_RANGE_VIS | W_RANGE_VIS;
U_TRANS_VIS | V_TRANS_VIS | W_TRANS_VIS |
U_RANGE_VIS | V_RANGE_VIS | W_RANGE_VIS |
SCALE_VIS | VOLUME_VIS;
params.setVisibleWidgets(visibleWidgets);
lines = new IndexedLineArray(24, GeometryArray.COORDINATES | GeometryArray.COLOR_3, 24);
lines.setCoordinateIndices(0, new int[] { 0, 1, 2, 3, 4, 5, 6, 7,
8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23 });
16, 17, 18, 19, 20, 21, 22, 23,});
lines.setColorIndices(0, new int[] { 0, 0, 0, 0, 0, 0, 0, 0,
1, 1, 1, 1, 1, 1, 1, 1,
2, 2, 2, 2, 2, 2, 2, 2 });
2, 2, 2, 2, 2, 2, 2, 2});
lines.setCapability(GeometryArray.ALLOW_COORDINATE_READ);
lines.setCapability(GeometryArray.ALLOW_COORDINATE_WRITE);
lines.setCapability(GeometryArray.ALLOW_COLOR_READ);
......@@ -89,6 +91,8 @@ public class BoxGlyph extends Glyph
lines.setColors(0, lineColors);
lineShape.addGeometry(lines);
glyphGroup.addChild(lineShape);
reper = new Reper3D(params);
addChild(reper);
}
@Override
......@@ -96,23 +100,34 @@ public class BoxGlyph extends Glyph
{
for (int i = 0; i < 3; i++) {
float c = params.center[i];
float u = params.uScale * params.u[i];
float v = params.vScale * params.v[i];
float w = params.wScale * params.w[i];
float u0 = params.uRange[0] * params.u[i];
float u1 = params.uRange[1] * params.u[i];
float v0 = params.vRange[0] * params.v[i];
float v1 = params.vRange[1] * params.v[i];
float w0 = params.wRange[0] * params.w[i];
float w1 = params.wRange[1] * params.w[i];
glyphVerts[ i] = glyphVerts[24 + i] = glyphVerts[48 + i] = c - u - v - w;
glyphVerts[ 3 + i] = glyphVerts[42 + i] = glyphVerts[66 + i] = c - u - v + w;
glyphVerts[ i] = glyphVerts[24 + i] = glyphVerts[48 + i] = c + u0 + v0 + w0;
glyphVerts[ 3 + i] = glyphVerts[42 + i] = glyphVerts[66 + i] = c + u0 + v0 + w1;
glyphVerts[ 6 + i] = glyphVerts[27 + i] = glyphVerts[54 + i] = c + u - v - w;
glyphVerts[ 9 + i] = glyphVerts[45 + i] = glyphVerts[60 + i] = c + u - v + w;
glyphVerts[ 6 + i] = glyphVerts[27 + i] = glyphVerts[54 + i] = c + u1 + v0 + w0;
glyphVerts[ 9 + i] = glyphVerts[45 + i] = glyphVerts[60 + i] = c + u1 + v0 + w1;
glyphVerts[12 + i] = glyphVerts[33 + i] = glyphVerts[57 + i] = c + u + v - w;
glyphVerts[15 + i] = glyphVerts[39 + i] = glyphVerts[63 + i] = c + u + v + w;
glyphVerts[12 + i] = glyphVerts[33 + i] = glyphVerts[57 + i] = c + u1 + v1 + w0;
glyphVerts[15 + i] = glyphVerts[39 + i] = glyphVerts[63 + i] = c + u1 + v1 + w1;
glyphVerts[18 + i] = glyphVerts[30 + i] = glyphVerts[51 + i] = c - u + v - w;
glyphVerts[21 + i] = glyphVerts[36 + i] = glyphVerts[69 + i] = c - u + v + w;
}
glyphVerts[18 + i] = glyphVerts[30 + i] = glyphVerts[51 + i] = c + u0 + v1 + w0;
glyphVerts[21 + i] = glyphVerts[36 + i] = glyphVerts[69 + i] = c + u0 + v1 + w1;
}
lines.setCoordinates(0, glyphVerts);
lines.setColors(0, lineColors);
float s = params.getScale();
if (showReper && reper.getParent() == null)
addChild(reper);
if (!showReper && reper.getParent() != null)
removeChild(reper);
if (reper.getParent() != null)
reper.update(new float[] {s, s, s});
}
}
......@@ -115,8 +115,8 @@ public class CircleGlyph extends Glyph
for (int i = 0; i < 3; i++) {
float c = params.center[i];
float u = params.scale * params.u[i];
float v = params.scale * params.v[i];
float u = params.glyphDim * params.u[i];
float v = params.glyphDim * params.v[i];
glyphVerts[12 * LOD + 3 + i] = c - u;
glyphVerts[12 * LOD + 6 + i] = c + u;
......
......@@ -80,6 +80,7 @@ abstract public class Glyph extends OpenBranchGroup
protected float[] lineColors = {0, .6f, .6f, .6f, .6f, 0, .6f, 0, .6f};
protected int visibleWidgets = W_ROT_VIS;
protected boolean useRadius = false;
protected boolean showReper = true;
abstract public void update();
......@@ -99,7 +100,7 @@ abstract public class Glyph extends OpenBranchGroup
lineApp.setColoringAttributes(colorAttr);
lineShape.setAppearance(lineApp);
transpAttr.setTransparencyMode(TransparencyAttributes.NICEST);
transpAttr.setTransparency(.8f);
transpAttr.setTransparency(.6f);
surfApp.setTransparencyAttributes(transpAttr);
addChild(glyphGroup);
}
......@@ -127,6 +128,11 @@ abstract public class Glyph extends OpenBranchGroup
{
return type;
}
public void setShowReper(boolean showReper) {
this.showReper = showReper;
update();
}
public void setParams(InteractiveGlyphParams params)
{
......
......@@ -118,7 +118,7 @@ public class InteractiveGlyph extends OpenBranchGroup
{
switch (type) {
case PLANE:
glyph = new PlaneGlyph(params, forceUseRadius);
glyph = new PlaneGlyph(params);
break;
case SPHERE:
glyph = new SphereGlyph(params);
......@@ -275,26 +275,29 @@ public class InteractiveGlyph extends OpenBranchGroup
{
float[] boxVerts;
float[] center = params.getCenter();
float[][] v = new float[3][3];
float[][][] v = new float[2][3][3];
for (int i = 0; i < 3; i++) {
v[0][i] = params.getuScale() * params.getU()[i];
v[1][i] = params.getvScale() * params.getV()[i];
v[2][i] = params.getwScale() * params.getW()[i];
v[0][0][i] = params.getuRange()[0] * params.getU()[i];
v[0][1][i] = params.getvRange()[0] * params.getV()[i];
v[0][2][i] = params.getwRange()[0] * params.getW()[i];
v[1][0][i] = params.getuRange()[1] * params.getU()[i];
v[1][1][i] = params.getvRange()[1] * params.getV()[i];
v[1][2][i] = params.getwRange()[1] * params.getW()[i];
}
if (trueDim == 3) {
boxVerts = new float[24];
for (int i = -1, m = 0; i < 2; i += 2)
for (int j = -1; j < 2; j+= 2)
for (int k = -1; k < 2; k += 2)
for (int i = 0, m = 0; i < 2; i++)
for (int j = 0; j < 2; j++)
for (int k = 0; k < 2; k++)
for (int l = 0; l < 3; l++, m++)
boxVerts[m] = center[l] + i * v[2][l] + j * v[1][l] + k * v[0][l];
boxVerts[m] = center[l] + v[i][0][l] + v[j][1][l] + v[k][2][l];
}
else {
boxVerts = new float[12];
for (int i = -1, m = 0; i < 2; i += 2)
for (int j = -1; j < 2; j+= 2)
for (int l = 0; l < 3; l++, m++)
boxVerts[m] = center[l] + i * v[1][l] + j * v[0][l];
for (int i = 0, m = 0; i < 2; i++)
for (int j = 0; j < 2; j++)
for (int l = 0; l < 3; l++, m++)
boxVerts[m] = center[l] + v[i][0][l] + v[j][1][l];
}
return boxVerts;
}
......
......@@ -61,7 +61,7 @@ public class LineGlyph extends Glyph
U_TRANS_VIS | V_TRANS_VIS | W_TRANS_VIS |
SCALE_VIS | AXES_VIS;
params.setVisibleWidgets(visibleWidgets);
reper = new Reper(params);
reper = new Reper3D(params);
addChild(reper);
}
......@@ -72,12 +72,12 @@ public class LineGlyph extends Glyph
setName("line glyph");
visibleWidgets = useRadius ? U_ROT_VIS | V_ROT_VIS | W_ROT_VIS |
U_TRANS_VIS | V_TRANS_VIS | W_TRANS_VIS |
SCALE_VIS | AXES_VIS | RADIUS_VIS
SCALE_VIS | AXES_VIS | RADIUS_VIS
: U_ROT_VIS | V_ROT_VIS | W_ROT_VIS |
U_TRANS_VIS | V_TRANS_VIS | W_TRANS_VIS |
SCALE_VIS | AXES_VIS;
params.setVisibleWidgets(visibleWidgets);
reper = new Reper(params);
reper = new Reper3D(params);
addChild(reper);
}
......@@ -90,9 +90,8 @@ public class LineGlyph extends Glyph
@Override
public void update()
{
float s = params.scale;
reper.update(params.center, .3f * s, .3f * s, s,
params.u, params.v, params.w);
float s = params.getScale();
reper.update(new float[]{.3f * s, .3f * s, s});
}
}
......@@ -121,8 +121,8 @@ public class PlanarLineGlyph extends Glyph
lineColors[3 * i + j] = currentColors[i + 1][j];
for (int i = 0; i < 3; i++) {
float c = params.center[i];
float u = params.scale * params.u[i];
float v = params.scale * params.v[i];
float u = params.glyphDim * params.u[i];
float v = params.glyphDim * params.v[i];
glyphVerts[i] = c - u;
glyphVerts[3 + i] = c + u;
......
......@@ -41,6 +41,7 @@
package pl.edu.icm.visnow.geometries.interactiveGlyphs;
import javax.media.j3d.GeometryArray;
import javax.media.j3d.IndexedLineArray;
import javax.media.j3d.IndexedQuadArray;
import static pl.edu.icm.visnow.geometries.interactiveGlyphs.InteractiveGlyph.GlyphType.PLANE;
import static pl.edu.icm.visnow.geometries.interactiveGlyphs.InteractiveGlyphParams.*;
......@@ -61,51 +62,19 @@ public class PlaneGlyph extends Glyph
public PlaneGlyph(InteractiveGlyphParams params)
{
super(params);
reper = new Reper(params);
reper = new Reper3D(params);
type = PLANE;
setName("plane glyph");
params.setRadiusSliderTitle("planar area dimension (in % of field size)");
visibleWidgets = U_ROT_VIS | V_ROT_VIS | W_ROT_VIS |
U_TRANS_VIS | V_TRANS_VIS | W_TRANS_VIS |
U_RANGE_VIS | V_RANGE_VIS |
SCALE_VIS | AXES_VIS;
params.setVisibleWidgets(visibleWidgets);
glyphVerts = new float[] {-1, -1, 0,
1, -1, 0,
1, 1, 0,
-1, 1, 0,
0, 0, 0,
0, 0, 1.5f};
glyphRects = new IndexedQuadArray(4, GeometryArray.COORDINATES, 4);
glyphRects.setCoordinateIndices(0, new int[] {0, 1, 2, 3});
glyphRects.setCapability(GeometryArray.ALLOW_COORDINATE_READ);
glyphRects.setCapability(GeometryArray.ALLOW_COORDINATE_WRITE);
glyphRects.setCoordinates(0, planeVerts);
surfShape.setAppearance(surfApp);
surfShape.addGeometry(glyphRects);
glyphGroup.addChild(surfShape);
currentColors = params.getCurrentColors();
addChild(reper);
}
public PlaneGlyph(InteractiveGlyphParams params, boolean useRadius)
{
super(params, useRadius);
reper = new Reper(params);
type = PLANE;
setName("plane glyph");
visibleWidgets = useRadius ? U_ROT_VIS | V_ROT_VIS | W_ROT_VIS |
U_TRANS_VIS | V_TRANS_VIS | W_TRANS_VIS |
SCALE_VIS | AXES_VIS | RADIUS_VIS
: U_ROT_VIS | V_ROT_VIS | W_ROT_VIS |
U_TRANS_VIS | V_TRANS_VIS | W_TRANS_VIS |
SCALE_VIS | AXES_VIS;
params.setVisibleWidgets(visibleWidgets);
glyphVerts = new float[] {-1, -1, 0,
1, -1, 0,
1, 1, 0,
-1, 1, 0,
0, 0, 0,
0, 0, 1.5f};
glyphVerts = new float[] {-1, -1, 0, -1, 1, 0,
1, -1, 0, 1, 1, 0,
-1, -1, 0, 1, -1, 0,
-1, 1, 0, 1, 1, 0};
glyphRects = new IndexedQuadArray(4, GeometryArray.COORDINATES, 4);
glyphRects.setCoordinateIndices(0, new int[] {0, 1, 2, 3});
glyphRects.setCapability(GeometryArray.ALLOW_COORDINATE_READ);
......@@ -114,6 +83,17 @@ public class PlaneGlyph extends Glyph
surfShape.setAppearance(surfApp);
surfShape.addGeometry(glyphRects);
glyphGroup.addChild(surfShape);
lines = new IndexedLineArray(8, GeometryArray.COORDINATES | GeometryArray.COLOR_3, 8);
lines.setCoordinateIndices(0, new int[] { 0, 1, 2, 3, 4, 5, 6, 7});
lines.setColorIndices(0, new int[] { 2, 2, 2, 2, 1, 1, 1, 1});
lines.setCapability(GeometryArray.ALLOW_COORDINATE_READ);
lines.setCapability(GeometryArray.ALLOW_COORDINATE_WRITE);
lines.setCapability(GeometryArray.ALLOW_COLOR_READ);
lines.setCapability(GeometryArray.ALLOW_COLOR_WRITE);
lines.setCoordinates(0, glyphVerts);
lines.setColors(0, lineColors);
lineShape.addGeometry(lines);
glyphGroup.addChild(lineShape);
currentColors = params.getCurrentColors();
addChild(reper);
}
......@@ -129,20 +109,23 @@ public class PlaneGlyph extends Glyph
{
for (int i = 0; i < 3; i++) {
float c = params.center[i];
float u = params.scale * params.u[i];
float v = params.scale * params.v[i];
if (useRadius) {
u = params.radius * params.u[i];
v = params.radius * params.v[i];
}
planeVerts[i] = c - u - v;
planeVerts[3 + i] = c + u - v;
planeVerts[6 + i] = c + u + v;
planeVerts[9 + i] = c - u + v;
float u0 = params.uRange[0] * params.u[i];
float u1 = params.uRange[1] * params.u[i];
float v0 = params.vRange[0] * params.v[i];
float v1 = params.vRange[1] * params.v[i];
planeVerts[i] = c + u0 + v0;
planeVerts[3 + i] = c + u1 + v0;
planeVerts[6 + i] = c + u1 + v1;
planeVerts[9 + i] = c + u0 + v1;
glyphVerts[ i] = glyphVerts[12 + i] = c + u0 + v0;
glyphVerts[ 3 + i] = glyphVerts[18 + i] = c + u0 + v1;
glyphVerts[ 6 + i] = glyphVerts[15 + i] = c + u1 + v0;
glyphVerts[ 9 + i] = glyphVerts[21 + i] = c + u1 + v1;
}
glyphRects.setCoordinates(0, planeVerts);
float s = params.scale;
reper.update(params.center, .3f * s, .3f * s, .6f * s,
params.u, params.v, params.w);
lines.setCoordinates(0, glyphVerts);
float s = params.getScale();
reper.update(new float[]{.3f * s, .3f * s, s});
}
}
......@@ -40,8 +40,6 @@
package pl.edu.icm.visnow.geometries.interactiveGlyphs;
import javax.media.j3d.GeometryArray;
import javax.media.j3d.IndexedLineArray;
import static pl.edu.icm.visnow.geometries.interactiveGlyphs.InteractiveGlyph.GlyphType.POINT;
import static pl.edu.icm.visnow.geometries.interactiveGlyphs.InteractiveGlyphParams.*;
......@@ -62,7 +60,7 @@ public class PointGlyph extends Glyph
visibleWidgets = U_ROT_VIS | V_ROT_VIS | W_ROT_VIS |
U_TRANS_VIS | V_TRANS_VIS | W_TRANS_VIS |
SCALE_VIS;
reper = new Reper(params);
reper = new Reper3D(params);
addChild(reper);
params.setVisibleWidgets(visibleWidgets);
}
......@@ -70,8 +68,6 @@ public class PointGlyph extends Glyph
@Override
public final void update()
{
float s = .3f * params.scale;
reper.update(params.center, s, s, s,
params.u, params.v, params.w);
reper.update();
}
}
......@@ -60,7 +60,10 @@ public class RectangleGlyph extends Glyph
super(params);
type = RECTANGLE;
setName("rectangle glyph");
visibleWidgets = W_ROT_VIS | U_RANGE_VIS | V_RANGE_VIS;
visibleWidgets = W_ROT_VIS |
U_TRANS_VIS | V_TRANS_VIS |
U_RANGE_VIS | V_RANGE_VIS |
SCALE_VIS | VOLUME_VIS;
params.setVisibleWidgets(visibleWidgets);
glyphVerts = new float[] {-1, -1, 0, -1, 1, 0,
1, -1, 0, 1, 1, 0,
......@@ -77,6 +80,8 @@ public class RectangleGlyph extends Glyph
lines.setColors(0, lineColors);
lineShape.addGeometry(lines);
glyphGroup.addChild(lineShape);
reper = new Reper2D(params);
addChild(reper);
}
@Override
......@@ -84,15 +89,26 @@ public class RectangleGlyph extends Glyph
{
for (int i = 0; i < 2; i++) {
float c = params.center[i];
float u = params.uScale * params.u[i];
float v = params.vScale * params.v[i];
glyphVerts[ i] = glyphVerts[12 + i] = c - u - v;
glyphVerts[ 3 + i] = glyphVerts[18 + i] = c - u + v;
glyphVerts[ 6 + i] = glyphVerts[15 + i] = c + u - v;
glyphVerts[ 9 + i] = glyphVerts[21 + i] = c + u + v;
float u0 = params.uRange[0] * params.u[i];
float u1 = params.uRange[1] * params.u[i];
float v0 = params.vRange[0] * params.v[i];
float v1 = params.vRange[1] * params.v[i];
glyphVerts[ i] = glyphVerts[12 + i] = c + u0 + v0;
glyphVerts[ 3 + i] = glyphVerts[18 + i] = c + u0 + v1;
glyphVerts[ 6 + i] = glyphVerts[15 + i] = c + u1 + v0;
glyphVerts[ 9 + i] = glyphVerts[21 + i] = c + u1 + v1;
System.arraycopy(currentColors[2 - i], 0, lineColors, 3 * i, 3);
}
lines.setCoordinates(0, glyphVerts);
lines.setColors(0, lineColors);
float s = params.getScale();
if (showReper && reper.getParent() == null)
addChild(reper);
if (!showReper && reper.getParent() != null)
removeChild(reper);
if (reper.getParent() != null)
reper.update(new float[] {s, s, s});
}
}
......@@ -40,7 +40,6 @@
package pl.edu.icm.visnow.geometries.interactiveGlyphs;
import javax.media.j3d.GeometryArray;
import javax.media.j3d.IndexedLineStripArray;
import pl.edu.icm.visnow.geometries.objects.generics.OpenBranchGroup;
import pl.edu.icm.visnow.geometries.objects.generics.OpenShape3D;
......@@ -51,40 +50,28 @@ import pl.edu.icm.visnow.geometries.objects.generics.OpenShape3D;
* Warsaw University, Interdisciplinary Centre
* for Mathematical and Computational Modelling)
*/
public class Reper extends OpenBranchGroup
abstract public class Reper extends OpenBranchGroup
{
protected IndexedLineStripArray glyphLines =
new IndexedLineStripArray(15,
GeometryArray.COORDINATES | GeometryArray.COLOR_3,
18, new int[] {3, 3, 3, 3, 3, 3});
protected OpenShape3D lineShape = new OpenShape3D("lines");
protected float[] glyphVerts = new float[45];
protected InteractiveGlyphParams params;
protected IndexedLineStripArray glyphLines;
protected OpenShape3D lineShape = new OpenShape3D("lines");
protected float[] scale;
protected float[] glyphVerts;
protected float[][] currentColors = InteractiveGlyphParams.LIGHT_COLORS;
protected float[] lineColors = {0, .6f, .6f, .6f, .6f, 0, .6f, 0, .6f};
public Reper(InteractiveGlyphParams params)
{
super();
glyphVerts = new float[45];
update(new float[]{0, 0, 0}, 1, 1, 1,
new float[]{1, 0, 0}, new float[]{0, 1, 0}, new float[]{0, 0, 1});
glyphLines.setCoordinateIndices(0, new int[] {0, 1, 2, 3, 1, 4,
5, 6, 7, 8, 6, 9,
10, 11, 12, 13, 11, 14});
glyphLines.setColorIndices(0, new int[] {0, 0, 0, 0, 0, 0,
1, 1, 1, 1, 1, 1,
2, 2, 2, 2, 2, 2});
glyphLines.setCapability(GeometryArray.ALLOW_COORDINATE_READ);
glyphLines.setCapability(GeometryArray.ALLOW_COORDINATE_WRITE);
glyphLines.setCapability(GeometryArray.ALLOW_COLOR_READ);
glyphLines.setCapability(GeometryArray.ALLOW_COLOR_WRITE);
glyphLines.setCoordinates(0, glyphVerts);
glyphLines.setColors(0, lineColors);
lineShape.addGeometry(glyphLines);
addChild(lineShape);
currentColors = params.getCurrentColors();
for (int i = 0; i < 3; i++)
System.arraycopy(currentColors[(i + 1) % 3], 0, lineColors, 3 * i, 3);
this.params = params;
scale = new float[] {1, 1, 1};
}
public Reper(InteractiveGlyphParams params, float[] scale)
{
super();
this.params = params;
this.scale = scale;
}
public void updateColors(float[][] currentColors)
......@@ -93,32 +80,10 @@ public class Reper extends OpenBranchGroup
System.arraycopy(currentColors[(i + 1) % 3], 0, lineColors, 3 * i, 3);
}
private void addArrow(float[] center, float scale,
float[] uu, float[] vv, float[] ww, int s)
{
float t = (float)Math.sqrt(3) * .05f;
for (int i = 0; i < 3; i++) {
float c = center[i];
float u = scale * uu[i];
float v = scale * vv[i];
float w = scale * ww[i];
glyphVerts[s + i] = c - u;
glyphVerts[s + 3 + i] = c + u;
glyphVerts[s + 6 + i] = c + .85f * u + .07f * v;
glyphVerts[s + 9 + i] = c + .85f * u - .035f * v - t * w;
glyphVerts[s + 12 + i] = c + .85f * u - .035f * v + t * w;
}
}
abstract public void update(float[] scale);
public void update(float[] center,
float scaleU, float scaleV, float scaleW,
float[] uu, float[] vv, float[] ww)
public final void update()
{
float[][] r = new float[][] {uu, vv, ww};
float[] scale = new float[] {scaleU, scaleV, scaleW};
for (int i = 0; i < 3; i++)
addArrow(center, scale[i], r[i], r[(i + 1) % 3], r[(i + 2) % 3], 15 * i);
glyphLines.setCoordinates(0, glyphVerts);
glyphLines.setColors(0, lineColors);
update(scale);
}
}
//<editor-fold defaultstate="collapsed" desc=" COPYRIGHT AND LICENSE ">
/* VisNow
Copyright (C) 2006-2013 University of Warsaw, ICM
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
University of Warsaw, Interdisciplinary Centre for Mathematical and
Computational Modelling, Pawinskiego 5a, 02-106 Warsaw, Poland.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
//</editor-fold>
package pl.edu.icm.visnow.geometries.interactiveGlyphs;
import javax.media.j3d.GeometryArray;
import javax.media.j3d.IndexedLineStripArray;
/**
*
* @author know (Krzysztof S. Nowinski (know@icm.edu.pl)
* Warsaw University, Interdisciplinary Centre
* for Mathematical and Computational Modelling)
*/
public class Reper2D extends Reper
{
public Reper2D(InteractiveGlyphParams params)
{
super(params);
glyphVerts = new float[24];
glyphLines = new IndexedLineStripArray(8, GeometryArray.COORDINATES | GeometryArray.COLOR_3,
10, new int[] {2, 3, 2, 3});
update();
glyphLines.setCoordinateIndices(0, new int[] {0, 1, 2, 1, 3,
4, 5, 6, 5, 7});
glyphLines.setColorIndices(0, new int[] {0, 0, 0, 0, 0,
1, 1, 1, 1, 1});
glyphLines.setCapability(GeometryArray.ALLOW_COORDINATE_READ);
glyphLines.setCapability(GeometryArray.ALLOW_COORDINATE_WRITE);
glyphLines.setCapability(GeometryArray.ALLOW_COLOR_READ);
glyphLines.setCapability(GeometryArray.ALLOW_COLOR_WRITE);
glyphLines.setCoordinates(0, glyphVerts);
glyphLines.setColors(0, lineColors);
lineShape.addGeometry(glyphLines);
addChild(lineShape);
currentColors = params.getCurrentColors();
for (int i = 0; i < 3; i++)
System.arraycopy(currentColors[(i + 1) % 3], 0, lineColors, 3 * i, 3);
}
private void addArrow(float[] center, float scale,
float[] uu, float[] vv, int s)
{
for (int i = 0; i < 3; i++) {
float c = center[i];
float u = scale * uu[i];
float v = scale * vv[i];
glyphVerts[s + i] = c - u;
glyphVerts[s + 3 + i] = c + u;
glyphVerts[s + 6 + i] = c + .85f * u - .07f * v;
glyphVerts[s + 9 + i] = c + .85f * u + .07f * v;
}
}
public final void update(float[] scale)
{
float[][] r = new float[][] {params.getU(), params.getV()};
for (int i = 0; i < 2; i++)
addArrow(params.getCenter(), scale[i], r[i], r[(i + 1) % 2], 12 * i);
glyphLines.setCoordinates(0, glyphVerts);
glyphLines.setColors(0, lineColors);
}
}
//<editor-fold defaultstate="collapsed" desc=" COPYRIGHT AND LICENSE ">
/* VisNow
Copyright (C) 2006-2013 University of Warsaw, ICM
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
University of Warsaw, Interdisciplinary Centre for Mathematical and
Computational Modelling, Pawinskiego 5a, 02-106 Warsaw, Poland.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
//</editor-fold>
package pl.edu.icm.visnow.geometries.interactiveGlyphs;
import javax.media.j3d.GeometryArray;
import javax.media.j3d.IndexedLineStripArray;
/**
*
* @author know (Krzysztof S. Nowinski (know@icm.edu.pl)
* Warsaw University, Interdisciplinary Centre
* for Mathematical and Computational Modelling)
*/
public class Reper3D extends Reper
{
public Reper3D(InteractiveGlyphParams params)
{
super(params);
glyphVerts = new float[45];
glyphLines = new IndexedLineStripArray(15, GeometryArray.COORDINATES | GeometryArray.COLOR_3,
18, new int[] {3, 3, 3, 3, 3, 3});
update();
glyphLines.setCoordinateIndices(0, new int[] {0, 1, 2, 3, 1, 4,
5, 6, 7, 8, 6, 9,
10, 11, 12, 13, 11, 14});
glyphLines.setColorIndices(0, new int[] {0, 0, 0, 0, 0, 0,
1, 1, 1, 1, 1, 1,
2, 2, 2, 2, 2, 2});
glyphLines.setCapability(GeometryArray.ALLOW_COORDINATE_READ);
glyphLines.setCapability(GeometryArray.ALLOW_COORDINATE_WRITE);
glyphLines.setCapability(GeometryArray.ALLOW_COLOR_READ);
glyphLines.setCapability(GeometryArray.ALLOW_COLOR_WRITE);
glyphLines.setCoordinates(0, glyphVerts);
glyphLines.setColors(0, lineColors);
lineShape.addGeometry(glyphLines);
addChild(lineShape);
currentColors = params.getCurrentColors();
for (int i = 0; i < 3; i++)
System.arraycopy(currentColors[(i + 1) % 3], 0, lineColors, 3 * i, 3);
}
private void addArrow(float[] center, float scale,
float[] uu, float[] vv, float[] ww, int s)
{
float t = (float)Math.sqrt(3) * .05f;
for (int i = 0; i < 3; i++) {
float c = center[i];
float u = scale * uu[i];
float v = scale * vv[i];
float w = scale * ww[i];
glyphVerts[s + i] = c - u;
glyphVerts[s + 3 + i] = c + u;
glyphVerts[s + 6 + i] = c + .85f * u + .07f * v;
glyphVerts[s + 9 + i] = c + .85f * u - .035f * v - t * w;
glyphVerts[s + 12 + i] = c + .85f * u - .035f * v + t * w;
}
}
@Override
public final void update(float[] scale)
{
float[][] r = new float[][] {params.getU(), params.getV(), params.getW()};
for (int i = 0; i < 3; i++)
addArrow(params.getCenter(), scale[i], r[i], r[(i + 1) % 3], r[(i + 2) % 3], 15 * i);
glyphLines.setCoordinates(0, glyphVerts);
glyphLines.setColors(0, lineColors);
}
}
......@@ -68,11 +68,12 @@ public class SphereGlyph extends Glyph
public SphereGlyph(InteractiveGlyphParams params)
{
super(params);
reper = new Reper(params);
reper = new Reper3D(params);
type = SPHERE;
setName("sphere glyph");
visibleWidgets = U_ROT_VIS | V_ROT_VIS | W_ROT_VIS | RADIUS_VIS |
U_TRANS_VIS | V_TRANS_VIS | W_TRANS_VIS | SCALE_VIS;
visibleWidgets = U_ROT_VIS | V_ROT_VIS | W_ROT_VIS |
U_TRANS_VIS | V_TRANS_VIS | W_TRANS_VIS |
RADIUS_VIS | VOLUME_VIS | SCALE_VIS;
params.setVisibleWidgets(visibleWidgets);
params.setScaleSliderTitle("sphere radius (in % of field radius)");
if (!templateCreated) {
......@@ -170,6 +171,7 @@ public class SphereGlyph extends Glyph
surf.setNormalIndices(0, pntsIndex);
surfShape.setAppearance(surfApp);
surfShape.addGeometry(surf);
transpAttr.setTransparency(.8f);
glyphVerts = new float[12 * LOD * LOD];
glyphGroup.addChild(surfShape);
......@@ -180,7 +182,7 @@ public class SphereGlyph extends Glyph
@Override
public void update()
{
float s = .3f * params.scale;
float s = .3f * params.glyphDim;
float r = params.radius;
for (int i = 0; i < 3; i++) {
float c = params.center[i];
......@@ -188,8 +190,7 @@ public class SphereGlyph extends Glyph
glyphVerts[i + j] = r * templateVerts[i + j] + c;
}
surf.setCoordinates(0, glyphVerts);
reper.update(params.center, s, s, s,
params.u, params.v, params.w);
reper.update(new float[]{s, s, s});
}
public void print()
......
......@@ -68,7 +68,6 @@ public class TestInteractiveGlyph extends OutFieldVisualizationModule
protected Field inField = null;
protected int mergeCounter = 0;
protected GlyphType type;
protected InteractiveGlyph glyph;
protected InteractiveGlyphParams glyphParams;
......@@ -83,15 +82,15 @@ public class TestInteractiveGlyph extends OutFieldVisualizationModule
System.out.println("");
System.out.print(" u");
for (int i = 0; i < 3; i++)
System.out.printf(" %8.3f", glyphParams.getuScale() * glyphParams.getU()[i]);
System.out.printf(" %8.3f %8.3f ", glyphParams.getuRange()[0] * glyphParams.getU()[i], glyphParams.getuRange()[1] * glyphParams.getU()[i]);
System.out.println("");
System.out.print(" v");
for (int i = 0; i < 3; i++)
System.out.printf(" %8.3f", glyphParams.getvScale() * glyphParams.getV()[i]);
System.out.printf(" %8.3f %8.3f ", glyphParams.getvRange()[0] * glyphParams.getU()[i], glyphParams.getvRange()[1] * glyphParams.getU()[i]);
System.out.println("");
System.out.print(" w");
for (int i = 0; i < 3; i++)
System.out.printf(" %8.3f", glyphParams.getwScale() * glyphParams.getW()[i]);
System.out.printf(" %8.3f %8.3f ", glyphParams.getwRange()[0] * glyphParams.getU()[i], glyphParams.getwRange()[1] * glyphParams.getU()[i]);
System.out.println("");
}
};
......@@ -169,7 +168,7 @@ public class TestInteractiveGlyph extends OutFieldVisualizationModule
type = BOX;
if (inField.getTrueNSpace() == 2)
type = RECTANGLE;
glyph.setType(type);
}
glyphParams.setCoords(fieldCoords);
......
......@@ -2,7 +2,7 @@
<module name="interactive glyph" class="TestInteractiveGlyph">
<inputs>
<input name="inField" type="pl.edu.icm.visnow.lib.types.VNField">
<input name="inField" type="pl.edu.icm.visnow.lib.types.VNField" modifiers="NECESSARY:TRIGGERING">
</input>
</inputs>
<outputs>
......
......@@ -260,8 +260,10 @@ public class CellSetGeometry extends OpenBranchGroup
for (int m = Cell.getNProperCellTypesUpto1D(); m < Cell.getNProperCellTypesUpto2D(); m++) {
CellArray ar = cellSet.getBoundaryCellArray(CellType.getType(m));
if (ar == null)
if (ar == null || ar.getNCells() == 0 || ar.getDim() != 2)
continue;
if (ar.getCellNormals() == null)
createBoundaryCellNormals();
float[] cNormals = ar.getCellNormals().getData();
for (int i = 0; i < ar.getNCells(); i++) {
try {
......
......@@ -46,6 +46,8 @@ import javax.swing.event.ChangeListener;
import javax.vecmath.Color3f;
import pl.edu.icm.visnow.geometries.utils.transform.LocalToWindow;
import static org.apache.commons.math3.util.FastMath.*;
import static pl.edu.icm.visnow.geometries.parameters.FontParams.Decoration.*;
import static pl.edu.icm.visnow.geometries.parameters.FontParams.Position.*;
/**
*
......@@ -54,15 +56,107 @@ import static org.apache.commons.math3.util.FastMath.*;
public class FontParams
{
public enum Position
{
RADIAL ( 0, 0, 0, 0, 0, 0),
N ( 0, 1, 0, -1, 1, -1),
NE ( 1, 1, 1, -1, 1, -1),
E ( 1, 0, 1, 0, 1, -1),
SE ( 1, -1, 1, 1, 1, 1),
S ( 0, -1, 0, 1, 1, 1),
SW (-1, -1, -1, 1, -1, -1),
W (-1, 0, -1, 0, -1, -1),
NW (-1, 1, -1, -1, -1, -1),
AT_POINT( 0, 0, -1, -1, 0, 0) ;
private final int xShift;
private final int yShift;
private final int xFrameShift;
private final int yFrameShift;
private final int xEdgeShift;
private final int yEdgeShift;
private Position(int xShift, int yShift, int xFrameShift, int yFrameShift, int xEdgeShift, int yEdgeShift)
{
this.xShift = xShift;
this.yShift = yShift;
this.xFrameShift = xFrameShift;
this.yFrameShift = yFrameShift;
this.xEdgeShift = xEdgeShift;
this.yEdgeShift = yEdgeShift;
}
public int getxShift() {
return xShift;
}
public int getyShift() {
return yShift;
}
public int getxFrameShift() {
return xFrameShift;
}
public int getyFrameShift() {
return yFrameShift;
}
public int getxEdgeShift()
{
return xEdgeShift;
}
public int getyEdgeShift()
{
return yEdgeShift;
}
public static Position getPosition(float x, float y)
{
double phi = Math.atan2(y, x) / Math.PI;
if (phi < 0)
phi += 2;
int dir = (int)(4 * phi + .5);
if (dir >= 8)
dir = 0;
switch (dir) {
case 0:
return E;
case 1:
return NE;
case 2:
return N;
case 3:
return NW;
case 4:
return W;
case 5:
return SW;
case 6:
return S;
default:
return SE;
}
}
}
public enum Decoration {FRAME, EDGE, NONE}
private boolean threeDimensional = false;
private float size = .02f; //size of text glyps relative to the window size (2D) or field diameter (3d)
private float precision = 3; //precision of font model used for 3d fonts
private float font3DSize = 1;
private String fontName = "sans-serif";
private int fontSize = 12; //font size in pixels for 2d labels
private int fontSize = 15; //font size in pixels for 2d labels
private int fontType = Font.PLAIN;
private Color color = Color.WHITE;
private float colorCorrection = 1;
private Position position = RADIAL;
private Decoration decoration = FRAME;
private float opacity = .5f;
private float shift = 1f;
private Color bgColor = Color.BLACK;
public FontParams() {
}
......@@ -76,18 +170,16 @@ public class FontParams
this.color = color;
}
public void createFontMetrics(LocalToWindow localToWindow, int w, int h)
{
fontSize = max(5, (int) (h * size));
fontSize = max(7, (int) (h * size));
float z = localToWindow.transformPt(new double[]{0, 0, 0}, new int[2]);
float[] xl = localToWindow.reverseTransformPt(w / 2, (h - fontSize) / 2, z);
float[] xu = localToWindow.reverseTransformPt(w / 2, (h + fontSize) / 2, z);
font3DSize = (float) (sqrt((xu[0] - xl[0]) * (xu[0] - xl[0]) +
(xu[1] - xl[1]) * (xu[1] - xl[1]) +
(xu[2] - xl[2]) * (xu[2] - xl[2])));
(xu[1] - xl[1]) * (xu[1] - xl[1]) +
(xu[2] - xl[2]) * (xu[2] - xl[2])));
}
/**
......@@ -116,6 +208,27 @@ public class FontParams
fireStateChanged();
}
/**
* Get the value of bgColor
*
* @return the value of transparent background color
*/
public Color getBgColor()
{
return bgColor;
}
/**
* Set the value of bgColor
*
* @param bgColor new value of bgColor
*/
public void setBgColor(Color bgColor)
{
this.bgColor = bgColor;
fireStateChanged();
}
/**
* Set the value of fontType
*
......@@ -257,6 +370,93 @@ public class FontParams
fireStateChanged();
}