@itwin/imodel-components-react 4.0.0-dev.10 → 4.0.0-dev.11

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