@inweb/viewer-visualize 25.3.13

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 (164) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +63 -0
  3. package/dist/viewer-visualize.js +16982 -0
  4. package/dist/viewer-visualize.js.map +1 -0
  5. package/dist/viewer-visualize.min.js +1 -0
  6. package/dist/viewer-visualize.module.js +5267 -0
  7. package/dist/viewer-visualize.module.js.map +1 -0
  8. package/lib/Viewer/Commands/ApplyModelTransform.d.ts +1 -0
  9. package/lib/Viewer/Commands/ClearMarkup.d.ts +1 -0
  10. package/lib/Viewer/Commands/ClearSlices.d.ts +1 -0
  11. package/lib/Viewer/Commands/CreatePreview.d.ts +1 -0
  12. package/lib/Viewer/Commands/Explode.d.ts +1 -0
  13. package/lib/Viewer/Commands/GetDefaultViewPositions.d.ts +1 -0
  14. package/lib/Viewer/Commands/GetModels.d.ts +1 -0
  15. package/lib/Viewer/Commands/GetSelected.d.ts +1 -0
  16. package/lib/Viewer/Commands/HideSelected.d.ts +1 -0
  17. package/lib/Viewer/Commands/IsolateSelected.d.ts +1 -0
  18. package/lib/Viewer/Commands/RegenerateAll.d.ts +1 -0
  19. package/lib/Viewer/Commands/ResetView.d.ts +1 -0
  20. package/lib/Viewer/Commands/SelectModel.d.ts +1 -0
  21. package/lib/Viewer/Commands/SetActiveDragger.d.ts +1 -0
  22. package/lib/Viewer/Commands/SetDefaultViewPosition.d.ts +1 -0
  23. package/lib/Viewer/Commands/SetMarkupColor.d.ts +1 -0
  24. package/lib/Viewer/Commands/SetSelected.d.ts +1 -0
  25. package/lib/Viewer/Commands/ShowAll.d.ts +1 -0
  26. package/lib/Viewer/Commands/Unselect.d.ts +1 -0
  27. package/lib/Viewer/Commands/ZoomToExtents.d.ts +1 -0
  28. package/lib/Viewer/Commands/ZoomToObjects.d.ts +1 -0
  29. package/lib/Viewer/Commands/ZoomToSelected.d.ts +1 -0
  30. package/lib/Viewer/Commands/index.d.ts +22 -0
  31. package/lib/Viewer/Draggers/Actions/OrbitAction.d.ts +21 -0
  32. package/lib/Viewer/Draggers/Actions/PanAction.d.ts +17 -0
  33. package/lib/Viewer/Draggers/Actions/ZoomAction.d.ts +7 -0
  34. package/lib/Viewer/Draggers/Common/Geometry.d.ts +114 -0
  35. package/lib/Viewer/Draggers/Common/GestureManager.d.ts +40 -0
  36. package/lib/Viewer/Draggers/Common/OdBaseDragger.d.ts +53 -0
  37. package/lib/Viewer/Draggers/Common/OdaGeAction.d.ts +29 -0
  38. package/lib/Viewer/Draggers/MeasureLineDragger/MeasureLineItem.d.ts +30 -0
  39. package/lib/Viewer/Draggers/MeasureLineDragger/MeasureUtils.d.ts +19 -0
  40. package/lib/Viewer/Draggers/MeasureLineDragger/index.d.ts +23 -0
  41. package/lib/Viewer/Draggers/OdBaseCuttingPlaneDragger.d.ts +26 -0
  42. package/lib/Viewer/Draggers/OdCuttingPlaneXAxisDragger.d.ts +7 -0
  43. package/lib/Viewer/Draggers/OdCuttingPlaneYAxisDragger.d.ts +7 -0
  44. package/lib/Viewer/Draggers/OdCuttingPlaneZAxisDragger.d.ts +7 -0
  45. package/lib/Viewer/Draggers/OdOrbitDragger.d.ts +14 -0
  46. package/lib/Viewer/Draggers/OdPanDragger.d.ts +11 -0
  47. package/lib/Viewer/Draggers/OdZoomDragger.d.ts +11 -0
  48. package/lib/Viewer/Draggers/OdZoomWheelDragger.d.ts +10 -0
  49. package/lib/Viewer/Draggers/OdZoomWindowDragger/OdSelectionFrame.d.ts +18 -0
  50. package/lib/Viewer/Draggers/OdZoomWindowDragger/index.d.ts +13 -0
  51. package/lib/Viewer/Draggers/OdaLineDragger.d.ts +14 -0
  52. package/lib/Viewer/Draggers/OdaTextDragger.d.ts +15 -0
  53. package/lib/Viewer/Draggers/OdaWalkDragger.d.ts +29 -0
  54. package/lib/Viewer/Draggers/OrbitAroundBuildingDragger.d.ts +18 -0
  55. package/lib/Viewer/Loaders/BaseLoader.d.ts +10 -0
  56. package/lib/Viewer/Loaders/LoaderFactory.d.ts +10 -0
  57. package/lib/Viewer/Loaders/TCSLoader.d.ts +4 -0
  58. package/lib/Viewer/Loaders/UpdaterController.d.ts +14 -0
  59. package/lib/Viewer/Loaders/VsfXLoader.d.ts +4 -0
  60. package/lib/Viewer/Loaders/VsfXPartialLoader.d.ts +4 -0
  61. package/lib/Viewer/Loaders/VsfXStreamingLoader.d.ts +4 -0
  62. package/lib/Viewer/Markup/Api/IMarkupArrow.d.ts +21 -0
  63. package/lib/Viewer/Markup/Api/IMarkupCloud.d.ts +14 -0
  64. package/lib/Viewer/Markup/Api/IMarkupColorable.d.ts +4 -0
  65. package/lib/Viewer/Markup/Api/IMarkupEllipse.d.ts +14 -0
  66. package/lib/Viewer/Markup/Api/IMarkupImage.d.ts +14 -0
  67. package/lib/Viewer/Markup/Api/IMarkupLine.d.ts +12 -0
  68. package/lib/Viewer/Markup/Api/IMarkupObject.d.ts +11 -0
  69. package/lib/Viewer/Markup/Api/IMarkupRectangle.d.ts +14 -0
  70. package/lib/Viewer/Markup/Api/IMarkupText.d.ts +12 -0
  71. package/lib/Viewer/Markup/Api/Impl/Konva/KonvaArrow.d.ts +46 -0
  72. package/lib/Viewer/Markup/Api/Impl/Konva/KonvaCloud.d.ts +35 -0
  73. package/lib/Viewer/Markup/Api/Impl/Konva/KonvaEllipse.d.ts +40 -0
  74. package/lib/Viewer/Markup/Api/Impl/Konva/KonvaImage.d.ts +36 -0
  75. package/lib/Viewer/Markup/Api/Impl/Konva/KonvaLine.d.ts +36 -0
  76. package/lib/Viewer/Markup/Api/Impl/Konva/KonvaRectangle.d.ts +38 -0
  77. package/lib/Viewer/Markup/Api/Impl/Konva/KonvaText.d.ts +37 -0
  78. package/lib/Viewer/Markup/IMarkup.d.ts +39 -0
  79. package/lib/Viewer/Markup/Impl/Konva/KonvaMarkup.d.ts +70 -0
  80. package/lib/Viewer/Markup/Impl/Konva/MarkupColor.d.ts +18 -0
  81. package/lib/Viewer/Markup/Impl/Visualize/VisualizeMarkup.d.ts +33 -0
  82. package/lib/Viewer/Markup/MarkupFactory.d.ts +6 -0
  83. package/lib/Viewer/Viewer.d.ts +346 -0
  84. package/lib/Viewer/utils.d.ts +3 -0
  85. package/lib/index.d.ts +3 -0
  86. package/package.json +44 -0
  87. package/src/Viewer/Commands/ApplyModelTransform.ts +69 -0
  88. package/src/Viewer/Commands/ClearMarkup.ts +28 -0
  89. package/src/Viewer/Commands/ClearSlices.ts +27 -0
  90. package/src/Viewer/Commands/CreatePreview.ts +33 -0
  91. package/src/Viewer/Commands/Explode.ts +38 -0
  92. package/src/Viewer/Commands/GetDefaultViewPositions.ts +36 -0
  93. package/src/Viewer/Commands/GetModels.ts +43 -0
  94. package/src/Viewer/Commands/GetSelected.ts +58 -0
  95. package/src/Viewer/Commands/HideSelected.ts +37 -0
  96. package/src/Viewer/Commands/IsolateSelected.ts +37 -0
  97. package/src/Viewer/Commands/RegenerateAll.ts +37 -0
  98. package/src/Viewer/Commands/ResetView.ts +43 -0
  99. package/src/Viewer/Commands/SelectModel.ts +52 -0
  100. package/src/Viewer/Commands/SetActiveDragger.ts +29 -0
  101. package/src/Viewer/Commands/SetDefaultViewPosition.ts +50 -0
  102. package/src/Viewer/Commands/SetMarkupColor.ts +29 -0
  103. package/src/Viewer/Commands/SetSelected.ts +47 -0
  104. package/src/Viewer/Commands/ShowAll.ts +37 -0
  105. package/src/Viewer/Commands/Unselect.ts +37 -0
  106. package/src/Viewer/Commands/ZoomToExtents.ts +43 -0
  107. package/src/Viewer/Commands/ZoomToObjects.ts +47 -0
  108. package/src/Viewer/Commands/ZoomToSelected.ts +39 -0
  109. package/src/Viewer/Commands/index.ts +45 -0
  110. package/src/Viewer/Draggers/Actions/OrbitAction.ts +250 -0
  111. package/src/Viewer/Draggers/Actions/PanAction.ts +102 -0
  112. package/src/Viewer/Draggers/Actions/ZoomAction.ts +45 -0
  113. package/src/Viewer/Draggers/Common/Geometry.ts +152 -0
  114. package/src/Viewer/Draggers/Common/GestureManager.ts +263 -0
  115. package/src/Viewer/Draggers/Common/OdBaseDragger.ts +270 -0
  116. package/src/Viewer/Draggers/Common/OdaGeAction.ts +146 -0
  117. package/src/Viewer/Draggers/MeasureLineDragger/MeasureLineItem.ts +248 -0
  118. package/src/Viewer/Draggers/MeasureLineDragger/MeasureUtils.ts +182 -0
  119. package/src/Viewer/Draggers/MeasureLineDragger/index.ts +166 -0
  120. package/src/Viewer/Draggers/OdBaseCuttingPlaneDragger.ts +182 -0
  121. package/src/Viewer/Draggers/OdCuttingPlaneXAxisDragger.ts +53 -0
  122. package/src/Viewer/Draggers/OdCuttingPlaneYAxisDragger.ts +53 -0
  123. package/src/Viewer/Draggers/OdCuttingPlaneZAxisDragger.ts +53 -0
  124. package/src/Viewer/Draggers/OdOrbitDragger.ts +70 -0
  125. package/src/Viewer/Draggers/OdPanDragger.ts +62 -0
  126. package/src/Viewer/Draggers/OdZoomDragger.ts +59 -0
  127. package/src/Viewer/Draggers/OdZoomWheelDragger.ts +103 -0
  128. package/src/Viewer/Draggers/OdZoomWindowDragger/OdSelectionFrame.ts +123 -0
  129. package/src/Viewer/Draggers/OdZoomWindowDragger/index.ts +75 -0
  130. package/src/Viewer/Draggers/OdaLineDragger.ts +80 -0
  131. package/src/Viewer/Draggers/OdaTextDragger.ts +118 -0
  132. package/src/Viewer/Draggers/OdaWalkDragger.ts +278 -0
  133. package/src/Viewer/Draggers/OrbitAroundBuildingDragger.ts +184 -0
  134. package/src/Viewer/Loaders/BaseLoader.ts +40 -0
  135. package/src/Viewer/Loaders/LoaderFactory.ts +48 -0
  136. package/src/Viewer/Loaders/TCSLoader.ts +82 -0
  137. package/src/Viewer/Loaders/UpdaterController.ts +36 -0
  138. package/src/Viewer/Loaders/VsfXLoader.ts +65 -0
  139. package/src/Viewer/Loaders/VsfXPartialLoader.ts +208 -0
  140. package/src/Viewer/Loaders/VsfXStreamingLoader.ts +87 -0
  141. package/src/Viewer/Markup/Api/IMarkupArrow.ts +12 -0
  142. package/src/Viewer/Markup/Api/IMarkupCloud.ts +15 -0
  143. package/src/Viewer/Markup/Api/IMarkupColorable.ts +4 -0
  144. package/src/Viewer/Markup/Api/IMarkupEllipse.ts +15 -0
  145. package/src/Viewer/Markup/Api/IMarkupImage.ts +15 -0
  146. package/src/Viewer/Markup/Api/IMarkupLine.ts +13 -0
  147. package/src/Viewer/Markup/Api/IMarkupObject.ts +15 -0
  148. package/src/Viewer/Markup/Api/IMarkupRectangle.ts +15 -0
  149. package/src/Viewer/Markup/Api/IMarkupText.ts +12 -0
  150. package/src/Viewer/Markup/Api/Impl/Konva/KonvaArrow.ts +117 -0
  151. package/src/Viewer/Markup/Api/Impl/Konva/KonvaCloud.ts +208 -0
  152. package/src/Viewer/Markup/Api/Impl/Konva/KonvaEllipse.ts +118 -0
  153. package/src/Viewer/Markup/Api/Impl/Konva/KonvaImage.ts +123 -0
  154. package/src/Viewer/Markup/Api/Impl/Konva/KonvaLine.ts +131 -0
  155. package/src/Viewer/Markup/Api/Impl/Konva/KonvaRectangle.ts +119 -0
  156. package/src/Viewer/Markup/Api/Impl/Konva/KonvaText.ts +110 -0
  157. package/src/Viewer/Markup/IMarkup.ts +42 -0
  158. package/src/Viewer/Markup/Impl/Konva/KonvaMarkup.ts +1144 -0
  159. package/src/Viewer/Markup/Impl/Konva/MarkupColor.ts +39 -0
  160. package/src/Viewer/Markup/Impl/Visualize/VisualizeMarkup.ts +229 -0
  161. package/src/Viewer/Markup/MarkupFactory.ts +32 -0
  162. package/src/Viewer/Viewer.ts +1183 -0
  163. package/src/Viewer/utils.ts +74 -0
  164. package/src/index.ts +26 -0
