@itwin/imodel-components-react 3.0.0-extension.1 → 3.0.2
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.
- package/CHANGELOG.md +51 -0
- package/LICENSE.md +1 -1
- package/lib/cjs/imodel-components-react/color/ColorPickerDialog.d.ts +3 -2
- package/lib/cjs/imodel-components-react/color/ColorPickerDialog.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/color/ColorPickerDialog.js +17 -4
- package/lib/cjs/imodel-components-react/color/ColorPickerDialog.js.map +1 -1
- package/lib/cjs/imodel-components-react/color/ColorPickerPanel.d.ts +2 -2
- package/lib/cjs/imodel-components-react/color/ColorPickerPanel.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/color/ColorPickerPanel.js +1 -1
- package/lib/cjs/imodel-components-react/color/ColorPickerPanel.js.map +1 -1
- package/lib/cjs/imodel-components-react/color/ColorPickerPopup.d.ts +4 -3
- package/lib/cjs/imodel-components-react/color/ColorPickerPopup.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/color/ColorPickerPopup.js +41 -22
- package/lib/cjs/imodel-components-react/color/ColorPickerPopup.js.map +1 -1
- package/lib/cjs/imodel-components-react/color/ColorPickerPopup.scss +12 -2
- package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.js +3 -2
- package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.js.map +1 -1
- package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.scss +19 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatSample.js +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatSample.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatType.js +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatType.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.js +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.js +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/QuantityFormatPanel.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/QuantityFormatPanel.js +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/QuantityFormatPanel.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalPrecision.js +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalPrecision.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalSeparator.js +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalSeparator.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/FractionPrecision.js +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/FractionPrecision.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/ScientificType.js +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/ScientificType.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/SignOption.js +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/SignOption.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/StationSizeSelector.js +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/StationSizeSelector.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSelector.js +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSelector.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/UnitDescr.js +2 -2
- package/lib/cjs/imodel-components-react/quantityformat/misc/UnitDescr.js.map +1 -1
- package/lib/cjs/imodel-components-react/timeline/InlineEdit.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/timeline/InlineEdit.js +1 -1
- package/lib/cjs/imodel-components-react/timeline/InlineEdit.js.map +1 -1
- package/lib/cjs/imodel-components-react/viewport/ViewportComponent.d.ts +1 -25
- package/lib/cjs/imodel-components-react/viewport/ViewportComponent.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/viewport/ViewportComponent.js +201 -186
- package/lib/cjs/imodel-components-react/viewport/ViewportComponent.js.map +1 -1
- package/lib/cjs/imodel-components-react/viewport/ViewportComponentEvents.d.ts +1 -1
- package/lib/cjs/imodel-components-react/viewport/ViewportComponentEvents.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/viewport/ViewportComponentEvents.js +8 -7
- package/lib/cjs/imodel-components-react/viewport/ViewportComponentEvents.js.map +1 -1
- package/lib/esm/imodel-components-react/color/ColorPickerDialog.d.ts +3 -2
- package/lib/esm/imodel-components-react/color/ColorPickerDialog.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/color/ColorPickerDialog.js +17 -4
- package/lib/esm/imodel-components-react/color/ColorPickerDialog.js.map +1 -1
- package/lib/esm/imodel-components-react/color/ColorPickerPanel.d.ts +2 -2
- package/lib/esm/imodel-components-react/color/ColorPickerPanel.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/color/ColorPickerPanel.js +1 -1
- package/lib/esm/imodel-components-react/color/ColorPickerPanel.js.map +1 -1
- package/lib/esm/imodel-components-react/color/ColorPickerPopup.d.ts +4 -3
- package/lib/esm/imodel-components-react/color/ColorPickerPopup.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/color/ColorPickerPopup.js +41 -22
- package/lib/esm/imodel-components-react/color/ColorPickerPopup.js.map +1 -1
- package/lib/esm/imodel-components-react/color/ColorPickerPopup.scss +12 -2
- package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.js +3 -2
- package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.js.map +1 -1
- package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.scss +19 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatSample.js +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatSample.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatType.js +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatType.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.js +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatUnits.js +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatUnits.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/QuantityFormatPanel.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/QuantityFormatPanel.js +1 -1
- package/lib/esm/imodel-components-react/quantityformat/QuantityFormatPanel.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/DecimalPrecision.js +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/DecimalPrecision.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/DecimalSeparator.js +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/DecimalSeparator.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/FractionPrecision.js +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/FractionPrecision.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/ScientificType.js +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/ScientificType.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/SignOption.js +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/SignOption.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/StationSizeSelector.js +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/StationSizeSelector.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSelector.js +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSelector.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/UnitDescr.js +2 -2
- package/lib/esm/imodel-components-react/quantityformat/misc/UnitDescr.js.map +1 -1
- package/lib/esm/imodel-components-react/timeline/InlineEdit.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/timeline/InlineEdit.js +1 -1
- package/lib/esm/imodel-components-react/timeline/InlineEdit.js.map +1 -1
- package/lib/esm/imodel-components-react/viewport/ViewportComponent.d.ts +1 -25
- package/lib/esm/imodel-components-react/viewport/ViewportComponent.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/viewport/ViewportComponent.js +201 -186
- package/lib/esm/imodel-components-react/viewport/ViewportComponent.js.map +1 -1
- package/lib/esm/imodel-components-react/viewport/ViewportComponentEvents.d.ts +1 -1
- package/lib/esm/imodel-components-react/viewport/ViewportComponentEvents.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/viewport/ViewportComponentEvents.js +2 -1
- package/lib/esm/imodel-components-react/viewport/ViewportComponentEvents.js.map +1 -1
- package/lib/public/locales/en/UiIModelComponents.json +3 -1
- package/package.json +27 -29
|
@@ -10,186 +10,68 @@ import { Logger } from "@itwin/core-bentley";
|
|
|
10
10
|
import { Transform } from "@itwin/core-geometry";
|
|
11
11
|
import { NpcCenter } from "@itwin/core-common";
|
|
12
12
|
import { IModelApp, ScreenViewport, ToolSettings, ViewState, } from "@itwin/core-frontend";
|
|
13
|
-
import { UiIModelComponents } from "../UiIModelComponents";
|
|
14
13
|
import { ViewportComponentEvents, } from "./ViewportComponentEvents";
|
|
15
14
|
/**
|
|
16
15
|
* A viewport React component that creates a ScreenViewport.
|
|
17
16
|
* @public
|
|
18
17
|
*/
|
|
19
|
-
export
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
// istanbul ignore else
|
|
34
|
-
if (parentDiv) {
|
|
35
|
-
const parentWindow = parentDiv.ownerDocument.defaultView;
|
|
36
|
-
parentWindow.removeEventListener("beforeunload", this._handleDisconnectFromViewManager, false);
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
this._handleDrawingViewportChangeEvent = (args) => {
|
|
40
|
-
const viewManager = this.props.viewManagerOverride ? this.props.viewManagerOverride : /* istanbul ignore next */ IModelApp.viewManager;
|
|
41
|
-
/* istanbul ignore else */
|
|
42
|
-
if (this._vp && viewManager.selectedView === this._vp) {
|
|
43
|
-
this._vp.view.setOrigin(args.origin);
|
|
44
|
-
this._vp.view.setRotation(args.rotation);
|
|
45
|
-
this._vp.synchWithView({ noSaveInUndo: args.complete !== true });
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
this._handleCubeRotationChangeEvent = (args) => {
|
|
49
|
-
const viewManager = this.props.viewManagerOverride ? this.props.viewManagerOverride : /* istanbul ignore next */ IModelApp.viewManager;
|
|
50
|
-
/* istanbul ignore else */
|
|
51
|
-
if (this._vp && viewManager.selectedView === this._vp) {
|
|
52
|
-
const rotMatrix = args.rotMatrix;
|
|
53
|
-
/* istanbul ignore else */
|
|
54
|
-
if (this._vp.rotation !== rotMatrix) {
|
|
55
|
-
const inverse = rotMatrix.transpose(); // rotation is from current nav cube state...
|
|
56
|
-
const center = this._getRotatePoint(this._vp);
|
|
57
|
-
const targetMatrix = inverse.multiplyMatrixMatrix(this._vp.view.getRotation());
|
|
58
|
-
const worldTransform = Transform.createFixedPointAndMatrix(center, targetMatrix);
|
|
59
|
-
const frustum = this._vp.getWorldFrustum();
|
|
60
|
-
frustum.multiply(worldTransform);
|
|
61
|
-
this._vp.view.setupFromFrustum(frustum);
|
|
62
|
-
this._vp.synchWithView({ noSaveInUndo: !args.complete });
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
this._handleStandardRotationChangeEvent = (args) => {
|
|
67
|
-
const viewManager = this.props.viewManagerOverride ? this.props.viewManagerOverride : /* istanbul ignore next */ IModelApp.viewManager;
|
|
68
|
-
/* istanbul ignore else */
|
|
69
|
-
if (this._vp && viewManager.selectedView === this._vp) {
|
|
70
|
-
// this._vp.view.setStandardRotation(args.standardRotation);
|
|
71
|
-
this._vp.view.setRotationAboutPoint(ViewState.getStandardViewMatrix(args.standardRotation));
|
|
72
|
-
this._vp.synchWithView();
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
this._handleViewChanged = (vp) => {
|
|
76
|
-
ViewportComponentEvents.setViewMatrix(vp);
|
|
77
|
-
/* istanbul ignore else */
|
|
78
|
-
if (this._viewClassFullName !== vp.view.classFullName) {
|
|
79
|
-
setTimeout(() => {
|
|
80
|
-
ViewportComponentEvents.onViewClassFullNameChangedEvent.emit({ viewport: vp, oldName: this._viewClassFullName, newName: vp.view.classFullName });
|
|
81
|
-
this._viewClassFullName = vp.view.classFullName;
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
/* istanbul ignore else */
|
|
85
|
-
if (this.state.viewId !== vp.view.id) {
|
|
86
|
-
setTimeout(() => {
|
|
87
|
-
ViewportComponentEvents.onViewIdChangedEvent.emit({ viewport: vp, oldId: this.state.viewId, newId: vp.view.id });
|
|
88
|
-
/* istanbul ignore next - flaky mounted condition in the setTimeout */
|
|
89
|
-
if (this._mounted)
|
|
90
|
-
this.setState({ viewId: vp.view.id });
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
this._handleContextMenu = (e) => {
|
|
95
|
-
e.preventDefault();
|
|
96
|
-
if (this.props.onContextMenu)
|
|
97
|
-
this.props.onContextMenu(e);
|
|
98
|
-
return false;
|
|
99
|
-
};
|
|
100
|
-
this._viewportDiv = React.createRef();
|
|
101
|
-
this.state = {
|
|
102
|
-
viewId: "",
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
async componentDidMount() {
|
|
106
|
-
this._mounted = true;
|
|
18
|
+
export function ViewportComponent(props) {
|
|
19
|
+
const { viewState, imodel, viewDefinitionId, getViewOverlay, viewManagerOverride, tentativePointOverride, onContextMenu, style, className, screenViewportOverride, controlId, viewportRef } = props;
|
|
20
|
+
// istanbul ignore next
|
|
21
|
+
const viewManagerRef = React.useRef(viewManagerOverride !== null && viewManagerOverride !== void 0 ? viewManagerOverride : IModelApp.viewManager);
|
|
22
|
+
const tentativePointOverrideRef = React.useRef(tentativePointOverride);
|
|
23
|
+
const screenViewportCreated = React.useRef(false);
|
|
24
|
+
const viewportDiv = React.useRef(null);
|
|
25
|
+
const screenViewportRef = React.useRef(null);
|
|
26
|
+
const isMounted = React.useRef(false);
|
|
27
|
+
const viewClassFullName = React.useRef("");
|
|
28
|
+
const viewId = React.useRef("0");
|
|
29
|
+
// istanbul ignore next
|
|
30
|
+
const handleViewChanged = (vp) => {
|
|
107
31
|
// istanbul ignore next
|
|
108
|
-
if (!
|
|
109
|
-
Logger.logError(UiIModelComponents.loggerCategory(this), `Parent <div> failed to load`);
|
|
32
|
+
if (!(vp.iModel.isOpen || vp.iModel.isBlank))
|
|
110
33
|
return;
|
|
34
|
+
ViewportComponentEvents.setViewMatrix(vp);
|
|
35
|
+
if (viewClassFullName.current !== vp.view.classFullName) {
|
|
36
|
+
setTimeout(() => {
|
|
37
|
+
ViewportComponentEvents.onViewClassFullNameChangedEvent.emit({ viewport: vp, oldName: viewClassFullName.current, newName: vp.view.classFullName });
|
|
38
|
+
viewClassFullName.current = vp.view.classFullName;
|
|
39
|
+
});
|
|
111
40
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
41
|
+
if (viewId.current !== vp.view.id) {
|
|
42
|
+
setTimeout(() => {
|
|
43
|
+
ViewportComponentEvents.onViewIdChangedEvent.emit({ viewport: vp, oldId: viewId.current, newId: vp.view.id });
|
|
44
|
+
viewId.current = vp.view.id;
|
|
45
|
+
});
|
|
116
46
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
this._vp = screenViewport;
|
|
125
|
-
viewManager.addViewport(this._vp);
|
|
126
|
-
const parentWindow = parentDiv.ownerDocument.defaultView;
|
|
127
|
-
parentWindow.addEventListener("beforeunload", this._handleDisconnectFromViewManager, false);
|
|
128
|
-
ViewportComponentEvents.initialize();
|
|
129
|
-
ViewportComponentEvents.onDrawingViewportChangeEvent.addListener(this._handleDrawingViewportChangeEvent);
|
|
130
|
-
ViewportComponentEvents.onCubeRotationChangeEvent.addListener(this._handleCubeRotationChangeEvent);
|
|
131
|
-
ViewportComponentEvents.onStandardRotationChangeEvent.addListener(this._handleStandardRotationChangeEvent);
|
|
132
|
-
this._vp.onViewChanged.addListener(this._handleViewChanged);
|
|
133
|
-
this._viewClassFullName = this._vp.view.classFullName;
|
|
134
|
-
this.setState({ viewId: this._vp.view.id });
|
|
135
|
-
/* istanbul ignore else */
|
|
136
|
-
if (this.props.viewportRef)
|
|
137
|
-
this.props.viewportRef(this._vp);
|
|
138
|
-
}
|
|
139
|
-
componentWillUnmount() {
|
|
140
|
-
this._mounted = false;
|
|
141
|
-
this._handleDisconnectFromViewManager();
|
|
142
|
-
ViewportComponentEvents.onDrawingViewportChangeEvent.removeListener(this._handleDrawingViewportChangeEvent);
|
|
143
|
-
ViewportComponentEvents.onCubeRotationChangeEvent.removeListener(this._handleCubeRotationChangeEvent);
|
|
144
|
-
ViewportComponentEvents.onStandardRotationChangeEvent.removeListener(this._handleStandardRotationChangeEvent);
|
|
145
|
-
}
|
|
146
|
-
async componentDidUpdate(prevProps) {
|
|
147
|
-
if (this.props.imodel === prevProps.imodel &&
|
|
148
|
-
this.props.viewState === prevProps.viewState &&
|
|
149
|
-
this.props.viewDefinitionId === prevProps.viewDefinitionId)
|
|
150
|
-
return;
|
|
151
|
-
/* istanbul ignore else */
|
|
152
|
-
if (this._vp) {
|
|
153
|
-
const viewState = await this.getViewState();
|
|
154
|
-
if (viewState === undefined) {
|
|
155
|
-
Logger.logError(UiIModelComponents.loggerCategory(this), `Failed to obtain ViewState`);
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
this._vp.changeView(viewState);
|
|
159
|
-
/* istanbul ignore else */
|
|
160
|
-
if (this._mounted)
|
|
161
|
-
this.setState({ viewId: this._vp.view.id });
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
async getViewState() {
|
|
165
|
-
let viewState;
|
|
166
|
-
if (this.props.viewState) {
|
|
167
|
-
if (typeof this.props.viewState === "function")
|
|
168
|
-
viewState = this.props.viewState();
|
|
169
|
-
else
|
|
170
|
-
viewState = this.props.viewState;
|
|
47
|
+
};
|
|
48
|
+
const handleStandardRotationChangeEvent = (args) => {
|
|
49
|
+
const viewManager = viewManagerRef.current;
|
|
50
|
+
const currentScreenViewport = screenViewportRef.current;
|
|
51
|
+
if (currentScreenViewport && viewManager.selectedView === currentScreenViewport) {
|
|
52
|
+
currentScreenViewport.view.setRotationAboutPoint(ViewState.getStandardViewMatrix(args.standardRotation));
|
|
53
|
+
currentScreenViewport.synchWithView();
|
|
171
54
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
}
|
|
55
|
+
};
|
|
56
|
+
const handleDrawingViewportChangeEvent = (args) => {
|
|
57
|
+
const viewManager = viewManagerRef.current;
|
|
58
|
+
const currentScreenViewport = screenViewportRef.current;
|
|
59
|
+
if (currentScreenViewport && viewManager.selectedView === currentScreenViewport) {
|
|
60
|
+
currentScreenViewport.view.setOrigin(args.origin);
|
|
61
|
+
currentScreenViewport.view.setRotation(args.rotation);
|
|
62
|
+
currentScreenViewport.synchWithView({ noSaveInUndo: args.complete !== true });
|
|
181
63
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
64
|
+
};
|
|
65
|
+
const targetPoint = React.useRef(null);
|
|
66
|
+
const getRotatePoint = (vp) => {
|
|
67
|
+
var _a, _b;
|
|
68
|
+
const lastTargetPoint = targetPoint.current;
|
|
69
|
+
// istanbul ignore next
|
|
70
|
+
const tentativePoint = (_a = tentativePointOverrideRef.current) !== null && _a !== void 0 ? _a : IModelApp.tentativePoint;
|
|
71
|
+
// istanbul ignore else
|
|
190
72
|
if (tentativePoint.isActive)
|
|
191
73
|
return tentativePoint.getPoint();
|
|
192
|
-
|
|
74
|
+
// istanbul ignore else
|
|
193
75
|
if (undefined !== vp.viewCmdTargetCenter) {
|
|
194
76
|
const testPt = vp.worldToView(vp.viewCmdTargetCenter);
|
|
195
77
|
const viewRect = vp.viewRect;
|
|
@@ -197,31 +79,164 @@ export class ViewportComponent extends React.Component {
|
|
|
197
79
|
return vp.viewCmdTargetCenter;
|
|
198
80
|
vp.viewCmdTargetCenter = undefined;
|
|
199
81
|
}
|
|
200
|
-
|
|
201
|
-
|
|
82
|
+
// istanbul ignore else
|
|
83
|
+
if (null !== lastTargetPoint) {
|
|
84
|
+
const testPt = vp.worldToView(lastTargetPoint);
|
|
202
85
|
const viewRect = vp.viewRect.clone();
|
|
203
86
|
viewRect.scaleAboutCenter(0.25, 0.25);
|
|
204
87
|
// istanbul ignore next hard to reach because of mocks
|
|
205
88
|
if (viewRect.containsPoint(testPt))
|
|
206
|
-
return
|
|
207
|
-
|
|
89
|
+
return lastTargetPoint;
|
|
90
|
+
targetPoint.current = null;
|
|
208
91
|
}
|
|
209
92
|
const visiblePoint = vp.pickNearestVisibleGeometry(vp.npcToWorld(NpcCenter), vp.pixelsFromInches(ToolSettings.viewToolPickRadiusInches));
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
const
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
93
|
+
targetPoint.current = (undefined !== visiblePoint ? visiblePoint : vp.view.getTargetPoint());
|
|
94
|
+
// istanbul ignore next
|
|
95
|
+
return (_b = targetPoint.current) !== null && _b !== void 0 ? _b : vp.view.getCenter();
|
|
96
|
+
};
|
|
97
|
+
const handleCubeRotationChangeEvent = (args) => {
|
|
98
|
+
const viewManager = viewManagerRef.current;
|
|
99
|
+
const currentScreenViewport = screenViewportRef.current;
|
|
100
|
+
// istanbul ignore else
|
|
101
|
+
if (currentScreenViewport && viewManager.selectedView === currentScreenViewport) {
|
|
102
|
+
const rotMatrix = args.rotMatrix;
|
|
103
|
+
// istanbul ignore else
|
|
104
|
+
if (currentScreenViewport.rotation !== rotMatrix) {
|
|
105
|
+
const inverse = rotMatrix.transpose(); // rotation is from current nav cube state...
|
|
106
|
+
const center = getRotatePoint(currentScreenViewport);
|
|
107
|
+
const targetMatrix = inverse.multiplyMatrixMatrix(currentScreenViewport.view.getRotation());
|
|
108
|
+
const worldTransform = Transform.createFixedPointAndMatrix(center, targetMatrix);
|
|
109
|
+
const frustum = currentScreenViewport.getWorldFrustum();
|
|
110
|
+
frustum.multiply(worldTransform);
|
|
111
|
+
currentScreenViewport.view.setupFromFrustum(frustum);
|
|
112
|
+
currentScreenViewport.synchWithView({ noSaveInUndo: !args.complete });
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
const handleDisconnectFromViewManager = () => {
|
|
117
|
+
const screenViewport = screenViewportRef.current;
|
|
118
|
+
if (screenViewport) {
|
|
119
|
+
const viewManager = IModelApp.viewManager;
|
|
120
|
+
screenViewport.onViewChanged.removeListener(handleViewChanged);
|
|
121
|
+
screenViewportRef.current = null;
|
|
122
|
+
screenViewportCreated.current = false;
|
|
123
|
+
ViewportComponentEvents.onDrawingViewportChangeEvent.removeListener(handleDrawingViewportChangeEvent);
|
|
124
|
+
ViewportComponentEvents.onCubeRotationChangeEvent.removeListener(handleCubeRotationChangeEvent);
|
|
125
|
+
ViewportComponentEvents.onStandardRotationChangeEvent.removeListener(handleStandardRotationChangeEvent);
|
|
126
|
+
viewManager.dropViewport(screenViewport, true);
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
const getScreenViewport = (parentDiv, inViewState) => {
|
|
130
|
+
// istanbul ignore next
|
|
131
|
+
const screenViewportFactory = screenViewportOverride ? screenViewportOverride : ScreenViewport;
|
|
132
|
+
const parentWindow = parentDiv.ownerDocument.defaultView;
|
|
133
|
+
parentWindow.addEventListener("beforeunload", handleDisconnectFromViewManager, true); // listener clear after being called
|
|
134
|
+
ViewportComponentEvents.initialize();
|
|
135
|
+
ViewportComponentEvents.onDrawingViewportChangeEvent.addListener(handleDrawingViewportChangeEvent);
|
|
136
|
+
ViewportComponentEvents.onCubeRotationChangeEvent.addListener(handleCubeRotationChangeEvent);
|
|
137
|
+
ViewportComponentEvents.onStandardRotationChangeEvent.addListener(handleStandardRotationChangeEvent);
|
|
138
|
+
const screenViewport = screenViewportFactory.create(parentDiv, inViewState);
|
|
139
|
+
screenViewportCreated.current = true;
|
|
140
|
+
viewClassFullName.current = screenViewport.view.classFullName;
|
|
141
|
+
viewId.current = screenViewport.view.id;
|
|
142
|
+
screenViewport.onViewChanged.addListener(handleViewChanged);
|
|
143
|
+
return screenViewport;
|
|
144
|
+
};
|
|
145
|
+
React.useEffect(() => {
|
|
146
|
+
isMounted.current = true;
|
|
147
|
+
Logger.logInfo("ViewportComponent", `mounting ViewportComponent for controlId=${controlId}`);
|
|
148
|
+
return () => {
|
|
149
|
+
isMounted.current = false;
|
|
150
|
+
Logger.logInfo("ViewportComponent", `un-mounting ViewportComponent for controlId=${controlId}`);
|
|
151
|
+
handleDisconnectFromViewManager();
|
|
221
152
|
};
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
153
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
154
|
+
}, []);
|
|
155
|
+
const [initialViewState, setInitialViewState] = React.useState(() => {
|
|
156
|
+
if (viewState) {
|
|
157
|
+
if (typeof viewState === "function")
|
|
158
|
+
return viewState().clone();
|
|
159
|
+
else
|
|
160
|
+
return viewState.clone();
|
|
161
|
+
}
|
|
162
|
+
return undefined;
|
|
163
|
+
});
|
|
164
|
+
React.useEffect(() => {
|
|
165
|
+
setInitialViewState(undefined);
|
|
166
|
+
}, [viewDefinitionId, viewState]);
|
|
167
|
+
React.useEffect(() => {
|
|
168
|
+
async function fetchInitialViewstate() {
|
|
169
|
+
let currentViewState;
|
|
170
|
+
if (viewState) {
|
|
171
|
+
if (typeof viewState === "function")
|
|
172
|
+
currentViewState = viewState();
|
|
173
|
+
else
|
|
174
|
+
currentViewState = viewState;
|
|
175
|
+
}
|
|
176
|
+
else if (viewDefinitionId && imodel) {
|
|
177
|
+
try {
|
|
178
|
+
currentViewState = await imodel.views.load(viewDefinitionId);
|
|
179
|
+
// istanbul ignore next
|
|
180
|
+
if (!currentViewState) {
|
|
181
|
+
Logger.logError("ViewportComponent", `Viewstate failed to load`);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
catch (_e) {
|
|
185
|
+
// istanbul ignore next
|
|
186
|
+
Logger.logError("ViewportComponent", `Viewstate failed to load`);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
Logger.logError("ViewportComponent", `A Viewstate or a viewId and imodel must be provided`);
|
|
191
|
+
}
|
|
192
|
+
// istanbul ignore next
|
|
193
|
+
if (isMounted.current && ((currentViewState === null || currentViewState === void 0 ? void 0 : currentViewState.iModel.isOpen) || (currentViewState === null || currentViewState === void 0 ? void 0 : currentViewState.iModel.isBlank))) {
|
|
194
|
+
setInitialViewState(currentViewState === null || currentViewState === void 0 ? void 0 : currentViewState.clone());
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
if (undefined === initialViewState)
|
|
198
|
+
fetchInitialViewstate(); // eslint-disable-line @typescript-eslint/no-floating-promises
|
|
199
|
+
}, [imodel, initialViewState, viewDefinitionId, viewState]);
|
|
200
|
+
const [viewOverlay, setViewOverlay] = React.useState(null);
|
|
201
|
+
// This useEffect connects to ViewManger as soon as initialViewState is available once component is mounted.
|
|
202
|
+
React.useEffect(() => {
|
|
203
|
+
var _a;
|
|
204
|
+
const parentDiv = viewportDiv.current;
|
|
205
|
+
const viewManager = viewManagerRef.current;
|
|
206
|
+
// istanbul ignore next
|
|
207
|
+
if (parentDiv && initialViewState && ((initialViewState === null || initialViewState === void 0 ? void 0 : initialViewState.iModel.isOpen) || (initialViewState === null || initialViewState === void 0 ? void 0 : initialViewState.iModel.isBlank))) {
|
|
208
|
+
if (!screenViewportCreated.current) {
|
|
209
|
+
const screenViewport = getScreenViewport(parentDiv, initialViewState);
|
|
210
|
+
screenViewportRef.current = screenViewport;
|
|
211
|
+
if (viewportRef)
|
|
212
|
+
viewportRef(screenViewport);
|
|
213
|
+
Logger.logInfo("ViewportComponent", `processing viewManager.addViewport for controlId=${controlId}`);
|
|
214
|
+
viewManager.addViewport(screenViewport);
|
|
215
|
+
// overlay component is set up once a ScreenViewport is available. The overlay component must handle any view changes itself.
|
|
216
|
+
setViewOverlay(getViewOverlay ? getViewOverlay(screenViewport) : null);
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
// istanbul ignore next
|
|
220
|
+
(_a = screenViewportRef.current) === null || _a === void 0 ? void 0 : _a.changeView(initialViewState);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
224
|
+
}, [controlId, initialViewState, viewportRef]);
|
|
225
|
+
const handleContextMenu = React.useCallback((e) => {
|
|
226
|
+
e.preventDefault();
|
|
227
|
+
if (onContextMenu)
|
|
228
|
+
onContextMenu(e);
|
|
229
|
+
}, [onContextMenu]);
|
|
230
|
+
const parentDivStyle = {
|
|
231
|
+
height: "100%", width: "100%", position: "relative",
|
|
232
|
+
};
|
|
233
|
+
const viewportDivStyle = {
|
|
234
|
+
...style,
|
|
235
|
+
height: "100%", width: "100%",
|
|
236
|
+
};
|
|
237
|
+
return (React.createElement("div", { style: parentDivStyle, "data-item-id": controlId },
|
|
238
|
+
React.createElement(React.Fragment, null,
|
|
239
|
+
React.createElement("div", { ref: viewportDiv, "data-testid": "viewport-component", className: className, style: viewportDivStyle, onContextMenu: handleContextMenu }),
|
|
240
|
+
viewOverlay)));
|
|
226
241
|
}
|
|
227
242
|
//# sourceMappingURL=ViewportComponent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ViewportComponent.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/viewport/ViewportComponent.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAc,MAAM,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAW,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EACL,SAAS,EAAoB,cAAc,EAC3B,YAAY,EAClB,SAAS,GACpB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EACyF,uBAAuB,GACtH,MAAM,2BAA2B,CAAC;AAuCnC;;;GAGG;AACH,MAAM,OAAO,iBAAkB,SAAQ,KAAK,CAAC,SAAuC;IAQlF,YAAmB,KAAoB;QACrC,KAAK,CAAC,KAAK,CAAC,CAAC;QALP,uBAAkB,GAAW,EAAE,CAAC;QAEhC,aAAQ,GAAY,KAAK,CAAC;QAU1B,qCAAgC,GAAG,GAAG,EAAE;YAC9C,MAAM,cAAc,GAAG,IAAI,CAAC,GAAG,CAAC;YAChC,MAAM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KAAK;SACpB,CAAC;QAEF,OAAO,CACL,6BAAK,KAAK,EAAE,cAAc;YACxB,6BACE,GAAG,EAAE,IAAI,CAAC,YAAY,iBACV,oBAAoB,EAChC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,EAC/B,KAAK,EAAE,gBAAgB,EACvB,aAAa,EAAE,IAAI,CAAC,kBAAkB,GACtC;YACD,WAAW,CACR,CACP,CAAC;IACJ,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Viewport\r\n */\r\n\r\nimport * as React from \"react\";\r\nimport { Id64String, Logger } from \"@itwin/core-bentley\";\r\nimport { Point3d, Transform } from \"@itwin/core-geometry\";\r\nimport { NpcCenter } from \"@itwin/core-common\";\r\nimport {\r\n IModelApp, IModelConnection, ScreenViewport,\r\n TentativePoint, ToolSettings, ViewManager,\r\n Viewport, ViewState,\r\n} from \"@itwin/core-frontend\";\r\n\r\nimport { CommonProps } from \"@itwin/core-react\";\r\nimport { UiIModelComponents } from \"../UiIModelComponents\";\r\nimport {\r\n CubeRotationChangeEventArgs, DrawingViewportChangeEventArgs, StandardRotationChangeEventArgs, ViewportComponentEvents,\r\n} from \"./ViewportComponentEvents\";\r\n\r\n/** Type for a ViewState prop\r\n * @public\r\n */\r\nexport type ViewStateProp = ViewState | (() => ViewState);\r\n\r\n/**\r\n * Properties for [[ViewportComponent]] component.\r\n * @public\r\n */\r\nexport interface ViewportProps extends CommonProps {\r\n /** IModel to display */\r\n imodel: IModelConnection;\r\n /** Id of a default view definition to load as a starting point */\r\n viewDefinitionId?: Id64String;\r\n /** ViewState to use as a starting point */\r\n viewState?: ViewStateProp;\r\n /** Function to get a reference to the ScreenViewport */\r\n viewportRef?: (v: ScreenViewport) => void;\r\n /** controlId for this content component @internal */\r\n controlId?: string;\r\n /** @internal */\r\n onContextMenu?: (e: React.MouseEvent) => boolean;\r\n /** @internal */\r\n getViewOverlay?: (viewport: ScreenViewport) => React.ReactNode;\r\n /** @internal used only for testing */\r\n viewManagerOverride?: ViewManager;\r\n /** @internal used only for testing */\r\n screenViewportOverride?: typeof ScreenViewport;\r\n /** @internal used only for testing */\r\n tentativePointOverride?: TentativePoint;\r\n}\r\n\r\n/** @internal */\r\ninterface ViewportState {\r\n viewId: string;\r\n}\r\n\r\n/**\r\n * A viewport React component that creates a ScreenViewport.\r\n * @public\r\n */\r\nexport class ViewportComponent extends React.Component<ViewportProps, ViewportState> {\r\n\r\n private _viewportDiv: React.RefObject<HTMLDivElement>;\r\n private _vp?: ScreenViewport;\r\n private _viewClassFullName: string = \"\";\r\n private _lastTargetPoint?: Point3d;\r\n private _mounted: boolean = false;\r\n\r\n public constructor(props: ViewportProps) {\r\n super(props);\r\n this._viewportDiv = React.createRef<HTMLDivElement>();\r\n this.state = {\r\n viewId: \"\",\r\n };\r\n }\r\n\r\n private _handleDisconnectFromViewManager = () => {\r\n const screenViewport = this._vp;\r\n const parentDiv = this._viewportDiv.current;\r\n\r\n if (screenViewport) {\r\n const viewManager = IModelApp.viewManager;\r\n viewManager.dropViewport(screenViewport, true);\r\n screenViewport.onViewChanged.removeListener(this._handleViewChanged);\r\n this._vp = undefined;\r\n }\r\n // istanbul ignore else\r\n if (parentDiv) {\r\n const parentWindow = parentDiv.ownerDocument.defaultView as Window;\r\n parentWindow.removeEventListener(\"beforeunload\", this._handleDisconnectFromViewManager, false);\r\n }\r\n };\r\n\r\n public override async componentDidMount() {\r\n this._mounted = true;\r\n\r\n // istanbul ignore next\r\n if (!this._viewportDiv.current) {\r\n Logger.logError(UiIModelComponents.loggerCategory(this), `Parent <div> failed to load`);\r\n return;\r\n }\r\n\r\n const viewState = await this.getViewState();\r\n if (viewState === undefined) {\r\n Logger.logError(UiIModelComponents.loggerCategory(this), `Failed to obtain ViewState`);\r\n return;\r\n }\r\n\r\n /* istanbul ignore next */\r\n if (!this._mounted)\r\n return;\r\n\r\n const viewManager = this.props.viewManagerOverride ? this.props.viewManagerOverride : /* istanbul ignore next */ IModelApp.viewManager;\r\n const screenViewportFactory = this.props.screenViewportOverride ? this.props.screenViewportOverride : /* istanbul ignore next */ ScreenViewport;\r\n const parentDiv = this._viewportDiv.current;\r\n const screenViewport = screenViewportFactory.create(parentDiv, viewState);\r\n this._vp = screenViewport;\r\n viewManager.addViewport(this._vp);\r\n\r\n const parentWindow = parentDiv.ownerDocument.defaultView as Window;\r\n parentWindow.addEventListener(\"beforeunload\", this._handleDisconnectFromViewManager, false);\r\n\r\n ViewportComponentEvents.initialize();\r\n ViewportComponentEvents.onDrawingViewportChangeEvent.addListener(this._handleDrawingViewportChangeEvent);\r\n ViewportComponentEvents.onCubeRotationChangeEvent.addListener(this._handleCubeRotationChangeEvent);\r\n ViewportComponentEvents.onStandardRotationChangeEvent.addListener(this._handleStandardRotationChangeEvent);\r\n\r\n this._vp.onViewChanged.addListener(this._handleViewChanged);\r\n this._viewClassFullName = this._vp.view.classFullName;\r\n this.setState({ viewId: this._vp.view.id });\r\n\r\n /* istanbul ignore else */\r\n if (this.props.viewportRef)\r\n this.props.viewportRef(this._vp);\r\n }\r\n\r\n public override componentWillUnmount() {\r\n this._mounted = false;\r\n this._handleDisconnectFromViewManager();\r\n ViewportComponentEvents.onDrawingViewportChangeEvent.removeListener(this._handleDrawingViewportChangeEvent);\r\n ViewportComponentEvents.onCubeRotationChangeEvent.removeListener(this._handleCubeRotationChangeEvent);\r\n ViewportComponentEvents.onStandardRotationChangeEvent.removeListener(this._handleStandardRotationChangeEvent);\r\n }\r\n\r\n public override async componentDidUpdate(prevProps: ViewportProps) {\r\n if (this.props.imodel === prevProps.imodel &&\r\n this.props.viewState === prevProps.viewState &&\r\n this.props.viewDefinitionId === prevProps.viewDefinitionId)\r\n return;\r\n\r\n /* istanbul ignore else */\r\n if (this._vp) {\r\n const viewState = await this.getViewState();\r\n if (viewState === undefined) {\r\n Logger.logError(UiIModelComponents.loggerCategory(this), `Failed to obtain ViewState`);\r\n return;\r\n }\r\n\r\n this._vp.changeView(viewState);\r\n\r\n /* istanbul ignore else */\r\n if (this._mounted)\r\n this.setState({ viewId: this._vp.view.id });\r\n }\r\n }\r\n\r\n private async getViewState(): Promise<ViewState | undefined> {\r\n let viewState: ViewState;\r\n\r\n if (this.props.viewState) {\r\n if (typeof this.props.viewState === \"function\")\r\n viewState = this.props.viewState();\r\n else\r\n viewState = this.props.viewState;\r\n } else if (this.props.viewDefinitionId) {\r\n viewState = await this.props.imodel.views.load(this.props.viewDefinitionId);\r\n if (!viewState) {\r\n Logger.logError(UiIModelComponents.loggerCategory(this), `View state failed to load`);\r\n return undefined;\r\n } else {\r\n return viewState;\r\n }\r\n } else {\r\n Logger.logError(UiIModelComponents.loggerCategory(this), `Either viewDefinitionId or viewState must be provided as a ViewportComponent Prop`);\r\n return undefined;\r\n }\r\n\r\n return viewState.clone();\r\n }\r\n\r\n private _handleDrawingViewportChangeEvent = (args: DrawingViewportChangeEventArgs) => {\r\n const viewManager = this.props.viewManagerOverride ? this.props.viewManagerOverride : /* istanbul ignore next */ IModelApp.viewManager;\r\n\r\n /* istanbul ignore else */\r\n if (this._vp && viewManager.selectedView === this._vp) {\r\n this._vp.view.setOrigin(args.origin);\r\n this._vp.view.setRotation(args.rotation);\r\n this._vp.synchWithView({ noSaveInUndo: args.complete !== true });\r\n }\r\n };\r\n\r\n private _getRotatePoint(vp: ScreenViewport): Point3d {\r\n const tentativePoint = this.props.tentativePointOverride ? this.props.tentativePointOverride : /* istanbul ignore next */ IModelApp.tentativePoint;\r\n if (tentativePoint.isActive)\r\n return tentativePoint.getPoint();\r\n\r\n /* istanbul ignore else */\r\n if (undefined !== vp.viewCmdTargetCenter) {\r\n const testPt = vp.worldToView(vp.viewCmdTargetCenter);\r\n const viewRect = vp.viewRect;\r\n if (viewRect.containsPoint(testPt))\r\n return vp.viewCmdTargetCenter;\r\n vp.viewCmdTargetCenter = undefined;\r\n }\r\n\r\n if (undefined !== this._lastTargetPoint) {\r\n const testPt = vp.worldToView(this._lastTargetPoint);\r\n const viewRect = vp.viewRect.clone();\r\n viewRect.scaleAboutCenter(0.25, 0.25);\r\n // istanbul ignore next hard to reach because of mocks\r\n if (viewRect.containsPoint(testPt))\r\n return this._lastTargetPoint;\r\n this._lastTargetPoint = undefined;\r\n }\r\n\r\n const visiblePoint = vp.pickNearestVisibleGeometry(vp.npcToWorld(NpcCenter), vp.pixelsFromInches(ToolSettings.viewToolPickRadiusInches));\r\n this._lastTargetPoint = (undefined !== visiblePoint ? visiblePoint : vp.view.getTargetPoint());\r\n return this._lastTargetPoint;\r\n }\r\n\r\n private _handleCubeRotationChangeEvent = (args: CubeRotationChangeEventArgs) => {\r\n const viewManager = this.props.viewManagerOverride ? this.props.viewManagerOverride : /* istanbul ignore next */ IModelApp.viewManager;\r\n\r\n /* istanbul ignore else */\r\n if (this._vp && viewManager.selectedView === this._vp) {\r\n const rotMatrix = args.rotMatrix;\r\n\r\n /* istanbul ignore else */\r\n if (this._vp.rotation !== rotMatrix) {\r\n const inverse = rotMatrix.transpose(); // rotation is from current nav cube state...\r\n const center = this._getRotatePoint(this._vp);\r\n const targetMatrix = inverse.multiplyMatrixMatrix(this._vp.view.getRotation());\r\n const worldTransform = Transform.createFixedPointAndMatrix(center, targetMatrix);\r\n const frustum = this._vp.getWorldFrustum();\r\n frustum.multiply(worldTransform);\r\n this._vp.view.setupFromFrustum(frustum);\r\n this._vp.synchWithView({ noSaveInUndo: !args.complete });\r\n }\r\n }\r\n };\r\n\r\n private _handleStandardRotationChangeEvent = (args: StandardRotationChangeEventArgs) => {\r\n const viewManager = this.props.viewManagerOverride ? this.props.viewManagerOverride : /* istanbul ignore next */ IModelApp.viewManager;\r\n\r\n /* istanbul ignore else */\r\n if (this._vp && viewManager.selectedView === this._vp) {\r\n // this._vp.view.setStandardRotation(args.standardRotation);\r\n this._vp.view.setRotationAboutPoint(ViewState.getStandardViewMatrix(args.standardRotation));\r\n this._vp.synchWithView();\r\n }\r\n };\r\n\r\n private _handleViewChanged = (vp: Viewport) => {\r\n ViewportComponentEvents.setViewMatrix(vp);\r\n\r\n /* istanbul ignore else */\r\n if (this._viewClassFullName !== vp.view.classFullName) {\r\n setTimeout(() => {\r\n ViewportComponentEvents.onViewClassFullNameChangedEvent.emit({ viewport: vp, oldName: this._viewClassFullName, newName: vp.view.classFullName });\r\n this._viewClassFullName = vp.view.classFullName;\r\n });\r\n }\r\n\r\n /* istanbul ignore else */\r\n if (this.state.viewId !== vp.view.id) {\r\n setTimeout(() => {\r\n ViewportComponentEvents.onViewIdChangedEvent.emit({ viewport: vp, oldId: this.state.viewId, newId: vp.view.id });\r\n\r\n /* istanbul ignore next - flaky mounted condition in the setTimeout */\r\n if (this._mounted)\r\n this.setState({ viewId: vp.view.id });\r\n });\r\n }\r\n };\r\n\r\n private _handleContextMenu = (e: React.MouseEvent): boolean => {\r\n e.preventDefault();\r\n if (this.props.onContextMenu)\r\n this.props.onContextMenu(e);\r\n return false;\r\n };\r\n\r\n public override render() {\r\n const viewOverlay = this._vp && this.props.getViewOverlay ? this.props.getViewOverlay(this._vp) : null;\r\n\r\n const parentDivStyle: React.CSSProperties = {\r\n height: \"100%\", width: \"100%\", position: \"relative\",\r\n };\r\n\r\n const viewportDivStyle: React.CSSProperties = {\r\n height: \"100%\", width: \"100%\",\r\n ...this.props.style,\r\n };\r\n\r\n return (\r\n <div style={parentDivStyle}>\r\n <div\r\n ref={this._viewportDiv}\r\n data-testid=\"viewport-component\"\r\n className={this.props.className}\r\n style={viewportDivStyle}\r\n onContextMenu={this._handleContextMenu}\r\n />\r\n {viewOverlay}\r\n </div>\r\n );\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"ViewportComponent.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/viewport/ViewportComponent.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AA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,CAAC,mBAAmB,EAAE,oDAAoD,SAAS,EAAE,CAAC,CAAC;gBACrG,WAAW,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;gBAExC,6HAA6H;gBAC7H,cAAc,CAAC,cAAc,CAAC,CAAC,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;aACxE;iBAAM;gBACL,uBAAuB;gBACvB,MAAA,iBAAiB,CAAC,OAAO,0CAAE,UAAU,CAAC,gBAAgB,CAAC,CAAC;aACzD;SACF;QACD,uDAAuD;IACzD,CAAC,EAAE,CAAC,SAAS,EAAE,gBAAgB,EAAE,WAAW,CAAC,CAAC,CAAC;IAE/C,MAAM,iBAAiB,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,CAAmB,EAAE,EAAE;QAClE,CAAC,CAAC,cAAc,EAAE,CAAC;QACnB,IAAI,aAAa;YACf,aAAa,CAAC,CAAC,CAAC,CAAC;IACrB,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;IAEpB,MAAM,cAAc,GAAwB;QAC1C,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU;KACpD,CAAC;IAEF,MAAM,gBAAgB,GAAwB;QAC5C,GAAG,KAAK;QACR,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;KAC9B,CAAC;IAEF,OAAO,CACL,6BAAK,KAAK,EAAE,cAAc,kBAAgB,SAAS;QAEjD;YACE,6BACE,GAAG,EAAE,WAAW,iBACJ,oBAAoB,EAChC,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,gBAAgB,EACvB,aAAa,EAAE,iBAAiB,GAChC;YACD,WAAW,CACX,CACC,CACP,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Viewport\r\n */\r\n\r\nimport * as React from \"react\";\r\nimport { Id64String, Logger } from \"@itwin/core-bentley\";\r\nimport { Point3d, Transform } from \"@itwin/core-geometry\";\r\nimport { NpcCenter } from \"@itwin/core-common\";\r\nimport {\r\n IModelApp, IModelConnection, ScreenViewport,\r\n TentativePoint, ToolSettings, ViewManager,\r\n Viewport, ViewState,\r\n} from \"@itwin/core-frontend\";\r\n\r\nimport { CommonProps } from \"@itwin/core-react\";\r\nimport {\r\n CubeRotationChangeEventArgs, DrawingViewportChangeEventArgs, StandardRotationChangeEventArgs, ViewportComponentEvents,\r\n} from \"./ViewportComponentEvents\";\r\n\r\n/** Type for a ViewState prop\r\n * @public\r\n */\r\nexport type ViewStateProp = ViewState | (() => ViewState);\r\n\r\n/**\r\n * Properties for [[ViewportComponent]] component.\r\n * @public\r\n */\r\nexport interface ViewportProps extends CommonProps {\r\n /** IModel to display */\r\n imodel: IModelConnection;\r\n /** Id of a default view definition to load as a starting point */\r\n viewDefinitionId?: Id64String;\r\n /** ViewState to use as a starting point */\r\n viewState?: ViewStateProp;\r\n /** Function to get a reference to the ScreenViewport */\r\n viewportRef?: (v: ScreenViewport) => void;\r\n /** controlId for this content component @internal */\r\n controlId?: string;\r\n /** @internal */\r\n onContextMenu?: (e: React.MouseEvent) => boolean;\r\n /** @internal */\r\n getViewOverlay?: (viewport: ScreenViewport) => React.ReactNode;\r\n /** @internal used only for testing */\r\n viewManagerOverride?: ViewManager;\r\n /** @internal used only for testing */\r\n screenViewportOverride?: typeof ScreenViewport;\r\n /** @internal used only for testing */\r\n tentativePointOverride?: TentativePoint;\r\n}\r\n\r\n/**\r\n * A viewport React component that creates a ScreenViewport.\r\n * @public\r\n */\r\nexport function ViewportComponent(props: ViewportProps) {\r\n const { viewState, imodel, viewDefinitionId, getViewOverlay, viewManagerOverride,\r\n tentativePointOverride, onContextMenu, style, className, screenViewportOverride, controlId, viewportRef } = props;\r\n // istanbul ignore next\r\n const viewManagerRef = React.useRef(viewManagerOverride ?? IModelApp.viewManager);\r\n const tentativePointOverrideRef = React.useRef(tentativePointOverride);\r\n const screenViewportCreated = React.useRef(false);\r\n const viewportDiv = React.useRef<HTMLDivElement>(null);\r\n const screenViewportRef = React.useRef<ScreenViewport | null>(null);\r\n const isMounted = React.useRef(false);\r\n const viewClassFullName = React.useRef(\"\");\r\n const viewId = React.useRef(\"0\");\r\n\r\n // istanbul ignore next\r\n const handleViewChanged = (vp: Viewport) => {\r\n // istanbul ignore next\r\n if (!(vp.iModel.isOpen || vp.iModel.isBlank))\r\n return;\r\n ViewportComponentEvents.setViewMatrix(vp);\r\n if (viewClassFullName.current !== vp.view.classFullName) {\r\n setTimeout(() => {\r\n ViewportComponentEvents.onViewClassFullNameChangedEvent.emit({ viewport: vp, oldName: viewClassFullName.current, newName: vp.view.classFullName });\r\n viewClassFullName.current = vp.view.classFullName;\r\n });\r\n }\r\n if (viewId.current !== vp.view.id) {\r\n setTimeout(() => {\r\n ViewportComponentEvents.onViewIdChangedEvent.emit({ viewport: vp, oldId: viewId.current, newId: vp.view.id });\r\n viewId.current = vp.view.id;\r\n });\r\n }\r\n };\r\n\r\n const handleStandardRotationChangeEvent = (args: StandardRotationChangeEventArgs) => {\r\n const viewManager = viewManagerRef.current;\r\n const currentScreenViewport = screenViewportRef.current;\r\n if (currentScreenViewport && viewManager.selectedView === currentScreenViewport) {\r\n currentScreenViewport.view.setRotationAboutPoint(ViewState.getStandardViewMatrix(args.standardRotation));\r\n currentScreenViewport.synchWithView();\r\n }\r\n };\r\n\r\n const handleDrawingViewportChangeEvent = (args: DrawingViewportChangeEventArgs) => {\r\n const viewManager = viewManagerRef.current;\r\n const currentScreenViewport = screenViewportRef.current;\r\n if (currentScreenViewport && viewManager.selectedView === currentScreenViewport) {\r\n currentScreenViewport.view.setOrigin(args.origin);\r\n currentScreenViewport.view.setRotation(args.rotation);\r\n currentScreenViewport.synchWithView({ noSaveInUndo: args.complete !== true });\r\n }\r\n };\r\n\r\n const targetPoint = React.useRef<Point3d | null>(null);\r\n\r\n const getRotatePoint = (vp: ScreenViewport): Point3d => {\r\n const lastTargetPoint = targetPoint.current;\r\n // istanbul ignore next\r\n const tentativePoint = tentativePointOverrideRef.current ?? IModelApp.tentativePoint;\r\n // istanbul ignore else\r\n if (tentativePoint.isActive)\r\n return tentativePoint.getPoint();\r\n\r\n // istanbul ignore else\r\n if (undefined !== vp.viewCmdTargetCenter) {\r\n const testPt = vp.worldToView(vp.viewCmdTargetCenter);\r\n const viewRect = vp.viewRect;\r\n if (viewRect.containsPoint(testPt))\r\n return vp.viewCmdTargetCenter;\r\n vp.viewCmdTargetCenter = undefined;\r\n }\r\n\r\n // istanbul ignore else\r\n if (null !== lastTargetPoint) {\r\n const testPt = vp.worldToView(lastTargetPoint);\r\n const viewRect = vp.viewRect.clone();\r\n viewRect.scaleAboutCenter(0.25, 0.25);\r\n // istanbul ignore next hard to reach because of mocks\r\n if (viewRect.containsPoint(testPt))\r\n return lastTargetPoint;\r\n targetPoint.current = null;\r\n }\r\n\r\n const visiblePoint = vp.pickNearestVisibleGeometry(vp.npcToWorld(NpcCenter), vp.pixelsFromInches(ToolSettings.viewToolPickRadiusInches));\r\n targetPoint.current = (undefined !== visiblePoint ? visiblePoint : vp.view.getTargetPoint());\r\n // istanbul ignore next\r\n return targetPoint.current ?? vp.view.getCenter();\r\n };\r\n\r\n const handleCubeRotationChangeEvent = (args: CubeRotationChangeEventArgs) => {\r\n const viewManager = viewManagerRef.current;\r\n const currentScreenViewport = screenViewportRef.current;\r\n // istanbul ignore else\r\n if (currentScreenViewport && viewManager.selectedView === currentScreenViewport) {\r\n const rotMatrix = args.rotMatrix;\r\n // istanbul ignore else\r\n if (currentScreenViewport.rotation !== rotMatrix) {\r\n const inverse = rotMatrix.transpose(); // rotation is from current nav cube state...\r\n const center = getRotatePoint(currentScreenViewport);\r\n const targetMatrix = inverse.multiplyMatrixMatrix(currentScreenViewport.view.getRotation());\r\n const worldTransform = Transform.createFixedPointAndMatrix(center, targetMatrix);\r\n const frustum = currentScreenViewport.getWorldFrustum();\r\n frustum.multiply(worldTransform);\r\n currentScreenViewport.view.setupFromFrustum(frustum);\r\n currentScreenViewport.synchWithView({ noSaveInUndo: !args.complete });\r\n }\r\n }\r\n };\r\n\r\n const handleDisconnectFromViewManager = () => {\r\n const screenViewport = screenViewportRef.current;\r\n if (screenViewport) {\r\n const viewManager = IModelApp.viewManager;\r\n screenViewport.onViewChanged.removeListener(handleViewChanged);\r\n screenViewportRef.current = null;\r\n screenViewportCreated.current = false;\r\n\r\n ViewportComponentEvents.onDrawingViewportChangeEvent.removeListener(handleDrawingViewportChangeEvent);\r\n ViewportComponentEvents.onCubeRotationChangeEvent.removeListener(handleCubeRotationChangeEvent);\r\n ViewportComponentEvents.onStandardRotationChangeEvent.removeListener(handleStandardRotationChangeEvent);\r\n viewManager.dropViewport(screenViewport, true);\r\n }\r\n };\r\n\r\n const getScreenViewport = (parentDiv: HTMLDivElement, inViewState: ViewState) => {\r\n // istanbul ignore next\r\n const screenViewportFactory = screenViewportOverride ? screenViewportOverride : ScreenViewport;\r\n const parentWindow = parentDiv.ownerDocument.defaultView as Window;\r\n parentWindow.addEventListener(\"beforeunload\", handleDisconnectFromViewManager, true); // listener clear after being called\r\n ViewportComponentEvents.initialize();\r\n ViewportComponentEvents.onDrawingViewportChangeEvent.addListener(handleDrawingViewportChangeEvent);\r\n ViewportComponentEvents.onCubeRotationChangeEvent.addListener(handleCubeRotationChangeEvent);\r\n ViewportComponentEvents.onStandardRotationChangeEvent.addListener(handleStandardRotationChangeEvent);\r\n const screenViewport = screenViewportFactory.create(parentDiv, inViewState);\r\n screenViewportCreated.current = true;\r\n viewClassFullName.current = screenViewport.view.classFullName;\r\n viewId.current = screenViewport.view.id;\r\n screenViewport.onViewChanged.addListener(handleViewChanged);\r\n return screenViewport;\r\n };\r\n\r\n React.useEffect(() => {\r\n isMounted.current = true;\r\n Logger.logInfo(\"ViewportComponent\", `mounting ViewportComponent for controlId=${controlId}`);\r\n\r\n return () => {\r\n isMounted.current = false;\r\n Logger.logInfo(\"ViewportComponent\", `un-mounting ViewportComponent for controlId=${controlId}`);\r\n handleDisconnectFromViewManager();\r\n };\r\n // eslint-disable-next-line react-hooks/exhaustive-deps\r\n }, []);\r\n\r\n const [initialViewState, setInitialViewState] = React.useState<ViewState | undefined>(() => {\r\n if (viewState) {\r\n if (typeof viewState === \"function\")\r\n return viewState().clone();\r\n else\r\n return viewState.clone();\r\n }\r\n return undefined;\r\n });\r\n\r\n React.useEffect(() => {\r\n setInitialViewState(undefined);\r\n }, [viewDefinitionId, viewState]);\r\n React.useEffect(() => {\r\n async function fetchInitialViewstate() {\r\n let currentViewState: ViewState | undefined;\r\n if (viewState) {\r\n if (typeof viewState === \"function\")\r\n currentViewState = viewState();\r\n else\r\n currentViewState = viewState;\r\n } else if (viewDefinitionId && imodel) {\r\n try {\r\n currentViewState = await imodel.views.load(viewDefinitionId);\r\n // istanbul ignore next\r\n if (!currentViewState) {\r\n Logger.logError(\"ViewportComponent\", `Viewstate failed to load`);\r\n }\r\n } catch (_e) {\r\n // istanbul ignore next\r\n Logger.logError(\"ViewportComponent\", `Viewstate failed to load`);\r\n }\r\n } else {\r\n Logger.logError(\"ViewportComponent\", `A Viewstate or a viewId and imodel must be provided`);\r\n }\r\n // istanbul ignore next\r\n if (isMounted.current && (currentViewState?.iModel.isOpen || currentViewState?.iModel.isBlank)) {\r\n setInitialViewState(currentViewState?.clone());\r\n }\r\n }\r\n if (undefined === initialViewState)\r\n fetchInitialViewstate(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }, [imodel, initialViewState, viewDefinitionId, viewState]);\r\n\r\n const [viewOverlay, setViewOverlay] = React.useState<React.ReactNode>(null);\r\n\r\n // This useEffect connects to ViewManger as soon as initialViewState is available once component is mounted.\r\n React.useEffect(() => {\r\n const parentDiv = viewportDiv.current;\r\n const viewManager = viewManagerRef.current;\r\n // istanbul ignore next\r\n if (parentDiv && initialViewState && (initialViewState?.iModel.isOpen || initialViewState?.iModel.isBlank) ) {\r\n if (!screenViewportCreated.current) {\r\n const screenViewport = getScreenViewport(parentDiv, initialViewState);\r\n screenViewportRef.current = screenViewport;\r\n\r\n if (viewportRef)\r\n viewportRef(screenViewport);\r\n\r\n Logger.logInfo(\"ViewportComponent\", `processing viewManager.addViewport for controlId=${controlId}`);\r\n viewManager.addViewport(screenViewport);\r\n\r\n // overlay component is set up once a ScreenViewport is available. The overlay component must handle any view changes itself.\r\n setViewOverlay(getViewOverlay ? getViewOverlay(screenViewport) : null);\r\n } else {\r\n // istanbul ignore next\r\n screenViewportRef.current?.changeView(initialViewState);\r\n }\r\n }\r\n // eslint-disable-next-line react-hooks/exhaustive-deps\r\n }, [controlId, initialViewState, viewportRef]);\r\n\r\n const handleContextMenu = React.useCallback((e: React.MouseEvent) => {\r\n e.preventDefault();\r\n if (onContextMenu)\r\n onContextMenu(e);\r\n }, [onContextMenu]);\r\n\r\n const parentDivStyle: React.CSSProperties = {\r\n height: \"100%\", width: \"100%\", position: \"relative\",\r\n };\r\n\r\n const viewportDivStyle: React.CSSProperties = {\r\n ...style,\r\n height: \"100%\", width: \"100%\",\r\n };\r\n\r\n return (\r\n <div style={parentDivStyle} data-item-id={controlId}\r\n >\r\n <>\r\n <div\r\n ref={viewportDiv}\r\n data-testid=\"viewport-component\"\r\n className={className}\r\n style={viewportDivStyle}\r\n onContextMenu={handleContextMenu}\r\n />\r\n {viewOverlay}\r\n </>\r\n </div>\r\n );\r\n}\r\n"]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { Matrix3d, Point3d, Vector3d } from "@itwin/core-geometry";
|
|
5
5
|
import { StandardViewId, Viewport } from "@itwin/core-frontend";
|
|
6
|
-
import { UiEvent } from "@itwin/
|
|
6
|
+
import { UiEvent } from "@itwin/appui-abstract";
|
|
7
7
|
import { Face } from "../navigationaids/Cube";
|
|
8
8
|
/** Arguments for [[DrawingViewportChangeEvent]]
|
|
9
9
|
* @public
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ViewportComponentEvents.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/viewport/ViewportComponentEvents.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAA0C,cAAc,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACxG,OAAO,EAAE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"ViewportComponentEvents.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/viewport/ViewportComponentEvents.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAA0C,cAAc,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACxG,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,8BAA8B;IAC7C,QAAQ,EAAE,QAAQ,CAAC;IACnB,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,qBAAa,0BAA2B,SAAQ,OAAO,CAAC,8BAA8B,CAAC;CAAI;AAE3F;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,SAAS,EAAE,QAAQ,CAAC;IACpB,IAAI,EAAE,IAAI,CAAC;IACX,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,OAAO,CAAC,2BAA2B,CAAC;CAAI;AAErF;;GAEG;AACH,MAAM,WAAW,+BAA+B;IAC9C,gBAAgB,EAAE,cAAc,CAAC;CAClC;AAED;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rF,uBAAuB,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,GAAE,OAAe,GAAG,IAAI;WAI7F,mBAAmB,CAAC,gBAAgB,EAAE,cAAc,GAAG,IAAI;WAI3D,aAAa,CAAC,QAAQ,EAAE,QAAQ,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI;CAa9E"}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { Matrix3d, Point3d, Vector3d } from "@itwin/core-geometry";
|
|
9
9
|
import { IModelApp } from "@itwin/core-frontend";
|
|
10
|
-
import { UiEvent } from "@itwin/
|
|
10
|
+
import { UiEvent } from "@itwin/appui-abstract";
|
|
11
11
|
import { Face } from "../navigationaids/Cube";
|
|
12
12
|
/** Drawing View Change event
|
|
13
13
|
* @public
|
|
@@ -73,6 +73,7 @@ export class ViewportComponentEvents {
|
|
|
73
73
|
static setViewMatrix(viewport, animationTime) {
|
|
74
74
|
// When handling onViewChanged, use setTimeout
|
|
75
75
|
setTimeout(() => {
|
|
76
|
+
// istanbul ignore next
|
|
76
77
|
if (viewport.view) {
|
|
77
78
|
this.origin.setFrom(viewport.view.getOrigin());
|
|
78
79
|
this.extents.setFrom(viewport.view.getExtents());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ViewportComponentEvents.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/viewport/ViewportComponentEvents.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,SAAS,EAAyD,MAAM,sBAAsB,CAAC;AACxG,OAAO,EAAE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"ViewportComponentEvents.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/viewport/ViewportComponentEvents.ts"],"names":[],"mappings":"AAAA;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AAU,EAAE,CAAC;AAChC,sCAAc,GAAG,QAAQ,CAAC,cAAc,EAAE,CAAC;AAC3C,oDAA4B,GAAG,IAAI,0BAA0B,EAAE,CAAC;AAChE,iDAAyB,GAAG,IAAI,uBAAuB,EAAE,CAAC;AAC1D,qDAA6B,GAAG,IAAI,2BAA2B,EAAE,CAAC;AAClE,iDAAyB,GAAG,IAAI,uBAAuB,EAAE,CAAC;AAC1D,uDAA+B,GAAG,IAAI,6BAA6B,EAAE,CAAC;AACtE,4CAAoB,GAAG,IAAI,kBAAkB,EAAE,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Viewport\r\n */\r\n\r\nimport { Matrix3d, Point3d, Vector3d } from \"@itwin/core-geometry\";\r\nimport { IModelApp, SelectedViewportChangedArgs, StandardViewId, Viewport } from \"@itwin/core-frontend\";\r\nimport { UiEvent } from \"@itwin/appui-abstract\";\r\nimport { Face } from \"../navigationaids/Cube\";\r\n\r\n/** Arguments for [[DrawingViewportChangeEvent]]\r\n * @public\r\n */\r\nexport interface DrawingViewportChangeEventArgs {\r\n rotation: Matrix3d;\r\n origin: Point3d;\r\n complete: boolean;\r\n}\r\n\r\n/** Drawing View Change event\r\n * @public\r\n */\r\nexport class DrawingViewportChangeEvent extends UiEvent<DrawingViewportChangeEventArgs> { }\r\n\r\n/** Arguments for [[CubeRotationChangeEvent]]\r\n * @public\r\n */\r\nexport interface CubeRotationChangeEventArgs {\r\n rotMatrix: Matrix3d;\r\n face: Face;\r\n complete?: boolean;\r\n}\r\n\r\n/** 3d Cube Rotation Change event\r\n * @public\r\n */\r\nexport class CubeRotationChangeEvent extends UiEvent<CubeRotationChangeEventArgs> { }\r\n\r\n/** Arguments for [[StandardRotationChangeEvent]]\r\n * @public\r\n */\r\nexport interface StandardRotationChangeEventArgs {\r\n standardRotation: StandardViewId;\r\n}\r\n\r\n/** Standard Rotation Change event\r\n * @public\r\n */\r\nexport class StandardRotationChangeEvent extends UiEvent<StandardRotationChangeEventArgs> { }\r\n\r\n/** Arguments for [[ViewRotationChangeEvent]]\r\n * @public\r\n */\r\nexport interface ViewRotationChangeEventArgs {\r\n viewport: Viewport;\r\n animationTime?: number;\r\n}\r\n\r\n/** View Rotation Change event\r\n * @public\r\n */\r\nexport class ViewRotationChangeEvent extends UiEvent<ViewRotationChangeEventArgs> { }\r\n\r\n/** Arguments for [[ViewClassFullNameChangedEvent]]\r\n * @public\r\n */\r\nexport interface ViewClassFullNameChangedEventArgs {\r\n viewport: Viewport;\r\n oldName: string;\r\n newName: string;\r\n}\r\n\r\n/** View Class Full Name Change event\r\n * @public\r\n */\r\nexport class ViewClassFullNameChangedEvent extends UiEvent<ViewClassFullNameChangedEventArgs> { }\r\n\r\n/** Arguments for [[ViewIdChangedEvent]]\r\n * @public\r\n */\r\nexport interface ViewIdChangedEventArgs {\r\n viewport: Viewport;\r\n oldId: string;\r\n newId: string;\r\n}\r\n\r\n/** View Id Change event\r\n * @public\r\n */\r\nexport class ViewIdChangedEvent extends UiEvent<ViewIdChangedEventArgs> { }\r\n\r\n/** Viewport Rotation events and methods\r\n * @public\r\n */\r\nexport class ViewportComponentEvents {\r\n private static _removeListener?: () => void;\r\n\r\n public static initialize() {\r\n if (undefined !== this._removeListener)\r\n return;\r\n\r\n this._removeListener = IModelApp.viewManager.onSelectedViewportChanged.addListener(ViewportComponentEvents.handleSelectedViewportChanged);\r\n }\r\n\r\n /** @internal - for unit testing */\r\n public static terminate() {\r\n if (this._removeListener) {\r\n this._removeListener();\r\n this._removeListener = undefined;\r\n }\r\n }\r\n\r\n public static face = Face.None;\r\n public static readonly origin = Point3d.createZero();\r\n public static readonly extents = Vector3d.createZero();\r\n public static readonly rotationMatrix = Matrix3d.createIdentity();\r\n public static readonly onDrawingViewportChangeEvent = new DrawingViewportChangeEvent();\r\n public static readonly onCubeRotationChangeEvent = new CubeRotationChangeEvent();\r\n public static readonly onStandardRotationChangeEvent = new StandardRotationChangeEvent();\r\n public static readonly onViewRotationChangeEvent = new ViewRotationChangeEvent();\r\n public static readonly onViewClassFullNameChangedEvent = new ViewClassFullNameChangedEvent();\r\n public static readonly onViewIdChangedEvent = new ViewIdChangedEvent();\r\n\r\n private static handleSelectedViewportChanged(args: SelectedViewportChangedArgs): void {\r\n if (args.current)\r\n ViewportComponentEvents.setViewMatrix(args.current);\r\n }\r\n\r\n public static setCubeMatrix(rotMatrix: Matrix3d, face = Face.None, complete: boolean = false): void {\r\n this.rotationMatrix.setFrom(rotMatrix);\r\n this.face = face;\r\n this.onCubeRotationChangeEvent.emit({ rotMatrix, complete, face });\r\n }\r\n\r\n public static setDrawingViewportState(origin: Point3d, rotation: Matrix3d, complete: boolean = false): void {\r\n this.onDrawingViewportChangeEvent.emit({ origin, rotation, complete });\r\n }\r\n\r\n public static setStandardRotation(standardRotation: StandardViewId): void {\r\n this.onStandardRotationChangeEvent.emit({ standardRotation });\r\n }\r\n\r\n public static setViewMatrix(viewport: Viewport, animationTime?: number): void {\r\n // When handling onViewChanged, use setTimeout\r\n setTimeout(() => {\r\n // istanbul ignore next\r\n if (viewport.view) {\r\n this.origin.setFrom(viewport.view.getOrigin());\r\n this.extents.setFrom(viewport.view.getExtents());\r\n }\r\n this.rotationMatrix.setFrom(viewport.rotation);\r\n\r\n this.onViewRotationChangeEvent.emit({ viewport, animationTime });\r\n });\r\n }\r\n}\r\n"]}
|
|
@@ -37,8 +37,10 @@
|
|
|
37
37
|
"rotateStyle": "Toggle background-rotate"
|
|
38
38
|
},
|
|
39
39
|
"color": {
|
|
40
|
+
"close": "Close",
|
|
40
41
|
"hue": "Hue",
|
|
41
42
|
"saturation": "Saturation",
|
|
43
|
+
"toggleColorPopup": "Toggle Color Picker Popup",
|
|
42
44
|
"transparency": "Transparency"
|
|
43
45
|
},
|
|
44
46
|
"QuantityInput": {
|
|
@@ -134,4 +136,4 @@
|
|
|
134
136
|
"setFormat": "Set Format"
|
|
135
137
|
}
|
|
136
138
|
}
|
|
137
|
-
}
|
|
139
|
+
}
|