mxdraw 0.0.18 → 0.1.3
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.
- package/README.md +66 -161
- package/dist/lib/MxModule/McEdGetPointWorldDrawObject/McEdGetPointWorldDrawObjectClass.js +0 -1
- package/dist/lib/MxModule/McEdGetPointWorldDrawObject/index.js +0 -1
- package/dist/lib/MxModule/McGeVector3d/McGeVector3d.js +2 -0
- package/dist/lib/MxModule/McGeVector3d/index.js +3 -0
- package/dist/lib/MxModule/McGiWorldDraw/McGiWorldDraw.js +0 -15
- package/dist/lib/MxModule/McGiWorldDraw/index.js +0 -2
- package/dist/lib/MxModule/McGiWorldDrawType/McGiWorldDrawType.js +19 -0
- package/dist/lib/MxModule/McGiWorldDrawType/index.js +4 -0
- package/dist/lib/MxModule/MrxDbgUiPrBaseReturn/MrxDbgUiPrBaseReturn.js +0 -1
- package/dist/lib/MxModule/MrxDbgUiPrBaseReturn/index.js +0 -1
- package/dist/lib/MxModule/MrxDbgUiPrPoint/MrxDbgUiPrPointClass.js +0 -1
- package/dist/lib/MxModule/MrxDbgUiPrPoint/index.js +0 -1
- package/dist/lib/MxModule/MxDbAlignedDimension/MxDbAlignedDimension.js +213 -0
- package/dist/lib/MxModule/MxDbAlignedDimension/index.js +5 -0
- package/dist/lib/MxModule/MxDbEntity/MxDbEntity.js +108 -28
- package/dist/lib/MxModule/MxDbEntity/index.js +0 -1
- package/dist/lib/MxModule/MxDbImage/MxDbImage.js +150 -0
- package/dist/lib/MxModule/MxDbImage/index.js +5 -0
- package/dist/lib/MxModule/MxDbSVG/MxDbSVG.js +208 -0
- package/dist/lib/MxModule/MxDbSVG/index.js +5 -0
- package/dist/lib/MxModule/MxDrawObject/MxDrawObject.js +112 -19
- package/dist/lib/MxModule/MxDrawObject/index.js +0 -1
- package/dist/lib/MxModule/MxFun/MxFun.js +111 -19
- package/dist/lib/MxModule/MxFun/index.js +0 -1
- package/dist/lib/MxModule/MxThreeJS/MxThreeJS.js +10 -35
- package/dist/lib/MxModule/MxThreeJS/MxThreeJS.mixin.js +71 -29
- package/dist/lib/MxModule/MxThreeJS/SVGLoader.js +0 -1
- package/dist/lib/MxModule/MxThreeJS/index.js +0 -1
- package/dist/lib/MxModule/MxType/MxType.js +27 -0
- package/dist/lib/MxModule/MxType/index.js +4 -0
- package/dist/lib/MxModule/Mxassembly/Mxassembly.js +18 -0
- package/dist/lib/MxModule/Mxassembly/index.js +9 -0
- package/dist/lib/MxModule/loadCoreCode/index.js +0 -1
- package/dist/lib/MxModule/loadCoreCode/loadCoreCode.js +62 -41
- package/dist/lib/MxModule/loadCoreCode/mxcadassembly_es5.js +1519 -0
- package/dist/lib/MxModule/loadCoreCode/mxfun.es5.js +743 -687
- package/dist/lib/MxModule/store/PubsubClass.js +0 -1
- package/dist/lib/MxModule/store/StoreClass.js +0 -1
- package/dist/lib/MxModule/store/index.js +0 -1
- package/dist/lib/MxModule/store/store.js +1 -1
- package/dist/lib/MxModule/useCanvasResizeListener/index.js +0 -1
- package/dist/lib/MxModule/useCanvasResizeListener/useCanvasResizeListener.js +77 -25
- package/dist/lib/doc.js +5 -2
- package/dist/lib/mxdraw.js +23 -4
- package/dist/lib/tools/algorithm/math.js +0 -1
- package/dist/lib/tools/algorithm/random.js +0 -1
- package/dist/lib/tools/dom/create.js +0 -1
- package/dist/lib/tools/dynamicImport/index.js +142 -0
- package/dist/lib/tools/formatting/index.js +0 -1
- package/dist/lib/tools/proxy/index.js +0 -1
- package/dist/lib/tools/three/index.js +0 -1
- package/dist/lib/types/McEdGetPointWorldDrawObject.js +2 -0
- package/dist/lib/types/MrxDbgUiPrPoint.js +2 -0
- package/dist/lib/types/MxCADObject.js +3 -0
- package/dist/lib/types/MxDrawObject.js +2 -0
- package/dist/lib/types/MxFun.js +2 -0
- package/dist/lib/types/Mxassembly.js +2 -0
- package/dist/mxdraw.es5.js +28 -3
- package/dist/mxdraw.es5.js.map +1 -1
- package/dist/mxdraw.umd.js +29 -4
- package/dist/mxdraw.umd.js.map +1 -1
- package/dist/types/MxModule/McEdGetPointWorldDrawObject/McEdGetPointWorldDrawObjectClass.d.ts +1 -1
- package/dist/types/MxModule/McGeVector3d/McGeVector3d.d.ts +17 -0
- package/dist/types/MxModule/McGeVector3d/index.d.ts +3 -0
- package/dist/types/MxModule/McGiWorldDraw/McGiWorldDraw.d.ts +89 -18
- package/dist/types/MxModule/McGiWorldDraw/index.d.ts +1 -2
- package/dist/types/MxModule/McGiWorldDrawType/McGiWorldDrawType.d.ts +16 -0
- package/dist/types/MxModule/McGiWorldDrawType/index.d.ts +2 -0
- package/dist/types/MxModule/MrxDbgUiPrPoint/MrxDbgUiPrPointClass.d.ts +1 -1
- package/dist/types/MxModule/MxDbAlignedDimension/MxDbAlignedDimension.d.ts +21 -0
- package/dist/types/MxModule/MxDbAlignedDimension/index.d.ts +3 -0
- package/dist/types/MxModule/MxDbEntity/MxDbEntity.d.ts +110 -16
- package/dist/types/MxModule/MxDbImage/MxDbImage.d.ts +28 -0
- package/dist/types/MxModule/MxDbImage/index.d.ts +3 -0
- package/dist/types/MxModule/MxDbSVG/MxDbSVG.d.ts +42 -0
- package/dist/types/MxModule/MxDbSVG/index.d.ts +3 -0
- package/dist/types/MxModule/MxDrawObject/MxDrawObject.d.ts +95 -13
- package/dist/types/MxModule/MxFun/MxFun.d.ts +87 -15
- package/dist/types/MxModule/MxThreeJS/MxThreeJS.d.ts +11 -14
- package/dist/types/MxModule/MxType/MxType.d.ts +24 -0
- package/dist/types/MxModule/MxType/index.d.ts +2 -0
- package/dist/types/MxModule/Mxassembly/Mxassembly.d.ts +11 -0
- package/dist/types/MxModule/Mxassembly/index.d.ts +3 -0
- package/dist/types/MxModule/loadCoreCode/mxcadassembly_es5.d.ts +1 -0
- package/dist/types/MxModule/store/store.d.ts +3 -1
- package/dist/types/MxModule/useCanvasResizeListener/useCanvasResizeListener.d.ts +9 -5
- package/dist/types/doc.d.ts +4 -1
- package/dist/types/mxdraw.d.ts +16 -3
- package/dist/types/tools/dynamicImport/index.d.ts +1 -0
- package/dist/types/types/McEdGetPointWorldDrawObject.d.ts +9 -0
- package/dist/types/types/MrxDbgUiPrPoint.d.ts +23 -0
- package/dist/types/types/MxCADObject.d.ts +40 -0
- package/dist/types/types/MxDrawObject.d.ts +57 -0
- package/dist/types/types/MxFun.d.ts +40 -0
- package/dist/types/types/Mxassembly.d.ts +3 -0
- package/package.json +6 -1
- package/dist/lib/MxModule/McEdGetPointWorldDrawObject/McEdGetPointWorldDrawObjectClass.js.map +0 -1
- package/dist/lib/MxModule/McEdGetPointWorldDrawObject/index.js.map +0 -1
- package/dist/lib/MxModule/McGiWorldDraw/McGiWorldDraw.js.map +0 -1
- package/dist/lib/MxModule/McGiWorldDraw/index.js.map +0 -1
- package/dist/lib/MxModule/MrxDbgUiPrBaseReturn/MrxDbgUiPrBaseReturn.js.map +0 -1
- package/dist/lib/MxModule/MrxDbgUiPrBaseReturn/index.js.map +0 -1
- package/dist/lib/MxModule/MrxDbgUiPrPoint/MrxDbgUiPrPointClass.js.map +0 -1
- package/dist/lib/MxModule/MrxDbgUiPrPoint/index.js.map +0 -1
- package/dist/lib/MxModule/MxDbEntity/MxDbEntity.js.map +0 -1
- package/dist/lib/MxModule/MxDbEntity/index.js.map +0 -1
- package/dist/lib/MxModule/MxDrawObject/MxDrawObject.js.map +0 -1
- package/dist/lib/MxModule/MxDrawObject/index.js.map +0 -1
- package/dist/lib/MxModule/MxFun/MxFun.js.map +0 -1
- package/dist/lib/MxModule/MxFun/index.js.map +0 -1
- package/dist/lib/MxModule/MxThreeJS/MxThreeJS.js.map +0 -1
- package/dist/lib/MxModule/MxThreeJS/MxThreeJS.mixin.js.map +0 -1
- package/dist/lib/MxModule/MxThreeJS/SVGLoader.js.map +0 -1
- package/dist/lib/MxModule/MxThreeJS/index.js.map +0 -1
- package/dist/lib/MxModule/loadCoreCode/index.js.map +0 -1
- package/dist/lib/MxModule/loadCoreCode/loadCoreCode.js.map +0 -1
- package/dist/lib/MxModule/loadCoreCode/mxfun.es5.js.map +0 -1
- package/dist/lib/MxModule/store/PubsubClass.js.map +0 -1
- package/dist/lib/MxModule/store/StoreClass.js.map +0 -1
- package/dist/lib/MxModule/store/index.js.map +0 -1
- package/dist/lib/MxModule/store/store.js.map +0 -1
- package/dist/lib/MxModule/useCanvasResizeListener/index.js.map +0 -1
- package/dist/lib/MxModule/useCanvasResizeListener/useCanvasResizeListener.js.map +0 -1
- package/dist/lib/doc.js.map +0 -1
- package/dist/lib/mxdraw.js.map +0 -1
- package/dist/lib/tools/algorithm/math.js.map +0 -1
- package/dist/lib/tools/algorithm/random.js.map +0 -1
- package/dist/lib/tools/dom/create.js.map +0 -1
- package/dist/lib/tools/formatting/index.js.map +0 -1
- package/dist/lib/tools/proxy/index.js.map +0 -1
- package/dist/lib/tools/three/index.js.map +0 -1
|
@@ -1,31 +1,49 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/** @module MxDbEntity*/
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
var MxType_1 = require("../MxType");
|
|
5
|
+
var store_1 = require("../store/store");
|
|
4
6
|
/**
|
|
5
|
-
* MxDbEntity
|
|
7
|
+
* MxDbEntity 用于构建一个自定义对象的抽象类(该类无法实例化 请通过继承的方式对其抽象方法进行实现)
|
|
8
|
+
* @description MxDbEntity 属于 abstract class(抽象类) 主要用途是通过继承这个类实现一个用于动态绘制的回调对象
|
|
9
|
+
* 继承实现这个类必须实现的抽象方法:(方法名称前有'Abstract'标签就是必须实现的方法)
|
|
6
10
|
* @example ```typescript
|
|
7
|
-
*
|
|
11
|
+
* import THREE from "three"
|
|
12
|
+
* import { McGiWorldDraw, MxDbEntity } from "mxdraw"
|
|
13
|
+
* class MxLineEntity extends MxDbEntity {
|
|
14
|
+
* constructor() {
|
|
15
|
+
* super(); // 在派生类的构造函数中必须调用 super()
|
|
16
|
+
* }
|
|
17
|
+
* private pt1: THREE.Vector3 = new THREE.Vector3();
|
|
18
|
+
* private pt2: THREE.Vector3 = new THREE.Vector3();
|
|
19
|
+
* worldDraw(pWorldDraw: McGiWorldDraw) {
|
|
20
|
+
* pWorldDraw.drawLine(this.pt1,this.pt2);
|
|
21
|
+
* }
|
|
22
|
+
* ...
|
|
23
|
+
* }
|
|
8
24
|
* ```
|
|
9
25
|
*/
|
|
10
26
|
var MxDbEntity = /** @class */ (function () {
|
|
11
27
|
function MxDbEntity() {
|
|
12
28
|
this.iColor = 0xffffff;
|
|
29
|
+
this.iRenderOrder = 30;
|
|
13
30
|
}
|
|
14
31
|
/**
|
|
15
|
-
*
|
|
32
|
+
* 自定义实体的坐标变换.
|
|
16
33
|
* @param
|
|
17
|
-
* @returns
|
|
34
|
+
* @returns void
|
|
18
35
|
* @example
|
|
19
|
-
*
|
|
20
|
-
*
|
|
36
|
+
* }
|
|
21
37
|
* ```
|
|
22
38
|
*/
|
|
23
|
-
MxDbEntity.prototype.
|
|
24
|
-
|
|
25
|
-
|
|
39
|
+
MxDbEntity.prototype.transformBy = function (mat) { };
|
|
40
|
+
MxDbEntity.prototype.getImp = function () {
|
|
41
|
+
var myThis = this;
|
|
42
|
+
var imp = myThis['MxDbEntityImp'];
|
|
43
|
+
return imp;
|
|
26
44
|
};
|
|
27
45
|
/**
|
|
28
|
-
*
|
|
46
|
+
* 更新显示
|
|
29
47
|
* @param
|
|
30
48
|
* @returns boolean
|
|
31
49
|
* @example
|
|
@@ -33,31 +51,37 @@ var MxDbEntity = /** @class */ (function () {
|
|
|
33
51
|
*
|
|
34
52
|
* ```
|
|
35
53
|
*/
|
|
36
|
-
MxDbEntity.prototype.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
54
|
+
MxDbEntity.prototype.setNeedUpdateDisplay = function (isImmediate) {
|
|
55
|
+
var imp = this.getImp();
|
|
56
|
+
if (imp) {
|
|
57
|
+
if (isImmediate) {
|
|
58
|
+
imp.upDisplay();
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
imp.setDirtyDisplay(true);
|
|
62
|
+
}
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
44
68
|
};
|
|
45
69
|
/**
|
|
46
|
-
*
|
|
70
|
+
* 得到对象的id.
|
|
47
71
|
* @param
|
|
48
|
-
* @returns
|
|
72
|
+
* @returns number
|
|
49
73
|
* @example
|
|
50
74
|
* ``` typescript
|
|
51
75
|
*
|
|
52
76
|
* ```
|
|
53
77
|
*/
|
|
54
|
-
MxDbEntity.prototype.
|
|
78
|
+
MxDbEntity.prototype.objectId = function () {
|
|
55
79
|
var imp = this.getImp();
|
|
56
80
|
if (imp) {
|
|
57
|
-
return imp.
|
|
81
|
+
return imp.objectId();
|
|
58
82
|
}
|
|
59
83
|
else {
|
|
60
|
-
return
|
|
84
|
+
return 0;
|
|
61
85
|
}
|
|
62
86
|
};
|
|
63
87
|
/**
|
|
@@ -103,18 +127,74 @@ var MxDbEntity = /** @class */ (function () {
|
|
|
103
127
|
return this.iColor;
|
|
104
128
|
};
|
|
105
129
|
/**
|
|
106
|
-
*
|
|
130
|
+
* 复制对象。
|
|
131
|
+
* @param
|
|
132
|
+
* @returns MxDbEntity
|
|
133
|
+
* @example
|
|
134
|
+
* ``` typescript
|
|
135
|
+
*
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
MxDbEntity.prototype.clone = function (type) {
|
|
139
|
+
var ret = this.create();
|
|
140
|
+
var objData = { type: type ? type : MxType_1.default.MxCloneType.kClone };
|
|
141
|
+
this.dwgOut(objData);
|
|
142
|
+
ret.dwgIn(objData);
|
|
143
|
+
return ret;
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* 自定义对象内部数据输入同步(实现dwgIn抽象方法 必须在实现中调用 this.onDwgIn())
|
|
147
|
+
* @param obj dwgIn抽象方法的回调数据
|
|
148
|
+
*/
|
|
149
|
+
MxDbEntity.prototype.onDwgIn = function (obj) {
|
|
150
|
+
this.iColor = obj['iColor'];
|
|
151
|
+
this.iRenderOrder = obj['iRenderOrder'];
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* 自定义对象内部数据输出同步(实现dwgIn抽象方法 必须在实现中调用 this.onDwgIn()
|
|
155
|
+
* @param obj dwgOut抽象方法的回调数据
|
|
156
|
+
*/
|
|
157
|
+
MxDbEntity.prototype.onDwgOut = function (obj) {
|
|
158
|
+
obj['iColor'] = this.iColor;
|
|
159
|
+
obj['iRenderOrder'] = this.iRenderOrder;
|
|
160
|
+
};
|
|
161
|
+
/**
|
|
162
|
+
* 初始自定义对象的类型信息.
|
|
107
163
|
* @param
|
|
108
|
-
* @returns
|
|
164
|
+
* @returns
|
|
165
|
+
* @example
|
|
166
|
+
* ``` typescript
|
|
167
|
+
*
|
|
168
|
+
* ```
|
|
169
|
+
*/
|
|
170
|
+
MxDbEntity.prototype.rxInit = function () {
|
|
171
|
+
;
|
|
172
|
+
store_1.default.state.MxFun.initMxDbEntityType(this);
|
|
173
|
+
};
|
|
174
|
+
/**
|
|
175
|
+
* 设置显示顺序
|
|
176
|
+
* @param
|
|
177
|
+
* @returns boolean
|
|
178
|
+
* @example
|
|
179
|
+
* ``` typescript
|
|
180
|
+
*
|
|
181
|
+
* ```
|
|
182
|
+
*/
|
|
183
|
+
MxDbEntity.prototype.setRenderOrder = function (iRenderOrder) {
|
|
184
|
+
this.iRenderOrder = iRenderOrder;
|
|
185
|
+
};
|
|
186
|
+
/**
|
|
187
|
+
* 得到显示顺序
|
|
188
|
+
* @param
|
|
189
|
+
* @returns boolean
|
|
109
190
|
* @example
|
|
110
191
|
* ``` typescript
|
|
111
192
|
*
|
|
112
193
|
* ```
|
|
113
194
|
*/
|
|
114
|
-
MxDbEntity.prototype.
|
|
115
|
-
return
|
|
195
|
+
MxDbEntity.prototype.getRenderOrder = function () {
|
|
196
|
+
return this.iRenderOrder;
|
|
116
197
|
};
|
|
117
198
|
return MxDbEntity;
|
|
118
199
|
}());
|
|
119
200
|
exports.default = MxDbEntity;
|
|
120
|
-
//# sourceMappingURL=MxDbEntity.js.map
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
3
|
+
//版权所有(C)2002-2022,成都梦想凯德科技有限公司。
|
|
4
|
+
//本软件代码及其文档和相关资料归成都梦想凯德科技有限公司
|
|
5
|
+
//应用包含本软件的程序必须包括以下声明
|
|
6
|
+
//在版权声明中:
|
|
7
|
+
//此应用程序与成都梦想凯德科技有限公司成协议。
|
|
8
|
+
//通过使用本软件、其文档或相关材料
|
|
9
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
10
|
+
/** @module MxDbImage*/
|
|
11
|
+
var __extends = (this && this.__extends) || (function () {
|
|
12
|
+
var extendStatics = function (d, b) {
|
|
13
|
+
extendStatics = Object.setPrototypeOf ||
|
|
14
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
15
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
16
|
+
return extendStatics(d, b);
|
|
17
|
+
};
|
|
18
|
+
return function (d, b) {
|
|
19
|
+
if (typeof b !== "function" && b !== null)
|
|
20
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
21
|
+
extendStatics(d, b);
|
|
22
|
+
function __() { this.constructor = d; }
|
|
23
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
24
|
+
};
|
|
25
|
+
})();
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
var THREE = require("three");
|
|
28
|
+
var MxDbEntity_1 = require("../MxDbEntity");
|
|
29
|
+
var MxFun_1 = require("../MxFun");
|
|
30
|
+
/**
|
|
31
|
+
* MxDbImage 图片对象.
|
|
32
|
+
*/
|
|
33
|
+
var MxDbImage = /** @class */ (function (_super) {
|
|
34
|
+
__extends(MxDbImage, _super);
|
|
35
|
+
function MxDbImage() {
|
|
36
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
37
|
+
// pt1,pt2是图片的两个对角点.
|
|
38
|
+
_this.pt1 = new THREE.Vector3();
|
|
39
|
+
_this.pt2 = new THREE.Vector3();
|
|
40
|
+
_this.imagePath = '';
|
|
41
|
+
_this.isLoadMaterialFromPath = true;
|
|
42
|
+
_this.material = null;
|
|
43
|
+
return _this;
|
|
44
|
+
}
|
|
45
|
+
MxDbImage.prototype.getTypeName = function () {
|
|
46
|
+
return 'MxDbImage';
|
|
47
|
+
};
|
|
48
|
+
// 图片对象的绘制
|
|
49
|
+
MxDbImage.prototype.worldDraw = function (pWorldDraw) {
|
|
50
|
+
var _this = this;
|
|
51
|
+
var pt3 = new THREE.Vector3(this.pt1.x, this.pt2.y);
|
|
52
|
+
var pt4 = new THREE.Vector3(this.pt2.x, this.pt1.y);
|
|
53
|
+
pWorldDraw.drawLine(this.pt1, pt3);
|
|
54
|
+
pWorldDraw.drawLine(pt3, this.pt2);
|
|
55
|
+
pWorldDraw.drawLine(this.pt2, pt4);
|
|
56
|
+
pWorldDraw.drawLine(pt4, this.pt1);
|
|
57
|
+
if (pWorldDraw.getType() == 1) {
|
|
58
|
+
// 图片正常的显示绘制.
|
|
59
|
+
if (this.material) {
|
|
60
|
+
var w = Math.abs(this.pt1.x - this.pt2.x);
|
|
61
|
+
var h = Math.abs(this.pt1.y - this.pt2.y);
|
|
62
|
+
var geometry = new THREE.PlaneGeometry(w, h);
|
|
63
|
+
var x = Math.min(this.pt1.x, this.pt2.x);
|
|
64
|
+
var y = Math.min(this.pt1.y, this.pt2.y);
|
|
65
|
+
for (var i = 0; i < geometry.vertices.length; i++) {
|
|
66
|
+
geometry.vertices[i].x += x + w * 0.5;
|
|
67
|
+
geometry.vertices[i].y += y + h * 0.5;
|
|
68
|
+
geometry.vertices[i].z = 0;
|
|
69
|
+
}
|
|
70
|
+
var mesh = new THREE.Mesh(geometry, this.material);
|
|
71
|
+
mesh.material['depthTest'] = false;
|
|
72
|
+
pWorldDraw.drawEntity(mesh);
|
|
73
|
+
}
|
|
74
|
+
else if (this.imagePath.length > 0 && this.isLoadMaterialFromPath) {
|
|
75
|
+
var myThis_1 = this;
|
|
76
|
+
MxFun_1.default.loadImageMaterial('./models/img/mxcad.jpg', function (material) {
|
|
77
|
+
_this.isLoadMaterialFromPath = false;
|
|
78
|
+
if (!material) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
myThis_1.setMaterial(material);
|
|
82
|
+
myThis_1.setNeedUpdateDisplay();
|
|
83
|
+
MxFun_1.default.updateDisplay();
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
MxDbImage.prototype.setImagePath = function (sPath) {
|
|
89
|
+
this.imagePath = sPath;
|
|
90
|
+
this.isLoadMaterialFromPath = true;
|
|
91
|
+
this.material = null;
|
|
92
|
+
};
|
|
93
|
+
MxDbImage.prototype.getImagePath = function () {
|
|
94
|
+
return this.imagePath;
|
|
95
|
+
};
|
|
96
|
+
MxDbImage.prototype.setMaterial = function (material) {
|
|
97
|
+
this.material = material;
|
|
98
|
+
};
|
|
99
|
+
MxDbImage.prototype.setPoint1 = function (pt1) {
|
|
100
|
+
this.pt1 = pt1;
|
|
101
|
+
};
|
|
102
|
+
MxDbImage.prototype.getPoint1 = function () {
|
|
103
|
+
return this.pt1;
|
|
104
|
+
};
|
|
105
|
+
MxDbImage.prototype.setPoint2 = function (pt2) {
|
|
106
|
+
this.pt2 = pt2;
|
|
107
|
+
};
|
|
108
|
+
MxDbImage.prototype.getPoint2 = function () {
|
|
109
|
+
return this.pt2;
|
|
110
|
+
};
|
|
111
|
+
// 返回图片的可编辑的夹点.
|
|
112
|
+
MxDbImage.prototype.getGripPoints = function () {
|
|
113
|
+
var ret = [];
|
|
114
|
+
ret.push(this.pt1);
|
|
115
|
+
ret.push(this.pt2);
|
|
116
|
+
return ret;
|
|
117
|
+
};
|
|
118
|
+
// 图片的夹点拖动编辑.
|
|
119
|
+
MxDbImage.prototype.moveGripPointsAt = function (index, offset) {
|
|
120
|
+
if (index == 0) {
|
|
121
|
+
this.pt1.add(offset);
|
|
122
|
+
}
|
|
123
|
+
else if ((index = 1)) {
|
|
124
|
+
this.pt2.add(offset);
|
|
125
|
+
}
|
|
126
|
+
return true;
|
|
127
|
+
};
|
|
128
|
+
// 图片数据的保存.
|
|
129
|
+
MxDbImage.prototype.dwgIn = function (obj) {
|
|
130
|
+
this.onDwgIn(obj);
|
|
131
|
+
this.pt1.copy(obj['pt1']);
|
|
132
|
+
this.pt2.copy(obj['pt2']);
|
|
133
|
+
this.imagePath = obj['imagePath'].substr(0);
|
|
134
|
+
this.isLoadMaterialFromPath = true;
|
|
135
|
+
return true;
|
|
136
|
+
};
|
|
137
|
+
// 图片数据的恢复.
|
|
138
|
+
MxDbImage.prototype.dwgOut = function (obj) {
|
|
139
|
+
this.onDwgOut(obj);
|
|
140
|
+
obj['pt1'] = this.pt1;
|
|
141
|
+
obj['pt2'] = this.pt2;
|
|
142
|
+
obj['imagePath'] = this.imagePath;
|
|
143
|
+
return obj;
|
|
144
|
+
};
|
|
145
|
+
MxDbImage.prototype.create = function () {
|
|
146
|
+
return new MxDbImage();
|
|
147
|
+
};
|
|
148
|
+
return MxDbImage;
|
|
149
|
+
}(MxDbEntity_1.default));
|
|
150
|
+
exports.default = MxDbImage;
|
|
@@ -0,0 +1,208 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
var THREE = require("three");
|
|
25
|
+
var MxDbEntity_1 = require("../MxDbEntity");
|
|
26
|
+
var MxFun_1 = require("../MxFun");
|
|
27
|
+
var MxThreeJS_1 = require("../MxThreeJS");
|
|
28
|
+
var MxType_1 = require("../MxType");
|
|
29
|
+
/**
|
|
30
|
+
* MxDbSVG SVG对象.
|
|
31
|
+
*/
|
|
32
|
+
var MxDbSVG = /** @class */ (function (_super) {
|
|
33
|
+
__extends(MxDbSVG, _super);
|
|
34
|
+
function MxDbSVG() {
|
|
35
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
36
|
+
_this.svgPos = new THREE.Vector3();
|
|
37
|
+
_this.svgPath = '';
|
|
38
|
+
_this.svgSize = new THREE.Vector2(50, 50);
|
|
39
|
+
_this.svgAlignmentRatio = new THREE.Vector2(0, 0);
|
|
40
|
+
_this.isSvgDirtyLocation = false;
|
|
41
|
+
_this.isLoadFromPath = true;
|
|
42
|
+
_this.txtPos = new THREE.Vector3();
|
|
43
|
+
_this.txt = '';
|
|
44
|
+
_this.txtHeight = 1;
|
|
45
|
+
return _this;
|
|
46
|
+
}
|
|
47
|
+
MxDbSVG.prototype.worldDraw = function (pWorldDraw) {
|
|
48
|
+
this.calcSvgPosition();
|
|
49
|
+
if (this.txt.length > 0) {
|
|
50
|
+
var posTxt = new THREE.Vector3(this.txtPos.x, this.txtPos.y, 0);
|
|
51
|
+
pWorldDraw.drawText(this.txt, this.txtHeight, 0, posTxt);
|
|
52
|
+
}
|
|
53
|
+
var svgPosX = this.svgPos.x - this.svgSize.x * this.svgAlignmentRatio.x;
|
|
54
|
+
var svgPosY = this.svgPos.y - this.svgSize.y * this.svgAlignmentRatio.y;
|
|
55
|
+
var pt1 = new THREE.Vector3(svgPosX, svgPosY, 0);
|
|
56
|
+
var pt2 = new THREE.Vector3(svgPosX + this.svgSize.x, svgPosY + this.svgSize.y, 0);
|
|
57
|
+
if (pWorldDraw.getType() == 1) {
|
|
58
|
+
if (this.svg) {
|
|
59
|
+
pWorldDraw.drawEntity(this.svg);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
if (this.svgPath.length > 0 && this.isLoadFromPath) {
|
|
63
|
+
var myThis_1 = this;
|
|
64
|
+
MxThreeJS_1.default.loadSVG(this.svgPath, undefined, function (obj) {
|
|
65
|
+
if (obj) {
|
|
66
|
+
var box = new THREE.Box3().setFromObject(obj);
|
|
67
|
+
obj.scale.x = myThis_1.svgSize.x / (box.max.x - box.min.x);
|
|
68
|
+
obj.scale.y = myThis_1.svgSize.y / (box.max.y - box.min.y);
|
|
69
|
+
obj.scale.z = obj.scale.x;
|
|
70
|
+
myThis_1.isSvgDirtyLocation = true;
|
|
71
|
+
obj.traverse(function (child) {
|
|
72
|
+
if (child.material) {
|
|
73
|
+
child.material.transparent = true;
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
//this.svgPos.multiply
|
|
77
|
+
myThis_1.svg = obj;
|
|
78
|
+
myThis_1.setNeedUpdateDisplay(true);
|
|
79
|
+
MxFun_1.default.updateDisplay();
|
|
80
|
+
}
|
|
81
|
+
myThis_1.isLoadFromPath = false;
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
pWorldDraw.drawSelectLine(pt1.x, pt1.y, pt2.x, pt2.y);
|
|
86
|
+
pWorldDraw.drawSelectLine(pt1.x, pt2.y, pt2.x, pt1.y);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
pWorldDraw.drawLine(pt1.x, pt1.y, pt1.x, pt2.y);
|
|
90
|
+
pWorldDraw.drawLine(pt1.x, pt2.y, pt2.x, pt2.y);
|
|
91
|
+
pWorldDraw.drawLine(pt2.x, pt2.y, pt2.x, pt1.y);
|
|
92
|
+
pWorldDraw.drawLine(pt2.x, pt1.y, pt1.x, pt1.y);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
MxDbSVG.prototype.setSvgPath = function (path) {
|
|
96
|
+
this.svgPath = path;
|
|
97
|
+
this.svg = null;
|
|
98
|
+
this.isLoadFromPath = true;
|
|
99
|
+
};
|
|
100
|
+
MxDbSVG.prototype.getSvgPath = function () {
|
|
101
|
+
return this.svgPath;
|
|
102
|
+
};
|
|
103
|
+
MxDbSVG.prototype.setSvgPostion = function (pos) {
|
|
104
|
+
this.svgPos = pos;
|
|
105
|
+
this.isSvgDirtyLocation = true;
|
|
106
|
+
};
|
|
107
|
+
MxDbSVG.prototype.getSvgPostion = function () {
|
|
108
|
+
return this.svgPos;
|
|
109
|
+
};
|
|
110
|
+
MxDbSVG.prototype.setSvgSize = function (size) {
|
|
111
|
+
this.svgSize = size;
|
|
112
|
+
this.isSvgDirtyLocation = true;
|
|
113
|
+
};
|
|
114
|
+
MxDbSVG.prototype.getSvgSize = function () {
|
|
115
|
+
return this.svgSize;
|
|
116
|
+
};
|
|
117
|
+
MxDbSVG.prototype.setSvgAlignmentRatio = function (alignmentRatio) {
|
|
118
|
+
this.svgAlignmentRatio = alignmentRatio;
|
|
119
|
+
this.isSvgDirtyLocation = true;
|
|
120
|
+
};
|
|
121
|
+
MxDbSVG.prototype.getSvgAlignmentRatio = function () {
|
|
122
|
+
return this.svgAlignmentRatio;
|
|
123
|
+
};
|
|
124
|
+
//
|
|
125
|
+
MxDbSVG.prototype.setTextHeight = function (height) {
|
|
126
|
+
this.txtHeight = height;
|
|
127
|
+
};
|
|
128
|
+
MxDbSVG.prototype.getTextHeight = function () {
|
|
129
|
+
return this.txtHeight;
|
|
130
|
+
};
|
|
131
|
+
MxDbSVG.prototype.setText = function (txt) {
|
|
132
|
+
this.txt = txt;
|
|
133
|
+
};
|
|
134
|
+
MxDbSVG.prototype.getText = function () {
|
|
135
|
+
return this.txt;
|
|
136
|
+
};
|
|
137
|
+
MxDbSVG.prototype.setTextPostion = function (pos) {
|
|
138
|
+
this.txtPos = pos;
|
|
139
|
+
};
|
|
140
|
+
MxDbSVG.prototype.getTextPostion = function () {
|
|
141
|
+
return this.txtPos;
|
|
142
|
+
};
|
|
143
|
+
MxDbSVG.prototype.getGripPoints = function () {
|
|
144
|
+
var ret = [];
|
|
145
|
+
ret.push(this.svgPos);
|
|
146
|
+
return ret;
|
|
147
|
+
};
|
|
148
|
+
MxDbSVG.prototype.moveGripPointsAt = function (index, offset) {
|
|
149
|
+
if (index == 0) {
|
|
150
|
+
this.svgPos.add(offset);
|
|
151
|
+
this.txtPos.add(offset);
|
|
152
|
+
}
|
|
153
|
+
this.isSvgDirtyLocation = true;
|
|
154
|
+
return true;
|
|
155
|
+
};
|
|
156
|
+
MxDbSVG.prototype.calcSvgPosition = function () {
|
|
157
|
+
if (!this.svg || !this.isSvgDirtyLocation) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
this.isSvgDirtyLocation = false;
|
|
161
|
+
this.svg.position.x = this.svgPos.x - this.svgSize.x * this.svgAlignmentRatio.x;
|
|
162
|
+
this.svg.position.y = this.svgPos.y - this.svgSize.y * this.svgAlignmentRatio.y;
|
|
163
|
+
};
|
|
164
|
+
MxDbSVG.prototype.dwgIn = function (obj) {
|
|
165
|
+
this.onDwgIn(obj);
|
|
166
|
+
if (obj.type == MxType_1.default.MxCloneType.kClone && obj['svg']) {
|
|
167
|
+
this.svg = obj['svg'].clone();
|
|
168
|
+
}
|
|
169
|
+
this.svgPos.copy(obj['svgPos']);
|
|
170
|
+
this.svgPath = obj['svgPath'].substr(0);
|
|
171
|
+
this.svgSize.copy(obj['svgSize']);
|
|
172
|
+
this.svgAlignmentRatio.copy(obj['svgAlignmentRatio']);
|
|
173
|
+
this.isSvgDirtyLocation = true;
|
|
174
|
+
if (!this.svg)
|
|
175
|
+
this.isLoadFromPath = true;
|
|
176
|
+
this.txt = obj['txt'];
|
|
177
|
+
this.txtHeight = obj['txtHeight'];
|
|
178
|
+
this.txtPos.copy(obj['txtPos']);
|
|
179
|
+
return true;
|
|
180
|
+
};
|
|
181
|
+
MxDbSVG.prototype.dwgOut = function (obj) {
|
|
182
|
+
this.onDwgOut(obj);
|
|
183
|
+
if (obj.type == MxType_1.default.MxCloneType.kClone) {
|
|
184
|
+
obj['svg'] = this.svg;
|
|
185
|
+
}
|
|
186
|
+
obj['svgPath'] = this.svgPath;
|
|
187
|
+
obj['svgPos'] = this.svgPos;
|
|
188
|
+
obj['svgSize'] = this.svgSize;
|
|
189
|
+
obj['svgAlignmentRatio'] = this.svgAlignmentRatio;
|
|
190
|
+
obj['txt'] = this.txt;
|
|
191
|
+
obj['txtHeight'] = this.txtHeight;
|
|
192
|
+
obj['txtPos'] = this.txtPos;
|
|
193
|
+
return obj;
|
|
194
|
+
};
|
|
195
|
+
MxDbSVG.prototype.create = function () {
|
|
196
|
+
return new MxDbSVG();
|
|
197
|
+
};
|
|
198
|
+
MxDbSVG.prototype.transformBy = function (mat) {
|
|
199
|
+
this.svgPos.applyMatrix4(mat);
|
|
200
|
+
this.txtPos.applyMatrix4(mat);
|
|
201
|
+
this.isSvgDirtyLocation = true;
|
|
202
|
+
};
|
|
203
|
+
MxDbSVG.prototype.getTypeName = function () {
|
|
204
|
+
return 'MxDbSVG';
|
|
205
|
+
};
|
|
206
|
+
return MxDbSVG;
|
|
207
|
+
}(MxDbEntity_1.default));
|
|
208
|
+
exports.default = MxDbSVG;
|