diff --git a/Comparison/src/main/java/cz/fidentis/analyst/Project.java b/Comparison/src/main/java/cz/fidentis/analyst/Project.java index 73a0fd18cc968d03230a432a07cf1572814c2951..3b891f298ecb835717f646a7d708723fcb2e6d7c 100644 --- a/Comparison/src/main/java/cz/fidentis/analyst/Project.java +++ b/Comparison/src/main/java/cz/fidentis/analyst/Project.java @@ -4,10 +4,6 @@ import cz.fidentis.analyst.face.HumanFace; import java.io.File; import java.io.IOException; import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; /** @@ -19,8 +15,6 @@ import java.util.List; public class Project { private boolean saved = true; - - private List<HumanFace> faces = new ArrayList<>(); /* Project data (paths to faces, opened tabs..) */ private ProjectConfiguration cfg = new ProjectConfiguration(); @@ -96,140 +90,25 @@ public class Project { public void removeFaceToFaceTab(String name1, String name2) { this.cfg.removeFaceToFaceTab(name1, name2); } - - /** - * Returns list of HumanFace secondary faces - * - * @return list of secondary faces - */ - public List<HumanFace> getFaces() { - return Collections.unmodifiableList(faces); - } - - /** - * Sets new list of secondary faces - * - * @param secondaryFaces list of HumanFace which will be new list of - * secondary faces - * @throws IllegalArgumentException if one of faces from argument is null - */ - public void setFaces(List<HumanFace> secondaryFaces) { - this.faces.clear(); - for (int i = 0; i < secondaryFaces.size(); i++) { - if (secondaryFaces.get(i) == null) { - throw new IllegalArgumentException("One of faces is null"); - } - } - this.faces.addAll(secondaryFaces); - } - - /** - * Adds new face to faces - * - * @param face HumanFace which will be added to list of secondary faces - * @throws IllegalArgumentException when argument face is null - */ - public void addFace(HumanFace face) { - if (face == null) { - throw new IllegalArgumentException("Face is null"); - } - this.faces.add(face); - } - - /** - * Removes HumanFace from faces - * - * @param face HumanFace which will be removed from faces - * @throws IllegalArgumentException when argument face is null - */ - public void removeFace(HumanFace face) { - if (face == null) { - throw new IllegalArgumentException("Face is null"); - } - - for (int i = 0; i < faces.size(); i++) { - if (faces.get(i).equals(face)) { - faces.remove(i); - } - } - } - - /** - * Removes face by providing its name - * - * @param name name of the face to be removed - */ - public void removeFaceByName(String name) { - HumanFace face = this.getFaceByName(name); - if (face != null) { - this.removeFace(face); - } - - this.cfg.removePath(name); - //this.cfg.removeFaceTab(name); - - } - - /** - * Removes all faces from list of faces - */ - public void removeAll() { - faces.clear(); - } - - /** - * Removes faces which are sent to this function by list of HumanFace - * from faces - * - * @param faces List of HumanFace faces which should be removed from - * faces - */ - public void removeSelected(List<HumanFace> faces) { - for (int i = 0; i < faces.size(); i++) { - this.removeFace(faces.get(i)); - } - } - - - /** - * - * @param name String name of the model (face) - * @return face from this project faces, if not in project than returns - * null - */ - public HumanFace getFaceByName(String name) { - for (HumanFace face : faces) { - if (face.getShortName().equals(name)) { - return face; - } - } - return null; - } - + /** * Loads face from path * @param name String name of face - * @return loaded HumanFace + * @return loaded HumanFace or null */ public HumanFace loadFace(String name) { - HumanFace face = this.getFaceByName(name); - if (face == null) { - try { - Logger out = Logger.measureTime(); - Path path = this.getCfg().getPathToFaceByName(name); - File file = path.toFile(); - face = new HumanFace(file, true); // loads also landmarks, if exist - //Path preview = path.resolveSibling(name.concat("_preview.jpg")); - Path preview = Paths.get(face.getPath().split(".obj")[0] + "_preview.jpg"); - face.setPreview(preview); - this.addFace(face); - out.printDuration("Loaded model " + face.getShortName() +" with " + face.getMeshModel().getNumVertices() + " vertices"); - } catch (IOException ex) { - //ex.printStackTrace(); - Logger.print(ex.toString()); - } - } - return face; + try { + Logger out = Logger.measureTime(); + Path path = this.getCfg().getPathToFaceByName(name); + File file = path.toFile(); + HumanFace face = new HumanFace(file, true); // loads also landmarks, if exist + out.printDuration("Loaded model " + face.getShortName() +" with " + face.getMeshModel().getNumVertices() + " vertices"); + return face; + } catch (IOException ex) { + //ex.printStackTrace(); + Logger.print(ex.toString()); + } + return null; } } diff --git a/Comparison/src/main/java/cz/fidentis/analyst/face/HumanFace.java b/Comparison/src/main/java/cz/fidentis/analyst/face/HumanFace.java index 5ea502d615f0670151b61b810d9073f5c4ce6f47..a0c12a6d3b05bef153a599093902e62f852ee89a 100644 --- a/Comparison/src/main/java/cz/fidentis/analyst/face/HumanFace.java +++ b/Comparison/src/main/java/cz/fidentis/analyst/face/HumanFace.java @@ -14,18 +14,15 @@ import cz.fidentis.analyst.visitors.face.HumanFaceVisitor; import cz.fidentis.analyst.visitors.mesh.BoundingBox; import cz.fidentis.analyst.visitors.mesh.BoundingBox.BBox; import cz.fidentis.analyst.visitors.mesh.Curvature; -import java.awt.image.BufferedImage; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.Serializable; -import java.nio.file.Path; import java.util.Collections; import java.util.List; import java.util.ArrayList; import java.util.Objects; -import javax.imageio.ImageIO; /** * This class encapsulates data for a 3D scan of a single human face. @@ -61,9 +58,7 @@ public class HumanFace implements Serializable { private final transient EventBus eventBus; private final String id; - - private transient BufferedImage preview; - + private transient Curvature curvature; /** @@ -378,31 +373,6 @@ public class HumanFace implements Serializable { return ret; } - /** - * Sets preview image - * @param path Path to preview - * @return whether preview was found and successfully set or not - */ - public boolean setPreview(Path path) { - try { - if (path.toFile().exists()) { - preview = ImageIO.read(path.toFile()); - return true; - } - } catch (IOException ex) { - ex.printStackTrace(); - } - return false; - } - - /** - * Gets preview image - * @return preview photo (or {@code null}) - */ - public BufferedImage getPreview() { - return this.preview; - } - /** * Tries to find a file with landmarks definition based on the name of the face's OBJ file. * @return The file with landmarks or {@code null} diff --git a/GUI/src/main/java/cz/fidentis/analyst/project/FaceGeometryInfo.java b/GUI/src/main/java/cz/fidentis/analyst/project/FaceGeometryInfo.java new file mode 100644 index 0000000000000000000000000000000000000000..ab96418181ca0352669a0daa8133dbc07746824c --- /dev/null +++ b/GUI/src/main/java/cz/fidentis/analyst/project/FaceGeometryInfo.java @@ -0,0 +1,52 @@ +package cz.fidentis.analyst.project; + +import java.util.List; + +/** + * + * @author Matej Kovar + */ +public class FaceGeometryInfo { + + private String verticesInfo; + private String facetsInfo; + private List<String> featurePointsInfo; + + /** + * Face geometry info of face + * @param verticesInfo String number of vertices + * @param facetsInfo String number of facets + * @param featurePointsInfo List of feature points + */ + public FaceGeometryInfo(String verticesInfo, String facetsInfo, List<String> featurePointsInfo) { + this.verticesInfo = verticesInfo; + this.facetsInfo = facetsInfo; + this.featurePointsInfo = featurePointsInfo; + } + + public String getVerticesInfo() { + return verticesInfo; + } + + public void setVerticesInfo(String verticesInfo) { + this.verticesInfo = verticesInfo; + } + + public String getFecetsInfo() { + return facetsInfo; + } + + public void setFecetsInfo(String fecetsInfo) { + this.facetsInfo = fecetsInfo; + } + + public List<String> getFeaturePointsInfo() { + return featurePointsInfo; + } + + public void setFeaturePointsInfo(List<String> featurePointsInfo) { + this.featurePointsInfo = featurePointsInfo; + } + + +} diff --git a/GUI/src/main/java/cz/fidentis/analyst/project/FaceStatePanel.form b/GUI/src/main/java/cz/fidentis/analyst/project/FaceStatePanel.form index 5f24629f5fcb1345f11bf94de6eab3cd9a71f2ad..100b4d23178652ad8205a1bad5cf8746192acdc0 100644 --- a/GUI/src/main/java/cz/fidentis/analyst/project/FaceStatePanel.form +++ b/GUI/src/main/java/cz/fidentis/analyst/project/FaceStatePanel.form @@ -20,7 +20,7 @@ <EmptySpace max="-2" attributes="0"/> <Group type="103" groupAlignment="0" attributes="0"> <Component id="filePanel" max="32767" attributes="0"/> - <Component id="facePanel" alignment="0" max="32767" attributes="0"/> + <Component id="geometryPanel" alignment="0" max="32767" attributes="0"/> <Component id="photoPanel" alignment="0" min="-2" max="-2" attributes="0"/> </Group> <EmptySpace max="-2" attributes="0"/> @@ -33,9 +33,9 @@ <EmptySpace min="-2" pref="6" max="-2" attributes="0"/> <Component id="photoPanel" min="-2" max="-2" attributes="0"/> <EmptySpace type="unrelated" max="-2" attributes="0"/> - <Component id="filePanel" max="32767" attributes="0"/> - <EmptySpace type="separate" max="32767" attributes="0"/> - <Component id="facePanel" min="-2" max="-2" attributes="0"/> + <Component id="filePanel" min="-2" max="-2" attributes="0"/> + <EmptySpace type="separate" max="-2" attributes="0"/> + <Component id="geometryPanel" max="32767" attributes="0"/> <EmptySpace max="-2" attributes="0"/> </Group> </Group> @@ -211,12 +211,12 @@ </Component> </SubComponents> </Container> - <Container class="javax.swing.JPanel" name="facePanel"> + <Container class="javax.swing.JPanel" name="geometryPanel"> <Properties> <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> <Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo"> - <TitledBorder title="Face info"> - <ResourceString PropertyName="titleX" bundle="cz/fidentis/analyst/project/Bundle.properties" key="FaceStatePanel.facePanel.border.title" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> + <TitledBorder title="Geometry info"> + <ResourceString PropertyName="titleX" bundle="cz/fidentis/analyst/project/Bundle.properties" key="FaceStatePanel.geometryPanel.border.title" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> <Font PropertyName="font" name="Dialog" size="14" style="1"/> </TitledBorder> </Border> @@ -229,25 +229,33 @@ <Group type="102" attributes="0"> <EmptySpace max="-2" attributes="0"/> <Group type="103" groupAlignment="0" attributes="0"> - <Component id="kdTreeLabel" alignment="0" min="-2" max="-2" attributes="0"/> - <Component id="featurePointsLoadedLabel" alignment="0" min="-2" max="-2" attributes="0"/> - </Group> - <EmptySpace min="-2" pref="22" max="-2" attributes="0"/> - <Group type="103" groupAlignment="0" attributes="0"> - <Component id="hasFPOutput" min="-2" max="-2" attributes="0"/> - <Component id="hasKDOutput" min="-2" max="-2" attributes="0"/> - </Group> - <EmptySpace pref="430" max="32767" attributes="0"/> - </Group> - <Group type="102" alignment="1" attributes="0"> - <EmptySpace max="32767" attributes="0"/> - <Component id="warningLabel" min="-2" max="-2" attributes="0"/> - <EmptySpace type="unrelated" max="-2" attributes="0"/> - <Group type="103" groupAlignment="0" attributes="0"> - <Component id="faceNotLoadedLabel" min="-2" max="-2" attributes="0"/> - <Component id="loadFaceButton" min="-2" max="-2" attributes="0"/> + <Group type="102" alignment="0" attributes="0"> + <Component id="verticesLabel" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="verticesOutput" max="32767" attributes="0"/> + </Group> + <Group type="102" alignment="1" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="facetsLabel" alignment="0" min="-2" max="-2" attributes="0"/> + <Component id="fpLabel" alignment="0" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace pref="286" max="32767" attributes="0"/> + <Component id="loadInfoButton" min="-2" max="-2" attributes="0"/> + <EmptySpace min="-2" pref="51" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace min="-2" pref="20" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jComboBox1" alignment="1" max="32767" attributes="0"/> + <Component id="facetsOutput" max="32767" attributes="0"/> + </Group> + </Group> + </Group> + </Group> </Group> - <EmptySpace min="-2" pref="33" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> </Group> </Group> </DimensionLayout> @@ -255,88 +263,92 @@ <Group type="103" groupAlignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0"> <EmptySpace max="-2" attributes="0"/> - <Group type="103" groupAlignment="3" attributes="0"> - <Component id="kdTreeLabel" alignment="3" min="-2" max="-2" attributes="0"/> - <Component id="hasKDOutput" alignment="3" min="-2" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" max="-2" attributes="0"> + <Component id="verticesLabel" max="32767" attributes="0"/> + <Component id="verticesOutput" max="32767" attributes="0"/> </Group> <EmptySpace type="separate" max="-2" attributes="0"/> - <Group type="103" groupAlignment="3" attributes="0"> - <Component id="featurePointsLoadedLabel" alignment="3" min="-2" max="-2" attributes="0"/> - <Component id="hasFPOutput" alignment="3" min="-2" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" max="-2" attributes="0"> + <Component id="facetsLabel" max="32767" attributes="0"/> + <Component id="facetsOutput" max="32767" attributes="0"/> </Group> - <EmptySpace min="-2" pref="56" max="-2" attributes="0"/> - <Group type="103" groupAlignment="1" attributes="0"> - <Component id="warningLabel" min="-2" max="-2" attributes="0"/> - <Component id="faceNotLoadedLabel" min="-2" max="-2" attributes="0"/> + <EmptySpace type="separate" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="fpLabel" min="-2" max="-2" attributes="0"/> + <Component id="jComboBox1" min="-2" max="-2" attributes="0"/> </Group> - <EmptySpace type="unrelated" max="-2" attributes="0"/> - <Component id="loadFaceButton" min="-2" max="-2" attributes="0"/> - <EmptySpace max="32767" attributes="0"/> + <EmptySpace min="-2" pref="53" max="-2" attributes="0"/> + <Component id="loadInfoButton" min="-2" max="-2" attributes="0"/> + <EmptySpace pref="34" max="32767" attributes="0"/> </Group> </Group> </DimensionLayout> </Layout> <SubComponents> - <Component class="javax.swing.JLabel" name="kdTreeLabel"> + <Component class="javax.swing.JLabel" name="verticesLabel"> <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="10" style="1"/> + </Property> <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> - <ResourceString bundle="cz/fidentis/analyst/project/Bundle.properties" key="FaceStatePanel.kdTreeLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> + <ResourceString bundle="cz/fidentis/analyst/project/Bundle.properties" key="FaceStatePanel.verticesLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> </Property> <Property name="enabled" type="boolean" value="false"/> </Properties> </Component> - <Component class="javax.swing.JLabel" name="featurePointsLoadedLabel"> + <Component class="javax.swing.JLabel" name="verticesOutput"> <Properties> <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> - <ResourceString bundle="cz/fidentis/analyst/project/Bundle.properties" key="FaceStatePanel.featurePointsLoadedLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> + <ResourceString bundle="cz/fidentis/analyst/project/Bundle.properties" key="FaceStatePanel.verticesOutput.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> </Property> - <Property name="enabled" type="boolean" value="false"/> </Properties> </Component> - <Component class="javax.swing.JLabel" name="hasKDOutput"> + <Component class="javax.swing.JLabel" name="facetsLabel"> <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="10" style="1"/> + </Property> <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> - <ResourceString bundle="cz/fidentis/analyst/project/Bundle.properties" key="FaceStatePanel.hasKDOutput.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> + <ResourceString bundle="cz/fidentis/analyst/project/Bundle.properties" key="FaceStatePanel.facetsLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> </Property> + <Property name="enabled" type="boolean" value="false"/> </Properties> </Component> - <Component class="javax.swing.JLabel" name="hasFPOutput"> + <Component class="javax.swing.JLabel" name="facetsOutput"> <Properties> <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> - <ResourceString bundle="cz/fidentis/analyst/project/Bundle.properties" key="FaceStatePanel.hasFPOutput.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> + <ResourceString bundle="cz/fidentis/analyst/project/Bundle.properties" key="FaceStatePanel.facetsOutput.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> </Property> </Properties> </Component> - <Component class="javax.swing.JLabel" name="faceNotLoadedLabel"> + <Component class="javax.swing.JLabel" name="fpLabel"> <Properties> <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> - <Font name="Tahoma" size="12" style="1"/> + <Font name="Tahoma" size="10" style="1"/> </Property> <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> - <ResourceString bundle="cz/fidentis/analyst/project/Bundle.properties" key="FaceStatePanel.faceNotLoadedLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> + <ResourceString bundle="cz/fidentis/analyst/project/Bundle.properties" key="FaceStatePanel.fpLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> </Property> + <Property name="enabled" type="boolean" value="false"/> </Properties> - <AuxValues> - <AuxValue name="JavaCodeGenerator_InitCodePost" type="java.lang.String" value="faceNotLoadedLabel.setVisible(false);"/> - </AuxValues> </Component> - <Component class="javax.swing.JButton" name="loadFaceButton"> + <Component class="javax.swing.JComboBox" name="jComboBox1"> <Properties> - <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> - <ResourceString bundle="cz/fidentis/analyst/project/Bundle.properties" key="FaceStatePanel.loadFaceButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> + <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> + <StringArray count="0"/> </Property> </Properties> <AuxValues> - <AuxValue name="JavaCodeGenerator_InitCodePre" type="java.lang.String" value="loadFaceButton.setVisible(false);"/> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> </AuxValues> </Component> - <Component class="javax.swing.JLabel" name="warningLabel"> + <Component class="javax.swing.JButton" name="loadInfoButton"> <Properties> - <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor" postCode="warningLabel.setVisible(false);"> - <Image iconType="3" name="/warning16x16.png"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="12" style="1"/> </Property> <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> - <ResourceString bundle="cz/fidentis/analyst/project/Bundle.properties" key="FaceStatePanel.warningLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> + <ResourceString bundle="cz/fidentis/analyst/project/Bundle.properties" key="FaceStatePanel.loadInfoButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> </Property> </Properties> </Component> diff --git a/GUI/src/main/java/cz/fidentis/analyst/project/FaceStatePanel.java b/GUI/src/main/java/cz/fidentis/analyst/project/FaceStatePanel.java index db5d4b3acb23fd8577f1438ab3475f62d68425af..1fbddaa3f169c63112985fe7ee23f32e9f8bda5b 100644 --- a/GUI/src/main/java/cz/fidentis/analyst/project/FaceStatePanel.java +++ b/GUI/src/main/java/cz/fidentis/analyst/project/FaceStatePanel.java @@ -3,18 +3,23 @@ package cz.fidentis.analyst.project; import cz.fidentis.analyst.core.ControlPanel; import cz.fidentis.analyst.face.HumanFace; import java.awt.Dimension; +import java.awt.Image; import java.awt.Toolkit; import java.awt.event.ActionListener; -import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; import javax.imageio.ImageIO; +import javax.swing.DefaultComboBoxModel; import javax.swing.ImageIcon; import javax.swing.JOptionPane; -import org.imgscalr.Scalr; /** * @@ -22,14 +27,14 @@ import org.imgscalr.Scalr; */ public class FaceStatePanel extends ControlPanel { - private final ImageIcon notCheck = new ImageIcon(FaceStatePanel.class.getClassLoader().getResource("/" + "notCheck16x16.png")); - private final ImageIcon check = new ImageIcon(FaceStatePanel.class.getClassLoader().getResource("/" + "check16x16.png")); - private final ImageIcon previewBasic = new ImageIcon(FaceStatePanel.class.getClassLoader().getResource("/" + "face160x160.png")); + private final ImageIcon anonymousFace = new ImageIcon(FaceStatePanel.class.getClassLoader().getResource("/" + "face160x160.png")); private ImageIcon previewFace = null; public static final String ICON = "head28x28.png"; public static final String NAME = "Face State"; + // Loaded geometry info of face + private Map<String, FaceGeometryInfo> loadedFaces = new HashMap<>(); /** * Panel with face information @@ -39,7 +44,8 @@ public class FaceStatePanel extends ControlPanel { this.setName(NAME); initComponents(); - loadFaceButton.addActionListener(loadFaceListener); + loadInfoButton.addActionListener(loadFaceListener); + loadInfoButton.setToolTipText("Loads face geometry info from file in specified file path"); //210 140 } @@ -64,14 +70,14 @@ public class FaceStatePanel extends ControlPanel { previewOutput = new javax.swing.JLabel(); textureLabel = new javax.swing.JLabel(); textureOutput = new javax.swing.JLabel(); - facePanel = new javax.swing.JPanel(); - kdTreeLabel = new javax.swing.JLabel(); - featurePointsLoadedLabel = new javax.swing.JLabel(); - hasKDOutput = new javax.swing.JLabel(); - hasFPOutput = new javax.swing.JLabel(); - faceNotLoadedLabel = new javax.swing.JLabel(); - loadFaceButton = new javax.swing.JButton(); - warningLabel = new javax.swing.JLabel(); + geometryPanel = new javax.swing.JPanel(); + verticesLabel = new javax.swing.JLabel(); + verticesOutput = new javax.swing.JLabel(); + facetsLabel = new javax.swing.JLabel(); + facetsOutput = new javax.swing.JLabel(); + fpLabel = new javax.swing.JLabel(); + jComboBox1 = new javax.swing.JComboBox<>(); + loadInfoButton = new javax.swing.JButton(); photoPanel = new javax.swing.JPanel(); photo = new javax.swing.JLabel(); @@ -155,70 +161,72 @@ public class FaceStatePanel extends ControlPanel { .addGap(14, 14, 14)) ); - facePanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, org.openide.util.NbBundle.getMessage(FaceStatePanel.class, "FaceStatePanel.facePanel.border.title"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", 1, 14))); // NOI18N + geometryPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, org.openide.util.NbBundle.getMessage(FaceStatePanel.class, "FaceStatePanel.geometryPanel.border.title"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", 1, 14))); // NOI18N - org.openide.awt.Mnemonics.setLocalizedText(kdTreeLabel, org.openide.util.NbBundle.getMessage(FaceStatePanel.class, "FaceStatePanel.kdTreeLabel.text")); // NOI18N - kdTreeLabel.setEnabled(false); + verticesLabel.setFont(new java.awt.Font("Tahoma", 1, 10)); // NOI18N + org.openide.awt.Mnemonics.setLocalizedText(verticesLabel, org.openide.util.NbBundle.getMessage(FaceStatePanel.class, "FaceStatePanel.verticesLabel.text")); // NOI18N + verticesLabel.setEnabled(false); - org.openide.awt.Mnemonics.setLocalizedText(featurePointsLoadedLabel, org.openide.util.NbBundle.getMessage(FaceStatePanel.class, "FaceStatePanel.featurePointsLoadedLabel.text")); // NOI18N - featurePointsLoadedLabel.setEnabled(false); + org.openide.awt.Mnemonics.setLocalizedText(verticesOutput, org.openide.util.NbBundle.getMessage(FaceStatePanel.class, "FaceStatePanel.verticesOutput.text")); // NOI18N - org.openide.awt.Mnemonics.setLocalizedText(hasKDOutput, org.openide.util.NbBundle.getMessage(FaceStatePanel.class, "FaceStatePanel.hasKDOutput.text")); // NOI18N + facetsLabel.setFont(new java.awt.Font("Tahoma", 1, 10)); // NOI18N + org.openide.awt.Mnemonics.setLocalizedText(facetsLabel, org.openide.util.NbBundle.getMessage(FaceStatePanel.class, "FaceStatePanel.facetsLabel.text")); // NOI18N + facetsLabel.setEnabled(false); - org.openide.awt.Mnemonics.setLocalizedText(hasFPOutput, org.openide.util.NbBundle.getMessage(FaceStatePanel.class, "FaceStatePanel.hasFPOutput.text")); // NOI18N + org.openide.awt.Mnemonics.setLocalizedText(facetsOutput, org.openide.util.NbBundle.getMessage(FaceStatePanel.class, "FaceStatePanel.facetsOutput.text")); // NOI18N - faceNotLoadedLabel.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N - org.openide.awt.Mnemonics.setLocalizedText(faceNotLoadedLabel, org.openide.util.NbBundle.getMessage(FaceStatePanel.class, "FaceStatePanel.faceNotLoadedLabel.text")); // NOI18N - faceNotLoadedLabel.setVisible(false); + fpLabel.setFont(new java.awt.Font("Tahoma", 1, 10)); // NOI18N + org.openide.awt.Mnemonics.setLocalizedText(fpLabel, org.openide.util.NbBundle.getMessage(FaceStatePanel.class, "FaceStatePanel.fpLabel.text")); // NOI18N + fpLabel.setEnabled(false); - loadFaceButton.setVisible(false); - org.openide.awt.Mnemonics.setLocalizedText(loadFaceButton, org.openide.util.NbBundle.getMessage(FaceStatePanel.class, "FaceStatePanel.loadFaceButton.text")); // NOI18N + loadInfoButton.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N + org.openide.awt.Mnemonics.setLocalizedText(loadInfoButton, org.openide.util.NbBundle.getMessage(FaceStatePanel.class, "FaceStatePanel.loadInfoButton.text")); // NOI18N - warningLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/warning16x16.png"))); // NOI18N - warningLabel.setVisible(false); - org.openide.awt.Mnemonics.setLocalizedText(warningLabel, org.openide.util.NbBundle.getMessage(FaceStatePanel.class, "FaceStatePanel.warningLabel.text")); // NOI18N - - javax.swing.GroupLayout facePanelLayout = new javax.swing.GroupLayout(facePanel); - facePanel.setLayout(facePanelLayout); - facePanelLayout.setHorizontalGroup( - facePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(facePanelLayout.createSequentialGroup() + javax.swing.GroupLayout geometryPanelLayout = new javax.swing.GroupLayout(geometryPanel); + geometryPanel.setLayout(geometryPanelLayout); + geometryPanelLayout.setHorizontalGroup( + geometryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(geometryPanelLayout.createSequentialGroup() .addContainerGap() - .addGroup(facePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(kdTreeLabel) - .addComponent(featurePointsLoadedLabel)) - .addGap(22, 22, 22) - .addGroup(facePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(hasFPOutput) - .addComponent(hasKDOutput)) - .addContainerGap(430, Short.MAX_VALUE)) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, facePanelLayout.createSequentialGroup() - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(warningLabel) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addGroup(facePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(faceNotLoadedLabel) - .addComponent(loadFaceButton)) - .addGap(33, 33, 33)) + .addGroup(geometryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(geometryPanelLayout.createSequentialGroup() + .addComponent(verticesLabel) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(verticesOutput, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, geometryPanelLayout.createSequentialGroup() + .addGroup(geometryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(facetsLabel) + .addComponent(fpLabel)) + .addGroup(geometryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(geometryPanelLayout.createSequentialGroup() + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 286, Short.MAX_VALUE) + .addComponent(loadInfoButton) + .addGap(51, 51, 51)) + .addGroup(geometryPanelLayout.createSequentialGroup() + .addGap(20, 20, 20) + .addGroup(geometryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jComboBox1, javax.swing.GroupLayout.Alignment.TRAILING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(facetsOutput, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))))) + .addContainerGap()) ); - facePanelLayout.setVerticalGroup( - facePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(facePanelLayout.createSequentialGroup() + geometryPanelLayout.setVerticalGroup( + geometryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(geometryPanelLayout.createSequentialGroup() .addContainerGap() - .addGroup(facePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(kdTreeLabel) - .addComponent(hasKDOutput)) + .addGroup(geometryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(verticesLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(verticesOutput, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGap(18, 18, 18) - .addGroup(facePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(featurePointsLoadedLabel) - .addComponent(hasFPOutput)) - .addGap(56, 56, 56) - .addGroup(facePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) - .addComponent(warningLabel) - .addComponent(faceNotLoadedLabel)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(loadFaceButton) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addGroup(geometryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(facetsLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(facetsOutput, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addGap(18, 18, 18) + .addGroup(geometryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(fpLabel) + .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(53, 53, 53) + .addComponent(loadInfoButton) + .addContainerGap(34, Short.MAX_VALUE)) ); photoPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, org.openide.util.NbBundle.getMessage(FaceStatePanel.class, "FaceStatePanel.photoPanel.border.title"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", 1, 14))); // NOI18N @@ -256,7 +264,7 @@ public class FaceStatePanel extends ControlPanel { .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(filePanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(facePanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(geometryPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(photoPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap()) ); @@ -266,9 +274,9 @@ public class FaceStatePanel extends ControlPanel { .addGap(6, 6, 6) .addComponent(photoPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(filePanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addGap(18, 18, Short.MAX_VALUE) - .addComponent(facePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(filePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addComponent(geometryPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap()) ); @@ -285,23 +293,23 @@ public class FaceStatePanel extends ControlPanel { /** * Shows face information on panel - * @param face HumanFace * @param name String * @param path Path */ - public void showFaceState(HumanFace face, String name, Path path) { - - photo.setIcon(getPhoto(face, path)); + public void showFaceState(String faceName, Path path) { + photo.setIcon(getPhoto(path)); + pathOutput.setText(getPathText(path)); sizeOutput.setText(getSizeText(path)); featurePointsOutput.setText(getFeaturePointsText(path)); previewOutput.setText(getPreviewText(path)); textureOutput.setText(getTextureText(path)); - - hasKDOutput.setIcon(getKdTree(face)); - hasFPOutput.setIcon(getFeaturePoints(face)); - checkFaceLoaded(face); + + verticesOutput.setText(getNumberOfVertices(faceName)); + facetsOutput.setText(getNumberOfFacets(faceName)); + loadFeaturePoints(faceName); + } @Override @@ -311,57 +319,38 @@ public class FaceStatePanel extends ControlPanel { /** * Gets photo which would be displayed on photo panel - * @param face HumanFace * @param path Path * @return ImageIcon either loaded face preview or anonymous face when preview is not found */ - private ImageIcon getPhoto(HumanFace face, Path path) { - - previewFace = null; - BufferedImage image = null; + private ImageIcon getPhoto(Path path) { - // If face is loaded to project, preview is loaded from face - if (face != null) { - if (face.getPreview() != null) { - image = face.getPreview(); - - } else { - photo.setToolTipText(""); - return previewBasic; - } + ImageIcon image; + previewFace = null; + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); + + if (path != null && path.toFile().exists()) { - } else if (path != null && path.toFile().exists()) { - Path preview = Paths.get(path.toString().split(".obj")[0] + "_preview.jpg"); + String pathString = path.toString(); + Path preview = Paths.get(pathString.substring(0, pathString.lastIndexOf(".")).concat("_preview.jpg")); try { - image = ImageIO.read(preview.toFile()); + + previewFace = new ImageIcon(ImageIO.read(preview.toFile()).getScaledInstance((int)screenSize.getWidth() - 200, (int)screenSize.getHeight() - 200, Image.SCALE_FAST)); + image = new ImageIcon(previewFace.getImage().getScaledInstance(240, 160, Image.SCALE_FAST)); + photo.setToolTipText("Click to enlarge the image"); + return image; } catch (IOException ex) { //Exceptions.printStackTrace(ex);) } - } - - if (image == null) { - - // Basic black siluete - photo.setToolTipText(""); - return previewBasic; - } - - Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); - image = Scalr.resize(image, (int)screenSize.getHeight() - 200); - - previewFace = new ImageIcon(image); - photo.setToolTipText("Click to enlarge the image"); - - return new ImageIcon(Scalr.resize(image, 240, 160)); - + photo.setToolTipText(""); + return anonymousFace; } /** * Gets path text * @param path Path - * @return String path + * @return String path or blank string */ private String getPathText(Path path) { @@ -376,7 +365,7 @@ public class FaceStatePanel extends ControlPanel { /** * Gets size of model ".obj" * @param path Path - * @return String size in kB + * @return String size in kB or blank string */ private String getSizeText(Path path) { @@ -396,6 +385,11 @@ public class FaceStatePanel extends ControlPanel { return ""; } + /** + * Gets path to feature points file + * @param path Path to face + * @return String path to feature points file or blank string + */ private String getFeaturePointsText(Path path) { if (path != null) { @@ -421,6 +415,11 @@ public class FaceStatePanel extends ControlPanel { return ""; } + /** + * Gets path to preview file + * @param path Path to face + * @return String path to preview file or blank string + */ private String getPreviewText(Path path) { if (path != null) { @@ -437,6 +436,11 @@ public class FaceStatePanel extends ControlPanel { return ""; } + /** + * Gets path to texture file + * @param path Path to face + * @return String path to texture file or blank string + */ private String getTextureText(Path path) { if (path != null) { @@ -455,90 +459,145 @@ public class FaceStatePanel extends ControlPanel { } /** - * Gets icon which shows if face has calculated KD-tree - * @param face HumanFace - * @return ImageIcon either check or notCheck + * Gets number of vertices from face mesh model + * @param faceName String name of face + * @return String number of vertices or blank string */ - private ImageIcon getKdTree(HumanFace face) { - if (face == null) { - kdTreeLabel.setEnabled(false); - return null; + private String getNumberOfVertices(String faceName) { + if (faceName != null && loadedFaces.get(faceName) != null) { + verticesLabel.setEnabled(true); + return "" + loadedFaces.get(faceName).getVerticesInfo(); } - kdTreeLabel.setEnabled(true); - if (face.hasKdTree()) { - return check; + verticesLabel.setEnabled(false); + return ""; + } + + /** + * Gets number of facets from face mesh model + * @param faceName String name of face + * @return String number of facets or blank string + */ + private String getNumberOfFacets(String faceName) { + if (faceName != null && loadedFaces.get(faceName) != null) { + facetsLabel.setEnabled(true); + return "" + loadedFaces.get(faceName).getFecetsInfo(); } - return notCheck; + + facetsLabel.setEnabled(false); + return ""; } /** - * Gets icon which shows if face has featurePoints - * @param face HumanFace - * @return ImageIcon either check or notCheck + * Loads geometry info of face to loadedFaces + * @param faceName String name of face + */ + public void loadFaceGeometryInfo(String faceName) { + + FaceGeometryInfo faceGeometryInfo = new FaceGeometryInfo(getNumberOfVertices(faceName), getNumberOfFacets(faceName), getFeaturePoints(faceName)); + loadedFaces.put(faceName, faceGeometryInfo); + + } + + /** + * Gets feature points of face + * @param faceName String name of face + * @return feature points or empty list */ - private ImageIcon getFeaturePoints(HumanFace face) { + private List<String> getFeaturePoints(String faceName) { - if (face == null) { - featurePointsLoadedLabel.setEnabled(false); - return null; + List<String> featurePoints = Collections.EMPTY_LIST; + if (loadedFaces.get(faceName) != null) { + featurePoints = loadedFaces.get(faceName).getFeaturePointsInfo() + .stream().collect(Collectors.toList()); + return featurePoints; + } + + return featurePoints; + } + + /** + * Loads feature points to combo-box or disable feature points if face + * has not any + * @param faceName String name of face + */ + private void loadFeaturePoints(String faceName) { + DefaultComboBoxModel model = new DefaultComboBoxModel(); + if (faceName != null && + loadedFaces.get(faceName) != null && + !loadedFaces.get(faceName).getFeaturePointsInfo().isEmpty()) { + + fpLabel.setEnabled(true); + jComboBox1.setVisible(true); + + } else { + fpLabel.setEnabled(false); + jComboBox1.setVisible(false); } - featurePointsLoadedLabel.setEnabled(true); - if (face.hasFeaturePoints() || face.findLandmarks() != null) { - return check; + if (faceName != null) { + model.addAll(getFeaturePoints(faceName)); } - return notCheck; + + jComboBox1.setModel(model); } /** - * Checks whether face is loaded in project or not - * If not, button which loads currently selected face to project shows up + * Store face geometry info to loadedFaces * @param face HumanFace */ - private void checkFaceLoaded(HumanFace face) { - warningLabel.setVisible(face == null); - faceNotLoadedLabel.setVisible(face == null); - loadFaceButton.setVisible(face == null); + public void loadFaceGeometryInfo(HumanFace face) { + String vertices = Long.toString(face.getMeshModel().getNumVertices()); + String facets = Integer.toString(face.getMeshModel().getFacets().size()); + List<String> featurePoints = face.getFeaturePoints().stream() + .map(fp -> fp.getFeaturePointType().getName()) + .collect(Collectors.toList()); + + FaceGeometryInfo faceGeometryInfo = new FaceGeometryInfo(vertices, facets, featurePoints); + + loadedFaces.put(face.getShortName(), faceGeometryInfo); } /** - * All information is returned to basic value + * Removes face from loadedFaces + * @param faceName String name of face */ - public void deselectFace() { - this.showFaceState(null, null, null); - warningLabel.setVisible(false); - faceNotLoadedLabel.setVisible(false); - loadFaceButton.setVisible(false); + public void removeFaceByName(String faceName) { + loadedFaces.remove(faceName); + } + + /** + * Removes all loaded faces + */ + public void clearLoadedFaces() { + loadedFaces.clear(); } /** * Face from list is (de)selected * @param selected true if face is selected, false if deselected - * @param face HumanFace * @param name String name of face * @param path Path to face */ - public void newSelection(boolean selected, HumanFace face, String name, Path path) { + public void newSelection(boolean selected, String faceName, Path path) { if (selected) { - this.showFaceState(face, name, path); + this.showFaceState(faceName, path); } else { - this.deselectFace(); + this.showFaceState(null, null); } } // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JLabel faceNotLoadedLabel; - private javax.swing.JPanel facePanel; + private javax.swing.JLabel facetsLabel; + private javax.swing.JLabel facetsOutput; private javax.swing.JLabel featurePointsLabel; - private javax.swing.JLabel featurePointsLoadedLabel; private javax.swing.JLabel featurePointsOutput; private javax.swing.JPanel filePanel; - private javax.swing.JLabel hasFPOutput; - private javax.swing.JLabel hasKDOutput; - private javax.swing.JLabel kdTreeLabel; - private javax.swing.JButton loadFaceButton; + private javax.swing.JLabel fpLabel; + private javax.swing.JPanel geometryPanel; + private javax.swing.JComboBox<String> jComboBox1; + private javax.swing.JButton loadInfoButton; private javax.swing.JLabel pathLabel; private javax.swing.JLabel pathOutput; private javax.swing.JLabel photo; @@ -549,7 +608,8 @@ public class FaceStatePanel extends ControlPanel { private javax.swing.JLabel sizeOutput; private javax.swing.JLabel textureLabel; private javax.swing.JLabel textureOutput; - private javax.swing.JLabel warningLabel; + private javax.swing.JLabel verticesLabel; + private javax.swing.JLabel verticesOutput; // End of variables declaration//GEN-END:variables } diff --git a/GUI/src/main/java/cz/fidentis/analyst/project/ProjectPanel.form b/GUI/src/main/java/cz/fidentis/analyst/project/ProjectPanel.form index 4ea426830f46d797a04ebab6d34c16dbba61fbc3..0f6af971885bde13eb07344ab6b7667233e28dd3 100644 --- a/GUI/src/main/java/cz/fidentis/analyst/project/ProjectPanel.form +++ b/GUI/src/main/java/cz/fidentis/analyst/project/ProjectPanel.form @@ -29,10 +29,7 @@ <EmptySpace min="-2" pref="78" max="-2" attributes="0"/> <Component id="newProjectButton" min="-2" max="-2" attributes="0"/> </Group> - <Group type="102" alignment="1" attributes="0"> - <EmptySpace max="-2" attributes="0"/> - <Component id="openProjectButton" min="-2" max="-2" attributes="0"/> - </Group> + <Component id="openProjectButton" alignment="1" min="-2" max="-2" attributes="0"/> </Group> <Group type="102" alignment="1" attributes="0"> <EmptySpace min="-2" pref="78" max="-2" attributes="0"/> diff --git a/GUI/src/main/java/cz/fidentis/analyst/project/ProjectPanel.java b/GUI/src/main/java/cz/fidentis/analyst/project/ProjectPanel.java index e1cb10bfb1eacbe39d3f2e5d6bfaf8a174973872..6b3cd725fd6ea107dc64a4b6040116bf18085257 100644 --- a/GUI/src/main/java/cz/fidentis/analyst/project/ProjectPanel.java +++ b/GUI/src/main/java/cz/fidentis/analyst/project/ProjectPanel.java @@ -256,9 +256,7 @@ public class ProjectPanel extends JPanel { .addGroup(layout.createSequentialGroup() .addGap(78, 78, 78) .addComponent(newProjectButton)) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(openProjectButton))) + .addComponent(openProjectButton, javax.swing.GroupLayout.Alignment.TRAILING)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGap(78, 78, 78) .addComponent(saveProjectButton))) @@ -334,11 +332,6 @@ public class ProjectPanel extends JPanel { String name = model.getValueAt(selectedRows.get(0), 1).toString(); HumanFace face = project.loadFace(name); - - if (project.getFaceByName(name) == null) { - project.addFace(face); - } - createSingleFaceTab(face, name, false); } @@ -353,14 +346,6 @@ public class ProjectPanel extends JPanel { HumanFace face1 = project.loadFace(name1); HumanFace face2 = project.loadFace(name2); - if (project.getFaceByName(name1) == null) { - project.addFace(face1); - } - - if (project.getFaceByName(name2) == null) { - project.addFace(face2); - } - Object[] options = {face1.getShortName(), face2.getShortName()}; int choice = JOptionPane.showOptionDialog(this, @@ -460,8 +445,8 @@ public class ProjectPanel extends JPanel { while(!tabsToClose.isEmpty()) { tabsToClose.remove(0).close(); } - - project.removeFaceByName(name); + + faceStatePanel.removeFaceByName(name); model.removeRow(row); }); selectedRows.clear(); @@ -499,7 +484,6 @@ public class ProjectPanel extends JPanel { project.setSaved(false); } } - /** * Loads model selected in file chooser by user @@ -577,30 +561,6 @@ public class ProjectPanel extends JPanel { } - /** - * Checks whether face is already loaded in some tab and if it is different tab - * (different tabName) than opens this face again from file (copy of face) - * @param tabName String name of tab which is about to be opened - * @param face HumanFace which will be in tab - * @return either loaded face from project or newly opened face from file - */ - private HumanFace getLoadedOrNewFace(String tabName, HumanFace face) { - - for (FaceTab t : tabs) { - - if (t.hasFace(face.getShortName()) && !t.getName().equals(tabName)) { - - try { - return new HumanFace(Paths.get(face.getPath()).toFile(), true); - - } catch (IOException ex) { - Exceptions.printStackTrace(ex); - } - } - } - return face; - } - /** * Creates and opens tab with one face * @param face which will be analyzed @@ -615,9 +575,6 @@ public class ProjectPanel extends JPanel { }; - // Check if face is already loaded in some other tab - if not, face - // is not open from path but loaded from project - face = getLoadedOrNewFace(name, face); FaceTab newTab = new FaceTab(face, null, name, tabCloseListener); if (!tabs.contains(newTab)) { @@ -628,7 +585,6 @@ public class ProjectPanel extends JPanel { newTab.open(); newTab.requestActive(); this.project.setSaved(false); - areAllFacesLoadedToProject(); } else { @@ -650,11 +606,6 @@ public class ProjectPanel extends JPanel { closeTab(e); } }; - - // Check if face is already loaded in some other tab - if not, face - // is not open from path but loaded from project - face1 = getLoadedOrNewFace(nameOfTab, face1); - face2 = getLoadedOrNewFace(nameOfTab, face2); FaceTab newTab = new FaceTab(face1, face2, nameOfTab, tabCloseListener); if (!tabs.contains(newTab)) { @@ -666,7 +617,6 @@ public class ProjectPanel extends JPanel { newTab.open(); newTab.requestActive(); this.project.setSaved(false); - areAllFacesLoadedToProject(); } else { tabs.stream().filter(t -> (t.equals(newTab))).forEachOrdered(t -> { t.requestActive(); @@ -700,11 +650,8 @@ public class ProjectPanel extends JPanel { * @param selected Boolean true if some face is selected from list, false otherwise */ private void checkFaceState(String faceName, boolean selected) { - - HumanFace face = project.getFaceByName(faceName); Path path = project.getCfg().getPathToFaceByName(faceName); - faceStatePanel.newSelection(selected, face, faceName, path); - + faceStatePanel.newSelection(selected, faceName, path); } /** @@ -728,7 +675,7 @@ public class ProjectPanel extends JPanel { Collections.sort(names); names.forEach(name -> { - HumanFace face = project.getFaceByName(name); + HumanFace face = project.loadFace(name); Path preview = Paths.get(face.getPath().split(".obj")[0] + "_preview.jpg"); model.addRowWithName(name, preview); }); @@ -742,7 +689,7 @@ public class ProjectPanel extends JPanel { deselectAllRows(); for (int i = 0; i < model.getRowCount(); i++) { - HumanFace face = project.getFaceByName(model.getValueAt(i, 1).toString()); + HumanFace face = project.loadFace(model.getValueAt(i, 1).toString()); if ((isKdTreeFilter && !face.hasKdTree()) || (isFeaturePointsFilter && !face.hasFeaturePoints())) { model.setValueAt(true, i, 0); @@ -793,7 +740,7 @@ public class ProjectPanel extends JPanel { while (!tabs.isEmpty()) { tabs.get(0).close(); } - project.removeAll(); + faceStatePanel.clearLoadedFaces(); model.setRowCount(0); checkFaceState(null, false); selectedRows.clear(); @@ -803,7 +750,7 @@ public class ProjectPanel extends JPanel { /** * Checks whether current project is saved, if not then asks user if he wants * to save it - * @return + * @return false if user cancels selection, true otherwise */ private boolean loadNewProject() { if (!project.isSaved()) { @@ -952,31 +899,14 @@ public class ProjectPanel extends JPanel { } /** - * Loads currently selected (clicked in table) face to project + * Loads currently selected (clicked in table) face geometry info */ public void loadCurrentlySelectedFace() { + String name = table.getValueAt(table.getSelectedRow(), 1).toString(); - project.loadFace(name); + HumanFace face = project.loadFace(name); + faceStatePanel.loadFaceGeometryInfo(face); checkFaceState(name, true); - areAllFacesLoadedToProject(); - } - - /** - * Checks whether all faces from list are loaded to project - */ - public void areAllFacesLoadedToProject() { - - for (int i = 0; i < model.getRowCount(); i++) { - HumanFace face = project.getFaceByName(model.getValueAt(i, 1).toString()); - - if (face == null) { - filterPanel.checkAllFacesLoaded(false); - return; - } - } - - filterPanel.checkAllFacesLoaded(true); - } /** diff --git a/GUI/src/main/resources/cz/fidentis/analyst/project/Bundle.properties b/GUI/src/main/resources/cz/fidentis/analyst/project/Bundle.properties index 5c1b82d3eaa55f23527054b3571e919e25533537..19ed0260e88c6efd3f19883f13ce5cf7f04155cf 100644 --- a/GUI/src/main/resources/cz/fidentis/analyst/project/Bundle.properties +++ b/GUI/src/main/resources/cz/fidentis/analyst/project/Bundle.properties @@ -1,13 +1,11 @@ -FaceStatePanel.facePanel.border.title=Face info -FaceStatePanel.kdTreeLabel.text=Has KD - tree : -FaceStatePanel.featurePointsLoadedLabel.text=Feature points loaded : +FaceStatePanel.filePanel.AccessibleContext.accessibleName=File info +FaceStatePanel.filePanel.border.title=File info +FaceStatePanel.pathLabel.text=Path : +FaceStatePanel.sizeLabel.text=Size : +FaceStatePanel.pathOutput.text= +FaceStatePanel.sizeOutput.text= FaceStatePanel.photoPanel.border.title=Photo FaceStatePanel.photo.text= -FaceStatePanel.hasKDOutput.text= -FaceStatePanel.hasFPOutput.text= -FaceStatePanel.warningLabel.text= -FaceStatePanel.faceNotLoadedLabel.text=Face not loaded -FaceStatePanel.loadFaceButton.text=Load face FilterPanel.filterPanel.border.title=Filter settings FilterPanel.hasFP.text=has feature points FilterPanel.hasKD.text=has kd-tree @@ -25,6 +23,12 @@ ProjectPanel.deselectAllButton.text=Deselect all ProjectPanel.selectAllButton.text=Select all ProjectPanel.removeButton.text=Remove ProjectPanel.addButton.text=Add +FaceStatePanel.geometryPanel.border.title=Geometry info +FaceStatePanel.verticesLabel.text=Number of vertices : +FaceStatePanel.facetsLabel.text=Number of facets : +FaceStatePanel.fpLabel.text=Feature points : +FaceStatePanel.verticesOutput.text= +FaceStatePanel.facetsOutput.text= FaceStatePanel.textureOutput.text= FaceStatePanel.previewOutput.text= FaceStatePanel.featurePointsOutput.text= @@ -37,3 +41,4 @@ FaceStatePanel.sizeLabel.text=Size : FaceStatePanel.pathLabel.text=Path : FaceStatePanel.filePanel.AccessibleContext.accessibleName=File info FaceStatePanel.filePanel.border.title=File info +FaceStatePanel.loadInfoButton.text=(Re)Load info