From ba5c79839d464b8715b36deefd404bb826986719 Mon Sep 17 00:00:00 2001
From: Richard Pajersky <xpajersk@fi.muni.cz>
Date: Tue, 11 May 2021 10:15:48 +0200
Subject: [PATCH] Implemented custom feature points thershold

---
 .../gui/RegistrationCPEventListener.java      | 12 +++++++-
 .../analyst/gui/tab/PostRegistrationCP.form   | 25 +++++++++++++++-
 .../analyst/gui/tab/PostRegistrationCP.java   | 30 +++++++++++++++++--
 .../analyst/gui/tab/Bundle.properties         |  2 ++
 4 files changed, 64 insertions(+), 5 deletions(-)

diff --git a/GUI/src/main/java/cz/fidentis/analyst/gui/RegistrationCPEventListener.java b/GUI/src/main/java/cz/fidentis/analyst/gui/RegistrationCPEventListener.java
index 18e51504..587922d7 100644
--- a/GUI/src/main/java/cz/fidentis/analyst/gui/RegistrationCPEventListener.java
+++ b/GUI/src/main/java/cz/fidentis/analyst/gui/RegistrationCPEventListener.java
@@ -25,7 +25,6 @@ import javax.vecmath.Vector3d;
  */
 public class RegistrationCPEventListener {
     
-    private final double featurePointsThreshold = 0.1;
     private final Color defaultPrimaryColor = new Color(51, 51, 153);
     private final Color defaultSecondaryColor = new Color(255, 239, 0);
     private final int transparencyRange = 10;
@@ -38,6 +37,7 @@ public class RegistrationCPEventListener {
     
     private DrawableMesh primaryFace;
     private DrawableMesh secondaryFace;
+    private double featurePointsThreshold = 0.1;
     
     public RegistrationCPEventListener(Canvas canvas) {
         this.canvas = canvas;
@@ -358,4 +358,14 @@ public class RegistrationCPEventListener {
         calculateFeaturePoints();
         canvas.renderScene();
     }
+
+    public double getFeaturePointsThreshold() {
+        return featurePointsThreshold;
+    }
+
+    public void setFeaturePointsThreshold(double featurePointsThreshold) {
+        this.featurePointsThreshold = featurePointsThreshold;
+        calculateFeaturePoints();
+    }
+    
 }
diff --git a/GUI/src/main/java/cz/fidentis/analyst/gui/tab/PostRegistrationCP.form b/GUI/src/main/java/cz/fidentis/analyst/gui/tab/PostRegistrationCP.form
index 57847abc..ae27aad2 100644
--- a/GUI/src/main/java/cz/fidentis/analyst/gui/tab/PostRegistrationCP.form
+++ b/GUI/src/main/java/cz/fidentis/analyst/gui/tab/PostRegistrationCP.form
@@ -246,6 +246,10 @@
                                   <Component id="featurePointsLabel" min="-2" max="-2" attributes="0"/>
                                   <EmptySpace type="separate" max="-2" attributes="0"/>
                                   <Component id="featurePointsButton" min="-2" pref="50" max="-2" attributes="0"/>
+                                  <EmptySpace type="separate" max="-2" attributes="0"/>
+                                  <Component id="thersholdFTF" min="-2" pref="70" max="-2" attributes="0"/>
+                                  <EmptySpace max="-2" attributes="0"/>
+                                  <Component id="thersholdLabel" min="-2" max="-2" attributes="0"/>
                               </Group>
                               <Group type="102" alignment="0" attributes="0">
                                   <Component id="viewLabel" min="-2" max="-2" attributes="0"/>
@@ -332,6 +336,8 @@
               <Group type="103" groupAlignment="3" attributes="0">
                   <Component id="featurePointsLabel" alignment="3" min="-2" max="-2" attributes="0"/>
                   <Component id="featurePointsButton" alignment="3" min="-2" max="-2" attributes="0"/>
+                  <Component id="thersholdLabel" alignment="3" min="-2" max="-2" attributes="0"/>
+                  <Component id="thersholdFTF" alignment="3" min="-2" max="-2" attributes="0"/>
               </Group>
               <EmptySpace max="-2" attributes="0"/>
               <Component id="jSeparator7" min="-2" pref="10" max="-2" attributes="0"/>
@@ -413,7 +419,7 @@
                   <Component id="resetAllButton" alignment="3" min="-2" max="-2" attributes="0"/>
                   <Component id="applyButton" alignment="3" min="-2" max="-2" attributes="0"/>
               </Group>
-              <EmptySpace pref="41" max="32767" attributes="0"/>
+              <EmptySpace pref="40" max="32767" attributes="0"/>
           </Group>
       </Group>
     </DimensionLayout>
@@ -1505,5 +1511,22 @@
         </Property>
       </Properties>
     </Component>
+    <Component class="javax.swing.JLabel" name="thersholdLabel">
+      <Properties>
+        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+          <ResourceString bundle="cz/fidentis/analyst/gui/tab/Bundle.properties" key="PostRegistrationCP.thersholdLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
+        </Property>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JFormattedTextField" name="thersholdFTF">
+      <Properties>
+        <Property name="formatterFactory" type="javax.swing.JFormattedTextField$AbstractFormatterFactory" editor="org.netbeans.modules.form.editors.AbstractFormatterFactoryEditor">
+          <Format subtype="0" type="0"/>
+        </Property>
+      </Properties>
+      <Events>
+        <EventHandler event="propertyChange" listener="java.beans.PropertyChangeListener" parameters="java.beans.PropertyChangeEvent" handler="thersholdFTFPropertyChange"/>
+      </Events>
+    </Component>
   </SubComponents>
 </Form>
diff --git a/GUI/src/main/java/cz/fidentis/analyst/gui/tab/PostRegistrationCP.java b/GUI/src/main/java/cz/fidentis/analyst/gui/tab/PostRegistrationCP.java
index 3ea7a4df..5a5db1ce 100644
--- a/GUI/src/main/java/cz/fidentis/analyst/gui/tab/PostRegistrationCP.java
+++ b/GUI/src/main/java/cz/fidentis/analyst/gui/tab/PostRegistrationCP.java
@@ -38,6 +38,7 @@ public class PostRegistrationCP extends javax.swing.JPanel {
         secondaryColorPanel.setBackground(listener.getDefaultSecondaryColor());
         primaryFillRB.setSelected(true);
         secondaryFillRB.setSelected(true);
+        thersholdFTF.setValue(listener.getFeaturePointsThreshold());
         resetAllButtonActionPerformed(null);
     }
 
@@ -134,6 +135,8 @@ public class PostRegistrationCP extends javax.swing.JPanel {
         primaryPointsRB = new javax.swing.JRadioButton();
         transformationLabel = new javax.swing.JLabel();
         featurePointsLabel = new javax.swing.JLabel();
+        thersholdLabel = new javax.swing.JLabel();
+        thersholdFTF = new javax.swing.JFormattedTextField();
 
         setBackground(new java.awt.Color(176, 230, 226));
         setPreferredSize(new java.awt.Dimension(405, 600));
@@ -735,6 +738,15 @@ public class PostRegistrationCP extends javax.swing.JPanel {
 
         org.openide.awt.Mnemonics.setLocalizedText(featurePointsLabel, org.openide.util.NbBundle.getMessage(PostRegistrationCP.class, "PostRegistrationCP.featurePointsLabel.text")); // NOI18N
 
+        org.openide.awt.Mnemonics.setLocalizedText(thersholdLabel, org.openide.util.NbBundle.getMessage(PostRegistrationCP.class, "PostRegistrationCP.thersholdLabel.text")); // NOI18N
+
+        thersholdFTF.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter()));
+        thersholdFTF.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
+            public void propertyChange(java.beans.PropertyChangeEvent evt) {
+                thersholdFTFPropertyChange(evt);
+            }
+        });
+
         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
         this.setLayout(layout);
         layout.setHorizontalGroup(
@@ -913,7 +925,11 @@ public class PostRegistrationCP extends javax.swing.JPanel {
                                 .addGroup(layout.createSequentialGroup()
                                     .addComponent(featurePointsLabel)
                                     .addGap(18, 18, 18)
-                                    .addComponent(featurePointsButton, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
+                                    .addComponent(featurePointsButton, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
+                                    .addGap(18, 18, 18)
+                                    .addComponent(thersholdFTF, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
+                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                                    .addComponent(thersholdLabel))
                                 .addGroup(layout.createSequentialGroup()
                                     .addComponent(viewLabel)
                                     .addGap(18, 18, 18)
@@ -980,7 +996,9 @@ public class PostRegistrationCP extends javax.swing.JPanel {
                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                     .addComponent(featurePointsLabel)
-                    .addComponent(featurePointsButton))
+                    .addComponent(featurePointsButton)
+                    .addComponent(thersholdLabel)
+                    .addComponent(thersholdFTF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                 .addComponent(jSeparator7, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
@@ -1053,7 +1071,7 @@ public class PostRegistrationCP extends javax.swing.JPanel {
                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                     .addComponent(resetAllButton)
                     .addComponent(applyButton))
-                .addContainerGap(41, Short.MAX_VALUE))
+                .addContainerGap(40, Short.MAX_VALUE))
         );
     }// </editor-fold>//GEN-END:initComponents
 
@@ -1350,6 +1368,10 @@ public class PostRegistrationCP extends javax.swing.JPanel {
         }
     }//GEN-LAST:event_featurePointsButtonActionPerformed
 
+    private void thersholdFTFPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_thersholdFTFPropertyChange
+        listener.setFeaturePointsThreshold(((Number)thersholdFTF.getValue()).doubleValue());
+    }//GEN-LAST:event_thersholdFTFPropertyChange
+
 
     // Variables declaration - do not modify//GEN-BEGIN:variables
     private javax.swing.JButton applyButton;
@@ -1425,6 +1447,8 @@ public class PostRegistrationCP extends javax.swing.JPanel {
     private javax.swing.JRadioButton secondaryLinesRB;
     private javax.swing.JRadioButton secondaryPointsRB;
     private javax.swing.ButtonGroup secondaryRenerModeGroup;
+    private javax.swing.JFormattedTextField thersholdFTF;
+    private javax.swing.JLabel thersholdLabel;
     private javax.swing.JLabel transformationLabel;
     private javax.swing.JLabel translXLabel;
     private javax.swing.JLabel translYLabel;
diff --git a/GUI/src/main/resources/cz/fidentis/analyst/gui/tab/Bundle.properties b/GUI/src/main/resources/cz/fidentis/analyst/gui/tab/Bundle.properties
index 6812c229..63ab7edf 100644
--- a/GUI/src/main/resources/cz/fidentis/analyst/gui/tab/Bundle.properties
+++ b/GUI/src/main/resources/cz/fidentis/analyst/gui/tab/Bundle.properties
@@ -88,3 +88,5 @@ PostRegistrationCP.colorButton.toolTipText=reset colors
 PostRegistrationCP.colorButton.text=color
 PostRegistrationCP.transformationLabel.text=Transformation
 PostRegistrationCP.featurePointsLabel.text=Feature points:
+PostRegistrationCP.jFormattedTextField1.text=jFormattedTextField1
+PostRegistrationCP.thersholdLabel.text=thershold
-- 
GitLab