@inweb/client 25.2.2

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 (218) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +70 -0
  3. package/dist/client.js +21126 -0
  4. package/dist/client.js.map +1 -0
  5. package/dist/client.min.js +1 -0
  6. package/dist/client.module.js +7151 -0
  7. package/dist/client.module.js.map +1 -0
  8. package/lib/Api/Assembly.d.ts +339 -0
  9. package/lib/Api/ClashTest.d.ts +176 -0
  10. package/lib/Api/Client.d.ts +452 -0
  11. package/lib/Api/ClientEvents.d.ts +29 -0
  12. package/lib/Api/File.d.ts +568 -0
  13. package/lib/Api/HttpClient.d.ts +13 -0
  14. package/lib/Api/IAssembly.d.ts +14 -0
  15. package/lib/Api/IFile.d.ts +46 -0
  16. package/lib/Api/IHttpClient.d.ts +11 -0
  17. package/lib/Api/IUser.d.ts +11 -0
  18. package/lib/Api/Job.d.ts +142 -0
  19. package/lib/Api/Member.d.ts +85 -0
  20. package/lib/Api/Model.d.ts +147 -0
  21. package/lib/Api/Permission.d.ts +93 -0
  22. package/lib/Api/Project.d.ts +247 -0
  23. package/lib/Api/Role.d.ts +82 -0
  24. package/lib/Api/User.d.ts +197 -0
  25. package/lib/Api/impl/FetchError.d.ts +18 -0
  26. package/lib/Api/impl/Utils.d.ts +33 -0
  27. package/lib/Api/impl/http.d.ts +67 -0
  28. package/lib/ConvetMath.d.ts +29 -0
  29. package/lib/Viewer/CanvasEvents.d.ts +2 -0
  30. package/lib/Viewer/Commands/ApplyModelTransform.d.ts +2 -0
  31. package/lib/Viewer/Commands/ClearMarkup.d.ts +2 -0
  32. package/lib/Viewer/Commands/ClearSlices.d.ts +2 -0
  33. package/lib/Viewer/Commands/CreatePreview.d.ts +2 -0
  34. package/lib/Viewer/Commands/Explode.d.ts +2 -0
  35. package/lib/Viewer/Commands/GetDefaultViewPositions.d.ts +2 -0
  36. package/lib/Viewer/Commands/GetModels.d.ts +2 -0
  37. package/lib/Viewer/Commands/GetSelected.d.ts +2 -0
  38. package/lib/Viewer/Commands/HideSelected.d.ts +2 -0
  39. package/lib/Viewer/Commands/IsolateSelected.d.ts +2 -0
  40. package/lib/Viewer/Commands/RegenerateAll.d.ts +2 -0
  41. package/lib/Viewer/Commands/ResetView.d.ts +2 -0
  42. package/lib/Viewer/Commands/SelectModel.d.ts +2 -0
  43. package/lib/Viewer/Commands/SetActiveDragger.d.ts +2 -0
  44. package/lib/Viewer/Commands/SetDefaultViewPosition.d.ts +2 -0
  45. package/lib/Viewer/Commands/SetMarkupColor.d.ts +2 -0
  46. package/lib/Viewer/Commands/SetSelected.d.ts +2 -0
  47. package/lib/Viewer/Commands/ShowAll.d.ts +2 -0
  48. package/lib/Viewer/Commands/Unselect.d.ts +2 -0
  49. package/lib/Viewer/Commands/ZoomToExtents.d.ts +2 -0
  50. package/lib/Viewer/Commands/ZoomToObjects.d.ts +2 -0
  51. package/lib/Viewer/Commands/ZoomToSelected.d.ts +2 -0
  52. package/lib/Viewer/Commands.d.ts +3 -0
  53. package/lib/Viewer/Draggers/Actions/OrbitAction.d.ts +22 -0
  54. package/lib/Viewer/Draggers/Actions/PanAction.d.ts +18 -0
  55. package/lib/Viewer/Draggers/Actions/ZoomAction.d.ts +8 -0
  56. package/lib/Viewer/Draggers/Common/Geometry.d.ts +115 -0
  57. package/lib/Viewer/Draggers/Common/GestureManager.d.ts +41 -0
  58. package/lib/Viewer/Draggers/Common/OdBaseDragger.d.ts +54 -0
  59. package/lib/Viewer/Draggers/Common/OdaGeAction.d.ts +30 -0
  60. package/lib/Viewer/Draggers/MeasureLineDragger/MeasureLineItem.d.ts +31 -0
  61. package/lib/Viewer/Draggers/MeasureLineDragger/MeasureUtils.d.ts +20 -0
  62. package/lib/Viewer/Draggers/MeasureLineDragger/index.d.ts +24 -0
  63. package/lib/Viewer/Draggers/OdBaseCuttingPlaneDragger.d.ts +27 -0
  64. package/lib/Viewer/Draggers/OdCuttingPlaneXAxisDragger.d.ts +8 -0
  65. package/lib/Viewer/Draggers/OdCuttingPlaneYAxisDragger.d.ts +8 -0
  66. package/lib/Viewer/Draggers/OdCuttingPlaneZAxisDragger.d.ts +8 -0
  67. package/lib/Viewer/Draggers/OdOrbitDragger.d.ts +15 -0
  68. package/lib/Viewer/Draggers/OdPanDragger.d.ts +12 -0
  69. package/lib/Viewer/Draggers/OdZoomDragger.d.ts +12 -0
  70. package/lib/Viewer/Draggers/OdZoomWheelDragger.d.ts +11 -0
  71. package/lib/Viewer/Draggers/OdZoomWindowDragger/OdSelectionFrame.d.ts +19 -0
  72. package/lib/Viewer/Draggers/OdZoomWindowDragger/index.d.ts +14 -0
  73. package/lib/Viewer/Draggers/OdaLineDragger.d.ts +15 -0
  74. package/lib/Viewer/Draggers/OdaTextDragger.d.ts +16 -0
  75. package/lib/Viewer/Draggers/OdaWalkDragger.d.ts +30 -0
  76. package/lib/Viewer/Draggers/OrbitAroundBuildingDragger.d.ts +19 -0
  77. package/lib/Viewer/EventEmitter2.d.ts +54 -0
  78. package/lib/Viewer/ICommands.d.ts +25 -0
  79. package/lib/Viewer/IEventEmitter2.d.ts +13 -0
  80. package/lib/Viewer/IViewer.d.ts +27 -0
  81. package/lib/Viewer/Loaders/BaseLoader.d.ts +11 -0
  82. package/lib/Viewer/Loaders/LoaderFactory.d.ts +10 -0
  83. package/lib/Viewer/Loaders/TCSLoader.d.ts +5 -0
  84. package/lib/Viewer/Loaders/UpdaterController.d.ts +15 -0
  85. package/lib/Viewer/Loaders/VsfXLoader.d.ts +5 -0
  86. package/lib/Viewer/Loaders/VsfXPartialLoader.d.ts +5 -0
  87. package/lib/Viewer/Markup/Api/IMarkupArrow.d.ts +12 -0
  88. package/lib/Viewer/Markup/Api/IMarkupColorable.d.ts +5 -0
  89. package/lib/Viewer/Markup/Api/IMarkupEllipse.d.ts +15 -0
  90. package/lib/Viewer/Markup/Api/IMarkupImage.d.ts +15 -0
  91. package/lib/Viewer/Markup/Api/IMarkupLine.d.ts +11 -0
  92. package/lib/Viewer/Markup/Api/IMarkupObject.d.ts +12 -0
  93. package/lib/Viewer/Markup/Api/IMarkupRectangle.d.ts +15 -0
  94. package/lib/Viewer/Markup/Api/IMarkupText.d.ts +13 -0
  95. package/lib/Viewer/Markup/Api/Impl/Konva/KonvaArrow.d.ts +32 -0
  96. package/lib/Viewer/Markup/Api/Impl/Konva/KonvaEllipse.d.ts +40 -0
  97. package/lib/Viewer/Markup/Api/Impl/Konva/KonvaImage.d.ts +36 -0
  98. package/lib/Viewer/Markup/Api/Impl/Konva/KonvaLine.d.ts +32 -0
  99. package/lib/Viewer/Markup/Api/Impl/Konva/KonvaRectangle.d.ts +38 -0
  100. package/lib/Viewer/Markup/Api/Impl/Konva/KonvaText.d.ts +37 -0
  101. package/lib/Viewer/Markup/IMarkup.d.ts +38 -0
  102. package/lib/Viewer/Markup/Impl/Konva/KonvaMarkup.d.ts +63 -0
  103. package/lib/Viewer/Markup/Impl/Konva/MarkupColor.d.ts +19 -0
  104. package/lib/Viewer/Markup/Impl/Visualize/VisualizeMarkup.d.ts +33 -0
  105. package/lib/Viewer/Markup/MarkupFactory.d.ts +7 -0
  106. package/lib/Viewer/Options.d.ts +228 -0
  107. package/lib/Viewer/OptionsEvents.d.ts +26 -0
  108. package/lib/Viewer/Viewer.d.ts +353 -0
  109. package/lib/Viewer/ViewerCommands.d.ts +23 -0
  110. package/lib/Viewer/ViewerEvents.d.ts +601 -0
  111. package/lib/Viewer/utils.d.ts +4 -0
  112. package/lib/index.d.ts +24 -0
  113. package/package.json +32 -0
  114. package/src/Api/Assembly.ts +678 -0
  115. package/src/Api/ClashTest.ts +290 -0
  116. package/src/Api/Client.ts +816 -0
  117. package/src/Api/ClientEvents.ts +31 -0
  118. package/src/Api/File.ts +962 -0
  119. package/src/Api/HttpClient.ts +73 -0
  120. package/src/Api/IAssembly.ts +37 -0
  121. package/src/Api/IFile.ts +74 -0
  122. package/src/Api/IHttpClient.ts +50 -0
  123. package/src/Api/IUser.ts +33 -0
  124. package/src/Api/Job.ts +253 -0
  125. package/src/Api/Member.ts +161 -0
  126. package/src/Api/Model.ts +259 -0
  127. package/src/Api/Permission.ts +173 -0
  128. package/src/Api/Project.ts +479 -0
  129. package/src/Api/Role.ts +158 -0
  130. package/src/Api/User.ts +357 -0
  131. package/src/Api/impl/FetchError.ts +48 -0
  132. package/src/Api/impl/Utils.ts +367 -0
  133. package/src/Api/impl/http.ts +92 -0
  134. package/src/ConvetMath.ts +372 -0
  135. package/src/Viewer/CanvasEvents.ts +41 -0
  136. package/src/Viewer/Commands/ApplyModelTransform.ts +70 -0
  137. package/src/Viewer/Commands/ClearMarkup.ts +28 -0
  138. package/src/Viewer/Commands/ClearSlices.ts +27 -0
  139. package/src/Viewer/Commands/CreatePreview.ts +33 -0
  140. package/src/Viewer/Commands/Explode.ts +38 -0
  141. package/src/Viewer/Commands/GetDefaultViewPositions.ts +36 -0
  142. package/src/Viewer/Commands/GetModels.ts +43 -0
  143. package/src/Viewer/Commands/GetSelected.ts +58 -0
  144. package/src/Viewer/Commands/HideSelected.ts +37 -0
  145. package/src/Viewer/Commands/IsolateSelected.ts +37 -0
  146. package/src/Viewer/Commands/RegenerateAll.ts +37 -0
  147. package/src/Viewer/Commands/ResetView.ts +43 -0
  148. package/src/Viewer/Commands/SelectModel.ts +52 -0
  149. package/src/Viewer/Commands/SetActiveDragger.ts +29 -0
  150. package/src/Viewer/Commands/SetDefaultViewPosition.ts +50 -0
  151. package/src/Viewer/Commands/SetMarkupColor.ts +29 -0
  152. package/src/Viewer/Commands/SetSelected.ts +47 -0
  153. package/src/Viewer/Commands/ShowAll.ts +37 -0
  154. package/src/Viewer/Commands/Unselect.ts +37 -0
  155. package/src/Viewer/Commands/ZoomToExtents.ts +43 -0
  156. package/src/Viewer/Commands/ZoomToObjects.ts +47 -0
  157. package/src/Viewer/Commands/ZoomToSelected.ts +39 -0
  158. package/src/Viewer/Commands.ts +81 -0
  159. package/src/Viewer/Draggers/Actions/OrbitAction.ts +250 -0
  160. package/src/Viewer/Draggers/Actions/PanAction.ts +102 -0
  161. package/src/Viewer/Draggers/Actions/ZoomAction.ts +45 -0
  162. package/src/Viewer/Draggers/Common/Geometry.ts +152 -0
  163. package/src/Viewer/Draggers/Common/GestureManager.ts +263 -0
  164. package/src/Viewer/Draggers/Common/OdBaseDragger.ts +270 -0
  165. package/src/Viewer/Draggers/Common/OdaGeAction.ts +146 -0
  166. package/src/Viewer/Draggers/MeasureLineDragger/MeasureLineItem.ts +248 -0
  167. package/src/Viewer/Draggers/MeasureLineDragger/MeasureUtils.ts +182 -0
  168. package/src/Viewer/Draggers/MeasureLineDragger/index.ts +166 -0
  169. package/src/Viewer/Draggers/OdBaseCuttingPlaneDragger.ts +182 -0
  170. package/src/Viewer/Draggers/OdCuttingPlaneXAxisDragger.ts +53 -0
  171. package/src/Viewer/Draggers/OdCuttingPlaneYAxisDragger.ts +53 -0
  172. package/src/Viewer/Draggers/OdCuttingPlaneZAxisDragger.ts +53 -0
  173. package/src/Viewer/Draggers/OdOrbitDragger.ts +70 -0
  174. package/src/Viewer/Draggers/OdPanDragger.ts +62 -0
  175. package/src/Viewer/Draggers/OdZoomDragger.ts +59 -0
  176. package/src/Viewer/Draggers/OdZoomWheelDragger.ts +103 -0
  177. package/src/Viewer/Draggers/OdZoomWindowDragger/OdSelectionFrame.ts +123 -0
  178. package/src/Viewer/Draggers/OdZoomWindowDragger/index.ts +75 -0
  179. package/src/Viewer/Draggers/OdaLineDragger.ts +80 -0
  180. package/src/Viewer/Draggers/OdaTextDragger.ts +118 -0
  181. package/src/Viewer/Draggers/OdaWalkDragger.ts +278 -0
  182. package/src/Viewer/Draggers/OrbitAroundBuildingDragger.ts +184 -0
  183. package/src/Viewer/EventEmitter2.ts +116 -0
  184. package/src/Viewer/ICommands.ts +53 -0
  185. package/src/Viewer/IEventEmitter2.ts +36 -0
  186. package/src/Viewer/IViewer.ts +55 -0
  187. package/src/Viewer/Loaders/BaseLoader.ts +40 -0
  188. package/src/Viewer/Loaders/LoaderFactory.ts +44 -0
  189. package/src/Viewer/Loaders/TCSLoader.ts +82 -0
  190. package/src/Viewer/Loaders/UpdaterController.ts +36 -0
  191. package/src/Viewer/Loaders/VsfXLoader.ts +87 -0
  192. package/src/Viewer/Loaders/VsfXPartialLoader.ts +208 -0
  193. package/src/Viewer/Markup/Api/IMarkupArrow.ts +15 -0
  194. package/src/Viewer/Markup/Api/IMarkupColorable.ts +4 -0
  195. package/src/Viewer/Markup/Api/IMarkupEllipse.ts +15 -0
  196. package/src/Viewer/Markup/Api/IMarkupImage.ts +15 -0
  197. package/src/Viewer/Markup/Api/IMarkupLine.ts +10 -0
  198. package/src/Viewer/Markup/Api/IMarkupObject.ts +15 -0
  199. package/src/Viewer/Markup/Api/IMarkupRectangle.ts +15 -0
  200. package/src/Viewer/Markup/Api/IMarkupText.ts +12 -0
  201. package/src/Viewer/Markup/Api/Impl/Konva/KonvaArrow.ts +119 -0
  202. package/src/Viewer/Markup/Api/Impl/Konva/KonvaEllipse.ts +113 -0
  203. package/src/Viewer/Markup/Api/Impl/Konva/KonvaImage.ts +121 -0
  204. package/src/Viewer/Markup/Api/Impl/Konva/KonvaLine.ts +99 -0
  205. package/src/Viewer/Markup/Api/Impl/Konva/KonvaRectangle.ts +113 -0
  206. package/src/Viewer/Markup/Api/Impl/Konva/KonvaText.ts +104 -0
  207. package/src/Viewer/Markup/IMarkup.ts +39 -0
  208. package/src/Viewer/Markup/Impl/Konva/KonvaMarkup.ts +872 -0
  209. package/src/Viewer/Markup/Impl/Konva/MarkupColor.ts +39 -0
  210. package/src/Viewer/Markup/Impl/Visualize/VisualizeMarkup.ts +273 -0
  211. package/src/Viewer/Markup/MarkupFactory.ts +32 -0
  212. package/src/Viewer/Options.ts +502 -0
  213. package/src/Viewer/OptionsEvents.ts +28 -0
  214. package/src/Viewer/Viewer.ts +1109 -0
  215. package/src/Viewer/ViewerCommands.ts +45 -0
  216. package/src/Viewer/ViewerEvents.ts +700 -0
  217. package/src/Viewer/utils.ts +74 -0
  218. package/src/index.ts +48 -0
