deeptwins-engine-3d 0.1.64 → 0.1.65

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 (169) hide show
  1. package/dist/esm/{plot/utils/Algorithm.js → drawer/algorithm.js} +1 -3
  2. package/dist/esm/drawer/common.d.ts +61 -0
  3. package/dist/esm/{plot/utils/PlotCommon.js → drawer/common.js} +104 -551
  4. package/dist/esm/drawer/index.d.ts +11 -18
  5. package/dist/esm/drawer/index.js +329 -80
  6. package/dist/esm/{plot/utils → drawer}/plotUtil.js +1 -3
  7. package/dist/esm/drawer/shape/Assemble.d.ts +34 -0
  8. package/dist/esm/drawer/shape/Assemble.js +415 -0
  9. package/dist/esm/drawer/shape/AttackArrow.d.ts +32 -0
  10. package/dist/esm/drawer/shape/AttackArrow.js +442 -0
  11. package/dist/esm/drawer/shape/BaseShape.d.ts +14 -4
  12. package/dist/esm/drawer/shape/BaseShape.js +175 -20
  13. package/dist/esm/drawer/shape/Bow.d.ts +31 -0
  14. package/dist/esm/drawer/shape/Bow.js +375 -0
  15. package/dist/esm/drawer/shape/Circle.d.ts +37 -0
  16. package/dist/esm/drawer/shape/Circle.js +461 -0
  17. package/dist/esm/drawer/shape/Curve.d.ts +29 -0
  18. package/dist/esm/drawer/shape/Curve.js +386 -0
  19. package/dist/esm/drawer/shape/DragPoint.d.ts +32 -0
  20. package/dist/esm/drawer/shape/DragPoint.js +211 -0
  21. package/dist/esm/drawer/shape/Elliptic.d.ts +38 -0
  22. package/dist/esm/drawer/shape/Elliptic.js +491 -0
  23. package/dist/esm/drawer/shape/Formation.d.ts +33 -0
  24. package/dist/esm/drawer/shape/Formation.js +395 -0
  25. package/dist/esm/drawer/shape/PincerArrow.d.ts +32 -0
  26. package/dist/esm/drawer/shape/PincerArrow.js +445 -0
  27. package/dist/esm/drawer/shape/Point.d.ts +2 -31
  28. package/dist/esm/drawer/shape/Point.js +7 -201
  29. package/dist/esm/drawer/shape/Polygon.d.ts +1 -1
  30. package/dist/esm/drawer/shape/Polygon.js +10 -81
  31. package/dist/esm/drawer/shape/Polyline.d.ts +1 -1
  32. package/dist/esm/drawer/shape/Polyline.js +10 -81
  33. package/dist/esm/drawer/shape/RegularPolygon.d.ts +37 -0
  34. package/dist/esm/drawer/shape/RegularPolygon.js +468 -0
  35. package/dist/esm/drawer/shape/RightAngleArrow.d.ts +34 -0
  36. package/dist/esm/drawer/shape/RightAngleArrow.js +423 -0
  37. package/dist/esm/drawer/shape/Sector.d.ts +37 -0
  38. package/dist/esm/drawer/shape/Sector.js +568 -0
  39. package/dist/esm/drawer/shape/StraightArrow.d.ts +34 -0
  40. package/dist/esm/drawer/shape/StraightArrow.js +422 -0
  41. package/dist/esm/drawer/shape/SwallowtailArrow.d.ts +36 -0
  42. package/dist/esm/drawer/shape/SwallowtailArrow.js +438 -0
  43. package/dist/esm/drawer/types.d.ts +23 -0
  44. package/dist/esm/drawer/types.js +11 -0
  45. package/dist/esm/drawer/utils.d.ts +14 -0
  46. package/dist/esm/drawer/utils.js +320 -2
  47. package/dist/esm/index.js +2 -2
  48. package/dist/esm/measure/Area.d.ts +17 -17
  49. package/dist/esm/measure/Area.js +95 -63
  50. package/dist/esm/measure/BaseDraw.d.ts +9 -4
  51. package/dist/esm/measure/BaseDraw.js +37 -2
  52. package/dist/esm/measure/Distance.d.ts +9 -9
  53. package/dist/esm/measure/Distance.js +52 -68
  54. package/dist/esm/measure/index.d.ts +16 -26
  55. package/dist/esm/measure/index.js +72 -84
  56. package/dist/esm/measure/types.d.ts +94 -0
  57. package/dist/esm/measure/types.js +17 -0
  58. package/dist/esm/measure/utils.d.ts +7 -7
  59. package/dist/esm/measure/utils.js +43 -24
  60. package/dist/esm/tool/utils.js +1 -1
  61. package/dist/umd/deeptwins-engine-3d.min.js +1 -1
  62. package/package.json +1 -1
  63. package/dist/esm/plot/create/CreateAssemble.d.ts +0 -2
  64. package/dist/esm/plot/create/CreateAssemble.js +0 -63
  65. package/dist/esm/plot/create/CreateAttackArrow.d.ts +0 -5
  66. package/dist/esm/plot/create/CreateAttackArrow.js +0 -75
  67. package/dist/esm/plot/create/CreateBillboard.d.ts +0 -2
  68. package/dist/esm/plot/create/CreateBillboard.js +0 -47
  69. package/dist/esm/plot/create/CreateBow.d.ts +0 -2
  70. package/dist/esm/plot/create/CreateBow.js +0 -63
  71. package/dist/esm/plot/create/CreateCircle.d.ts +0 -2
  72. package/dist/esm/plot/create/CreateCircle.js +0 -68
  73. package/dist/esm/plot/create/CreateCurve.d.ts +0 -2
  74. package/dist/esm/plot/create/CreateCurve.js +0 -76
  75. package/dist/esm/plot/create/CreateElliptic.d.ts +0 -2
  76. package/dist/esm/plot/create/CreateElliptic.js +0 -69
  77. package/dist/esm/plot/create/CreateFlag.d.ts +0 -2
  78. package/dist/esm/plot/create/CreateFlag.js +0 -80
  79. package/dist/esm/plot/create/CreateFormation.d.ts +0 -2
  80. package/dist/esm/plot/create/CreateFormation.js +0 -65
  81. package/dist/esm/plot/create/CreateFreeLine.d.ts +0 -2
  82. package/dist/esm/plot/create/CreateFreeLine.js +0 -69
  83. package/dist/esm/plot/create/CreateFreePolygon.d.ts +0 -2
  84. package/dist/esm/plot/create/CreateFreePolygon.js +0 -65
  85. package/dist/esm/plot/create/CreateLabel.d.ts +0 -2
  86. package/dist/esm/plot/create/CreateLabel.js +0 -55
  87. package/dist/esm/plot/create/CreateLineArrow.d.ts +0 -2
  88. package/dist/esm/plot/create/CreateLineArrow.js +0 -79
  89. package/dist/esm/plot/create/CreatePincerArrow.d.ts +0 -5
  90. package/dist/esm/plot/create/CreatePincerArrow.js +0 -73
  91. package/dist/esm/plot/create/CreatePoint.d.ts +0 -2
  92. package/dist/esm/plot/create/CreatePoint.js +0 -47
  93. package/dist/esm/plot/create/CreatePolygon.d.ts +0 -2
  94. package/dist/esm/plot/create/CreatePolygon.js +0 -80
  95. package/dist/esm/plot/create/CreatePolyline.d.ts +0 -2
  96. package/dist/esm/plot/create/CreatePolyline.js +0 -70
  97. package/dist/esm/plot/create/CreateRectangle.d.ts +0 -2
  98. package/dist/esm/plot/create/CreateRectangle.js +0 -60
  99. package/dist/esm/plot/create/CreateRegularPolygon.d.ts +0 -2
  100. package/dist/esm/plot/create/CreateRegularPolygon.js +0 -75
  101. package/dist/esm/plot/create/CreateRightAngleArrow.d.ts +0 -5
  102. package/dist/esm/plot/create/CreateRightAngleArrow.js +0 -73
  103. package/dist/esm/plot/create/CreateRoundRectangle.d.ts +0 -2
  104. package/dist/esm/plot/create/CreateRoundRectangle.js +0 -63
  105. package/dist/esm/plot/create/CreateSector.d.ts +0 -2
  106. package/dist/esm/plot/create/CreateSector.js +0 -65
  107. package/dist/esm/plot/create/CreateStraightArrow.d.ts +0 -5
  108. package/dist/esm/plot/create/CreateStraightArrow.js +0 -65
  109. package/dist/esm/plot/create/CreateSwallowtailArrow.d.ts +0 -5
  110. package/dist/esm/plot/create/CreateSwallowtailArrow.js +0 -67
  111. package/dist/esm/plot/create/index.d.ts +0 -25
  112. package/dist/esm/plot/create/index.js +0 -25
  113. package/dist/esm/plot/edit/EditAssemble.d.ts +0 -8
  114. package/dist/esm/plot/edit/EditAssemble.js +0 -120
  115. package/dist/esm/plot/edit/EditAttackArrow.d.ts +0 -8
  116. package/dist/esm/plot/edit/EditAttackArrow.js +0 -182
  117. package/dist/esm/plot/edit/EditBillboard.d.ts +0 -7
  118. package/dist/esm/plot/edit/EditBillboard.js +0 -70
  119. package/dist/esm/plot/edit/EditBow.d.ts +0 -8
  120. package/dist/esm/plot/edit/EditBow.js +0 -119
  121. package/dist/esm/plot/edit/EditCircle.d.ts +0 -8
  122. package/dist/esm/plot/edit/EditCircle.js +0 -133
  123. package/dist/esm/plot/edit/EditCurve.d.ts +0 -8
  124. package/dist/esm/plot/edit/EditCurve.js +0 -180
  125. package/dist/esm/plot/edit/EditElliptic.d.ts +0 -8
  126. package/dist/esm/plot/edit/EditElliptic.js +0 -144
  127. package/dist/esm/plot/edit/EditFlag.d.ts +0 -8
  128. package/dist/esm/plot/edit/EditFlag.js +0 -121
  129. package/dist/esm/plot/edit/EditFormation.d.ts +0 -8
  130. package/dist/esm/plot/edit/EditFormation.js +0 -120
  131. package/dist/esm/plot/edit/EditLabel.d.ts +0 -7
  132. package/dist/esm/plot/edit/EditLabel.js +0 -100
  133. package/dist/esm/plot/edit/EditLineArrow.d.ts +0 -8
  134. package/dist/esm/plot/edit/EditLineArrow.js +0 -180
  135. package/dist/esm/plot/edit/EditPincerArrow.d.ts +0 -8
  136. package/dist/esm/plot/edit/EditPincerArrow.js +0 -121
  137. package/dist/esm/plot/edit/EditPoint.d.ts +0 -7
  138. package/dist/esm/plot/edit/EditPoint.js +0 -70
  139. package/dist/esm/plot/edit/EditPolygon.d.ts +0 -8
  140. package/dist/esm/plot/edit/EditPolygon.js +0 -181
  141. package/dist/esm/plot/edit/EditPolyline.d.ts +0 -8
  142. package/dist/esm/plot/edit/EditPolyline.js +0 -179
  143. package/dist/esm/plot/edit/EditRectangle.d.ts +0 -8
  144. package/dist/esm/plot/edit/EditRectangle.js +0 -119
  145. package/dist/esm/plot/edit/EditRegularPolygon.d.ts +0 -8
  146. package/dist/esm/plot/edit/EditRegularPolygon.js +0 -170
  147. package/dist/esm/plot/edit/EditRightAngleArrow.d.ts +0 -8
  148. package/dist/esm/plot/edit/EditRightAngleArrow.js +0 -143
  149. package/dist/esm/plot/edit/EditRoundRectangle.d.ts +0 -8
  150. package/dist/esm/plot/edit/EditRoundRectangle.js +0 -119
  151. package/dist/esm/plot/edit/EditSector.d.ts +0 -8
  152. package/dist/esm/plot/edit/EditSector.js +0 -120
  153. package/dist/esm/plot/edit/EditStraightArrow.d.ts +0 -8
  154. package/dist/esm/plot/edit/EditStraightArrow.js +0 -120
  155. package/dist/esm/plot/edit/EditSwallowtailArrow.d.ts +0 -8
  156. package/dist/esm/plot/edit/EditSwallowtailArrow.js +0 -121
  157. package/dist/esm/plot/edit/index.d.ts +0 -23
  158. package/dist/esm/plot/edit/index.js +0 -23
  159. package/dist/esm/plot/utils/DomUtil.d.ts +0 -34
  160. package/dist/esm/plot/utils/DomUtil.js +0 -100
  161. package/dist/esm/plot/utils/PlotCommon.d.ts +0 -101
  162. package/dist/esm/plot/utils/ReminderTip.d.ts +0 -10
  163. package/dist/esm/plot/utils/ReminderTip.js +0 -67
  164. package/dist/esm/plot/utils/Tooltip.d.ts +0 -3
  165. package/dist/esm/plot/utils/Tooltip.js +0 -97
  166. /package/dist/esm/{plot/utils/Algorithm.d.ts → drawer/algorithm.d.ts} +0 -0
  167. /package/dist/esm/{plot/utils/Coordinate.d.ts → drawer/coordinate.d.ts} +0 -0
  168. /package/dist/esm/{plot/utils/Coordinate.js → drawer/coordinate.js} +0 -0
  169. /package/dist/esm/{plot/utils → drawer}/plotUtil.d.ts +0 -0
