Add API method to allow soft stage updates

This commit is contained in:
Shaunak Kishore
2015-10-28 01:32:05 -04:00
parent cb227961d4
commit 872c3ce476
3 changed files with 13 additions and 2 deletions

View File

@ -43,8 +43,10 @@ const forceRefresh = (from_construct_stage) => {
} }
if (!_.isEqual(output, current)) { if (!_.isEqual(output, current)) {
glyph.stages[stage.type] = output; glyph.stages[stage.type] = output;
for (let i = types.indexOf(stage.type) + 1; i < types.length; i++) { if (!output || !current || stage.clearLaterStages(output, current)) {
glyph.stages[types[i]] = null; for (let i = types.indexOf(stage.type) + 1; i < types.length; i++) {
glyph.stages[types[i]] = null;
}
} }
Session.set('editor.glyph', glyph); Session.set('editor.glyph', glyph);
} }

View File

@ -38,6 +38,12 @@ stages.AbstractStage = class AbstractStage {
Session.set('stage.points', undefined); Session.set('stage.points', undefined);
Session.set('stage.status', undefined); Session.set('stage.status', undefined);
} }
// Returns true if the difference between the two outputs is significant
// enough that the output from all later stages must be erased. By default,
// we return true to be safe. We should be very careful when returning false.
clearLaterStages(output1, output2) {
return true;
}
// Return this stage's value based on current internal state. The default // Return this stage's value based on current internal state. The default
// implementation works for stages that follow the 'original/adjusted' // implementation works for stages that follow the 'original/adjusted'
// convention described in the constructor. // convention described in the constructor.

View File

@ -130,6 +130,9 @@ stages.analysis = class AnalysisStage extends stages.AbstractStage {
stage = this; stage = this;
updateStatus(); updateStatus();
} }
clearLaterStages(output1, output2) {
return output1.decomposition !== output2.decomposition;
}
getStageOutput() { getStageOutput() {
return { return {
decomposition: decomposition_util.convertTreeToDecomposition(this.tree), decomposition: decomposition_util.convertTreeToDecomposition(this.tree),