@@ -0,0 +1,47 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2002-2023, Open Design Alliance (the "Alliance").
3
+ // All rights reserved.
4
+ //
5
+ // This software and its documentation and related materials are owned by
6
+ // the Alliance. The software may only be incorporated into application
7
+ // programs owned by members of the Alliance, subject to a signed
8
+ // Membership Agreement and Supplemental Software License Agreement with the
9
+ // Alliance. The structure and organization of this software are the valuable
10
+ // trade secrets of the Alliance and its suppliers. The software is also
11
+ // protected by copyright law and international treaty provisions. Application
12
+ // programs incorporating this software must include the following statement
13
+ // with their copyright notices:
14
+ //
15
+ // This application incorporates Open Design Alliance software pursuant to a
16
+ // license agreement with Open Design Alliance.
17
+ // Open Design Alliance Copyright (C) 2002-2021 by Open Design Alliance.
18
+ // All rights reserved.
19
+ //
20
+ // By use of this software, its documentation or related materials, you
21
+ // acknowledge and accept the above terms.
22
+ ///////////////////////////////////////////////////////////////////////////////
23
+
24
+ import { commands } from "@inweb/viewer-core";
25
+ import { Viewer } from "../Viewer";
26
+
27
+ function zoomToObjects(viewer: Viewer, handles: string[] = []): void {
28
+ if (!viewer.visualizeJs) return;
29
+
30
+ const visLib = viewer.visLib();
31
+ const visViewer = viewer.visViewer();
32
+
33
+ const selectionSet = new visLib.OdTvSelectionSet();
34
+ handles.forEach((handle) => {
35
+ const entityId = visViewer.getEntityByOriginalHandle(handle + "");
36
+ if (!entityId.isNull()) selectionSet.appendEntity(entityId);
37
+ });
38
+
39
+ visViewer.zoomToObjects?.(selectionSet);
40
+
41
+ viewer.update();
42
+ viewer.emitEvent({ type: "zoom" });
43
+
44
+ selectionSet.delete();
45
+ }
46
+
47
+ commands("VisualizeJS").registerCommand("zoomToObjects", zoomToObjects);
@@ -0,0 +1,39 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2002-2023, Open Design Alliance (the "Alliance").
3
+ // All rights reserved.
4
+ //
5
+ // This software and its documentation and related materials are owned by
6
+ // the Alliance. The software may only be incorporated into application
7
+ // programs owned by members of the Alliance, subject to a signed
8
+ // Membership Agreement and Supplemental Software License Agreement with the
9
+ // Alliance. The structure and organization of this software are the valuable
10
+ // trade secrets of the Alliance and its suppliers. The software is also
11
+ // protected by copyright law and international treaty provisions. Application
12
+ // programs incorporating this software must include the following statement
13
+ // with their copyright notices:
14
+ //
15
+ // This application incorporates Open Design Alliance software pursuant to a
16
+ // license agreement with Open Design Alliance.
17
+ // Open Design Alliance Copyright (C) 2002-2021 by Open Design Alliance.
18
+ // All rights reserved.
19
+ //
20
+ // By use of this software, its documentation or related materials, you
21
+ // acknowledge and accept the above terms.
22
+ ///////////////////////////////////////////////////////////////////////////////
23
+
24
+ import { commands } from "@inweb/viewer-core";
25
+ import { Viewer } from "../Viewer";
26
+
27
+ function zoomToSelected(viewer: Viewer): void {
28
+ if (!viewer.visualizeJs) return;
29
+
30
+ const visViewer = viewer.visViewer();
31
+
32
+ const selectionSet = visViewer.getSelected();
33
+ visViewer.zoomToObjects?.(selectionSet);
34
+
35
+ viewer.update();
36
+ viewer.emitEvent({ type: "zoom" });
37
+ }
38
+
39
+ commands("VisualizeJS").registerCommand("zoomToSelected", zoomToSelected);
@@ -0,0 +1,45 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2002-2023, Open Design Alliance (the "Alliance").
3
+ // All rights reserved.
4
+ //
5
+ // This software and its documentation and related materials are owned by
6
+ // the Alliance. The software may only be incorporated into application
7
+ // programs owned by members of the Alliance, subject to a signed
8
+ // Membership Agreement and Supplemental Software License Agreement with the
9
+ // Alliance. The structure and organization of this software are the valuable
10
+ // trade secrets of the Alliance and its suppliers. The software is also
11
+ // protected by copyright law and international treaty provisions. Application
12
+ // programs incorporating this software must include the following statement
13
+ // with their copyright notices:
14
+ //
15
+ // This application incorporates Open Design Alliance software pursuant to a
16
+ // license agreement with Open Design Alliance.
17
+ // Open Design Alliance Copyright (C) 2002-2021 by Open Design Alliance.
18
+ // All rights reserved.
19
+ //
20
+ // By use of this software, its documentation or related materials, you
21
+ // acknowledge and accept the above terms.
22
+ ///////////////////////////////////////////////////////////////////////////////
23
+
24
+ import "./ApplyModelTransform";
25
+ import "./ClearMarkup";
26
+ import "./ClearSlices";
27
+ import "./CreatePreview";
28
+ import "./Explode";
29
+ import "./GetDefaultViewPositions";
30
+ import "./GetModels";
31
+ import "./GetSelected";
32
+ import "./HideSelected";
33
+ import "./IsolateSelected";
34
+ import "./RegenerateAll";
35
+ import "./ResetView";
36
+ import "./SelectModel";
37
+ import "./SetActiveDragger";
38
+ import "./SetDefaultViewPosition";
39
+ import "./SetMarkupColor";
40
+ import "./SetSelected";
41
+ import "./ShowAll";
42
+ import "./Unselect";
43
+ import "./ZoomToExtents";
44
+ import "./ZoomToObjects";
45
+ import "./ZoomToSelected";
@@ -0,0 +1,250 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2002-2021, Open Design Alliance (the "Alliance").
3
+ // All rights reserved.
4
+ //
5
+ // This software and its documentation and related materials are owned by
6
+ // the Alliance. The software may only be incorporated into application
7
+ // programs owned by members of the Alliance, subject to a signed
8
+ // Membership Agreement and Supplemental Software License Agreement with the
9
+ // Alliance. The structure and organization of this software are the valuable
10
+ // trade secrets of the Alliance and its suppliers. The software is also
11
+ // protected by copyright law and international treaty provisions. Application
12
+ // programs incorporating this software must include the following statement
13
+ // with their copyright notices:
14
+ //
15
+ // This application incorporates Open Design Alliance software pursuant to a
16
+ // license agreement with Open Design Alliance.
17
+ // Open Design Alliance Copyright (C) 2002-2021 by Open Design Alliance.
18
+ // All rights reserved.
19
+ //
20
+ // By use of this software, its documentation or related materials, you
21
+ // acknowledge and accept the above terms.
22
+ ///////////////////////////////////////////////////////////////////////////////
23
+
24
+ import { Point2d, Point3d, Vector3d } from "../Common/Geometry";
25
+ import { Viewer } from "../../Viewer";
26
+
27
+ export class OrbitAction {
28
+ private _m_module: any;
29
+ private _subject: Viewer;
30
+ private _beginInteractivity: () => void;
31
+ private _endInteractivity: () => void;
32
+ private m_viewCenter: any;
33
+ private m_startPoint: Point2d;
34
+
35
+ constructor(m_module: any, subject: Viewer, beginInteractivity: () => void, endInteractivity: () => void) {
36
+ this._m_module = m_module;
37
+ this._subject = subject;
38
+ this._beginInteractivity = beginInteractivity;
39
+ this._endInteractivity = endInteractivity;
40
+ }
41
+
42
+ public beginAction(x: number, y: number) {
43
+ this.m_viewCenter = this.getCenter();
44
+ this.m_startPoint = { x, y };
45
+
46
+ const view = this.getViewer().activeView;
47
+
48
+ view.delete();
49
+ this._beginInteractivity();
50
+ }
51
+
52
+ public action(x: number, y: number) {
53
+ const view = this.getViewer().activeView;
54
+
55
+ const corners = view.vportRect;
56
+
57
+ const size = Math.max(Math.abs(corners[2] - corners[0]), Math.abs(corners[3] - corners[1]));
58
+
59
+ const distX = ((this.m_startPoint.x - x) * Math.PI) / size;
60
+ const distY = ((this.m_startPoint.y - y) * Math.PI) / size;
61
+
62
+ this.m_startPoint.x = x;
63
+ this.m_startPoint.y = y;
64
+
65
+ const xOrbit = distY;
66
+ const yOrbit = distX;
67
+
68
+ const viewParams = {
69
+ position: view.viewPosition,
70
+ target: view.viewTarget,
71
+ upVector: view.upVector,
72
+ viewFieldWidth: view.viewFieldWidth,
73
+ viewFieldHeight: view.viewFieldHeight,
74
+ perspective: view.perspective,
75
+ };
76
+
77
+ view.delete();
78
+
79
+ const sideVector = this.getSideVector(viewParams);
80
+
81
+ if (xOrbit !== 0.0) {
82
+ this.calculateXOrbit(viewParams, -xOrbit, sideVector);
83
+ }
84
+
85
+ if (yOrbit !== 0.0) {
86
+ this.calculateYOrbit(viewParams, yOrbit, sideVector);
87
+ }
88
+
89
+ sideVector.delete();
90
+
91
+ const extView = this.getViewer().getActiveTvExtendedView();
92
+
93
+ extView.setView(
94
+ viewParams.position,
95
+ viewParams.target,
96
+ viewParams.upVector,
97
+ viewParams.viewFieldWidth,
98
+ viewParams.viewFieldHeight,
99
+ viewParams.perspective
100
+ );
101
+ extView.delete();
102
+
103
+ this._subject.activeDragger()?.updatePreview();
104
+ }
105
+
106
+ public endAction() {
107
+ this._endInteractivity();
108
+ }
109
+
110
+ private getSideVector(viewParams: any): any {
111
+ const pUpV = this.toVector(viewParams.upVector);
112
+ const pTarget = this.toPoint(viewParams.target);
113
+ const pPosition = this.toPoint(viewParams.position);
114
+
115
+ const direct = pTarget.sub(pPosition);
116
+ const vDirect = direct.asVector();
117
+
118
+ const vCross = pUpV.crossProduct(vDirect);
119
+ const sideVector = vCross.normalize();
120
+
121
+ this.deleteAll([direct, pUpV, pTarget, pPosition, vDirect, vCross]);
122
+
123
+ return sideVector;
124
+ }
125
+
126
+ private calculateXOrbit(viewParams: any, delta: number, sideVector: Vector3d): void {
127
+ {
128
+ const pPoint = this.toPoint(viewParams.position);
129
+ const pCenter = this.toPoint(this.m_viewCenter);
130
+
131
+ const rotatePoint = pPoint.rotateByBasePoint(delta, sideVector, pCenter);
132
+ viewParams.position = rotatePoint.toArray();
133
+
134
+ this.deleteAll([pPoint, pCenter, rotatePoint]);
135
+ }
136
+
137
+ {
138
+ const pTarget = this.toPoint(viewParams.target);
139
+ const pCenter = this.toPoint(this.m_viewCenter);
140
+
141
+ const rotatePoint = pTarget.rotateByBasePoint(delta, sideVector, pCenter);
142
+ viewParams.target = rotatePoint.toArray();
143
+
144
+ this.deleteAll([pTarget, pCenter, rotatePoint]);
145
+ }
146
+
147
+ {
148
+ const pPoint = this.toPoint(viewParams.position);
149
+ const pTarget = this.toPoint(viewParams.target);
150
+ const pCenter = this.toPoint(this.m_viewCenter);
151
+
152
+ const pUp = pTarget.sub(pPoint);
153
+ const vUp = pUp.asVector();
154
+
155
+ const crossProduct = vUp.crossProduct(sideVector);
156
+ const crossProductNormal = crossProduct.normalize();
157
+
158
+ viewParams.upVector = crossProductNormal.toArray();
159
+
160
+ this.deleteAll([pPoint, pTarget, pCenter, pUp, vUp, crossProduct, crossProductNormal]);
161
+ }
162
+ }
163
+
164
+ private calculateYOrbit(viewParams: any, delta: number, sideVector: any): void {
165
+ {
166
+ const pPoint = this.toPoint(viewParams.position);
167
+ const pCenter = this.toPoint(this.m_viewCenter);
168
+
169
+ const zAxis = this.toVector(this._m_module.Vector3d.kZAxis);
170
+
171
+ const rotatePoint = pPoint.rotateByBasePoint(delta, zAxis, pCenter);
172
+ viewParams.position = rotatePoint.toArray();
173
+
174
+ this.deleteAll([zAxis, pPoint, pCenter, rotatePoint]);
175
+ }
176
+
177
+ {
178
+ const pTarget = this.toPoint(viewParams.target);
179
+ const pCenter = this.toPoint(this.m_viewCenter);
180
+
181
+ const zAxis = this.toVector(this._m_module.Vector3d.kZAxis);
182
+
183
+ const rotatePoint = pTarget.rotateByBasePoint(delta, zAxis, pCenter);
184
+ viewParams.target = rotatePoint.toArray();
185
+
186
+ this.deleteAll([zAxis, pTarget, pCenter, rotatePoint]);
187
+ }
188
+
189
+ {
190
+ const zAxis = this.toVector(this._m_module.Vector3d.kZAxis);
191
+ const pTarget = this.toPoint(viewParams.target);
192
+ const pPoint = this.toPoint(viewParams.position);
193
+
194
+ const side = sideVector.rotateBy(delta, zAxis);
195
+
196
+ const pUp = pTarget.sub(pPoint);
197
+ const vUp = pUp.asVector();
198
+
199
+ const cross = vUp.crossProduct(side);
200
+ const crossNormal = cross.normalize();
201
+
202
+ viewParams.upVector = crossNormal.toArray();
203
+
204
+ this.deleteAll([zAxis, pTarget, pPoint, side, pUp, vUp, cross, crossNormal]);
205
+ }
206
+ }
207
+
208
+ private getCenter(): any {
209
+ const viewer = this.getViewer();
210
+ let center;
211
+
212
+ const pSet = viewer.getSelected();
213
+ if (!pSet.isNull() && pSet.numItems() !== 0) {
214
+ const itr = pSet.getIterator();
215
+ let ext, entId, extSelected;
216
+ for (; !itr.done(); itr.step()) {
217
+ entId = itr.getEntity();
218
+ ext = entId.getWCSExtents();
219
+ if (extSelected) extSelected.addExt(ext);
220
+ else extSelected = ext;
221
+ }
222
+ center = extSelected.center();
223
+
224
+ extSelected.delete();
225
+ itr.delete();
226
+ } else {
227
+ center = viewer.getActiveExtents().center();
228
+ }
229
+
230
+ return center;
231
+ }
232
+
233
+ private getViewer(): any {
234
+ return this._m_module.getViewer();
235
+ }
236
+
237
+ private toVector(geVector): Vector3d {
238
+ return this._m_module.Vector3d.createFromArray(geVector);
239
+ }
240
+
241
+ private toPoint(gePoint: number[]): Point3d {
242
+ return this._m_module.Point3d.createFromArray(gePoint);
243
+ }
244
+
245
+ private deleteAll(objects): void {
246
+ for (const obj of objects) {
247
+ obj?.delete?.();
248
+ }
249
+ }
250
+ }
@@ -0,0 +1,102 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2002-2021, Open Design Alliance (the "Alliance").
3
+ // All rights reserved.
4
+ //
5
+ // This software and its documentation and related materials are owned by
6
+ // the Alliance. The software may only be incorporated into application
7
+ // programs owned by members of the Alliance, subject to a signed
8
+ // Membership Agreement and Supplemental Software License Agreement with the
9
+ // Alliance. The structure and organization of this software are the valuable
10
+ // trade secrets of the Alliance and its suppliers. The software is also
11
+ // protected by copyright law and international treaty provisions. Application
12
+ // programs incorporating this software must include the following statement
13
+ // with their copyright notices:
14
+ //
15
+ // This application incorporates Open Design Alliance software pursuant to a
16
+ // license agreement with Open Design Alliance.
17
+ // Open Design Alliance Copyright (C) 2002-2021 by Open Design Alliance.
18
+ // All rights reserved.
19
+ //
20
+ // By use of this software, its documentation or related materials, you
21
+ // acknowledge and accept the above terms.
22
+ ///////////////////////////////////////////////////////////////////////////////
23
+
24
+ import { Point2d, Point3d } from "../Common/Geometry";
25
+ import { ViewParams } from "../Common/OdaGeAction";
26
+ import { Viewer } from "../../Viewer";
27
+
28
+ export class PanAction {
29
+ private _m_module: any;
30
+ private _subject: Viewer;
31
+ private _m_start: Point3d;
32
+ private _deltaScreenPosition: Point2d;
33
+ private _beginInteractivity: () => void;
34
+ private _endInteractivity: () => void;
35
+ private _getViewParams: () => ViewParams;
36
+ private _setViewParams: (params: ViewParams) => void;
37
+
38
+ constructor(
39
+ m_module: any,
40
+ subject: Viewer,
41
+ beginInteractivity: () => void,
42
+ endInteractivity: () => void,
43
+ getViewParams: () => ViewParams,
44
+ setViewParams: (params: ViewParams) => void
45
+ ) {
46
+ this._m_module = m_module;
47
+ this._subject = subject;
48
+ this._beginInteractivity = beginInteractivity;
49
+ this._endInteractivity = endInteractivity;
50
+ this._getViewParams = getViewParams;
51
+ this._setViewParams = setViewParams;
52
+ }
53
+
54
+ public beginAction(x: number, y: number) {
55
+ this._m_start = this.screenToWorld(x, y);
56
+ this._deltaScreenPosition = { x, y };
57
+ this._beginInteractivity();
58
+ }
59
+
60
+ public action(x: number, y: number) {
61
+ const { Vector3d } = this._m_module;
62
+ const params = this._getViewParams();
63
+ const pt = this.screenToWorld(x, y);
64
+
65
+ const ptSub = this._m_start.sub(pt);
66
+ const delta = ptSub.asVector();
67
+
68
+ const target = Vector3d.createFromArray(params.target);
69
+ const targetWithDelta = target.add(delta);
70
+ params.target = targetWithDelta.toArray();
71
+
72
+ const position = Vector3d.createFromArray(params.position);
73
+ const positionWithDelta = position.add(delta);
74
+ params.position = positionWithDelta.toArray();
75
+
76
+ this._setViewParams(params);
77
+ target.delete();
78
+
79
+ targetWithDelta.delete();
80
+ position.delete();
81
+ positionWithDelta.delete();
82
+
83
+ this._subject.activeDragger()?.updatePreview();
84
+ this._subject.emitEvent({
85
+ type: "pan",
86
+ x,
87
+ y,
88
+ dX: x - this._deltaScreenPosition.x,
89
+ dY: y - this._deltaScreenPosition.y,
90
+ });
91
+
92
+ this._deltaScreenPosition = { x, y };
93
+ }
94
+
95
+ public endAction() {
96
+ this._endInteractivity();
97
+ }
98
+
99
+ private screenToWorld(x: number, y: number): Point3d {
100
+ return this._m_module.Point3d.createFromArray(this._m_module.getViewer().screenToWorld(x, y));
101
+ }
102
+ }
@@ -0,0 +1,45 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2002-2021, Open Design Alliance (the "Alliance").
3
+ // All rights reserved.
4
+ //
5
+ // This software and its documentation and related materials are owned by
6
+ // the Alliance. The software may only be incorporated into application
7
+ // programs owned by members of the Alliance, subject to a signed
8
+ // Membership Agreement and Supplemental Software License Agreement with the
9
+ // Alliance. The structure and organization of this software are the valuable
10
+ // trade secrets of the Alliance and its suppliers. The software is also
11
+ // protected by copyright law and international treaty provisions. Application
12
+ // programs incorporating this software must include the following statement
13
+ // with their copyright notices:
14
+ //
15
+ // This application incorporates Open Design Alliance software pursuant to a
16
+ // license agreement with Open Design Alliance.
17
+ // Open Design Alliance Copyright (C) 2002-2021 by Open Design Alliance.
18
+ // All rights reserved.
19
+ //
20
+ // By use of this software, its documentation or related materials, you
21
+ // acknowledge and accept the above terms.
22
+ ///////////////////////////////////////////////////////////////////////////////
23
+
24
+ import { Viewer } from "../../Viewer";
25
+
26
+ export class ZoomAction {
27
+ private _m_module: any;
28
+ private _subject: Viewer;
29
+
30
+ constructor(m_module: any, subject: Viewer) {
31
+ this._m_module = m_module;
32
+ this._subject = subject;
33
+ }
34
+
35
+ public action(x: number, y: number, zoomFactor: number) {
36
+ const viewer = this._m_module.getViewer();
37
+ viewer.zoomAt(zoomFactor, x, y);
38
+
39
+ this._subject.activeDragger()?.updatePreview();
40
+ this._subject.emitEvent({
41
+ type: "zoomat",
42
+ data: zoomFactor,
43
+ });
44
+ }
45
+ }
@@ -0,0 +1,152 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2002-2021, Open Design Alliance (the "Alliance").
3
+ // All rights reserved.
4
+ //
5
+ // This software and its documentation and related materials are owned by
6
+ // the Alliance. The software may only be incorporated into application
7
+ // programs owned by members of the Alliance, subject to a signed
8
+ // Membership Agreement and Supplemental Software License Agreement with the
9
+ // Alliance. The structure and organization of this software are the valuable
10
+ // trade secrets of the Alliance and its suppliers. The software is also
11
+ // protected by copyright law and international treaty provisions. Application
12
+ // programs incorporating this software must include the following statement
13
+ // with their copyright notices:
14
+ //
15
+ // This application incorporates Open Design Alliance software pursuant to a
16
+ // license agreement with Open Design Alliance.
17
+ // Open Design Alliance Copyright (C) 2002-2021 by Open Design Alliance.
18
+ // All rights reserved.
19
+ //
20
+ // By use of this software, its documentation or related materials, you
21
+ // acknowledge and accept the above terms.
22
+ ///////////////////////////////////////////////////////////////////////////////
23
+ export interface Point2d {
24
+ x: number;
25
+ y: number;
26
+ }
27
+
28
+ export type Vector3 = [x: number, y: number, z: number];
29
+
30
+ export interface Point3d {
31
+ add(point: Point3d);
32
+ asVector(): Vector3d;
33
+ distanceTo(point: Point3d);
34
+ rotateBy(angle: number, vector: Vector3d);
35
+ rotateByBasePoint(angle: number, vector: Vector3d, basePoint: Point3d);
36
+ scaleBy(factor: number, basePoint: Point3d);
37
+ set(x: number, y: number, z: number);
38
+ setToProduct(matrix: any, point: Point3d);
39
+ setToSum(point: Point3d, vector: Vector3d);
40
+ sub(point: Point3d): Point3d;
41
+ toArray(): number[];
42
+ transformBy(matrix: any);
43
+ translate(vector: Vector3d);
44
+ get x(): number;
45
+ set x(x: number);
46
+ get y(): number;
47
+ set y(y: number);
48
+ get z(): number;
49
+ set z(z: number);
50
+ }
51
+
52
+ export interface Vector3d {
53
+ add(vector: Vector3d);
54
+ angleTo(vector: Vector3d);
55
+ angleToWithRef(vector: Vector3d, ref: Vector3d);
56
+ asPoint(): Point3d;
57
+ crossProduct(vector: Vector3d);
58
+ dotProduct(vector: Vector3d);
59
+ isEqualTo(vector: Vector3d): boolean;
60
+ length(): number;
61
+ lengthSqrd(): number;
62
+ mirror();
63
+ negate();
64
+ normal();
65
+ normalize();
66
+ rotateBy(angle: number, vector: Vector3d);
67
+ set(x: number, y: number, z: number);
68
+ setLength(length: number);
69
+ setToProduct(vector: Vector3d, scale: number);
70
+ setToSum(vector1: Vector3d, vector2: Vector3d);
71
+ sub(vector: Vector3d);
72
+ toArray(): number[];
73
+ transformBy(matrix: any);
74
+ get x(): number;
75
+ set x(x: number);
76
+ get y(): number;
77
+ set y(y: number);
78
+ get z(): number;
79
+ set z(z: number);
80
+ }
81
+
82
+ export interface Matrix3d {
83
+ det(): number;
84
+ get(row: number, col: number): number;
85
+ getCoordSystem(origin: Point3d, xAxis: Vector3d, yAxis: Vector3d, zAxis: Vector3d);
86
+ getCsOrigin(): Point3d;
87
+ getCsXAxis(): Vector3d;
88
+ getCsYAxis(): Vector3d;
89
+ getCsZAxis(): Vector3d;
90
+ invert(): Matrix3d;
91
+ isEqualTo();
92
+ isPerspective();
93
+ isScaledOrtho();
94
+ isSingular();
95
+ isUniScaledOrtho();
96
+ norm(): number;
97
+ postMultBy(rightSide: Matrix3d): Matrix3d;
98
+ preMultBy(leftSide: Matrix3d): Matrix3d;
99
+ scale();
100
+ set(row: number, col: number, value: number);
101
+ setCoordSystem(origin: Point3d, xAxis: Vector3d, yAxis: Vector3d, zAxis: Vector3d): Matrix3d;
102
+ setToAlignCoordSys(
103
+ fromOrigin: Point3d,
104
+ fromXAxis: Vector3d,
105
+ fromYAxis: Vector3d,
106
+ fromZAxis: Vector3d,
107
+ toOrigin: Point3d,
108
+ toXAxis: Vector3d,
109
+ toYAxis: Vector3d,
110
+ toZAxis: Vector3d
111
+ );
112
+ setToIdentity(): Matrix3d;
113
+ setToProduct(matrix1: Matrix3d, matrix2): Matrix3d;
114
+ setToProjection(projectionPlane: OdTvPlane, projectDir: Vector3d): Matrix3d;
115
+ setToRotation(angle: number, axis: Vector3, center: Point3d): Matrix3d;
116
+ setToScaling(arg0: any, arg1: any);
117
+ setToWorldToPlane(geVector3d: number[]);
118
+ setTranslation(vect: Vector3d);
119
+ transpose(): Matrix3d;
120
+ transposeIt(): Matrix3d;
121
+ validateZero(): void;
122
+ }
123
+
124
+ export interface OdTvPlane {
125
+ getOrigin();
126
+ getUAxis();
127
+ getVAxis();
128
+ normal();
129
+ set(point: number[], normal: OdTvVector);
130
+ set3ptr(uPnt: OdTvVector, origin: OdTvVector, vPnt: OdTvVector);
131
+ set4double(a: number, b: number, c: number, d: number);
132
+ setUV(origin: OdTvPoint, uAxis: OdTvPoint, vAxis: OdTvPoint);
133
+ }
134
+
135
+ export interface OdTvPoint {
136
+ setParam(controlPoints: any[]);
137
+ getParam(): any[];
138
+ getPointsCount(): number;
139
+ editPointsViaRange(startPos: number, points: any[]);
140
+ editPointsViaList(indPoints: any[], points: any[]);
141
+ setPointSize(value: number);
142
+ getPointSize(): number;
143
+ setPointColorsViaList(indPoints: any[], colors: any[]);
144
+ setPointColorsViaRange(indStart: number, nCount: number, colors: any[]);
145
+ getPointColor(ind: number): any;
146
+ setPointNormalsViaList(indPoints: any[], vectors: any[]);
147
+ setPointNormalsViaRange(indStart: number, vectors: any[]);
148
+ getPointNormal(ind: number);
149
+ }
150
+
151
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
152
+ export interface OdTvVector {}