Skip to content
GitLab
Projects
Groups
Snippets
/
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
c5142824
Commit
c5142824
authored
Feb 15, 2019
by
legoc
Browse files
Added reference axis list display
parent
b403dec0
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/fr/ill/ics/n3d/gui/EditorMenuBar.java
View file @
c5142824
...
...
@@ -149,6 +149,13 @@ public class EditorMenuBar extends MenuBar {
this
.
componentName
=
new
SimpleStringProperty
(
componentName
);
this
.
type
=
new
SimpleStringProperty
(
type
);
}
private
AxisTableEntry
(
String
axisName
)
{
super
();
this
.
axisName
=
new
SimpleStringProperty
(
axisName
);
this
.
componentName
=
new
SimpleStringProperty
(
""
);
this
.
type
=
new
SimpleStringProperty
(
""
);
}
public
String
getAxisName
()
{
return
axisName
.
get
();
...
...
@@ -1475,8 +1482,7 @@ public class EditorMenuBar extends MenuBar {
Group
rootNode
=
(
Group
)
Nomad3DEditor
.
getInstance
().
getModel
().
getRoot
().
getSceneNode
();
// We set it at the end of the group so that it is always in front of the components.
rootNode
.
getChildren
().
add
(
0
,
referenceAxisBuilder
.
getVisualGroup
());
referenceAxisBuilder
.
getVisualGroup
().
toFront
();
rootNode
.
getChildren
().
add
(
referenceAxisBuilder
.
getVisualGroup
());
///////////////////////////////////////////////////////////////////////////////////////
// Length
...
...
@@ -1800,9 +1806,74 @@ public class EditorMenuBar extends MenuBar {
mainPane
.
addRow
(
1
,
buttonPane
);
stage
.
showAndWait
();
});
///////////////////////////////////////////////////////////////////////////////////////
// Reference axis menu
MenuItem
displayReferenceAxesItem
=
new
MenuItem
(
"Show Reference Axes"
);
displayReferenceAxesItem
.
setAccelerator
(
new
KeyCodeCombination
(
KeyCode
.
R
,
KeyCombination
.
CONTROL_DOWN
));
displayReferenceAxesItem
.
setOnAction
(
event
->
{
if
(
Nomad3DEditor
.
getInstance
().
getModel
()
==
null
||
Nomad3DEditor
.
getInstance
().
getRoot
()
==
null
)
{
return
;
}
// Reference axis list display.
ReferenceAxisListDisplay
referenceAxisDisplay
=
new
ReferenceAxisListDisplay
();
// Get the root node.
Group
rootNode
=
(
Group
)
Nomad3DEditor
.
getInstance
().
getModel
().
getRoot
().
getSceneNode
();
// We set it at the end of the group so that it is always in front of the components.
rootNode
.
getChildren
().
add
(
referenceAxisDisplay
.
getVisualGroup
());
// Pane
GridPane
scenePane
=
new
GridPane
();
Scene
displayScene
=
new
Scene
(
scenePane
);
Stage
displayStage
=
new
Stage
(
StageStyle
.
UTILITY
);
displayStage
.
setWidth
(
300
);
displayStage
.
setTitle
(
"Reference Axes"
);
displayStage
.
setScene
(
displayScene
);
displayStage
.
initOwner
(
Nomad3DEditor
.
getInstance
().
getStage
());
TableView
<
AxisTableEntry
>
tableView
=
new
TableView
();
tableView
.
setEditable
(
false
);
TableColumn
axisNameColumn
=
new
TableColumn
<>(
"Name"
);
axisNameColumn
.
setMinWidth
(
300
);
axisNameColumn
.
setCellValueFactory
(
new
PropertyValueFactory
<
AxisTableEntry
,
String
>(
"axisName"
));
tableView
.
getSelectionModel
().
selectedItemProperty
().
addListener
(
new
ChangeListener
<
AxisTableEntry
>()
{
@Override
public
void
changed
(
ObservableValue
<?
extends
AxisTableEntry
>
observable
,
AxisTableEntry
oldValue
,
AxisTableEntry
newValue
)
{
referenceAxisDisplay
.
select
(
newValue
.
getAxisName
());
}
});
final
ObservableList
<
AxisTableEntry
>
data
=
FXCollections
.
observableArrayList
();
List
<
ReferenceAxis
>
axes
=
ReferenceAxisList
.
getInstance
().
get
();
for
(
ReferenceAxis
axis
:
axes
)
{
data
.
add
(
new
AxisTableEntry
(
axis
.
getName
()));
}
tableView
.
setItems
(
data
);
tableView
.
getColumns
().
addAll
(
axisNameColumn
);
scenePane
.
addRow
(
0
,
tableView
);
displayStage
.
setOnCloseRequest
(
closeEvent
->
{
// Remove the reference axis display.
rootNode
.
getChildren
().
remove
(
referenceAxisDisplay
.
getVisualGroup
());
});
displayStage
.
show
();
});
///////////////////////////////////////////////////////////////////////////////////////
// Not used anymore
...
...
@@ -2225,7 +2296,7 @@ public class EditorMenuBar extends MenuBar {
undoItem
,
new
SeparatorMenuItem
(),
editAxisItem
,
displayAxisItem
,
editMaterialItem
,
new
SeparatorMenuItem
(),
addComponentItem
,
removeComponentsItem
,
renameComponentItem
,
moveComponentsItem
,
new
SeparatorMenuItem
(),
addReferenceAxisItem
,
removeReferenceAxisItem
);
new
SeparatorMenuItem
(),
displayReferenceAxesItem
,
addReferenceAxisItem
,
removeReferenceAxisItem
);
this
.
view
=
new
Menu
(
"View"
);
Menu
cameraMenu
=
new
Menu
(
"Camera"
);
...
...
src/main/java/fr/ill/ics/n3d/gui/ReferenceAxisListDisplay.java
0 → 100644
View file @
c5142824
package
fr.ill.ics.n3d.gui
;
import
java.util.ArrayList
;
import
fr.ill.ics.n3d.gui.EditorMenuBar.AxisTableEntry
;
import
fr.ill.ics.n3d.model.Axis
;
import
fr.ill.ics.n3d.model.ReferenceAxis
;
import
fr.ill.ics.n3d.model.ReferenceAxisList
;
import
javafx.geometry.Point3D
;
import
javafx.scene.DepthTest
;
import
javafx.scene.Group
;
/**
* Class for creating reference axes.
*/
public
class
ReferenceAxisListDisplay
{
private
Group
visualGroup
;
private
String
selectedAxisName
=
""
;
/**
* Default constructor.
*/
public
ReferenceAxisListDisplay
()
{
visualGroup
=
new
Group
();
visualGroup
.
setVisible
(
true
);
init
();
}
public
Group
getVisualGroup
()
{
return
visualGroup
;
}
private
void
init
()
{
visualGroup
.
getChildren
().
clear
();
visualGroup
.
getTransforms
().
clear
();
ArrayList
<
ReferenceAxis
>
axes
=
ReferenceAxisList
.
getInstance
().
get
();
for
(
ReferenceAxis
axis
:
axes
)
{
Group
visualAxisGroup
=
new
Group
();
if
(
axis
.
getName
().
equals
(
selectedAxisName
))
{
Axis
.
updateVisualAxisGroup
(
visualAxisGroup
,
Axis
.
Type
.
NEW
,
axis
.
getPosition
(),
axis
.
getDirection
(),
false
);
}
else
{
Axis
.
updateVisualAxisGroup
(
visualAxisGroup
,
Axis
.
Type
.
REFERENCE1
,
axis
.
getPosition
(),
axis
.
getDirection
(),
false
);
}
visualGroup
.
getChildren
().
add
(
visualAxisGroup
);
}
visualGroup
.
setDepthTest
(
DepthTest
.
DISABLE
);
}
public
void
select
(
String
axisName
)
{
this
.
selectedAxisName
=
axisName
;
init
();
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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