Skip to content
Snippets Groups Projects
Commit 6922bb8c authored by Radek Ošlejšek's avatar Radek Ošlejšek
Browse files

Merge branch '191-fix-error-in-feature-points-rendering' into 'master'

Resolve "Fix error in feature points rendering"

Closes #191

See merge request grp-fidentis/analyst2!210
parents 1882da95 2883b90b
No related branches found
No related tags found
No related merge requests found
package cz.fidentis.analyst.featurepoints; package cz.fidentis.analyst.featurepoints;
import cz.fidentis.analyst.Logger;
import cz.fidentis.analyst.canvas.Canvas; import cz.fidentis.analyst.canvas.Canvas;
import cz.fidentis.analyst.core.ControlPanelAction; import cz.fidentis.analyst.core.ControlPanelAction;
import cz.fidentis.analyst.core.DoubleSpinner; import cz.fidentis.analyst.core.DoubleSpinner;
import cz.fidentis.analyst.core.LoadedActionEvent; import cz.fidentis.analyst.core.LoadedActionEvent;
import static cz.fidentis.analyst.drawables.DrawableFeaturePoints.CLOSE_TO_MESH_COLOR;
import static cz.fidentis.analyst.drawables.DrawableFeaturePoints.OFF_THE_MESH_COLOR;
import static cz.fidentis.analyst.drawables.DrawableFeaturePoints.ON_THE_MESH_COLOR;
import cz.fidentis.analyst.events.HumanFaceEvent; import cz.fidentis.analyst.events.HumanFaceEvent;
import cz.fidentis.analyst.events.HumanFaceListener; import cz.fidentis.analyst.events.HumanFaceListener;
import cz.fidentis.analyst.feature.FeaturePoint; import cz.fidentis.analyst.feature.FeaturePoint;
...@@ -25,7 +29,6 @@ public class FeaturePointsAction extends ControlPanelAction implements HumanFace ...@@ -25,7 +29,6 @@ public class FeaturePointsAction extends ControlPanelAction implements HumanFace
/* /*
* GUI elements * GUI elements
*/ */
private FeaturePointType hoveredFeaturePoint = null;
private final FeaturePointsPanel controlPanel; private final FeaturePointsPanel controlPanel;
private List<FeaturePointType> selectedFeaturePoints = new ArrayList<>();; private List<FeaturePointType> selectedFeaturePoints = new ArrayList<>();;
...@@ -48,6 +51,9 @@ public class FeaturePointsAction extends ControlPanelAction implements HumanFace ...@@ -48,6 +51,9 @@ public class FeaturePointsAction extends ControlPanelAction implements HumanFace
// If the FeaturePoints panel is focused... // If the FeaturePoints panel is focused...
if (((JTabbedPane) e.getSource()).getSelectedComponent() instanceof FeaturePointsPanel) { if (((JTabbedPane) e.getSource()).getSelectedComponent() instanceof FeaturePointsPanel) {
getCanvas().getScene().setDefaultColors(); getCanvas().getScene().setDefaultColors();
setColorsOfFeaturePoints();
} else {
getPrimaryFeaturePoints().resetAllColorsToDefault();
} }
}); });
...@@ -77,7 +83,7 @@ public class FeaturePointsAction extends ControlPanelAction implements HumanFace ...@@ -77,7 +83,7 @@ public class FeaturePointsAction extends ControlPanelAction implements HumanFace
break; break;
case FeaturePointListPanel.ACTION_COMMAND_FEATURE_POINT_SELECT: case FeaturePointListPanel.ACTION_COMMAND_FEATURE_POINT_SELECT:
selectFeaturePoint((LoadedActionEvent) ae); selectFeaturePoint((LoadedActionEvent) ae);
highlightSelectedFeaturePoints(); setColorsOfFeaturePoints();
break; break;
case FeaturePointListPanel.ACTION_COMMAND_FEATURE_POINT_HOVER_IN: case FeaturePointListPanel.ACTION_COMMAND_FEATURE_POINT_HOVER_IN:
hoverFeaturePoint((LoadedActionEvent) ae, true); hoverFeaturePoint((LoadedActionEvent) ae, true);
...@@ -87,6 +93,7 @@ public class FeaturePointsAction extends ControlPanelAction implements HumanFace ...@@ -87,6 +93,7 @@ public class FeaturePointsAction extends ControlPanelAction implements HumanFace
break; break;
case FeaturePointsPanel.ACTION_CHANGE_DISTANCE_THRESHOLD: case FeaturePointsPanel.ACTION_CHANGE_DISTANCE_THRESHOLD:
changeDistanceThreshold(ae); changeDistanceThreshold(ae);
setColorsOfFeaturePoints();
break; break;
case FeaturePointsPanel.ACTION_PIN_ALL_FEATURE_POINTS: case FeaturePointsPanel.ACTION_PIN_ALL_FEATURE_POINTS:
for (FeaturePoint fp : getPrimaryFeaturePoints().getFeaturePoints()) { for (FeaturePoint fp : getPrimaryFeaturePoints().getFeaturePoints()) {
...@@ -94,10 +101,12 @@ public class FeaturePointsAction extends ControlPanelAction implements HumanFace ...@@ -94,10 +101,12 @@ public class FeaturePointsAction extends ControlPanelAction implements HumanFace
pinFeaturePointToMesh(fp); pinFeaturePointToMesh(fp);
} }
} }
setColorsOfFeaturePoints();
controlPanel.getFeaturePointListPanel().refreshPanel(this, getPrimaryFeaturePoints(), selectedFeaturePoints); controlPanel.getFeaturePointListPanel().refreshPanel(this, getPrimaryFeaturePoints(), selectedFeaturePoints);
break; break;
case FeaturePointsPanel.ACTION_PIN_SELECTED_FEATURE_POINTS: case FeaturePointsPanel.ACTION_PIN_SELECTED_FEATURE_POINTS:
workWithSelectedFp("pin"); workWithSelectedFp("pin");
setColorsOfFeaturePoints();
controlPanel.getFeaturePointListPanel().refreshPanel(this, getPrimaryFeaturePoints(), selectedFeaturePoints); controlPanel.getFeaturePointListPanel().refreshPanel(this, getPrimaryFeaturePoints(), selectedFeaturePoints);
break; break;
default: default:
...@@ -118,11 +127,9 @@ public class FeaturePointsAction extends ControlPanelAction implements HumanFace ...@@ -118,11 +127,9 @@ public class FeaturePointsAction extends ControlPanelAction implements HumanFace
private void hoverFeaturePoint(LoadedActionEvent actionEvent, boolean entered) { private void hoverFeaturePoint(LoadedActionEvent actionEvent, boolean entered) {
final int index = (int) actionEvent.getData(); final int index = (int) actionEvent.getData();
setColorsOfFeaturePoints();
if (entered) { // entering a feature point if (entered) { // entering a feature point
getPrimaryFeaturePoints().setColor(index, FEATURE_POINT_HOVER_COLOR); getPrimaryFeaturePoints().setColor(index, FEATURE_POINT_HOVER_COLOR);
hoveredFeaturePoint = getTypeOfFeaturePoint(index);
} else if (selectedFeaturePoints.contains(hoveredFeaturePoint)) { // leaving highlighted FP
getPrimaryFeaturePoints().setColor(index, FEATURE_POINT_HIGHLIGHT_COLOR);
} else { // leaving ordinary FP } else { // leaving ordinary FP
getPrimaryFeaturePoints().resetColorToDefault(index); getPrimaryFeaturePoints().resetColorToDefault(index);
} }
...@@ -159,16 +166,25 @@ public class FeaturePointsAction extends ControlPanelAction implements HumanFace ...@@ -159,16 +166,25 @@ public class FeaturePointsAction extends ControlPanelAction implements HumanFace
} }
} }
private void highlightSelectedFeaturePoints() { private void setColorsOfFeaturePoints() {
if (selectedFeaturePoints.isEmpty()) { List<FeaturePoint> fps = getPrimaryFeaturePoints().getFeaturePoints();
return; for (int i = 0; i < fps.size(); i++) {
}
for (int i = 0; i < getPrimaryFeaturePoints().getFeaturePoints().size(); i++) {
if (selectedFeaturePoints.contains(getTypeOfFeaturePoint(i))) { if (selectedFeaturePoints.contains(getTypeOfFeaturePoint(i))) {
getPrimaryFeaturePoints().setColor(i, FEATURE_POINT_HIGHLIGHT_COLOR); getPrimaryFeaturePoints().setColor(i, FEATURE_POINT_HIGHLIGHT_COLOR);
} else { } else {
getPrimaryFeaturePoints().resetColorToDefault(i); switch (fps.get(i).getRelationToMesh().getPositionType()) {
case ON_THE_MESH:
getPrimaryFeaturePoints().setColor(i, ON_THE_MESH_COLOR);
break;
case CLOSE_TO_MESH:
getPrimaryFeaturePoints().setColor(i, CLOSE_TO_MESH_COLOR);
break;
case OFF_THE_MESH:
getPrimaryFeaturePoints().setColor(i, OFF_THE_MESH_COLOR);
break;
default:
getPrimaryFeaturePoints().resetColorToDefault(i);
}
} }
} }
} }
......
...@@ -2,7 +2,9 @@ package cz.fidentis.analyst.featurepoints; ...@@ -2,7 +2,9 @@ package cz.fidentis.analyst.featurepoints;
import cz.fidentis.analyst.core.ControlPanel; import cz.fidentis.analyst.core.ControlPanel;
import cz.fidentis.analyst.drawables.DrawableFeaturePoints; import cz.fidentis.analyst.drawables.DrawableFeaturePoints;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import javax.swing.AbstractAction;
import javax.swing.ImageIcon; import javax.swing.ImageIcon;
/** /**
...@@ -73,7 +75,7 @@ public class FeaturePointsPanel extends ControlPanel { ...@@ -73,7 +75,7 @@ public class FeaturePointsPanel extends ControlPanel {
* Resets the slider into initial values * Resets the slider into initial values
*/ */
public void resetSlider() { public void resetSlider() {
thresholdSpinSlider.initDouble(0.1, 0.0, 0.2, 3); thresholdSpinSlider.initDouble(0.01, 0.0, 0.2, 3);
thresholdSpinSlider.addSpinnerListener(createListener(action, ACTION_CHANGE_DISTANCE_THRESHOLD)); thresholdSpinSlider.addSpinnerListener(createListener(action, ACTION_CHANGE_DISTANCE_THRESHOLD));
} }
......
...@@ -85,16 +85,7 @@ public class DrawableFeaturePoints extends Drawable { ...@@ -85,16 +85,7 @@ public class DrawableFeaturePoints extends Drawable {
if (specialColors.containsKey(index)) { if (specialColors.containsKey(index)) {
return specialColors.get(index); return specialColors.get(index);
} else { } else {
switch (featurePoints.get(index).getRelationToMesh().getPositionType()) { return FP_DEFAULT_COLOR;
case ON_THE_MESH:
return ON_THE_MESH_COLOR;
case CLOSE_TO_MESH:
return CLOSE_TO_MESH_COLOR;
case OFF_THE_MESH:
return OFF_THE_MESH_COLOR;
default:
return Color.BLACK;
}
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment