@itwin/imodel-components-react 4.0.0-dev.9 → 4.0.0

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 (327) hide show
  1. package/CHANGELOG.md +156 -1
  2. package/README.md +2 -2
  3. package/lib/cjs/imodel-components-react/UiIModelComponents.d.ts +28 -28
  4. package/lib/cjs/imodel-components-react/UiIModelComponents.d.ts.map +1 -1
  5. package/lib/cjs/imodel-components-react/UiIModelComponents.js +77 -79
  6. package/lib/cjs/imodel-components-react/UiIModelComponents.js.map +1 -1
  7. package/lib/cjs/imodel-components-react/color/AlphaSlider.d.ts +36 -36
  8. package/lib/cjs/imodel-components-react/color/AlphaSlider.js +190 -186
  9. package/lib/cjs/imodel-components-react/color/AlphaSlider.js.map +1 -1
  10. package/lib/cjs/imodel-components-react/color/ColorPickerButton.d.ts +37 -37
  11. package/lib/cjs/imodel-components-react/color/ColorPickerButton.d.ts.map +1 -1
  12. package/lib/cjs/imodel-components-react/color/ColorPickerButton.js +112 -107
  13. package/lib/cjs/imodel-components-react/color/ColorPickerButton.js.map +1 -1
  14. package/lib/cjs/imodel-components-react/color/ColorPickerButton.scss +4 -4
  15. package/lib/cjs/imodel-components-react/color/ColorPickerDialog.d.ts +23 -23
  16. package/lib/cjs/imodel-components-react/color/ColorPickerDialog.js +78 -74
  17. package/lib/cjs/imodel-components-react/color/ColorPickerDialog.js.map +1 -1
  18. package/lib/cjs/imodel-components-react/color/ColorPickerPopup.d.ts +44 -44
  19. package/lib/cjs/imodel-components-react/color/ColorPickerPopup.d.ts.map +1 -1
  20. package/lib/cjs/imodel-components-react/color/ColorPickerPopup.js +143 -137
  21. package/lib/cjs/imodel-components-react/color/ColorPickerPopup.js.map +1 -1
  22. package/lib/cjs/imodel-components-react/color/ColorPickerPopup.scss +4 -5
  23. package/lib/cjs/imodel-components-react/color/HueSlider.d.ts +22 -22
  24. package/lib/cjs/imodel-components-react/color/HueSlider.js +203 -199
  25. package/lib/cjs/imodel-components-react/color/HueSlider.js.map +1 -1
  26. package/lib/cjs/imodel-components-react/color/SaturationPicker.d.ts +20 -20
  27. package/lib/cjs/imodel-components-react/color/SaturationPicker.js +217 -213
  28. package/lib/cjs/imodel-components-react/color/SaturationPicker.js.map +1 -1
  29. package/lib/cjs/imodel-components-react/color/Swatch.d.ts +22 -22
  30. package/lib/cjs/imodel-components-react/color/Swatch.js +64 -60
  31. package/lib/cjs/imodel-components-react/color/Swatch.js.map +1 -1
  32. package/lib/cjs/imodel-components-react/color/Swatch.scss +1 -2
  33. package/lib/cjs/imodel-components-react/color/getCSSColorFromDef.d.ts +6 -6
  34. package/lib/cjs/imodel-components-react/color/getCSSColorFromDef.js +23 -23
  35. package/lib/cjs/imodel-components-react/editors/ColorEditor.d.ts +44 -44
  36. package/lib/cjs/imodel-components-react/editors/ColorEditor.js +155 -151
  37. package/lib/cjs/imodel-components-react/editors/ColorEditor.js.map +1 -1
  38. package/lib/cjs/imodel-components-react/editors/ColorEditor.scss +1 -1
  39. package/lib/cjs/imodel-components-react/editors/WeightEditor.d.ts +47 -47
  40. package/lib/cjs/imodel-components-react/editors/WeightEditor.js +164 -160
  41. package/lib/cjs/imodel-components-react/editors/WeightEditor.js.map +1 -1
  42. package/lib/cjs/imodel-components-react/editors/WeightEditor.scss +1 -1
  43. package/lib/cjs/imodel-components-react/inputs/QuantityInput.d.ts +25 -25
  44. package/lib/cjs/imodel-components-react/inputs/QuantityInput.js +100 -96
  45. package/lib/cjs/imodel-components-react/inputs/QuantityInput.js.map +1 -1
  46. package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.d.ts +44 -44
  47. package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.d.ts.map +1 -1
  48. package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.js +272 -265
  49. package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.js.map +1 -1
  50. package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.scss +6 -7
  51. package/lib/cjs/imodel-components-react/lineweight/Swatch.d.ts +33 -33
  52. package/lib/cjs/imodel-components-react/lineweight/Swatch.js +89 -85
  53. package/lib/cjs/imodel-components-react/lineweight/Swatch.js.map +1 -1
  54. package/lib/cjs/imodel-components-react/lineweight/Swatch.scss +1 -1
  55. package/lib/cjs/imodel-components-react/lineweight/WeightPickerButton.d.ts +60 -60
  56. package/lib/cjs/imodel-components-react/lineweight/WeightPickerButton.js +163 -159
  57. package/lib/cjs/imodel-components-react/lineweight/WeightPickerButton.js.map +1 -1
  58. package/lib/cjs/imodel-components-react/lineweight/WeightPickerButton.scss +7 -8
  59. package/lib/cjs/imodel-components-react/navigationaids/Cube.d.ts +45 -45
  60. package/lib/cjs/imodel-components-react/navigationaids/Cube.js +131 -127
  61. package/lib/cjs/imodel-components-react/navigationaids/Cube.js.map +1 -1
  62. package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.d.ts +154 -174
  63. package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.d.ts.map +1 -1
  64. package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.js +631 -634
  65. package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.js.map +1 -1
  66. package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.scss +13 -17
  67. package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.d.ts +145 -145
  68. package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.d.ts.map +1 -1
  69. package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.js +657 -647
  70. package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.js.map +1 -1
  71. package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.scss +4 -3
  72. package/lib/cjs/imodel-components-react/quantityformat/FormatPanel.d.ts +26 -26
  73. package/lib/cjs/imodel-components-react/quantityformat/FormatPanel.js +103 -99
  74. package/lib/cjs/imodel-components-react/quantityformat/FormatPanel.js.map +1 -1
  75. package/lib/cjs/imodel-components-react/quantityformat/FormatPanel.scss +2 -6
  76. package/lib/cjs/imodel-components-react/quantityformat/FormatPrecision.d.ts +17 -17
  77. package/lib/cjs/imodel-components-react/quantityformat/FormatPrecision.js +57 -53
  78. package/lib/cjs/imodel-components-react/quantityformat/FormatPrecision.js.map +1 -1
  79. package/lib/cjs/imodel-components-react/quantityformat/FormatSample.d.ts +18 -18
  80. package/lib/cjs/imodel-components-react/quantityformat/FormatSample.d.ts.map +1 -1
  81. package/lib/cjs/imodel-components-react/quantityformat/FormatSample.js +88 -83
  82. package/lib/cjs/imodel-components-react/quantityformat/FormatSample.js.map +1 -1
  83. package/lib/cjs/imodel-components-react/quantityformat/FormatType.d.ts +17 -17
  84. package/lib/cjs/imodel-components-react/quantityformat/FormatType.js +90 -86
  85. package/lib/cjs/imodel-components-react/quantityformat/FormatType.js.map +1 -1
  86. package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.d.ts +17 -17
  87. package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.js +113 -109
  88. package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.js.map +1 -1
  89. package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.d.ts +19 -19
  90. package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.js +137 -133
  91. package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.js.map +1 -1
  92. package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.d.ts +21 -21
  93. package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.js +188 -184
  94. package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.js.map +1 -1
  95. package/lib/cjs/imodel-components-react/quantityformat/QuantityFormatPanel.d.ts +22 -22
  96. package/lib/cjs/imodel-components-react/quantityformat/QuantityFormatPanel.js +149 -145
  97. package/lib/cjs/imodel-components-react/quantityformat/QuantityFormatPanel.js.map +1 -1
  98. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalPrecision.d.ts +17 -17
  99. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalPrecision.js +63 -59
  100. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalPrecision.js.map +1 -1
  101. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalSeparator.d.ts +17 -17
  102. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalSeparator.js +51 -47
  103. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalSeparator.js.map +1 -1
  104. package/lib/cjs/imodel-components-react/quantityformat/misc/FractionPrecision.d.ts +16 -16
  105. package/lib/cjs/imodel-components-react/quantityformat/misc/FractionPrecision.js +58 -54
  106. package/lib/cjs/imodel-components-react/quantityformat/misc/FractionPrecision.js.map +1 -1
  107. package/lib/cjs/imodel-components-react/quantityformat/misc/ScientificType.d.ts +18 -18
  108. package/lib/cjs/imodel-components-react/quantityformat/misc/ScientificType.js +52 -48
  109. package/lib/cjs/imodel-components-react/quantityformat/misc/ScientificType.js.map +1 -1
  110. package/lib/cjs/imodel-components-react/quantityformat/misc/SignOption.d.ts +17 -17
  111. package/lib/cjs/imodel-components-react/quantityformat/misc/SignOption.js +54 -50
  112. package/lib/cjs/imodel-components-react/quantityformat/misc/SignOption.js.map +1 -1
  113. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSeparatorSelector.d.ts +17 -17
  114. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js +62 -58
  115. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js.map +1 -1
  116. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSizeSelector.d.ts +17 -17
  117. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSizeSelector.js +51 -47
  118. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSizeSelector.js.map +1 -1
  119. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSelector.d.ts +17 -17
  120. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSelector.js +60 -56
  121. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSelector.js.map +1 -1
  122. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSeparator.d.ts +17 -17
  123. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSeparator.js +99 -95
  124. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSeparator.js.map +1 -1
  125. package/lib/cjs/imodel-components-react/quantityformat/misc/UnitDescr.d.ts +23 -23
  126. package/lib/cjs/imodel-components-react/quantityformat/misc/UnitDescr.js +123 -119
  127. package/lib/cjs/imodel-components-react/quantityformat/misc/UnitDescr.js.map +1 -1
  128. package/lib/cjs/imodel-components-react/timeline/BaseSolarDataProvider.d.ts +52 -52
  129. package/lib/cjs/imodel-components-react/timeline/BaseSolarDataProvider.d.ts.map +1 -1
  130. package/lib/cjs/imodel-components-react/timeline/BaseSolarDataProvider.js +142 -143
  131. package/lib/cjs/imodel-components-react/timeline/BaseSolarDataProvider.js.map +1 -1
  132. package/lib/cjs/imodel-components-react/timeline/BaseTimelineDataProvider.d.ts +31 -31
  133. package/lib/cjs/imodel-components-react/timeline/BaseTimelineDataProvider.js +69 -69
  134. package/lib/cjs/imodel-components-react/timeline/InlineEdit.d.ts +27 -27
  135. package/lib/cjs/imodel-components-react/timeline/InlineEdit.js +85 -81
  136. package/lib/cjs/imodel-components-react/timeline/InlineEdit.js.map +1 -1
  137. package/lib/cjs/imodel-components-react/timeline/InlineEdit.scss +2 -2
  138. package/lib/cjs/imodel-components-react/timeline/PlayerButton.d.ts +33 -33
  139. package/lib/cjs/imodel-components-react/timeline/PlayerButton.d.ts.map +1 -1
  140. package/lib/cjs/imodel-components-react/timeline/PlayerButton.js +99 -91
  141. package/lib/cjs/imodel-components-react/timeline/PlayerButton.js.map +1 -1
  142. package/lib/cjs/imodel-components-react/timeline/PlayerButton.scss +9 -12
  143. package/lib/cjs/imodel-components-react/timeline/Scrubber.d.ts +54 -54
  144. package/lib/cjs/imodel-components-react/timeline/Scrubber.js +195 -191
  145. package/lib/cjs/imodel-components-react/timeline/Scrubber.js.map +1 -1
  146. package/lib/cjs/imodel-components-react/timeline/Scrubber.scss +8 -15
  147. package/lib/cjs/imodel-components-react/timeline/SolarTimeline.d.ts +77 -77
  148. package/lib/cjs/imodel-components-react/timeline/SolarTimeline.d.ts.map +1 -1
  149. package/lib/cjs/imodel-components-react/timeline/SolarTimeline.js +432 -424
  150. package/lib/cjs/imodel-components-react/timeline/SolarTimeline.js.map +1 -1
  151. package/lib/cjs/imodel-components-react/timeline/SolarTimeline.scss +27 -24
  152. package/lib/cjs/imodel-components-react/timeline/SpeedTimeline.d.ts +15 -15
  153. package/lib/cjs/imodel-components-react/timeline/SpeedTimeline.js +58 -54
  154. package/lib/cjs/imodel-components-react/timeline/SpeedTimeline.js.map +1 -1
  155. package/lib/cjs/imodel-components-react/timeline/TimelineComponent.d.ts +130 -133
  156. package/lib/cjs/imodel-components-react/timeline/TimelineComponent.d.ts.map +1 -1
  157. package/lib/cjs/imodel-components-react/timeline/TimelineComponent.js +398 -358
  158. package/lib/cjs/imodel-components-react/timeline/TimelineComponent.js.map +1 -1
  159. package/lib/cjs/imodel-components-react/timeline/TimelineComponent.scss +25 -11
  160. package/lib/cjs/imodel-components-react/timeline/interfaces.d.ts +145 -174
  161. package/lib/cjs/imodel-components-react/timeline/interfaces.d.ts.map +1 -1
  162. package/lib/cjs/imodel-components-react/timeline/interfaces.js +45 -45
  163. package/lib/cjs/imodel-components-react/timeline/interfaces.js.map +1 -1
  164. package/lib/cjs/imodel-components-react/viewport/ViewportComponent.d.ts +42 -42
  165. package/lib/cjs/imodel-components-react/viewport/ViewportComponent.d.ts.map +1 -1
  166. package/lib/cjs/imodel-components-react/viewport/ViewportComponent.js +278 -274
  167. package/lib/cjs/imodel-components-react/viewport/ViewportComponent.js.map +1 -1
  168. package/lib/cjs/imodel-components-react/viewport/ViewportComponentEvents.d.ts +106 -106
  169. package/lib/cjs/imodel-components-react/viewport/ViewportComponentEvents.js +105 -105
  170. package/lib/cjs/imodel-components-react/viewport/ViewportComponentEvents.js.map +1 -1
  171. package/lib/cjs/imodel-components-react.d.ts +81 -82
  172. package/lib/cjs/imodel-components-react.d.ts.map +1 -1
  173. package/lib/cjs/imodel-components-react.js +104 -101
  174. package/lib/cjs/imodel-components-react.js.map +1 -1
  175. package/lib/esm/imodel-components-react/UiIModelComponents.d.ts +28 -28
  176. package/lib/esm/imodel-components-react/UiIModelComponents.d.ts.map +1 -1
  177. package/lib/esm/imodel-components-react/UiIModelComponents.js +74 -75
  178. package/lib/esm/imodel-components-react/UiIModelComponents.js.map +1 -1
  179. package/lib/esm/imodel-components-react/color/AlphaSlider.d.ts +36 -36
  180. package/lib/esm/imodel-components-react/color/AlphaSlider.js +160 -160
  181. package/lib/esm/imodel-components-react/color/AlphaSlider.js.map +1 -1
  182. package/lib/esm/imodel-components-react/color/ColorPickerButton.d.ts +37 -37
  183. package/lib/esm/imodel-components-react/color/ColorPickerButton.d.ts.map +1 -1
  184. package/lib/esm/imodel-components-react/color/ColorPickerButton.js +83 -82
  185. package/lib/esm/imodel-components-react/color/ColorPickerButton.js.map +1 -1
  186. package/lib/esm/imodel-components-react/color/ColorPickerButton.scss +4 -4
  187. package/lib/esm/imodel-components-react/color/ColorPickerDialog.d.ts +23 -23
  188. package/lib/esm/imodel-components-react/color/ColorPickerDialog.js +51 -51
  189. package/lib/esm/imodel-components-react/color/ColorPickerPopup.d.ts +44 -44
  190. package/lib/esm/imodel-components-react/color/ColorPickerPopup.d.ts.map +1 -1
  191. package/lib/esm/imodel-components-react/color/ColorPickerPopup.js +114 -112
  192. package/lib/esm/imodel-components-react/color/ColorPickerPopup.js.map +1 -1
  193. package/lib/esm/imodel-components-react/color/ColorPickerPopup.scss +4 -5
  194. package/lib/esm/imodel-components-react/color/HueSlider.d.ts +22 -22
  195. package/lib/esm/imodel-components-react/color/HueSlider.js +173 -173
  196. package/lib/esm/imodel-components-react/color/SaturationPicker.d.ts +20 -20
  197. package/lib/esm/imodel-components-react/color/SaturationPicker.js +187 -187
  198. package/lib/esm/imodel-components-react/color/Swatch.d.ts +22 -22
  199. package/lib/esm/imodel-components-react/color/Swatch.js +34 -34
  200. package/lib/esm/imodel-components-react/color/Swatch.scss +1 -2
  201. package/lib/esm/imodel-components-react/color/getCSSColorFromDef.d.ts +6 -6
  202. package/lib/esm/imodel-components-react/color/getCSSColorFromDef.js +19 -19
  203. package/lib/esm/imodel-components-react/editors/ColorEditor.d.ts +44 -44
  204. package/lib/esm/imodel-components-react/editors/ColorEditor.js +124 -124
  205. package/lib/esm/imodel-components-react/editors/ColorEditor.scss +1 -1
  206. package/lib/esm/imodel-components-react/editors/WeightEditor.d.ts +47 -47
  207. package/lib/esm/imodel-components-react/editors/WeightEditor.js +133 -133
  208. package/lib/esm/imodel-components-react/editors/WeightEditor.scss +1 -1
  209. package/lib/esm/imodel-components-react/inputs/QuantityInput.d.ts +25 -25
  210. package/lib/esm/imodel-components-react/inputs/QuantityInput.js +70 -70
  211. package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.d.ts +44 -44
  212. package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.d.ts.map +1 -1
  213. package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.js +243 -240
  214. package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.js.map +1 -1
  215. package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.scss +6 -7
  216. package/lib/esm/imodel-components-react/lineweight/Swatch.d.ts +33 -33
  217. package/lib/esm/imodel-components-react/lineweight/Swatch.js +59 -59
  218. package/lib/esm/imodel-components-react/lineweight/Swatch.scss +1 -1
  219. package/lib/esm/imodel-components-react/lineweight/WeightPickerButton.d.ts +60 -60
  220. package/lib/esm/imodel-components-react/lineweight/WeightPickerButton.js +134 -133
  221. package/lib/esm/imodel-components-react/lineweight/WeightPickerButton.js.map +1 -1
  222. package/lib/esm/imodel-components-react/lineweight/WeightPickerButton.scss +7 -8
  223. package/lib/esm/imodel-components-react/navigationaids/Cube.d.ts +45 -45
  224. package/lib/esm/imodel-components-react/navigationaids/Cube.js +100 -100
  225. package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.d.ts +154 -174
  226. package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.d.ts.map +1 -1
  227. package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.js +601 -606
  228. package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.js.map +1 -1
  229. package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.scss +13 -17
  230. package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.d.ts +145 -145
  231. package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.d.ts.map +1 -1
  232. package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.js +627 -620
  233. package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.js.map +1 -1
  234. package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.scss +4 -3
  235. package/lib/esm/imodel-components-react/quantityformat/FormatPanel.d.ts +26 -26
  236. package/lib/esm/imodel-components-react/quantityformat/FormatPanel.js +76 -76
  237. package/lib/esm/imodel-components-react/quantityformat/FormatPanel.scss +2 -6
  238. package/lib/esm/imodel-components-react/quantityformat/FormatPrecision.d.ts +17 -17
  239. package/lib/esm/imodel-components-react/quantityformat/FormatPrecision.js +30 -30
  240. package/lib/esm/imodel-components-react/quantityformat/FormatSample.d.ts +18 -18
  241. package/lib/esm/imodel-components-react/quantityformat/FormatSample.d.ts.map +1 -1
  242. package/lib/esm/imodel-components-react/quantityformat/FormatSample.js +61 -60
  243. package/lib/esm/imodel-components-react/quantityformat/FormatSample.js.map +1 -1
  244. package/lib/esm/imodel-components-react/quantityformat/FormatType.d.ts +17 -17
  245. package/lib/esm/imodel-components-react/quantityformat/FormatType.js +63 -63
  246. package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.d.ts +17 -17
  247. package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.js +83 -83
  248. package/lib/esm/imodel-components-react/quantityformat/FormatUnits.d.ts +19 -19
  249. package/lib/esm/imodel-components-react/quantityformat/FormatUnits.js +110 -110
  250. package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.d.ts +21 -21
  251. package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.js +158 -158
  252. package/lib/esm/imodel-components-react/quantityformat/QuantityFormatPanel.d.ts +22 -22
  253. package/lib/esm/imodel-components-react/quantityformat/QuantityFormatPanel.js +122 -122
  254. package/lib/esm/imodel-components-react/quantityformat/misc/DecimalPrecision.d.ts +17 -17
  255. package/lib/esm/imodel-components-react/quantityformat/misc/DecimalPrecision.js +36 -36
  256. package/lib/esm/imodel-components-react/quantityformat/misc/DecimalSeparator.d.ts +17 -17
  257. package/lib/esm/imodel-components-react/quantityformat/misc/DecimalSeparator.js +24 -24
  258. package/lib/esm/imodel-components-react/quantityformat/misc/FractionPrecision.d.ts +16 -16
  259. package/lib/esm/imodel-components-react/quantityformat/misc/FractionPrecision.js +31 -31
  260. package/lib/esm/imodel-components-react/quantityformat/misc/ScientificType.d.ts +18 -18
  261. package/lib/esm/imodel-components-react/quantityformat/misc/ScientificType.js +25 -25
  262. package/lib/esm/imodel-components-react/quantityformat/misc/SignOption.d.ts +17 -17
  263. package/lib/esm/imodel-components-react/quantityformat/misc/SignOption.js +27 -27
  264. package/lib/esm/imodel-components-react/quantityformat/misc/StationSeparatorSelector.d.ts +17 -17
  265. package/lib/esm/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js +35 -35
  266. package/lib/esm/imodel-components-react/quantityformat/misc/StationSizeSelector.d.ts +17 -17
  267. package/lib/esm/imodel-components-react/quantityformat/misc/StationSizeSelector.js +24 -24
  268. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSelector.d.ts +17 -17
  269. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSelector.js +33 -33
  270. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSeparator.d.ts +17 -17
  271. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSeparator.js +69 -69
  272. package/lib/esm/imodel-components-react/quantityformat/misc/UnitDescr.d.ts +23 -23
  273. package/lib/esm/imodel-components-react/quantityformat/misc/UnitDescr.js +96 -96
  274. package/lib/esm/imodel-components-react/timeline/BaseSolarDataProvider.d.ts +52 -52
  275. package/lib/esm/imodel-components-react/timeline/BaseSolarDataProvider.d.ts.map +1 -1
  276. package/lib/esm/imodel-components-react/timeline/BaseSolarDataProvider.js +138 -139
  277. package/lib/esm/imodel-components-react/timeline/BaseSolarDataProvider.js.map +1 -1
  278. package/lib/esm/imodel-components-react/timeline/BaseTimelineDataProvider.d.ts +31 -31
  279. package/lib/esm/imodel-components-react/timeline/BaseTimelineDataProvider.js +65 -65
  280. package/lib/esm/imodel-components-react/timeline/InlineEdit.d.ts +27 -27
  281. package/lib/esm/imodel-components-react/timeline/InlineEdit.js +55 -55
  282. package/lib/esm/imodel-components-react/timeline/InlineEdit.scss +2 -2
  283. package/lib/esm/imodel-components-react/timeline/PlayerButton.d.ts +33 -33
  284. package/lib/esm/imodel-components-react/timeline/PlayerButton.d.ts.map +1 -1
  285. package/lib/esm/imodel-components-react/timeline/PlayerButton.js +68 -64
  286. package/lib/esm/imodel-components-react/timeline/PlayerButton.js.map +1 -1
  287. package/lib/esm/imodel-components-react/timeline/PlayerButton.scss +9 -12
  288. package/lib/esm/imodel-components-react/timeline/Scrubber.d.ts +54 -54
  289. package/lib/esm/imodel-components-react/timeline/Scrubber.js +164 -164
  290. package/lib/esm/imodel-components-react/timeline/Scrubber.scss +8 -15
  291. package/lib/esm/imodel-components-react/timeline/SolarTimeline.d.ts +77 -77
  292. package/lib/esm/imodel-components-react/timeline/SolarTimeline.d.ts.map +1 -1
  293. package/lib/esm/imodel-components-react/timeline/SolarTimeline.js +402 -398
  294. package/lib/esm/imodel-components-react/timeline/SolarTimeline.js.map +1 -1
  295. package/lib/esm/imodel-components-react/timeline/SolarTimeline.scss +27 -24
  296. package/lib/esm/imodel-components-react/timeline/SpeedTimeline.d.ts +15 -15
  297. package/lib/esm/imodel-components-react/timeline/SpeedTimeline.js +28 -28
  298. package/lib/esm/imodel-components-react/timeline/TimelineComponent.d.ts +130 -133
  299. package/lib/esm/imodel-components-react/timeline/TimelineComponent.d.ts.map +1 -1
  300. package/lib/esm/imodel-components-react/timeline/TimelineComponent.js +368 -332
  301. package/lib/esm/imodel-components-react/timeline/TimelineComponent.js.map +1 -1
  302. package/lib/esm/imodel-components-react/timeline/TimelineComponent.scss +25 -11
  303. package/lib/esm/imodel-components-react/timeline/interfaces.d.ts +145 -174
  304. package/lib/esm/imodel-components-react/timeline/interfaces.d.ts.map +1 -1
  305. package/lib/esm/imodel-components-react/timeline/interfaces.js +42 -42
  306. package/lib/esm/imodel-components-react/timeline/interfaces.js.map +1 -1
  307. package/lib/esm/imodel-components-react/viewport/ViewportComponent.d.ts +42 -42
  308. package/lib/esm/imodel-components-react/viewport/ViewportComponent.d.ts.map +1 -1
  309. package/lib/esm/imodel-components-react/viewport/ViewportComponent.js +251 -251
  310. package/lib/esm/imodel-components-react/viewport/ViewportComponentEvents.d.ts +106 -106
  311. package/lib/esm/imodel-components-react/viewport/ViewportComponentEvents.js +96 -95
  312. package/lib/esm/imodel-components-react/viewport/ViewportComponentEvents.js.map +1 -1
  313. package/lib/esm/imodel-components-react.d.ts +81 -82
  314. package/lib/esm/imodel-components-react.d.ts.map +1 -1
  315. package/lib/esm/imodel-components-react.js +86 -87
  316. package/lib/esm/imodel-components-react.js.map +1 -1
  317. package/package.json +35 -37
  318. package/lib/cjs/imodel-components-react/color/ColorPickerPanel.d.ts +0 -22
  319. package/lib/cjs/imodel-components-react/color/ColorPickerPanel.d.ts.map +0 -1
  320. package/lib/cjs/imodel-components-react/color/ColorPickerPanel.js +0 -146
  321. package/lib/cjs/imodel-components-react/color/ColorPickerPanel.js.map +0 -1
  322. package/lib/cjs/imodel-components-react/color/ColorPickerPanel.scss +0 -94
  323. package/lib/esm/imodel-components-react/color/ColorPickerPanel.d.ts +0 -22
  324. package/lib/esm/imodel-components-react/color/ColorPickerPanel.d.ts.map +0 -1
  325. package/lib/esm/imodel-components-react/color/ColorPickerPanel.js +0 -123
  326. package/lib/esm/imodel-components-react/color/ColorPickerPanel.js.map +0 -1
  327. package/lib/esm/imodel-components-react/color/ColorPickerPanel.scss +0 -94
