Commit b125082b authored by legoc's avatar legoc
Browse files

Some improvements in energy trajectory loading

parent ef92dca3
......@@ -253,6 +253,9 @@ class TrajectoryController extends Controller {
planeChange() {
this._trajectory3D.changePlane();
// Reset the trajectories.
this.trajectoryChange();
}
setEnergyVisible(value) {
......
......@@ -182,7 +182,6 @@ class TrajectoryView3D extends View3D {
}
changePlane() {
// First we reset the group matrix to identity.
let inv = new THREE.Matrix4();
inv.getInverse(this._energyViewGroup.matrix);
......@@ -288,21 +287,23 @@ class TrajectoryView3D extends View3D {
// Reset old highlighted lines.
let lines = this._trajectoryLines[this._highlightId];
if (lines !== undefined) {
lines.hkl.highlight(false);
if (lines !== null) {
if (lines.hkl !== null) {
lines.hkl.highlight(false);
}
if (lines.energy !== undefined) {
if (lines.energy !== null) {
lines.energy.highlight(false);
}
}
// Highlight current lines.
let hklLine = this._trajectoryLines[id].hkl;
if (hklLine !== undefined) {
if (hklLine !== null) {
hklLine.highlight(true);
}
let energyLine = this._trajectoryLines[id].energy;
if (energyLine !== undefined) {
if (energyLine !== null) {
energyLine.highlight(true);
}
......@@ -324,34 +325,43 @@ class TrajectoryView3D extends View3D {
*/
deleteTrajectory(id) {
let hklLine = this._trajectoryLines[id].hkl;
hklLine.destroy();
if (hklLine !== null) {
hklLine.destroy();
}
let energyLine = this._trajectoryLines[id].energy;
if (energyLine !== undefined) {
if (energyLine !== null) {
energyLine.destroy();
}
delete this._trajectoryLines[id];
}
createTrajectoryQ(trajectory) {
let bMatrix = trajectory.bMatrix;
let uMatrix = trajectory.uMatrix;
let start = new THREE.Vector3(trajectory.start.x, trajectory.start.y, trajectory.start.z);
let end = new THREE.Vector3(trajectory.end.x, trajectory.end.y, trajectory.end.z);
let center = new THREE.Vector3(trajectory.start.x, trajectory.start.y, trajectory.start.z);
let hklLine = new TrajectoryLine(trajectory.type, this._hklGroup,
start,
end,
center,
trajectory.steps);
let hklLine = null;
// Define the energy line only if the plane hasn't changed.
if (uMatrix.equals(matrix.uMatrix)) {
hklLine = new TrajectoryLine(trajectory.type, this._hklGroup,
start,
end,
center,
trajectory.steps);
}
this._trajectoryLines[trajectory.id] = {
hkl: hklLine
hkl: hklLine,
energy: null
}
}
loadEnergyPoint(trajectoryPoint, bMatrix, uMatrix_1, uMatrix) {
loadEnergyPoint(trajectoryPoint, bMatrix, uMatrix) {
// The point is in Rc.
let point = new THREE.Vector3(trajectoryPoint.x, trajectoryPoint.y, trajectoryPoint.z);
......@@ -402,20 +412,26 @@ class TrajectoryView3D extends View3D {
end.applyMatrix3(bMatrix_1);
center.applyMatrix3(bMatrix_1);
let hklLine = new TrajectoryLine(trajectory.type, this._hklGroup,
start,
end,
center,
trajectory.steps);
let energyStart = this.loadEnergyPoint(trajectory.start, bMatrix, uMatrix_1, uMatrix);
let energyEnd = this.loadEnergyPoint(trajectory.end, bMatrix, uMatrix_1, uMatrix);
let energyLine = new TrajectoryLine('q', this._energyGroup,
energyStart,
energyEnd,
energyStart,
trajectory.steps);
let hklLine = null;
let energyLine = null;
// Define the energy lines only if the plane hasn't changed.
if (uMatrix.equals(matrix.uMatrix)) {
hklLine = new TrajectoryLine(trajectory.type, this._hklGroup,
start,
end,
center,
trajectory.steps);
let energyStart = this.loadEnergyPoint(trajectory.start, bMatrix, uMatrix);
let energyEnd = this.loadEnergyPoint(trajectory.end, bMatrix, uMatrix);
energyLine = new TrajectoryLine('q', this._energyGroup,
energyStart,
energyEnd,
energyStart,
trajectory.steps);
}
this._trajectoryLines[trajectory.id] = {
hkl: hklLine,
......@@ -467,20 +483,26 @@ class TrajectoryView3D extends View3D {
end.applyMatrix3(bMatrix_1);
center.applyMatrix3(bMatrix_1);
let hklLine = new TrajectoryLine(trajectory.type, this._hklGroup,
start,
end,
center,
trajectory.steps);
let energyStart = this.loadEnergyPoint(trajectory.start, bMatrix, uMatrix_1, uMatrix);
let energyEnd = this.loadEnergyPoint(trajectory.end, bMatrix, uMatrix_1, uMatrix);
let energyLine = new TrajectoryLine('q', this._energyGroup,
energyStart,
energyEnd,
energyStart,
trajectory.steps);
let hklLine = null;
let energyLine = null;
// Define the energy line only if the plane hasn't changed.
if (uMatrix.equals(matrix.uMatrix)) {
hklLine = new TrajectoryLine(trajectory.type, this._hklGroup,
start,
end,
center,
trajectory.steps);
let energyStart = this.loadEnergyPoint(trajectory.start, bMatrix, uMatrix);
let energyEnd = this.loadEnergyPoint(trajectory.end, bMatrix, uMatrix);
energyLine = new TrajectoryLine('q', this._energyGroup,
energyStart,
energyEnd,
energyStart,
trajectory.steps);
}
this._trajectoryLines[trajectory.id] = {
hkl: hklLine,
......@@ -528,7 +550,7 @@ class TrajectoryView3D extends View3D {
let hklLine = this._trajectoryLines[id].hkl;
hklLine.setVisibility(visibility);
let energyLine = this._trajectoryLines[id].energy;
if (energyLine !== undefined) {
if (energyLine !== null) {
energyLine.setVisibility(visibility);
}
}
......@@ -540,7 +562,7 @@ class TrajectoryView3D extends View3D {
let hklLine = this._trajectoryLines[id].hkl;
hklLine.steps = steps;
let energyLine = this._trajectoryLines[id].energy;
if (energyLine !== undefined) {
if (energyLine !== null) {
energyLine.steps = steps;
}
}
......
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