Skip to content
Snippets Groups Projects
Commit a53cbdf4 authored by Matej Kovár's avatar Matej Kovár Committed by Radek Ošlejšek
Browse files

Resolve "Indicate faces analyzed in multiple tasks"

parent 988dfb20
No related branches found
No related tags found
No related merge requests found
Showing
with 657 additions and 268 deletions
......@@ -5,11 +5,9 @@ import cz.fidentis.analyst.faceState.FaceStatePanel;
import cz.fidentis.analyst.core.ControlPanel;
import cz.fidentis.analyst.core.OutputWindowThread;
import cz.fidentis.analyst.core.TopControlPanel;
import cz.fidentis.analyst.gui.Installer;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.GroupLayout;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.LayoutStyle;
import org.netbeans.api.settings.ConvertAsProperties;
......@@ -50,7 +48,6 @@ public final class ProjectTopComp extends TopComponent {
private final ProjectPanel projectPanel;
private final TopControlPanel controlPanel;
//private final JScrollPane projectPanelScrollPane;
private final JScrollPane controlPanelScrollPane;
public static final int CONTROL_PANEL_TAB_POSITION_FILTER_PANEL = 1;
......@@ -104,8 +101,6 @@ public final class ProjectTopComp extends TopComponent {
// Asks user whether he wants to create new project or open existing
projectPanel.openExistingOrNewProject();
// Pass this class to installer so it can call method of this class on close
Installer inst = new Installer(this);
this.repaint();
}
......@@ -159,21 +154,4 @@ public final class ProjectTopComp extends TopComponent {
String version = p.getProperty("version");
// TODO read your settings according to their version
}
/**
* Checks whether currently opened project is saved or not and asks user
* whether he wants to save it or not on close
*/
public void saveProjectOnClose() {
if (!projectPanel.isProjectSaved()) {
int save = JOptionPane.showConfirmDialog(null,
"Project is not saved. Would you like to save project?", "Save project", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
if (save == JOptionPane.YES_OPTION) {
projectPanel.saveProject();
}
}
}
}
package cz.fidentis.analyst.project;
import cz.fidentis.analyst.face.HumanFace;
import cz.fidentis.analyst.scene.Camera;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.RandomAccessFile;
import java.io.Serializable;
import java.nio.file.Paths;
/**
*
* @author Matej Kovar
*/
public class Task implements Serializable {
private HumanFace primary = null;
private HumanFace secondary = null;
private Camera camera = null;
/**
* Constructor for task
* @param primary human face
* @param secondary human face (or null)
* @param camera camera
*/
public Task(HumanFace primary, HumanFace secondary, Camera camera) {
this.primary = primary;
this.secondary = secondary;
this.camera = camera;
}
public HumanFace getPrimary() {
return primary;
}
public void setPrimary(HumanFace primary) {
this.primary = primary;
}
public HumanFace getSecondary() {
return secondary;
}
public void setSecondary(HumanFace secondary) {
this.secondary = secondary;
}
public Camera getCamera() {
return camera;
}
public void setCamera(Camera camera) {
this.camera = camera;
}
/**
* Serializes data into file
* @param pathToProjectDirectory path to project directory
* @return file where data is stored
* @throws IOException exception
*/
public File dumpToFile(String pathToProjectDirectory) throws IOException {
File projectDirectory = Paths.get(pathToProjectDirectory).toFile();
String name = primary.getShortName();
if (secondary != null) {
name = primary.getShortName() + "_TO_" + secondary.getShortName();
}
File file = new File(projectDirectory.toString() + File.separatorChar + name + ".bin");
//file.deleteOnExit();
RandomAccessFile raf = new RandomAccessFile(file, "rw");
try (ObjectOutputStream fos = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(raf.getFD())))) {
fos.writeObject(this);
fos.flush();
}
return file;
}
/**
* Restores serialized data from file
* @param dumpFile file with serialized data
* @return instance of Task class with primary, secondary and camera
* @throws IOException
* @throws ClassNotFoundException
*/
public static Task restoreFromFile(File dumpFile) throws IOException, ClassNotFoundException {
try (ObjectInputStream fos = new ObjectInputStream(new BufferedInputStream(new FileInputStream(dumpFile)))) {
return (Task) fos.readObject();
}
}
/**
* Tries to delete task from disc
* @param pathToTask path to task
*/
public static void endTask(String pathToTask) {
File file = new File(pathToTask);
if (file.exists()) {
file.delete();
}
}
}
package cz.fidentis.analyst.project;
import java.awt.Component;
import javax.swing.AbstractCellEditor;
import javax.swing.JComboBox;
import javax.swing.JTable;
import javax.swing.table.TableCellEditor;
/**
*
* @author Matej Kovar
*/
public class TaskCellEditor extends AbstractCellEditor implements TableCellEditor {
private JComboBox comboBox;
TaskCellEditor() {
comboBox = new JComboBox();
//comboBox.setOpaque(true);
//comboBox.setBackground(Color.white);
}
@Override
public Object getCellEditorValue() {
return comboBox;
}
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
comboBox = ((JComboBox)value);
return comboBox;
}
}
package cz.fidentis.analyst.project;
import java.awt.Component;
import javax.swing.JComboBox;
import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;
/**
*
* @author Matej Kovar
*/
public class TaskCellRenderer extends JComboBox implements TableCellRenderer {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
//setOpaque(true);
setSelectedItem(value);
//this.setForeground(this.getBackground());
//setBackground(Color.white);
return this;
}
}
package cz.fidentis.analyst.scene;
import java.io.Serializable;
import javax.vecmath.Vector3d;
/**
......@@ -8,7 +9,7 @@ import javax.vecmath.Vector3d;
* @author Natalia Bebjakova
* @author Radek Oslejsek
*/
public class Camera {
public class Camera implements Serializable {
public static final Vector3d DEFAULT_POSITION = new Vector3d(0, 0, 300);
......
......@@ -60,7 +60,7 @@ public class DrawablePlane extends Drawable {
/**
* Switches on/off bounding box rendering.
*
* @param show If {@code true], then the bounding box is rendered as well
* @param show If {@code true}, then the bounding box is rendered as well
*/
public void setShowBBox(boolean show) {
this.showBoundingBox = show;
......
......@@ -23,9 +23,7 @@ public class DrawablePointCloud extends Drawable {
/**
* Constructor.
*
* @param featurePoints Feature points
* @param defaultColor Default color
* @param defaultPerimeter Default perimeter
* @param points Feature points
*/
public DrawablePointCloud(List<MeshPoint> points) {
this.points = points;
......
......@@ -236,7 +236,7 @@ public class Scene {
* If the drawable is {@code null}, then the drawable is removed.
*
* @param slot Slot of the drawable
* @param face New face or {@code null}
* @param dr Drawable
*/
public boolean setOtherDrawable(int slot, Drawable dr) {
if (slot < 0 || slot >= Scene.MAX_FACES_IN_SCENE) {
......
......@@ -7,10 +7,12 @@ FaceStatePanel.sizeOutput.text=
ProjectPanel.newProjectButton.text=
ProjectPanel.openProjectButton.text=
ProjectPanel.saveProjectButton.text=
ProjectPanel.analyseButton.text=Analyse
ProjectPanel.analyseButton.text=Create Task
ProjectPanel.inflateButton.text=Inflate
ProjectPanel.deselectAllButton.text=Deselect all
ProjectPanel.selectAllButton.text=Select all
ProjectPanel.removeButton.text=Remove
ProjectPanel.addButton.text=Add
FilterPanel.nameTextField.text=
ProjectPanel.projectNameLabel.text=Project name :
ProjectPanel.projectNameOutput.text=
......@@ -13,6 +13,7 @@ import javax.vecmath.Vector3d;
*
* @author Natalia Bebjakova
* @author Dominik Racek
* @author Enkh-Undral EnkhBayar
*/
public class MeshTriangle implements Iterable<MeshPoint> {
......@@ -146,8 +147,6 @@ public class MeshTriangle implements Iterable<MeshPoint> {
* @param second second point on second line
* Must not be {@code null}
* @return point of intersection or {@code null} if the lines are parallel
*
* @author Enkh-Undral EnkhBayar
*/
protected static Point3d getLinesIntersection(Point3d origin, Vector3d vector, Point3d first, Point3d second) {
Point3d o = new Point3d(origin);
......@@ -231,8 +230,6 @@ public class MeshTriangle implements Iterable<MeshPoint> {
* @param origin Point of origin form which the ray starts
* @param vector directional vector of the ray
* @return point of intersection or null if there is no intersection
*
* @author Enkh-Undral EnkhBayar
*/
public Point3d getRayIntersection(Point3d origin, Vector3d vector) {
Vector3d normal = computeNormal();
......@@ -484,8 +481,6 @@ public class MeshTriangle implements Iterable<MeshPoint> {
*
* @param point Point located on the plane of the triangle
* @return true if point is in triangle, false otherwise
*
* @author Enkh-Undral EnkhBayar
*/
public boolean isPointInTriangle(Point3d point) {
// https://www.scratchapixel.com/lessons/3d-basic-rendering/ray-tracing-rendering-a-triangle/barycentric-coordinates
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment