diff --git a/GUI/src/main/java/cz/fidentis/analyst/gui/AligmentTopComponent.form b/GUI/src/main/java/cz/fidentis/analyst/gui/AligmentTopComponent.form new file mode 100644 index 0000000000000000000000000000000000000000..26b2d319402c31ac7adb429d1757762b4598900a --- /dev/null +++ b/GUI/src/main/java/cz/fidentis/analyst/gui/AligmentTopComponent.form @@ -0,0 +1,236 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<!-- + + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +--> + +<Form version="1.4" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[1200, 500]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[1250, 600]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="1" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jSplitPane1" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="jPanel1" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jPanel1" pref="576" max="32767" attributes="0"/> + </Group> + <Component id="jSplitPane1" alignment="0" pref="589" max="32767" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Properties> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 500]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[200, 600]"/> + </Property> + </Properties> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLabel1" min="-2" max="-2" attributes="0"/> + <Component id="jButton1" min="-2" max="-2" attributes="0"/> + <Component id="primaryColorPanel" min="-2" max="-2" attributes="0"/> + <Component id="jLabel2" min="-2" max="-2" attributes="0"/> + <Component id="jLabel3" min="-2" max="-2" attributes="0"/> + <Component id="secondaryColorPanel" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace min="0" pref="88" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel1" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jButton1" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="jLabel2" min="-2" max="-2" attributes="0"/> + <EmptySpace min="-2" pref="5" max="-2" attributes="0"/> + <Component id="primaryColorPanel" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel3" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="secondaryColorPanel" min="-2" max="-2" attributes="0"/> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="cz/fidentis/analyst/gui/Bundle.properties" key="AligmentTopComponent.jLabel1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JButton" name="jButton1"> + <Properties> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="cz/fidentis/analyst/gui/Bundle.properties" key="AligmentTopComponent.jButton1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/> + </Events> + </Component> + <Container class="javax.swing.JPanel" name="primaryColorPanel"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 40]"/> + </Property> + </Properties> + <Events> + <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="primaryColorPanelMouseClicked"/> + </Events> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <EmptySpace min="0" pref="100" max="32767" attributes="0"/> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <EmptySpace min="0" pref="40" max="32767" attributes="0"/> + </Group> + </DimensionLayout> + </Layout> + </Container> + <Component class="javax.swing.JLabel" name="jLabel2"> + <Properties> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="cz/fidentis/analyst/gui/Bundle.properties" key="AligmentTopComponent.jLabel2.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel3"> + <Properties> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="cz/fidentis/analyst/gui/Bundle.properties" key="AligmentTopComponent.jLabel3.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> + </Property> + </Properties> + </Component> + <Container class="javax.swing.JPanel" name="secondaryColorPanel"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 40]"/> + </Property> + </Properties> + <Events> + <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="secondaryColorPanelMouseClicked"/> + </Events> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <EmptySpace min="0" pref="100" max="32767" attributes="0"/> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <EmptySpace min="0" pref="40" max="32767" attributes="0"/> + </Group> + </DimensionLayout> + </Layout> + </Container> + </SubComponents> + </Container> + <Container class="javax.swing.JSplitPane" name="jSplitPane1"> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout"/> + <SubComponents> + <Component class="cz.fidentis.analyst.gui.Canvas" name="canvas1"> + <Properties> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[300, 0]"/> + </Property> + <Property name="name" type="java.lang.String" value="" noResource="true"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[500, 0]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription"> + <JSplitPaneConstraints position="left"/> + </Constraint> + </Constraints> + </Component> + <Component class="cz.fidentis.analyst.gui.Canvas" name="canvas2"> + <Properties> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[300, 0]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[500, 0]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription"> + <JSplitPaneConstraints position="right"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/GUI/src/main/java/cz/fidentis/analyst/gui/AligmentTopComponent.java b/GUI/src/main/java/cz/fidentis/analyst/gui/AligmentTopComponent.java new file mode 100644 index 0000000000000000000000000000000000000000..05d09082e3973fdfce1f242c0a0e73ce2da54478 --- /dev/null +++ b/GUI/src/main/java/cz/fidentis/analyst/gui/AligmentTopComponent.java @@ -0,0 +1,250 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package cz.fidentis.analyst.gui; + +import cz.fidentis.analyst.icp.Icp; +import cz.fidentis.analyst.mesh.core.MeshFacet; +import cz.fidentis.analyst.mesh.core.MeshModel; +import java.awt.Color; +import javax.swing.JColorChooser; +import org.netbeans.api.settings.ConvertAsProperties; +import org.openide.awt.ActionID; +import org.openide.awt.ActionReference; +import org.openide.windows.TopComponent; +import org.openide.util.NbBundle.Messages; + +/** + * + * @author Richard PajerskĂ˝ + * + * Window for Registration + */ +@ConvertAsProperties( + dtd = "-//cz.fidentis.analyst.gui//Aligment//EN", + autostore = false +) +@TopComponent.Description( + preferredID = "AligmentTopComponent", + //iconBase="SET/PATH/TO/ICON/HERE", + persistenceType = TopComponent.PERSISTENCE_ALWAYS +) +@TopComponent.Registration(mode = "editor", openAtStartup = false) +@ActionID(category = "Window", id = "cz.fidentis.analyst.gui.AligmentTopComponent") +@ActionReference(path = "Menu/Window" /*, position = 333 */) +@TopComponent.OpenActionRegistration( + displayName = "#CTL_AligmentAction", + preferredID = "AligmentTopComponent" +) +@Messages({ + "CTL_AligmentAction=Registration", + "CTL_AligmentTopComponent=Registration", + "HINT_AligmentTopComponent=This is a Registration window" +}) +public final class AligmentTopComponent extends TopComponent { + + private RegistrationGLEventListener regListener; + + public AligmentTopComponent() { + initComponents(); + setName(Bundle.CTL_AligmentTopComponent()); + setToolTipText(Bundle.HINT_AligmentTopComponent()); + regListener = new RegistrationGLEventListener(canvas1, canvas2); + canvas1.setListener(regListener); + Manipulator3D manipulator = new Manipulator3D(regListener); + canvas1.setManipulator(manipulator); + primaryColorPanel.setBackground(regListener.getPrimaryColor()); + secondaryColorPanel.setBackground(regListener.getSecondaryColor()); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel1 = new javax.swing.JPanel(); + jLabel1 = new javax.swing.JLabel(); + jButton1 = new javax.swing.JButton(); + primaryColorPanel = new javax.swing.JPanel(); + jLabel2 = new javax.swing.JLabel(); + jLabel3 = new javax.swing.JLabel(); + secondaryColorPanel = new javax.swing.JPanel(); + jSplitPane1 = new javax.swing.JSplitPane(); + canvas1 = new cz.fidentis.analyst.gui.Canvas(); + canvas2 = new cz.fidentis.analyst.gui.Canvas(); + + setMinimumSize(new java.awt.Dimension(1200, 500)); + setPreferredSize(new java.awt.Dimension(1250, 600)); + + jPanel1.setMinimumSize(new java.awt.Dimension(100, 500)); + jPanel1.setPreferredSize(new java.awt.Dimension(200, 600)); + + org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(AligmentTopComponent.class, "AligmentTopComponent.jLabel1.text")); // NOI18N + + org.openide.awt.Mnemonics.setLocalizedText(jButton1, org.openide.util.NbBundle.getMessage(AligmentTopComponent.class, "AligmentTopComponent.jButton1.text")); // NOI18N + jButton1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton1ActionPerformed(evt); + } + }); + + primaryColorPanel.setPreferredSize(new java.awt.Dimension(100, 40)); + primaryColorPanel.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + primaryColorPanelMouseClicked(evt); + } + }); + + javax.swing.GroupLayout primaryColorPanelLayout = new javax.swing.GroupLayout(primaryColorPanel); + primaryColorPanel.setLayout(primaryColorPanelLayout); + primaryColorPanelLayout.setHorizontalGroup( + primaryColorPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 100, Short.MAX_VALUE) + ); + primaryColorPanelLayout.setVerticalGroup( + primaryColorPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 40, Short.MAX_VALUE) + ); + + org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(AligmentTopComponent.class, "AligmentTopComponent.jLabel2.text")); // NOI18N + + org.openide.awt.Mnemonics.setLocalizedText(jLabel3, org.openide.util.NbBundle.getMessage(AligmentTopComponent.class, "AligmentTopComponent.jLabel3.text")); // NOI18N + + secondaryColorPanel.setPreferredSize(new java.awt.Dimension(100, 40)); + secondaryColorPanel.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + secondaryColorPanelMouseClicked(evt); + } + }); + + javax.swing.GroupLayout secondaryColorPanelLayout = new javax.swing.GroupLayout(secondaryColorPanel); + secondaryColorPanel.setLayout(secondaryColorPanelLayout); + secondaryColorPanelLayout.setHorizontalGroup( + secondaryColorPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 100, Short.MAX_VALUE) + ); + secondaryColorPanelLayout.setVerticalGroup( + secondaryColorPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 40, Short.MAX_VALUE) + ); + + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel1) + .addComponent(jButton1) + .addComponent(primaryColorPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel2) + .addComponent(jLabel3) + .addComponent(secondaryColorPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(0, 100, Short.MAX_VALUE)) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jButton1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jLabel2) + .addGap(5, 5, 5) + .addComponent(primaryColorPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel3) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(secondaryColorPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE)) + ); + + canvas1.setMinimumSize(new java.awt.Dimension(300, 0)); + canvas1.setName(""); // NOI18N + canvas1.setPreferredSize(new java.awt.Dimension(500, 0)); + jSplitPane1.setLeftComponent(canvas1); + + canvas2.setMinimumSize(new java.awt.Dimension(300, 0)); + canvas2.setPreferredSize(new java.awt.Dimension(500, 0)); + jSplitPane1.setRightComponent(canvas2); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap() + .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 578, Short.MAX_VALUE)) + .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 589, Short.MAX_VALUE)) + .addContainerGap()) + ); + }// </editor-fold>//GEN-END:initComponents + + private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed + canvas1.changeModel(canvas2.getLoadedFace().getMeshModel()); + }//GEN-LAST:event_jButton1ActionPerformed + + private void primaryColorPanelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_primaryColorPanelMouseClicked + Color current = primaryColorPanel.getBackground(); + Color newColor = JColorChooser.showDialog(null, "Choose a color", current); + primaryColorPanel.setBackground(newColor); + regListener.setPrimaryColor(newColor); + }//GEN-LAST:event_primaryColorPanelMouseClicked + + private void secondaryColorPanelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_secondaryColorPanelMouseClicked + Color current = secondaryColorPanel.getBackground(); + Color newColor = JColorChooser.showDialog(null, "Choose a color", current); + secondaryColorPanel.setBackground(newColor); + regListener.setSecondaryColor(newColor); + }//GEN-LAST:event_secondaryColorPanelMouseClicked + + // Variables declaration - do not modify//GEN-BEGIN:variables + private cz.fidentis.analyst.gui.Canvas canvas1; + private cz.fidentis.analyst.gui.Canvas canvas2; + private javax.swing.JButton jButton1; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JPanel jPanel1; + private javax.swing.JSplitPane jSplitPane1; + private javax.swing.JPanel primaryColorPanel; + private javax.swing.JPanel secondaryColorPanel; + // End of variables declaration//GEN-END:variables + @Override + public void componentOpened() { + // TODO add custom code on component opening + } + + @Override + public void componentClosed() { + // TODO add custom code on component closing + } + + void writeProperties(java.util.Properties p) { + // better to version settings since initial version as advocated at + // http://wiki.apidesign.org/wiki/PropertyFiles + p.setProperty("version", "1.0"); + // TODO store your settings + } + + void readProperties(java.util.Properties p) { + String version = p.getProperty("version"); + // TODO read your settings according to their version + } +} diff --git a/GUI/src/main/java/cz/fidentis/analyst/gui/Canvas.java b/GUI/src/main/java/cz/fidentis/analyst/gui/Canvas.java index 1a14735b3a8423042e6f90664857b6bea9544025..47ef0369b9ef7041b54a0b6493352a4a8f80b4f7 100644 --- a/GUI/src/main/java/cz/fidentis/analyst/gui/Canvas.java +++ b/GUI/src/main/java/cz/fidentis/analyst/gui/Canvas.java @@ -101,11 +101,32 @@ public class Canvas extends javax.swing.JPanel { // enables 3D manipualtion manipulator = new Manipulator3D(listener); + setMouseListeners(); + + this.validate(); + } + + private void removeMoseListeners() { + glCanvas.removeMouseListener(this.manipulator); + glCanvas.removeMouseMotionListener(this.manipulator); + glCanvas.removeMouseWheelListener(this.manipulator); + } + + private void setMouseListeners() { glCanvas.addMouseListener(manipulator); glCanvas.addMouseMotionListener(manipulator); glCanvas.addMouseWheelListener(manipulator); - - this.validate(); + } + + /** + * Sets new mouse listeners for this canvas + * + * @param manipulator new Manipulator3D, probably with different listener + */ + public void setManipulator(Manipulator3D manipulator) { + removeMoseListeners(); + this.manipulator = manipulator; + setMouseListeners(); } /** diff --git a/GUI/src/main/java/cz/fidentis/analyst/gui/RegistrationGLEventListener.java b/GUI/src/main/java/cz/fidentis/analyst/gui/RegistrationGLEventListener.java new file mode 100644 index 0000000000000000000000000000000000000000..443addc73c6503e4422cd466a540118c68c2387b --- /dev/null +++ b/GUI/src/main/java/cz/fidentis/analyst/gui/RegistrationGLEventListener.java @@ -0,0 +1,193 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package cz.fidentis.analyst.gui; + +import com.jogamp.opengl.GL; +import static com.jogamp.opengl.GL.GL_FRONT_AND_BACK; +import static com.jogamp.opengl.GL.GL_VIEWPORT; +import com.jogamp.opengl.GL2; +import static com.jogamp.opengl.GL2GL3.GL_FILL; +import static com.jogamp.opengl.GL2GL3.GL_LINE; +import com.jogamp.opengl.GLAutoDrawable; +import static com.jogamp.opengl.fixedfunc.GLMatrixFunc.GL_MODELVIEW_MATRIX; +import static com.jogamp.opengl.fixedfunc.GLMatrixFunc.GL_PROJECTION_MATRIX; +import cz.fidentis.analyst.icp.Icp; +//import cz.fidentis.analyst.face.HumanFace; +import cz.fidentis.analyst.mesh.core.MeshFacet; +import cz.fidentis.analyst.mesh.core.MeshModel; +import cz.fidentis.analyst.mesh.core.MeshPoint; +import java.awt.Color; +import javax.vecmath.Vector3d; + +/** + * + * @author Richard Pajersky + */ +public class RegistrationGLEventListener extends GeneralGLEventListener{ + + private MeshModel primaryModel = null; + private MeshModel secondaryModel = null; + + private Color primaryColor = Color.BLUE; + private Color secondaryColor = Color.RED; + + private boolean other = false; + + private double leftPt = 0.0f; + private double rightPt = 0.0f; + private double topPt = 0.0f; + private double bottomPt = 0.0f; + private double farPt = 0.0f; + private double nearPt = 0.0f; + private Vector3d center; + + public RegistrationGLEventListener(Canvas primary, Canvas secondary) { + super(primary); + } + + private void calculateCenter(MeshModel model) { + for (MeshFacet mf : model.getFacets()) { + for (MeshPoint mp : mf.getVertices()) { + Vector3d vert = mp.getPosition(); + if (vert.x > rightPt) { + rightPt = vert.x; + } + if (vert.x < leftPt) { + leftPt = vert.x; + } + if (vert.y > topPt) { + topPt = vert.y; + } + if (vert.y < bottomPt) { + bottomPt = vert.y; + } + if (vert.z > nearPt) { + nearPt = vert.z; + } + if (vert.z < farPt) { + farPt = vert.z; + } + } + } + double xc = (rightPt + leftPt) / 2.0f; + double yc = (topPt + bottomPt) / 2.0f; + double zc = (nearPt + farPt) / 2.0f; + center = new Vector3d(xc, yc, zc); + } + + @Override + public void setModel(MeshModel model) { + if (primaryModel == null) { + primaryModel = model; + } + else { + Icp icp = new Icp(); + icp.setParameters(10, false, 0.05); + MeshFacet facet = icp.getTransformedFacet(primaryModel.getFacets().get(0), model.getFacets().get(0)); + MeshModel newModel = new MeshModel(); + newModel.addFacet(facet); + secondaryModel = newModel; + } + } + + @Override + public void display(GLAutoDrawable glad) { + wireModel = glCanvas.getDrawWired(); // is wire-frame or not + if (whiteBackround) { + gl.glClearColor(0.9f,0.9f,0.9f,0); + } else { + gl.glClearColor(0.25f,0.25f,0.25f,0); + } + // background for GLCanvas + gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); + gl.glLoadIdentity(); + + // sets model to proper position + glu.gluLookAt(xCameraPosition, yCameraPosition, zCameraPosition, xCenter, yCenter, zCenter, xUpPosition, yUpPosition, zUpPosition); + + gl.glShadeModel(GL2.GL_SMOOTH); + gl.glGetIntegerv(GL_VIEWPORT, viewport, 0); + gl.glGetFloatv(GL_MODELVIEW_MATRIX, modelViewMatrix, 0); + gl.glGetFloatv(GL_PROJECTION_MATRIX, projectionMatrix, 0); + + //if there is any model, draw + if (primaryModel != null) { + if (wireModel) { + gl.glPolygonMode( GL_FRONT_AND_BACK, GL_LINE ); //drawn as wire-frame + drawWithoutTextures(primaryModel); + if (secondaryModel != null) + drawWithoutTextures(secondaryModel); + } else { + gl.glPolygonMode( GL_FRONT_AND_BACK, GL_FILL); // drawn as full traingles + drawWithoutTextures(primaryModel); + if (secondaryModel != null) + drawWithoutTextures(secondaryModel); + } + } + + //gl.glPopMatrix(); + gl.glFlush(); + } + + /** + * Loops through the facets and render each of them + * + * @param model model of the face + */ + @Override + public void drawWithoutTextures(MeshModel model) { + for (int i = 0; i < model.getFacets().size(); i++) { + renderFacet(model.getFacets().get(i)); + } + other = !other; + } + + /** + * Loops through the facet and render all the vertices as they are stored in corner table + * + * @param facet facet of model + */ + @Override + public void renderFacet(MeshFacet facet) { + gl.glBegin(GL2.GL_TRIANGLES); //vertices are rendered as triangles + // get the normal and tex coords indicies for face i + for (int v = 0; v < facet.getCornerTable().getSize(); v++) { + // render the normals + Vector3d norm; + norm = facet.getVertices().get(facet.getCornerTable().getRow(v).getVertexIndex()).getNormal(); + if(norm != null) { + gl.glNormal3d(norm.x, norm.y, norm.z); + } + // render the vertices + Vector3d vert; + vert = facet.getVertices().get(facet.getCornerTable().getRow(v).getVertexIndex()).getPosition(); + //Color c = Color.GREEN; + if (other && secondaryModel != null) + gl.glMaterialfv(GL2.GL_FRONT_AND_BACK, GL2.GL_DIFFUSE, secondaryColor.getComponents(null), 0); + else + gl.glMaterialfv(GL2.GL_FRONT_AND_BACK, GL2.GL_DIFFUSE, primaryColor.getComponents(null), 0); + gl.glVertex3d(vert.x, vert.y, vert.z); + } + gl.glEnd(); + } + + public Color getPrimaryColor() { + return primaryColor; + } + + public void setPrimaryColor(Color primaryColor) { + this.primaryColor = primaryColor; + } + + public Color getSecondaryColor() { + return secondaryColor; + } + + public void setSecondaryColor(Color secondaryColor) { + this.secondaryColor = secondaryColor; + } + +} diff --git a/GUI/src/main/resources/cz/fidentis/analyst/gui/Bundle.properties b/GUI/src/main/resources/cz/fidentis/analyst/gui/Bundle.properties index 76112423db301a514255f7a39623bb1891158770..c6936b9c57f362dc121362b92fea41fe9b112ac1 100644 --- a/GUI/src/main/resources/cz/fidentis/analyst/gui/Bundle.properties +++ b/GUI/src/main/resources/cz/fidentis/analyst/gui/Bundle.properties @@ -12,3 +12,7 @@ DashboardTopComponent.selectAllButton1.text=Select all DashboardTopComponent.removeButton1.text=Remove DashboardTopComponent.addButton1.text=Add DashboardTopComponent.analyzeButton1.text=Open 1:1 +AligmentTopComponent.jLabel1.text=Registration +AligmentTopComponent.jButton1.text=Register +AligmentTopComponent.jLabel2.text=Primary color +AligmentTopComponent.jLabel3.text=Secondary color