@@ -0,0 +1,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
+ 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
+ }
@@ -0,0 +1,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: { 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
+ }
@@ -0,0 +1,121 @@
1
+ import Konva from "konva";
2
+ import { IMarkupImage } from "../../IMarkupImage";
3
+
4
+ export class KonvaImage implements IMarkupImage {
5
+ private _ref: Konva.Image;
6
+ private _canvasImage: HTMLImageElement;
7
+ private _ratio = 1;
8
+
9
+ constructor(params: { position: { x: number; y: number }; src: string; width: number; height: number }, ref = null) {
10
+ if (ref) {
11
+ if (ref.height() === 0 || ref.width() === 0) return;
12
+
13
+ this._ref = ref;
14
+ this._canvasImage = ref.image();
15
+ this._ref.id(this._ref._id.toString());
16
+ this._ratio = this._ref.height() / this._ref.width();
17
+ return;
18
+ }
19
+
20
+ if (!params.position || !params.src) return;
21
+ this._canvasImage = new Image();
22
+
23
+ this._ref = new Konva.Image({
24
+ x: params.position.x,
25
+ y: params.position.y,
26
+ image: this._canvasImage,
27
+ width: params.width,
28
+ height: params.height,
29
+ draggable: true,
30
+ });
31
+
32
+ this._canvasImage.onload = () => {
33
+ this._ref.image(this._canvasImage);
34
+ this._ratio = this._ref.height() === 0 || this._ref.width() === 0 ? 1 : this._ref.height() / this._ref.width();
35
+ };
36
+
37
+ this._canvasImage.src = params.src;
38
+
39
+ this._ref.id(this._ref._id.toString());
40
+ }
41
+
42
+ getSrc(): string {
43
+ return this._canvasImage.src;
44
+ }
45
+
46
+ setSrc(src: any) {
47
+ this._canvasImage.src = src;
48
+ }
49
+
50
+ getWidth(): number {
51
+ return this._ref.width();
52
+ }
53
+
54
+ setWidth(w: number) {
55
+ this._ref.width(w);
56
+ this._ref.height(w * this._ratio);
57
+ }
58
+
59
+ getHeight(): number {
60
+ return this._ref.height();
61
+ }
62
+
63
+ setHeight(h: number) {
64
+ this._ref.height(h);
65
+ this._ref.width(h / this._ratio);
66
+ }
67
+
68
+ ref() {
69
+ return this._ref;
70
+ }
71
+
72
+ id(): string {
73
+ return this._ref.id();
74
+ }
75
+
76
+ enableMouseEditing(value: boolean) {
77
+ this._ref.draggable(value);
78
+ }
79
+
80
+ type(): string {
81
+ return "image";
82
+ }
83
+
84
+ // we can break Liskov Substitution Principle, need to use separate IColorable
85
+ // getColor(): string {
86
+ // return this._ref.fill();
87
+ // }
88
+
89
+ // setColor(hex: string) {
90
+ // this._ref.fill(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
+
114
+ getPosition(): { x: number; y: number } {
115
+ return this._ref.getPosition();
116
+ }
117
+
118
+ setPosition(x: number, y: number) {
119
+ this._ref.setPosition({ x, y });
120
+ }
121
+ }
@@ -0,0 +1,99 @@
1
+ import Konva from "konva";
2
+ import { IMarkupLine } from "../../IMarkupLine";
3
+ import { IMarkupColorable } from "../../IMarkupColorable";
4
+
5
+ export class KonvaLine implements IMarkupLine, IMarkupColorable {
6
+ private _ref: Konva.Line;
7
+
8
+ constructor(params: { points: { x: number; y: number }[]; color: string; width: number }, ref = null) {
9
+ if (ref) {
10
+ this._ref = ref;
11
+ this._ref.id(this._ref._id.toString());
12
+ return;
13
+ }
14
+
15
+ if (!params.points) return;
16
+
17
+ const konvaPoints = [];
18
+ params.points.forEach((point) => konvaPoints.push(point.x, point.y));
19
+
20
+ this._ref = new Konva.Line({
21
+ stroke: params.color ?? "#ff0000",
22
+ strokeWidth: params.width ?? 4,
23
+ globalCompositeOperation: "source-over",
24
+ lineCap: "round",
25
+ lineJoin: "round",
26
+ points: konvaPoints,
27
+ draggable: true,
28
+ strokeScaleEnabled: false,
29
+ });
30
+
31
+ this._ref.id(this._ref._id.toString());
32
+ }
33
+
34
+ ref() {
35
+ return this._ref;
36
+ }
37
+
38
+ id(): string {
39
+ return this._ref.id();
40
+ }
41
+
42
+ enableMouseEditing(value: boolean) {
43
+ this._ref.draggable(value);
44
+ }
45
+
46
+ type(): string {
47
+ return "line";
48
+ }
49
+
50
+ getColor(): string {
51
+ return this._ref.stroke();
52
+ }
53
+
54
+ setColor(hex: string) {
55
+ this._ref.stroke(hex);
56
+ }
57
+
58
+ getRotation(): number {
59
+ return this._ref.rotation();
60
+ }
61
+
62
+ setRotation(degrees: number): void {
63
+ this._ref.rotation(degrees);
64
+ }
65
+
66
+ getZIndex(): number {
67
+ return this._ref.zIndex();
68
+ }
69
+
70
+ setZIndex(zIndex: number): void {
71
+ this._ref.zIndex(zIndex);
72
+ }
73
+
74
+ delete() {
75
+ this._ref.destroy();
76
+ this._ref = null;
77
+ }
78
+
79
+ getPoints(): [] {
80
+ return this._ref.attrs.points;
81
+ }
82
+
83
+ setLineWidth(size: number) {
84
+ this._ref.strokeWidth(size);
85
+ }
86
+
87
+ getLineWidth(): number {
88
+ return this._ref.strokeWidth();
89
+ }
90
+
91
+ addPoints(points: [{ x: number; y: number }]) {
92
+ let newPoints = this._ref.points();
93
+ points.forEach((point) => {
94
+ newPoints = newPoints.concat([point.x, point.y]);
95
+ });
96
+
97
+ this._ref.points(newPoints);
98
+ }
99
+ }
@@ -0,0 +1,113 @@
1
+ import Konva from "konva";
2
+ import { IMarkupRectangle } from "../../IMarkupRectangle";
3
+ import { IMarkupColorable } from "../../IMarkupColorable";
4
+
5
+ export class KonvaRectangle implements IMarkupRectangle, IMarkupColorable {
6
+ private _ref: Konva.Rect;
7
+
8
+ constructor(
9
+ params: { pos: { x: number; y: number }; color: string; lineWidth: number; width: number; height: 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.Rect({
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
+ width: params.width,
29
+ height: params.height,
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
+ getWidth(): number {
42
+ return this._ref.width();
43
+ }
44
+
45
+ getHeigth(): number {
46
+ return this._ref.height();
47
+ }
48
+
49
+ setWidth(w: number) {
50
+ this._ref.width(w);
51
+ }
52
+
53
+ setHeight(h: number) {
54
+ this._ref.height(h);
55
+ }
56
+
57
+ setPosition(x: number, y: number) {
58
+ this._ref.setPosition({ x, y });
59
+ }
60
+
61
+ ref() {
62
+ return this._ref;
63
+ }
64
+
65
+ id(): string {
66
+ return this._ref.id();
67
+ }
68
+
69
+ enableMouseEditing(value: boolean): void {
70
+ this._ref.draggable(value);
71
+ }
72
+
73
+ type(): string {
74
+ return "rectangle";
75
+ }
76
+
77
+ getColor(): string {
78
+ return this._ref.stroke();
79
+ }
80
+
81
+ setColor(hex: string): void {
82
+ this._ref.stroke(hex);
83
+ }
84
+
85
+ getRotation(): number {
86
+ return this._ref.rotation();
87
+ }
88
+
89
+ setRotation(degrees: number): void {
90
+ this._ref.rotation(degrees);
91
+ }
92
+
93
+ getZIndex(): number {
94
+ return this._ref.zIndex();
95
+ }
96
+
97
+ setZIndex(zIndex: number): void {
98
+ this._ref.zIndex(zIndex);
99
+ }
100
+
101
+ delete(): void {
102
+ this._ref.destroy();
103
+ this._ref = null;
104
+ }
105
+
106
+ setLineWidth(size: number): void {
107
+ this._ref.strokeWidth(size);
108
+ }
109
+
110
+ getLineWidth(): number {
111
+ return this._ref.strokeWidth();
112
+ }
113
+ }
@@ -0,0 +1,104 @@
1
+ import Konva from "konva";
2
+ import { IMarkupText } from "../../IMarkupText";
3
+ import { IMarkupColorable } from "../../IMarkupColorable";
4
+
5
+ export class KonvaText implements IMarkupText, IMarkupColorable {
6
+ private _ref: Konva.Text;
7
+ private readonly TEXT_FONT_FAMILY = "Calibri";
8
+
9
+ constructor(
10
+ params: { position: { x: number; y: number }; text: string; fontSize: number; color: string; rotation: number },
11
+ ref = null
12
+ ) {
13
+ if (ref) {
14
+ this._ref = ref;
15
+ this._ref.id(this._ref._id.toString());
16
+ return;
17
+ }
18
+
19
+ if (!params || !params.text) return;
20
+
21
+ this._ref = new Konva.Text({
22
+ x: params.position.x,
23
+ y: params.position.y,
24
+ text: params.text,
25
+ fontSize: params.fontSize ?? 34,
26
+ fontFamily: this.TEXT_FONT_FAMILY,
27
+ fill: params.color ?? "#ff0000",
28
+ align: "left",
29
+ draggable: true,
30
+ rotation: params.rotation ?? 0,
31
+ });
32
+
33
+ this._ref.id(this._ref._id.toString());
34
+ }
35
+
36
+ ref() {
37
+ return this._ref;
38
+ }
39
+
40
+ id(): string {
41
+ return this._ref.id();
42
+ }
43
+
44
+ enableMouseEditing(value: boolean) {
45
+ this._ref.draggable(value);
46
+ }
47
+
48
+ type(): string {
49
+ return "text";
50
+ }
51
+
52
+ getColor(): string {
53
+ return this._ref.fill();
54
+ }
55
+
56
+ setColor(hex: string) {
57
+ this._ref.fill(hex);
58
+ }
59
+
60
+ getRotation(): number {
61
+ return this._ref.rotation();
62
+ }
63
+
64
+ setRotation(degrees: number): void {
65
+ this._ref.rotation(degrees);
66
+ }
67
+
68
+ getZIndex(): number {
69
+ return this._ref.zIndex();
70
+ }
71
+
72
+ setZIndex(zIndex: number): void {
73
+ this._ref.zIndex(zIndex);
74
+ }
75
+
76
+ delete() {
77
+ this._ref.destroy();
78
+ this._ref = null;
79
+ }
80
+
81
+ getText(): string {
82
+ return this._ref.text();
83
+ }
84
+
85
+ setText(text: string): void {
86
+ this._ref.text(text);
87
+ }
88
+
89
+ getPosition(): { x: number; y: number } {
90
+ return this._ref.getPosition();
91
+ }
92
+
93
+ setPosition(x: number, y: number) {
94
+ this._ref.setPosition({ x, y });
95
+ }
96
+
97
+ getFontSize() {
98
+ return this._ref.fontSize();
99
+ }
100
+
101
+ setFontSize(size: number) {
102
+ this._ref.fontSize(size);
103
+ }
104
+ }
@@ -0,0 +1,39 @@
1
+ import { OdBaseDragger } from "../Draggers/Common/OdBaseDragger";
2
+ import { Viewer } from "../Viewer";
3
+ import { IMarkupObject } from "./Api/IMarkupObject";
4
+
5
+ export enum MarkupType {
6
+ Unknown,
7
+ Konva = "Konva",
8
+ Visualize = "Visualize",
9
+ }
10
+
11
+ export enum MarkupMode {
12
+ Line = "Line",
13
+ Text = "Text",
14
+ Rectangle = "Rectangle",
15
+ Ellipse = "Ellipse",
16
+ Arrow = "Arrow",
17
+ Image = "Image",
18
+ }
19
+
20
+ export interface IMarkup {
21
+ lineWidth: number;
22
+
23
+ initialize(viewer: Viewer, canvas: HTMLCanvasElement, canvasEvents: string[]): void;
24
+ dispose(): void;
25
+
26
+ getDraggers(): Map<string, typeof OdBaseDragger>;
27
+ clearOverlay(): void;
28
+ getMarkupColor(): { r: number; g: number; b: number };
29
+ setMarkupColor(r: number, g: number, b: number): void;
30
+ colorizeAllMarkup(r: number, g: number, b: number): void;
31
+ drawViewpoint(viewpoint: any): void;
32
+ createViewpoint(): object;
33
+
34
+ createObject(type: string, params: any): IMarkupObject;
35
+ getObjects(): IMarkupObject[];
36
+ getSelectedObjects(): IMarkupObject[];
37
+ selectObjects(objects: IMarkupObject[]): void;
38
+ clearSelected(): void;
39
+ }