Commit 4a23d395 authored by legoc's avatar legoc
Browse files

Generalised TrajectoryView3D.redraw() to take into account change of U and B matrices

parent 01ef2a62
......@@ -35,7 +35,8 @@ class TrajectoryController extends Controller {
// Event handlers.
PubSub.subscribe('change-trajectory', () => { this.trajectoryChange(); });
PubSub.subscribe('change-sample', () => { this.sampleChange(); });
PubSub.subscribe('change-peaks', () => { this.redraw(); });
PubSub.subscribe('change-sample', () => { this.redraw(); });
PubSub.subscribe('change-plane', () => { this.planeChange(); });
PubSub.subscribe('update-3D-local', () => { this.update3DLocal(); });
PubSub.subscribe('update-3D-scattering', () => { this.update3DLocal(); });
......@@ -262,12 +263,8 @@ class TrajectoryController extends Controller {
});
}
sampleChange() {
this._trajectory3D.changeSample();
}
planeChange() {
this._trajectory3D.changePlane();
this._trajectory3D.updateEnergyViewGroup();
// Reset the trajectories.
this.trajectoryChange();
......@@ -278,7 +275,9 @@ class TrajectoryController extends Controller {
}
update3DLocal() {
this._trajectory3D.update3DLocal();
// It is necessary to update the energy translation group so that the scattering plane follows the current energy.
this._trajectory3D.updateEnergyTranslationGroup();
}
updateTrajectorySettings(values) {
......@@ -287,7 +286,7 @@ class TrajectoryController extends Controller {
clientSettings.dataSphereRadius = values.dataSphereRadius;
clientSettings.maxIntensity = values.maxIntensity;
this._trajectory3D.changeSettings();
this._trajectory3D.redraw();
}
updateTrajectoryData() {
......@@ -327,6 +326,10 @@ class TrajectoryController extends Controller {
this._spy = false;
}
redraw() {
this._trajectory3D.redraw();
}
}
module.exports = TrajectoryController;
\ No newline at end of file
......@@ -264,8 +264,6 @@ class ScatteringData {
this._ss = scatteringModel.ss;
this._status = scatteringModel.status;
console.log('status', this._status)
}
}
......
......@@ -160,7 +160,7 @@ class TrajectoryView3D extends View3D {
// Convert the bMatrix to Matrix4 and apply it.
let matrix4 = new THREE.Matrix4();
let m = transform.elements;
matrix4.set(m[0], m[3], m[6], 0.0, m[1], m[4], m[7], 0.0, m[2], m[5], m[8], 0.0, 0.0, 0.0, 0.0, 0.0);
matrix4.set(m[0], m[3], m[6], 0.0, m[1], m[4], m[7], 0.0, m[2], m[5], m[8], 0.0, 0.0, 0.0, 0.0, 1.0);
return matrix4;
}
......@@ -178,7 +178,20 @@ class TrajectoryView3D extends View3D {
return group;
}
changePlane() {
updateHKLViewGroup() {
// First we reset the group matrix to identity.
let inv = new THREE.Matrix4();
inv.getInverse(this._hklViewGroup.matrix);
this._hklViewGroup.applyMatrix(inv);
// Then we can apply the new B matrix.
let matrix4 = this.matrix3To4(matrix.bMatrix);
this._hklViewGroup.applyMatrix(matrix4);
}
updateEnergyViewGroup() {
// First we reset the group matrix to identity.
let inv = new THREE.Matrix4();
inv.getInverse(this._energyViewGroup.matrix);
......@@ -189,22 +202,7 @@ class TrajectoryView3D extends View3D {
this._energyViewGroup.applyMatrix(matrix4);
}
changeSettings() {
// Update the local matrix.
this.update3DLocal();
// Iterate on the trajectory lines.
for (let id in this._trajectoryLines) {
// Update the lines
let hklLine = this._trajectoryLines[id].hkl;
hklLine.updateLine();
let energyLine = this._trajectoryLines[id].energy;
energyLine.updateLine();
}
}
update3DLocal() {
updateEnergyTranslationGroup() {
// First we reset the group matrix to identity.
let inv = new THREE.Matrix4();
......@@ -218,6 +216,23 @@ class TrajectoryView3D extends View3D {
this._energyTranslationGroup.translateZ(-scalarWorldToView(dE));
}
redraw() {
// Update the groups with the new U, B matrix, scattering vectors.
this.updateHKLViewGroup();
this.updateEnergyViewGroup();
this.updateEnergyTranslationGroup();
// Iterate on the trajectory lines.
for (let id in this._trajectoryLines) {
// Update the lines
let hklLine = this._trajectoryLines[id].hkl;
hklLine.updateLine();
let energyLine = this._trajectoryLines[id].energy;
energyLine.updateLine();
}
}
changeDisplayMode() {
if (displayMode.view == Constants.DisplayMode.SPE) {
this._hklViewGroup.visible = false;
......@@ -656,13 +671,6 @@ class TrajectoryView3D extends View3D {
}
}
}
/**
* Update the trajectory line used for edition.
*/
changeSample() {
// TODO
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment