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
22cb5fc5
Commit
22cb5fc5
authored
Jun 26, 2017
by
Ivan Dages
Browse files
improved axis modification
parent
2b7c8578
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/fr/ill/ics/n3d/gui/AxisBuilder.java
View file @
22cb5fc5
...
...
@@ -34,6 +34,14 @@ public class AxisBuilder {
this
.
parentGroup
=
null
;
}
/**
* Gets the axis.
* @return The axis
*/
public
Axis
getAxis
()
{
return
axis
;
}
/**
* Starts the axis editing.
* @param axis Axis to edit
...
...
src/main/java/fr/ill/ics/n3d/gui/EditorMenuBar.java
View file @
22cb5fc5
...
...
@@ -250,9 +250,117 @@ public class EditorMenuBar extends MenuBar {
Nomad3DEditor
.
getInstance
().
getAxisBuilder
().
setType
(
newValue
);
}
});
Label
dirLabel
=
new
Label
(
"Direction : "
);
Label
xDirLabel
=
new
Label
(
"X : "
);
Label
yDirLabel
=
new
Label
(
"Y : "
);
Label
zDirLabel
=
new
Label
(
"Z : "
);
TextField
xDirField
=
new
TextField
(
Double
.
toString
(
selectedAxis
.
getDirection
().
getX
()));
xDirField
.
setOnAction
(
valueEvent
->
{
try
{
Point3D
newDir
=
new
Point3D
(
Double
.
parseDouble
(
xDirField
.
getText
()),
Nomad3DEditor
.
getInstance
().
getAxisBuilder
().
getAxis
().
getDirection
().
getY
(),
Nomad3DEditor
.
getInstance
().
getAxisBuilder
().
getAxis
().
getDirection
().
getZ
());
Nomad3DEditor
.
getInstance
().
getAxisBuilder
().
getAxis
().
setDirection
(
newDir
.
normalize
());
}
catch
(
Exception
e
)
{
// Invalid input, nothing to do
}
});
TextField
yDirField
=
new
TextField
(
Double
.
toString
(
selectedAxis
.
getDirection
().
getY
()));
yDirField
.
setOnAction
(
valueEvent
->
{
try
{
Point3D
newDir
=
new
Point3D
(
Nomad3DEditor
.
getInstance
().
getAxisBuilder
().
getAxis
().
getDirection
().
getX
(),
Double
.
parseDouble
(
yDirField
.
getText
()),
Nomad3DEditor
.
getInstance
().
getAxisBuilder
().
getAxis
().
getDirection
().
getZ
());
Nomad3DEditor
.
getInstance
().
getAxisBuilder
().
getAxis
().
setDirection
(
newDir
.
normalize
());
}
catch
(
Exception
e
)
{
// Invalid input, nothing to do
}
});
TextField
zDirField
=
new
TextField
(
Double
.
toString
(
selectedAxis
.
getDirection
().
getZ
()));
zDirField
.
setOnAction
(
valueEvent
->
{
try
{
Point3D
newDir
=
new
Point3D
(
Nomad3DEditor
.
getInstance
().
getAxisBuilder
().
getAxis
().
getDirection
().
getX
(),
Nomad3DEditor
.
getInstance
().
getAxisBuilder
().
getAxis
().
getDirection
().
getY
(),
Double
.
parseDouble
(
zDirField
.
getText
()));
Nomad3DEditor
.
getInstance
().
getAxisBuilder
().
getAxis
().
setDirection
(
newDir
.
normalize
());
}
catch
(
Exception
e
)
{
// Invalid input, nothing to do
}
});
Label
posLabel
=
new
Label
(
"Position : "
);
Label
xPosLabel
=
new
Label
(
"X : "
);
Label
yPosLabel
=
new
Label
(
"Y : "
);
Label
zPosLabel
=
new
Label
(
"Z : "
);
TextField
xPosField
=
new
TextField
(
Double
.
toString
(
selectedAxis
.
getPosition
().
getX
()));
xPosField
.
setOnAction
(
valueEvent
->
{
try
{
Point3D
newPos
=
new
Point3D
(
Double
.
parseDouble
(
xPosField
.
getText
()),
Nomad3DEditor
.
getInstance
().
getAxisBuilder
().
getAxis
().
getPosition
().
getY
(),
Nomad3DEditor
.
getInstance
().
getAxisBuilder
().
getAxis
().
getPosition
().
getZ
());
Nomad3DEditor
.
getInstance
().
getAxisBuilder
().
getAxis
().
setPosition
(
newPos
);
Nomad3DEditor
.
getInstance
().
getControls
().
setCenter
(
newPos
);
}
catch
(
Exception
e
)
{
// Invalid input, nothing to do
}
});
TextField
yPosField
=
new
TextField
(
Double
.
toString
(
selectedAxis
.
getPosition
().
getY
()));
yPosField
.
setOnAction
(
valueEvent
->
{
try
{
Point3D
newPos
=
new
Point3D
(
Nomad3DEditor
.
getInstance
().
getAxisBuilder
().
getAxis
().
getPosition
().
getX
(),
Double
.
parseDouble
(
yPosField
.
getText
()),
Nomad3DEditor
.
getInstance
().
getAxisBuilder
().
getAxis
().
getPosition
().
getZ
());
Nomad3DEditor
.
getInstance
().
getAxisBuilder
().
getAxis
().
setPosition
(
newPos
);
Nomad3DEditor
.
getInstance
().
getControls
().
setCenter
(
newPos
);
}
catch
(
Exception
e
)
{
// Invalid input, nothing to do
}
});
TextField
zPosField
=
new
TextField
(
Double
.
toString
(
selectedAxis
.
getPosition
().
getZ
()));
zPosField
.
setOnAction
(
valueEvent
->
{
try
{
Point3D
newPos
=
new
Point3D
(
Nomad3DEditor
.
getInstance
().
getAxisBuilder
().
getAxis
().
getPosition
().
getX
(),
Nomad3DEditor
.
getInstance
().
getAxisBuilder
().
getAxis
().
getPosition
().
getY
(),
Double
.
parseDouble
(
zPosField
.
getText
()));
Nomad3DEditor
.
getInstance
().
getAxisBuilder
().
getAxis
().
setPosition
(
newPos
);
Nomad3DEditor
.
getInstance
().
getControls
().
setCenter
(
newPos
);
}
catch
(
Exception
e
)
{
// Invalid input, nothing to do
}
});
Thread
updateThread
=
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
try
{
while
(
true
)
{
boolean
someFieldFocused
=
false
;
someFieldFocused
=
someFieldFocused
||
xDirField
.
isFocused
();
someFieldFocused
=
someFieldFocused
||
yDirField
.
isFocused
();
someFieldFocused
=
someFieldFocused
||
zDirField
.
isFocused
();
someFieldFocused
=
someFieldFocused
||
xPosField
.
isFocused
();
someFieldFocused
=
someFieldFocused
||
yPosField
.
isFocused
();
someFieldFocused
=
someFieldFocused
||
zPosField
.
isFocused
();
if
(!
someFieldFocused
)
{
Platform
.
runLater
(()
->
xDirField
.
setText
(
Double
.
toString
(
selectedAxis
.
getDirection
().
getX
())));
Platform
.
runLater
(()
->
yDirField
.
setText
(
Double
.
toString
(
selectedAxis
.
getDirection
().
getY
())));
Platform
.
runLater
(()
->
zDirField
.
setText
(
Double
.
toString
(
selectedAxis
.
getDirection
().
getZ
())));
Platform
.
runLater
(()
->
xPosField
.
setText
(
Double
.
toString
(
selectedAxis
.
getPosition
().
getX
())));
Platform
.
runLater
(()
->
yPosField
.
setText
(
Double
.
toString
(
selectedAxis
.
getPosition
().
getY
())));
Platform
.
runLater
(()
->
zPosField
.
setText
(
Double
.
toString
(
selectedAxis
.
getPosition
().
getZ
())));
}
Thread
.
sleep
(
50
);
}
}
catch
(
InterruptedException
e
)
{
// Nothing to do
}
}
});
Button
okButton
=
new
Button
(
"OK"
);
okButton
.
setDefaultButton
(
true
);
//
okButton.setDefaultButton(true);
okButton
.
setOnAction
(
okEvent
->
{
updateThread
.
interrupt
();
selectedAxis
.
setMethod
(
Axis
.
Method
.
ADDED
);
Nomad3DEditor
.
getInstance
().
getAxisBuilder
().
stop
(
selectedComponent
);
Nomad3DEditor
.
getInstance
().
getModel
().
clearSelection
();
...
...
@@ -263,6 +371,7 @@ public class EditorMenuBar extends MenuBar {
Button
cancelButton
=
new
Button
(
"Cancel"
);
cancelButton
.
setCancelButton
(
true
);
cancelButton
.
setOnAction
(
cancelEvent
->
{
updateThread
.
interrupt
();
Nomad3DEditor
.
getInstance
().
getAxisBuilder
().
stop
(
modified
);
selectedComponent
.
setAxis
(
axisInit
);
Nomad3DEditor
.
getInstance
().
getModel
().
clearSelection
();
...
...
@@ -270,11 +379,16 @@ public class EditorMenuBar extends MenuBar {
Nomad3DEditor
.
getInstance
().
getModel
().
addToSelection
(
selectedComponent
);
addStage
.
close
();
});
GridPane
typePane
=
new
GridPane
();
typePane
.
setHgap
(
10
);
typePane
.
setVgap
(
5
);
typePane
.
setPrefWidth
(
650
);
typePane
.
setAlignment
(
Pos
.
CENTER
);
typePane
.
addRow
(
0
,
typeLabel
,
typeBox
);
typePane
.
addRow
(
1
,
dirLabel
,
xDirLabel
,
xDirField
,
yDirLabel
,
yDirField
,
zDirLabel
,
zDirField
);
typePane
.
addRow
(
2
,
posLabel
,
xPosLabel
,
xPosField
,
yPosLabel
,
yPosField
,
zPosLabel
,
zPosField
);
GridPane
.
setColumnSpan
(
typeBox
,
GridPane
.
REMAINING
);
addPane
.
addRow
(
0
,
typePane
);
GridPane
buttonPane
=
new
GridPane
();
...
...
@@ -284,6 +398,7 @@ public class EditorMenuBar extends MenuBar {
addPane
.
addRow
(
1
,
buttonPane
);
Nomad3DEditor
.
getInstance
().
getAxisBuilder
().
start
(
selectedAxis
,
Nomad3DEditor
.
getInstance
().
getRoot
(),
Nomad3DEditor
.
getInstance
().
getControls
(),
modified
);
updateThread
.
start
();
addStage
.
show
();
});
MenuItem
calibrateAxisItem
=
new
MenuItem
(
"Calibrate axis"
);
...
...
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