Skip to content
Snippets Groups Projects
Verified Commit 62c66b62 authored by philippe.verley_ird.fr's avatar philippe.verley_ird.fr Committed by philippe.verley_ird.fr
Browse files

Plugged in the new Visualization module to AMAPVoxGUI. Temporarily kept two...

Plugged in the new Visualization module to AMAPVoxGUI. Temporarily kept two buttons 3D Viewer and New 3D Viewer for comparison.
parent 1ccfd22e
No related branches found
No related tags found
No related merge requests found
......@@ -110,7 +110,10 @@
<dependency>
<groupId>fr.amap.lidar.amapvox</groupId>
<artifactId>amapvox-core</artifactId>
<type>jar</type>
</dependency>
<dependency>
<groupId>amap.lidar.amapvox</groupId>
<artifactId>visualization</artifactId>
</dependency>
<dependency>
<groupId>fr.amap.threed</groupId>
......
......@@ -8,23 +8,29 @@ package fr.amap.lidar.amapvox.gui.viewer3d;
import com.jogamp.common.nio.Buffers;
import com.jogamp.newt.event.KeyAdapter;
import com.jogamp.newt.event.KeyEvent;
<<<<<<< HEAD
import fr.amap.commons.math.geometry.BoundingBox2F;
import fr.amap.commons.raster.asc.AsciiGridHelper;
import fr.amap.commons.raster.asc.Raster;
import fr.amap.commons.math.util.MatrixFileParser;
=======
import fr.amap.commons.math.point.Point3D;
import fr.amap.commons.math.point.Point3F;
import fr.amap.commons.math.vector.Vec3F;
import fr.amap.commons.raster.asc.Raster;
>>>>>>> 1ab82ce1 (Plugged in the new Visualization module to AMAPVoxGUI. Temporarily kept two buttons 3D Viewer and New 3D Viewer for comparison.)
import fr.amap.commons.util.image.ScaleGradient;
import fr.amap.lidar.amapvox.commons.VoxelSpaceInfos;
import fr.amap.lidar.amapvox.gui.DialogHelper;
import fr.amap.commons.javafx.io.FileChooserContext;
import fr.amap.commons.raster.asc.Face;
import fr.amap.commons.raster.asc.Point;
import fr.amap.commons.util.ColorGradient;
import fr.amap.lidar.amapvox.gui.DragAndDropHelper;
import fr.amap.lidar.amapvox.visualization.Visualization;
import fr.amap.lidar.amapvox.voxreader.VoxelFileReader;
import fr.amap.viewer3d.FXNewtOverlap;
import fr.amap.viewer3d.SimpleViewer;
import fr.amap.viewer3d.loading.shader.InstanceLightedShader;
import fr.amap.viewer3d.loading.shader.PhongShader;
import fr.amap.viewer3d.loading.shader.SimpleShader;
import fr.amap.viewer3d.loading.shader.TextureShader;
import fr.amap.viewer3d.loading.texture.Texture;
......@@ -41,14 +47,16 @@ import java.awt.Color;
import java.awt.image.BufferedImage;
import java.beans.PropertyChangeEvent;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URL;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.ResourceBundle;
import java.util.logging.Level;
import javafx.application.Platform;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.value.ObservableValue;
import javafx.collections.ObservableList;
import javafx.concurrent.Service;
import javafx.concurrent.Task;
......@@ -59,23 +67,27 @@ import javafx.fxml.Initializable;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox;
import javafx.scene.control.TextField;
import javafx.scene.input.DragEvent;
import javafx.scene.input.Dragboard;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.FileChooser;
import javafx.stage.Screen;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;
<<<<<<< HEAD
import javax.vecmath.Matrix4d;
import javax.vecmath.Point2f;
import javax.vecmath.Point3d;
import javax.vecmath.Point3f;
import javax.vecmath.Vector3d;
import javax.vecmath.Vector3f;
=======
import javax.swing.SwingUtilities;
import javax.vecmath.Point3d;
import javax.vecmath.Point3f;
>>>>>>> 1ab82ce1 (Plugged in the new Visualization module to AMAPVoxGUI. Temporarily kept two buttons 3D Viewer and New 3D Viewer for comparison.)
import org.apache.log4j.Logger;
import org.controlsfx.dialog.ProgressDialog;
......@@ -94,34 +106,17 @@ public class Viewer3DPanelController implements Initializable {
private FileChooserContext fileChooserOpenVoxelFile;
private File currentVoxelFile;
private FileChooserContext fileChooserOpenDTMFile;
private FileChooserContext fileChooserOpenMatrixFile;
private Matrix4d rasterTransfMatrix;
@FXML
private TextField textFieldVoxelFile;
@FXML
private ComboBox<String> comboboxAttributeToView;
@FXML
private VBox vboxRasterProperties;
@FXML
private HBox hboxRasterFile;
@FXML
private HBox hboxAttributeToView;
@FXML
private TextField textfieldRasterFilePath;
@FXML
private CheckBox checkboxUseTransformationMatrix;
@FXML
private Button buttonSetTransformationMatrix;
@FXML
private CheckBox checkboxFitRasterToVoxelSpace;
@FXML
private TextField textfieldRasterFittingMargin;
@FXML
private Button buttonOpen3DView;
@FXML
private Button buttonOpenNew3DView;
/**
* Initialises the controller class.
......@@ -142,26 +137,9 @@ public class Viewer3DPanelController implements Initializable {
if (file != null) {
textFieldVoxelFile.setText(file.getAbsolutePath());
updateCurrentVoxelFile(file);
hboxRasterFile.setDisable(false);
hboxAttributeToView.setDisable(false);
buttonOpen3DView.setDisable(false);
}
}
}
event.setDropCompleted(success);
event.consume();
});
textfieldRasterFilePath.setOnDragOver(DragAndDropHelper.dragOverEvent);
textfieldRasterFilePath.setOnDragDropped((DragEvent event)
-> {
Dragboard db = event.getDragboard();
boolean success = false;
if (db.hasFiles() && db.getFiles().size() == 1) {
success = true;
for (File file : db.getFiles()) {
if (file != null) {
textfieldRasterFilePath.setText(file.getAbsolutePath());
buttonOpenNew3DView.setDisable(false);
}
}
}
......@@ -174,21 +152,6 @@ public class Viewer3DPanelController implements Initializable {
fileChooserOpenVoxelFile.fc.getExtensionFilters().addAll(
new FileChooser.ExtensionFilter("All Files", "*"),
new FileChooser.ExtensionFilter("Voxel Files", "*.vox"));
fileChooserOpenDTMFile = new FileChooserContext();
fileChooserOpenDTMFile.fc.setTitle("Choose DTM file");
fileChooserOpenDTMFile.fc.getExtensionFilters().addAll(
new FileChooser.ExtensionFilter("All Files", "*"),
new FileChooser.ExtensionFilter("DTM Files", "*.asc"));
fileChooserOpenMatrixFile = new FileChooserContext();
rasterTransfMatrix = new Matrix4d();
rasterTransfMatrix.setIdentity();
checkboxUseTransformationMatrix.selectedProperty().addListener((ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> {
buttonSetTransformationMatrix.setDisable(!newValue);
});
}
private void updateCurrentVoxelFile(File voxelFile) {
......@@ -218,6 +181,7 @@ public class Viewer3DPanelController implements Initializable {
}
buttonOpen3DView.setDisable(false);
buttonOpenNew3DView.setDisable(false);
} catch (Exception ex) {
LOGGER.error("Cannot read voxel file", ex);
}
......@@ -249,63 +213,29 @@ public class Viewer3DPanelController implements Initializable {
if (selectedFile != null) {
textFieldVoxelFile.setText(selectedFile.getAbsolutePath());
updateCurrentVoxelFile(selectedFile);
hboxRasterFile.setDisable(false);
hboxAttributeToView.setDisable(false);
buttonOpen3DView.setDisable(false);
buttonOpenNew3DView.setDisable(false);
} else {
hboxRasterFile.setDisable(true);
vboxRasterProperties.setDisable(true);
hboxAttributeToView.setDisable(true);
buttonOpen3DView.setDisable(true);
buttonOpenNew3DView.setDisable(true);
}
}
@FXML
private void onActionButtonOpenRasterFile(ActionEvent event) {
if (currentVoxelFile != null) {
fileChooserOpenDTMFile.fc.setInitialDirectory(currentVoxelFile.getParentFile());
}
File selectedFile = fileChooserOpenDTMFile.showOpenDialog(stage);
if (selectedFile != null) {
textfieldRasterFilePath.setText(selectedFile.getAbsolutePath());
vboxRasterProperties.setDisable(false);
} else {
vboxRasterProperties.setDisable(true);
}
}
@FXML
private void onActionButtonSetTransformationMatrix(ActionEvent event) {
fileChooserOpenMatrixFile.fc.setInitialDirectory(currentVoxelFile.getParentFile());
private void onActionButtonNewVisualization(ActionEvent event) {
File selectedFile = fileChooserOpenMatrixFile.showOpenDialog(stage);
if (selectedFile != null) {
Matrix4d mat;
final File voxelFile = currentVoxelFile;
//final String attributeToView = comboboxAttributeToView.getSelectionModel().getSelectedItem();
SwingUtilities.invokeLater(() -> {
try {
mat = MatrixFileParser.getMatrixFromFile(selectedFile);
if (mat != null) {
rasterTransfMatrix = MatrixFileParser.getMatrixFromFile(selectedFile);
if (rasterTransfMatrix == null) {
rasterTransfMatrix = new Matrix4d();
rasterTransfMatrix.setIdentity();
}
} else {
DialogHelper.showErrorDialog(stage, new Exception("bad format"));
}
} catch (IOException ex) {
LOGGER.error("Cannot read matrix file", ex);
Visualization.launch(new FileInputStream(voxelFile));
} catch (FileNotFoundException ex) {
LOGGER.error(ex);
}
}
});
}
@FXML
......@@ -314,6 +244,7 @@ public class Viewer3DPanelController implements Initializable {
final File voxelFile = currentVoxelFile;
final String attributeToView = comboboxAttributeToView.getSelectionModel().getSelectedItem();
<<<<<<< HEAD
final File dtmFile = new File(textfieldRasterFilePath.getText());
final boolean drawDTM = dtmFile.exists();
final Matrix4d dtmVOPMatrix = rasterTransfMatrix;
......@@ -321,6 +252,8 @@ public class Viewer3DPanelController implements Initializable {
final int mntFittingMargin = Integer.valueOf(textfieldRasterFittingMargin.getText());
final boolean transform = checkboxUseTransformationMatrix.isSelected();
=======
>>>>>>> 1ab82ce1 (Plugged in the new Visualization module to AMAPVoxGUI. Temporarily kept two buttons 3D Viewer and New 3D Viewer for comparison.)
//window size
ObservableList<Screen> screens = Screen.getScreens();
......@@ -414,6 +347,7 @@ public class Viewer3DPanelController implements Initializable {
infos.setMinCorner(new Point3d());
/**
<<<<<<< HEAD
* *DTM**
*/
SceneObject dtmSceneObject = null;
......@@ -455,6 +389,8 @@ public class Viewer3DPanelController implements Initializable {
}
/**
=======
>>>>>>> 1ab82ce1 (Plugged in the new Visualization module to AMAPVoxGUI. Temporarily kept two buttons 3D Viewer and New 3D Viewer for comparison.)
* *scale**
*/
updateMessage("Generating scale");
......@@ -499,6 +435,7 @@ public class Viewer3DPanelController implements Initializable {
});
/**
<<<<<<< HEAD
* Axis
*/
/*InputStream axis3ObjStream = SimpleViewer.class.getResourceAsStream("/mesh/axis3.obj");
......@@ -512,6 +449,8 @@ public class Viewer3DPanelController implements Initializable {
axisSceneObject.setShader(new AxisShader());
viewer3D.getScene().addSceneObject(axisSceneObject);*/
/**
=======
>>>>>>> 1ab82ce1 (Plugged in the new Visualization module to AMAPVoxGUI. Temporarily kept two buttons 3D Viewer and New 3D Viewer for comparison.)
* *light**
*/
scene.setLightPosition(new Point3f(voxelSpace.getGravityCenter().x, voxelSpace.getGravityCenter().y, voxelSpace.getGravityCenter().z + voxelSpace.widthZ + 100));
......@@ -524,8 +463,6 @@ public class Viewer3DPanelController implements Initializable {
trackballCamera.setLocation(new Vector3f(voxelSpace.getGravityCenter().x + voxelSpace.widthX, voxelSpace.getGravityCenter().y + voxelSpace.widthY, voxelSpace.getGravityCenter().z + voxelSpace.widthZ));
viewer3D.getScene().setCamera(trackballCamera);
final SceneObject dtmSceneObjectFinal = dtmSceneObject;
Platform.runLater(() -> {
final Stage viewer3DStage = new Stage();
final FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/viewer3d/Viewer3DFrame.fxml"));
......@@ -542,11 +479,17 @@ public class Viewer3DPanelController implements Initializable {
viewer3DFrameController.setAttributes(attributeToView, voxelSpace.data.getVoxelSpaceInfos().getColumnNames());
viewer3DFrameController.initContent(voxelSpace);
viewer3DFrameController.addSceneObject(voxelSpace, voxelFile.getName());
<<<<<<< HEAD
if (dtmSceneObjectFinal != null) {
viewer3DFrameController.addSceneObject(dtmSceneObjectFinal, dtmFile.getName());
}
SceneObjectListener listener = (SceneObject sceneObject, MousePicker mousePicker, Point3d intersection) -> {
Vector3f camLocation = viewer3D.getScene().getCamera().getLocation();
=======
SceneObjectListener listener = (SceneObject sceneObject, MousePicker mousePicker, Point3D intersection) -> {
Vec3F camLocation = viewer3D.getScene().getCamera().getLocation();
>>>>>>> 1ab82ce1 (Plugged in the new Visualization module to AMAPVoxGUI. Temporarily kept two buttons 3D Viewer and New 3D Viewer for comparison.)
VoxelObject selectedVoxel = voxelSpace.doPicking(mousePicker);
if (selectedVoxel != null) {
LinkedHashMap<String, Double> attributes = new LinkedHashMap<>();
......
......@@ -26,85 +26,47 @@
<AnchorPane id="AnchorPane" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="fr.amap.lidar.amapvox.gui.viewer3d.Viewer3DPanelController">
<children>
<ScrollPane fitToWidth="true" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<content>
<VBox>
<children>
<TitledPane collapsible="false" text="Visualization">
<content>
<VBox spacing="10.0">
<children>
<Label text="Voxel file" />
<VBox spacing="10.0">
<children>
<HBox>
<children>
<TextField fx:id="textFieldVoxelFile" editable="false" prefHeight="25.0" prefWidth="350" />
<Button contentDisplay="CENTER" mnemonicParsing="false" onAction="#onActionButtonOpenVoxelFile" text="..." />
</children>
</HBox>
<HBox fx:id="hboxAttributeToView" alignment="CENTER_LEFT" disable="true" spacing="10.0">
<children>
<Label text="Attribute to view" />
<ComboBox fx:id="comboboxAttributeToView" prefHeight="25.0" prefWidth="150.0" />
</children>
</HBox>
</children>
<padding>
<Insets left="25.0" />
</padding>
</VBox>
<Label text="Raster file" />
<VBox spacing="10.0">
<children>
<HBox fx:id="hboxRasterFile" disable="true">
<children>
<TextField fx:id="textfieldRasterFilePath" editable="false" prefHeight="25.0" prefWidth="350.0" />
<Button mnemonicParsing="false" onAction="#onActionButtonOpenRasterFile" text="..." />
</children>
</HBox>
<VBox fx:id="vboxRasterProperties" disable="true" spacing="10.0">
<children>
<CheckBox fx:id="checkboxUseTransformationMatrix" mnemonicParsing="false" prefHeight="30.0" prefWidth="280.0">
<graphic>
<HBox alignment="CENTER_LEFT" spacing="10.0">
<children>
<Label text="Transformation" />
<Button fx:id="buttonSetTransformationMatrix" disable="true" mnemonicParsing="false" onAction="#onActionButtonSetTransformationMatrix">
<graphic>
<ImageView fitHeight="20.0" fitWidth="20.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@../icons/Interaction_Transformation.png" />
</image>
</ImageView>
</graphic>
</Button>
</children>
</HBox>
</graphic>
</CheckBox>
<HBox alignment="CENTER_LEFT" spacing="10.0">
<children>
<CheckBox fx:id="checkboxFitRasterToVoxelSpace" mnemonicParsing="false" selected="true" text="Fit to voxel space" />
<Label text="Margin (cell number)" />
<TextField fx:id="textfieldRasterFittingMargin" prefHeight="25.0" prefWidth="60.0" text="0" />
</children>
</HBox>
</children>
</VBox>
</children>
<padding>
<Insets left="25.0" />
</padding>
</VBox>
</children>
</VBox>
</content>
</TitledPane>
</children>
</VBox>
</content>
</ScrollPane>
<Button fx:id="buttonOpen3DView" disable="true" mnemonicParsing="false" onAction="#onActionButtonVizualize" text="Open 3D viewer" AnchorPane.bottomAnchor="10.0" AnchorPane.rightAnchor="10.0" />
<ScrollPane fitToWidth="true" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<content>
<VBox>
<children>
<TitledPane collapsible="false" text="Visualization">
<content>
<VBox spacing="25.0">
<children>
<VBox spacing="10.0">
<children>
<HBox alignment="CENTER_LEFT" spacing="10.0">
<children>
<Label text="Voxel file" />
<TextField fx:id="textFieldVoxelFile" editable="false" prefHeight="25.0" prefWidth="350" />
<Button contentDisplay="CENTER" mnemonicParsing="false" onAction="#onActionButtonOpenVoxelFile" text="..." />
</children>
</HBox>
<HBox fx:id="hboxAttributeToView" alignment="CENTER_LEFT" disable="true" spacing="10.0">
<children>
<Label text="Attribute to view" />
<ComboBox fx:id="comboboxAttributeToView" prefHeight="25.0" prefWidth="150.0" />
</children>
</HBox>
</children>
<padding>
<Insets left="25.0" />
</padding>
</VBox>
<HBox spacing="10.0" alignment="CENTER_LEFT" >
<children>
<Button fx:id="buttonOpen3DView" disable="true" mnemonicParsing="false" onAction="#onActionButtonVizualize" text="Open 3D viewer" />
<Button fx:id="buttonOpenNew3DView" disable="true" mnemonicParsing="false" onAction="#onActionButtonNewVisualization" text="Open new 3D viewer" />
</children>
</HBox>
</children>
</VBox>
</content>
</TitledPane>
</children>
</VBox>
</content>
</ScrollPane>
</children>
</AnchorPane>
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