xushiting hai 1 ano
pai
achega
81c9ebdca4

+ 14 - 9
src/view/case/draw/board/editCAD/Controls/UIControl.js

@@ -405,14 +405,19 @@ export default class UIControl {
   }
 
   exportImg(canvas,filename, callback){
-    coordinate.ratio = 3;
+    coordinate.setRatio(3)
+    canvas.width = canvas.width * coordinate.ratio
+    canvas.height = canvas.height * coordinate.ratio
     this.layer.renderer.autoRedraw()
     setTimeout(() => {
-      let img = this.downloadCadImg(canvas, filename)
-      // 完成callback传出blob  callback(blob)
-      coordinate.ratio = 1;
+      let blobImg = this.downloadCadImg(canvas, filename)
+      // 完成callback传出blob  
+      callback(blobImg)
+      
+      canvas.width = canvas.width / coordinate.ratio
+      canvas.height = canvas.height / coordinate.ratio
+      coordinate.setRatio(1)
       this.layer.renderer.autoRedraw()
-      return img;
     },100)
 
   }
@@ -423,12 +428,12 @@ export default class UIControl {
     var type = "png";
     var imgData = canvas.toDataURL(type, 1);
 
-    let blobImg = this.base64ToBlob(imgData);
-    return blobImg;
+    //let blobImg = this.base64ToBlob(imgData);
+    
 
     // 加工image data,替换mime type
-    //imgData = imgData.replace(this._fixType(type), 'image/octet-stream')
-
+    let blobImg  = imgData.replace(this._fixType(type), 'image/octet-stream')
+    return blobImg;
     // download
     //this.saveFile(imgData, filename)
   }

+ 4 - 0
src/view/case/draw/board/editCAD/Coordinate.js

@@ -40,6 +40,10 @@ export default class Coordinate {
         }
     }
 
