Index: work/remote/web/client/scripts/draw.js =================================================================== --- work/remote/web/client/scripts/draw.js (revision 6546) +++ work/remote/web/client/scripts/draw.js (revision 6547) @@ -30,6 +30,7 @@ this.layers = []; this.layerGroups = []; this.currentLayerGroup = undefined; + this.enableDraw = true; } GraphicEngine.getLayerList = function () { return this.layers; @@ -44,7 +45,7 @@ } GraphicEngine.prototype.onMessage = function (command, args) { try { - switch (command) { + if (this.enableDraw) switch (command) { case "line": this.line(Number(args[0]), Number(args[1]), Number(args[2]), Number(args[3]), Number(args[4])); @@ -56,22 +57,36 @@ case "fcirc": this.fillCircle(Number(args[0]), Number(args[1]), Number(args[2]), Number(args[3])); return; - - case "clr": this.setColor(Number(args[0]), args[1]); return; + case "poly": this.fillPoly(Number(args[0]), + Number(args[1]), args[2]); + return; + case "clr": this.setColor(Number(args[0]), args[1]); + return; case "linwid": this.setLineWidth(Number(args[0]), Number(args[1])); return; - case "setxor": this.setXor(Number(args[0]), Number(args[1])); return; - case "cap": this.setLineCap(Number(args[0]), args[1]); return; - //case "umask": this.useMask(args[0]); return; - case "newlg": this.newLayerGroup(args[0], Number(args[1]), args[2][0], args[2][1], args[2][2]); return; - case "newly": this.newLayer(args[0], Number(args[1]), Number(args[2])); return; - case "setlg": this.setLayerGroup(Number(args[0]), Number(args[1]) === 1); return; - - case "makeGC": this.makeGC(); return; - case "delGC": this.deleteGC(Number(args[0])); return; - case "ready": this.ready(); return; - case "unit": this.setUnit(args[0]); return; - case "ver": this.version(Number(args[0])); return; + case "setxor": this.setXor(Number(args[0]), Number(args[1])); + return; + case "cap": this.setLineCap(Number(args[0]), args[1]); + return; + } + switch (command) { + case "newlg": this.newLayerGroup(args[0], Number(args[1]), + args[2][0], args[2][1], args[2][2]); + return; + case "newly": this.newLayer(args[0], Number(args[1]), Number(args[2])); + return; + case "setlg": this.setLayerGroup(Number(args[0]), Number(args[1]) === 1); + return; + case "makeGC": this.makeGC(); + return; + case "delGC": this.deleteGC(Number(args[0])); + return; + case "ready": this.ready(); + return; + case "unit": this.setUnit(args[0]); + return; + case "ver": this.version(Number(args[0])); + return; default: this.comm.error("unknown command: " + command); } } catch (e) { @@ -103,6 +118,18 @@ this.cc.arc(x1, y1, r, 0, 2 * Math.PI); this.cc.fill(); } +GraphicEngine.prototype.fillPoly = function (gci, n, points) { + if (!Array.isArray(points) || points.length === 0) { + return; + } + this.selectGC(gci); + this.cc.beginPath(); + this.cc.moveTo(points[0][0], points[0][1]); + for (var i = 1; i < points.length; ++i) { + this.cc.lineTo(points[i][0], points[i][1]); + } + this.cc.fill(); +} GraphicEngine.prototype.setColor = function (gci, color) { gc = this.GCs[gci]; if (!gc) { @@ -208,6 +235,8 @@ this.cc = this.mainCc; } this.currentLayerGroup = this.layerGroups[id]; + var name = this.currentLayerGroup.name; + this.enableDraw = name !== "top mask" && name !== "bottom mask" && name !== "fab"; if (this.currentLayerGroup && this.currentLayerGroup.isMask) { this.cc = this.maskCc; this.cc.clearRect(0, 0, this.cc.canvas.width, this.cc.canvas.height);