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-commons
Commits
5c4569cd
Commit
5c4569cd
authored
Jul 17, 2017
by
Ivan Dages
Browse files
configurations editing : various bug fixes
parent
685e80b3
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/fr/ill/ics/n3d/model/Component.java
View file @
5c4569cd
...
...
@@ -342,6 +342,7 @@ public class Component {
* @param config New configuration
*/
public
void
addConfiguration
(
ConfigParams
config
)
{
removeConfiguration
(
config
.
getConfiguration
(),
false
);
this
.
configurations
.
add
(
config
);
}
...
...
@@ -362,44 +363,44 @@ public class Component {
* Saves the current position of the component and its descendants in a new configuration.
* @param configName Name of the new configuration
*/
public
void
saveCurrentConfiguration
(
String
configName
,
boolean
recursive
)
{
public
void
saveCurrentConfiguration
(
String
configName
,
String
configSourceName
,
boolean
recursive
)
{
ConfigParams
newConfig
=
new
ConfigParams
(
this
);
newConfig
.
setConfiguration
(
configName
);
newConfig
.
setTransform
(
this
.
getSceneNode
().
getLocalToSceneTransform
());
newConfig
.
setAxisValue
(
this
.
axis
.
getValue
());
ConfigParams
configSource
=
getConfigurationByName
(
configSourceName
);
if
(
configSource
!=
null
)
{
newConfig
.
setVisible
(
configSource
.
isVisible
());
}
addConfiguration
(
newConfig
);
if
(
recursive
)
{
for
(
Component
child
:
this
.
children
)
{
child
.
saveCurrentConfiguration
(
configName
,
recursive
);
child
.
saveCurrentConfiguration
(
configName
,
configSourceName
,
recursive
);
}
}
}
public
void
saveCurrentConfiguration
(
String
configName
)
{
this
.
saveCurrentConfiguration
(
configName
,
true
);
public
void
saveCurrentConfiguration
(
String
configName
,
String
configSourceName
)
{
this
.
saveCurrentConfiguration
(
configName
,
configSourceName
,
true
);
}
public
void
saveMedianConfiguration
()
{
// Clean up
this
.
removeConfiguration
(
"median"
,
false
);
public
void
saveMedianConfiguration
(
String
configSourceName
)
{
double
oldAxisValue
=
this
.
axis
.
getValue
();
this
.
axis
.
moveTo
(
this
.
axis
.
getMedianValue
());
saveCurrentConfiguration
(
"median"
,
false
);
saveCurrentConfiguration
(
"median"
,
configSourceName
,
false
);
for
(
Component
child
:
this
.
children
)
{
child
.
saveMedianConfiguration
();
child
.
saveMedianConfiguration
(
configSourceName
);
}
this
.
axis
.
moveTo
(
oldAxisValue
);
}
public
void
saveMinConfiguration
()
{
// Clean up
this
.
removeConfiguration
(
"min"
,
false
);
public
void
saveMinConfiguration
(
String
configSourceName
)
{
double
oldAxisValue
=
this
.
axis
.
getValue
();
if
(!
Double
.
isInfinite
(
this
.
axis
.
getMinValue
())
&&
!
Double
.
isNaN
(
this
.
axis
.
getMinValue
()))
{
...
...
@@ -407,22 +408,19 @@ public class Component {
}
else
{
this
.
axis
.
moveTo
(
this
.
axis
.
getMedianValue
());
}
saveCurrentConfiguration
(
"min"
,
false
);
saveCurrentConfiguration
(
"min"
,
configSourceName
,
false
);
if
(
Double
.
isInfinite
(
this
.
axis
.
getMinValue
())
||
Double
.
isNaN
(
this
.
axis
.
getMinValue
()))
{
this
.
getConfigurationByName
(
"min"
).
setAxisValue
(
this
.
axis
.
getMinValue
());
}
for
(
Component
child
:
this
.
children
)
{
child
.
saveMinConfiguration
();
child
.
saveMinConfiguration
(
configSourceName
);
}
this
.
axis
.
moveTo
(
oldAxisValue
);
}
public
void
saveMaxConfiguration
()
{
// Clean up
this
.
removeConfiguration
(
"max"
,
false
);
public
void
saveMaxConfiguration
(
String
configSourceName
)
{
double
oldAxisValue
=
this
.
axis
.
getValue
();
if
(!
Double
.
isInfinite
(
this
.
axis
.
getMaxValue
())
&&
!
Double
.
isNaN
(
this
.
axis
.
getMaxValue
()))
{
...
...
@@ -430,30 +428,36 @@ public class Component {
}
else
{
this
.
axis
.
moveTo
(
this
.
axis
.
getMedianValue
());
}
saveCurrentConfiguration
(
"max"
,
false
);
saveCurrentConfiguration
(
"max"
,
configSourceName
,
false
);
if
(
Double
.
isInfinite
(
this
.
axis
.
getMaxValue
())
||
Double
.
isNaN
(
this
.
axis
.
getMaxValue
()))
{
this
.
getConfigurationByName
(
"max"
).
setAxisValue
(
this
.
axis
.
getMaxValue
());
}
for
(
Component
child
:
this
.
children
)
{
child
.
saveMaxConfiguration
();
child
.
saveMaxConfiguration
(
configSourceName
);
}
this
.
axis
.
moveTo
(
oldAxisValue
);
}
public
void
setConfigurationVisibility
(
boolean
visible
,
String
configName
,
String
configSourceName
,
boolean
recursive
)
{
public
void
setConfigurationVisibility
(
boolean
visible
,
String
configName
,
String
configSourceName
,
boolean
overrideSourceVisibility
,
boolean
recursive
)
{
ConfigParams
config
=
this
.
getConfigurationByName
(
configName
);
config
.
setVisible
(
visible
);
if
(
visible
&&
!
this
.
isRoot
()
&&
!
this
.
parent
.
getConfigurationByName
(
configName
).
isVisible
())
{
parent
.
setConfigurationVisibility
(
visible
,
configName
,
configSourceName
,
false
);
parent
.
setConfigurationVisibility
(
visible
,
configName
,
configSourceName
,
overrideSourceVisibility
,
false
);
}
config
.
setVisible
(
visible
);
try
{
ConfigParams
configSource
=
this
.
getConfigurationByName
(
configSourceName
);
config
.
setRotation
(
configSource
.
getRotation
());
config
.
setTranslation
(
configSource
.
getTranslation
());
config
.
setScale
(
configSource
.
getScale
());
if
(!
overrideSourceVisibility
)
{
config
.
setVisible
(
visible
&&
configSource
.
isVisible
());
}
}
catch
(
NullPointerException
e
)
{
// Nothing to do : no source config
}
catch
(
Exception
e
)
{
...
...
@@ -463,7 +467,7 @@ public class Component {
if
(
recursive
)
{
for
(
Component
child
:
this
.
children
)
{
child
.
setConfigurationVisibility
(
visible
,
configName
,
configSourceName
,
recursive
);
child
.
setConfigurationVisibility
(
visible
,
configName
,
configSourceName
,
overrideSourceVisibility
,
recursive
);
}
}
}
...
...
@@ -519,6 +523,9 @@ public class Component {
* @return The configuration if it exists, null otherwise
*/
public
ConfigParams
getConfigurationByName
(
String
configName
)
{
if
(
configName
==
null
)
{
return
null
;
}
for
(
ConfigParams
config
:
this
.
configurations
)
{
if
(
configName
.
equals
(
config
.
getConfiguration
()))
{
return
config
;
...
...
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