mxdraw 0.1.16 → 0.1.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/dist/lib/MxModule/McEdGetPointWorldDrawObject/McEdGetPointWorldDrawObjectClass.js +128 -1
  2. package/dist/lib/MxModule/McEdGetPointWorldDrawObject/index.js +5 -1
  3. package/dist/lib/MxModule/McGeVector3d/McGeVector3d.js +2 -1
  4. package/dist/lib/MxModule/McGeVector3d/index.js +3 -1
  5. package/dist/lib/MxModule/McGiWorldDraw/McGiWorldDraw.js +3 -1
  6. package/dist/lib/MxModule/McGiWorldDraw/index.js +2 -1
  7. package/dist/lib/MxModule/McGiWorldDrawType/McGiWorldDrawType.js +19 -1
  8. package/dist/lib/MxModule/McGiWorldDrawType/index.js +4 -1
  9. package/dist/lib/MxModule/MrxDbgUiPrBaseReturn/MrxDbgUiPrBaseReturn.js +31 -1
  10. package/dist/lib/MxModule/MrxDbgUiPrBaseReturn/index.js +5 -1
  11. package/dist/lib/MxModule/MrxDbgUiPrPoint/MrxDbgUiPrPointClass.js +159 -1
  12. package/dist/lib/MxModule/MrxDbgUiPrPoint/index.js +5 -1
  13. package/dist/lib/MxModule/MxDbAlignedDimension/MxDbAlignedDimension.js +213 -1
  14. package/dist/lib/MxModule/MxDbAlignedDimension/index.js +5 -1
  15. package/dist/lib/MxModule/MxDbEntity/MxDbEntity.js +258 -1
  16. package/dist/lib/MxModule/MxDbEntity/index.js +5 -1
  17. package/dist/lib/MxModule/MxDbImage/MxDbImage.js +160 -1
  18. package/dist/lib/MxModule/MxDbImage/index.js +5 -1
  19. package/dist/lib/MxModule/MxDbLine/MxDbLine.js +94 -1
  20. package/dist/lib/MxModule/MxDbLine/index.js +5 -1
  21. package/dist/lib/MxModule/MxDbPolyline/MxDbPolyline.js +97 -0
  22. package/dist/lib/MxModule/MxDbPolyline/index.js +5 -0
  23. package/dist/lib/MxModule/MxDbRect/MxDbRect.js +273 -1
  24. package/dist/lib/MxModule/MxDbRect/index.js +4 -1
  25. package/dist/lib/MxModule/MxDbSVG/MxDbSVG.js +419 -1
  26. package/dist/lib/MxModule/MxDbSVG/index.js +5 -1
  27. package/dist/lib/MxModule/MxDbSVGText/MxDbSVGText.js +21 -1
  28. package/dist/lib/MxModule/MxDbSVGText/index.js +5 -1
  29. package/dist/lib/MxModule/MxDrawObject/MxDrawObject.js +782 -1
  30. package/dist/lib/MxModule/MxDrawObject/index.js +5 -1
  31. package/dist/lib/MxModule/MxFilters/MxFilters.js +201 -1
  32. package/dist/lib/MxModule/MxFilters/index.js +4 -1
  33. package/dist/lib/MxModule/MxFun/MxFun.js +676 -1
  34. package/dist/lib/MxModule/MxFun/index.js +4 -1
  35. package/dist/lib/MxModule/MxThreeJS/MxThreeJS.js +283 -1
  36. package/dist/lib/MxModule/MxThreeJS/MxThreeJS.mixin.js +146 -1
  37. package/dist/lib/MxModule/MxThreeJS/SVGLoader.js +1862 -1
  38. package/dist/lib/MxModule/MxThreeJS/index.js +7 -1
  39. package/dist/lib/MxModule/MxType/MxType.js +27 -1
  40. package/dist/lib/MxModule/MxType/index.js +4 -1
  41. package/dist/lib/MxModule/Mxassembly/Mxassembly.js +20 -1
  42. package/dist/lib/MxModule/Mxassembly/index.js +9 -1
  43. package/dist/lib/MxModule/loadCoreCode/index.js +5 -1
  44. package/dist/lib/MxModule/loadCoreCode/loadCoreCode.js +125 -1
  45. package/dist/lib/MxModule/loadCoreCode/mxUiData.js +312 -1
  46. package/dist/lib/MxModule/loadCoreCode/mxcadassembly_es5.js +1519 -1
  47. package/dist/lib/MxModule/loadCoreCode/mxfun.es5.js +7363 -1
  48. package/dist/lib/MxModule/store/PubsubClass.js +40 -1
  49. package/dist/lib/MxModule/store/StoreClass.js +73 -1
  50. package/dist/lib/MxModule/store/index.js +19 -1
  51. package/dist/lib/MxModule/store/store.js +25 -1
  52. package/dist/lib/MxModule/useCanvasResizeListener/index.js +5 -1
  53. package/dist/lib/MxModule/useCanvasResizeListener/useCanvasResizeListener.js +95 -1
  54. package/dist/lib/doc.js +38 -1
  55. package/dist/lib/mxdraw.js +67 -1
  56. package/dist/lib/tools/algorithm/math.js +16 -1
  57. package/dist/lib/tools/algorithm/random.js +13 -1
  58. package/dist/lib/tools/dom/create.js +47 -1
  59. package/dist/lib/tools/dynamicImport/index.js +243 -1
  60. package/dist/lib/tools/formatting/index.js +20 -1
  61. package/dist/lib/tools/proxy/index.js +17 -1
  62. package/dist/lib/tools/three/index.js +124 -1
  63. package/dist/lib/types/McEdGetPointWorldDrawObject.js +2 -1
  64. package/dist/lib/types/MrxDbgUiPrPoint.js +2 -1
  65. package/dist/lib/types/MxCADObject.js +2 -1
  66. package/dist/lib/types/MxDrawObject.js +2 -1
  67. package/dist/lib/types/MxFun.js +2 -1
  68. package/dist/lib/types/Mxassembly.js +2 -1
  69. package/dist/types/MxModule/McEdGetPointWorldDrawObject/McEdGetPointWorldDrawObjectClass.d.ts +1 -0
  70. package/dist/types/MxModule/McGiWorldDraw/McGiWorldDraw.d.ts +1 -0
  71. package/dist/types/MxModule/MrxDbgUiPrPoint/MrxDbgUiPrPointClass.d.ts +2 -1
  72. package/dist/types/MxModule/MxDbEntity/MxDbEntity.d.ts +1 -0
  73. package/dist/types/MxModule/MxDbLine/MxDbLine.d.ts +2 -2
  74. package/dist/types/MxModule/MxDbPolyline/MxDbPolyline.d.ts +21 -0
  75. package/dist/types/MxModule/MxDbPolyline/index.d.ts +3 -0
  76. package/dist/types/MxModule/MxDbSVG/MxDbSVG.d.ts +1 -0
  77. package/dist/types/MxModule/MxDbSVGText/MxDbSVGText.d.ts +1 -0
  78. package/dist/types/MxModule/MxFun/MxFun.d.ts +7 -2
  79. package/dist/types/MxModule/MxThreeJS/MxThreeJS.d.ts +2 -0
  80. package/dist/types/MxModule/MxType/MxType.d.ts +1 -0
  81. package/dist/types/MxModule/loadCoreCode/mxUiData.d.ts +3 -3
  82. package/dist/types/MxModule/store/StoreClass.d.ts +10 -4
  83. package/dist/types/MxModule/store/store.d.ts +2 -2
  84. package/dist/types/mxdraw.d.ts +9 -2
  85. package/dist/types/types/MxFun.d.ts +6 -0
  86. package/package.json +1 -1
  87. package/dist/mxdraw.es5.js +0 -1
  88. package/dist/mxdraw.umd.js +0 -1
