@itwin/imodel-components-react 4.0.0-dev.12 → 4.0.0-dev.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (352) hide show
  1. package/lib/cjs/imodel-components-react/UiIModelComponents.d.ts +28 -28
  2. package/lib/cjs/imodel-components-react/UiIModelComponents.js +75 -77
  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 +190 -186
  6. package/lib/cjs/imodel-components-react/color/AlphaSlider.js.map +1 -1
  7. package/lib/cjs/imodel-components-react/color/AlphaSlider.scss +63 -63
  8. package/lib/cjs/imodel-components-react/color/ColorPickerButton.d.ts +37 -37
  9. package/lib/cjs/imodel-components-react/color/ColorPickerButton.js +112 -108
  10. package/lib/cjs/imodel-components-react/color/ColorPickerButton.js.map +1 -1
  11. package/lib/cjs/imodel-components-react/color/ColorPickerButton.scss +90 -90
  12. package/lib/cjs/imodel-components-react/color/ColorPickerDialog.d.ts +23 -23
  13. package/lib/cjs/imodel-components-react/color/ColorPickerDialog.js +78 -74
  14. package/lib/cjs/imodel-components-react/color/ColorPickerDialog.js.map +1 -1
  15. package/lib/cjs/imodel-components-react/color/ColorPickerPanel.d.ts +21 -21
  16. package/lib/cjs/imodel-components-react/color/ColorPickerPanel.js +149 -145
  17. package/lib/cjs/imodel-components-react/color/ColorPickerPanel.js.map +1 -1
  18. package/lib/cjs/imodel-components-react/color/ColorPickerPanel.scss +93 -93
  19. package/lib/cjs/imodel-components-react/color/ColorPickerPopup.d.ts +44 -44
  20. package/lib/cjs/imodel-components-react/color/ColorPickerPopup.js +143 -139
  21. package/lib/cjs/imodel-components-react/color/ColorPickerPopup.js.map +1 -1
  22. package/lib/cjs/imodel-components-react/color/ColorPickerPopup.scss +62 -62
  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/HueSlider.scss +61 -61
  27. package/lib/cjs/imodel-components-react/color/SaturationPicker.d.ts +20 -20
  28. package/lib/cjs/imodel-components-react/color/SaturationPicker.js +217 -213
  29. package/lib/cjs/imodel-components-react/color/SaturationPicker.js.map +1 -1
  30. package/lib/cjs/imodel-components-react/color/SaturationPicker.scss +35 -35
  31. package/lib/cjs/imodel-components-react/color/Swatch.d.ts +22 -22
  32. package/lib/cjs/imodel-components-react/color/Swatch.js +64 -60
  33. package/lib/cjs/imodel-components-react/color/Swatch.js.map +1 -1
  34. package/lib/cjs/imodel-components-react/color/Swatch.scss +22 -22
  35. package/lib/cjs/imodel-components-react/color/getCSSColorFromDef.d.ts +6 -6
  36. package/lib/cjs/imodel-components-react/color/getCSSColorFromDef.js +23 -23
  37. package/lib/cjs/imodel-components-react/color/getCSSColorFromDef.js.map +1 -1
  38. package/lib/cjs/imodel-components-react/editors/ColorEditor.d.ts +44 -44
  39. package/lib/cjs/imodel-components-react/editors/ColorEditor.js +155 -151
  40. package/lib/cjs/imodel-components-react/editors/ColorEditor.js.map +1 -1
  41. package/lib/cjs/imodel-components-react/editors/ColorEditor.scss +18 -18
  42. package/lib/cjs/imodel-components-react/editors/WeightEditor.d.ts +47 -47
  43. package/lib/cjs/imodel-components-react/editors/WeightEditor.js +164 -160
  44. package/lib/cjs/imodel-components-react/editors/WeightEditor.js.map +1 -1
  45. package/lib/cjs/imodel-components-react/editors/WeightEditor.scss +16 -16
  46. package/lib/cjs/imodel-components-react/inputs/QuantityInput.d.ts +25 -25
  47. package/lib/cjs/imodel-components-react/inputs/QuantityInput.js +100 -96
  48. package/lib/cjs/imodel-components-react/inputs/QuantityInput.js.map +1 -1
  49. package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.d.ts +44 -44
  50. package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.d.ts.map +1 -1
  51. package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.js +272 -268
  52. package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.js.map +1 -1
  53. package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.scss +106 -106
  54. package/lib/cjs/imodel-components-react/lineweight/Swatch.d.ts +33 -33
  55. package/lib/cjs/imodel-components-react/lineweight/Swatch.js +89 -85
  56. package/lib/cjs/imodel-components-react/lineweight/Swatch.js.map +1 -1
  57. package/lib/cjs/imodel-components-react/lineweight/Swatch.scss +48 -48
  58. package/lib/cjs/imodel-components-react/lineweight/WeightPickerButton.d.ts +60 -60
  59. package/lib/cjs/imodel-components-react/lineweight/WeightPickerButton.js +163 -159
  60. package/lib/cjs/imodel-components-react/lineweight/WeightPickerButton.js.map +1 -1
  61. package/lib/cjs/imodel-components-react/lineweight/WeightPickerButton.scss +51 -52
  62. package/lib/cjs/imodel-components-react/navigationaids/Cube.d.ts +45 -45
  63. package/lib/cjs/imodel-components-react/navigationaids/Cube.js +131 -127
  64. package/lib/cjs/imodel-components-react/navigationaids/Cube.js.map +1 -1
  65. package/lib/cjs/imodel-components-react/navigationaids/Cube.scss +19 -19
  66. package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.d.ts +175 -174
  67. package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.d.ts.map +1 -1
  68. package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.js +650 -638
  69. package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.js.map +1 -1
  70. package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.scss +178 -178
  71. package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.d.ts +145 -145
  72. package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.js +657 -653
  73. package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.js.map +1 -1
  74. package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.scss +135 -135
  75. package/lib/cjs/imodel-components-react/quantityformat/FormatPanel.d.ts +26 -26
  76. package/lib/cjs/imodel-components-react/quantityformat/FormatPanel.js +103 -99
  77. package/lib/cjs/imodel-components-react/quantityformat/FormatPanel.js.map +1 -1
  78. package/lib/cjs/imodel-components-react/quantityformat/FormatPanel.scss +59 -63
  79. package/lib/cjs/imodel-components-react/quantityformat/FormatPrecision.d.ts +17 -17
  80. package/lib/cjs/imodel-components-react/quantityformat/FormatPrecision.js +56 -53
  81. package/lib/cjs/imodel-components-react/quantityformat/FormatPrecision.js.map +1 -1
  82. package/lib/cjs/imodel-components-react/quantityformat/FormatSample.d.ts +18 -18
  83. package/lib/cjs/imodel-components-react/quantityformat/FormatSample.js +88 -84
  84. package/lib/cjs/imodel-components-react/quantityformat/FormatSample.js.map +1 -1
  85. package/lib/cjs/imodel-components-react/quantityformat/FormatType.d.ts +17 -17
  86. package/lib/cjs/imodel-components-react/quantityformat/FormatType.js +89 -86
  87. package/lib/cjs/imodel-components-react/quantityformat/FormatType.js.map +1 -1
  88. package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.d.ts +17 -17
  89. package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.js +112 -109
  90. package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.js.map +1 -1
  91. package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.d.ts +19 -19
  92. package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.js +133 -133
  93. package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.js.map +1 -1
  94. package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.d.ts +21 -21
  95. package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.js +187 -184
  96. package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.js.map +1 -1
  97. package/lib/cjs/imodel-components-react/quantityformat/QuantityFormatPanel.d.ts +22 -22
  98. package/lib/cjs/imodel-components-react/quantityformat/QuantityFormatPanel.js +149 -145
  99. package/lib/cjs/imodel-components-react/quantityformat/QuantityFormatPanel.js.map +1 -1
  100. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalPrecision.d.ts +17 -17
  101. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalPrecision.js +63 -59
  102. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalPrecision.js.map +1 -1
  103. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalSeparator.d.ts +17 -17
  104. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalSeparator.js +51 -47
  105. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalSeparator.js.map +1 -1
  106. package/lib/cjs/imodel-components-react/quantityformat/misc/FractionPrecision.d.ts +16 -16
  107. package/lib/cjs/imodel-components-react/quantityformat/misc/FractionPrecision.js +58 -54
  108. package/lib/cjs/imodel-components-react/quantityformat/misc/FractionPrecision.js.map +1 -1
  109. package/lib/cjs/imodel-components-react/quantityformat/misc/ScientificType.d.ts +18 -18
  110. package/lib/cjs/imodel-components-react/quantityformat/misc/ScientificType.js +52 -48
  111. package/lib/cjs/imodel-components-react/quantityformat/misc/ScientificType.js.map +1 -1
  112. package/lib/cjs/imodel-components-react/quantityformat/misc/SignOption.d.ts +17 -17
  113. package/lib/cjs/imodel-components-react/quantityformat/misc/SignOption.js +54 -50
  114. package/lib/cjs/imodel-components-react/quantityformat/misc/SignOption.js.map +1 -1
  115. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSeparatorSelector.d.ts +17 -17
  116. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js +62 -58
  117. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js.map +1 -1
  118. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSizeSelector.d.ts +17 -17
  119. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSizeSelector.js +51 -47
  120. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSizeSelector.js.map +1 -1
  121. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSelector.d.ts +17 -17
  122. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSelector.js +60 -56
  123. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSelector.js.map +1 -1
  124. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSeparator.d.ts +17 -17
  125. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSeparator.js +98 -95
  126. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSeparator.js.map +1 -1
  127. package/lib/cjs/imodel-components-react/quantityformat/misc/UnitDescr.d.ts +23 -23
  128. package/lib/cjs/imodel-components-react/quantityformat/misc/UnitDescr.js +123 -119
  129. package/lib/cjs/imodel-components-react/quantityformat/misc/UnitDescr.js.map +1 -1
  130. package/lib/cjs/imodel-components-react/timeline/BaseSolarDataProvider.d.ts +52 -52
  131. package/lib/cjs/imodel-components-react/timeline/BaseSolarDataProvider.js +143 -143
  132. package/lib/cjs/imodel-components-react/timeline/BaseSolarDataProvider.js.map +1 -1
  133. package/lib/cjs/imodel-components-react/timeline/BaseTimelineDataProvider.d.ts +31 -31
  134. package/lib/cjs/imodel-components-react/timeline/BaseTimelineDataProvider.js +69 -69
  135. package/lib/cjs/imodel-components-react/timeline/BaseTimelineDataProvider.js.map +1 -1
  136. package/lib/cjs/imodel-components-react/timeline/InlineEdit.d.ts +27 -27
  137. package/lib/cjs/imodel-components-react/timeline/InlineEdit.js +85 -81
  138. package/lib/cjs/imodel-components-react/timeline/InlineEdit.js.map +1 -1
  139. package/lib/cjs/imodel-components-react/timeline/InlineEdit.scss +26 -26
  140. package/lib/cjs/imodel-components-react/timeline/PlayerButton.d.ts +33 -33
  141. package/lib/cjs/imodel-components-react/timeline/PlayerButton.js +99 -95
  142. package/lib/cjs/imodel-components-react/timeline/PlayerButton.js.map +1 -1
  143. package/lib/cjs/imodel-components-react/timeline/PlayerButton.scss +28 -28
  144. package/lib/cjs/imodel-components-react/timeline/Scrubber.d.ts +54 -54
  145. package/lib/cjs/imodel-components-react/timeline/Scrubber.js +195 -191
  146. package/lib/cjs/imodel-components-react/timeline/Scrubber.js.map +1 -1
  147. package/lib/cjs/imodel-components-react/timeline/Scrubber.scss +105 -105
  148. package/lib/cjs/imodel-components-react/timeline/SolarTimeline.d.ts +77 -77
  149. package/lib/cjs/imodel-components-react/timeline/SolarTimeline.js +432 -428
  150. package/lib/cjs/imodel-components-react/timeline/SolarTimeline.js.map +1 -1
  151. package/lib/cjs/imodel-components-react/timeline/SolarTimeline.scss +359 -359
  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/SpeedTimeline.scss +39 -39
  156. package/lib/cjs/imodel-components-react/timeline/Timeline.scss +164 -164
  157. package/lib/cjs/imodel-components-react/timeline/TimelineComponent.d.ts +130 -133
  158. package/lib/cjs/imodel-components-react/timeline/TimelineComponent.d.ts.map +1 -1
  159. package/lib/cjs/imodel-components-react/timeline/TimelineComponent.js +398 -365
  160. package/lib/cjs/imodel-components-react/timeline/TimelineComponent.js.map +1 -1
  161. package/lib/cjs/imodel-components-react/timeline/TimelineComponent.scss +178 -161
  162. package/lib/cjs/imodel-components-react/timeline/interfaces.d.ts +174 -174
  163. package/lib/cjs/imodel-components-react/timeline/interfaces.d.ts.map +1 -1
  164. package/lib/cjs/imodel-components-react/timeline/interfaces.js +45 -45
  165. package/lib/cjs/imodel-components-react/timeline/interfaces.js.map +1 -1
  166. package/lib/cjs/imodel-components-react/viewport/ViewportComponent.d.ts +42 -42
  167. package/lib/cjs/imodel-components-react/viewport/ViewportComponent.d.ts.map +1 -1
  168. package/lib/cjs/imodel-components-react/viewport/ViewportComponent.js +276 -274
  169. package/lib/cjs/imodel-components-react/viewport/ViewportComponent.js.map +1 -1
  170. package/lib/cjs/imodel-components-react/viewport/ViewportComponentEvents.d.ts +106 -106
  171. package/lib/cjs/imodel-components-react/viewport/ViewportComponentEvents.js +105 -105
  172. package/lib/cjs/imodel-components-react/viewport/ViewportComponentEvents.js.map +1 -1
  173. package/lib/cjs/imodel-components-react.d.ts +82 -82
  174. package/lib/cjs/imodel-components-react.js +105 -101
  175. package/lib/cjs/imodel-components-react.js.map +1 -1
  176. package/lib/esm/imodel-components-react/UiIModelComponents.d.ts +28 -28
  177. package/lib/esm/imodel-components-react/UiIModelComponents.js +72 -73
  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/AlphaSlider.scss +63 -63
  183. package/lib/esm/imodel-components-react/color/ColorPickerButton.d.ts +37 -37
  184. package/lib/esm/imodel-components-react/color/ColorPickerButton.js +83 -83
  185. package/lib/esm/imodel-components-react/color/ColorPickerButton.js.map +1 -1
  186. package/lib/esm/imodel-components-react/color/ColorPickerButton.scss +90 -90
  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/ColorPickerDialog.js.map +1 -1
  190. package/lib/esm/imodel-components-react/color/ColorPickerPanel.d.ts +21 -21
  191. package/lib/esm/imodel-components-react/color/ColorPickerPanel.js +122 -122
  192. package/lib/esm/imodel-components-react/color/ColorPickerPanel.js.map +1 -1
  193. package/lib/esm/imodel-components-react/color/ColorPickerPanel.scss +93 -93
  194. package/lib/esm/imodel-components-react/color/ColorPickerPopup.d.ts +44 -44
  195. package/lib/esm/imodel-components-react/color/ColorPickerPopup.js +114 -114
  196. package/lib/esm/imodel-components-react/color/ColorPickerPopup.js.map +1 -1
  197. package/lib/esm/imodel-components-react/color/ColorPickerPopup.scss +62 -62
  198. package/lib/esm/imodel-components-react/color/HueSlider.d.ts +22 -22
  199. package/lib/esm/imodel-components-react/color/HueSlider.js +173 -173
  200. package/lib/esm/imodel-components-react/color/HueSlider.js.map +1 -1
  201. package/lib/esm/imodel-components-react/color/HueSlider.scss +61 -61
  202. package/lib/esm/imodel-components-react/color/SaturationPicker.d.ts +20 -20
  203. package/lib/esm/imodel-components-react/color/SaturationPicker.js +187 -187
  204. package/lib/esm/imodel-components-react/color/SaturationPicker.js.map +1 -1
  205. package/lib/esm/imodel-components-react/color/SaturationPicker.scss +35 -35
  206. package/lib/esm/imodel-components-react/color/Swatch.d.ts +22 -22
  207. package/lib/esm/imodel-components-react/color/Swatch.js +34 -34
  208. package/lib/esm/imodel-components-react/color/Swatch.js.map +1 -1
  209. package/lib/esm/imodel-components-react/color/Swatch.scss +22 -22
  210. package/lib/esm/imodel-components-react/color/getCSSColorFromDef.d.ts +6 -6
  211. package/lib/esm/imodel-components-react/color/getCSSColorFromDef.js +19 -19
  212. package/lib/esm/imodel-components-react/color/getCSSColorFromDef.js.map +1 -1
  213. package/lib/esm/imodel-components-react/editors/ColorEditor.d.ts +44 -44
  214. package/lib/esm/imodel-components-react/editors/ColorEditor.js +124 -124
  215. package/lib/esm/imodel-components-react/editors/ColorEditor.js.map +1 -1
  216. package/lib/esm/imodel-components-react/editors/ColorEditor.scss +18 -18
  217. package/lib/esm/imodel-components-react/editors/WeightEditor.d.ts +47 -47
  218. package/lib/esm/imodel-components-react/editors/WeightEditor.js +133 -133
  219. package/lib/esm/imodel-components-react/editors/WeightEditor.js.map +1 -1
  220. package/lib/esm/imodel-components-react/editors/WeightEditor.scss +16 -16
  221. package/lib/esm/imodel-components-react/inputs/QuantityInput.d.ts +25 -25
  222. package/lib/esm/imodel-components-react/inputs/QuantityInput.js +70 -70
  223. package/lib/esm/imodel-components-react/inputs/QuantityInput.js.map +1 -1
  224. package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.d.ts +44 -44
  225. package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.d.ts.map +1 -1
  226. package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.js +243 -243
  227. package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.js.map +1 -1
  228. package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.scss +106 -106
  229. package/lib/esm/imodel-components-react/lineweight/Swatch.d.ts +33 -33
  230. package/lib/esm/imodel-components-react/lineweight/Swatch.js +59 -59
  231. package/lib/esm/imodel-components-react/lineweight/Swatch.js.map +1 -1
  232. package/lib/esm/imodel-components-react/lineweight/Swatch.scss +48 -48
  233. package/lib/esm/imodel-components-react/lineweight/WeightPickerButton.d.ts +60 -60
  234. package/lib/esm/imodel-components-react/lineweight/WeightPickerButton.js +134 -133
  235. package/lib/esm/imodel-components-react/lineweight/WeightPickerButton.js.map +1 -1
  236. package/lib/esm/imodel-components-react/lineweight/WeightPickerButton.scss +51 -52
  237. package/lib/esm/imodel-components-react/navigationaids/Cube.d.ts +45 -45
  238. package/lib/esm/imodel-components-react/navigationaids/Cube.js +100 -100
  239. package/lib/esm/imodel-components-react/navigationaids/Cube.js.map +1 -1
  240. package/lib/esm/imodel-components-react/navigationaids/Cube.scss +19 -19
  241. package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.d.ts +175 -174
  242. package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.d.ts.map +1 -1
  243. package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.js +620 -610
  244. package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.js.map +1 -1
  245. package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.scss +178 -178
  246. package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.d.ts +145 -145
  247. package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.js +627 -626
  248. package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.js.map +1 -1
  249. package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.scss +135 -135
  250. package/lib/esm/imodel-components-react/quantityformat/FormatPanel.d.ts +26 -26
  251. package/lib/esm/imodel-components-react/quantityformat/FormatPanel.js +76 -76
  252. package/lib/esm/imodel-components-react/quantityformat/FormatPanel.js.map +1 -1
  253. package/lib/esm/imodel-components-react/quantityformat/FormatPanel.scss +59 -63
  254. package/lib/esm/imodel-components-react/quantityformat/FormatPrecision.d.ts +17 -17
  255. package/lib/esm/imodel-components-react/quantityformat/FormatPrecision.js +29 -30
  256. package/lib/esm/imodel-components-react/quantityformat/FormatPrecision.js.map +1 -1
  257. package/lib/esm/imodel-components-react/quantityformat/FormatSample.d.ts +18 -18
  258. package/lib/esm/imodel-components-react/quantityformat/FormatSample.js +61 -61
  259. package/lib/esm/imodel-components-react/quantityformat/FormatSample.js.map +1 -1
  260. package/lib/esm/imodel-components-react/quantityformat/FormatType.d.ts +17 -17
  261. package/lib/esm/imodel-components-react/quantityformat/FormatType.js +62 -63
  262. package/lib/esm/imodel-components-react/quantityformat/FormatType.js.map +1 -1
  263. package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.d.ts +17 -17
  264. package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.js +82 -83
  265. package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.js.map +1 -1
  266. package/lib/esm/imodel-components-react/quantityformat/FormatUnits.d.ts +19 -19
  267. package/lib/esm/imodel-components-react/quantityformat/FormatUnits.js +106 -110
  268. package/lib/esm/imodel-components-react/quantityformat/FormatUnits.js.map +1 -1
  269. package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.d.ts +21 -21
  270. package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.js +157 -158
  271. package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.js.map +1 -1
  272. package/lib/esm/imodel-components-react/quantityformat/QuantityFormatPanel.d.ts +22 -22
  273. package/lib/esm/imodel-components-react/quantityformat/QuantityFormatPanel.js +122 -122
  274. package/lib/esm/imodel-components-react/quantityformat/QuantityFormatPanel.js.map +1 -1
  275. package/lib/esm/imodel-components-react/quantityformat/misc/DecimalPrecision.d.ts +17 -17
  276. package/lib/esm/imodel-components-react/quantityformat/misc/DecimalPrecision.js +36 -36
  277. package/lib/esm/imodel-components-react/quantityformat/misc/DecimalPrecision.js.map +1 -1
  278. package/lib/esm/imodel-components-react/quantityformat/misc/DecimalSeparator.d.ts +17 -17
  279. package/lib/esm/imodel-components-react/quantityformat/misc/DecimalSeparator.js +24 -24
  280. package/lib/esm/imodel-components-react/quantityformat/misc/DecimalSeparator.js.map +1 -1
  281. package/lib/esm/imodel-components-react/quantityformat/misc/FractionPrecision.d.ts +16 -16
  282. package/lib/esm/imodel-components-react/quantityformat/misc/FractionPrecision.js +31 -31
  283. package/lib/esm/imodel-components-react/quantityformat/misc/FractionPrecision.js.map +1 -1
  284. package/lib/esm/imodel-components-react/quantityformat/misc/ScientificType.d.ts +18 -18
  285. package/lib/esm/imodel-components-react/quantityformat/misc/ScientificType.js +25 -25
  286. package/lib/esm/imodel-components-react/quantityformat/misc/ScientificType.js.map +1 -1
  287. package/lib/esm/imodel-components-react/quantityformat/misc/SignOption.d.ts +17 -17
  288. package/lib/esm/imodel-components-react/quantityformat/misc/SignOption.js +27 -27
  289. package/lib/esm/imodel-components-react/quantityformat/misc/SignOption.js.map +1 -1
  290. package/lib/esm/imodel-components-react/quantityformat/misc/StationSeparatorSelector.d.ts +17 -17
  291. package/lib/esm/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js +35 -35
  292. package/lib/esm/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js.map +1 -1
  293. package/lib/esm/imodel-components-react/quantityformat/misc/StationSizeSelector.d.ts +17 -17
  294. package/lib/esm/imodel-components-react/quantityformat/misc/StationSizeSelector.js +24 -24
  295. package/lib/esm/imodel-components-react/quantityformat/misc/StationSizeSelector.js.map +1 -1
  296. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSelector.d.ts +17 -17
  297. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSelector.js +33 -33
  298. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSelector.js.map +1 -1
  299. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSeparator.d.ts +17 -17
  300. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSeparator.js +68 -69
  301. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSeparator.js.map +1 -1
  302. package/lib/esm/imodel-components-react/quantityformat/misc/UnitDescr.d.ts +23 -23
  303. package/lib/esm/imodel-components-react/quantityformat/misc/UnitDescr.js +96 -96
  304. package/lib/esm/imodel-components-react/quantityformat/misc/UnitDescr.js.map +1 -1
  305. package/lib/esm/imodel-components-react/timeline/BaseSolarDataProvider.d.ts +52 -52
  306. package/lib/esm/imodel-components-react/timeline/BaseSolarDataProvider.js +139 -139
  307. package/lib/esm/imodel-components-react/timeline/BaseSolarDataProvider.js.map +1 -1
  308. package/lib/esm/imodel-components-react/timeline/BaseTimelineDataProvider.d.ts +31 -31
  309. package/lib/esm/imodel-components-react/timeline/BaseTimelineDataProvider.js +65 -65
  310. package/lib/esm/imodel-components-react/timeline/BaseTimelineDataProvider.js.map +1 -1
  311. package/lib/esm/imodel-components-react/timeline/InlineEdit.d.ts +27 -27
  312. package/lib/esm/imodel-components-react/timeline/InlineEdit.js +55 -55
  313. package/lib/esm/imodel-components-react/timeline/InlineEdit.js.map +1 -1
  314. package/lib/esm/imodel-components-react/timeline/InlineEdit.scss +26 -26
  315. package/lib/esm/imodel-components-react/timeline/PlayerButton.d.ts +33 -33
  316. package/lib/esm/imodel-components-react/timeline/PlayerButton.js +68 -68
  317. package/lib/esm/imodel-components-react/timeline/PlayerButton.js.map +1 -1
  318. package/lib/esm/imodel-components-react/timeline/PlayerButton.scss +28 -28
  319. package/lib/esm/imodel-components-react/timeline/Scrubber.d.ts +54 -54
  320. package/lib/esm/imodel-components-react/timeline/Scrubber.js +164 -164
  321. package/lib/esm/imodel-components-react/timeline/Scrubber.js.map +1 -1
  322. package/lib/esm/imodel-components-react/timeline/Scrubber.scss +105 -105
  323. package/lib/esm/imodel-components-react/timeline/SolarTimeline.d.ts +77 -77
  324. package/lib/esm/imodel-components-react/timeline/SolarTimeline.js +402 -402
  325. package/lib/esm/imodel-components-react/timeline/SolarTimeline.js.map +1 -1
  326. package/lib/esm/imodel-components-react/timeline/SolarTimeline.scss +359 -359
  327. package/lib/esm/imodel-components-react/timeline/SpeedTimeline.d.ts +15 -15
  328. package/lib/esm/imodel-components-react/timeline/SpeedTimeline.js +28 -28
  329. package/lib/esm/imodel-components-react/timeline/SpeedTimeline.js.map +1 -1
  330. package/lib/esm/imodel-components-react/timeline/SpeedTimeline.scss +39 -39
  331. package/lib/esm/imodel-components-react/timeline/Timeline.scss +164 -164
  332. package/lib/esm/imodel-components-react/timeline/TimelineComponent.d.ts +130 -133
  333. package/lib/esm/imodel-components-react/timeline/TimelineComponent.d.ts.map +1 -1
  334. package/lib/esm/imodel-components-react/timeline/TimelineComponent.js +368 -339
  335. package/lib/esm/imodel-components-react/timeline/TimelineComponent.js.map +1 -1
  336. package/lib/esm/imodel-components-react/timeline/TimelineComponent.scss +178 -161
  337. package/lib/esm/imodel-components-react/timeline/interfaces.d.ts +174 -174
  338. package/lib/esm/imodel-components-react/timeline/interfaces.d.ts.map +1 -1
  339. package/lib/esm/imodel-components-react/timeline/interfaces.js +42 -42
  340. package/lib/esm/imodel-components-react/timeline/interfaces.js.map +1 -1
  341. package/lib/esm/imodel-components-react/viewport/ViewportComponent.d.ts +42 -42
  342. package/lib/esm/imodel-components-react/viewport/ViewportComponent.d.ts.map +1 -1
  343. package/lib/esm/imodel-components-react/viewport/ViewportComponent.js +249 -251
  344. package/lib/esm/imodel-components-react/viewport/ViewportComponent.js.map +1 -1
  345. package/lib/esm/imodel-components-react/viewport/ViewportComponentEvents.d.ts +106 -106
  346. package/lib/esm/imodel-components-react/viewport/ViewportComponentEvents.js +96 -95
  347. package/lib/esm/imodel-components-react/viewport/ViewportComponentEvents.js.map +1 -1
  348. package/lib/esm/imodel-components-react.d.ts +82 -82
  349. package/lib/esm/imodel-components-react.js +87 -87
  350. package/lib/esm/imodel-components-react.js.map +1 -1
  351. package/lib/public/locales/en/UiIModelComponents.json +139 -139
  352. package/package.json +21 -21
@@ -1,627 +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 { 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
- }
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
+ }
627
628
  //# sourceMappingURL=DrawingNavigationAid.js.map