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 b27c940d7a3825bb8b7ce8d7a003e82ecdea092e..0899a74abeaaee5e21d7a9fc2eac246803ae5650 100644 --- a/GUI/src/main/java/cz/fidentis/analyst/gui/RegistrationCPEventListener.java +++ b/GUI/src/main/java/cz/fidentis/analyst/gui/RegistrationCPEventListener.java @@ -8,6 +8,8 @@ package cz.fidentis.analyst.gui; import com.jogamp.opengl.GL2; import cz.fidentis.analyst.gui.canvas.Canvas; import cz.fidentis.analyst.gui.scene.DrawableMesh; +import cz.fidentis.analyst.mesh.core.MeshFacet; +import cz.fidentis.analyst.mesh.core.MeshPoint; import cz.fidentis.analyst.visitors.mesh.BoundingBox; import java.awt.Color; import java.util.ArrayList; @@ -54,6 +56,60 @@ public class RegistrationCPEventListener { scaleXYZ = (visitor.getBoundingBox().getMaxDiag() / (10 * changeAmount)); } + public void transformFace() { + for (MeshFacet transformedFacet : secondaryFace.getFacets()) { + for (MeshPoint comparedPoint : transformedFacet.getVertices()) { + Point3d point = comparedPoint.getPosition(); + Point3d newPoint = new Point3d(0, 0, 0); + double quotient; + + // rotate around X + quotient = Math.toRadians(secondaryFace.getRotation().x); + if (!Double.isNaN(quotient)) { + double cos = Math.cos(quotient); + double sin = Math.sin(quotient); + newPoint.y = point.y * cos - point.z * sin; + newPoint.z = point.z * cos + point.y * sin; + point.y = newPoint.y; + point.z = newPoint.z; + } + + // rotate around Y + quotient = Math.toRadians(secondaryFace.getRotation().y); + if (!Double.isNaN(quotient)) { + double cos = Math.cos(quotient); + double sin = Math.sin(quotient); + newPoint.x = point.x * cos + point.z * sin; + newPoint.z = point.z * cos - point.x * sin; + point.x = newPoint.x; + point.z = newPoint.z; + } + + // rotate around Z + quotient = Math.toRadians(secondaryFace.getRotation().z); + if (!Double.isNaN(quotient)) { + double cos = Math.cos(quotient); + double sin = Math.sin(quotient); + newPoint.x = point.x * cos - point.y * sin; + newPoint.y = point.y * cos + point.x * sin; + point.x = newPoint.x; + point.y = newPoint.y; + } + + // translate + point.x += secondaryFace.getTranslation().x; + point.y += secondaryFace.getTranslation().y; + point.z += secondaryFace.getTranslation().z; + + // scale + point.x *= 1 + secondaryFace.getScale().x; + point.y *= 1 + secondaryFace.getScale().y; + point.z *= 1 + secondaryFace.getScale().z; + } + } + canvas.renderScene(); + } + public final void setDeafultColor() { primaryFace.setColor(defaultPrimaryColor); secondaryFace.setColor(defaultSecondaryColor); 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 1a21e7270045f5e4a00901221dffb5b6ecc97481..86cee8186911b0b60606d18ad4c202c35d1b85a4 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 @@ -182,12 +182,19 @@ <Component id="modelLabel" alignment="0" min="-2" max="-2" attributes="0"/> <Component id="viewLabel" alignment="0" min="-2" max="-2" attributes="0"/> </Group> - <EmptySpace type="separate" max="-2" attributes="0"/> - <Group type="103" groupAlignment="0" max="-2" attributes="0"> - <Component id="secondaryColorPanel" pref="50" max="32767" attributes="0"/> - <Component id="primaryColorPanel" pref="50" max="32767" attributes="0"/> - <Component id="colorButton" alignment="1" max="32767" attributes="0"/> - <Component id="profileButton" pref="50" max="32767" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace type="separate" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" max="-2" attributes="0"> + <Component id="secondaryColorPanel" pref="50" max="32767" attributes="0"/> + <Component id="primaryColorPanel" pref="50" max="32767" attributes="0"/> + <Component id="colorButton" alignment="1" pref="50" max="32767" attributes="0"/> + </Group> + </Group> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace min="-2" pref="16" max="-2" attributes="0"/> + <Component id="frontButton" min="-2" pref="50" max="-2" attributes="0"/> + </Group> </Group> <EmptySpace type="separate" max="-2" attributes="0"/> <Group type="103" groupAlignment="0" attributes="0"> @@ -245,7 +252,7 @@ </Group> </Group> </Group> - <Component id="frontButton" alignment="0" min="-2" pref="50" max="-2" attributes="0"/> + <Component id="profileButton" alignment="0" min="-2" pref="50" max="-2" attributes="0"/> </Group> </Group> </Group> @@ -755,9 +762,11 @@ <Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor"> <Color id="Hand Cursor"/> </Property> - <Property name="enabled" type="boolean" value="false"/> <Property name="opaque" type="boolean" value="false"/> </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="applyButtonActionPerformed"/> + </Events> </Component> <Component class="javax.swing.JSeparator" name="jSeparator1"> </Component> 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 542e78b058be6ca92c484b47794686e429f16ff9..271a6622a5fa51516d682c3d613cc025a15870f8 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 @@ -328,8 +328,12 @@ public class PostRegistrationCP extends javax.swing.JPanel { org.openide.awt.Mnemonics.setLocalizedText(applyButton, org.openide.util.NbBundle.getMessage(PostRegistrationCP.class, "PostRegistrationCP.applyButton.text")); // NOI18N applyButton.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR)); - applyButton.setEnabled(false); applyButton.setOpaque(false); + applyButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + applyButtonActionPerformed(evt); + } + }); org.openide.awt.Mnemonics.setLocalizedText(leftTranslationYButton, org.openide.util.NbBundle.getMessage(PostRegistrationCP.class, "PostRegistrationCP.leftTranslationYButton.text")); // NOI18N leftTranslationYButton.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); @@ -853,12 +857,16 @@ public class PostRegistrationCP extends javax.swing.JPanel { .addComponent(primaryLabel) .addComponent(modelLabel) .addComponent(viewLabel)) - .addGap(18, 18, 18) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addComponent(secondaryColorPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 50, Short.MAX_VALUE) - .addComponent(primaryColorPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 50, Short.MAX_VALUE) - .addComponent(colorButton, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(profileButton, javax.swing.GroupLayout.DEFAULT_SIZE, 50, Short.MAX_VALUE)) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(18, 18, 18) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(secondaryColorPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 50, Short.MAX_VALUE) + .addComponent(primaryColorPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 50, Short.MAX_VALUE) + .addComponent(colorButton, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 50, Short.MAX_VALUE))) + .addGroup(layout.createSequentialGroup() + .addGap(16, 16, 16) + .addComponent(frontButton, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() @@ -901,7 +909,7 @@ public class PostRegistrationCP extends javax.swing.JPanel { .addGroup(layout.createSequentialGroup() .addGap(17, 17, 17) .addComponent(transparencyButton, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)))))) - .addComponent(frontButton, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addComponent(profileButton, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)))) .addComponent(transformationLabel)) .addGap(0, 0, Short.MAX_VALUE))) .addContainerGap()) @@ -1097,7 +1105,6 @@ public class PostRegistrationCP extends javax.swing.JPanel { private void resetAllButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_resetAllButtonActionPerformed colorButtonActionPerformed(evt); transparencyButtonActionPerformed(evt); - frontButtonActionPerformed(evt); translationButtonActionPerformed(evt); rotationButtonActionPerformed(evt); scaleButtonActionPerformed(evt); @@ -1169,37 +1176,37 @@ public class PostRegistrationCP extends javax.swing.JPanel { }//GEN-LAST:event_scalePlusButtonActionPerformed private void translationXFTFPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_translationXFTFPropertyChange - float value = ((Number)translationXFTF.getValue()).floatValue(); + double value = ((Number)translationXFTF.getValue()).doubleValue(); listener.setXTranslation(value); }//GEN-LAST:event_translationXFTFPropertyChange private void translationYFTFPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_translationYFTFPropertyChange - float value = ((Number)translationYFTF.getValue()).floatValue(); + double value = ((Number)translationYFTF.getValue()).doubleValue(); listener.setYTranslation(value); }//GEN-LAST:event_translationYFTFPropertyChange private void translationZFTFPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_translationZFTFPropertyChange - float value = ((Number)translationZFTF.getValue()).floatValue(); + double value = ((Number)translationZFTF.getValue()).doubleValue(); listener.setZTranslation(value); }//GEN-LAST:event_translationZFTFPropertyChange private void rotationXFTFPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_rotationXFTFPropertyChange - float value = ((Number)rotationXFTF.getValue()).floatValue(); + double value = ((Number)rotationXFTF.getValue()).doubleValue(); listener.setXRotation(value); }//GEN-LAST:event_rotationXFTFPropertyChange private void rotationYFTFPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_rotationYFTFPropertyChange - float value = ((Number)rotationYFTF.getValue()).floatValue(); + double value = ((Number)rotationYFTF.getValue()).doubleValue(); listener.setYRotation(value); }//GEN-LAST:event_rotationYFTFPropertyChange private void rotationZFTFPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_rotationZFTFPropertyChange - float value = ((Number)rotationZFTF.getValue()).floatValue(); + double value = ((Number)rotationZFTF.getValue()).doubleValue(); listener.setZRotation(value); }//GEN-LAST:event_rotationZFTFPropertyChange private void scaleFTFPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_scaleFTFPropertyChange - float value = ((Number)scaleFTF.getValue()).floatValue(); + double value = ((Number)scaleFTF.getValue()).doubleValue(); listener.setScale(value); }//GEN-LAST:event_scaleFTFPropertyChange @@ -1317,6 +1324,11 @@ public class PostRegistrationCP extends javax.swing.JPanel { listener.setDeafultColor(); }//GEN-LAST:event_colorButtonActionPerformed + private void applyButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_applyButtonActionPerformed + listener.transformFace(); + resetAllButtonActionPerformed(evt); + }//GEN-LAST:event_applyButtonActionPerformed + // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton applyButton; 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 29f6c88567e00a3dbc21d5eeb0e6344852b761b7..165dbe5e34f33d26b8540249d5f836c517c77eaa 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 @@ -20,7 +20,7 @@ PostRegistrationCP.leftTranslationXButton.text=<< PostRegistrationCP.translationButton.toolTipText=reset translation PostRegistrationCP.translationButton.text=reset PostRegistrationCP.profileButton.toolTipText=model profile view -PostRegistrationCP.profileButton.text=profile +PostRegistrationCP.profileButton.text=side PostRegistrationCP.frontButton.toolTipText=model front view PostRegistrationCP.frontButton.text=front PostRegistrationCP.featurePointsButton.text=Feature points