Commit 9b876a14 authored by Radek Ošlejšek's avatar Radek Ošlejšek
Browse files

Initiate cotnrol pannel correctly

parent 1ec96204
Loading
Loading
Loading
Loading
+16 −22
Original line number Diff line number Diff line
@@ -65,13 +65,7 @@ public class SymmetryAction extends ControlPanelAction<SymmetryPanel> implements
        setShowHideCode(
                () -> { // SHOW
                    // show point cloud:
                    if (getSecondaryFace() == null) { // single face analysis
                        primCloudSlot = drawPointSamples(
                                getCanvas().getScene().getPrimaryFaceSlot(), 
                                primCloudSlot, 
                                getControlPanel().getPointSamplingStrength1()
                        );
                    }
                    drawPrimaryPointSamples(getCanvas().getScene().getPrimaryFaceSlot(), getControlPanel().getPointSamplingStrength1());
                    //getCanvas().getScene().setDefaultColors();
                    getCanvas().getScene().showSymmetryPlane(getCanvas().getScene().getPrimaryFaceSlot(), true);
                    getCanvas().getScene().showSymmetryPlane(getCanvas().getScene().getSecondaryFaceSlot(), true);
@@ -87,6 +81,8 @@ public class SymmetryAction extends ControlPanelAction<SymmetryPanel> implements
                }
        );

        drawPrimaryPointSamples(getCanvas().getScene().getPrimaryFaceSlot(), getControlPanel().getPointSamplingStrength1());

        // Be informed about changes in faces perfomed by other GUI elements
        getPrimaryDrawableFace().getHumanFace().registerListener(this);
        if (getSecondaryDrawableFace() != null) {
@@ -112,15 +108,11 @@ public class SymmetryAction extends ControlPanelAction<SymmetryPanel> implements
                break;
            case SymmetryPanel.ACTION_COMMAND_POINT_SAMPLING_STRENGTH:
                int numSamples = (Integer) ((SpinSlider) ae.getSource()).getValue();
                if (getSecondaryFace() == null) { // single face analysis
                    primCloudSlot = drawPointSamples(getCanvas().getScene().getPrimaryFaceSlot(), primCloudSlot, numSamples);
                }
                drawPrimaryPointSamples(getCanvas().getScene().getPrimaryFaceSlot(), numSamples);
                //secCloudSlot = drawPointSamples(getCanvas().getScene().getSecondaryFaceSlot(), secCloudSlot, numSamples);
                break;
            case SymmetryPanel.ACTION_COMMAND_POINT_SAMPLING_STRATEGY:
                if (getSecondaryFace() == null) { // single face analysis
                    primCloudSlot = drawPointSamples(getCanvas().getScene().getPrimaryFaceSlot(), primCloudSlot, getControlPanel().getPointSamplingStrength1());
                }
                drawPrimaryPointSamples(getCanvas().getScene().getPrimaryFaceSlot(), getControlPanel().getPointSamplingStrength1());
                //secCloudSlot = drawPointSamples(getCanvas().getScene().getSecondaryFaceSlot(), secCloudSlot, controlPanel.getPointSamplingStrength());
                break;
            default:
@@ -252,10 +244,14 @@ public class SymmetryAction extends ControlPanelAction<SymmetryPanel> implements
        getControlPanel().updateHausdorffDistanceStats(visitor.getStats(), getFaces().getFace(0) == face);
    }

    private int drawPointSamples(int faceSlot, int cloudSlot, int numSamples) {
    private void drawPrimaryPointSamples(int faceSlot, int numSamples) {
        if (getSecondaryFace() != null) { // face-to-face analysis
            return;
        }

        HumanFace face = getFaces().getFace(faceSlot);
        if (face == null) {
            return -1;
            return;
        }                
        
        PointSampling sampling = getSamplingStrategy();
@@ -263,16 +259,14 @@ public class SymmetryAction extends ControlPanelAction<SymmetryPanel> implements
        face.getMeshModel().compute(sampling);
        
        if (sampling.getClass() == NoSampling.class) { // don't show
            if (cloudSlot != -1) {
                getScene().setOtherDrawable(cloudSlot, null);
            if (this.primCloudSlot != -1) {
                getScene().setOtherDrawable(this.primCloudSlot, null);
            }
            return -1;
        } else {
            if (cloudSlot == -1) {
                cloudSlot = getCanvas().getScene().getFreeSlotForFace();
            if (this.primCloudSlot == -1) {
                this.primCloudSlot = getCanvas().getScene().getFreeSlotForFace();
            }
            getScene().setOtherDrawable(cloudSlot, new DrawablePointCloud(sampling.getSamples()));
            return cloudSlot;
            getScene().setOtherDrawable(this.primCloudSlot, new DrawablePointCloud(sampling.getSamples()));
        }
    }