@itwin/imodel-components-react 3.4.0-dev.48 → 3.4.0-dev.50

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 (342) hide show
  1. package/lib/cjs/imodel-components-react/UiIModelComponents.d.ts +28 -28
  2. package/lib/cjs/imodel-components-react/UiIModelComponents.js +79 -79
  3. package/lib/cjs/imodel-components-react/UiIModelComponents.js.map +1 -1
  4. package/lib/cjs/imodel-components-react/color/AlphaSlider.d.ts +36 -36
  5. package/lib/cjs/imodel-components-react/color/AlphaSlider.js +186 -186
  6. package/lib/cjs/imodel-components-react/color/AlphaSlider.js.map +1 -1
  7. package/lib/cjs/imodel-components-react/color/AlphaSlider.scss +63 -63
  8. package/lib/cjs/imodel-components-react/color/ColorPickerButton.d.ts +37 -37
  9. package/lib/cjs/imodel-components-react/color/ColorPickerButton.js +107 -107
  10. package/lib/cjs/imodel-components-react/color/ColorPickerButton.js.map +1 -1
  11. package/lib/cjs/imodel-components-react/color/ColorPickerButton.scss +91 -91
  12. package/lib/cjs/imodel-components-react/color/ColorPickerDialog.d.ts +23 -23
  13. package/lib/cjs/imodel-components-react/color/ColorPickerDialog.js +74 -74
  14. package/lib/cjs/imodel-components-react/color/ColorPickerDialog.js.map +1 -1
  15. package/lib/cjs/imodel-components-react/color/ColorPickerPanel.d.ts +21 -21
  16. package/lib/cjs/imodel-components-react/color/ColorPickerPanel.js +145 -145
  17. package/lib/cjs/imodel-components-react/color/ColorPickerPanel.js.map +1 -1
  18. package/lib/cjs/imodel-components-react/color/ColorPickerPanel.scss +93 -93
  19. package/lib/cjs/imodel-components-react/color/ColorPickerPopup.d.ts +44 -44
  20. package/lib/cjs/imodel-components-react/color/ColorPickerPopup.js +137 -137
  21. package/lib/cjs/imodel-components-react/color/ColorPickerPopup.js.map +1 -1
  22. package/lib/cjs/imodel-components-react/color/ColorPickerPopup.scss +64 -64
  23. package/lib/cjs/imodel-components-react/color/HueSlider.d.ts +22 -22
  24. package/lib/cjs/imodel-components-react/color/HueSlider.js +199 -199
  25. package/lib/cjs/imodel-components-react/color/HueSlider.js.map +1 -1
  26. package/lib/cjs/imodel-components-react/color/HueSlider.scss +61 -61
  27. package/lib/cjs/imodel-components-react/color/SaturationPicker.d.ts +20 -20
  28. package/lib/cjs/imodel-components-react/color/SaturationPicker.js +213 -213
  29. package/lib/cjs/imodel-components-react/color/SaturationPicker.js.map +1 -1
  30. package/lib/cjs/imodel-components-react/color/SaturationPicker.scss +35 -35
  31. package/lib/cjs/imodel-components-react/color/Swatch.d.ts +22 -22
  32. package/lib/cjs/imodel-components-react/color/Swatch.js +60 -60
  33. package/lib/cjs/imodel-components-react/color/Swatch.js.map +1 -1
  34. package/lib/cjs/imodel-components-react/color/Swatch.scss +23 -23
  35. package/lib/cjs/imodel-components-react/color/getCSSColorFromDef.d.ts +6 -6
  36. package/lib/cjs/imodel-components-react/color/getCSSColorFromDef.js +23 -23
  37. package/lib/cjs/imodel-components-react/color/getCSSColorFromDef.js.map +1 -1
  38. package/lib/cjs/imodel-components-react/editors/ColorEditor.d.ts +44 -44
  39. package/lib/cjs/imodel-components-react/editors/ColorEditor.js +151 -151
  40. package/lib/cjs/imodel-components-react/editors/ColorEditor.js.map +1 -1
  41. package/lib/cjs/imodel-components-react/editors/ColorEditor.scss +18 -18
  42. package/lib/cjs/imodel-components-react/editors/WeightEditor.d.ts +47 -47
  43. package/lib/cjs/imodel-components-react/editors/WeightEditor.js +160 -160
  44. package/lib/cjs/imodel-components-react/editors/WeightEditor.js.map +1 -1
  45. package/lib/cjs/imodel-components-react/editors/WeightEditor.scss +16 -16
  46. package/lib/cjs/imodel-components-react/inputs/QuantityInput.d.ts +25 -25
  47. package/lib/cjs/imodel-components-react/inputs/QuantityInput.js +96 -96
  48. package/lib/cjs/imodel-components-react/inputs/QuantityInput.js.map +1 -1
  49. package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.d.ts +44 -44
  50. package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.js +265 -265
  51. package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.js.map +1 -1
  52. package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.scss +107 -107
  53. package/lib/cjs/imodel-components-react/lineweight/Swatch.d.ts +33 -33
  54. package/lib/cjs/imodel-components-react/lineweight/Swatch.js +85 -85
  55. package/lib/cjs/imodel-components-react/lineweight/Swatch.js.map +1 -1
  56. package/lib/cjs/imodel-components-react/lineweight/Swatch.scss +48 -48
  57. package/lib/cjs/imodel-components-react/lineweight/WeightPickerButton.d.ts +60 -60
  58. package/lib/cjs/imodel-components-react/lineweight/WeightPickerButton.js +159 -159
  59. package/lib/cjs/imodel-components-react/lineweight/WeightPickerButton.js.map +1 -1
  60. package/lib/cjs/imodel-components-react/lineweight/WeightPickerButton.scss +52 -52
  61. package/lib/cjs/imodel-components-react/navigationaids/Cube.d.ts +45 -45
  62. package/lib/cjs/imodel-components-react/navigationaids/Cube.js +127 -127
  63. package/lib/cjs/imodel-components-react/navigationaids/Cube.js.map +1 -1
  64. package/lib/cjs/imodel-components-react/navigationaids/Cube.scss +19 -19
  65. package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.d.ts +174 -174
  66. package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.js +634 -634
  67. package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.js.map +1 -1
  68. package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.scss +180 -180
  69. package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.d.ts +145 -145
  70. package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.js +647 -647
  71. package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.js.map +1 -1
  72. package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.scss +133 -133
  73. package/lib/cjs/imodel-components-react/quantityformat/FormatPanel.d.ts +26 -26
  74. package/lib/cjs/imodel-components-react/quantityformat/FormatPanel.js +99 -99
  75. package/lib/cjs/imodel-components-react/quantityformat/FormatPanel.js.map +1 -1
  76. package/lib/cjs/imodel-components-react/quantityformat/FormatPanel.scss +64 -64
  77. package/lib/cjs/imodel-components-react/quantityformat/FormatPrecision.d.ts +17 -17
  78. package/lib/cjs/imodel-components-react/quantityformat/FormatPrecision.js +53 -53
  79. package/lib/cjs/imodel-components-react/quantityformat/FormatPrecision.js.map +1 -1
  80. package/lib/cjs/imodel-components-react/quantityformat/FormatSample.d.ts +18 -18
  81. package/lib/cjs/imodel-components-react/quantityformat/FormatSample.js +83 -83
  82. package/lib/cjs/imodel-components-react/quantityformat/FormatSample.js.map +1 -1
  83. package/lib/cjs/imodel-components-react/quantityformat/FormatType.d.ts +17 -17
  84. package/lib/cjs/imodel-components-react/quantityformat/FormatType.js +86 -86
  85. package/lib/cjs/imodel-components-react/quantityformat/FormatType.js.map +1 -1
  86. package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.d.ts +17 -17
  87. package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.js +109 -109
  88. package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.js.map +1 -1
  89. package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.d.ts +19 -19
  90. package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.js +133 -133
  91. package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.js.map +1 -1
  92. package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.d.ts +21 -21
  93. package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.js +184 -184
  94. package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.js.map +1 -1
  95. package/lib/cjs/imodel-components-react/quantityformat/QuantityFormatPanel.d.ts +22 -22
  96. package/lib/cjs/imodel-components-react/quantityformat/QuantityFormatPanel.js +154 -154
  97. package/lib/cjs/imodel-components-react/quantityformat/QuantityFormatPanel.js.map +1 -1
  98. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalPrecision.d.ts +17 -17
  99. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalPrecision.js +59 -59
  100. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalPrecision.js.map +1 -1
  101. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalSeparator.d.ts +17 -17
  102. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalSeparator.js +47 -47
  103. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalSeparator.js.map +1 -1
  104. package/lib/cjs/imodel-components-react/quantityformat/misc/FractionPrecision.d.ts +16 -16
  105. package/lib/cjs/imodel-components-react/quantityformat/misc/FractionPrecision.js +54 -54
  106. package/lib/cjs/imodel-components-react/quantityformat/misc/FractionPrecision.js.map +1 -1
  107. package/lib/cjs/imodel-components-react/quantityformat/misc/ScientificType.d.ts +18 -18
  108. package/lib/cjs/imodel-components-react/quantityformat/misc/ScientificType.js +48 -48
  109. package/lib/cjs/imodel-components-react/quantityformat/misc/ScientificType.js.map +1 -1
  110. package/lib/cjs/imodel-components-react/quantityformat/misc/SignOption.d.ts +17 -17
  111. package/lib/cjs/imodel-components-react/quantityformat/misc/SignOption.js +50 -50
  112. package/lib/cjs/imodel-components-react/quantityformat/misc/SignOption.js.map +1 -1
  113. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSeparatorSelector.d.ts +17 -17
  114. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js +58 -58
  115. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js.map +1 -1
  116. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSizeSelector.d.ts +17 -17
  117. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSizeSelector.js +47 -47
  118. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSizeSelector.js.map +1 -1
  119. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSelector.d.ts +17 -17
  120. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSelector.js +56 -56
  121. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSelector.js.map +1 -1
  122. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSeparator.d.ts +17 -17
  123. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSeparator.js +95 -95
  124. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSeparator.js.map +1 -1
  125. package/lib/cjs/imodel-components-react/quantityformat/misc/UnitDescr.d.ts +23 -23
  126. package/lib/cjs/imodel-components-react/quantityformat/misc/UnitDescr.js +119 -119
  127. package/lib/cjs/imodel-components-react/quantityformat/misc/UnitDescr.js.map +1 -1
  128. package/lib/cjs/imodel-components-react/timeline/BaseSolarDataProvider.d.ts +52 -52
  129. package/lib/cjs/imodel-components-react/timeline/BaseSolarDataProvider.js +143 -143
  130. package/lib/cjs/imodel-components-react/timeline/BaseSolarDataProvider.js.map +1 -1
  131. package/lib/cjs/imodel-components-react/timeline/BaseTimelineDataProvider.d.ts +31 -31
  132. package/lib/cjs/imodel-components-react/timeline/BaseTimelineDataProvider.js +69 -69
  133. package/lib/cjs/imodel-components-react/timeline/BaseTimelineDataProvider.js.map +1 -1
  134. package/lib/cjs/imodel-components-react/timeline/InlineEdit.d.ts +27 -27
  135. package/lib/cjs/imodel-components-react/timeline/InlineEdit.js +81 -81
  136. package/lib/cjs/imodel-components-react/timeline/InlineEdit.js.map +1 -1
  137. package/lib/cjs/imodel-components-react/timeline/InlineEdit.scss +26 -26
  138. package/lib/cjs/imodel-components-react/timeline/PlayerButton.d.ts +33 -33
  139. package/lib/cjs/imodel-components-react/timeline/PlayerButton.js +91 -91
  140. package/lib/cjs/imodel-components-react/timeline/PlayerButton.js.map +1 -1
  141. package/lib/cjs/imodel-components-react/timeline/PlayerButton.scss +25 -25
  142. package/lib/cjs/imodel-components-react/timeline/Scrubber.d.ts +54 -54
  143. package/lib/cjs/imodel-components-react/timeline/Scrubber.js +191 -191
  144. package/lib/cjs/imodel-components-react/timeline/Scrubber.js.map +1 -1
  145. package/lib/cjs/imodel-components-react/timeline/Scrubber.scss +106 -106
  146. package/lib/cjs/imodel-components-react/timeline/SolarTimeline.d.ts +77 -77
  147. package/lib/cjs/imodel-components-react/timeline/SolarTimeline.js +424 -424
  148. package/lib/cjs/imodel-components-react/timeline/SolarTimeline.js.map +1 -1
  149. package/lib/cjs/imodel-components-react/timeline/SolarTimeline.scss +357 -357
  150. package/lib/cjs/imodel-components-react/timeline/SpeedTimeline.d.ts +15 -15
  151. package/lib/cjs/imodel-components-react/timeline/SpeedTimeline.js +54 -54
  152. package/lib/cjs/imodel-components-react/timeline/SpeedTimeline.js.map +1 -1
  153. package/lib/cjs/imodel-components-react/timeline/SpeedTimeline.scss +39 -39
  154. package/lib/cjs/imodel-components-react/timeline/Timeline.scss +164 -164
  155. package/lib/cjs/imodel-components-react/timeline/TimelineComponent.d.ts +133 -133
  156. package/lib/cjs/imodel-components-react/timeline/TimelineComponent.js +358 -358
  157. package/lib/cjs/imodel-components-react/timeline/TimelineComponent.js.map +1 -1
  158. package/lib/cjs/imodel-components-react/timeline/TimelineComponent.scss +163 -163
  159. package/lib/cjs/imodel-components-react/timeline/interfaces.d.ts +174 -174
  160. package/lib/cjs/imodel-components-react/timeline/interfaces.js +45 -45
  161. package/lib/cjs/imodel-components-react/timeline/interfaces.js.map +1 -1
  162. package/lib/cjs/imodel-components-react/viewport/ViewportComponent.d.ts +42 -42
  163. package/lib/cjs/imodel-components-react/viewport/ViewportComponent.js +274 -274
  164. package/lib/cjs/imodel-components-react/viewport/ViewportComponent.js.map +1 -1
  165. package/lib/cjs/imodel-components-react/viewport/ViewportComponentEvents.d.ts +106 -106
  166. package/lib/cjs/imodel-components-react/viewport/ViewportComponentEvents.js +105 -105
  167. package/lib/cjs/imodel-components-react/viewport/ViewportComponentEvents.js.map +1 -1
  168. package/lib/cjs/imodel-components-react.d.ts +82 -82
  169. package/lib/cjs/imodel-components-react.js +101 -101
  170. package/lib/cjs/imodel-components-react.js.map +1 -1
  171. package/lib/esm/imodel-components-react/UiIModelComponents.d.ts +28 -28
  172. package/lib/esm/imodel-components-react/UiIModelComponents.js +75 -75
  173. package/lib/esm/imodel-components-react/UiIModelComponents.js.map +1 -1
  174. package/lib/esm/imodel-components-react/color/AlphaSlider.d.ts +36 -36
  175. package/lib/esm/imodel-components-react/color/AlphaSlider.js +160 -160
  176. package/lib/esm/imodel-components-react/color/AlphaSlider.js.map +1 -1
  177. package/lib/esm/imodel-components-react/color/AlphaSlider.scss +63 -63
  178. package/lib/esm/imodel-components-react/color/ColorPickerButton.d.ts +37 -37
  179. package/lib/esm/imodel-components-react/color/ColorPickerButton.js +82 -82
  180. package/lib/esm/imodel-components-react/color/ColorPickerButton.js.map +1 -1
  181. package/lib/esm/imodel-components-react/color/ColorPickerButton.scss +91 -91
  182. package/lib/esm/imodel-components-react/color/ColorPickerDialog.d.ts +23 -23
  183. package/lib/esm/imodel-components-react/color/ColorPickerDialog.js +51 -51
  184. package/lib/esm/imodel-components-react/color/ColorPickerDialog.js.map +1 -1
  185. package/lib/esm/imodel-components-react/color/ColorPickerPanel.d.ts +21 -21
  186. package/lib/esm/imodel-components-react/color/ColorPickerPanel.js +122 -122
  187. package/lib/esm/imodel-components-react/color/ColorPickerPanel.js.map +1 -1
  188. package/lib/esm/imodel-components-react/color/ColorPickerPanel.scss +93 -93
  189. package/lib/esm/imodel-components-react/color/ColorPickerPopup.d.ts +44 -44
  190. package/lib/esm/imodel-components-react/color/ColorPickerPopup.js +112 -112
  191. package/lib/esm/imodel-components-react/color/ColorPickerPopup.js.map +1 -1
  192. package/lib/esm/imodel-components-react/color/ColorPickerPopup.scss +64 -64
  193. package/lib/esm/imodel-components-react/color/HueSlider.d.ts +22 -22
  194. package/lib/esm/imodel-components-react/color/HueSlider.js +173 -173
  195. package/lib/esm/imodel-components-react/color/HueSlider.js.map +1 -1
  196. package/lib/esm/imodel-components-react/color/HueSlider.scss +61 -61
  197. package/lib/esm/imodel-components-react/color/SaturationPicker.d.ts +20 -20
  198. package/lib/esm/imodel-components-react/color/SaturationPicker.js +187 -187
  199. package/lib/esm/imodel-components-react/color/SaturationPicker.js.map +1 -1
  200. package/lib/esm/imodel-components-react/color/SaturationPicker.scss +35 -35
  201. package/lib/esm/imodel-components-react/color/Swatch.d.ts +22 -22
  202. package/lib/esm/imodel-components-react/color/Swatch.js +34 -34
  203. package/lib/esm/imodel-components-react/color/Swatch.js.map +1 -1
  204. package/lib/esm/imodel-components-react/color/Swatch.scss +23 -23
  205. package/lib/esm/imodel-components-react/color/getCSSColorFromDef.d.ts +6 -6
  206. package/lib/esm/imodel-components-react/color/getCSSColorFromDef.js +19 -19
  207. package/lib/esm/imodel-components-react/color/getCSSColorFromDef.js.map +1 -1
  208. package/lib/esm/imodel-components-react/editors/ColorEditor.d.ts +44 -44
  209. package/lib/esm/imodel-components-react/editors/ColorEditor.js +124 -124
  210. package/lib/esm/imodel-components-react/editors/ColorEditor.js.map +1 -1
  211. package/lib/esm/imodel-components-react/editors/ColorEditor.scss +18 -18
  212. package/lib/esm/imodel-components-react/editors/WeightEditor.d.ts +47 -47
  213. package/lib/esm/imodel-components-react/editors/WeightEditor.js +133 -133
  214. package/lib/esm/imodel-components-react/editors/WeightEditor.js.map +1 -1
  215. package/lib/esm/imodel-components-react/editors/WeightEditor.scss +16 -16
  216. package/lib/esm/imodel-components-react/inputs/QuantityInput.d.ts +25 -25
  217. package/lib/esm/imodel-components-react/inputs/QuantityInput.js +70 -70
  218. package/lib/esm/imodel-components-react/inputs/QuantityInput.js.map +1 -1
  219. package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.d.ts +44 -44
  220. package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.js +240 -240
  221. package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.js.map +1 -1
  222. package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.scss +107 -107
  223. package/lib/esm/imodel-components-react/lineweight/Swatch.d.ts +33 -33
  224. package/lib/esm/imodel-components-react/lineweight/Swatch.js +59 -59
  225. package/lib/esm/imodel-components-react/lineweight/Swatch.js.map +1 -1
  226. package/lib/esm/imodel-components-react/lineweight/Swatch.scss +48 -48
  227. package/lib/esm/imodel-components-react/lineweight/WeightPickerButton.d.ts +60 -60
  228. package/lib/esm/imodel-components-react/lineweight/WeightPickerButton.js +133 -133
  229. package/lib/esm/imodel-components-react/lineweight/WeightPickerButton.js.map +1 -1
  230. package/lib/esm/imodel-components-react/lineweight/WeightPickerButton.scss +52 -52
  231. package/lib/esm/imodel-components-react/navigationaids/Cube.d.ts +45 -45
  232. package/lib/esm/imodel-components-react/navigationaids/Cube.js +100 -100
  233. package/lib/esm/imodel-components-react/navigationaids/Cube.js.map +1 -1
  234. package/lib/esm/imodel-components-react/navigationaids/Cube.scss +19 -19
  235. package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.d.ts +174 -174
  236. package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.js +606 -606
  237. package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.js.map +1 -1
  238. package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.scss +180 -180
  239. package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.d.ts +145 -145
  240. package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.js +620 -620
  241. package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.js.map +1 -1
  242. package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.scss +133 -133
  243. package/lib/esm/imodel-components-react/quantityformat/FormatPanel.d.ts +26 -26
  244. package/lib/esm/imodel-components-react/quantityformat/FormatPanel.js +76 -76
  245. package/lib/esm/imodel-components-react/quantityformat/FormatPanel.js.map +1 -1
  246. package/lib/esm/imodel-components-react/quantityformat/FormatPanel.scss +64 -64
  247. package/lib/esm/imodel-components-react/quantityformat/FormatPrecision.d.ts +17 -17
  248. package/lib/esm/imodel-components-react/quantityformat/FormatPrecision.js +30 -30
  249. package/lib/esm/imodel-components-react/quantityformat/FormatPrecision.js.map +1 -1
  250. package/lib/esm/imodel-components-react/quantityformat/FormatSample.d.ts +18 -18
  251. package/lib/esm/imodel-components-react/quantityformat/FormatSample.js +60 -60
  252. package/lib/esm/imodel-components-react/quantityformat/FormatSample.js.map +1 -1
  253. package/lib/esm/imodel-components-react/quantityformat/FormatType.d.ts +17 -17
  254. package/lib/esm/imodel-components-react/quantityformat/FormatType.js +63 -63
  255. package/lib/esm/imodel-components-react/quantityformat/FormatType.js.map +1 -1
  256. package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.d.ts +17 -17
  257. package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.js +83 -83
  258. package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.js.map +1 -1
  259. package/lib/esm/imodel-components-react/quantityformat/FormatUnits.d.ts +19 -19
  260. package/lib/esm/imodel-components-react/quantityformat/FormatUnits.js +110 -110
  261. package/lib/esm/imodel-components-react/quantityformat/FormatUnits.js.map +1 -1
  262. package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.d.ts +21 -21
  263. package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.js +158 -158
  264. package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.js.map +1 -1
  265. package/lib/esm/imodel-components-react/quantityformat/QuantityFormatPanel.d.ts +22 -22
  266. package/lib/esm/imodel-components-react/quantityformat/QuantityFormatPanel.js +131 -131
  267. package/lib/esm/imodel-components-react/quantityformat/QuantityFormatPanel.js.map +1 -1
  268. package/lib/esm/imodel-components-react/quantityformat/misc/DecimalPrecision.d.ts +17 -17
  269. package/lib/esm/imodel-components-react/quantityformat/misc/DecimalPrecision.js +36 -36
  270. package/lib/esm/imodel-components-react/quantityformat/misc/DecimalPrecision.js.map +1 -1
  271. package/lib/esm/imodel-components-react/quantityformat/misc/DecimalSeparator.d.ts +17 -17
  272. package/lib/esm/imodel-components-react/quantityformat/misc/DecimalSeparator.js +24 -24
  273. package/lib/esm/imodel-components-react/quantityformat/misc/DecimalSeparator.js.map +1 -1
  274. package/lib/esm/imodel-components-react/quantityformat/misc/FractionPrecision.d.ts +16 -16
  275. package/lib/esm/imodel-components-react/quantityformat/misc/FractionPrecision.js +31 -31
  276. package/lib/esm/imodel-components-react/quantityformat/misc/FractionPrecision.js.map +1 -1
  277. package/lib/esm/imodel-components-react/quantityformat/misc/ScientificType.d.ts +18 -18
  278. package/lib/esm/imodel-components-react/quantityformat/misc/ScientificType.js +25 -25
  279. package/lib/esm/imodel-components-react/quantityformat/misc/ScientificType.js.map +1 -1
  280. package/lib/esm/imodel-components-react/quantityformat/misc/SignOption.d.ts +17 -17
  281. package/lib/esm/imodel-components-react/quantityformat/misc/SignOption.js +27 -27
  282. package/lib/esm/imodel-components-react/quantityformat/misc/SignOption.js.map +1 -1
  283. package/lib/esm/imodel-components-react/quantityformat/misc/StationSeparatorSelector.d.ts +17 -17
  284. package/lib/esm/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js +35 -35
  285. package/lib/esm/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js.map +1 -1
  286. package/lib/esm/imodel-components-react/quantityformat/misc/StationSizeSelector.d.ts +17 -17
  287. package/lib/esm/imodel-components-react/quantityformat/misc/StationSizeSelector.js +24 -24
  288. package/lib/esm/imodel-components-react/quantityformat/misc/StationSizeSelector.js.map +1 -1
  289. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSelector.d.ts +17 -17
  290. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSelector.js +33 -33
  291. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSelector.js.map +1 -1
  292. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSeparator.d.ts +17 -17
  293. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSeparator.js +69 -69
  294. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSeparator.js.map +1 -1
  295. package/lib/esm/imodel-components-react/quantityformat/misc/UnitDescr.d.ts +23 -23
  296. package/lib/esm/imodel-components-react/quantityformat/misc/UnitDescr.js +96 -96
  297. package/lib/esm/imodel-components-react/quantityformat/misc/UnitDescr.js.map +1 -1
  298. package/lib/esm/imodel-components-react/timeline/BaseSolarDataProvider.d.ts +52 -52
  299. package/lib/esm/imodel-components-react/timeline/BaseSolarDataProvider.js +139 -139
  300. package/lib/esm/imodel-components-react/timeline/BaseSolarDataProvider.js.map +1 -1
  301. package/lib/esm/imodel-components-react/timeline/BaseTimelineDataProvider.d.ts +31 -31
  302. package/lib/esm/imodel-components-react/timeline/BaseTimelineDataProvider.js +65 -65
  303. package/lib/esm/imodel-components-react/timeline/BaseTimelineDataProvider.js.map +1 -1
  304. package/lib/esm/imodel-components-react/timeline/InlineEdit.d.ts +27 -27
  305. package/lib/esm/imodel-components-react/timeline/InlineEdit.js +55 -55
  306. package/lib/esm/imodel-components-react/timeline/InlineEdit.js.map +1 -1
  307. package/lib/esm/imodel-components-react/timeline/InlineEdit.scss +26 -26
  308. package/lib/esm/imodel-components-react/timeline/PlayerButton.d.ts +33 -33
  309. package/lib/esm/imodel-components-react/timeline/PlayerButton.js +64 -64
  310. package/lib/esm/imodel-components-react/timeline/PlayerButton.js.map +1 -1
  311. package/lib/esm/imodel-components-react/timeline/PlayerButton.scss +25 -25
  312. package/lib/esm/imodel-components-react/timeline/Scrubber.d.ts +54 -54
  313. package/lib/esm/imodel-components-react/timeline/Scrubber.js +164 -164
  314. package/lib/esm/imodel-components-react/timeline/Scrubber.js.map +1 -1
  315. package/lib/esm/imodel-components-react/timeline/Scrubber.scss +106 -106
  316. package/lib/esm/imodel-components-react/timeline/SolarTimeline.d.ts +77 -77
  317. package/lib/esm/imodel-components-react/timeline/SolarTimeline.js +398 -398
  318. package/lib/esm/imodel-components-react/timeline/SolarTimeline.js.map +1 -1
  319. package/lib/esm/imodel-components-react/timeline/SolarTimeline.scss +357 -357
  320. package/lib/esm/imodel-components-react/timeline/SpeedTimeline.d.ts +15 -15
  321. package/lib/esm/imodel-components-react/timeline/SpeedTimeline.js +28 -28
  322. package/lib/esm/imodel-components-react/timeline/SpeedTimeline.js.map +1 -1
  323. package/lib/esm/imodel-components-react/timeline/SpeedTimeline.scss +39 -39
  324. package/lib/esm/imodel-components-react/timeline/Timeline.scss +164 -164
  325. package/lib/esm/imodel-components-react/timeline/TimelineComponent.d.ts +133 -133
  326. package/lib/esm/imodel-components-react/timeline/TimelineComponent.js +332 -332
  327. package/lib/esm/imodel-components-react/timeline/TimelineComponent.js.map +1 -1
  328. package/lib/esm/imodel-components-react/timeline/TimelineComponent.scss +163 -163
  329. package/lib/esm/imodel-components-react/timeline/interfaces.d.ts +174 -174
  330. package/lib/esm/imodel-components-react/timeline/interfaces.js +42 -42
  331. package/lib/esm/imodel-components-react/timeline/interfaces.js.map +1 -1
  332. package/lib/esm/imodel-components-react/viewport/ViewportComponent.d.ts +42 -42
  333. package/lib/esm/imodel-components-react/viewport/ViewportComponent.js +251 -251
  334. package/lib/esm/imodel-components-react/viewport/ViewportComponent.js.map +1 -1
  335. package/lib/esm/imodel-components-react/viewport/ViewportComponentEvents.d.ts +106 -106
  336. package/lib/esm/imodel-components-react/viewport/ViewportComponentEvents.js +95 -95
  337. package/lib/esm/imodel-components-react/viewport/ViewportComponentEvents.js.map +1 -1
  338. package/lib/esm/imodel-components-react.d.ts +82 -82
  339. package/lib/esm/imodel-components-react.js +87 -87
  340. package/lib/esm/imodel-components-react.js.map +1 -1
  341. package/lib/public/locales/en/UiIModelComponents.json +139 -139
  342. package/package.json +19 -19
