Index: web/client/scripts/draw.js =================================================================== --- web/client/scripts/draw.js (revision 6888) +++ web/client/scripts/draw.js (revision 6889) @@ -8,7 +8,9 @@ * @param options.comm - communication interface * @param options.canvas - HTML canvas rendering context * @param options.colors - color chart for symbolic color names + * @param options.layerGroupMap - prescriptions based on layer group id * @param options.purposeMap - prescriptions based on layer group purposes + * @param options.onNewLayerGroup - called when a new layer group is defined */ function GraphicEngine(options) { this.options = Object.assign({}, options); @@ -188,9 +190,6 @@ this.cc.fill(); } GraphicEngine.prototype.setColor = function (gci, color) { - if (!this.enableDrawing) { - return; - } gc = this.GCs[gci]; if (!gc) { this.comm.error("invalid GC"); @@ -212,9 +211,6 @@ } } GraphicEngine.prototype.setLineWidth = function (gci, width) { - if (!this.enableDrawing) { - return; - } gc = this.GCs[gci]; if (!gc) { this.comm.error("invalid GC"); @@ -240,9 +236,6 @@ // } //} GraphicEngine.prototype.setXor = function (gci, state) { - if (!this.enableDrawing) { - return; - } gc = this.GCs[gci]; if (!gc) { this.comm.error("invalid GC"); @@ -253,9 +246,6 @@ } } GraphicEngine.prototype.setLineCap = function (gci, cap) { - if (!this.enableDrawing) { - return; - } gc = this.GCs[gci]; if (!gc) { this.comm.error("invalid GC"); @@ -272,6 +262,9 @@ } } GraphicEngine.prototype.newLayerGroup = function (name, id, location, purpose, properties) { + if (this.layerGroups[id]) { + return; + } var locstr = ""; if (Array.isArray(location) && location.length > 0) { locstr = location[0]; @@ -296,7 +289,7 @@ } } } - this.layerGroups[id] = { + var lg = { name: name, id: id, location: locstr, @@ -304,6 +297,10 @@ props: props, isMask: isMask }; + this.layerGroups[id] = lg; + if (this.options.onNewLayerGroup) { + this.options.onNewLayerGroup(lg); + } } GraphicEngine.prototype.newLayer = function (name, id, groupId) { this.layers[name] = { @@ -322,6 +319,9 @@ } this.currentLayerGroup = this.layerGroups[id]; this.enableDrawing = true; + if (this.options.layerGroupMap[id] && this.options.layerGroupMap[id].hidden) { + this.enableDrawing = false; + } if (this.currentLayerGroup) { var purposes = this.currentLayerGroup.purposes; for (var i = 0; i < purposes.length; ++i) { Index: web/testclient/draw.html =================================================================== --- web/testclient/draw.html (revision 6888) +++ web/testclient/draw.html (revision 6889) @@ -6,12 +6,24 @@
choose test file:
- main canvasError loading draw-bundle.js
- +choose test file:
+ main canvasError loading draw-bundle.js
+ +