Commit 3e869c39 authored by amandaghassaei's avatar amandaghassaei

step simulation forward

parent a8b7bf4d
......@@ -12,7 +12,8 @@ define(['jquery', 'underscore', 'menuParent', 'emSimPlist', 'emSim', 'emSimLatti
"click #runSimulation": "_runSimulation",
"click #pauseSimulation": "_pauseSimulation",
"click #resetSimulation": "_resetSimulation"
"click #resetSimulation": "_resetSimulation",
"click #stepSimulation": "_stepSimulation"
},
_initialize: function(){
......@@ -27,7 +28,7 @@ define(['jquery', 'underscore', 'menuParent', 'emSimPlist', 'emSim', 'emSimLatti
_runSimulation: function(e){
e.preventDefault();
emSim.run();
emSim.run(false);
},
_pauseSimulation: function(e){
......@@ -40,6 +41,11 @@ define(['jquery', 'underscore', 'menuParent', 'emSimPlist', 'emSim', 'emSimLatti
emSim.reset();
},
_stepSimulation: function(e){
e.preventDefault();
emSim.run(true);
},
_makeTemplateJSON: function(){
return _.extend(emSim.toJSON(), emSim.simLattice.toJSON(), emPlist);
......
......@@ -7,9 +7,12 @@
<% } else if (needsReset) { %>
<a href="#" id="runSimulation" class="btn btn-halfWidth btn-lg btn-success">Continue</a>
<a href="#" id="resetSimulation" class="btn btn-halfWidth btn-lg pull-right btn-default">Reset</a><br/><br/>
<a href="#" id="stepSimulation" class="btn btn-block btn-lg btn-default">Step Forward</a><br/>
<% } else { %>
<a href="#" id="runSimulation" class="btn btn-block btn-lg btn-success">Run Simulation</a><br/>
<a href="#" id="stepSimulation" class="btn btn-block btn-lg btn-default">Step Forward</a><br/>
<% } %>
<!--View Mode:-->
<!--<% _.each(EMViewModes, function(EMViewMode, key){ %>-->
<!--<label class="radio">-->
......
......@@ -82,17 +82,15 @@ define(['three', 'underscore', 'backbone', 'threeModel', 'appState', 'lattice'],
run: function(){
run: function(singleStepMode){
var self = this;
this.set("isRunning", true);
this.set("needsReset", true);
var dt = this.get("dtSolver")/1000000;//convert to sec
var renderRate = this.get("dtRender");
var runConstants = this._setRunConstants();
runConstants.dt = dt;
three.startAnimationLoop(function(){
var animationCallback = function(){
for (var i=0;i<renderRate-1;i++){
self.time += dt;
self.simLattice.iter(self.time, runConstants, false);
......@@ -102,7 +100,18 @@ define(['three', 'underscore', 'backbone', 'threeModel', 'appState', 'lattice'],
//if (self._getViewMode() == "translation"){
// self.calcTranslation();
//}
});
};
this.set("needsReset", true);
if (singleStepMode) {
animationCallback();
three.render();
return;
}
this.set("isRunning", true);
three.startAnimationLoop(animationCallback);
},
pause: function(){
......@@ -123,6 +132,7 @@ define(['three', 'underscore', 'backbone', 'threeModel', 'appState', 'lattice'],
},
fixCellAtIndex: function(index){
var position = index.clone().sub(lattice.get("cellsMin"));
var fixed = this.simLattice.fixCellAtIndex(position);
......
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