+    setRatio(ratio) {
+        this.ratio = ratio;
+    }
+
     // 世界坐标转换成屏幕坐标
     getScreenXY(point) {
         if (this.width == null || this.height == null) {

+ 2 - 2
src/view/case/draw/board/editCAD/Geometry/Table.js

@@ -192,11 +192,11 @@ export default class Table extends Geometry {
         const cell = floorplanService.getCell(vectorId)
         for(let i=0;i<cell.rowIndex;++i){
             const _cell = floorplanService.getCell(this.cells[i][0])
-            height += _cell.height;
+            height += _cell.height*coordinate.ratio;
         }
         for(let i=0;i<cell.colIndex;++i){
             const _cell = floorplanService.getCell(this.cells[0][i])
-            width += _cell.width;
+            width += _cell.width*coordinate.ratio;
         }
 
         return {

+ 35 - 36
src/view/case/draw/board/editCAD/Renderer/Draw.js

@@ -250,7 +250,8 @@ export default class Draw {
             //     this.context.fillText(geometry.value, fontStart1.newpoint2.x, fontStart1.newpoint2.y)
             // }
             //let count = (2*(i-(fontInfo.textValues.length-1))+1)
-            let count = 1 * (fontInfo.textValues.length-i)
+            //let count = 1 * (fontInfo.textValues.length-i)
+            let count = i+1
             count = 2* count  - fontInfo.textValues.length
             this.context.fillText(fontInfo.textValues[i], pt.x - fontWidth1/2, pt.y + dy*count)
         }
@@ -292,7 +293,7 @@ export default class Draw {
     drawCell(geometry,width,height){
 
         this.context.save()
-        this.context.lineWidth = Style.Table.lineWidth * coordinate.ratio
+        this.context.lineWidth = Style.Table.lineWidth 
         this.context.strokeStyle = Style.Table.strokeStyle
         this.context.fillStyle = Style.Table.fillStyle
 
@@ -321,16 +322,13 @@ export default class Draw {
         this.context.translate(width, height)
         this.context.beginPath()
         this.context.moveTo(0,0)
-        this.context.lineTo(geometry.width,0)
-        this.context.lineTo(geometry.width,geometry.height)
-        this.context.lineTo(0,geometry.height)
+        this.context.lineTo(geometry.width* coordinate.ratio,0)
+        this.context.lineTo(geometry.width* coordinate.ratio,geometry.height* coordinate.ratio)
+        this.context.lineTo(0,geometry.height* coordinate.ratio)
         this.context.closePath();
         this.context.stroke()
 
-        const defaultHeight = 24;
-        const defaultWidth = 156;
-
-        this.context.font = '12px Microsoft YaHei'
+        this.context.font = 12*coordinate.ratio+'px Microsoft YaHei'
         let fontWidth = this.context.measureText(geometry.value).width
         //如果是数字或者字母
         const patt = /[A-z0-9]/g;
@@ -342,12 +340,12 @@ export default class Draw {
         
 
         //let rowCount = Math.ceil(geometry.height/defaultHeight)               //分几行写
-        let rowCount = Math.ceil(fontWidth/geometry.width)                        //分几行写,根据要写的文字的长度来判断
+        let rowCount = Math.ceil(fontWidth/(geometry.width* coordinate.ratio))                        //分几行写,根据要写的文字的长度来判断
 
         if(rowCount == 1){
             this.context.textAlign = "center";
             this.context.textBaseline = "middle";
-            this.context.fillText(geometry.value, geometry.width/2, geometry.height/2)
+            this.context.fillText(geometry.value, geometry.width/2* coordinate.ratio, geometry.height/2* coordinate.ratio)
         }
         //大于1行
         else{
@@ -356,7 +354,7 @@ export default class Draw {
             this.context.textAlign = "left";
             for(let i=0;i<rowCount;++i){
                 const value = geometry.value.substr(i*rowFontCount,rowFontCount)
-                this.context.fillText(value, geometry.width/2 - rowWidth/2, 18+18*i)
+                this.context.fillText(value, (geometry.width/2* coordinate.ratio- rowWidth/2), (18+18*i)* coordinate.ratio)
             }
         }
 
@@ -460,7 +458,7 @@ export default class Draw {
 
     drawCircleGeo(geometry)
     {
-        let radius = geometry.radius * coordinate.res * coordinate.zoom/Constant.defaultZoom
+        let radius = geometry.radius * coordinate.res * coordinate.zoom/Constant.defaultZoom * coordinate.ratio
         const twoPi = Math.PI * 2
         const pt = coordinate.getScreenXY(geometry.center)
 
@@ -543,7 +541,7 @@ export default class Draw {
 
     drawIcon(geometry)
     {
-        let radius = geometry.radius * coordinate.res * coordinate.zoom/Constant.defaultZoom
+        let radius = geometry.radius * coordinate.res * coordinate.zoom/Constant.defaultZoom * coordinate.ratio
         const twoPi = Math.PI * 2
         const pt = coordinate.getScreenXY(geometry.center)
 
@@ -626,7 +624,7 @@ export default class Draw {
         this.setCanvasStyle(Style.Font)
         
         let fontSize = Math.ceil(radius * 14/20);
-        this.context.font = fontSize + Style.Font.font;   
+        this.context.font = fontSize + Style.Font.font   
         let center = coordinate.getScreenXY(geometry.center);
         this.context.fillText(geometry.value, center.x , center.y)
         this.context.restore()
@@ -842,17 +840,17 @@ export default class Draw {
             this.context.strokeStyle = Style.Focus.Title.strokeStyle
             this.context.fillStyle = Style.Focus.Title.fillStyle
         }
-        //let pt = {}
-        //pt.x = (this.context.canvas.width - this.context.measureText(geometry.value).width)/2
-        this.context.fillText(geometry.value, this.context.canvas.width/2, geometry.height)
+        //this.context.font = `400 ${geometry.fontSize}px Microsoft YaHei`
+        this.context.font = `${24*coordinate.ratio}px Microsoft YaHei`
+        this.context.fillText(geometry.value, this.context.canvas.width/2, geometry.height*coordinate.ratio)
         this.context.restore()
     }
     
     drawBgImage(geometry){
         if(geometry.src != null){
             const pt = {
-                x:80,
-                y:150
+                x:80*coordinate.ratio,
+                y:150*coordinate.ratio
             }
 
             this.context.save()
@@ -862,16 +860,16 @@ export default class Draw {
                 img.src = geometry.src;
                 img.crossOrigin=""
                 img.onload = function () {
-                    this.context.drawImage(img, pt.x, pt.y, img.width, img.height)
+                    this.context.drawImage(img, pt.x, pt.y, img.width*coordinate.ratio, img.height*coordinate.ratio)
                 }.bind(this)
                 geometry.image = img;
             }
             else{
                 if(geometry.hasOwnProperty('width')){
-                    this.context.drawImage(geometry.image, pt.x, pt.y, geometry.width, geometry.height)
+                    this.context.drawImage(geometry.image, pt.x, pt.y, geometry.width*coordinate.ratio, geometry.height*coordinate.ratio)
                 }
                 else{
-                    this.context.drawImage(geometry.image, pt.x, pt.y, geometry.image.width, geometry.image.height)
+                    this.context.drawImage(geometry.image, pt.x, pt.y, geometry.image.width*coordinate.ratio, geometry.image.height*coordinate.ratio)
                 }
                 
             }
@@ -904,18 +902,18 @@ export default class Draw {
                 img.crossOrigin=""
                 img.onload = function () {
                     //this.context.drawImage(img, pt.x-img.width/2, pt.y-img.height/2, img.width, img.height)
-                    this.context.drawImage(img, -img.width / 2, -img.height / 2)
+                    this.context.drawImage(img, -img.width / 2*coordinate.ratio, -img.height / 2*coordinate.ratio)
                 }.bind(this)
                 geometry.image = img;
             }
             else{
                 if(geometry.hasOwnProperty('width')){
                     //this.context.drawImage(geometry.image, pt.x-geometry.width/2, pt.y-geometry.height/2, geometry.width, geometry.height)
-                    this.context.drawImage(geometry.image, -geometry.ratio * geometry.width / 2, -geometry.ratio * geometry.height / 2,geometry.ratio * geometry.width / 2, geometry.ratio * geometry.height / 2)
+                    this.context.drawImage(geometry.image, -geometry.ratio * geometry.width / 2*coordinate.ratio, -geometry.ratio * geometry.height / 2*coordinate.ratio,geometry.ratio * geometry.width / 2*coordinate.ratio, geometry.ratio * geometry.height / 2*coordinate.ratio)
                 }
                 else{
                     //this.context.drawImage(geometry.image, pt.x-geometry.width/2, pt.y-geometry.height/2, geometry.image.width, geometry.image.height)
-                    this.context.drawImage(geometry.image, -geometry.ratio * geometry.width / 2, -geometry.ratio * geometry.height / 2,geometry.ratio * geometry.width / 2, geometry.ratio * geometry.height / 2)
+                    this.context.drawImage(geometry.image, -geometry.ratio * geometry.width / 2*coordinate.ratio, -geometry.ratio * geometry.height / 2*coordinate.ratio,geometry.ratio * geometry.width / 2*coordinate.ratio, geometry.ratio * geometry.height / 2*coordinate.ratio)
                 }
                 
             }
@@ -995,7 +993,8 @@ export default class Draw {
             }
         }
 
-        this.context.translate(geometry.center.x,geometry.center.y)
+        this.context.translate(geometry.center.x*coordinate.ratio,geometry.center.y*coordinate.ratio)
+        this.context.scale(coordinate.ratio,coordinate.ratio)
         this.context.translate(16, 36)
         this.context.rotate((geometry.angle)/180 * Math.PI)
         this.context.translate(-16, -36)
@@ -1179,7 +1178,7 @@ export default class Draw {
         this.context.rotate((geometry.angle / 180) * Math.PI)
         this.context.translate(pt.x - center.x, pt.y - center.y)
 
-        this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom, (geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
+        this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom*coordinate.ratio, (geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom*coordinate.ratio)
         this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
 
         this.context.miterLimit = 4
@@ -1286,7 +1285,7 @@ export default class Draw {
         this.context.translate(center.x, center.y)
         this.context.rotate((geometry.angle / 180) * Math.PI)
         this.context.translate(pt.x - center.x, pt.y - center.y)
-        this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32, (geometry.getLen() * geometry.scale * coordinate.res) / 32)
+        this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32*coordinate.ratio, (geometry.getLen() * geometry.scale * coordinate.res) / 32*coordinate.ratio)
         this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32)
 
         this.context.beginPath();
@@ -1358,7 +1357,7 @@ export default class Draw {
         this.context.translate(center.x, center.y)
         this.context.rotate((geometry.angle / 180) * Math.PI)
         this.context.translate(pt.x - center.x, pt.y - center.y)
-        this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom, (geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
+        this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom*coordinate.ratio, (geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom*coordinate.ratio)
         this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
 
         this.context.beginPath();
@@ -1469,7 +1468,7 @@ export default class Draw {
         this.context.translate(center.x, center.y)
         this.context.rotate((geometry.angle / 180) * Math.PI)
         this.context.translate(pt.x - center.x, pt.y - center.y)
-        this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom, (geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
+        this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom*coordinate.ratio, (geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom*coordinate.ratio)
         this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
 
         this.context.beginPath();
@@ -1580,7 +1579,7 @@ export default class Draw {
         this.context.translate(center.x, center.y)
         this.context.rotate((geometry.angle / 180) * Math.PI)
         this.context.translate(pt.x - center.x, pt.y - center.y)
-        this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom, (geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
+        this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom*coordinate.ratio, (geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom*coordinate.ratio)
         this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
 
         this.context.beginPath();
@@ -1651,7 +1650,7 @@ export default class Draw {
         this.context.translate(center.x, center.y)
         this.context.rotate((geometry.angle / 180) * Math.PI)
         this.context.translate(pt.x - center.x, pt.y - center.y)
-        this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom, (geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
+        this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom*coordinate.ratio, (geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom*coordinate.ratio)
         this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
 
         this.context.beginPath();
@@ -1722,7 +1721,7 @@ export default class Draw {
         this.context.translate(center.x, center.y)
         this.context.rotate((geometry.angle / 180) * Math.PI)
         this.context.translate(pt.x - center.x, pt.y - center.y)
-        this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom, (geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
+        this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom*coordinate.ratio, (geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom*coordinate.ratio)
         this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
 
         this.context.beginPath();
@@ -1876,7 +1875,7 @@ export default class Draw {
         this.context.translate(center.x, center.y)
         this.context.rotate((geometry.angle / 180) * Math.PI)
         this.context.translate(pt.x - center.x, pt.y - center.y)
-        this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom, (geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
+        this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom*coordinate.ratio, (geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom*coordinate.ratio)
         this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
 
         this.context.beginPath();
@@ -1986,7 +1985,7 @@ export default class Draw {
         this.context.translate(center.x, center.y)
         this.context.rotate((geometry.angle / 180) * Math.PI)
         this.context.translate(pt.x - center.x, pt.y - center.y)
-        this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom, (geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
+        this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom*coordinate.ratio, (geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom*coordinate.ratio)
         this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
 
         this.context.beginPath();

+ 1 - 1
src/view/case/draw/board/editCAD/Service/FloorplanService.js

@@ -304,7 +304,7 @@ export class FloorplanService {
         }
         let customImage = this.getCustomImage(customImageId, floor)
         customImage = null
-        delete floorplanData.floors[floor].customImages[tagId]
+        delete floorplanData.floors[floor].customImages[customImageId]
     }
 
     addTable(table, floor) {