@@ -1,4 +1,7 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
3
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
4
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
2
5
  function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
3
6
  function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
4
7
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
@@ -8,203 +11,14 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
8
11
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
9
12
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
10
13
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
11
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
12
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
13
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
14
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
15
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
16
14
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
17
15
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
18
16
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
19
17
  import * as Cesium from 'deeptwins-cesium';
20
18
  import { isNil } from 'lodash';
21
- import { v4 as uuidV4 } from 'uuid';
22
- import PositionProperty from "../../property/PositionProperty";
23
- import * as utils from "../../tool/utils";
24
19
  import BaseShape from "./BaseShape";
25
-
26
- // 拖动点样式
27
- var DRAG_POINT_STYLE = {
28
- pixelSize: 10,
29
- color: '#ffffff',
30
- outline: true,
31
- outlineColor: '#1890FF',
32
- outlineWidth: 2
33
- };
34
-
35
- // 临时拖动点样式
36
- var TEMP_DRAG_POINT_STYLE = {
37
- pixelSize: 10,
38
- color: '#1890FF',
39
- outline: true,
40
- outlineColor: '#ffffff',
41
- outlineWidth: 2
42
- };
43
-
44
- // 创建可拖动的点
45
- export var DragPoint = /*#__PURE__*/function () {
46
- /**
47
- * 构造函数,用于创建一个地图元素实例
48
- * @param map 地图对象,包含地图上下文信息
49
- * @param options 配置选项对象
50
- * @param options.positions 点的坐标位置数组
51
- * @param options.style 样式配置
52
- * @param options.isMiddlePoint 是否为中间点的标识,默认为false
53
- */
54
- function DragPoint(map, _ref) {
55
- var positions = _ref.positions,
56
- style = _ref.style,
57
- _ref$isMiddlePoint = _ref.isMiddlePoint,
58
- isMiddlePoint = _ref$isMiddlePoint === void 0 ? false : _ref$isMiddlePoint;
59
- _classCallCheck(this, DragPoint);
60
- _defineProperty(this, "_mapContext", void 0);
61
- _defineProperty(this, "id", '');
62
- _defineProperty(this, "layer", void 0);
63
- // 是否编辑中
64
- _defineProperty(this, "isEditing", false);
65
- // 是否是中间点
66
- _defineProperty(this, "isMiddlePoint", false);
67
- _defineProperty(this, "isDestroyed", false);
68
- _defineProperty(this, "labelLayer", void 0);
69
- _defineProperty(this, "_geoJson", void 0);
70
- _defineProperty(this, "_style", void 0);
71
- this._mapContext = map._mapContext;
72
- this.id = uuidV4();
73
- this.isMiddlePoint = isMiddlePoint;
74
- this._geoJson = {
75
- type: 'Feature',
76
- geometry: {
77
- type: 'Point',
78
- coordinates: positions
79
- }
80
- };
81
- this._style = style;
82
- this._create();
83
- }
84
- _createClass(DragPoint, [{
85
- key: "getMap",
86
- value: function getMap() {
87
- return this._mapContext && this._mapContext.getMap();
88
- }
89
-
90
- // 是否能进行操作
91
- }, {
92
- key: "_canOperate",
93
- value: function _canOperate() {
94
- if (this.isDestroyed) {
95
- utils.error('DragPoint实例已销毁');
96
- return false;
97
- }
98
- return true;
99
- }
100
-
101
- // 创建
102
- }, {
103
- key: "_create",
104
- value: function _create() {
105
- if (!this._canOperate()) return;
106
- this.layer = this.getMap().addGraphicLayer(this._geoJson, {
107
- type: 'point',
108
- id: this.id,
109
- style: _objectSpread(_objectSpread({}, this._style), {}, {
110
- disableDepthTestDistance: Number.POSITIVE_INFINITY
111
- }),
112
- positionProperty: new PositionProperty()
113
- });
114
- if (!this.isMiddlePoint) {
115
- this._createLabel();
116
- }
117
- }
118
-
119
- // 创建label
120
- }, {
121
- key: "_createLabel",
122
- value: function _createLabel() {
123
- this.labelLayer = this.getMap().addGraphicLayer(this._geoJson, {
124
- type: 'label',
125
- style: {
126
- text: '',
127
- font: 'bold 16px Arial',
128
- style: Cesium.LabelStyle.FILL_AND_OUTLINE,
129
- outlineWidth: 4,
130
- eyeOffset: [-20, 0, 0],
131
- horizontalOrigin: Cesium.HorizontalOrigin.RIGHT,
132
- heightReference: Cesium.HeightReference.NONE,
133
- disableDepthTestDistance: Number.POSITIVE_INFINITY,
134
- show: false
135
- },
136
- positionProperty: new PositionProperty()
137
- });
138
- }
139
-
140
- // 开始编辑
141
- }, {
142
- key: "startEdit",
143
- value: function startEdit() {
144
- if (!this._canOperate()) return;
145
- this.isEditing = true;
146
- this.layer && this.layer.setStyle(this.isMiddlePoint ? TEMP_DRAG_POINT_STYLE : DRAG_POINT_STYLE);
147
- }
148
-
149
- // 开始鼠标拖拽
150
- }, {
151
- key: "mouseDragStart",
152
- value: function mouseDragStart() {
153
- if (this.isMiddlePoint) {
154
- this.isMiddlePoint = false;
155
- this.layer && this.layer.setStyle(DRAG_POINT_STYLE);
156
- this._createLabel();
157
- }
158
- }
159
-
160
- // 鼠标拖拽
161
- }, {
162
- key: "mouseDragChange",
163
- value: function mouseDragChange(position) {
164
- if (!this._canOperate()) return;
165
- if (this.layer && position) {
166
- var lng = position.lng,
167
- lat = position.lat,
168
- alt = position.alt;
169
- this._geoJson.geometry.coordinates = [lng, lat, alt];
170
- this.layer.setData(this._geoJson);
171
- this.labelLayer && this.labelLayer.setData(this._geoJson);
172
- }
173
- }
174
-
175
- // 结束编辑
176
- }, {
177
- key: "endEdit",
178
- value: function endEdit() {
179
- if (!this._canOperate()) return;
180
- if (this.layer) {
181
- this.isEditing = false;
182
- this.layer.setStyle(this._style);
183
- }
184
- }
185
-
186
- // 隐藏
187
- }, {
188
- key: "show",
189
- value: function show(isShow) {
190
- if (!this._canOperate()) return;
191
- this.layer && this.layer.show(isShow);
192
- }
193
-
194
- // 销毁
195
- }, {
196
- key: "destroy",
197
- value: function destroy() {
198
- if (!this._canOperate()) return;
199
- this.isDestroyed = true;
200
- this.layer && this.layer.remove();
201
- this.layer = null;
202
- this.labelLayer && this.labelLayer.remove();
203
- this.labelLayer = null;
204
- }
205
- }]);
206
- return DragPoint;
207
- }();
20
+ import DragPoint from "./DragPoint";
21
+ export { default as DragPoint } from "./DragPoint";
208
22
  var Point = /*#__PURE__*/function (_BaseShape) {
209
23
  _inherits(Point, _BaseShape);
210
24
  var _super = _createSuper(Point);
@@ -299,7 +113,8 @@ var Point = /*#__PURE__*/function (_BaseShape) {
299
113
  }, {
300
114
  key: "endEdit",
301
115
  value: function endEdit(layer) {
302
- _get(_getPrototypeOf(Point.prototype), "endEdit", this).call(this, layer);
116
+ var emitComplete = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
117
+ _get(_getPrototypeOf(Point.prototype), "endEdit", this).call(this, layer, emitComplete);
303
118
  this.dragPoints[0] && this.dragPoints[0].endEdit();
304
119
  }
305
120
 
@@ -308,15 +123,6 @@ var Point = /*#__PURE__*/function (_BaseShape) {
308
123
  key: "destroy",
309
124
  value: function destroy() {
310
125
  _get(_getPrototypeOf(Point.prototype), "destroy", this).call(this);
311
- this.dragPoints.forEach(function (t) {
312
- return t.destroy();
313
- });
314
- this.dragPoints = [];
315
- this.edges.forEach(function (t) {
316
- return t.middlePoint.destroy();
317
- });
318
- this.edges = [];
319
- this.shapePointLayer && this.shapePointLayer.destroy();
320
126
  this.shapePointLayer = null;
321
127
  }
322
128
  }]);
