Commit 5ef11b93 authored by legoc's avatar legoc
Browse files

Created ClientSettings class to store settings like energy scale, etc.

parent 8faef48e
/**
* Class storing the client settings.
*/
class ClientSettings {
constructor() {
this._energyScale = 1;
this._dataSphereRadius = 1;
}
get energyScale() { return this._energyScale; }
set energyScale(value) { this._energyScale = value; }
get energyScale() { return this._energyScale; }
set dataSphereRadius(value) { this._dataSphereRadius = value; }
}
const clientSettings = new ClientSettings();
module.exports = { clientSettings };
\ No newline at end of file
......@@ -2,6 +2,7 @@ const Controller = require('./controller');
const PubSub = require('pubsub-js');
const { requester } = require('../main/context');
const { trajectory, scattering, matrix } = require('../server-state');
const { clientSettings } = require('../client-state');
const { synchronize, synchronizeSpy, synchronizeScan } = require('../main/synchronizer');
const THREE = require('three');
......@@ -274,7 +275,11 @@ class TrajectoryController extends Controller {
}
updateTrajectorySettings(values) {
this._trajectory3D.changeSettings(values);
// Copy the settings.
clientSettings.energyScale = values.energyScale;
clientSettings.dataSphereRadius = values.dataSphereRadius;
this._trajectory3D.changeSettings();
}
updateTrajectoryData() {
......
......@@ -5,6 +5,7 @@ const { calculateKiKf } = require('../../utils/calculations');
const THREE = require('three');
const { displayMode } = require('../../main/context');
const { scattering, matrix, trajectoryData } = require('../../server-state');
const { clientSettings } = require('../../client-state');
const {scalarWorldToView} = require('../../utils/conversion');
const Constants = require('../../utils/constants');
......@@ -191,9 +192,10 @@ class TrajectoryView3D extends View3D {
this._energyViewGroup.applyMatrix(matrix4);
}
changeSettings(values) {
changeSettings() {
// Change the scale on the z direction to change the length of the energy lines.
this._energyScaleGroup.scale.z = values.energyScale;
this._energyScaleGroup.scale.z = clientSettings.energyScale;
}
update3DLocal() {
......
......@@ -13,8 +13,8 @@ class TrajectorySettingsPanelView {
<div class='col-sm-4'/>
</div>
<div class='row'>
<label class='col-sm-4' for='sphereRadius'>Sphere Radius</label>
<input class='col-sm-4' type='text' name='sphereRadius' id='sphereRadius' />
<label class='col-sm-4' for='dataSphereRadius'>Data Sphere Radius</label>
<input class='col-sm-4' type='text' name='dataSphereRadius' id='dataSphereRadius' />
<div class='col-sm-4'/>
</div>
</div>`;
......@@ -41,10 +41,10 @@ class TrajectorySettingsPanelView {
});
// Init sphere radius with 1.0.
$('#sphereRadius').val(1.0);
$('#dataSphereRadius').val(1.0);
// When the view is initialised, we can access to the html elements.
$("#sphereRadius").keypress((event) => {
$("#dataSphereRadius").keypress((event) => {
if (event.which == 13 || event.keyCode == 13) {
PubSub.publish('update-trajectory-settings', this.getInputs());
......@@ -61,7 +61,7 @@ class TrajectorySettingsPanelView {
getInputs() {
return {
energyScale: parseFloat($("#energyScale").val()),
sphereRadius: parseFloat($("#sphereRadius").val())
dataSphereRadius: parseFloat($("#dataSphereRadius").val())
};
}
}
......
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