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
Scientific Software
vEXP
Commits
9acaa763
Commit
9acaa763
authored
May 07, 2020
by
legoc
Browse files
Get the existing trajectories data at init of the trajectory controller
parent
a79bc02d
Changes
6
Hide whitespace changes
Inline
Side-by-side
js/client/app-state.js
View file @
9acaa763
...
...
@@ -714,16 +714,16 @@ class TrajectoriesData {
class
TrajectoriesDataData
{
constructor
()
{
this
.
_
trajectoriesD
ata
=
{};
this
.
_
d
ata
=
{};
this
.
_currentId
=
0
;
}
get
currentId
()
{
return
this
.
_currentId
;
}
get
trajectoriesD
ata
()
{
return
this
.
_
trajectoriesD
ata
;
}
get
d
ata
()
{
return
this
.
_
d
ata
;
}
get
current
Trajectory
Data
()
{
get
currentData
()
{
if
(
this
.
_currentId
!==
0
)
{
return
this
.
_
trajectoriesD
ata
[
this
.
_currentId
];
return
this
.
_
d
ata
[
this
.
_currentId
];
}
return
null
;
}
...
...
@@ -731,7 +731,7 @@ class TrajectoriesDataData {
update
(
trajectoriesDataModel
)
{
this
.
_currentId
=
trajectoriesDataModel
.
id
;
this
.
_
trajectoriesData
[
this
.
_currentId
]
=
trajectoriesDataModel
.
data
;
this
.
_
data
=
trajectoriesDataModel
.
data
;
return
true
;
}
...
...
js/client/controllers/trajectory-controller.js
View file @
9acaa763
...
...
@@ -38,6 +38,7 @@ class TrajectoryController extends Controller {
PubSub
.
subscribe
(
'
update-3D-local
'
,
()
=>
{
this
.
update3DLocal
();
});
PubSub
.
subscribe
(
'
update-3D-scattering
'
,
()
=>
{
this
.
update3DLocal
();
});
PubSub
.
subscribe
(
'
update-trajectory-data
'
,
()
=>
{
this
.
updateTrajectoryData
();
});
PubSub
.
subscribe
(
'
update-current-trajectory-data
'
,
()
=>
{
this
.
updateCurrentTrajectoryData
();
});
}
init
()
{
...
...
@@ -49,6 +50,8 @@ class TrajectoryController extends Controller {
this
.
_trajectoryPanel
.
addTrajectory
(
traj
,
trajectory
.
isVisible
(
id
),
false
);
this
.
_trajectory3D
.
createTrajectory
(
traj
);
}
this
.
updateTrajectoryData
();
}
/**
...
...
@@ -276,6 +279,10 @@ class TrajectoryController extends Controller {
this
.
_trajectory3D
.
updateData
();
}
updateCurrentTrajectoryData
()
{
this
.
_trajectory3D
.
updateCurrentData
();
}
/**
* Inits the scan spy configuration.
*/
...
...
js/client/main/synchronizer.js
View file @
9acaa763
...
...
@@ -17,6 +17,8 @@ function synchronize(data) {
state
.
scattering
.
update
(
data
.
scattering
);
let
updateTrajectories
=
state
.
trajectory
.
update
(
data
.
trajectory
);
state
.
trajectoryData
.
update
(
data
.
trajectoryData
);
state
.
matrix
.
update
(
data
.
matrix
);
state
.
config
.
configurations
=
{};
...
...
@@ -31,6 +33,7 @@ function synchronize(data) {
PubSub
.
publish
(
'
change-expdata
'
,
0
);
PubSub
.
publish
(
'
change-trajectory
'
,
0
);
PubSub
.
publish
(
'
update-trajectory-data
'
,
0
);
PubSub
.
publish
(
'
change-atoms-conf
'
,
0
);
PubSub
.
publish
(
'
update-atom-controller
'
,
0
);
...
...
@@ -101,7 +104,7 @@ function synchronizeSpy(data) {
PubSub
.
publish
(
'
change-trajectory
'
,
0
);
}
PubSub
.
publish
(
'
update-trajectory-data
'
,
0
);
PubSub
.
publish
(
'
update-
current-
trajectory-data
'
,
0
);
if
(
updateAtoms
)
{
PubSub
.
publish
(
'
change-atoms-conf
'
,
0
);
...
...
js/client/views/3D/trajectory-view.js
View file @
9acaa763
...
...
@@ -603,9 +603,29 @@ class TrajectoryView3D extends View3D {
}
/**
* Update the data of the
current
trajector
y
.
* Update the data of the
all the
trajector
ies
.
*/
updateData
()
{
// Add the trajectories.
for
(
let
id
in
trajectoryData
.
data
)
{
let
lines
=
this
.
_trajectoryLines
[
id
];
if
(
lines
!==
undefined
&&
lines
!==
null
)
{
// If the energy line exists, then it "carries" the data.
if
(
lines
.
energy
!==
null
)
{
lines
.
energy
.
setData
(
trajectoryData
.
data
[
id
]);
lines
.
energy
.
updateDataGroup
();
}
}
}
}
/**
* Update the data of the current trajectory.
*/
updateCurrentData
()
{
if
(
trajectoryData
.
currentId
==
0
)
{
return
;
...
...
@@ -616,7 +636,7 @@ class TrajectoryView3D extends View3D {
// If the energy line exists, then it "carries" the data.
if
(
lines
.
energy
!==
null
)
{
lines
.
energy
.
setData
(
trajectoryData
.
current
Trajectory
Data
);
lines
.
energy
.
setData
(
trajectoryData
.
currentData
);
lines
.
energy
.
updateDataGroup
();
}
}
...
...
js/server/main.js
View file @
9acaa763
...
...
@@ -434,6 +434,7 @@ receiver.on('init', (msg, data) => {
expdata
:
expDataModel
.
toObject
(),
scattering
:
scatteringModel
.
toObject
(),
trajectory
:
trajectoryModel
.
toObject
(),
trajectoryData
:
trajectoryDataModel
.
toObject
(),
// We pass all the trajectories.
atoms
:
atomsModel
.
toObject
(),
matrix
:
{
uMatrix
:
vEXP
.
uMatrix
.
toArray
(),
...
...
@@ -593,7 +594,7 @@ PubSub.subscribe('syncSpy', (message, clearTrajectories) => {
// Set the XBU path.
trajectoryModel
.
xbuPath
=
vEXP
.
xbuPath
;
// Set the scan data.
// Set the scan data.
Notice the last point may be missing if the measurement time is very short.
trajectoryDataModel
.
setDataToCurrentTrajectory
(
vEXP
.
dataScan
);
// Update the trajectories.
...
...
js/server/model/trajectory-data-model.js
View file @
9acaa763
...
...
@@ -36,7 +36,12 @@ class TrajectoryDataModel extends Model {
setDataToCurrentTrajectory
(
value
)
{
if
(
this
.
_currentId
!==
0
)
{
this
.
_trajectoriesData
[
this
.
_currentId
]
=
value
;
// Test the length of passed data to avoid clearing the current data.
// It can happen when the current id is not yet changed.
if
(
value
.
length
>
0
)
{
this
.
_trajectoriesData
[
this
.
_currentId
]
=
value
;
}
}
}
...
...
@@ -57,28 +62,33 @@ class TrajectoryDataModel extends Model {
return
null
;
}
/**
* Save the model data into a config object (the saver object).
*/
save
(
saver
)
{
saver
.
trajectoryData
=
{};
}
/**
* Cast this instance into a basic JS object.
* Only passes the current data.
*/
currentToObject
()
{
let
data
=
{};
data
[
this
.
_currentId
]
=
this
.
getCurrentTrajectoryData
();
return
{
id
:
this
.
_currentId
,
data
:
this
.
getCurrentTrajectoryData
()
data
}
}
/**
* Save the model data into a config object (the saver object).
*/
save
(
saver
)
{
saver
.
trajectoryData
=
{};
}
/**
* Cast this instance into a basic JS object.
*/
toObject
()
{
return
{
id
:
this
.
_currentId
,
data
:
this
.
_trajectoriesData
...
...
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