Loading GUI/src/main/java/cz/fidentis/analyst/scene/DrawableFeaturePoints.java +73 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,11 @@ public class DrawableFeaturePoints extends Drawable { */ private final Map<Integer, Double> specialSizes = new HashMap<>(); /** * feature points rendered differently than the default render mode */ private final Map<Integer, Integer> specialRenderModes = new HashMap<>(); /** * Constructor. * Loading Loading @@ -146,6 +151,65 @@ public class DrawableFeaturePoints extends Drawable { specialSizes.clear(); } /** * Returns render mode of the feature point. * * @param index Index of the feature point * @return The render mode or {@code null} */ public Integer getRenderMode(int index) { if (index < 0 || index >= featurePoints.size()) { return null; } if (specialRenderModes.containsKey(index)) { return specialRenderModes.get(index); } else { return getRenderMode(); } } /** * Sets render mode of the feature point. * The render mode must be {@link GL2#GL_FILL}, {@link GL2#GL_LINE} * or {@link GL2#GL_POINT}. * * @param index Index of the feature point * @param renderMode New render mode of the feature point * @throws IllegalArgumentException if renderMode isn't {@code GL_FILL}, * {@code GL_LINE} or {@code GL_POINT} */ public void setRenderMode(int index, int renderMode) { if (renderMode != GL2.GL_FILL && renderMode != GL2.GL_LINE && renderMode != GL2.GL_POINT) { throw new IllegalArgumentException("renderMode"); } if (index < 0 || index >= featurePoints.size()) { return; } if (renderMode == getRenderMode()) { specialRenderModes.remove(index); } else { specialRenderModes.put(index, renderMode); } } /** * Removes (possible) special render mode of the feature point. * * @param index Index of the feature point */ public void resetRenderModeToDefault(int index) { setRenderMode(index, getRenderMode()); } /** * Removes all individual render modes of feature points. */ public void resetAllRenderModesToDefault() { specialRenderModes.clear(); } @Override protected void renderObject(GL2 gl) { float[] rgba = { Loading @@ -158,12 +222,18 @@ public class DrawableFeaturePoints extends Drawable { for (int i = 0; i < featurePoints.size(); i++) { FeaturePoint fp = featurePoints.get(i); Color specialColor = specialColors.get(i); if (specialColor != null) { float[] tmpRGB = {specialColor.getRed() / 255f, specialColor.getGreen() / 255f, specialColor.getBlue() / 255f, getTransparency()}; gl.glMaterialfv(GL2.GL_FRONT_AND_BACK, GL2.GL_DIFFUSE, tmpRGB, 0); } Integer specialRenderMode = specialRenderModes.get(i); if (specialRenderMode != null) { gl.glPolygonMode(GL2.GL_FRONT_AND_BACK, specialRenderMode); } gl.glPushMatrix(); gl.glTranslated(fp.getX(), fp.getY(), fp.getZ()); GLUquadric center = GLU_CONTEXT.gluNewQuadric(); Loading @@ -177,6 +247,9 @@ public class DrawableFeaturePoints extends Drawable { if (specialColor != null) { gl.glMaterialfv(GL2.GL_FRONT_AND_BACK, GL2.GL_DIFFUSE, rgba, 0); // set default color } if (specialRenderMode != null) { gl.glPolygonMode(GL2.GL_FRONT_AND_BACK, getRenderMode()); // set default render mode } } } Loading Loading
GUI/src/main/java/cz/fidentis/analyst/scene/DrawableFeaturePoints.java +73 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,11 @@ public class DrawableFeaturePoints extends Drawable { */ private final Map<Integer, Double> specialSizes = new HashMap<>(); /** * feature points rendered differently than the default render mode */ private final Map<Integer, Integer> specialRenderModes = new HashMap<>(); /** * Constructor. * Loading Loading @@ -146,6 +151,65 @@ public class DrawableFeaturePoints extends Drawable { specialSizes.clear(); } /** * Returns render mode of the feature point. * * @param index Index of the feature point * @return The render mode or {@code null} */ public Integer getRenderMode(int index) { if (index < 0 || index >= featurePoints.size()) { return null; } if (specialRenderModes.containsKey(index)) { return specialRenderModes.get(index); } else { return getRenderMode(); } } /** * Sets render mode of the feature point. * The render mode must be {@link GL2#GL_FILL}, {@link GL2#GL_LINE} * or {@link GL2#GL_POINT}. * * @param index Index of the feature point * @param renderMode New render mode of the feature point * @throws IllegalArgumentException if renderMode isn't {@code GL_FILL}, * {@code GL_LINE} or {@code GL_POINT} */ public void setRenderMode(int index, int renderMode) { if (renderMode != GL2.GL_FILL && renderMode != GL2.GL_LINE && renderMode != GL2.GL_POINT) { throw new IllegalArgumentException("renderMode"); } if (index < 0 || index >= featurePoints.size()) { return; } if (renderMode == getRenderMode()) { specialRenderModes.remove(index); } else { specialRenderModes.put(index, renderMode); } } /** * Removes (possible) special render mode of the feature point. * * @param index Index of the feature point */ public void resetRenderModeToDefault(int index) { setRenderMode(index, getRenderMode()); } /** * Removes all individual render modes of feature points. */ public void resetAllRenderModesToDefault() { specialRenderModes.clear(); } @Override protected void renderObject(GL2 gl) { float[] rgba = { Loading @@ -158,12 +222,18 @@ public class DrawableFeaturePoints extends Drawable { for (int i = 0; i < featurePoints.size(); i++) { FeaturePoint fp = featurePoints.get(i); Color specialColor = specialColors.get(i); if (specialColor != null) { float[] tmpRGB = {specialColor.getRed() / 255f, specialColor.getGreen() / 255f, specialColor.getBlue() / 255f, getTransparency()}; gl.glMaterialfv(GL2.GL_FRONT_AND_BACK, GL2.GL_DIFFUSE, tmpRGB, 0); } Integer specialRenderMode = specialRenderModes.get(i); if (specialRenderMode != null) { gl.glPolygonMode(GL2.GL_FRONT_AND_BACK, specialRenderMode); } gl.glPushMatrix(); gl.glTranslated(fp.getX(), fp.getY(), fp.getZ()); GLUquadric center = GLU_CONTEXT.gluNewQuadric(); Loading @@ -177,6 +247,9 @@ public class DrawableFeaturePoints extends Drawable { if (specialColor != null) { gl.glMaterialfv(GL2.GL_FRONT_AND_BACK, GL2.GL_DIFFUSE, rgba, 0); // set default color } if (specialRenderMode != null) { gl.glPolygonMode(GL2.GL_FRONT_AND_BACK, getRenderMode()); // set default render mode } } } Loading