diff --git a/src/examples/app/index.ts b/src/examples/app/index.ts index 148f480..744e051 100644 --- a/src/examples/app/index.ts +++ b/src/examples/app/index.ts @@ -261,9 +261,9 @@ export function loadDrawDatas(app: GraphicApp) { storage.links.forEach((link) => { datas.push(new LinkData(link)); }); - /* storage.Rects.forEach((rect) => { + storage.Rects.forEach((rect) => { datas.push(new RectData(rect)); - }); */ + }); storage.iscsFans.forEach((fan) => { datas.push(new IscsFanData(fan)); }); diff --git a/src/graphics/rect/RectDrawAssistant.ts b/src/graphics/rect/RectDrawAssistant.ts index e186ce4..a8ed20e 100644 --- a/src/graphics/rect/RectDrawAssistant.ts +++ b/src/graphics/rect/RectDrawAssistant.ts @@ -93,17 +93,19 @@ export class RectDraw extends GraphicDrawAssistant { return [x, y, w, h]; } prepareData(data: IRectData): boolean { + if (this.point1 == null) { + console.log('Rect绘制因点不够取消绘制'); + return false; + } const p1 = this.point1 as Point; const p2 = this.point2 as Point; - if (p1 !== null) { - const [x, y, width, height] = this.normalize(p1, p2); - const template = this.graphicTemplate; - data.point = new Point(x, y); - data.lineWidth = template.lineWidth; - data.lineColor = template.lineColor; - data.width = width; - data.height = height; - } + const [x, y, width, height] = this.normalize(p1, p2); + const template = this.graphicTemplate; + data.point = new Point(x, y); + data.lineWidth = template.lineWidth; + data.lineColor = template.lineColor; + data.width = width; + data.height = height; return true; } }