@inweb/client 25.2.2 → 25.2.5

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 (222) hide show
  1. package/LICENSE +20 -20
  2. package/README.md +70 -70
  3. package/dist/client.js +12739 -12352
  4. package/dist/client.js.map +1 -1
  5. package/dist/client.min.js +1 -1
  6. package/dist/client.module.js +588 -157
  7. package/dist/client.module.js.map +1 -1
  8. package/lib/Api/Assembly.d.ts +338 -338
  9. package/lib/Api/ClashTest.d.ts +175 -175
  10. package/lib/Api/Client.d.ts +451 -451
  11. package/lib/Api/ClientEvents.d.ts +28 -28
  12. package/lib/Api/File.d.ts +567 -567
  13. package/lib/Api/HttpClient.d.ts +12 -12
  14. package/lib/Api/IAssembly.d.ts +13 -13
  15. package/lib/Api/IFile.d.ts +45 -45
  16. package/lib/Api/IHttpClient.d.ts +10 -10
  17. package/lib/Api/IUser.d.ts +10 -10
  18. package/lib/Api/Job.d.ts +141 -141
  19. package/lib/Api/Member.d.ts +84 -84
  20. package/lib/Api/Model.d.ts +146 -146
  21. package/lib/Api/Permission.d.ts +92 -92
  22. package/lib/Api/Project.d.ts +246 -246
  23. package/lib/Api/Role.d.ts +81 -81
  24. package/lib/Api/User.d.ts +196 -196
  25. package/lib/Api/impl/FetchError.d.ts +17 -17
  26. package/lib/Api/impl/Utils.d.ts +32 -32
  27. package/lib/Api/impl/http.d.ts +66 -66
  28. package/lib/ConvetMath.d.ts +28 -28
  29. package/lib/Viewer/CanvasEvents.d.ts +1 -1
  30. package/lib/Viewer/Commands/ApplyModelTransform.d.ts +1 -1
  31. package/lib/Viewer/Commands/ClearMarkup.d.ts +1 -1
  32. package/lib/Viewer/Commands/ClearSlices.d.ts +1 -1
  33. package/lib/Viewer/Commands/CreatePreview.d.ts +1 -1
  34. package/lib/Viewer/Commands/Explode.d.ts +1 -1
  35. package/lib/Viewer/Commands/GetDefaultViewPositions.d.ts +1 -1
  36. package/lib/Viewer/Commands/GetModels.d.ts +1 -1
  37. package/lib/Viewer/Commands/GetSelected.d.ts +1 -1
  38. package/lib/Viewer/Commands/HideSelected.d.ts +1 -1
  39. package/lib/Viewer/Commands/IsolateSelected.d.ts +1 -1
  40. package/lib/Viewer/Commands/RegenerateAll.d.ts +1 -1
  41. package/lib/Viewer/Commands/ResetView.d.ts +1 -1
  42. package/lib/Viewer/Commands/SelectModel.d.ts +1 -1
  43. package/lib/Viewer/Commands/SetActiveDragger.d.ts +1 -1
  44. package/lib/Viewer/Commands/SetDefaultViewPosition.d.ts +1 -1
  45. package/lib/Viewer/Commands/SetMarkupColor.d.ts +1 -1
  46. package/lib/Viewer/Commands/SetSelected.d.ts +1 -1
  47. package/lib/Viewer/Commands/ShowAll.d.ts +1 -1
  48. package/lib/Viewer/Commands/Unselect.d.ts +1 -1
  49. package/lib/Viewer/Commands/ZoomToExtents.d.ts +1 -1
  50. package/lib/Viewer/Commands/ZoomToObjects.d.ts +1 -1
  51. package/lib/Viewer/Commands/ZoomToSelected.d.ts +1 -1
  52. package/lib/Viewer/Commands.d.ts +2 -2
  53. package/lib/Viewer/Draggers/Actions/OrbitAction.d.ts +21 -21
  54. package/lib/Viewer/Draggers/Actions/PanAction.d.ts +17 -17
  55. package/lib/Viewer/Draggers/Actions/ZoomAction.d.ts +7 -7
  56. package/lib/Viewer/Draggers/Common/Geometry.d.ts +114 -114
  57. package/lib/Viewer/Draggers/Common/GestureManager.d.ts +40 -40
  58. package/lib/Viewer/Draggers/Common/OdBaseDragger.d.ts +53 -53
  59. package/lib/Viewer/Draggers/Common/OdaGeAction.d.ts +29 -29
  60. package/lib/Viewer/Draggers/MeasureLineDragger/MeasureLineItem.d.ts +30 -30
  61. package/lib/Viewer/Draggers/MeasureLineDragger/MeasureUtils.d.ts +19 -19
  62. package/lib/Viewer/Draggers/MeasureLineDragger/index.d.ts +23 -23
  63. package/lib/Viewer/Draggers/OdBaseCuttingPlaneDragger.d.ts +26 -26
  64. package/lib/Viewer/Draggers/OdCuttingPlaneXAxisDragger.d.ts +7 -7
  65. package/lib/Viewer/Draggers/OdCuttingPlaneYAxisDragger.d.ts +7 -7
  66. package/lib/Viewer/Draggers/OdCuttingPlaneZAxisDragger.d.ts +7 -7
  67. package/lib/Viewer/Draggers/OdOrbitDragger.d.ts +14 -14
  68. package/lib/Viewer/Draggers/OdPanDragger.d.ts +11 -11
  69. package/lib/Viewer/Draggers/OdZoomDragger.d.ts +11 -11
  70. package/lib/Viewer/Draggers/OdZoomWheelDragger.d.ts +10 -10
  71. package/lib/Viewer/Draggers/OdZoomWindowDragger/OdSelectionFrame.d.ts +18 -18
  72. package/lib/Viewer/Draggers/OdZoomWindowDragger/index.d.ts +13 -13
  73. package/lib/Viewer/Draggers/OdaLineDragger.d.ts +14 -14
  74. package/lib/Viewer/Draggers/OdaTextDragger.d.ts +15 -15
  75. package/lib/Viewer/Draggers/OdaWalkDragger.d.ts +29 -29
  76. package/lib/Viewer/Draggers/OrbitAroundBuildingDragger.d.ts +18 -18
  77. package/lib/Viewer/EventEmitter2.d.ts +53 -53
  78. package/lib/Viewer/ICommands.d.ts +24 -24
  79. package/lib/Viewer/IEventEmitter2.d.ts +12 -12
  80. package/lib/Viewer/IViewer.d.ts +26 -26
  81. package/lib/Viewer/Loaders/BaseLoader.d.ts +10 -10
  82. package/lib/Viewer/Loaders/LoaderFactory.d.ts +9 -9
  83. package/lib/Viewer/Loaders/TCSLoader.d.ts +4 -4
  84. package/lib/Viewer/Loaders/UpdaterController.d.ts +14 -14
  85. package/lib/Viewer/Loaders/VsfXLoader.d.ts +4 -4
  86. package/lib/Viewer/Loaders/VsfXPartialLoader.d.ts +4 -4
  87. package/lib/Viewer/Markup/Api/IMarkupArrow.d.ts +21 -11
  88. package/lib/Viewer/Markup/Api/IMarkupCloud.d.ts +15 -0
  89. package/lib/Viewer/Markup/Api/IMarkupColorable.d.ts +4 -4
  90. package/lib/Viewer/Markup/Api/IMarkupEllipse.d.ts +14 -14
  91. package/lib/Viewer/Markup/Api/IMarkupImage.d.ts +14 -14
  92. package/lib/Viewer/Markup/Api/IMarkupLine.d.ts +18 -10
  93. package/lib/Viewer/Markup/Api/IMarkupObject.d.ts +11 -11
  94. package/lib/Viewer/Markup/Api/IMarkupRectangle.d.ts +14 -14
  95. package/lib/Viewer/Markup/Api/IMarkupText.d.ts +12 -12
  96. package/lib/Viewer/Markup/Api/Impl/Konva/KonvaArrow.d.ts +46 -31
  97. package/lib/Viewer/Markup/Api/Impl/Konva/KonvaCloud.d.ts +36 -0
  98. package/lib/Viewer/Markup/Api/Impl/Konva/KonvaEllipse.d.ts +40 -39
  99. package/lib/Viewer/Markup/Api/Impl/Konva/KonvaImage.d.ts +36 -35
  100. package/lib/Viewer/Markup/Api/Impl/Konva/KonvaLine.d.ts +35 -31
  101. package/lib/Viewer/Markup/Api/Impl/Konva/KonvaRectangle.d.ts +38 -37
  102. package/lib/Viewer/Markup/Api/Impl/Konva/KonvaText.d.ts +37 -36
  103. package/lib/Viewer/Markup/IMarkup.d.ts +38 -37
  104. package/lib/Viewer/Markup/Impl/Konva/KonvaMarkup.d.ts +71 -62
  105. package/lib/Viewer/Markup/Impl/Konva/MarkupColor.d.ts +18 -18
  106. package/lib/Viewer/Markup/Impl/Visualize/VisualizeMarkup.d.ts +32 -32
  107. package/lib/Viewer/Markup/MarkupFactory.d.ts +6 -6
  108. package/lib/Viewer/Options.d.ts +227 -227
  109. package/lib/Viewer/OptionsEvents.d.ts +25 -25
  110. package/lib/Viewer/Viewer.d.ts +352 -352
  111. package/lib/Viewer/ViewerCommands.d.ts +22 -22
  112. package/lib/Viewer/ViewerEvents.d.ts +600 -600
  113. package/lib/Viewer/utils.d.ts +3 -3
  114. package/lib/index.d.ts +23 -23
  115. package/package.json +38 -32
  116. package/src/Api/Assembly.ts +678 -678
  117. package/src/Api/ClashTest.ts +290 -290
  118. package/src/Api/Client.ts +816 -816
  119. package/src/Api/ClientEvents.ts +31 -31
  120. package/src/Api/File.ts +962 -962
  121. package/src/Api/HttpClient.ts +73 -73
  122. package/src/Api/IAssembly.ts +37 -37
  123. package/src/Api/IFile.ts +74 -74
  124. package/src/Api/IHttpClient.ts +50 -50
  125. package/src/Api/IUser.ts +33 -33
  126. package/src/Api/Job.ts +253 -253
  127. package/src/Api/Member.ts +161 -161
  128. package/src/Api/Model.ts +259 -259
  129. package/src/Api/Permission.ts +173 -173
  130. package/src/Api/Project.ts +479 -479
  131. package/src/Api/Role.ts +158 -158
  132. package/src/Api/User.ts +357 -357
  133. package/src/Api/impl/FetchError.ts +48 -48
  134. package/src/Api/impl/Utils.ts +367 -367
  135. package/src/Api/impl/http.ts +92 -92
  136. package/src/ConvetMath.ts +372 -372
  137. package/src/Viewer/CanvasEvents.ts +41 -41
  138. package/src/Viewer/Commands/ApplyModelTransform.ts +70 -70
  139. package/src/Viewer/Commands/ClearMarkup.ts +28 -28
  140. package/src/Viewer/Commands/ClearSlices.ts +27 -27
  141. package/src/Viewer/Commands/CreatePreview.ts +33 -33
  142. package/src/Viewer/Commands/Explode.ts +38 -38
  143. package/src/Viewer/Commands/GetDefaultViewPositions.ts +36 -36
  144. package/src/Viewer/Commands/GetModels.ts +43 -43
  145. package/src/Viewer/Commands/GetSelected.ts +58 -58
  146. package/src/Viewer/Commands/HideSelected.ts +37 -37
  147. package/src/Viewer/Commands/IsolateSelected.ts +37 -37
  148. package/src/Viewer/Commands/RegenerateAll.ts +37 -37
  149. package/src/Viewer/Commands/ResetView.ts +43 -43
  150. package/src/Viewer/Commands/SelectModel.ts +52 -52
  151. package/src/Viewer/Commands/SetActiveDragger.ts +29 -29
  152. package/src/Viewer/Commands/SetDefaultViewPosition.ts +50 -50
  153. package/src/Viewer/Commands/SetMarkupColor.ts +29 -29
  154. package/src/Viewer/Commands/SetSelected.ts +47 -47
  155. package/src/Viewer/Commands/ShowAll.ts +37 -37
  156. package/src/Viewer/Commands/Unselect.ts +37 -37
  157. package/src/Viewer/Commands/ZoomToExtents.ts +43 -43
  158. package/src/Viewer/Commands/ZoomToObjects.ts +47 -47
  159. package/src/Viewer/Commands/ZoomToSelected.ts +39 -39
  160. package/src/Viewer/Commands.ts +81 -81
  161. package/src/Viewer/Draggers/Actions/OrbitAction.ts +250 -250
  162. package/src/Viewer/Draggers/Actions/PanAction.ts +102 -102
  163. package/src/Viewer/Draggers/Actions/ZoomAction.ts +45 -45
  164. package/src/Viewer/Draggers/Common/Geometry.ts +152 -152
  165. package/src/Viewer/Draggers/Common/GestureManager.ts +263 -263
  166. package/src/Viewer/Draggers/Common/OdBaseDragger.ts +270 -270
  167. package/src/Viewer/Draggers/Common/OdaGeAction.ts +146 -146
  168. package/src/Viewer/Draggers/MeasureLineDragger/MeasureLineItem.ts +248 -248
  169. package/src/Viewer/Draggers/MeasureLineDragger/MeasureUtils.ts +182 -182
  170. package/src/Viewer/Draggers/MeasureLineDragger/index.ts +166 -166
  171. package/src/Viewer/Draggers/OdBaseCuttingPlaneDragger.ts +182 -182
  172. package/src/Viewer/Draggers/OdCuttingPlaneXAxisDragger.ts +53 -53
  173. package/src/Viewer/Draggers/OdCuttingPlaneYAxisDragger.ts +53 -53
  174. package/src/Viewer/Draggers/OdCuttingPlaneZAxisDragger.ts +53 -53
  175. package/src/Viewer/Draggers/OdOrbitDragger.ts +70 -70
  176. package/src/Viewer/Draggers/OdPanDragger.ts +62 -62
  177. package/src/Viewer/Draggers/OdZoomDragger.ts +59 -59
  178. package/src/Viewer/Draggers/OdZoomWheelDragger.ts +103 -103
  179. package/src/Viewer/Draggers/OdZoomWindowDragger/OdSelectionFrame.ts +123 -123
  180. package/src/Viewer/Draggers/OdZoomWindowDragger/index.ts +75 -75
  181. package/src/Viewer/Draggers/OdaLineDragger.ts +80 -80
  182. package/src/Viewer/Draggers/OdaTextDragger.ts +118 -118
  183. package/src/Viewer/Draggers/OdaWalkDragger.ts +278 -278
  184. package/src/Viewer/Draggers/OrbitAroundBuildingDragger.ts +184 -184
  185. package/src/Viewer/EventEmitter2.ts +116 -116
  186. package/src/Viewer/ICommands.ts +53 -53
  187. package/src/Viewer/IEventEmitter2.ts +36 -36
  188. package/src/Viewer/IViewer.ts +55 -55
  189. package/src/Viewer/Loaders/BaseLoader.ts +40 -40
  190. package/src/Viewer/Loaders/LoaderFactory.ts +44 -44
  191. package/src/Viewer/Loaders/TCSLoader.ts +82 -82
  192. package/src/Viewer/Loaders/UpdaterController.ts +36 -36
  193. package/src/Viewer/Loaders/VsfXLoader.ts +87 -87
  194. package/src/Viewer/Loaders/VsfXPartialLoader.ts +208 -208
  195. package/src/Viewer/Markup/Api/IMarkupArrow.ts +12 -15
  196. package/src/Viewer/Markup/Api/IMarkupCloud.ts +15 -0
  197. package/src/Viewer/Markup/Api/IMarkupColorable.ts +4 -4
  198. package/src/Viewer/Markup/Api/IMarkupEllipse.ts +15 -15
  199. package/src/Viewer/Markup/Api/IMarkupImage.ts +15 -15
  200. package/src/Viewer/Markup/Api/IMarkupLine.ts +20 -10
  201. package/src/Viewer/Markup/Api/IMarkupObject.ts +15 -15
  202. package/src/Viewer/Markup/Api/IMarkupRectangle.ts +15 -15
  203. package/src/Viewer/Markup/Api/IMarkupText.ts +12 -12
  204. package/src/Viewer/Markup/Api/Impl/Konva/KonvaArrow.ts +117 -119
  205. package/src/Viewer/Markup/Api/Impl/Konva/KonvaCloud.ts +208 -0
  206. package/src/Viewer/Markup/Api/Impl/Konva/KonvaEllipse.ts +118 -113
  207. package/src/Viewer/Markup/Api/Impl/Konva/KonvaImage.ts +123 -121
  208. package/src/Viewer/Markup/Api/Impl/Konva/KonvaLine.ts +130 -99
  209. package/src/Viewer/Markup/Api/Impl/Konva/KonvaRectangle.ts +119 -113
  210. package/src/Viewer/Markup/Api/Impl/Konva/KonvaText.ts +110 -104
  211. package/src/Viewer/Markup/IMarkup.ts +40 -39
  212. package/src/Viewer/Markup/Impl/Konva/KonvaMarkup.ts +1208 -872
  213. package/src/Viewer/Markup/Impl/Konva/MarkupColor.ts +39 -39
  214. package/src/Viewer/Markup/Impl/Visualize/VisualizeMarkup.ts +273 -273
  215. package/src/Viewer/Markup/MarkupFactory.ts +32 -32
  216. package/src/Viewer/Options.ts +502 -502
  217. package/src/Viewer/OptionsEvents.ts +28 -28
  218. package/src/Viewer/Viewer.ts +1109 -1109
  219. package/src/Viewer/ViewerCommands.ts +45 -45
  220. package/src/Viewer/ViewerEvents.ts +700 -700
  221. package/src/Viewer/utils.ts +74 -74
  222. package/src/index.ts +48 -48
