Skip to content
Snippets Groups Projects
Commit 6bb1fe5f authored by Daniel Schramm's avatar Daniel Schramm
Browse files

Action for the computation of weighted Hausdorff distance prepared

parent 956a7c84
No related branches found
No related tags found
No related merge requests found
...@@ -4,12 +4,14 @@ import cz.fidentis.analyst.canvas.Canvas; ...@@ -4,12 +4,14 @@ import cz.fidentis.analyst.canvas.Canvas;
import cz.fidentis.analyst.core.LoadedActionEvent; import cz.fidentis.analyst.core.LoadedActionEvent;
import cz.fidentis.analyst.core.ControlPanelAction; import cz.fidentis.analyst.core.ControlPanelAction;
import cz.fidentis.analyst.feature.FeaturePointType; import cz.fidentis.analyst.feature.FeaturePointType;
import cz.fidentis.analyst.mesh.core.MeshFacet;
import cz.fidentis.analyst.scene.DrawableFeaturePoints; import cz.fidentis.analyst.scene.DrawableFeaturePoints;
import cz.fidentis.analyst.visitors.face.HausdorffDistancePrioritized; import cz.fidentis.analyst.visitors.face.HausdorffDistancePrioritized;
import cz.fidentis.analyst.visitors.mesh.HausdorffDistance.Strategy; import cz.fidentis.analyst.visitors.mesh.HausdorffDistance.Strategy;
import java.awt.Color; import java.awt.Color;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import javax.swing.JComboBox; import javax.swing.JComboBox;
import javax.swing.JTabbedPane; import javax.swing.JTabbedPane;
...@@ -31,6 +33,7 @@ public class DistanceAction extends ControlPanelAction { ...@@ -31,6 +33,7 @@ public class DistanceAction extends ControlPanelAction {
private final Map<FeaturePointType, Double> featurePointTypes = new HashMap<>(); private final Map<FeaturePointType, Double> featurePointTypes = new HashMap<>();
private String strategy = DistancePanel.STRATEGY_POINT_TO_POINT; private String strategy = DistancePanel.STRATEGY_POINT_TO_POINT;
private boolean relativeDist = false; private boolean relativeDist = false;
private boolean weightedDist = false;
private final DistancePanel controlPanel; private final DistancePanel controlPanel;
...@@ -77,6 +80,8 @@ public class DistanceAction extends ControlPanelAction { ...@@ -77,6 +80,8 @@ public class DistanceAction extends ControlPanelAction {
case DistancePanel.ACTION_COMMAND_FEATURE_POINT_RESIZE: case DistancePanel.ACTION_COMMAND_FEATURE_POINT_RESIZE:
resizeFeaturePoint((LoadedActionEvent) ae); resizeFeaturePoint((LoadedActionEvent) ae);
break; break;
case DistancePanel.ACTION_COMMAND_WEIGHTED_DISTANCE:
this.weightedDist = ((JToggleButton) ae.getSource()).isSelected();
case DistancePanel.ACTION_COMMAND_WEIGHTED_DIST_RECOMPUTE: case DistancePanel.ACTION_COMMAND_WEIGHTED_DIST_RECOMPUTE:
this.visitor = null; // recompute this.visitor = null; // recompute
setHeatmap(); setHeatmap();
...@@ -109,9 +114,17 @@ public class DistanceAction extends ControlPanelAction { ...@@ -109,9 +114,17 @@ public class DistanceAction extends ControlPanelAction {
getSecondaryDrawableFace().getHumanFace().accept(visitor); getSecondaryDrawableFace().getHumanFace().accept(visitor);
} }
getSecondaryDrawableFace().setHeatMap(visitor.getDistances()); getSecondaryDrawableFace().setHeatMap(calculateHausdorffDistance());
} }
private Map<MeshFacet, List<Double>> calculateHausdorffDistance() {
if (weightedDist) {
// TODO Merge the map of distances with the map of priorities
}
return visitor.getDistances();
}
private void highlightFeaturePoint(LoadedActionEvent actionEvent) { private void highlightFeaturePoint(LoadedActionEvent actionEvent) {
final int index = (int) actionEvent.getData(); final int index = (int) actionEvent.getData();
final FeaturePointType fpType = getTypeOfFeaturePoint(index); final FeaturePointType fpType = getTypeOfFeaturePoint(index);
......
...@@ -35,6 +35,7 @@ public class DistancePanel extends ControlPanel { ...@@ -35,6 +35,7 @@ public class DistancePanel extends ControlPanel {
public static final String ACTION_COMMAND_SHOW_HIDE_HEATMAP = "show-hide heatmap"; public static final String ACTION_COMMAND_SHOW_HIDE_HEATMAP = "show-hide heatmap";
public static final String ACTION_COMMAND_SET_DISTANCE_STRATEGY = "set strategy"; public static final String ACTION_COMMAND_SET_DISTANCE_STRATEGY = "set strategy";
public static final String ACTION_COMMAND_RELATIVE_ABSOLUTE_DIST = "switch abosulte-relative distance"; public static final String ACTION_COMMAND_RELATIVE_ABSOLUTE_DIST = "switch abosulte-relative distance";
public static final String ACTION_COMMAND_WEIGHTED_DISTANCE = "switch weighted distance on/off";
public static final String ACTION_COMMAND_FEATURE_POINT_HIGHLIGHT = "highlight feature point with color"; public static final String ACTION_COMMAND_FEATURE_POINT_HIGHLIGHT = "highlight feature point with color";
public static final String ACTION_COMMAND_FEATURE_POINT_RESIZE = "set size of feature point"; public static final String ACTION_COMMAND_FEATURE_POINT_RESIZE = "set size of feature point";
public static final String ACTION_COMMAND_WEIGHTED_DIST_RECOMPUTE = "recompute weighted distance"; public static final String ACTION_COMMAND_WEIGHTED_DIST_RECOMPUTE = "recompute weighted distance";
...@@ -77,7 +78,7 @@ public class DistancePanel extends ControlPanel { ...@@ -77,7 +78,7 @@ public class DistancePanel extends ControlPanel {
null, null,
"Weighted Hausdorff distance", "Weighted Hausdorff distance",
false, false,
null // TODO implement action createListener(action, ACTION_COMMAND_WEIGHTED_DISTANCE)
); );
builder.addLine(); builder.addLine();
...@@ -115,9 +116,9 @@ public class DistancePanel extends ControlPanel { ...@@ -115,9 +116,9 @@ public class DistancePanel extends ControlPanel {
createListener(action, ACTION_COMMAND_WEIGHTED_DIST_RECOMPUTE) createListener(action, ACTION_COMMAND_WEIGHTED_DIST_RECOMPUTE)
); );
recomputeButton.setEnabled(false); recomputeButton.setEnabled(false);
recomputeButton.addActionListener((ActionEvent ae) -> { recomputeButton.addActionListener((ActionEvent ae) ->
recomputeButton.setEnabled(false); recomputeButton.setEnabled(false)
}); );
weightedDistChBx.addActionListener((ActionEvent ae) -> { weightedDistChBx.addActionListener((ActionEvent ae) -> {
if (!weightedDistChBx.isSelected()) { if (!weightedDistChBx.isSelected()) {
recomputeButton.setEnabled(false); recomputeButton.setEnabled(false);
...@@ -166,4 +167,5 @@ public class DistancePanel extends ControlPanel { ...@@ -166,4 +167,5 @@ public class DistancePanel extends ControlPanel {
public static ImageIcon getStaticIcon() { public static ImageIcon getStaticIcon() {
return new ImageIcon(SymmetryPanel.class.getClassLoader().getResource("/" + ICON)); return new ImageIcon(SymmetryPanel.class.getClassLoader().getResource("/" + ICON));
} }
} }
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