@@ -1 +1,419 @@
1
- "use strict";var __extends=this&&this.__extends||function(){var t=function(e,o){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])})(e,o)};return function(e,o){if("function"!=typeof o&&null!==o)throw new TypeError("Class extends value "+String(o)+" is not a constructor or null");function i(){this.constructor=e}t(e,o),e.prototype=null===o?Object.create(o):(i.prototype=o.prototype,new i)}}(),__awaiter=this&&this.__awaiter||function(t,e,o,i){return new(o||(o=Promise))(function(s,r){function n(t){try{c(i.next(t))}catch(t){r(t)}}function a(t){try{c(i.throw(t))}catch(t){r(t)}}function c(t){var e;t.done?s(t.value):(e=t.value,e instanceof o?e:new o(function(t){t(e)})).then(n,a)}c((i=i.apply(t,e||[])).next())})},__generator=this&&this.__generator||function(t,e){var o,i,s,r,n={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return r={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function a(r){return function(a){return function(r){if(o)throw new TypeError("Generator is already executing.");for(;n;)try{if(o=1,i&&(s=2&r[0]?i.return:r[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,r[1])).done)return s;switch(i=0,s&&(r=[2&r[0],s.value]),r[0]){case 0:case 1:s=r;break;case 4:return n.label++,{value:r[1],done:!1};case 5:n.label++,i=r[1],r=[0];continue;case 7:r=n.ops.pop(),n.trys.pop();continue;default:if(!(s=(s=n.trys).length>0&&s[s.length-1])&&(6===r[0]||2===r[0])){n=0;continue}if(3===r[0]&&(!s||r[1]>s[0]&&r[1]<s[3])){n.label=r[1];break}if(6===r[0]&&n.label<s[1]){n.label=s[1],s=r;break}if(s&&n.label<s[2]){n.label=s[2],n.ops.push(r);break}s[2]&&n.ops.pop(),n.trys.pop();continue}r=e.call(t,n)}catch(t){r=[6,t],i=0}finally{o=s=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,a])}}};Object.defineProperty(exports,"__esModule",{value:!0});var THREE=require("three"),MxDbEntity_1=require("../MxDbEntity"),MxDbSVGText_1=require("../MxDbSVGText"),MxThreeJS_1=require("../MxThreeJS"),MxType_1=require("../MxType"),MxDbSVG=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.svgPos=new THREE.Vector3,e.svg=null,e.svgPath="",e.svgSize=new THREE.Vector2(50,50),e.svgAlignmentRatio=new THREE.Vector2(0,0),e.svgRotate=0,e.svgReverse=!1,e.svgMargin=new THREE.Vector2(0,0),e.isSvgDirtyLocation=!1,e.isLoadFromPath=!0,e.aryText=[],e.svgBoxSize=null,e.fixedSize=!1,e.useSvgColor=!1,e}return __extends(e,t),e.prototype.calcVewSize=function(t){var e=this.svgSize.x,o=this.svgSize.y;return o<=0&&(o=this.svgBoxSize?this.svgBoxSize.y/this.svgBoxSize.x*e:e),this.fixedSize&&(e=t.screenCoordLong2Doc(e),o=t.screenCoordLong2Doc(o)),[e,o]},e.prototype.worldDraw=function(t){var e=this,o=t.getMxObject();this.calcSvgPosition(o);var i=this.calcVewSize(o),s=i[0],r=i[1],n=new THREE.Matrix4;this.svgReverse&&n.makeScale(1,-1,1);var a=new THREE.Matrix4;a.makeRotationZ(this.svgRotate);var c=new THREE.Matrix4,g=new THREE.Vector3(this.svgPos.x-s*this.svgAlignmentRatio.x,this.svgPos.y-r*this.svgAlignmentRatio.y,0);c.makeTranslation(g.x,g.y,g.z),a.multiply(n),a.premultiply(c);var v=new THREE.Vector3(0,0,0),h=new THREE.Vector3(s,0,0),x=new THREE.Vector3(s,r,0),l=new THREE.Vector3(0,r,0);if(v.applyMatrix4(a),h.applyMatrix4(a),x.applyMatrix4(a),l.applyMatrix4(a),1==t.getType()){if(this.aryText.forEach(function(i){if(i.txt.length>0){var s=new THREE.Vector3(i.txtPos.x,i.txtPos.y,0);e.fixedSize&&(i.txtPos.x>0?s.x=e.svgPos.x+o.screenCoordLong2Doc(i.txtPos.x):s.x=e.svgPos.x-o.screenCoordLong2Doc(i.txtPos.x),i.txtPos.y>0?s.y=e.svgPos.y+o.screenCoordLong2Doc(i.txtPos.y):s.y=e.svgPos.y-o.screenCoordLong2Doc(i.txtPos.y));var r=void 0;i.color&&(r=t.getColor(),t.setColor(i.color));var n=i.txtHeight;e.fixedSize&&(n=o.screenCoordLong2Doc(i.txtHeight)),i._txtObject=t.drawText(i.txt,n,0,s),i._txtAspectRatio=-1,r&&t.setColor(r)}}),this.svg)t.drawEntity(this.svg);else if(this.svgPath.length>0&&this.isLoadFromPath){var u=this,y=t.getMxObject();MxThreeJS_1.default.loadSVG(this.svgPath,void 0,function(e){if(e){var i=(new THREE.Box3).setFromObject(e);u.svgBoxSize||(u.svgBoxSize=new THREE.Vector3),u.svgBoxSize.x=i.max.x-i.min.x,u.svgBoxSize.y=i.max.y-i.min.y;var s=u.calcVewSize(o),r=s[0],n=s[1];e.scale.x=r/u.svgBoxSize.x,e.scale.y=n/u.svgBoxSize.y,e.scale.z=e.scale.x,u.svgReverse&&(e.scale.y*=-1),e.rotateZ(u.svgRotate),u.isSvgDirtyLocation=!0;var a=new THREE.Color(t.getColor());e.traverse(function(t){t.material&&(t.material=t.material.clone(),t.material.transparent=!0,u.useSvgColor||(t.material.color=a))}),u.svg=e,u.setNeedUpdateDisplay(),y.updateDisplay()}u.isLoadFromPath=!1})}t.drawSelectLine(v,x),t.drawSelectLine(h,l)}else t.drawLine(v,h),t.drawLine(h,x),t.drawLine(x,l),t.drawLine(l,v)},e.prototype.setSvgPath=function(t,e){return void 0===e&&(e=!1),__awaiter(this,void 0,void 0,function(){return __generator(this,function(o){switch(o.label){case 0:return this.svgPath=t,this.svg=null,this.isLoadFromPath=!0,this.svgBoxSize=null,e?[4,MxThreeJS_1.default.loadSVG(t)]:[3,2];case 1:o.sent(),o.label=2;case 2:return[2]}})})},e.prototype.getSvgPath=function(){return this.svgPath},e.prototype.setSvgPostion=function(t){this.svgPos=t.clone(),this.isSvgDirtyLocation=!0},e.prototype.getSvgPostion=function(){return this.svgPos},e.prototype.setSvgSize=function(t){this.svgSize=t,this.isSvgDirtyLocation=!0},e.prototype.getSvgSize=function(){return this.svgSize},e.prototype.setSvgAlignmentRatio=function(t){this.svgAlignmentRatio=t,this.isSvgDirtyLocation=!0},e.prototype.getSvgAlignmentRatio=function(){return this.svgAlignmentRatio},e.prototype.getText=function(t){return t<this.aryText.length?this.aryText[t]:null},e.prototype.addText=function(t){this.aryText.push(t)},e.prototype.getGripPoints=function(){var t=[];return t.push(this.svgPos),t},e.prototype.moveGripPointsAt=function(t,e){return 0==t&&(this.svgPos.add(e),this.fixedSize||this.aryText.forEach(function(t){t.txtPos.add(e)})),this.isSvgDirtyLocation=!0,!0},e.prototype.calcSvgPosition=function(t){if(this.svg&&this.isSvgDirtyLocation){this.isSvgDirtyLocation=!1;var e=this.calcVewSize(t),o=e[0],i=e[1];this.svg.position.x=this.svgPos.x-o*this.svgAlignmentRatio.x-this.svgMargin.x*o,this.svg.position.y=this.svgPos.y-i*this.svgAlignmentRatio.y-this.svgMargin.y*i}},e.prototype.dwgIn=function(t){var e=this;this.onDwgIn(t),this.fixedSize=t.fixedSize,this.fixedSize?this.svg=null:t.type==MxType_1.default.MxCloneType.kClone&&t.svg&&(this.svg=t.svg.clone()),this.svgPos.copy(t.svgPos),this.svgPath=t.svgPath.substr(0),this.svgSize.copy(t.svgSize),this.svgAlignmentRatio.copy(t.svgAlignmentRatio),this.isSvgDirtyLocation=!0,this.svg||(this.isLoadFromPath=!0),this.svgBoxSize=null;var o=t.txts;return this.aryText=[],o.forEach(function(t){var o=new MxDbSVGText_1.default;o.txt=t.txt,o.txtHeight=t.txtHeight,o.txtPos.copy(t.txtPos),e.aryText.push(o)}),this.svgRotate=t.svgRotate,this.useSvgColor=t.useSvgColor,this.svgReverse=t.svgReverse,this.svgMargin=t.svgMargin,!0},e.prototype.dwgOut=function(t){return this.onDwgOut(t),t.type==MxType_1.default.MxCloneType.kClone&&(t.svg=this.svg),t.svgPath=this.svgPath,t.svgPos=this.svgPos,t.svgSize=this.svgSize,t.svgAlignmentRatio=this.svgAlignmentRatio,t.txts=this.aryText,t.fixedSize=this.fixedSize,t.svgRotate=this.svgRotate,t.useSvgColor=this.useSvgColor,t.svgReverse=this.svgReverse,t.svgMargin=this.svgMargin,t},e.prototype.create=function(){return new e},e.prototype.transformBy=function(t){this.svgPos.applyMatrix4(t),this.isSvgDirtyLocation=!0,this.fixedSize||this.aryText.forEach(function(e){e.txtPos.applyMatrix4(t)})},e.prototype.getTypeName=function(){return"MxDbSVG"},e.prototype.setColor=function(e){if(t.prototype.setColor.call(this,e),this.svg){var o=new THREE.Color(this.color);this.svg.traverse(function(t){t.material&&(t.material.color=o)})}},e.prototype.onViewChange=function(){if(!this.fixedSize)return!1;var t=this.getMxObject();if(null==t)return!1;if(this.svg){if(!this.svgBoxSize){this.svgBoxSize=new THREE.Vector3;var e=(new THREE.Box3).setFromObject(this.svg);this.svgBoxSize.x=e.max.x-e.min.x,this.svgBoxSize.y=e.max.y-e.min.y}var o=this.calcVewSize(t),i=o[0],s=o[1];this.svg.scale.x=i/this.svgBoxSize.x,this.svg.scale.y=s/this.svgBoxSize.y,this.svg.scale.z=this.svg.scale.x,this.svgReverse&&(this.svg.scale.y*=-1),this.isSvgDirtyLocation=!0,this.calcSvgPosition(t)}var r=this;return this.aryText.forEach(function(e){if(e._txtObject&&t){var o=t.screenCoordLong2Doc(e.txtHeight);o>1e-5&&(e._txtAspectRatio<=0&&(e._txtAspectRatio=e._txtObject.scale.x/e._txtObject.scale.y),e._txtObject.scale.set(e._txtAspectRatio*o,o,1),e.txtPos.x>0?e._txtObject.position.x=r.svgPos.x+t.screenCoordLong2Doc(e.txtPos.x):e._txtObject.position.x=r.svgPos.x-t.screenCoordLong2Doc(e.txtPos.x),e.txtPos.y>0?e._txtObject.position.y=r.svgPos.y+t.screenCoordLong2Doc(e.txtPos.y):e._txtObject.position.y=r.svgPos.y-t.screenCoordLong2Doc(e.txtPos.y),e._txtObject.updateMatrix())}}),!0},e}(MxDbEntity_1.default);exports.default=MxDbSVG;
1
+ "use strict";
2
+ ///////////////////////////////////////////////////////////////////////////////
3
+ //版权所有(C)2002-2022,成都梦想凯德科技有限公司。
4
+ //本软件代码及其文档和相关资料归成都梦想凯德科技有限公司,应用包含本软件的程序必须包括以下版权声明
5
+ //此应用程序与成都梦想凯德科技有限公司成协议。通过使用本软件、其文档或相关材料
6
+ ///////////////////////////////////////////////////////////////////////////////
7
+ /** @module MxDbSVG*/
8
+ var __extends = (this && this.__extends) || (function () {
9
+ var extendStatics = function (d, b) {
10
+ extendStatics = Object.setPrototypeOf ||
11
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
12
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
13
+ return extendStatics(d, b);
14
+ };
15
+ return function (d, b) {
16
+ if (typeof b !== "function" && b !== null)
17
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
18
+ extendStatics(d, b);
19
+ function __() { this.constructor = d; }
20
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
21
+ };
22
+ })();
23
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
24
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
25
+ return new (P || (P = Promise))(function (resolve, reject) {
26
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
27
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
28
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
29
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
30
+ });
31
+ };
32
+ var __generator = (this && this.__generator) || function (thisArg, body) {
33
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
34
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
35
+ function verb(n) { return function (v) { return step([n, v]); }; }
36
+ function step(op) {
37
+ if (f) throw new TypeError("Generator is already executing.");
38
+ while (_) try {
39
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
40
+ if (y = 0, t) op = [op[0] & 2, t.value];
41
+ switch (op[0]) {
42
+ case 0: case 1: t = op; break;
43
+ case 4: _.label++; return { value: op[1], done: false };
44
+ case 5: _.label++; y = op[1]; op = [0]; continue;
45
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
46
+ default:
47
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
48
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
49
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
50
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
51
+ if (t[2]) _.ops.pop();
52
+ _.trys.pop(); continue;
53
+ }
54
+ op = body.call(thisArg, _);
55
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
56
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
57
+ }
58
+ };
59
+ Object.defineProperty(exports, "__esModule", { value: true });
60
+ var THREE = require("three");
61
+ var MxDbEntity_1 = require("../MxDbEntity");
62
+ var MxDbSVGText_1 = require("../MxDbSVGText");
63
+ var MxThreeJS_1 = require("../MxThreeJS");
64
+ var MxType_1 = require("../MxType");
65
+ /**
66
+ * MxDbSVG SVG对象.
67
+ */
68
+ var MxDbSVG = /** @class */ (function (_super) {
69
+ __extends(MxDbSVG, _super);
70
+ function MxDbSVG() {
71
+ var _this = _super !== null && _super.apply(this, arguments) || this;
72
+ _this.svgPos = new THREE.Vector3();
73
+ _this.svg = null;
74
+ _this.svgPath = '';
75
+ _this.svgSize = new THREE.Vector2(50, 50);
76
+ _this.svgAlignmentRatio = new THREE.Vector2(0, 0);
77
+ _this.svgRotate = 0;
78
+ _this.svgReverse = false;
79
+ _this.svgMargin = new THREE.Vector2(0, 0);
80
+ _this.isSvgDirtyLocation = false;
81
+ _this.isLoadFromPath = true;
82
+ _this.aryText = [];
83
+ _this.svgBoxSize = null;
84
+ // 固定尺寸,图片和文字大小,取屏幕像素绘图单位。
85
+ _this.fixedSize = false;
86
+ _this.useSvgColor = false;
87
+ return _this;
88
+ }
89
+ MxDbSVG.prototype.calcVewSize = function (mxObj) {
90
+ var sizew = this.svgSize.x;
91
+ var sizeh = this.svgSize.y;
92
+ if (sizeh <= 0) {
93
+ if (this.svgBoxSize) {
94
+ sizeh = (this.svgBoxSize.y / this.svgBoxSize.x) * sizew;
95
+ }
96
+ else {
97
+ sizeh = sizew;
98
+ }
99
+ }
100
+ if (this.fixedSize) {
101
+ sizew = mxObj.screenCoordLong2Doc(sizew);
102
+ sizeh = mxObj.screenCoordLong2Doc(sizeh);
103
+ }
104
+ return [sizew, sizeh];
105
+ };
106
+ MxDbSVG.prototype.worldDraw = function (pWorldDraw) {
107
+ var _this = this;
108
+ var mxObj = pWorldDraw.getMxObject();
109
+ this.calcSvgPosition(mxObj);
110
+ var _a = this.calcVewSize(mxObj), sizew = _a[0], sizeh = _a[1];
111
+ var matSclae = new THREE.Matrix4();
112
+ if (this.svgReverse)
113
+ matSclae.makeScale(1, -1, 1);
114
+ var mat = new THREE.Matrix4();
115
+ mat.makeRotationZ(this.svgRotate);
116
+ var matMove = new THREE.Matrix4();
117
+ var svgNewPos = new THREE.Vector3(this.svgPos.x - sizew * this.svgAlignmentRatio.x, this.svgPos.y - sizeh * this.svgAlignmentRatio.y, 0);
118
+ matMove.makeTranslation(svgNewPos.x, svgNewPos.y, svgNewPos.z);
119
+ mat.multiply(matSclae);
120
+ mat.premultiply(matMove);
121
+ var pt1 = new THREE.Vector3(0, 0, 0);
122
+ var pt3 = new THREE.Vector3(sizew, 0, 0);
123
+ var pt2 = new THREE.Vector3(sizew, sizeh, 0);
124
+ var pt4 = new THREE.Vector3(0, sizeh, 0);
125
+ pt1.applyMatrix4(mat);
126
+ pt3.applyMatrix4(mat);
127
+ pt2.applyMatrix4(mat);
128
+ pt4.applyMatrix4(mat);
129
+ if (pWorldDraw.getType() == 1) {
130
+ this.aryText.forEach(function (txt) {
131
+ if (txt.txt.length > 0) {
132
+ var posTxt = new THREE.Vector3(txt.txtPos.x, txt.txtPos.y, 0);
133
+ if (_this.fixedSize) {
134
+ if (txt.txtPos.x > 0)
135
+ posTxt.x = _this.svgPos.x + mxObj.screenCoordLong2Doc(txt.txtPos.x);
136
+ else
137
+ posTxt.x = _this.svgPos.x - mxObj.screenCoordLong2Doc(txt.txtPos.x);
138
+ if (txt.txtPos.y > 0)
139
+ posTxt.y = _this.svgPos.y + mxObj.screenCoordLong2Doc(txt.txtPos.y);
140
+ else
141
+ posTxt.y = _this.svgPos.y - mxObj.screenCoordLong2Doc(txt.txtPos.y);
142
+ }
143
+ var bakColor = undefined;
144
+ if (txt.color) {
145
+ bakColor = pWorldDraw.getColor();
146
+ pWorldDraw.setColor(txt.color);
147
+ }
148
+ var iSize = txt.txtHeight;
149
+ if (_this.fixedSize)
150
+ iSize = mxObj.screenCoordLong2Doc(txt.txtHeight);
151
+ txt._txtObject = pWorldDraw.drawText(txt.txt, iSize, 0, posTxt);
152
+ txt._txtAspectRatio = -1;
153
+ if (bakColor) {
154
+ pWorldDraw.setColor(bakColor);
155
+ }
156
+ }
157
+ });
158
+ if (this.svg) {
159
+ pWorldDraw.drawEntity(this.svg);
160
+ }
161
+ else {
162
+ if (this.svgPath.length > 0 && this.isLoadFromPath) {
163
+ var myThis_1 = this;
164
+ var mxobj_1 = pWorldDraw.getMxObject();
165
+ MxThreeJS_1.default.loadSVG(this.svgPath, undefined, function (obj) {
166
+ if (obj) {
167
+ var box = new THREE.Box3().setFromObject(obj);
168
+ if (!myThis_1.svgBoxSize) {
169
+ myThis_1.svgBoxSize = new THREE.Vector3();
170
+ }
171
+ myThis_1.svgBoxSize.x = box.max.x - box.min.x;
172
+ myThis_1.svgBoxSize.y = box.max.y - box.min.y;
173
+ var _a = myThis_1.calcVewSize(mxObj), sizew_1 = _a[0], sizeh_1 = _a[1];
174
+ obj.scale.x = sizew_1 / myThis_1.svgBoxSize.x;
175
+ obj.scale.y = sizeh_1 / myThis_1.svgBoxSize.y;
176
+ obj.scale.z = obj.scale.x;
177
+ if (myThis_1.svgReverse) {
178
+ obj.scale.y *= -1;
179
+ }
180
+ obj.rotateZ(myThis_1.svgRotate);
181
+ myThis_1.isSvgDirtyLocation = true;
182
+ var color_1 = new THREE.Color(pWorldDraw.getColor());
183
+ obj.traverse(function (child) {
184
+ if (child.material) {
185
+ child.material = child.material.clone();
186
+ child.material.transparent = true;
187
+ if (!myThis_1.useSvgColor)
188
+ child.material.color = color_1;
189
+ }
190
+ });
191
+ //this.svgPos.multiply
192
+ myThis_1.svg = obj;
193
+ myThis_1.setNeedUpdateDisplay();
194
+ mxobj_1.updateDisplay();
195
+ }
196
+ myThis_1.isLoadFromPath = false;
197
+ });
198
+ }
199
+ }
200
+ pWorldDraw.drawSelectLine(pt1, pt2);
201
+ pWorldDraw.drawSelectLine(pt3, pt4);
202
+ }
203
+ else {
204
+ pWorldDraw.drawLine(pt1, pt3);
205
+ pWorldDraw.drawLine(pt3, pt2);
206
+ pWorldDraw.drawLine(pt2, pt4);
207
+ pWorldDraw.drawLine(pt4, pt1);
208
+ }
209
+ };
210
+ MxDbSVG.prototype.setSvgPath = function (path, preload) {
211
+ if (preload === void 0) { preload = false; }
212
+ return __awaiter(this, void 0, void 0, function () {
213
+ return __generator(this, function (_a) {
214
+ switch (_a.label) {
215
+ case 0:
216
+ this.svgPath = path;
217
+ this.svg = null;
218
+ this.isLoadFromPath = true;
219
+ this.svgBoxSize = null;
220
+ if (!preload) return [3 /*break*/, 2];
221
+ return [4 /*yield*/, MxThreeJS_1.default.loadSVG(path)];
222
+ case 1:
223
+ _a.sent();
224
+ _a.label = 2;
225
+ case 2: return [2 /*return*/];
226
+ }
227
+ });
228
+ });
229
+ };
230
+ MxDbSVG.prototype.getSvgPath = function () {
231
+ return this.svgPath;
232
+ };
233
+ MxDbSVG.prototype.setSvgPostion = function (pos) {
234
+ this.svgPos = pos.clone();
235
+ this.isSvgDirtyLocation = true;
236
+ };
237
+ MxDbSVG.prototype.getSvgPostion = function () {
238
+ return this.svgPos;
239
+ };
240
+ MxDbSVG.prototype.setSvgSize = function (size) {
241
+ this.svgSize = size;
242
+ this.isSvgDirtyLocation = true;
243
+ };
244
+ MxDbSVG.prototype.getSvgSize = function () {
245
+ return this.svgSize;
246
+ };
247
+ MxDbSVG.prototype.setSvgAlignmentRatio = function (alignmentRatio) {
248
+ this.svgAlignmentRatio = alignmentRatio;
249
+ this.isSvgDirtyLocation = true;
250
+ };
251
+ MxDbSVG.prototype.getSvgAlignmentRatio = function () {
252
+ return this.svgAlignmentRatio;
253
+ };
254
+ MxDbSVG.prototype.getText = function (index) {
255
+ if (index < this.aryText.length) {
256
+ return this.aryText[index];
257
+ }
258
+ else {
259
+ return null;
260
+ }
261
+ };
262
+ MxDbSVG.prototype.addText = function (txt) {
263
+ this.aryText.push(txt);
264
+ };
265
+ MxDbSVG.prototype.getGripPoints = function () {
266
+ var ret = [];
267
+ ret.push(this.svgPos);
268
+ return ret;
269
+ };
270
+ MxDbSVG.prototype.moveGripPointsAt = function (index, offset) {
271
+ if (index == 0) {
272
+ this.svgPos.add(offset);
273
+ if (!this.fixedSize) {
274
+ this.aryText.forEach(function (txt) {
275
+ txt.txtPos.add(offset);
276
+ });
277
+ }
278
+ }
279
+ this.isSvgDirtyLocation = true;
280
+ return true;
281
+ };
282
+ MxDbSVG.prototype.calcSvgPosition = function (mxObj) {
283
+ if (!this.svg || !this.isSvgDirtyLocation) {
284
+ return;
285
+ }
286
+ this.isSvgDirtyLocation = false;
287
+ var _a = this.calcVewSize(mxObj), sizew = _a[0], sizeh = _a[1];
288
+ this.svg.position.x =
289
+ this.svgPos.x - sizew * this.svgAlignmentRatio.x - this.svgMargin.x * sizew;
290
+ this.svg.position.y =
291
+ this.svgPos.y - sizeh * this.svgAlignmentRatio.y - this.svgMargin.y * sizeh;
292
+ };
293
+ MxDbSVG.prototype.dwgIn = function (obj) {
294
+ var _this = this;
295
+ this.onDwgIn(obj);
296
+ this.fixedSize = obj['fixedSize'];
297
+ if (this.fixedSize) {
298
+ // svg = null,重新加载svg.
299
+ this.svg = null;
300
+ }
301
+ else if (obj.type == MxType_1.default.MxCloneType.kClone && obj['svg']) {
302
+ this.svg = obj['svg'].clone();
303
+ }
304
+ this.svgPos.copy(obj['svgPos']);
305
+ this.svgPath = obj['svgPath'].substr(0);
306
+ this.svgSize.copy(obj['svgSize']);
307
+ this.svgAlignmentRatio.copy(obj['svgAlignmentRatio']);
308
+ this.isSvgDirtyLocation = true;
309
+ if (!this.svg)
310
+ this.isLoadFromPath = true;
311
+ this.svgBoxSize = null;
312
+ var aryText = obj['txts'];
313
+ this.aryText = [];
314
+ aryText.forEach(function (txt) {
315
+ var copyTxt = new MxDbSVGText_1.default();
316
+ copyTxt.txt = txt.txt;
317
+ copyTxt.txtHeight = txt.txtHeight;
318
+ copyTxt.txtPos.copy(txt.txtPos);
319
+ _this.aryText.push(copyTxt);
320
+ });
321
+ this.svgRotate = obj['svgRotate'];
322
+ this.useSvgColor = obj['useSvgColor'];
323
+ this.svgReverse = obj['svgReverse'];
324
+ this.svgMargin = obj['svgMargin'];
325
+ return true;
326
+ };
327
+ MxDbSVG.prototype.dwgOut = function (obj) {
328
+ this.onDwgOut(obj);
329
+ if (obj.type == MxType_1.default.MxCloneType.kClone) {
330
+ obj['svg'] = this.svg;
331
+ }
332
+ obj['svgPath'] = this.svgPath;
333
+ obj['svgPos'] = this.svgPos;
334
+ obj['svgSize'] = this.svgSize;
335
+ obj['svgAlignmentRatio'] = this.svgAlignmentRatio;
336
+ obj['txts'] = this.aryText;
337
+ obj['fixedSize'] = this.fixedSize;
338
+ obj['svgRotate'] = this.svgRotate;
339
+ obj['useSvgColor'] = this.useSvgColor;
340
+ obj['svgReverse'] = this.svgReverse;
341
+ obj['svgMargin'] = this.svgMargin;
342
+ return obj;
343
+ };
344
+ MxDbSVG.prototype.create = function () {
345
+ return new MxDbSVG();
346
+ };
347
+ MxDbSVG.prototype.transformBy = function (mat) {
348
+ this.svgPos.applyMatrix4(mat);
349
+ this.isSvgDirtyLocation = true;
350
+ if (!this.fixedSize) {
351
+ this.aryText.forEach(function (txt) {
352
+ txt.txtPos.applyMatrix4(mat);
353
+ });
354
+ }
355
+ };
356
+ MxDbSVG.prototype.getTypeName = function () {
357
+ return 'MxDbSVG';
358
+ };
359
+ MxDbSVG.prototype.setColor = function (color) {
360
+ _super.prototype.setColor.call(this, color);
361
+ if (this.svg) {
362
+ var color_2 = new THREE.Color(this.color);
363
+ this.svg.traverse(function (child) {
364
+ if (child.material) {
365
+ child.material.color = color_2;
366
+ }
367
+ });
368
+ }
369
+ };
370
+ MxDbSVG.prototype.onViewChange = function () {
371
+ if (!this.fixedSize) {
372
+ return false;
373
+ }
374
+ var mxObj = this.getMxObject();
375
+ if (mxObj == null)
376
+ return false;
377
+ if (this.svg) {
378
+ if (!this.svgBoxSize) {
379
+ this.svgBoxSize = new THREE.Vector3();
380
+ var box = new THREE.Box3().setFromObject(this.svg);
381
+ this.svgBoxSize.x = box.max.x - box.min.x;
382
+ this.svgBoxSize.y = box.max.y - box.min.y;
383
+ }
384
+ var _a = this.calcVewSize(mxObj), sizew = _a[0], sizeh = _a[1];
385
+ this.svg.scale.x = sizew / this.svgBoxSize.x;
386
+ this.svg.scale.y = sizeh / this.svgBoxSize.y;
387
+ this.svg.scale.z = this.svg.scale.x;
388
+ if (this.svgReverse) {
389
+ this.svg.scale.y *= -1;
390
+ }
391
+ this.isSvgDirtyLocation = true;
392
+ this.calcSvgPosition(mxObj);
393
+ }
394
+ var myThis = this;
395
+ this.aryText.forEach(function (txt) {
396
+ if (txt._txtObject && mxObj) {
397
+ var iSize = mxObj.screenCoordLong2Doc(txt.txtHeight);
398
+ if (iSize > 0.00001) {
399
+ if (txt._txtAspectRatio <= 0) {
400
+ txt._txtAspectRatio = txt._txtObject.scale.x / txt._txtObject.scale.y;
401
+ }
402
+ txt._txtObject.scale.set(txt._txtAspectRatio * iSize, iSize, 1);
403
+ if (txt.txtPos.x > 0)
404
+ txt._txtObject.position.x = myThis.svgPos.x + mxObj.screenCoordLong2Doc(txt.txtPos.x);
405
+ else
406
+ txt._txtObject.position.x = myThis.svgPos.x - mxObj.screenCoordLong2Doc(txt.txtPos.x);
407
+ if (txt.txtPos.y > 0)
408
+ txt._txtObject.position.y = myThis.svgPos.y + mxObj.screenCoordLong2Doc(txt.txtPos.y);
409
+ else
410
+ txt._txtObject.position.y = myThis.svgPos.y - mxObj.screenCoordLong2Doc(txt.txtPos.y);
411
+ txt._txtObject.updateMatrix();
412
+ }
413
+ }
414
+ });
415
+ return true;
416
+ };
417
+ return MxDbSVG;
418
+ }(MxDbEntity_1.default));
419
+ exports.default = MxDbSVG;
@@ -1 +1,5 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var MxDbSVG_1=require("./MxDbSVG");exports.default=MxDbSVG_1.default;
1
+ "use strict";
2
+ /** @module McEdGetPointWorldDrawObject*/
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ var MxDbSVG_1 = require("./MxDbSVG");
5
+ exports.default = MxDbSVG_1.default;
@@ -1 +1,21 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var THREE=require("three"),MxDbSVGText=function(){return function(){this.txtPos=new THREE.Vector3,this.txt="",this.txtHeight=1,this.color=void 0,this._txtObject=null,this._txtAspectRatio=-1}}();exports.default=MxDbSVGText;
1
+ "use strict";
2
+ ///////////////////////////////////////////////////////////////////////////////
3
+ //版权所有(C)2002-2022,成都梦想凯德科技有限公司。
4
+ //本软件代码及其文档和相关资料归成都梦想凯德科技有限公司,应用包含本软件的程序必须包括以下版权声明
5
+ //此应用程序与成都梦想凯德科技有限公司成协议。通过使用本软件、其文档或相关材料
6
+ ///////////////////////////////////////////////////////////////////////////////
7
+ /** @module MxDbSVG*/
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ var THREE = require("three");
10
+ var MxDbSVGText = /** @class */ (function () {
11
+ function MxDbSVGText() {
12
+ this.txtPos = new THREE.Vector3();
13
+ this.txt = '';
14
+ this.txtHeight = 1;
15
+ this.color = undefined;
16
+ this._txtObject = null;
17
+ this._txtAspectRatio = -1;
18
+ }
19
+ return MxDbSVGText;
20
+ }());
21
+ exports.default = MxDbSVGText;
@@ -1 +1,5 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var MxDbSVGText_1=require("./MxDbSVGText");exports.default=MxDbSVGText_1.default;
1
+ "use strict";
2
+ /** @module McEdGetPointWorldDrawObject*/
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ var MxDbSVGText_1 = require("./MxDbSVGText");
5
+ exports.default = MxDbSVGText_1.default;