@@ -1,621 +1,621 @@
1
- /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
- * See LICENSE.md in the project root for license terms and full copyright notice.
4
- *--------------------------------------------------------------------------------------------*/
5
- /** @packageDocumentation
6
- * @module NavigationAids
7
- */
8
- import "./DrawingNavigationAid.scss";
9
- import classnames from "classnames";
10
- import * as React from "react";
11
- import * as ReactDOM from "react-dom";
12
- import { Constant, Geometry, Matrix3d, Point2d, Point3d, Point4d, Vector3d } from "@itwin/core-geometry";
13
- import { IModelApp, ScreenViewport } from "@itwin/core-frontend";
14
- import { SpecialKey } from "@itwin/appui-abstract";
15
- import { UiIModelComponents } from "../UiIModelComponents";
16
- import { ViewportComponentEvents } from "../viewport/ViewportComponentEvents";
17
- // cSpell:ignore Quaternion Quaternions unrotate
18
- /* eslint-disable jsx-a11y/click-events-have-key-events */
19
- /**
20
- * Enum for mode that minimap is currently in
21
- * @internal
22
- */
23
- export var MapMode;
24
- (function (MapMode) {
25
- MapMode["Opened"] = "map-opened";
26
- MapMode["Closed"] = "map-closed";
27
- })(MapMode || (MapMode = {}));
28
- /**
29
- * A Drawing Navigation Aid.
30
- * @public
31
- */
32
- export class DrawingNavigationAid extends React.Component {
33
- constructor(props) {
34
- super(props);
35
- this._rootElement = React.createRef();
36
- this._viewContainerElement = React.createRef();
37
- this._viewElement = React.createRef();
38
- this._rootOffset = DOMRect.fromRect({ x: 0, y: 0, width: 0, height: 0 });
39
- this._mounted = false;
40
- this._isViewport3D = () => {
41
- return this.state.view !== undefined && this.state.view.is3d();
42
- };
43
- this._animation = () => {
44
- const t = Date.now();
45
- const delta = this._lastTime ? t - this._lastTime : 16;
46
- this._lastTime = t;
47
- if (this.state.animation !== 1) {
48
- const animation = Math.min(1, this.state.animation + delta / (1000 * (this.props.animationTime || 0.4)));
49
- this._updateFrustum();
50
- // istanbul ignore next
51
- if (this._mounted) {
52
- this.setState({ animation }, () => {
53
- this._animationFrame = setTimeout(this._animation, 16.667);
54
- });
55
- }
56
- }
57
- else {
58
- this._lastTime = undefined;
59
- this._animationEnd();
60
- }
61
- };
62
- this._animationEnd = () => {
63
- const hasViewportMoved = !this.state.origin.isAlmostEqual(this.state.startOrigin) ||
64
- !this.state.rotation.isAlmostEqual(this.state.startRotation);
65
- const startMapOrigin = Point3d.createFrom(this.state.mapOrigin);
66
- const startMapExtents = Vector3d.createFrom(this.state.mapExtents);
67
- const startDrawingZoom = this.state.drawingZoom;
68
- const startOrigin = this.state.origin;
69
- const startRotation = this.state.rotation;
70
- // istanbul ignore next
71
- if (this._mounted) {
72
- this.setState({ startMapOrigin, startDrawingZoom, startOrigin, startRotation, startMapExtents }, () => {
73
- // istanbul ignore else
74
- if (this.props.onAnimationEnd)
75
- this.props.onAnimationEnd();
76
- if (hasViewportMoved)
77
- this._updateFrustum(true);
78
- });
79
- }
80
- };
81
- this._panAnimation = () => {
82
- const t = Date.now();
83
- if (this._lastPanTime === undefined)
84
- this._lastPanTime = t - 16.667;
85
- const delta = t - this._lastPanTime;
86
- this._lastPanTime = t;
87
- // istanbul ignore else
88
- if (!this.state.panningDirection.isAlmostZero && this.state.isMoving) {
89
- const { panningDirection } = this.state;
90
- const offset = panningDirection.scale(delta / 1000 / this.state.drawingZoom);
91
- const mapOrigin = this.state.mapOrigin.plus(offset);
92
- const origin = this.state.origin.plus(offset);
93
- this._updateFrustum();
94
- // istanbul ignore next
95
- if (this._mounted) {
96
- this.setState({ mapOrigin, origin, panningDirection }, () => {
97
- this._animationFrame = setTimeout(this._panAnimation, 16.667);
98
- });
99
- }
100
- }
101
- else {
102
- this._lastPanTime = undefined;
103
- this._updateFrustum(true);
104
- }
105
- };
106
- // Synchronize with rotation coming from the Viewport
107
- this._handleViewRotationChangeEvent = (args) => {
108
- // istanbul ignore else
109
- if (!this.state.isMoving && !this.state.isPanning && this.props.viewport === args.viewport) {
110
- const extents = args.viewport.view.getExtents().clone();
111
- const rotation = args.viewport.view.getRotation().clone();
112
- const halfExtents = extents.scale(.5);
113
- const offset = this.state.rotateMinimapWithView || this._isViewport3D() ? rotation.multiplyTransposeVector(halfExtents) : halfExtents;
114
- const origin = args.viewport.view.getOrigin().plus(offset);
115
- const deltaZoom = (this.state.extents.x - extents.x) / this.state.extents.x;
116
- let drawingZoom = this.state.drawingZoom / (1 - deltaZoom);
117
- const deltaOrigin = origin.minus(this.state.origin);
118
- let mapOrigin = this.state.mapOrigin.plus(deltaOrigin);
119
- mapOrigin = mapOrigin.plus(Vector3d.createFrom(origin.minus(mapOrigin)).scale(deltaZoom));
120
- if (this.state.viewId !== args.viewport.view.id) {
121
- const rect = this.state.rotateMinimapWithView || this._isViewport3D() ? extents : DrawingNavigationAid.findRotatedWindowDimensions(extents, rotation);
122
- const maxRectDim = Math.max(rect.y, rect.x);
123
- const maxExtentDim = Math.max(this.state.mapExtents.x, this.state.mapExtents.y);
124
- drawingZoom = maxExtentDim / (3 * maxRectDim);
125
- mapOrigin = origin.clone();
126
- this._viewport = args.viewport;
127
- this.setState({ viewId: args.viewport.view.id, view: args.viewport.view.clone() });
128
- }
129
- // istanbul ignore next
130
- if (this._mounted) {
131
- this.setState({
132
- startOrigin: origin, origin, extents,
133
- startRotation: rotation, rotation,
134
- startMapOrigin: mapOrigin, mapOrigin,
135
- startDrawingZoom: drawingZoom, drawingZoom,
136
- });
137
- }
138
- }
139
- };
140
- this._updateFrustum = (complete = false) => {
141
- const halfExtents = this.state.extents.scale(.5);
142
- const offset = this.state.rotateMinimapWithView || this._isViewport3D() ? this.state.rotation.multiplyTransposeVector(halfExtents) : halfExtents;
143
- const origin = this.state.origin.minus(offset);
144
- ViewportComponentEvents.setDrawingViewportState(origin, this.state.rotation, complete);
145
- };
146
- this._toggleRotationMode = () => {
147
- const rotateMinimapWithView = !this.state.rotateMinimapWithView;
148
- this.setState({ rotateMinimapWithView }, () => {
149
- if (this._viewport)
150
- this._handleViewRotationChangeEvent({ viewport: this._viewport });
151
- });
152
- };
153
- this._handleKeyUp = (event) => {
154
- // istanbul ignore else
155
- if (event.key === SpecialKey.Escape && this.state.mode === MapMode.Opened) {
156
- this._closeLargeMap();
157
- }
158
- };
159
- this._lastClientXY = Point2d.createZero();
160
- this._handleMouseDown = (event) => {
161
- // Used only to determine if mouse was moved between mousedown and mouseup
162
- const mouseStart = Point2d.create(event.clientX, event.clientY);
163
- this.setState({ mouseStart });
164
- this._lastClientXY = Point2d.create(event.clientX, event.clientY);
165
- };
166
- this._handleDrawingMouseDown = (event) => {
167
- if (this.state.mode === MapMode.Opened) {
168
- event.preventDefault();
169
- this.setState({ isPanning: true });
170
- }
171
- };
172
- this._handleWindowMouseDown = (event) => {
173
- event.preventDefault();
174
- this.setState({ isMoving: true });
175
- };
176
- this._handleMouseDrag = (event) => {
177
- const mouse = Point2d.create(event.clientX, event.clientY);
178
- const movement = mouse.minus(this._lastClientXY);
179
- if (this.state.isMoving) {
180
- // add scaled mouse movement
181
- this._processWindowDrag(movement);
182
- }
183
- else {
184
- // istanbul ignore else
185
- if (this.state.isPanning && this.state.mode === MapMode.Opened) {
186
- const vect = Vector3d.create(movement.x / this.state.drawingZoom, -movement.y / this.state.drawingZoom, 0);
187
- const offset = this.state.rotateMinimapWithView || this._isViewport3D() ? this.state.rotation.multiplyTransposeVector(vect) : vect;
188
- const mapOrigin = this.state.mapOrigin.minus(offset);
189
- this.setState({ startMapOrigin: mapOrigin, mapOrigin });
190
- }
191
- }
192
- this._lastClientXY = mouse;
193
- };
194
- this._handleMouseDragEnd = (event) => {
195
- const mouse = Point2d.create(event.clientX, event.clientY);
196
- if (mouse.isAlmostEqual(this.state.mouseStart) &&
197
- this.state.mode === MapMode.Closed &&
198
- (event.target === this._viewContainerElement.current || event.target === this._viewElement.current)) {
199
- this._openLargeMap();
200
- }
201
- else if (this.state.isMoving) {
202
- this._processWindowEndDrag();
203
- }
204
- else if (this.state.isPanning) {
205
- // istanbul ignore else
206
- if (this.state.mode === MapMode.Opened) {
207
- event.stopPropagation();
208
- this.setState({ isPanning: false });
209
- }
210
- }
211
- else if ((!(event.target instanceof Node) || this._rootElement.current && !this._rootElement.current.contains(event.target)) && mouse.isAlmostEqual(this.state.mouseStart)) {
212
- this._closeLargeMap();
213
- }
214
- this._lastClientXY = Point2d.create(event.clientX, event.clientY);
215
- };
216
- // istanbul ignore next - unable to test touch
217
- this._handleWindowTouchStart = (event) => {
218
- if (1 !== event.targetTouches.length)
219
- return;
220
- window.addEventListener("touchmove", this._onTouchMove, false);
221
- window.addEventListener("touchend", this._onTouchEnd, false);
222
- const mouseStart = Point2d.create(event.targetTouches[0].clientX, event.targetTouches[0].clientY);
223
- this.setState({ mouseStart });
224
- this._lastClientXY = mouseStart.clone();
225
- this.setState({ isMoving: true });
226
- };
227
- // istanbul ignore next - unable to test touch
228
- this._onTouchMove = (event) => {
229
- if (1 !== event.targetTouches.length)
230
- return;
231
- const mouse = Point2d.create(event.targetTouches[0].clientX, event.targetTouches[0].clientY);
232
- const movement = mouse.minus(this._lastClientXY);
233
- // add scaled mouse movement
234
- this._processWindowDrag(movement);
235
- this._lastClientXY = mouse;
236
- };
237
- // istanbul ignore next - unable to test touch
238
- this._onTouchEnd = (event) => {
239
- if (0 !== event.targetTouches.length)
240
- return;
241
- this._processWindowEndDrag();
242
- if (0 !== event.changedTouches.length)
243
- this._lastClientXY = Point2d.create(event.changedTouches[0].clientX, event.changedTouches[0].clientY); // Doesn't seem necessary...but _handleMouseDragEnd sets it...
244
- window.removeEventListener("touchmove", this._onTouchMove);
245
- window.removeEventListener("touchend", this._onTouchEnd);
246
- };
247
- this._getClosedMapSize = () => {
248
- if (this.props.closeSize === undefined)
249
- return DrawingNavigationAid.getDefaultClosedMapSize();
250
- return this.props.closeSize;
251
- };
252
- this._getOpenedMapSize = () => {
253
- if (this.props.openSize === undefined)
254
- return DrawingNavigationAid.getDefaultOpenedMapSize(this._rootOffset.right, this._rootOffset.top);
255
- return this.props.openSize;
256
- };
257
- this._openLargeMap = () => {
258
- // istanbul ignore else
259
- if (this.state.mode === MapMode.Closed && this.state.animation === 1.0) {
260
- // istanbul ignore else
261
- if (this._rootElement.current) {
262
- const rect = this._rootElement.current.getBoundingClientRect();
263
- this._rootOffset = rect;
264
- }
265
- const startMapExtents = Vector3d.createFrom(this.state.mapExtents);
266
- const mapExtents = this._getOpenedMapSize();
267
- this.setState({
268
- mode: MapMode.Opened,
269
- isMoving: false, isPanning: false,
270
- mapExtents, startMapExtents,
271
- animation: 0,
272
- }, () => {
273
- this._animationFrame = setTimeout(this._animation);
274
- });
275
- }
276
- };
277
- this._closeLargeMap = () => {
278
- // istanbul ignore else
279
- if (this.state.mode === MapMode.Opened && this.state.animation === 1.0) {
280
- const startMapOrigin = this.state.mapOrigin;
281
- const mapOrigin = this.state.origin.clone();
282
- const startMapExtents = Vector3d.createFrom(this.state.mapExtents);
283
- const mapExtents = this._getClosedMapSize();
284
- const rect = this.state.rotateMinimapWithView || this._isViewport3D() ? this.state.extents : DrawingNavigationAid.findRotatedWindowDimensions(this.state.extents, this.state.rotation);
285
- const maxRectDim = Math.max(rect.y, rect.x);
286
- const maxExtentDim = Math.max(mapExtents.x, mapExtents.y);
287
- const drawingZoom = maxExtentDim / (3 * maxRectDim);
288
- const startDrawingZoom = this.state.drawingZoom;
289
- this.setState({
290
- mode: MapMode.Closed,
291
- startMapOrigin, mapOrigin,
292
- startDrawingZoom, drawingZoom,
293
- isMoving: false, isPanning: false,
294
- startMapExtents, mapExtents,
295
- panningDirection: Vector3d.createZero(),
296
- animation: 0,
297
- }, () => {
298
- this._animationFrame = setTimeout(this._animation, 16.667);
299
- });
300
- }
301
- };
302
- this._getPanVector = () => {
303
- const is3D = this._isViewport3D();
304
- const rect = this.state.rotateMinimapWithView || is3D ? this.state.extents : DrawingNavigationAid.findRotatedWindowDimensions(this.state.extents, this.state.rotation);
305
- const mapExtents = this.state.mapExtents.scale(1 / this.state.drawingZoom);
306
- const maxMagnitude = 80; // maximum acceleration
307
- const magnitudeTravel = 30; // How far, in pixels, that magnitude increases from 0 to max acceleration
308
- const diff = Vector3d.createFrom(this.state.origin.minus(this.state.mapOrigin));
309
- const diffVector = this.state.rotateMinimapWithView || is3D ? this.state.rotation.multiplyVector(diff) : diff;
310
- // capture any values
311
- const magnitudeVector = Vector3d.create(Math.max(0, Math.abs(diffVector.x) - (mapExtents.x - rect.x) / 2), Math.max(0, Math.abs(diffVector.y) - (mapExtents.y - rect.y) / 2));
312
- if (magnitudeVector.isAlmostZero)
313
- return Vector3d.createZero();
314
- const magnitude = Math.min(magnitudeVector.magnitude() * this.state.drawingZoom, magnitudeTravel) / magnitudeTravel * maxMagnitude;
315
- const vect = Vector3d.createFrom(this.state.origin.minus(this.state.mapOrigin)); // vect will never be zero or magnitude would also be zero
316
- const norm = vect.normalize();
317
- return norm.scale(magnitude); // norm is only undefined when vect is zero, in which it would have returned at magnitudeVector.isAlmostZero
318
- };
319
- this._handleWheel = (event) => {
320
- // istanbul ignore else
321
- if (this.state.mode === MapMode.Opened && this.state.animation === 1) {
322
- const { mapOrigin, drawingZoom } = this.state;
323
- const mapSize = this._getOpenedMapSize();
324
- const mouseX = event.clientX - this._rootOffset.right + mapSize.x / 2;
325
- const mouseY = event.clientY - this._rootOffset.top - mapSize.y / 2;
326
- const is3D = this._isViewport3D();
327
- if (event.deltaY < 0) {
328
- const zoom = drawingZoom * 1.1;
329
- const vect = Vector3d.create(mouseX * 0.1 / zoom, -mouseY * 0.1 / zoom, 0);
330
- const offset = this.state.rotateMinimapWithView || is3D ? this.state.rotation.multiplyTransposeVector(vect) : vect;
331
- const m = mapOrigin.plus(offset);
332
- this.setState({ mapOrigin: m, drawingZoom: zoom });
333
- }
334
- if (event.deltaY > 0) {
335
- const zoom = drawingZoom / 1.1;
336
- const vect = Vector3d.create(mouseX * 0.1 / drawingZoom, -mouseY * 0.1 / drawingZoom, 0);
337
- const offset = this.state.rotateMinimapWithView || is3D ? this.state.rotation.multiplyTransposeVector(vect) : vect;
338
- const m = mapOrigin.minus(offset);
339
- this.setState({ mapOrigin: m, drawingZoom: zoom });
340
- }
341
- }
342
- };
343
- this._handleZoomIn = () => {
344
- const zoom = this.state.drawingZoom * 1.4;
345
- this.setState({ drawingZoom: zoom });
346
- };
347
- this._handleZoomOut = () => {
348
- const zoom = this.state.drawingZoom / 1.4;
349
- this.setState({ drawingZoom: zoom });
350
- };
351
- this._handleUnrotate = () => {
352
- const startRotation = this.state.rotation;
353
- const halfExtents = this.state.extents.scale(.5);
354
- const offset = this.state.rotateMinimapWithView || this._isViewport3D() ? Vector3d.createZero() : this.state.rotation.multiplyTransposeVector(halfExtents).minus(halfExtents);
355
- const startOrigin = this.state.origin;
356
- const origin = this.state.origin.plus(offset);
357
- const startMapOrigin = this.state.mapOrigin;
358
- const mapOrigin = this.state.mapOrigin.plus(offset);
359
- this.setState({ animation: 0, startOrigin, origin, startMapOrigin, mapOrigin, startRotation, rotation: Matrix3d.createIdentity() }, () => {
360
- this._animationFrame = setTimeout(this._animation, 16.667);
361
- });
362
- };
363
- const mode = props.initialMapMode || MapMode.Closed;
364
- const mapExtents = mode === MapMode.Closed ? this._getClosedMapSize() : this._getOpenedMapSize();
365
- const startMapExtents = mapExtents;
366
- this.state = {
367
- startOrigin: Point3d.createZero(),
368
- origin: Point3d.createZero(),
369
- extents: Vector3d.create(1, 1, 1),
370
- startRotation: Matrix3d.createIdentity(),
371
- rotation: Matrix3d.createIdentity(),
372
- startMapOrigin: Point3d.createZero(),
373
- mapOrigin: Point3d.createZero(),
374
- startMapExtents,
375
- mapExtents,
376
- mouseStart: Point2d.createZero(),
377
- panningDirection: Vector3d.createZero(),
378
- startDrawingZoom: 1.0,
379
- drawingZoom: 1.0,
380
- mode,
381
- animation: 1.0,
382
- viewId: props.initialView !== undefined ? props.initialView.id : "",
383
- view: props.initialView,
384
- isMoving: false,
385
- isPanning: false,
386
- rotateMinimapWithView: props.initialRotateMinimapWithView !== undefined ? props.initialRotateMinimapWithView : false,
387
- };
388
- }
389
- /** @internal */
390
- render() {
391
- const { startOrigin, origin, extents, startRotation, rotation, startMapOrigin, mapOrigin, startMapExtents, mapExtents, startDrawingZoom, drawingZoom, animation, viewId, mode, rotateMinimapWithView, } = this.state;
392
- const a = DrawingNavigationAid._animationFn(animation);
393
- const rot = Matrix3d.createFromQuaternion(Point4d.interpolateQuaternions(startRotation.toQuaternion(), a, rotation.toQuaternion()));
394
- const or = startOrigin.interpolate(a, origin);
395
- const map = startMapOrigin.interpolate(a, mapOrigin);
396
- const sz = startMapExtents.interpolate(a, mapExtents);
397
- const dz = Geometry.interpolate(startDrawingZoom, a, drawingZoom);
398
- const rootStyle = {
399
- width: sz.x, height: sz.y,
400
- ...this.props.style,
401
- };
402
- const is3D = this._isViewport3D();
403
- const tOr = rotateMinimapWithView || is3D ? rotation.multiplyVector(Vector3d.createFrom(or)) : Vector3d.createFrom(or);
404
- const tMap = rotateMinimapWithView || is3D ? rotation.multiplyVector(Vector3d.createFrom(map)) : Vector3d.createFrom(map);
405
- const tPosX = (tOr.x - extents.x / 2 - tMap.x) * dz + sz.x / 2;
406
- const tPosY = (-tOr.y - extents.y / 2 + tMap.y) * dz + sz.y / 2;
407
- const viewWindowStyle = {
408
- transform: `translate(${tPosX}px, ${tPosY}px)`,
409
- height: extents.y * dz,
410
- width: extents.x * dz,
411
- };
412
- if (!rotateMinimapWithView && !is3D)
413
- viewWindowStyle.transform =
414
- "matrix3d(" +
415
- `${rot.at(0, 0)}, ${rot.at(1, 0)}, ${rot.at(2, 0)}, 0, ` +
416
- `${rot.at(0, 1)}, ${rot.at(1, 1)}, ${rot.at(2, 1)}, 0, ` +
417
- `${rot.at(0, 2)}, ${rot.at(1, 2)}, ${rot.at(2, 2)}, 0, ` +
418
- `${tPosX}, ${tPosY}, 0, 1)`;
419
- const isAnimating = animation !== 1 && !startMapExtents.isExactEqual(mapExtents);
420
- if (mode === MapMode.Opened || isAnimating) {
421
- rootStyle.position = "fixed";
422
- rootStyle.right = window.innerWidth - this._rootOffset.right;
423
- rootStyle.top = this._rootOffset.top;
424
- }
425
- const halfExtents = extents.scale(.5);
426
- const offset = rotateMinimapWithView || is3D ? Vector3d.createZero() : rotation.multiplyTransposeVector(halfExtents).minus(halfExtents);
427
- const unrotateLabel = UiIModelComponents.translate("drawing.unrotate");
428
- const e = sz.scale(1 / dz);
429
- const halfMapExtents = e.scale(.5);
430
- const mapOffset = rotateMinimapWithView || is3D ? rotation.multiplyTransposeVector(halfMapExtents) : halfMapExtents;
431
- const viewManager = this.props.viewManagerOverride ? this.props.viewManagerOverride : /* istanbul ignore next */ IModelApp.viewManager;
432
- const screenViewport = this.props.screenViewportOverride ? this.props.screenViewportOverride : /* istanbul ignore next */ ScreenViewport;
433
- const nodes = (React.createElement("div", { className: classnames("components-drawing-navigation-aid", this.props.className), "data-testid": "components-drawing-navigation-aid", ref: this._rootElement, onWheel: this._handleWheel, onMouseDown: this._handleDrawingMouseDown, style: rootStyle, role: "presentation" },
434
- React.createElement(DrawingNavigationCanvas, { view: this.state.view, viewManagerOverride: viewManager, screenViewportOverride: screenViewport, viewId: viewId, origin: map.plus(offset).minus(mapOffset), extents: e, zoom: dz, rotation: rotateMinimapWithView || is3D ? rotation : Matrix3d.createIdentity() }),
435
- React.createElement("div", { className: "drawing-container", "data-testid": "drawing-container", ref: this._viewContainerElement },
436
- React.createElement("div", { className: "drawing-view-window", "data-testid": "drawing-view-window", onMouseDown: this._handleWindowMouseDown, onTouchStart: this._handleWindowTouchStart, style: viewWindowStyle, ref: this._viewElement, role: "presentation" }),
437
- !is3D &&
438
- React.createElement("div", { className: classnames("toggle-rotate-style", "icon", "icon-rotate-left", { checked: rotateMinimapWithView }), "data-testid": "toggle-rotate-style", style: mode === MapMode.Closed && !isAnimating ? { bottom: 2, left: 2 } : {}, title: UiIModelComponents.translate("drawing.rotateStyle"), onClick: this._toggleRotationMode, role: "presentation" }),
439
- !rot.isIdentity &&
440
- React.createElement("div", { className: "unrotate-button", "data-testid": "drawing-unrotate-button", style: mode === MapMode.Closed && !isAnimating ? { top: 2 } : {}, onClick: this._handleUnrotate, role: "button", tabIndex: -1 }, unrotateLabel),
441
- mode === MapMode.Opened && !isAnimating && React.createElement(React.Fragment, null,
442
- React.createElement("div", { className: "close", "data-testid": "drawing-close-button", onClick: this._closeLargeMap, role: "button", tabIndex: -1 },
443
- React.createElement("div", { className: "close-icon icon icon-sort-up" })),
444
- React.createElement("div", { className: "zoom" },
445
- React.createElement("div", { className: "zoom-button icon icon-add", "data-testid": "drawing-zoom-in-button", onClick: this._handleZoomIn, role: "button", tabIndex: -1 }),
446
- React.createElement("div", { className: "zoom-button icon icon-remove-2", "data-testid": "drawing-zoom-out-button", onClick: this._handleZoomOut, role: "button", tabIndex: -1 }))))));
447
- if (mode === MapMode.Closed && (animation === 1.0 || startMapExtents.isExactEqual(mapExtents))) {
448
- return nodes;
449
- }
450
- else {
451
- let drawingPortal = document.querySelector("#components-drawing-portal");
452
- if (!drawingPortal) {
453
- drawingPortal = document.createElement("div");
454
- drawingPortal.id = "components-drawing-portal";
455
- document.body.appendChild(drawingPortal);
456
- }
457
- return ReactDOM.createPortal(nodes, drawingPortal);
458
- }
459
- }
460
- componentDidMount() {
461
- this._mounted = true;
462
- ViewportComponentEvents.onViewRotationChangeEvent.addListener(this._handleViewRotationChangeEvent);
463
- window.addEventListener("mousedown", this._handleMouseDown);
464
- window.addEventListener("mouseup", this._handleMouseDragEnd);
465
- window.addEventListener("mousemove", this._handleMouseDrag);
466
- window.addEventListener("keyup", this._handleKeyUp);
467
- }
468
- componentWillUnmount() {
469
- ViewportComponentEvents.onViewRotationChangeEvent.removeListener(this._handleViewRotationChangeEvent);
470
- window.removeEventListener("mousedown", this._handleMouseDown);
471
- window.removeEventListener("mouseup", this._handleMouseDragEnd);
472
- window.removeEventListener("mousemove", this._handleMouseDrag);
473
- window.removeEventListener("keyup", this._handleKeyUp);
474
- clearTimeout(this._animationFrame);
475
- if (this.props.onAnimationEnd)
476
- this.props.onAnimationEnd();
477
- const rt = document.getElementById("components-drawing-portal");
478
- if (rt && rt.parentElement !== null && rt.children.length === 0) {
479
- rt.parentElement.removeChild(rt);
480
- }
481
- this._mounted = false;
482
- }
483
- _processWindowDrag(movement) {
484
- const vect = Vector3d.create(movement.x / this.state.drawingZoom, -movement.y / this.state.drawingZoom, 0);
485
- const offset = this.state.rotateMinimapWithView || this._isViewport3D() ? this.state.rotation.multiplyTransposeVector(vect) : vect;
486
- const origin = this.state.origin.plus(offset);
487
- const panningDirection = this._getPanVector();
488
- const wasAlmostZero = this.state.panningDirection.isAlmostZero;
489
- this.setState({ startOrigin: origin, origin, panningDirection, isPanning: false }, () => {
490
- this._updateFrustum();
491
- if (wasAlmostZero && !this.state.panningDirection.isAlmostZero) {
492
- this._animationFrame = setTimeout(this._panAnimation, 16.667);
493
- }
494
- });
495
- }
496
- _processWindowEndDrag() {
497
- this.setState({ isMoving: false });
498
- this._updateFrustum(true);
499
- if (this.state.mode === MapMode.Closed) {
500
- setTimeout(() => {
501
- const startMapOrigin = this.state.mapOrigin;
502
- const mapOrigin = this.state.origin.clone();
503
- // istanbul ignore next
504
- if (this._mounted) {
505
- this.setState({ startMapOrigin, mapOrigin, animation: 0 }, () => {
506
- this._animationFrame = setTimeout(this._animation, 16.667);
507
- });
508
- }
509
- }, 0);
510
- }
511
- }
512
- }
513
- DrawingNavigationAid._animationFn = (t) => t < .5 ? 2 * t ** 2 : -1 + (4 - 2 * t) * t;
514
- /** @internal */
515
- DrawingNavigationAid.getDefaultClosedMapSize = () => {
516
- return Vector3d.create(96, 96);
517
- };
518
- /** @internal */
519
- DrawingNavigationAid.getDefaultOpenedMapSize = (paddingX = 0, paddingY = 0) => {
520
- return Vector3d.create(window.innerWidth / 3 - 2 * (window.innerWidth - paddingX), window.innerHeight / 3 - 2 * paddingY);
521
- };
522
- /** @internal */
523
- DrawingNavigationAid.findRotatedWindowDimensions = (extents, rotation) => {
524
- const cos = rotation.at(0, 0);
525
- const sin = rotation.at(1, 0);
526
- // extents.x/y should be divided in half, but we don't have to do that immediately.
527
- const cosWidth = cos * extents.x;
528
- const sinHeight = sin * extents.y;
529
- const sinWidth = cos * extents.x;
530
- const cosHeight = sin * extents.y;
531
- const a = Math.atan2(sin, cos);
532
- if (a % Math.PI >= 0 && a % Math.PI < Math.PI / 2) {
533
- const y1 = -cosHeight - sinWidth;
534
- const x2 = cosWidth + sinHeight;
535
- const y3 = cosHeight + sinWidth;
536
- const x4 = -cosWidth - sinHeight;
537
- // Instead, divide total difference
538
- return Vector3d.create(Math.abs(x2 - x4) / 2, Math.abs(y1 - y3) / 2);
539
- }
540
- else {
541
- const x1 = -cosWidth + sinHeight;
542
- const y2 = -cosHeight + sinWidth;
543
- const x3 = cosWidth - sinHeight;
544
- const y4 = cosHeight - sinWidth;
545
- return Vector3d.create(Math.abs(x1 - x3) / 2, Math.abs(y2 - y4) / 2);
546
- }
547
- };
548
- /** @internal */
549
- export class DrawingNavigationCanvas extends React.Component {
550
- constructor() {
551
- super(...arguments);
552
- this._canvasElement = React.createRef();
553
- this._update = () => {
554
- // istanbul ignore else
555
- if (this._vp) {
556
- const max = Math.max(this.props.extents.x, this.props.extents.y);
557
- this._vp.view.extentLimits = { max, min: Constant.oneMillimeter };
558
- this._vp.view.setOrigin(this.props.origin);
559
- this._vp.view.setRotation(this.props.rotation);
560
- this._vp.view.setExtents(this.props.extents);
561
- this._vp.applyViewState(this._vp.view);
562
- }
563
- };
564
- }
565
- render() {
566
- return (React.createElement("div", { className: "drawing-canvas", "data-testid": "drawing-canvas", ref: this._canvasElement }));
567
- }
568
- componentDidMount() {
569
- if (this._canvasElement.current && this.props.view !== undefined) {
570
- const viewManager = this.props.viewManagerOverride ? this.props.viewManagerOverride : /* istanbul ignore next */ IModelApp.viewManager;
571
- /* istanbul ignore next */
572
- const screenViewport = this.props.screenViewportOverride ? this.props.screenViewportOverride : /* istanbul ignore next */ ScreenViewport;
573
- const previousView = viewManager.selectedView;
574
- this._vp = screenViewport.create(this._canvasElement.current, this.props.view);
575
- this.customizeViewport(this._vp);
576
- viewManager.addViewport(this._vp);
577
- void viewManager.setSelectedView(previousView); // switch to original viewport
578
- this._update();
579
- }
580
- }
581
- customizeViewport(vp) {
582
- /* istanbul ignore next */
583
- if (vp.logo.style)
584
- vp.logo.style.display = "none";
585
- /* istanbul ignore next */
586
- if (vp.viewFlags.acsTriad)
587
- vp.viewFlags = vp.viewFlags.with("acsTriad", false);
588
- }
589
- componentDidUpdate(oldProps) {
590
- const viewManager = this.props.viewManagerOverride ? this.props.viewManagerOverride : /* istanbul ignore next */ IModelApp.viewManager;
591
- if (this.props.view !== undefined) {
592
- if (oldProps.view !== this.props.view) {
593
- const screenViewport = this.props.screenViewportOverride ? this.props.screenViewportOverride : /* istanbul ignore next */ ScreenViewport;
594
- if (oldProps !== undefined && oldProps.viewId !== "" && oldProps.viewId !== this.props.viewId && this._vp) {
595
- viewManager.dropViewport(this._vp, true);
596
- }
597
- // istanbul ignore else
598
- if (this._canvasElement.current &&
599
- (this.props.canvasSizeOverride ||
600
- ( /* istanbul ignore next */this._canvasElement.current.clientWidth !== 0 && /* istanbul ignore next */ this._canvasElement.current.clientHeight !== 0))) {
601
- const previousView = viewManager.selectedView;
602
- this._vp = screenViewport.create(this._canvasElement.current, this.props.view.clone());
603
- this.customizeViewport(this._vp);
604
- viewManager.addViewport(this._vp);
605
- void viewManager.setSelectedView(previousView); // switch to original viewport
606
- this._update();
607
- }
608
- }
609
- else if (!this.props.origin.isExactEqual(oldProps.origin) || !this.props.extents.isExactEqual(oldProps.extents) || this.props.zoom !== oldProps.zoom || !this.props.rotation.isExactEqual(oldProps.rotation)) {
610
- this._update();
611
- }
612
- }
613
- }
614
- componentWillUnmount() {
615
- if (this._vp) {
616
- const viewManager = this.props.viewManagerOverride ? this.props.viewManagerOverride : /* istanbul ignore next */ IModelApp.viewManager;
617
- viewManager.dropViewport(this._vp, true);
618
- }
619
- }
620
- }
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ /** @packageDocumentation
6
+ * @module NavigationAids
7
+ */
8
+ import "./DrawingNavigationAid.scss";
9
+ import classnames from "classnames";
10
+ import * as React from "react";
11
+ import * as ReactDOM from "react-dom";
12
+ import { Constant, Geometry, Matrix3d, Point2d, Point3d, Point4d, Vector3d } from "@itwin/core-geometry";
13
+ import { IModelApp, ScreenViewport } from "@itwin/core-frontend";
14
+ import { SpecialKey } from "@itwin/appui-abstract";
15
+ import { UiIModelComponents } from "../UiIModelComponents";
16
+ import { ViewportComponentEvents } from "../viewport/ViewportComponentEvents";
17
+ // cSpell:ignore Quaternion Quaternions unrotate
18
+ /* eslint-disable jsx-a11y/click-events-have-key-events */
19
+ /**
20
+ * Enum for mode that minimap is currently in
21
+ * @internal
22
+ */
23
+ export var MapMode;
24
+ (function (MapMode) {
25
+ MapMode["Opened"] = "map-opened";
26
+ MapMode["Closed"] = "map-closed";
27
+ })(MapMode || (MapMode = {}));
28
+ /**
29
+ * A Drawing Navigation Aid.
30
+ * @public
31
+ */
32
+ export class DrawingNavigationAid extends React.Component {
33
+ constructor(props) {
34
+ super(props);
35
+ this._rootElement = React.createRef();
36
+ this._viewContainerElement = React.createRef();
37
+ this._viewElement = React.createRef();
38
+ this._rootOffset = DOMRect.fromRect({ x: 0, y: 0, width: 0, height: 0 });
39
+ this._mounted = false;
40
+ this._isViewport3D = () => {
41
+ return this.state.view !== undefined && this.state.view.is3d();
42
+ };
43
+ this._animation = () => {
44
+ const t = Date.now();
45
+ const delta = this._lastTime ? t - this._lastTime : 16;
46
+ this._lastTime = t;
47
+ if (this.state.animation !== 1) {
48
+ const animation = Math.min(1, this.state.animation + delta / (1000 * (this.props.animationTime || 0.4)));
49
+ this._updateFrustum();
50
+ // istanbul ignore next
51
+ if (this._mounted) {
52
+ this.setState({ animation }, () => {
53
+ this._animationFrame = setTimeout(this._animation, 16.667);
54
+ });
55
+ }
56
+ }
57
+ else {
58
+ this._lastTime = undefined;
59
+ this._animationEnd();
60
+ }
61
+ };
62
+ this._animationEnd = () => {
63
+ const hasViewportMoved = !this.state.origin.isAlmostEqual(this.state.startOrigin) ||
64
+ !this.state.rotation.isAlmostEqual(this.state.startRotation);
65
+ const startMapOrigin = Point3d.createFrom(this.state.mapOrigin);
66
+ const startMapExtents = Vector3d.createFrom(this.state.mapExtents);
67
+ const startDrawingZoom = this.state.drawingZoom;
68
+ const startOrigin = this.state.origin;
69
+ const startRotation = this.state.rotation;
70
+ // istanbul ignore next
71
+ if (this._mounted) {
72
+ this.setState({ startMapOrigin, startDrawingZoom, startOrigin, startRotation, startMapExtents }, () => {
73
+ // istanbul ignore else
74
+ if (this.props.onAnimationEnd)
75
+ this.props.onAnimationEnd();
76
+ if (hasViewportMoved)
77
+ this._updateFrustum(true);
78
+ });
79
+ }
80
+ };
81
+ this._panAnimation = () => {
82
+ const t = Date.now();
83
+ if (this._lastPanTime === undefined)
84
+ this._lastPanTime = t - 16.667;
85
+ const delta = t - this._lastPanTime;
86
+ this._lastPanTime = t;
87
+ // istanbul ignore else
88
+ if (!this.state.panningDirection.isAlmostZero && this.state.isMoving) {
89
+ const { panningDirection } = this.state;
90
+ const offset = panningDirection.scale(delta / 1000 / this.state.drawingZoom);
91
+ const mapOrigin = this.state.mapOrigin.plus(offset);
92
+ const origin = this.state.origin.plus(offset);
93
+ this._updateFrustum();
94
+ // istanbul ignore next
95
+ if (this._mounted) {
96
+ this.setState({ mapOrigin, origin, panningDirection }, () => {
97
+ this._animationFrame = setTimeout(this._panAnimation, 16.667);
98
+ });
99
+ }
100
+ }
101
+ else {
102
+ this._lastPanTime = undefined;
103
+ this._updateFrustum(true);
104
+ }
105
+ };
106
+ // Synchronize with rotation coming from the Viewport
107
+ this._handleViewRotationChangeEvent = (args) => {
108
+ // istanbul ignore else
109
+ if (!this.state.isMoving && !this.state.isPanning && this.props.viewport === args.viewport) {
110
+ const extents = args.viewport.view.getExtents().clone();
111
+ const rotation = args.viewport.view.getRotation().clone();
112
+ const halfExtents = extents.scale(.5);
113
+ const offset = this.state.rotateMinimapWithView || this._isViewport3D() ? rotation.multiplyTransposeVector(halfExtents) : halfExtents;
114
+ const origin = args.viewport.view.getOrigin().plus(offset);
115
+ const deltaZoom = (this.state.extents.x - extents.x) / this.state.extents.x;
116
+ let drawingZoom = this.state.drawingZoom / (1 - deltaZoom);
117
+ const deltaOrigin = origin.minus(this.state.origin);
118
+ let mapOrigin = this.state.mapOrigin.plus(deltaOrigin);
119
+ mapOrigin = mapOrigin.plus(Vector3d.createFrom(origin.minus(mapOrigin)).scale(deltaZoom));
120
+ if (this.state.viewId !== args.viewport.view.id) {
121
+ const rect = this.state.rotateMinimapWithView || this._isViewport3D() ? extents : DrawingNavigationAid.findRotatedWindowDimensions(extents, rotation);
122
+ const maxRectDim = Math.max(rect.y, rect.x);
123
+ const maxExtentDim = Math.max(this.state.mapExtents.x, this.state.mapExtents.y);
124
+ drawingZoom = maxExtentDim / (3 * maxRectDim);
125
+ mapOrigin = origin.clone();
126
+ this._viewport = args.viewport;
127
+ this.setState({ viewId: args.viewport.view.id, view: args.viewport.view.clone() });
128
+ }
129
+ // istanbul ignore next
130
+ if (this._mounted) {
131
+ this.setState({
132
+ startOrigin: origin, origin, extents,
133
+ startRotation: rotation, rotation,
134
+ startMapOrigin: mapOrigin, mapOrigin,
135
+ startDrawingZoom: drawingZoom, drawingZoom,
136
+ });
137
+ }
138
+ }
139
+ };
140
+ this._updateFrustum = (complete = false) => {
141
+ const halfExtents = this.state.extents.scale(.5);
142
+ const offset = this.state.rotateMinimapWithView || this._isViewport3D() ? this.state.rotation.multiplyTransposeVector(halfExtents) : halfExtents;
143
+ const origin = this.state.origin.minus(offset);
144
+ ViewportComponentEvents.setDrawingViewportState(origin, this.state.rotation, complete);
145
+ };
146
+ this._toggleRotationMode = () => {
147
+ const rotateMinimapWithView = !this.state.rotateMinimapWithView;
148
+ this.setState({ rotateMinimapWithView }, () => {
149
+ if (this._viewport)
150
+ this._handleViewRotationChangeEvent({ viewport: this._viewport });
151
+ });
152
+ };
153
+ this._handleKeyUp = (event) => {
154
+ // istanbul ignore else
155
+ if (event.key === SpecialKey.Escape && this.state.mode === MapMode.Opened) {
156
+ this._closeLargeMap();
157
+ }
158
+ };
159
+ this._lastClientXY = Point2d.createZero();
160
+ this._handleMouseDown = (event) => {
161
+ // Used only to determine if mouse was moved between mousedown and mouseup
162
+ const mouseStart = Point2d.create(event.clientX, event.clientY);
163
+ this.setState({ mouseStart });
164
+ this._lastClientXY = Point2d.create(event.clientX, event.clientY);
165
+ };
166
+ this._handleDrawingMouseDown = (event) => {
167
+ if (this.state.mode === MapMode.Opened) {
168
+ event.preventDefault();
169
+ this.setState({ isPanning: true });
170
+ }
171
+ };
172
+ this._handleWindowMouseDown = (event) => {
173
+ event.preventDefault();
174
+ this.setState({ isMoving: true });
175
+ };
176
+ this._handleMouseDrag = (event) => {
177
+ const mouse = Point2d.create(event.clientX, event.clientY);
178
+ const movement = mouse.minus(this._lastClientXY);
179
+ if (this.state.isMoving) {
180
+ // add scaled mouse movement
181
+ this._processWindowDrag(movement);
182
+ }
183
+ else {
184
+ // istanbul ignore else
185
+ if (this.state.isPanning && this.state.mode === MapMode.Opened) {
186
+ const vect = Vector3d.create(movement.x / this.state.drawingZoom, -movement.y / this.state.drawingZoom, 0);
187
+ const offset = this.state.rotateMinimapWithView || this._isViewport3D() ? this.state.rotation.multiplyTransposeVector(vect) : vect;
188
+ const mapOrigin = this.state.mapOrigin.minus(offset);
189
+ this.setState({ startMapOrigin: mapOrigin, mapOrigin });
190
+ }
191
+ }
192
+ this._lastClientXY = mouse;
193
+ };
194
+ this._handleMouseDragEnd = (event) => {
195
+ const mouse = Point2d.create(event.clientX, event.clientY);
196
+ if (mouse.isAlmostEqual(this.state.mouseStart) &&
197
+ this.state.mode === MapMode.Closed &&
198
+ (event.target === this._viewContainerElement.current || event.target === this._viewElement.current)) {
199
+ this._openLargeMap();
200
+ }
201
+ else if (this.state.isMoving) {
202
+ this._processWindowEndDrag();
203
+ }
204
+ else if (this.state.isPanning) {
205
+ // istanbul ignore else
206
+ if (this.state.mode === MapMode.Opened) {
207
+ event.stopPropagation();
208
+ this.setState({ isPanning: false });
209
+ }
210
+ }
211
+ else if ((!(event.target instanceof Node) || this._rootElement.current && !this._rootElement.current.contains(event.target)) && mouse.isAlmostEqual(this.state.mouseStart)) {
212
+ this._closeLargeMap();
213
+ }
214
+ this._lastClientXY = Point2d.create(event.clientX, event.clientY);
215
+ };
216
+ // istanbul ignore next - unable to test touch
217
+ this._handleWindowTouchStart = (event) => {
218
+ if (1 !== event.targetTouches.length)
219
+ return;
220
+ window.addEventListener("touchmove", this._onTouchMove, false);
221
+ window.addEventListener("touchend", this._onTouchEnd, false);
222
+ const mouseStart = Point2d.create(event.targetTouches[0].clientX, event.targetTouches[0].clientY);
223
+ this.setState({ mouseStart });
224
+ this._lastClientXY = mouseStart.clone();
225
+ this.setState({ isMoving: true });
226
+ };
227
+ // istanbul ignore next - unable to test touch
228
+ this._onTouchMove = (event) => {
229
+ if (1 !== event.targetTouches.length)
230
+ return;
231
+ const mouse = Point2d.create(event.targetTouches[0].clientX, event.targetTouches[0].clientY);
232
+ const movement = mouse.minus(this._lastClientXY);
233
+ // add scaled mouse movement
234
+ this._processWindowDrag(movement);
235
+ this._lastClientXY = mouse;
236
+ };
237
+ // istanbul ignore next - unable to test touch
238
+ this._onTouchEnd = (event) => {
239
+ if (0 !== event.targetTouches.length)
240
+ return;
241
+ this._processWindowEndDrag();
242
+ if (0 !== event.changedTouches.length)
243
+ this._lastClientXY = Point2d.create(event.changedTouches[0].clientX, event.changedTouches[0].clientY); // Doesn't seem necessary...but _handleMouseDragEnd sets it...
244
+ window.removeEventListener("touchmove", this._onTouchMove);
245
+ window.removeEventListener("touchend", this._onTouchEnd);
246
+ };
247
+ this._getClosedMapSize = () => {
248
+ if (this.props.closeSize === undefined)
249
+ return DrawingNavigationAid.getDefaultClosedMapSize();
250
+ return this.props.closeSize;
251
+ };
252
+ this._getOpenedMapSize = () => {
253
+ if (this.props.openSize === undefined)
254
+ return DrawingNavigationAid.getDefaultOpenedMapSize(this._rootOffset.right, this._rootOffset.top);
255
+ return this.props.openSize;
256
+ };
257
+ this._openLargeMap = () => {
258
+ // istanbul ignore else
259
+ if (this.state.mode === MapMode.Closed && this.state.animation === 1.0) {
260
+ // istanbul ignore else
261
+ if (this._rootElement.current) {
262
+ const rect = this._rootElement.current.getBoundingClientRect();
263
+ this._rootOffset = rect;
264
+ }
265
+ const startMapExtents = Vector3d.createFrom(this.state.mapExtents);
266
+ const mapExtents = this._getOpenedMapSize();
267
+ this.setState({
268
+ mode: MapMode.Opened,
269
+ isMoving: false, isPanning: false,
270
+ mapExtents, startMapExtents,
271
+ animation: 0,
272
+ }, () => {
273
+ this._animationFrame = setTimeout(this._animation);
274
+ });
275
+ }
276
+ };
277
+ this._closeLargeMap = () => {
278
+ // istanbul ignore else
279
+ if (this.state.mode === MapMode.Opened && this.state.animation === 1.0) {
280
+ const startMapOrigin = this.state.mapOrigin;
281
+ const mapOrigin = this.state.origin.clone();
282
+ const startMapExtents = Vector3d.createFrom(this.state.mapExtents);
283
+ const mapExtents = this._getClosedMapSize();
284
+ const rect = this.state.rotateMinimapWithView || this._isViewport3D() ? this.state.extents : DrawingNavigationAid.findRotatedWindowDimensions(this.state.extents, this.state.rotation);
285
+ const maxRectDim = Math.max(rect.y, rect.x);
286
+ const maxExtentDim = Math.max(mapExtents.x, mapExtents.y);
287
+ const drawingZoom = maxExtentDim / (3 * maxRectDim);
288
+ const startDrawingZoom = this.state.drawingZoom;
289
+ this.setState({
290
+ mode: MapMode.Closed,
291
+ startMapOrigin, mapOrigin,
292
+ startDrawingZoom, drawingZoom,
293
+ isMoving: false, isPanning: false,
294
+ startMapExtents, mapExtents,
295
+ panningDirection: Vector3d.createZero(),
296
+ animation: 0,
297
+ }, () => {
298
+ this._animationFrame = setTimeout(this._animation, 16.667);
299
+ });
300
+ }
301
+ };
302
+ this._getPanVector = () => {
303
+ const is3D = this._isViewport3D();
304
+ const rect = this.state.rotateMinimapWithView || is3D ? this.state.extents : DrawingNavigationAid.findRotatedWindowDimensions(this.state.extents, this.state.rotation);
305
+ const mapExtents = this.state.mapExtents.scale(1 / this.state.drawingZoom);
306
+ const maxMagnitude = 80; // maximum acceleration
307
+ const magnitudeTravel = 30; // How far, in pixels, that magnitude increases from 0 to max acceleration
308
+ const diff = Vector3d.createFrom(this.state.origin.minus(this.state.mapOrigin));
309
+ const diffVector = this.state.rotateMinimapWithView || is3D ? this.state.rotation.multiplyVector(diff) : diff;
310
+ // capture any values
311
+ const magnitudeVector = Vector3d.create(Math.max(0, Math.abs(diffVector.x) - (mapExtents.x - rect.x) / 2), Math.max(0, Math.abs(diffVector.y) - (mapExtents.y - rect.y) / 2));
312
+ if (magnitudeVector.isAlmostZero)
313
+ return Vector3d.createZero();
314
+ const magnitude = Math.min(magnitudeVector.magnitude() * this.state.drawingZoom, magnitudeTravel) / magnitudeTravel * maxMagnitude;
315
+ const vect = Vector3d.createFrom(this.state.origin.minus(this.state.mapOrigin)); // vect will never be zero or magnitude would also be zero
316
+ const norm = vect.normalize();
317
+ return norm.scale(magnitude); // norm is only undefined when vect is zero, in which it would have returned at magnitudeVector.isAlmostZero
318
+ };
319
+ this._handleWheel = (event) => {
320
+ // istanbul ignore else
321
+ if (this.state.mode === MapMode.Opened && this.state.animation === 1) {
322
+ const { mapOrigin, drawingZoom } = this.state;
323
+ const mapSize = this._getOpenedMapSize();
324
+ const mouseX = event.clientX - this._rootOffset.right + mapSize.x / 2;
325
+ const mouseY = event.clientY - this._rootOffset.top - mapSize.y / 2;
326
+ const is3D = this._isViewport3D();
327
+ if (event.deltaY < 0) {
328
+ const zoom = drawingZoom * 1.1;
329
+ const vect = Vector3d.create(mouseX * 0.1 / zoom, -mouseY * 0.1 / zoom, 0);
330
+ const offset = this.state.rotateMinimapWithView || is3D ? this.state.rotation.multiplyTransposeVector(vect) : vect;
331
+ const m = mapOrigin.plus(offset);
332
+ this.setState({ mapOrigin: m, drawingZoom: zoom });
333
+ }
334
+ if (event.deltaY > 0) {
335
+ const zoom = drawingZoom / 1.1;
336
+ const vect = Vector3d.create(mouseX * 0.1 / drawingZoom, -mouseY * 0.1 / drawingZoom, 0);
337
+ const offset = this.state.rotateMinimapWithView || is3D ? this.state.rotation.multiplyTransposeVector(vect) : vect;
338
+ const m = mapOrigin.minus(offset);
339
+ this.setState({ mapOrigin: m, drawingZoom: zoom });
340
+ }
341
+ }
342
+ };
343
+ this._handleZoomIn = () => {
344
+ const zoom = this.state.drawingZoom * 1.4;
345
+ this.setState({ drawingZoom: zoom });
346
+ };
347
+ this._handleZoomOut = () => {
348
+ const zoom = this.state.drawingZoom / 1.4;
349
+ this.setState({ drawingZoom: zoom });
350
+ };
351
+ this._handleUnrotate = () => {
352
+ const startRotation = this.state.rotation;
353
+ const halfExtents = this.state.extents.scale(.5);
354
+ const offset = this.state.rotateMinimapWithView || this._isViewport3D() ? Vector3d.createZero() : this.state.rotation.multiplyTransposeVector(halfExtents).minus(halfExtents);
355
+ const startOrigin = this.state.origin;
356
+ const origin = this.state.origin.plus(offset);
357
+ const startMapOrigin = this.state.mapOrigin;
358
+ const mapOrigin = this.state.mapOrigin.plus(offset);
359
+ this.setState({ animation: 0, startOrigin, origin, startMapOrigin, mapOrigin, startRotation, rotation: Matrix3d.createIdentity() }, () => {
360
+ this._animationFrame = setTimeout(this._animation, 16.667);
361
+ });
362
+ };
363
+ const mode = props.initialMapMode || MapMode.Closed;
364
+ const mapExtents = mode === MapMode.Closed ? this._getClosedMapSize() : this._getOpenedMapSize();
365
+ const startMapExtents = mapExtents;
366
+ this.state = {
367
+ startOrigin: Point3d.createZero(),
368
+ origin: Point3d.createZero(),
369
+ extents: Vector3d.create(1, 1, 1),
370
+ startRotation: Matrix3d.createIdentity(),
371
+ rotation: Matrix3d.createIdentity(),
372
+ startMapOrigin: Point3d.createZero(),
373
+ mapOrigin: Point3d.createZero(),
374
+ startMapExtents,
375
+ mapExtents,
376
+ mouseStart: Point2d.createZero(),
377
+ panningDirection: Vector3d.createZero(),
378
+ startDrawingZoom: 1.0,
379
+ drawingZoom: 1.0,
380
+ mode,
381
+ animation: 1.0,
382
+ viewId: props.initialView !== undefined ? props.initialView.id : "",
383
+ view: props.initialView,
384
+ isMoving: false,
385
+ isPanning: false,
386
+ rotateMinimapWithView: props.initialRotateMinimapWithView !== undefined ? props.initialRotateMinimapWithView : false,
387
+ };
388
+ }
389
+ /** @internal */
390
+ render() {
391
+ const { startOrigin, origin, extents, startRotation, rotation, startMapOrigin, mapOrigin, startMapExtents, mapExtents, startDrawingZoom, drawingZoom, animation, viewId, mode, rotateMinimapWithView, } = this.state;
392
+ const a = DrawingNavigationAid._animationFn(animation);
393
+ const rot = Matrix3d.createFromQuaternion(Point4d.interpolateQuaternions(startRotation.toQuaternion(), a, rotation.toQuaternion()));
394
+ const or = startOrigin.interpolate(a, origin);
395
+ const map = startMapOrigin.interpolate(a, mapOrigin);
396
+ const sz = startMapExtents.interpolate(a, mapExtents);
397
+ const dz = Geometry.interpolate(startDrawingZoom, a, drawingZoom);
398
+ const rootStyle = {
399
+ width: sz.x, height: sz.y,
400
+ ...this.props.style,
401
+ };
402
+ const is3D = this._isViewport3D();
403
+ const tOr = rotateMinimapWithView || is3D ? rotation.multiplyVector(Vector3d.createFrom(or)) : Vector3d.createFrom(or);
404
+ const tMap = rotateMinimapWithView || is3D ? rotation.multiplyVector(Vector3d.createFrom(map)) : Vector3d.createFrom(map);
405
+ const tPosX = (tOr.x - extents.x / 2 - tMap.x) * dz + sz.x / 2;
406
+ const tPosY = (-tOr.y - extents.y / 2 + tMap.y) * dz + sz.y / 2;
407
+ const viewWindowStyle = {
408
+ transform: `translate(${tPosX}px, ${tPosY}px)`,
409
+ height: extents.y * dz,
410
+ width: extents.x * dz,
411
+ };
412
+ if (!rotateMinimapWithView && !is3D)
413
+ viewWindowStyle.transform =
414
+ "matrix3d(" +
415
+ `${rot.at(0, 0)}, ${rot.at(1, 0)}, ${rot.at(2, 0)}, 0, ` +
416
+ `${rot.at(0, 1)}, ${rot.at(1, 1)}, ${rot.at(2, 1)}, 0, ` +
417
+ `${rot.at(0, 2)}, ${rot.at(1, 2)}, ${rot.at(2, 2)}, 0, ` +
418
+ `${tPosX}, ${tPosY}, 0, 1)`;
419
+ const isAnimating = animation !== 1 && !startMapExtents.isExactEqual(mapExtents);
420
+ if (mode === MapMode.Opened || isAnimating) {
421
+ rootStyle.position = "fixed";
422
+ rootStyle.right = window.innerWidth - this._rootOffset.right;
423
+ rootStyle.top = this._rootOffset.top;
424
+ }
425
+ const halfExtents = extents.scale(.5);
426
+ const offset = rotateMinimapWithView || is3D ? Vector3d.createZero() : rotation.multiplyTransposeVector(halfExtents).minus(halfExtents);
427
+ const unrotateLabel = UiIModelComponents.translate("drawing.unrotate");
428
+ const e = sz.scale(1 / dz);
429
+ const halfMapExtents = e.scale(.5);
430
+ const mapOffset = rotateMinimapWithView || is3D ? rotation.multiplyTransposeVector(halfMapExtents) : halfMapExtents;
431
+ const viewManager = this.props.viewManagerOverride ? this.props.viewManagerOverride : /* istanbul ignore next */ IModelApp.viewManager;
432
+ const screenViewport = this.props.screenViewportOverride ? this.props.screenViewportOverride : /* istanbul ignore next */ ScreenViewport;
433
+ const nodes = (React.createElement("div", { className: classnames("components-drawing-navigation-aid", this.props.className), "data-testid": "components-drawing-navigation-aid", ref: this._rootElement, onWheel: this._handleWheel, onMouseDown: this._handleDrawingMouseDown, style: rootStyle, role: "presentation" },
434
+ React.createElement(DrawingNavigationCanvas, { view: this.state.view, viewManagerOverride: viewManager, screenViewportOverride: screenViewport, viewId: viewId, origin: map.plus(offset).minus(mapOffset), extents: e, zoom: dz, rotation: rotateMinimapWithView || is3D ? rotation : Matrix3d.createIdentity() }),
435
+ React.createElement("div", { className: "drawing-container", "data-testid": "drawing-container", ref: this._viewContainerElement },
436
+ React.createElement("div", { className: "drawing-view-window", "data-testid": "drawing-view-window", onMouseDown: this._handleWindowMouseDown, onTouchStart: this._handleWindowTouchStart, style: viewWindowStyle, ref: this._viewElement, role: "presentation" }),
437
+ !is3D &&
438
+ React.createElement("div", { className: classnames("toggle-rotate-style", "icon", "icon-rotate-left", { checked: rotateMinimapWithView }), "data-testid": "toggle-rotate-style", style: mode === MapMode.Closed && !isAnimating ? { bottom: 2, left: 2 } : {}, title: UiIModelComponents.translate("drawing.rotateStyle"), onClick: this._toggleRotationMode, role: "presentation" }),
439
+ !rot.isIdentity &&
440
+ React.createElement("div", { className: "unrotate-button", "data-testid": "drawing-unrotate-button", style: mode === MapMode.Closed && !isAnimating ? { top: 2 } : {}, onClick: this._handleUnrotate, role: "button", tabIndex: -1 }, unrotateLabel),
441
+ mode === MapMode.Opened && !isAnimating && React.createElement(React.Fragment, null,
442
+ React.createElement("div", { className: "close", "data-testid": "drawing-close-button", onClick: this._closeLargeMap, role: "button", tabIndex: -1 },
443
+ React.createElement("div", { className: "close-icon icon icon-sort-up" })),
444
+ React.createElement("div", { className: "zoom" },
445
+ React.createElement("div", { className: "zoom-button icon icon-add", "data-testid": "drawing-zoom-in-button", onClick: this._handleZoomIn, role: "button", tabIndex: -1 }),
446
+ React.createElement("div", { className: "zoom-button icon icon-remove-2", "data-testid": "drawing-zoom-out-button", onClick: this._handleZoomOut, role: "button", tabIndex: -1 }))))));
447
+ if (mode === MapMode.Closed && (animation === 1.0 || startMapExtents.isExactEqual(mapExtents))) {
448
+ return nodes;
449
+ }
450
+ else {
451
+ let drawingPortal = document.querySelector("#components-drawing-portal");
452
+ if (!drawingPortal) {
453
+ drawingPortal = document.createElement("div");
454
+ drawingPortal.id = "components-drawing-portal";
455
+ document.body.appendChild(drawingPortal);
456
+ }
457
+ return ReactDOM.createPortal(nodes, drawingPortal);
458
+ }
459
+ }
460
+ componentDidMount() {
461
+ this._mounted = true;
462
+ ViewportComponentEvents.onViewRotationChangeEvent.addListener(this._handleViewRotationChangeEvent);
463
+ window.addEventListener("mousedown", this._handleMouseDown);
464
+ window.addEventListener("mouseup", this._handleMouseDragEnd);
465
+ window.addEventListener("mousemove", this._handleMouseDrag);
466
+ window.addEventListener("keyup", this._handleKeyUp);
467
+ }
468
+ componentWillUnmount() {
469
+ ViewportComponentEvents.onViewRotationChangeEvent.removeListener(this._handleViewRotationChangeEvent);
470
+ window.removeEventListener("mousedown", this._handleMouseDown);
471
+ window.removeEventListener("mouseup", this._handleMouseDragEnd);
472
+ window.removeEventListener("mousemove", this._handleMouseDrag);
473
+ window.removeEventListener("keyup", this._handleKeyUp);
474
+ clearTimeout(this._animationFrame);
475
+ if (this.props.onAnimationEnd)
476
+ this.props.onAnimationEnd();
477
+ const rt = document.getElementById("components-drawing-portal");
478
+ if (rt && rt.parentElement !== null && rt.children.length === 0) {
479
+ rt.parentElement.removeChild(rt);
480
+ }
481
+ this._mounted = false;
482
+ }
483
+ _processWindowDrag(movement) {
484
+ const vect = Vector3d.create(movement.x / this.state.drawingZoom, -movement.y / this.state.drawingZoom, 0);
485
+ const offset = this.state.rotateMinimapWithView || this._isViewport3D() ? this.state.rotation.multiplyTransposeVector(vect) : vect;
486
+ const origin = this.state.origin.plus(offset);
487
+ const panningDirection = this._getPanVector();
488
+ const wasAlmostZero = this.state.panningDirection.isAlmostZero;
489
+ this.setState({ startOrigin: origin, origin, panningDirection, isPanning: false }, () => {
490
+ this._updateFrustum();
491
+ if (wasAlmostZero && !this.state.panningDirection.isAlmostZero) {
492
+ this._animationFrame = setTimeout(this._panAnimation, 16.667);
493
+ }
494
+ });
495
+ }
496
+ _processWindowEndDrag() {
497
+ this.setState({ isMoving: false });
498
+ this._updateFrustum(true);
499
+ if (this.state.mode === MapMode.Closed) {
500
+ setTimeout(() => {
501
+ const startMapOrigin = this.state.mapOrigin;
502
+ const mapOrigin = this.state.origin.clone();
503
+ // istanbul ignore next
504
+ if (this._mounted) {
505
+ this.setState({ startMapOrigin, mapOrigin, animation: 0 }, () => {
506
+ this._animationFrame = setTimeout(this._animation, 16.667);
507
+ });
508
+ }
509
+ }, 0);
510
+ }
511
+ }
512
+ }
513
+ DrawingNavigationAid._animationFn = (t) => t < .5 ? 2 * t ** 2 : -1 + (4 - 2 * t) * t;
514
+ /** @internal */
515
+ DrawingNavigationAid.getDefaultClosedMapSize = () => {
516
+ return Vector3d.create(96, 96);
517
+ };
518
+ /** @internal */
519
+ DrawingNavigationAid.getDefaultOpenedMapSize = (paddingX = 0, paddingY = 0) => {
520
+ return Vector3d.create(window.innerWidth / 3 - 2 * (window.innerWidth - paddingX), window.innerHeight / 3 - 2 * paddingY);
521
+ };
522
+ /** @internal */
523
+ DrawingNavigationAid.findRotatedWindowDimensions = (extents, rotation) => {
524
+ const cos = rotation.at(0, 0);
525
+ const sin = rotation.at(1, 0);
526
+ // extents.x/y should be divided in half, but we don't have to do that immediately.
527
+ const cosWidth = cos * extents.x;
528
+ const sinHeight = sin * extents.y;
529
+ const sinWidth = cos * extents.x;
530
+ const cosHeight = sin * extents.y;
531
+ const a = Math.atan2(sin, cos);
532
+ if (a % Math.PI >= 0 && a % Math.PI < Math.PI / 2) {
533
+ const y1 = -cosHeight - sinWidth;
534
+ const x2 = cosWidth + sinHeight;
535
+ const y3 = cosHeight + sinWidth;
536
+ const x4 = -cosWidth - sinHeight;
537
+ // Instead, divide total difference
538
+ return Vector3d.create(Math.abs(x2 - x4) / 2, Math.abs(y1 - y3) / 2);
539
+ }
540
+ else {
541
+ const x1 = -cosWidth + sinHeight;
542
+ const y2 = -cosHeight + sinWidth;
543
+ const x3 = cosWidth - sinHeight;
544
+ const y4 = cosHeight - sinWidth;
545
+ return Vector3d.create(Math.abs(x1 - x3) / 2, Math.abs(y2 - y4) / 2);
546
+ }
547
+ };
548
+ /** @internal */
549
+ export class DrawingNavigationCanvas extends React.Component {
550
+ constructor() {
551
+ super(...arguments);
552
+ this._canvasElement = React.createRef();
553
+ this._update = () => {
554
+ // istanbul ignore else
555
+ if (this._vp) {
556
+ const max = Math.max(this.props.extents.x, this.props.extents.y);
557
+ this._vp.view.extentLimits = { max, min: Constant.oneMillimeter };
558
+ this._vp.view.setOrigin(this.props.origin);
559
+ this._vp.view.setRotation(this.props.rotation);
560
+ this._vp.view.setExtents(this.props.extents);
561
+ this._vp.applyViewState(this._vp.view);
562
+ }
563
+ };
564
+ }
565
+ render() {
566
+ return (React.createElement("div", { className: "drawing-canvas", "data-testid": "drawing-canvas", ref: this._canvasElement }));
567
+ }
568
+ componentDidMount() {
569
+ if (this._canvasElement.current && this.props.view !== undefined) {
570
+ const viewManager = this.props.viewManagerOverride ? this.props.viewManagerOverride : /* istanbul ignore next */ IModelApp.viewManager;
571
+ /* istanbul ignore next */
572
+ const screenViewport = this.props.screenViewportOverride ? this.props.screenViewportOverride : /* istanbul ignore next */ ScreenViewport;
573
+ const previousView = viewManager.selectedView;
574
+ this._vp = screenViewport.create(this._canvasElement.current, this.props.view);
575
+ this.customizeViewport(this._vp);
576
+ viewManager.addViewport(this._vp);
577
+ void viewManager.setSelectedView(previousView); // switch to original viewport
578
+ this._update();
579
+ }
580
+ }
581
+ customizeViewport(vp) {
582
+ /* istanbul ignore next */
583
+ if (vp.logo.style)
584
+ vp.logo.style.display = "none";
585
+ /* istanbul ignore next */
586
+ if (vp.viewFlags.acsTriad)
587
+ vp.viewFlags = vp.viewFlags.with("acsTriad", false);
588
+ }
589
+ componentDidUpdate(oldProps) {
590
+ const viewManager = this.props.viewManagerOverride ? this.props.viewManagerOverride : /* istanbul ignore next */ IModelApp.viewManager;
591
+ if (this.props.view !== undefined) {
592
+ if (oldProps.view !== this.props.view) {
593
+ const screenViewport = this.props.screenViewportOverride ? this.props.screenViewportOverride : /* istanbul ignore next */ ScreenViewport;
594
+ if (oldProps !== undefined && oldProps.viewId !== "" && oldProps.viewId !== this.props.viewId && this._vp) {
595
+ viewManager.dropViewport(this._vp, true);
596
+ }
597
+ // istanbul ignore else
598
+ if (this._canvasElement.current &&
599
+ (this.props.canvasSizeOverride ||
600
+ ( /* istanbul ignore next */this._canvasElement.current.clientWidth !== 0 && /* istanbul ignore next */ this._canvasElement.current.clientHeight !== 0))) {
601
+ const previousView = viewManager.selectedView;
602
+ this._vp = screenViewport.create(this._canvasElement.current, this.props.view.clone());
603
+ this.customizeViewport(this._vp);
604
+ viewManager.addViewport(this._vp);
605
+ void viewManager.setSelectedView(previousView); // switch to original viewport
606
+ this._update();
607
+ }
608
+ }
609
+ else if (!this.props.origin.isExactEqual(oldProps.origin) || !this.props.extents.isExactEqual(oldProps.extents) || this.props.zoom !== oldProps.zoom || !this.props.rotation.isExactEqual(oldProps.rotation)) {
610
+ this._update();
611
+ }
612
+ }
613
+ }
614
+ componentWillUnmount() {
615
+ if (this._vp) {
616
+ const viewManager = this.props.viewManagerOverride ? this.props.viewManagerOverride : /* istanbul ignore next */ IModelApp.viewManager;
617
+ viewManager.dropViewport(this._vp, true);
618
+ }
619
+ }
620
+ }
621
621
  //# sourceMappingURL=DrawingNavigationAid.js.map