Commit 610bcda4 authored by Radek Ošlejšek's avatar Radek Ošlejšek
Browse files

Basic functional curvature panel

parent 82c73c70
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -134,7 +134,7 @@ public class ControlPanelBuilder {
        JLabel label = new JLabel(caption);
        label.setFont(CAPTION_FONT);
        controlPanel.add(label, c);
        addLine();
        //addLine();
        return label;
    }
    
@@ -179,7 +179,7 @@ public class ControlPanelBuilder {
        input.setText("0");
        input.addActionListener(inputAction);
        addSliderWithVal(sliderMax, input);
        addLine();
        //addLine();
        return input;
    }
    
@@ -200,7 +200,7 @@ public class ControlPanelBuilder {
        }
        addOptionText((text == null) ? "" : text);
        JCheckBox cb = addCheckBox(selected, checkBoxAction);
        addLine();
        //addLine();
        return cb;
    }

+16 −3
Original line number Diff line number Diff line
package cz.fidentis.analyst.curvature;

import cz.fidentis.analyst.canvas.Canvas;
import cz.fidentis.analyst.mesh.core.MeshFacet;
import cz.fidentis.analyst.visitors.mesh.Curvature;
import java.awt.event.ActionEvent;
import java.util.List;
import java.util.Map;
import javax.swing.AbstractAction;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
@@ -16,6 +19,7 @@ import javax.swing.JToggleButton;
public class CurvatureAction extends AbstractAction {
    
    public static final String ACTION_COMMAND_SHOW_HIDE_PANEL = "show-hide curvature control panel";
    public static final String ACTION_COMMAND_SHOW_HIDE_HEATMAP = "show-hide heatmap";
    
    private final CurvaturePanel controlPanel;
    private final JTabbedPane topControlPanel;
@@ -46,13 +50,22 @@ public class CurvatureAction extends AbstractAction {
                if (((JToggleButton) ae.getSource()).isSelected()) {
                    topControlPanel.addTab(CurvaturePanel.NAME, CurvaturePanel.ICON, controlPanel);
                    topControlPanel.setSelectedComponent(controlPanel); // focus
                    if (curvatureVisitor == null) {
                        //canvas.getScene().getDrawableFace(0).getModel().compute(curvatureVisitor);
                    }
                } else {
                    topControlPanel.remove(controlPanel);
                }
                break;
            case ACTION_COMMAND_SHOW_HIDE_HEATMAP:
                if (((JToggleButton) ae.getSource()).isSelected()) {
                    if (curvatureVisitor == null) { // compute missing curvature
                        this.curvatureVisitor = new Curvature();
                        canvas.getScene().getDrawableFace(0).getModel().compute(curvatureVisitor);
                        canvas.getScene().getDrawableFace(0).setHeatMap(curvatureVisitor.getGaussianCurvatures());
                    }
                    canvas.getScene().getDrawableFace(0).setRenderHeatmap(true);
                } else {
                    canvas.getScene().getDrawableFace(0).setRenderHeatmap(false);
                }
                break;
            default:
                throw new UnsupportedOperationException(action);
        }
+17 −2
Original line number Diff line number Diff line
package cz.fidentis.analyst.curvature;

import cz.fidentis.analyst.core.ControlPanelBuilder;
import java.awt.event.ActionEvent;
import javax.swing.ImageIcon;

/**
@@ -13,9 +14,23 @@ public class CurvaturePanel extends javax.swing.JPanel {
    public static final ImageIcon ICON = new ImageIcon(CurvaturePanel.class.getClassLoader().getResource("/curvature28x28.png"));
    public static final String NAME = "Curvature";
    
    //private final JCheckBox showCurvature;
   
    public CurvaturePanel(CurvatureAction curvAction) {
        new ControlPanelBuilder(this)
                .addCaptionLine("TO DO");
        ControlPanelBuilder builder = new ControlPanelBuilder(this);
        
        builder.addCaptionLine("Visualization options:");
        builder.addLine();
        
        builder.addCheckBoxOptionLine(null, "Show symmetry plane", false, 
                (ActionEvent e) -> {
                    curvAction.actionPerformed(new ActionEvent(
                            e.getSource(), 
                            ActionEvent.ACTION_PERFORMED, 
                            CurvatureAction.ACTION_COMMAND_SHOW_HIDE_HEATMAP)
                    ); 
                });
        builder.addLine();
    }
    
}
+51 −1
Original line number Diff line number Diff line
package cz.fidentis.analyst.scene;

import com.jogamp.opengl.GL2;
import cz.fidentis.analyst.feature.FeaturePoint;
import cz.fidentis.analyst.mesh.core.MeshFacet;
import cz.fidentis.analyst.mesh.core.MeshModel;
import java.awt.Color;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Drawable human face.
@@ -19,6 +24,12 @@ public class DrawableFace extends DrawableMesh {
    private List<FeaturePoint> featurePoints = new ArrayList<>();
    private List<Color> featurePointsColor = new ArrayList<>();
    private boolean renderFeaturePoints = false;
    private boolean renderHeatMap = false;
    
    /**
     * Values at mesh vertices that are to be transferred to colors.
     */
    private Map<MeshFacet, List<Double>> heatmap = new HashMap<>();
    
    /**
     * Constructor. 
@@ -74,10 +85,49 @@ public class DrawableFace extends DrawableMesh {
    }

    /**
     * Sets if feature points should be renderred or not
     * Sets if feature points should be rendered or not
     * @param renderFeaturePoints 
     */
    public void setRenderFeaturePoints(boolean renderFeaturePoints) {
        this.renderFeaturePoints = renderFeaturePoints;
    }    

    /**
     * Sets new heatmap.
     * 
     * @param heatmap New heatmap
     */
    public void setHeatMap(Map<MeshFacet, List<Double>> heatmap) {
        this.heatmap = heatmap;
    }
    
    public Map<MeshFacet, List<Double>> getHeatMap() {
        return Collections.unmodifiableMap(heatmap);
    }
    
    /**
     * Sets if the heatmap should be rendered or not.
     * @param render The switch
     */
    public void setRenderHeatmap(boolean render) {
        this.renderHeatMap = render;
    }
    
    /**
     * Determines whether the heatmap is set to be rendered.
     * @return id the heatmap will be rendered
     */
    public boolean isHeatmapRendered() {
        return this.renderHeatMap;
    }
    
    @Override
    protected void renderObject(GL2 gl) {
        if (isHeatmapRendered()) {
            new HeatmapRenderer().drawMeshModel(gl, getModel(), heatmap);
        } else {
            super.renderObject(gl);
        }
    }
    
}
+1 −0
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@ public class DrawableMesh extends Drawable {
        gl.glMaterialfv(GL2.GL_FRONT_AND_BACK, GL2.GL_SPECULAR, highlights, 0);
    }
    
    @Override
    protected void renderObject(GL2 gl) {
        for (MeshFacet facet: getFacets()) {
            gl.glBegin(GL2.GL_TRIANGLES); //vertices are rendered as triangles
Loading