From 067f0ecbc1aa6edd8ff5c1d9dd2146fed3ad2dd0 Mon Sep 17 00:00:00 2001 From: Val Erastov Date: Tue, 24 Feb 2015 00:36:26 -0800 Subject: [PATCH] implement clean method --- web/app/sketcher/main2d.js | 20 +++++++++ web/test.html | 85 ++++++++++++++++++++++---------------- 2 files changed, 70 insertions(+), 35 deletions(-) diff --git a/web/app/sketcher/main2d.js b/web/app/sketcher/main2d.js index dfe949e7..455fd0b6 100644 --- a/web/app/sketcher/main2d.js +++ b/web/app/sketcher/main2d.js @@ -163,6 +163,11 @@ TCAD.App2D = function() { app.viewer.parametricManager.solve([], 0, 4); app.viewer.refresh(); }); + + this.registerAction('CLEAN UP', "Clean All Draw", function () { + app.cleanUp(); + app.viewer.refresh(); + }); }; TCAD.App2D.prototype.loadFromLocalStorage = function() { @@ -176,8 +181,23 @@ TCAD.App2D.prototype.loadFromLocalStorage = function() { this.viewer.repaint(); }; +TCAD.App2D.prototype.cleanUp = function() { + for (var l = 0; l < this.viewer.layers.length; ++l) { + var layer = this.viewer.layers[l]; + if (layer.objects.length != 0) { + layer.objects = []; + } + } + if (this.viewer.parametricManager.system.length != 0) { + this.viewer.parametricManager.system = []; + this.viewer.parametricManager.notify(); + } +}; + TCAD.App2D.prototype.loadSketch = function(sketch) { + this.cleanUp(); + var index = {}; function endPoint(p) { diff --git a/web/test.html b/web/test.html index ae6e2644..ae65dc57 100644 --- a/web/test.html +++ b/web/test.html @@ -1,46 +1,61 @@ + + - TCAD - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + +
\ No newline at end of file