@@ -1,621 +1,628 @@
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
+ 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
+ export { DrawingNavigationAid };
555
+ /** @internal */
556
+ export class DrawingNavigationCanvas extends React.Component {
557
+ constructor() {
558
+ super(...arguments);
559
+ this._canvasElement = React.createRef();
560
+ this._update = () => {
561
+ // istanbul ignore else
562
+ if (this._vp) {
563
+ const max = Math.max(this.props.extents.x, this.props.extents.y);
564
+ this._vp.view.extentLimits = { max, min: Constant.oneMillimeter };
565
+ this._vp.view.setOrigin(this.props.origin);
566
+ this._vp.view.setRotation(this.props.rotation);
567
+ this._vp.view.setExtents(this.props.extents);
568
+ this._vp.applyViewState(this._vp.view);
569
+ }
570
+ };
571
+ }
572
+ render() {
573
+ return (React.createElement("div", { className: "drawing-canvas", "data-testid": "drawing-canvas", ref: this._canvasElement }));
574
+ }
575
+ componentDidMount() {
576
+ if (this._canvasElement.current && this.props.view !== undefined) {
577
+ const viewManager = this.props.viewManagerOverride ? this.props.viewManagerOverride : /* istanbul ignore next */ IModelApp.viewManager;
578
+ /* istanbul ignore next */
579
+ const screenViewport = this.props.screenViewportOverride ? this.props.screenViewportOverride : /* istanbul ignore next */ ScreenViewport;
580
+ const previousView = viewManager.selectedView;
581
+ this._vp = screenViewport.create(this._canvasElement.current, this.props.view);
582
+ this.customizeViewport(this._vp);
583
+ viewManager.addViewport(this._vp);
584
+ void viewManager.setSelectedView(previousView); // switch to original viewport
585
+ this._update();
586
+ }
587
+ }
588
+ customizeViewport(vp) {
589
+ /* istanbul ignore next */
590
+ if (vp.logo.style)
591
+ vp.logo.style.display = "none";
592
+ /* istanbul ignore next */
593
+ if (vp.viewFlags.acsTriad)
594
+ vp.viewFlags = vp.viewFlags.with("acsTriad", false);
595
+ }
596
+ componentDidUpdate(oldProps) {
597
+ const viewManager = this.props.viewManagerOverride ? this.props.viewManagerOverride : /* istanbul ignore next */ IModelApp.viewManager;
598
+ if (this.props.view !== undefined) {
599
+ if (oldProps.view !== this.props.view) {
600
+ const screenViewport = this.props.screenViewportOverride ? this.props.screenViewportOverride : /* istanbul ignore next */ ScreenViewport;
601
+ if (oldProps !== undefined && oldProps.viewId !== "" && oldProps.viewId !== this.props.viewId && this._vp) {
602
+ viewManager.dropViewport(this._vp, true);
603
+ }
604
+ // istanbul ignore else
605
+ if (this._canvasElement.current &&
606
+ (this.props.canvasSizeOverride ||
607
+ ( /* istanbul ignore next */this._canvasElement.current.clientWidth !== 0 && /* istanbul ignore next */ this._canvasElement.current.clientHeight !== 0))) {
608
+ const previousView = viewManager.selectedView;
609
+ this._vp = screenViewport.create(this._canvasElement.current, this.props.view.clone());
610
+ this.customizeViewport(this._vp);
611
+ viewManager.addViewport(this._vp);
612
+ void viewManager.setSelectedView(previousView); // switch to original viewport
613
+ this._update();
614
+ }
615
+ }
616
+ 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)) {
617
+ this._update();
618
+ }
619
+ }
620
+ }
621
+ componentWillUnmount() {
622
+ if (this._vp) {
623
+ const viewManager = this.props.viewManagerOverride ? this.props.viewManagerOverride : /* istanbul ignore next */ IModelApp.viewManager;
624
+ viewManager.dropViewport(this._vp, true);
625
+ }
626
+ }
627
+ }
621
628
  //# sourceMappingURL=DrawingNavigationAid.js.map