@@ -38,7 +38,7 @@ declare class Polygon extends BaseShape {
38
38
  mouseDragStart(position: any, dragLayer: any): void;
39
39
  mouseDragChange(position: any): void;
40
40
  mouseDragEnd(): void;
41
- endEdit(layer: any): void;
41
+ endEdit(layer: any, emitComplete?: boolean): void;
42
42
  destroy(): void;
43
43
  }
44
44
  export default Polygon;
@@ -25,9 +25,9 @@ import { isNil } from 'lodash';
25
25
  import { v4 as uuidV4 } from 'uuid';
26
26
  import PositionProperty from "../../property/PositionProperty";
27
27
  import * as utils from "../../tool/utils";
28
- import { STATUS } from "../index";
28
+ import { STATUS } from "../types";
29
29
  import BaseShape from "./BaseShape";
30
- import { DragPoint } from "./Point";
30
+ import DragPoint from "./DragPoint";
31
31
  import { ShapePolyline } from "./Polyline";
32
32
 
33
33
  // 创建形状面
@@ -295,6 +295,7 @@ var Polygon = /*#__PURE__*/function (_BaseShape) {
295
295
  key: "endDraw",
296
296
  value: function endDraw() {
297
297
  var _this$shapePolylineLa4, _this$shapePolygonLay4;
298
+ if (this.positions.length < 3) return;
298
299
  this._tempPosition = null;
299
300
  (_this$shapePolylineLa4 = this.shapePolylineLayer) === null || _this$shapePolylineLa4 === void 0 || _this$shapePolylineLa4.update(this._getDrawPolylinePositions());
300
301
  (_this$shapePolygonLay4 = this.shapePolygonLayer) === null || _this$shapePolygonLay4 === void 0 || _this$shapePolygonLay4.update(this._getDrawPolygonPositions());
@@ -309,63 +310,14 @@ var Polygon = /*#__PURE__*/function (_BaseShape) {
309
310
  key: "startEdit",
310
311
  value: function startEdit() {
311
312
  _get(_getPrototypeOf(Polygon.prototype), "startEdit", this).call(this);
312
- this.edges = [];
313
- this.edges = this._createEdgesAndMiddle(this.dragPoints, true);
313
+ this._startEdgeEditing(true);
314
314
  }
315
315
 
316
316
  // 开始鼠标拖拽
317
317
  }, {
318
318
  key: "mouseDragStart",
319
319
  value: function mouseDragStart(position, dragLayer) {
320
- var _this3 = this;
321
- this.dragging = true;
322
- this.dragLayer = dragLayer;
323
- if (this.dragLayer.isMiddlePoint) {
324
- // 找到相应有关系的边
325
- var changeEdges = this.edges.filter(function (t) {
326
- return t.middlePoint.id === _this3.dragLayer.id;
327
- });
328
- this.edges = this.edges.filter(function (t) {
329
- return t.middlePoint.id !== _this3.dragLayer.id;
330
- });
331
- var _loop = function _loop() {
332
- var source = changeEdges[i].source;
333
- var target = changeEdges[i].target;
334
- var middlePoint = changeEdges[i].middlePoint;
335
- middlePoint.isStart = false;
336
- _this3.edges.push({
337
- source: source,
338
- target: middlePoint,
339
- middlePoint: null
340
- }, {
341
- source: middlePoint,
342
- target: target,
343
- middlePoint: null
344
- });
345
- var findIndex = _this3.dragPoints.findIndex(function (t) {
346
- return t.id === source.id;
347
- });
348
- if (findIndex > -1) {
349
- _this3.dragPoints.splice(findIndex + 1, 0, middlePoint);
350
- }
351
- };
352
- for (var i = 0; i < changeEdges.length; i++) {
353
- _loop();
354
- }
355
- } else {
356
- // 找到相应有关系的边
357
- var _changeEdges = this.edges.filter(function (t) {
358
- return t.source.id === _this3.dragLayer.id || t.target.id === _this3.dragLayer.id;
359
- });
360
- for (var _i = 0; _i < _changeEdges.length; _i++) {
361
- // 删除中间点
362
- if (_changeEdges[_i].middlePoint) {
363
- _changeEdges[_i].middlePoint.destroy();
364
- _changeEdges[_i].middlePoint = null;
365
- }
366
- }
367
- }
368
- this.dragLayer.mouseDragStart();
320
+ this._handleDragStart(dragLayer);
369
321
  }
370
322
 
371
323
  // 鼠标拖拽
@@ -374,10 +326,7 @@ var Polygon = /*#__PURE__*/function (_BaseShape) {
374
326
  value: function mouseDragChange(position) {
375
327
  var _this$shapePolylineLa5, _this$shapePolygonLay5, _this$_drawContext$op, _this$_drawContext$op2;
376
328
  if (!this.dragging) return;
377
- // 点拖拽
378
- this.dragLayer.mouseDragChange(position);
379
- // 根据edges重新生成新的点位
380
- this.positions = this._updatePositionsFromEdges();
329
+ this.positions = this._handleDragChange(position);
381
330
  (_this$shapePolylineLa5 = this.shapePolylineLayer) === null || _this$shapePolylineLa5 === void 0 || _this$shapePolylineLa5.update(this._getDrawPolylinePositions());
382
331
  (_this$shapePolygonLay5 = this.shapePolygonLayer) === null || _this$shapePolygonLay5 === void 0 || _this$shapePolygonLay5.update(this._getDrawPolygonPositions());
383
332
  // 调用点位改变事件
@@ -391,36 +340,16 @@ var Polygon = /*#__PURE__*/function (_BaseShape) {
391
340
  }, {
392
341
  key: "mouseDragEnd",
393
342
  value: function mouseDragEnd() {
394
- var _this4 = this;
395
- // 找到相应有关系的边
396
- var changeEdges = this.edges.filter(function (t) {
397
- return t.source.id === _this4.dragLayer.id || t.target.id === _this4.dragLayer.id;
398
- });
399
- // 创建中间点
400
- for (var i = 0; i < changeEdges.length; i++) {
401
- var p1 = changeEdges[i].source.layer.layers[0].source.positions;
402
- var p2 = changeEdges[i].target.layer.layers[0].source.positions;
403
- var layer = this._createTwoPointMiddle(utils.getMidpoint(p1, p2));
404
- layer.startEdit();
405
- changeEdges[i].middlePoint = layer;
406
- }
407
- this.dragging = false;
408
- this.dragLayer = null;
343
+ this._handleDragEnd();
409
344
  }
410
345
 
411
346
  // 结束编辑
412
347
  }, {
413
348
  key: "endEdit",
414
349
  value: function endEdit(layer) {
415
- _get(_getPrototypeOf(Polygon.prototype), "endEdit", this).call(this, layer);
416
- this.dragPoints.forEach(function (t) {
417
- t.endEdit();
418
- t.show(false);
419
- });
420
- this.edges.forEach(function (t) {
421
- return t.middlePoint.destroy();
422
- });
423
- this.edges = [];
350
+ var emitComplete = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
351
+ _get(_getPrototypeOf(Polygon.prototype), "endEdit", this).call(this, layer, emitComplete);
352
+ this._stopEdgeEditing();
424
353
  }
425
354
 
426
355
  // 销毁
@@ -36,7 +36,7 @@ declare class Polyline extends BaseShape {
36
36
  mouseDragStart(position: any, dragLayer: any): void;
37
37
  mouseDragChange(position: any): void;
38
38
  mouseDragEnd(): void;
39
- endEdit(layer: any): void;
39
+ endEdit(layer: any, emitComplete?: boolean): void;
40
40
  destroy(): void;
41
41
  }
42
42
  export default Polyline;
@@ -24,9 +24,9 @@ import { isNil } from 'lodash';
24
24
  import { v4 as uuidV4 } from 'uuid';
25
25
  import PositionProperty from "../../property/PositionProperty";
26
26
  import * as utils from "../../tool/utils";
27
- import { STATUS } from "../index";
27
+ import { STATUS } from "../types";
28
28
  import BaseShape from "./BaseShape";
29
- import { DragPoint } from "./Point";
29
+ import DragPoint from "./DragPoint";
30
30
 
31
31
  // 创建形状线
32
32
  export var ShapePolyline = /*#__PURE__*/function () {
@@ -256,6 +256,7 @@ var Polyline = /*#__PURE__*/function (_BaseShape) {
256
256
  key: "endDraw",
257
257
  value: function endDraw() {
258
258
  var _this$shapePolylineLa5;
259
+ if (this.positions.length < 2) return;
259
260
  this._tempPosition = null;
260
261
  (_this$shapePolylineLa5 = this.shapePolylineLayer) === null || _this$shapePolylineLa5 === void 0 || _this$shapePolylineLa5.update(this._getDrawPolylinePositions());
261
262
  // 存入
@@ -269,63 +270,14 @@ var Polyline = /*#__PURE__*/function (_BaseShape) {
269
270
  key: "startEdit",
270
271
  value: function startEdit() {
271
272
  _get(_getPrototypeOf(Polyline.prototype), "startEdit", this).call(this);
272
- this.edges = [];
273
- this.edges = this._createEdgesAndMiddle(this.dragPoints);
273
+ this._startEdgeEditing();
274
274
  }
275
275
 
276
276
  // 开始鼠标拖拽
277
277
  }, {
278
278
  key: "mouseDragStart",
279
279
  value: function mouseDragStart(position, dragLayer) {
280
- var _this3 = this;
281
- this.dragging = true;
282
- this.dragLayer = dragLayer;
283
- if (this.dragLayer.isMiddlePoint) {
284
- // 找到相应有关系的边
285
- var changeEdges = this.edges.filter(function (t) {
286
- return t.middlePoint.id === _this3.dragLayer.id;
287
- });
288
- this.edges = this.edges.filter(function (t) {
289
- return t.middlePoint.id !== _this3.dragLayer.id;
290
- });
291
- var _loop = function _loop() {
292
- var source = changeEdges[i].source;
293
- var target = changeEdges[i].target;
294
- var middlePoint = changeEdges[i].middlePoint;
295
- middlePoint.isStart = false;
296
- _this3.edges.push({
297
- source: source,
298
- target: middlePoint,
299
- middlePoint: null
300
- }, {
301
- source: middlePoint,
302
- target: target,
303
- middlePoint: null
304
- });
305
- var findIndex = _this3.dragPoints.findIndex(function (t) {
306
- return t.id === source.id;
307
- });
308
- if (findIndex > -1) {
309
- _this3.dragPoints.splice(findIndex + 1, 0, middlePoint);
310
- }
311
- };
312
- for (var i = 0; i < changeEdges.length; i++) {
313
- _loop();
314
- }
315
- } else {
316
- // 找到相应有关系的边
317
- var _changeEdges = this.edges.filter(function (t) {
318
- return t.source.id === _this3.dragLayer.id || t.target.id === _this3.dragLayer.id;
319
- });
320
- for (var _i = 0; _i < _changeEdges.length; _i++) {
321
- // 删除中间点
322
- if (_changeEdges[_i].middlePoint) {
323
- _changeEdges[_i].middlePoint.destroy();
324
- _changeEdges[_i].middlePoint = null;
325
- }
326
- }
327
- }
328
- this.dragLayer.mouseDragStart();
280
+ this._handleDragStart(dragLayer);
329
281
  }
330
282
 
331
283
  // 鼠标拖拽
@@ -334,10 +286,7 @@ var Polyline = /*#__PURE__*/function (_BaseShape) {
334
286
  value: function mouseDragChange(position) {
335
287
  var _this$shapePolylineLa6, _this$_drawContext$op, _this$_drawContext$op2;
336
288
  if (!this.dragging) return;
337
- // 点拖拽
338
- this.dragLayer.mouseDragChange(position);
339
- // 根据edges重新生成新的点位
340
- this.positions = this._updatePositionsFromEdges();
289
+ this.positions = this._handleDragChange(position);
341
290
  (_this$shapePolylineLa6 = this.shapePolylineLayer) === null || _this$shapePolylineLa6 === void 0 || _this$shapePolylineLa6.update(this._getDrawPolylinePositions());
342
291
  // 调用点位改变事件
343
292
  ((_this$_drawContext$op = this._drawContext.options) === null || _this$_drawContext$op === void 0 ? void 0 : _this$_drawContext$op.onPointsChange) && ((_this$_drawContext$op2 = this._drawContext.options) === null || _this$_drawContext$op2 === void 0 ? void 0 : _this$_drawContext$op2.onPointsChange({
@@ -350,36 +299,16 @@ var Polyline = /*#__PURE__*/function (_BaseShape) {
350
299
  }, {
351
300
  key: "mouseDragEnd",
352
301
  value: function mouseDragEnd() {
353
- var _this4 = this;
354
- // 找到相应有关系的边
355
- var changeEdges = this.edges.filter(function (t) {
356
- return t.source.id === _this4.dragLayer.id || t.target.id === _this4.dragLayer.id;
357
- });
358
- // 创建中间点
359
- for (var i = 0; i < changeEdges.length; i++) {
360
- var p1 = changeEdges[i].source.layer.layers[0].source.positions;
361
- var p2 = changeEdges[i].target.layer.layers[0].source.positions;
362
- var layer = this._createTwoPointMiddle(utils.getMidpoint(p1, p2));
363
- layer.startEdit();
364
- changeEdges[i].middlePoint = layer;
365
- }
366
- this.dragging = false;
367
- this.dragLayer = null;
302
+ this._handleDragEnd();
368
303
  }
369
304
 
370
305
  // 结束编辑
371
306
  }, {
372
307
  key: "endEdit",
373
308
  value: function endEdit(layer) {
374
- _get(_getPrototypeOf(Polyline.prototype), "endEdit", this).call(this, layer);
375
- this.dragPoints.forEach(function (t) {
376
- t.endEdit();
377
- t.show(false);
378
- });
379
- this.edges.forEach(function (t) {
380
- return t.middlePoint.destroy();
381
- });
382
- this.edges = [];
309
+ var emitComplete = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
310
+ _get(_getPrototypeOf(Polyline.prototype), "endEdit", this).call(this, layer, emitComplete);
311
+ this._stopEdgeEditing();
383
312
  }
384
313
 
385
314
  // 销毁
@@ -0,0 +1,37 @@
1
+ import BaseShape from './BaseShape';
2
+ declare class RegularPolygon extends BaseShape {
3
+ readonly type: string;
4
+ shapePolylineLayer: any;
5
+ shapePolygonLayer: any;
6
+ private _sides;
7
+ private _centerPosition;
8
+ private _handlePosition;
9
+ constructor(drawContext: any, config: any);
10
+ private _normalizeSides;
11
+ private _toPositionTuple;
12
+ private _getDrawPolylinePositions;
13
+ private _getDrawPolygonPositions;
14
+ private _destroyShapeLayers;
15
+ private _syncShapeLayers;
16
+ private _buildRegularPolygonPositions;
17
+ private _getLocalHandleVector;
18
+ private _getPositionByLocalVector;
19
+ private _applyGeometry;
20
+ private _destroyEditHandles;
21
+ private _createEditHandle;
22
+ private _syncEditHandles;
23
+ private _emitMouseMoveChange;
24
+ private _emitPointsChange;
25
+ private _finishDraw;
26
+ transformData(positions: any[], config?: any): boolean;
27
+ addPoint(position: any): void;
28
+ updateTempPosition(position: any): void;
29
+ endDraw(): void;
30
+ startEdit(): void;
31
+ mouseDragStart(position: any, dragLayer: any): void;
32
+ mouseDragChange(position: any): void;
33
+ mouseDragEnd(): void;
34
+ endEdit(layer: any, emitComplete?: boolean): void;
35
+ destroy(): void;
36
+ }
37
+ export default RegularPolygon;