@@ -1,119 +1,117 @@
1
- import Konva from "konva";
2
- import { IMarkupArrow } from "../../IMarkupArrow";
3
- import { IMarkupColorable } from "../../IMarkupColorable";
4
-
5
- export class KonvaArrow implements IMarkupArrow, IMarkupColorable {
6
- private _ref: Konva.Arrow;
7
-
8
- constructor(
9
- params: {
10
- points: [];
11
- pointerWidth: number;
12
- pointerLength: number;
13
- color: string;
14
- lineWidth: number;
15
- },
16
- ref = null
17
- ) {
18
- if (ref) {
19
- this._ref = ref;
20
- this._ref.id(this._ref._id.toString());
21
- return;
22
- }
23
-
24
- if (!params.points) return;
25
-
26
- this._ref = new Konva.Arrow({
27
- stroke: params.color ?? "#ff0000",
28
- fill: params.color ?? "#ff0000",
29
- strokeWidth: params.lineWidth ?? 4,
30
- globalCompositeOperation: "source-over",
31
- lineCap: "round",
32
- lineJoin: "round",
33
- points: params.points,
34
- pointerWidth: params.pointerWidth,
35
- pointerLength: params.pointerLength,
36
- draggable: true,
37
- strokeScaleEnabled: false,
38
- });
39
-
40
- this._ref.id(this._ref._id.toString());
41
- }
42
-
43
- ref() {
44
- return this._ref;
45
- }
46
-
47
- id(): string {
48
- return this._ref.id();
49
- }
50
-
51
- enableMouseEditing(value: boolean) {
52
- this._ref.draggable(value);
53
- }
54
-
55
- type(): string {
56
- return "arrow";
57
- }
58
-
59
- getColor(): string {
60
- return this._ref.stroke();
61
- }
62
-
63
- setColor(hex: string) {
64
- this._ref.stroke(hex);
65
- }
66
-
67
- getRotation(): number {
68
- return this._ref.rotation();
69
- }
70
-
71
- setRotation(degrees: number): void {
72
- this._ref.rotation(degrees);
73
- }
74
-
75
- getZIndex(): number {
76
- return this._ref.zIndex();
77
- }
78
-
79
- setZIndex(zIndex: number): void {
80
- this._ref.zIndex(zIndex);
81
- }
82
-
83
- delete() {
84
- this._ref.destroy();
85
- this._ref = null;
86
- }
87
-
88
- getPoints(): number[] {
89
- return this._ref.attrs.points;
90
- }
91
-
92
- setPoints(points: number[]) {
93
- this._ref.points(points);
94
- }
95
-
96
- getPointerWidth(): number {
97
- return this._ref.pointerWidth();
98
- }
99
-
100
- setPointerWidth(w: number) {
101
- this._ref.pointerWidth(w);
102
- }
103
-
104
- getPointerLength(): number {
105
- return this._ref.pointerLength();
106
- }
107
-
108
- setPointerLength(l: number) {
109
- this._ref.pointerLength(l);
110
- }
111
-
112
- getLineWidth(): number {
113
- return this._ref.strokeWidth();
114
- }
115
-
116
- setLineWidth(size: number) {
117
- this._ref.strokeWidth(size);
118
- }
119
- }
1
+ import Konva from "konva";
2
+ import { IMarkupArrow } from "../../IMarkupArrow";
3
+ import { IMarkupColorable } from "../../IMarkupColorable";
4
+
5
+ export class KonvaArrow implements IMarkupArrow, IMarkupColorable {
6
+ private _ref: Konva.Arrow;
7
+
8
+ constructor(
9
+ params: {
10
+ start: { x: number; y: number };
11
+ end: { x: number; y: number };
12
+ color?: string;
13
+ id?: string;
14
+ },
15
+ ref = null
16
+ ) {
17
+ if (ref) {
18
+ this._ref = ref;
19
+ return;
20
+ }
21
+
22
+ if (!params.start || !params.end) return;
23
+
24
+ this._ref = new Konva.Arrow({
25
+ stroke: params.color ?? "#ff0000",
26
+ fill: params.color ?? "#ff0000",
27
+ strokeWidth: 4,
28
+ globalCompositeOperation: "source-over",
29
+ lineCap: "round",
30
+ lineJoin: "round",
31
+ points: [params.start.x, params.start.y, params.end.x, params.end.y],
32
+ draggable: true,
33
+ strokeScaleEnabled: false,
34
+ });
35
+
36
+ this._ref.id(this._ref._id.toString());
37
+ }
38
+
39
+ ref() {
40
+ return this._ref;
41
+ }
42
+
43
+ id(): string {
44
+ return this._ref.id();
45
+ }
46
+
47
+ enableMouseEditing(value: boolean) {
48
+ this._ref.draggable(value);
49
+ }
50
+
51
+ type(): string {
52
+ return "arrow";
53
+ }
54
+
55
+ getColor(): string {
56
+ return this._ref.stroke();
57
+ }
58
+
59
+ setColor(hex: string) {
60
+ this._ref.stroke(hex);
61
+ }
62
+
63
+ getRotation(): number {
64
+ return this._ref.rotation();
65
+ }
66
+
67
+ setRotation(degrees: number): void {
68
+ this._ref.rotation(degrees);
69
+ }
70
+
71
+ getZIndex(): number {
72
+ return this._ref.zIndex();
73
+ }
74
+
75
+ setZIndex(zIndex: number): void {
76
+ this._ref.zIndex(zIndex);
77
+ }
78
+
79
+ delete() {
80
+ this._ref.destroy();
81
+ this._ref = null;
82
+ }
83
+
84
+ getPoints(): { x: number; y: number }[] {
85
+ const points = this._ref.points();
86
+ return [
87
+ { x: points[0], y: points[1] },
88
+ { x: points[2], y: points[3] },
89
+ ];
90
+ }
91
+
92
+ setPoints(points: { x: number; y: number }[]) {
93
+ if (points.length === 2) {
94
+ this._ref.points([points[0].x, points[0].y, points[1].x, points[1].y]);
95
+ }
96
+ }
97
+
98
+ getStartPoint(): { x: number; y: number } {
99
+ const points = this._ref.points();
100
+ return { x: points[0], y: points[1] };
101
+ }
102
+
103
+ setStartPoint(x: number, y: number) {
104
+ const points = this._ref.points();
105
+ this._ref.points([x, y, points[2], points[3]]);
106
+ }
107
+
108
+ getEndPoint(): { x: number; y: number } {
109
+ const points = this._ref.points();
110
+ return { x: points[2], y: points[3] };
111
+ }
112
+
113
+ setEndPoint(x: number, y: number) {
114
+ const points = this._ref.points();
115
+ this._ref.points([points[0], points[1], x, y]);
116
+ }
117
+ }
@@ -0,0 +1,208 @@
1
+ import Konva from "konva";
2
+ import { IMarkupColorable } from "../../IMarkupColorable";
3
+ import { IMarkupCloud } from "../../IMarkupCloud";
4
+
5
+ export class KonvaCloud implements IMarkupCloud, IMarkupColorable {
6
+ private _ref: Konva.Shape;
7
+
8
+ constructor(
9
+ params: {
10
+ position: { x: number; y: number };
11
+ width: number;
12
+ height: number;
13
+ lineWidth: number;
14
+ color: string;
15
+ id?: string;
16
+ },
17
+ ref = null
18
+ ) {
19
+ if (ref) {
20
+ this._ref = ref;
21
+ return;
22
+ }
23
+
24
+ if (!params.position || !params.width || !params.height) return;
25
+
26
+ const arcRadius = 16;
27
+
28
+ this._ref = new Konva.Shape({
29
+ x: params.position.x,
30
+ y: params.position.y,
31
+ width: params.width ?? 200,
32
+ height: params.height ?? 200,
33
+ stroke: params.color ?? "#ff0000",
34
+ strokeWidth: params.lineWidth ?? 5,
35
+ draggable: true,
36
+ strokeScaleEnabled: false,
37
+ globalCompositeOperation: "source-over",
38
+ sceneFunc: (context, shape) => {
39
+ function calculateMidpoint(position, width, height) {
40
+ const midX = position.x + width / 2;
41
+ const midY = position.y + height / 2;
42
+ return { x: midX, y: midY };
43
+ }
44
+
45
+ const points = [
46
+ { x: 0, y: 0 },
47
+ { x: 0 + this._ref.width(), y: 0 },
48
+ { x: 0 + this._ref.width(), y: 0 + this._ref.height() },
49
+ { x: 0, y: 0 + this._ref.height() },
50
+ { x: 0, y: 0 },
51
+ ];
52
+
53
+ const midPoint = calculateMidpoint({ x: 0, y: 0 }, this._ref.width(), this._ref.height());
54
+
55
+ const baseArcLength = 30;
56
+ context.beginPath();
57
+ for (let iPoint = 0; iPoint < points.length - 1; iPoint++) {
58
+ let approxArcLength = baseArcLength;
59
+ const dx = points[iPoint + 1].x - points[iPoint].x;
60
+ const dy = points[iPoint + 1].y - points[iPoint].y;
61
+ const length = Math.sqrt(dx * dx + dy * dy);
62
+
63
+ const arcCount = Math.floor(length / approxArcLength);
64
+ const lengthMod = length % approxArcLength;
65
+ approxArcLength = baseArcLength + arcCount / lengthMod;
66
+
67
+ let pX = points[iPoint].x + dx / arcCount / 2;
68
+ let pY = points[iPoint].y + dy / arcCount / 2;
69
+ const pEndX = points[iPoint + 1].x;
70
+ const pEndY = points[iPoint + 1].y;
71
+ const endAngle = Math.atan((pEndY - pY) / (pEndX - pX));
72
+ const startAngle = endAngle + Math.PI;
73
+ const counterClockwise = pX > midPoint.x && pY > midPoint.y;
74
+ for (let iArc = 0; iArc < arcCount; iArc++) {
75
+ if (counterClockwise) {
76
+ context.arc(pX, pY, arcRadius, endAngle, startAngle);
77
+ } else {
78
+ context.arc(pX, pY, arcRadius, startAngle, endAngle);
79
+ }
80
+
81
+ pX += dx / arcCount;
82
+ pY += dy / arcCount;
83
+ }
84
+ }
85
+
86
+ context.closePath();
87
+ // (!) Konva specific method, it is very important
88
+ // it will apply are required styles
89
+ context.fillStrokeShape(shape);
90
+ },
91
+ });
92
+
93
+ this._ref.className = "Cloud";
94
+
95
+ this._ref.on("transform", (e) => {
96
+ const attrs = e.target.attrs;
97
+
98
+ const minWidth = 100;
99
+ const minHeight = 100;
100
+
101
+ const newWidth = this._ref.width() * attrs.scaleX;
102
+ const newHeight = this._ref.height() * attrs.scaleY;
103
+
104
+ if (newWidth < minWidth || newHeight < minHeight) {
105
+ this._ref.scale({ x: 1, y: 1 });
106
+ return;
107
+ }
108
+
109
+ if (Math.abs(attrs.scaleX - 1) > 10e-6) {
110
+ this._ref.width(newWidth);
111
+ }
112
+
113
+ if (Math.abs(attrs.scaleY - 1) > 10e-6) {
114
+ this._ref.height(newHeight);
115
+ }
116
+
117
+ this._ref.scale({ x: 1, y: 1 });
118
+ });
119
+
120
+ this._ref.getSelfRect = () => {
121
+ return {
122
+ x: 0 - arcRadius,
123
+ y: 0 - arcRadius,
124
+ width: this._ref.width() + 2 * arcRadius,
125
+ height: this._ref.height() + 2 * arcRadius,
126
+ };
127
+ };
128
+
129
+ this._ref.id(this._ref._id.toString());
130
+ }
131
+
132
+ ref() {
133
+ return this._ref;
134
+ }
135
+
136
+ id(): string {
137
+ return this._ref.id();
138
+ }
139
+
140
+ enableMouseEditing(value: boolean) {
141
+ this._ref.draggable(value);
142
+ }
143
+
144
+ type(): string {
145
+ return "cloud";
146
+ }
147
+
148
+ getColor(): string {
149
+ return this._ref.stroke();
150
+ }
151
+
152
+ setColor(hex: string) {
153
+ this._ref.stroke(hex);
154
+ }
155
+
156
+ getRotation(): number {
157
+ return this._ref.rotation();
158
+ }
159
+
160
+ setRotation(degrees: number): void {
161
+ this._ref.rotation(degrees);
162
+ }
163
+
164
+ getZIndex(): number {
165
+ return this._ref.zIndex();
166
+ }
167
+
168
+ setZIndex(zIndex: number): void {
169
+ this._ref.zIndex(zIndex);
170
+ }
171
+
172
+ delete() {
173
+ this._ref.destroy();
174
+ this._ref = null;
175
+ }
176
+
177
+ getPosition() {
178
+ return this._ref.position();
179
+ }
180
+
181
+ setPosition(x: number, y: number) {
182
+ this._ref.position({ x, y });
183
+ }
184
+
185
+ getWidth(): number {
186
+ return this._ref.width();
187
+ }
188
+
189
+ setWidth(w: number) {
190
+ this._ref.width(w);
191
+ }
192
+
193
+ getHeigth(): number {
194
+ return this._ref.height();
195
+ }
196
+
197
+ setHeight(h: number) {
198
+ this._ref.height(h);
199
+ }
200
+
201
+ getLineWidth(): number {
202
+ return this._ref.strokeWidth();
203
+ }
204
+
205
+ setLineWidth(size: number) {
206
+ this._ref.strokeWidth(size);
207
+ }
208
+ }
@@ -1,113 +1,118 @@
1
- import Konva from "konva";
2
- import { IMarkupEllipse } from "../../IMarkupEllipse";
3
- import { IMarkupColorable } from "../../IMarkupColorable";
4
-
5
- export class KonvaEllipse implements IMarkupEllipse, IMarkupColorable {
6
- private _ref: Konva.Ellipse;
7
-
8
- constructor(
9
- params: { pos: { x: number; y: number }; radius: { x: number; y: number }; color: string; lineWidth: number },
10
- ref = null
11
- ) {
12
- if (ref) {
13
- this._ref = ref;
14
- this._ref.id(this._ref._id.toString());
15
- return;
16
- }
17
-
18
- if (!params.pos) return;
19
-
20
- this._ref = new Konva.Ellipse({
21
- stroke: params.color ?? "#ff0000",
22
- strokeWidth: params.lineWidth ?? 4,
23
- globalCompositeOperation: "source-over",
24
- lineCap: "round",
25
- lineJoin: "round",
26
- x: params.pos.x,
27
- y: params.pos.y,
28
- radiusX: params.radius.x,
29
- radiusY: params.radius.y,
30
- draggable: true,
31
- strokeScaleEnabled: false,
32
- });
33
-
34
- this._ref.id(this._ref._id.toString());
35
- }
36
-
37
- getPosition(): { x: number; y: number } {
38
- return this._ref.position();
39
- }
40
-
41
- setPosition(x: number, y: number) {
42
- this._ref.setPosition({ x, y });
43
- }
44
-
45
- getRadiusX(): number {
46
- return this._ref.radiusX();
47
- }
48
-
49
- setRadiusX(r: number) {
50
- this._ref.radius({ x: r, y: this._ref.radiusY() });
51
- }
52
-
53
- getRadiusY(): number {
54
- return this._ref.radiusY();
55
- }
56
-
57
- setRadiusY(r: number) {
58
- this._ref.radius({ x: this._ref.radiusX(), y: r });
59
- }
60
-
61
- getLineWidth(): number {
62
- return this._ref.strokeWidth();
63
- }
64
-
65
- setLineWidth(size: number) {
66
- this._ref.strokeWidth(size);
67
- }
68
-
69
- ref() {
70
- return this._ref;
71
- }
72
-
73
- id(): string {
74
- return this._ref.id();
75
- }
76
-
77
- enableMouseEditing(value: boolean) {
78
- this._ref.draggable(value);
79
- }
80
-
81
- type(): string {
82
- return "ellipse";
83
- }
84
-
85
- getColor(): string {
86
- return this._ref.stroke();
87
- }
88
-
89
- setColor(hex: string) {
90
- this._ref.stroke(hex);
91
- }
92
-
93
- getRotation(): number {
94
- return this._ref.rotation();
95
- }
96
-
97
- setRotation(degrees: number): void {
98
- this._ref.rotation(degrees);
99
- }
100
-
101
- getZIndex(): number {
102
- return this._ref.zIndex();
103
- }
104
-
105
- setZIndex(zIndex: number): void {
106
- this._ref.zIndex(zIndex);
107
- }
108
-
109
- delete() {
110
- this._ref.destroy();
111
- this._ref = null;
112
- }
113
- }
1
+ import Konva from "konva";
2
+ import { IMarkupEllipse } from "../../IMarkupEllipse";
3
+ import { IMarkupColorable } from "../../IMarkupColorable";
4
+
5
+ export class KonvaEllipse implements IMarkupEllipse, IMarkupColorable {
6
+ private _ref: Konva.Ellipse;
7
+
8
+ constructor(
9
+ params: {
10
+ position: { x: number; y: number };
11
+ radius: { x: number; y: number };
12
+ color: string;
13
+ lineWidth?: number;
14
+ id?: string;
15
+ },
16
+ ref = null
17
+ ) {
18
+ if (ref) {
19
+ this._ref = ref;
20
+ return;
21
+ }
22
+
23
+ if (!params.position) return;
24
+
25
+ this._ref = new Konva.Ellipse({
26
+ stroke: params.color ?? "#ff0000",
27
+ strokeWidth: params.lineWidth ?? 4,
28
+ globalCompositeOperation: "source-over",
29
+ lineCap: "round",
30
+ lineJoin: "round",
31
+ x: params.position.x,
32
+ y: params.position.y,
33
+ radiusX: params.radius.x,
34
+ radiusY: params.radius.y,
35
+ draggable: true,
36
+ strokeScaleEnabled: false,
37
+ });
38
+
39
+ this._ref.id(this._ref._id.toString());
40
+ }
41
+
42
+ getPosition(): { x: number; y: number } {
43
+ return this._ref.position();
44
+ }
45
+
46
+ setPosition(x: number, y: number) {
47
+ this._ref.setPosition({ x, y });
48
+ }
49
+
50
+ getRadiusX(): number {
51
+ return this._ref.radiusX();
52
+ }
53
+
54
+ setRadiusX(r: number) {
55
+ this._ref.radius({ x: r, y: this._ref.radiusY() });
56
+ }
57
+
58
+ getRadiusY(): number {
59
+ return this._ref.radiusY();
60
+ }
61
+
62
+ setRadiusY(r: number) {
63
+ this._ref.radius({ x: this._ref.radiusX(), y: r });
64
+ }
65
+
66
+ getLineWidth(): number {
67
+ return this._ref.strokeWidth();
68
+ }
69
+
70
+ setLineWidth(size: number) {
71
+ this._ref.strokeWidth(size);
72
+ }
73
+
74
+ ref() {
75
+ return this._ref;
76
+ }
77
+
78
+ id(): string {
79
+ return this._ref.id();
80
+ }
81
+
82
+ enableMouseEditing(value: boolean) {
83
+ this._ref.draggable(value);
84
+ }
85
+
86
+ type(): string {
87
+ return "ellipse";
88
+ }
89
+
90
+ getColor(): string {
91
+ return this._ref.stroke();
92
+ }
93
+
94
+ setColor(hex: string) {
95
+ this._ref.stroke(hex);
96
+ }
97
+
98
+ getRotation(): number {
99
+ return this._ref.rotation();
100
+ }
101
+
102
+ setRotation(degrees: number): void {
103
+ this._ref.rotation(degrees);
104
+ }
105
+
106
+ getZIndex(): number {
107
+ return this._ref.zIndex();
108
+ }
109
+
110
+ setZIndex(zIndex: number): void {
111
+ this._ref.zIndex(zIndex);
112
+ }
113
+
114
+ delete() {
115
+ this._ref.destroy();
116
+ this._ref = null;
117
+ }
118
+ }