Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Instrument Control
Protos
Nomad 3D
nomad-3d-editor
Commits
bca6294f
Commit
bca6294f
authored
Mar 22, 2019
by
yannick legoc
Browse files
Reset the center of the camera when changing the displayed root
parent
2f335de8
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/main/java/fr/ill/ics/n3d/Nomad3DEditor.java
View file @
bca6294f
...
...
@@ -417,13 +417,21 @@ public class Nomad3DEditor extends Application {
buildEventHandlers
(
axesGroup
);
// Initialize the camera position
Bounds
rootBounds
=
this
.
model
.
getRoot
().
getSceneNode
().
localToScene
(
this
.
model
.
getRoot
().
getSceneNode
().
getBoundsInLocal
());
resetCamera
(
this
.
model
.
getRoot
());
return
scene
;
}
/**
* Sets the camera center and zoom according to the component.
* @param component
*/
private
void
resetCamera
(
Component
component
)
{
Bounds
rootBounds
=
component
.
getSceneNode
().
localToScene
(
component
.
getSceneNode
().
getBoundsInLocal
());
Point3D
rootCenter
=
new
Point3D
(
rootBounds
.
getMinX
(),
rootBounds
.
getMinY
(),
rootBounds
.
getMinZ
());
rootCenter
=
rootCenter
.
add
(
rootBounds
.
getWidth
()
/
2.0
,
rootBounds
.
getHeight
()
/
2.0
,
rootBounds
.
getDepth
()
/
2.0
);
this
.
controls
.
setCenter
(
rootCenter
);
this
.
controls
.
zoom
(-
1.0
*
((
new
Point3D
(
rootBounds
.
getWidth
(),
rootBounds
.
getHeight
(),
rootBounds
.
getDepth
())).
magnitude
()),
false
,
false
);
return
scene
;
}
/**
...
...
@@ -695,10 +703,20 @@ public class Nomad3DEditor extends Application {
}
}
public
void
setComponentAsRoot
(
Component
component
)
{
/**
* Sets the component as the displayed root.
* The tree view is modified as well as the camera to change the center to the displayed component.
* @param component
*/
public
void
setDisplayedRootComponent
(
Component
component
)
{
// Set the components that are not in the hierarchy of the new root component invisible.
Nomad3DEditor
.
getInstance
().
getModel
().
getRoot
().
resetVisible
(
component
);
menuBar
.
setDisplayedRoot
(
component
);
// Change the tree view.
menuBar
.
setDisplayedRootComponent
(
component
);
// Change the center of the camera.
resetCamera
(
component
);
}
}
src/main/java/fr/ill/ics/n3d/gui/EditorMenuBar.java
View file @
bca6294f
...
...
@@ -3001,7 +3001,7 @@ public class EditorMenuBar extends MenuBar {
updateScene
(
Nomad3DEditor
.
getInstance
().
getModel
().
getDisplayedRoot
());
}
public
void
setDisplayedRoot
(
Component
component
)
{
public
void
setDisplayedRoot
Component
(
Component
component
)
{
// Save the expanded state of the tree items.
HashMap
<
String
,
Boolean
>
itemStates
=
Nomad3DEditor
.
getInstance
().
getTreeViewExpandedStates
(
component
.
getTreeItem
());
...
...
src/main/java/fr/ill/ics/n3d/gui/HierarchyCell.java
View file @
bca6294f
...
...
@@ -63,7 +63,7 @@ public class HierarchyCell extends CheckBoxTreeCell<Component> {
Component
component
=
getItem
();
// Set it as the displayed root.
Nomad3DEditor
.
getInstance
().
setComponent
AsRoot
(
component
);
Nomad3DEditor
.
getInstance
().
set
DisplayedRoot
Component
(
component
);
}
});
...
...
@@ -73,7 +73,7 @@ public class HierarchyCell extends CheckBoxTreeCell<Component> {
displayAllTheComponentsItem
.
setOnAction
(
new
EventHandler
<
ActionEvent
>()
{
public
void
handle
(
ActionEvent
t
)
{
// Reset with the root component.
Nomad3DEditor
.
getInstance
().
setComponent
AsRoot
(
Nomad3DEditor
.
getInstance
().
getModel
().
getRoot
());
Nomad3DEditor
.
getInstance
().
set
DisplayedRoot
Component
(
Nomad3DEditor
.
getInstance
().
getModel
().
getRoot
());
}
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment