Skip to content

Commit

Permalink
Added dichroic color default
Browse files Browse the repository at this point in the history
Moved dichroic settings into mirror function
Replaced dichroic settings in all other mirrors with imported function.
  • Loading branch information
gljames24 committed Jan 29, 2023
1 parent 48bd834 commit 88b4a60
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 55 deletions.
14 changes: 3 additions & 11 deletions simulator/js/objs/arcmirror.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,11 @@ objTypes['arcmirror'] = {
return {type: 'arcmirror', p1: mouse, isDichroic: false, isDichroicFilter: false};
},

dichroicSettings: objTypes['mirror'].dichroicSettings,

//顯示屬性方塊 Show the property box
p_box: function(obj, elem) {
if (colorMode) {
createBooleanAttr(getMsg('dichroic'), obj.isDichroic, function(obj, value) {
obj.isDichroic = value;
}, elem);
createBooleanAttr(getMsg('filter'), obj.isDichroicFilter, function(obj, value) {
obj.isDichroicFilter = value;
}, elem);
createNumberAttr(getMsg('wavelength'), UV_WAVELENGTH, INFRARED_WAVELENGTH, 1, obj.wavelength || GREEN_WAVELENGTH, function(obj, value) {
obj.wavelength = value;
}, elem);
}
this.dichroicSettings(obj,elem);
},

//建立物件過程滑鼠按下 Mousedown when the obj is being constructed by the user
Expand Down
14 changes: 3 additions & 11 deletions simulator/js/objs/beamsplitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,14 @@ objTypes['beamsplitter'] = {
return {type: 'beamsplitter', p1: mouse, p2: mouse, p: .5, isDichroic: false, isDichroicFilter: false};
},

dichroicSettings: objTypes['mirror'].dichroicSettings,

//顯示屬性方塊 Show the property box
p_box: function(obj, elem) {
createNumberAttr(getMsg('transmissionratio'), 0, 1, 0.01, obj.p, function(obj, value) {
obj.p = value;
}, elem);
if (colorMode) {
createBooleanAttr(getMsg('dichroic'), obj.isDichroic, function(obj, value) {
obj.isDichroic = value;
}, elem);
createBooleanAttr(getMsg('filter'), obj.isDichroicFilter, function(obj, value) {
obj.isDichroicFilter = value;
}, elem);
createNumberAttr(getMsg('wavelength'), UV_WAVELENGTH, INFRARED_WAVELENGTH, 1, obj.wavelength || GREEN_WAVELENGTH, function(obj, value) {
obj.wavelength = value;
}, elem);
}
this.dichroicSettings(obj,elem);
},

//使用lineobj原型 Use the prototype lineobj
Expand Down
14 changes: 3 additions & 11 deletions simulator/js/objs/curvedmirror.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,14 @@ objTypes['curvedmirror'] = {
return {type: 'curvedmirror', p1: mouse, p2: mouse, p: "0.5\\cdot\\sqrt{1-x^2}", isDichroic: false, isDichroicFilter: false};
},

dichroicSettings: objTypes['mirror'].dichroicSettings,

//顯示屬性方塊 Show the property box
p_box: function(obj, elem) {
createEquationAttr('y = ', obj.p, function(obj, value) {
obj.p = value;
}, elem);
if (colorMode) {
createBooleanAttr(getMsg('dichroic'), obj.isDichroic, function(obj, value) {
obj.isDichroic = value;
}, elem);
createBooleanAttr(getMsg('filter'), obj.isDichroicFilter, function(obj, value) {
obj.isDichroicFilter = value;
}, elem);
createNumberAttr(getMsg('wavelength'), UV_WAVELENGTH, INFRARED_WAVELENGTH, 1, obj.wavelength || GREEN_WAVELENGTH, function(obj, value) {
obj.wavelength = value;
}, elem);
}
this.dichroicSettings(obj,elem);
},

c_mousedown: objTypes['lineobj'].c_mousedown,
Expand Down
14 changes: 3 additions & 11 deletions simulator/js/objs/idealmirror.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ objTypes['idealmirror'] = {
return {type: 'idealmirror', p1: mouse, p2: graphs.point(mouse.x + gridSize, mouse.y), p: 100, isDichroic: false, isDichroicFilter: false};
},

dichroicSettings: objTypes['mirror'].dichroicSettings,

//顯示屬性方塊 Show the property box
p_box: function(obj, elem) {
createNumberAttr(getMsg('focallength'), -1000, 1000, 1, obj.p * (cartesianSign?-1:1), function(obj, value) {
Expand All @@ -18,17 +20,7 @@ objTypes['idealmirror'] = {
selectObj(selectedObj);
}
}, elem);
if (colorMode) {
createBooleanAttr(getMsg('dichroic'), obj.isDichroic, function(obj, value) {
obj.isDichroic = value;
}, elem);
createBooleanAttr(getMsg('filter'), obj.isDichroicFilter, function(obj, value) {
obj.isDichroicFilter = value;
}, elem);
createNumberAttr(getMsg('wavelength'), UV_WAVELENGTH, INFRARED_WAVELENGTH, 1, obj.wavelength || GREEN_WAVELENGTH, function(obj, value) {
obj.wavelength = value;
}, elem);
}
this.dichroicSettings(obj,elem);
},

//使用lineobj原型 Use the prototype lineobj
Expand Down
5 changes: 5 additions & 0 deletions simulator/js/objs/mirror.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,14 @@ objTypes['mirror'] = {

//顯示屬性方塊 Show the property box
p_box: function(obj, elem) {
this.dichroicSettings(obj,elem);
},

dichroicSettings: function(obj,elem){
if (colorMode) {
createBooleanAttr(getMsg('dichroic'), obj.isDichroic, function(obj, value) {
obj.isDichroic = value;
obj.wavelength = obj.wavelength || GREEN_WAVELENGTH;
}, elem);
createBooleanAttr(getMsg('filter'), obj.isDichroicFilter, function(obj, value) {
obj.isDichroicFilter = value;
Expand Down
14 changes: 3 additions & 11 deletions simulator/js/objs/parabolicmirror.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,11 @@ objTypes['parabolicmirror'] = {
return {type: 'parabolicmirror', p1: mouse, isDichroic: false, isDichroicFilter: false};
},

dichroicSettings: objTypes['mirror'].dichroicSettings,

//顯示屬性方塊 Show the property box
p_box: function(obj, elem) {
if (colorMode) {
createBooleanAttr(getMsg('dichroic'), obj.isDichroic, function(obj, value) {
obj.isDichroic = value;
}, elem);
createBooleanAttr(getMsg('filter'), obj.isDichroicFilter, function(obj, value) {
obj.isDichroicFilter = value;
}, elem);
createNumberAttr(getMsg('wavelength'), UV_WAVELENGTH, INFRARED_WAVELENGTH, 1, obj.wavelength || GREEN_WAVELENGTH, function(obj, value) {
obj.wavelength = value;
}, elem);
}
this.dichroicSettings(obj,elem);
},

c_mousedown: objTypes['arcmirror'].c_mousedown,
Expand Down

0 comments on commit 88b4a60

Please sign in to comment.