@itwin/frontend-devtools 3.0.0-dev.72
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 +723 -0
- package/LICENSE.md +9 -0
- package/README.md +321 -0
- package/lib/ClipboardUtilities.d.ts +9 -0
- package/lib/ClipboardUtilities.d.ts.map +1 -0
- package/lib/ClipboardUtilities.js +27 -0
- package/lib/ClipboardUtilities.js.map +1 -0
- package/lib/FrontEndDevTools.d.ts +19 -0
- package/lib/FrontEndDevTools.d.ts.map +1 -0
- package/lib/FrontEndDevTools.js +203 -0
- package/lib/FrontEndDevTools.js.map +1 -0
- package/lib/effects/Convolution.d.ts +69 -0
- package/lib/effects/Convolution.d.ts.map +1 -0
- package/lib/effects/Convolution.js +166 -0
- package/lib/effects/Convolution.js.map +1 -0
- package/lib/effects/EffectTools.d.ts +34 -0
- package/lib/effects/EffectTools.d.ts.map +1 -0
- package/lib/effects/EffectTools.js +69 -0
- package/lib/effects/EffectTools.js.map +1 -0
- package/lib/effects/Explosion.d.ts +13 -0
- package/lib/effects/Explosion.d.ts.map +1 -0
- package/lib/effects/Explosion.js +168 -0
- package/lib/effects/Explosion.js.map +1 -0
- package/lib/effects/FlipImage.d.ts +31 -0
- package/lib/effects/FlipImage.d.ts.map +1 -0
- package/lib/effects/FlipImage.js +100 -0
- package/lib/effects/FlipImage.js.map +1 -0
- package/lib/effects/LensDistortion.d.ts +35 -0
- package/lib/effects/LensDistortion.d.ts.map +1 -0
- package/lib/effects/LensDistortion.js +110 -0
- package/lib/effects/LensDistortion.js.map +1 -0
- package/lib/effects/Random.d.ts +25 -0
- package/lib/effects/Random.d.ts.map +1 -0
- package/lib/effects/Random.js +50 -0
- package/lib/effects/Random.js.map +1 -0
- package/lib/effects/Saturation.d.ts +31 -0
- package/lib/effects/Saturation.d.ts.map +1 -0
- package/lib/effects/Saturation.js +86 -0
- package/lib/effects/Saturation.js.map +1 -0
- package/lib/effects/Snow.d.ts +77 -0
- package/lib/effects/Snow.d.ts.map +1 -0
- package/lib/effects/Snow.js +187 -0
- package/lib/effects/Snow.js.map +1 -0
- package/lib/effects/Vignette.d.ts +40 -0
- package/lib/effects/Vignette.d.ts.map +1 -0
- package/lib/effects/Vignette.js +109 -0
- package/lib/effects/Vignette.js.map +1 -0
- package/lib/frontend-devtools.d.ts +82 -0
- package/lib/frontend-devtools.d.ts.map +1 -0
- package/lib/frontend-devtools.js +98 -0
- package/lib/frontend-devtools.js.map +1 -0
- package/lib/public/locales/en/FrontendDevTools.json +449 -0
- package/lib/public/sprites/particle_explosion.png +0 -0
- package/lib/public/sprites/particle_flame.png +0 -0
- package/lib/public/sprites/particle_snow.png +0 -0
- package/lib/tools/AnimationIntervalTool.d.ts +16 -0
- package/lib/tools/AnimationIntervalTool.d.ts.map +1 -0
- package/lib/tools/AnimationIntervalTool.js +31 -0
- package/lib/tools/AnimationIntervalTool.js.map +1 -0
- package/lib/tools/ChangeUnitsTool.d.ts +16 -0
- package/lib/tools/ChangeUnitsTool.d.ts.map +1 -0
- package/lib/tools/ChangeUnitsTool.js +42 -0
- package/lib/tools/ChangeUnitsTool.js.map +1 -0
- package/lib/tools/ClipTools.d.ts +68 -0
- package/lib/tools/ClipTools.d.ts.map +1 -0
- package/lib/tools/ClipTools.js +162 -0
- package/lib/tools/ClipTools.js.map +1 -0
- package/lib/tools/DisplayStyleTools.d.ts +99 -0
- package/lib/tools/DisplayStyleTools.d.ts.map +1 -0
- package/lib/tools/DisplayStyleTools.js +242 -0
- package/lib/tools/DisplayStyleTools.js.map +1 -0
- package/lib/tools/EmphasizeElementsTool.d.ts +61 -0
- package/lib/tools/EmphasizeElementsTool.d.ts.map +1 -0
- package/lib/tools/EmphasizeElementsTool.js +155 -0
- package/lib/tools/EmphasizeElementsTool.js.map +1 -0
- package/lib/tools/FrustumDecoration.d.ts +58 -0
- package/lib/tools/FrustumDecoration.d.ts.map +1 -0
- package/lib/tools/FrustumDecoration.js +372 -0
- package/lib/tools/FrustumDecoration.js.map +1 -0
- package/lib/tools/InspectElementTool.d.ts +42 -0
- package/lib/tools/InspectElementTool.d.ts.map +1 -0
- package/lib/tools/InspectElementTool.js +185 -0
- package/lib/tools/InspectElementTool.js.map +1 -0
- package/lib/tools/MapLayerTool.d.ts +248 -0
- package/lib/tools/MapLayerTool.d.ts.map +1 -0
- package/lib/tools/MapLayerTool.js +462 -0
- package/lib/tools/MapLayerTool.js.map +1 -0
- package/lib/tools/MeasureTileLoadTime.d.ts +13 -0
- package/lib/tools/MeasureTileLoadTime.d.ts.map +1 -0
- package/lib/tools/MeasureTileLoadTime.js +61 -0
- package/lib/tools/MeasureTileLoadTime.js.map +1 -0
- package/lib/tools/ModelAppearanceTools.d.ts +87 -0
- package/lib/tools/ModelAppearanceTools.d.ts.map +1 -0
- package/lib/tools/ModelAppearanceTools.js +184 -0
- package/lib/tools/ModelAppearanceTools.js.map +1 -0
- package/lib/tools/PlanProjectionTools.d.ts +41 -0
- package/lib/tools/PlanProjectionTools.d.ts.map +1 -0
- package/lib/tools/PlanProjectionTools.js +150 -0
- package/lib/tools/PlanProjectionTools.js.map +1 -0
- package/lib/tools/PlanarMaskTools.d.ts +182 -0
- package/lib/tools/PlanarMaskTools.d.ts.map +1 -0
- package/lib/tools/PlanarMaskTools.js +366 -0
- package/lib/tools/PlanarMaskTools.js.map +1 -0
- package/lib/tools/ProjectExtents.d.ts +41 -0
- package/lib/tools/ProjectExtents.d.ts.map +1 -0
- package/lib/tools/ProjectExtents.js +108 -0
- package/lib/tools/ProjectExtents.js.map +1 -0
- package/lib/tools/RealityModelTools.d.ts +117 -0
- package/lib/tools/RealityModelTools.d.ts.map +1 -0
- package/lib/tools/RealityModelTools.js +269 -0
- package/lib/tools/RealityModelTools.js.map +1 -0
- package/lib/tools/RealityTransitionTool.d.ts +26 -0
- package/lib/tools/RealityTransitionTool.d.ts.map +1 -0
- package/lib/tools/RealityTransitionTool.js +110 -0
- package/lib/tools/RealityTransitionTool.js.map +1 -0
- package/lib/tools/RenderSystemTools.d.ts +46 -0
- package/lib/tools/RenderSystemTools.d.ts.map +1 -0
- package/lib/tools/RenderSystemTools.js +81 -0
- package/lib/tools/RenderSystemTools.js.map +1 -0
- package/lib/tools/RenderTargetTools.d.ts +101 -0
- package/lib/tools/RenderTargetTools.d.ts.map +1 -0
- package/lib/tools/RenderTargetTools.js +167 -0
- package/lib/tools/RenderTargetTools.js.map +1 -0
- package/lib/tools/ReportWebGLCompatibilityTool.d.ts +12 -0
- package/lib/tools/ReportWebGLCompatibilityTool.d.ts.map +1 -0
- package/lib/tools/ReportWebGLCompatibilityTool.js +31 -0
- package/lib/tools/ReportWebGLCompatibilityTool.js.map +1 -0
- package/lib/tools/SavedViews.d.ts +47 -0
- package/lib/tools/SavedViews.d.ts.map +1 -0
- package/lib/tools/SavedViews.js +137 -0
- package/lib/tools/SavedViews.js.map +1 -0
- package/lib/tools/SelectionTools.d.ts +17 -0
- package/lib/tools/SelectionTools.d.ts.map +1 -0
- package/lib/tools/SelectionTools.js +28 -0
- package/lib/tools/SelectionTools.js.map +1 -0
- package/lib/tools/SetGpuMemoryLimitTool.d.ts +16 -0
- package/lib/tools/SetGpuMemoryLimitTool.d.ts.map +1 -0
- package/lib/tools/SetGpuMemoryLimitTool.js +34 -0
- package/lib/tools/SetGpuMemoryLimitTool.js.map +1 -0
- package/lib/tools/SourceAspectIdTools.d.ts +41 -0
- package/lib/tools/SourceAspectIdTools.d.ts.map +1 -0
- package/lib/tools/SourceAspectIdTools.js +105 -0
- package/lib/tools/SourceAspectIdTools.js.map +1 -0
- package/lib/tools/TileRequestDecoration.d.ts +13 -0
- package/lib/tools/TileRequestDecoration.d.ts.map +1 -0
- package/lib/tools/TileRequestDecoration.js +84 -0
- package/lib/tools/TileRequestDecoration.js.map +1 -0
- package/lib/tools/TileTreeBoundsDecoration.d.ts +12 -0
- package/lib/tools/TileTreeBoundsDecoration.d.ts.map +1 -0
- package/lib/tools/TileTreeBoundsDecoration.js +75 -0
- package/lib/tools/TileTreeBoundsDecoration.js.map +1 -0
- package/lib/tools/ToolTipProvider.d.ts +16 -0
- package/lib/tools/ToolTipProvider.d.ts.map +1 -0
- package/lib/tools/ToolTipProvider.js +67 -0
- package/lib/tools/ToolTipProvider.js.map +1 -0
- package/lib/tools/ViewportTools.d.ts +194 -0
- package/lib/tools/ViewportTools.d.ts.map +1 -0
- package/lib/tools/ViewportTools.js +451 -0
- package/lib/tools/ViewportTools.js.map +1 -0
- package/lib/tools/parseArgs.d.ts +24 -0
- package/lib/tools/parseArgs.d.ts.map +1 -0
- package/lib/tools/parseArgs.js +52 -0
- package/lib/tools/parseArgs.js.map +1 -0
- package/lib/tools/parseBoolean.d.ts +9 -0
- package/lib/tools/parseBoolean.d.ts.map +1 -0
- package/lib/tools/parseBoolean.js +27 -0
- package/lib/tools/parseBoolean.js.map +1 -0
- package/lib/tools/parseToggle.d.ts +9 -0
- package/lib/tools/parseToggle.d.ts.map +1 -0
- package/lib/tools/parseToggle.js +26 -0
- package/lib/tools/parseToggle.js.map +1 -0
- package/lib/ui/Button.d.ts +30 -0
- package/lib/ui/Button.d.ts.map +1 -0
- package/lib/ui/Button.js +27 -0
- package/lib/ui/Button.js.map +1 -0
- package/lib/ui/CheckBox.d.ts +24 -0
- package/lib/ui/CheckBox.d.ts.map +1 -0
- package/lib/ui/CheckBox.js +28 -0
- package/lib/ui/CheckBox.js.map +1 -0
- package/lib/ui/ColorInput.d.ts +28 -0
- package/lib/ui/ColorInput.d.ts.map +1 -0
- package/lib/ui/ColorInput.js +54 -0
- package/lib/ui/ColorInput.js.map +1 -0
- package/lib/ui/ComboBox.d.ts +29 -0
- package/lib/ui/ComboBox.d.ts.map +1 -0
- package/lib/ui/ComboBox.js +43 -0
- package/lib/ui/ComboBox.js.map +1 -0
- package/lib/ui/DataList.d.ts +28 -0
- package/lib/ui/DataList.d.ts.map +1 -0
- package/lib/ui/DataList.js +40 -0
- package/lib/ui/DataList.js.map +1 -0
- package/lib/ui/NestedMenu.d.ts +20 -0
- package/lib/ui/NestedMenu.d.ts.map +1 -0
- package/lib/ui/NestedMenu.js +47 -0
- package/lib/ui/NestedMenu.js.map +1 -0
- package/lib/ui/NumericInput.d.ts +35 -0
- package/lib/ui/NumericInput.d.ts.map +1 -0
- package/lib/ui/NumericInput.js +60 -0
- package/lib/ui/NumericInput.js.map +1 -0
- package/lib/ui/RadioBox.d.ts +29 -0
- package/lib/ui/RadioBox.d.ts.map +1 -0
- package/lib/ui/RadioBox.js +77 -0
- package/lib/ui/RadioBox.js.map +1 -0
- package/lib/ui/Slider.d.ts +25 -0
- package/lib/ui/Slider.d.ts.map +1 -0
- package/lib/ui/Slider.js +33 -0
- package/lib/ui/Slider.js.map +1 -0
- package/lib/ui/TextBox.d.ts +33 -0
- package/lib/ui/TextBox.d.ts.map +1 -0
- package/lib/ui/TextBox.js +57 -0
- package/lib/ui/TextBox.js.map +1 -0
- package/lib/widgets/DiagnosticsPanel.d.ts +36 -0
- package/lib/widgets/DiagnosticsPanel.d.ts.map +1 -0
- package/lib/widgets/DiagnosticsPanel.js +76 -0
- package/lib/widgets/DiagnosticsPanel.js.map +1 -0
- package/lib/widgets/FpsTracker.d.ts +20 -0
- package/lib/widgets/FpsTracker.d.ts.map +1 -0
- package/lib/widgets/FpsTracker.js +57 -0
- package/lib/widgets/FpsTracker.js.map +1 -0
- package/lib/widgets/GpuProfiler.d.ts +17 -0
- package/lib/widgets/GpuProfiler.d.ts.map +1 -0
- package/lib/widgets/GpuProfiler.js +193 -0
- package/lib/widgets/GpuProfiler.js.map +1 -0
- package/lib/widgets/KeyinField.d.ts +62 -0
- package/lib/widgets/KeyinField.d.ts.map +1 -0
- package/lib/widgets/KeyinField.js +188 -0
- package/lib/widgets/KeyinField.js.map +1 -0
- package/lib/widgets/MemoryTracker.d.ts +28 -0
- package/lib/widgets/MemoryTracker.d.ts.map +1 -0
- package/lib/widgets/MemoryTracker.js +244 -0
- package/lib/widgets/MemoryTracker.js.map +1 -0
- package/lib/widgets/TileMemoryBreakdown.d.ts +31 -0
- package/lib/widgets/TileMemoryBreakdown.d.ts.map +1 -0
- package/lib/widgets/TileMemoryBreakdown.js +205 -0
- package/lib/widgets/TileMemoryBreakdown.js.map +1 -0
- package/lib/widgets/TileStatisticsTracker.d.ts +22 -0
- package/lib/widgets/TileStatisticsTracker.d.ts.map +1 -0
- package/lib/widgets/TileStatisticsTracker.js +143 -0
- package/lib/widgets/TileStatisticsTracker.js.map +1 -0
- package/lib/widgets/ToolSettingsTracker.d.ts +10 -0
- package/lib/widgets/ToolSettingsTracker.d.ts.map +1 -0
- package/lib/widgets/ToolSettingsTracker.js +182 -0
- package/lib/widgets/ToolSettingsTracker.js.map +1 -0
- package/package.json +59 -0
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
/** @packageDocumentation
|
|
7
|
+
* @module Tools
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.EmphasizeVisibleElementsTool = exports.ClearEmphasizedElementsTool = exports.ClearIsolatedElementsTool = exports.IsolateSelectedElementsTool = exports.EmphasizeSelectedElementsTool = exports.EmphasizeElementsTool = void 0;
|
|
11
|
+
const core_bentley_1 = require("@itwin/core-bentley");
|
|
12
|
+
const core_common_1 = require("@itwin/core-common");
|
|
13
|
+
const core_frontend_1 = require("@itwin/core-frontend");
|
|
14
|
+
const parseArgs_1 = require("./parseArgs");
|
|
15
|
+
/** Applies the `EmphasizeElements` API in some way to the selected Viewport.
|
|
16
|
+
* @beta
|
|
17
|
+
*/
|
|
18
|
+
class EmphasizeElementsTool extends core_frontend_1.Tool {
|
|
19
|
+
get _wantCreate() { return true; }
|
|
20
|
+
get _wantClear() { return false; }
|
|
21
|
+
async run(_args) {
|
|
22
|
+
const vp = core_frontend_1.IModelApp.viewManager.selectedView;
|
|
23
|
+
if (undefined === vp)
|
|
24
|
+
return true;
|
|
25
|
+
if (this._wantClear)
|
|
26
|
+
core_frontend_1.EmphasizeElements.clear(vp);
|
|
27
|
+
const emph = this._wantCreate ? core_frontend_1.EmphasizeElements.getOrCreate(vp) : core_frontend_1.EmphasizeElements.get(vp);
|
|
28
|
+
if (undefined !== emph)
|
|
29
|
+
this.execute(emph, vp);
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.EmphasizeElementsTool = EmphasizeElementsTool;
|
|
34
|
+
/** If any elements are selected, emphasize them all by overriding their color to be orange; and de-emphasize all other elements by drawing them transparent grey.
|
|
35
|
+
* @beta
|
|
36
|
+
*/
|
|
37
|
+
class EmphasizeSelectedElementsTool extends EmphasizeElementsTool {
|
|
38
|
+
constructor() {
|
|
39
|
+
super(...arguments);
|
|
40
|
+
this._type = 0 /* None */;
|
|
41
|
+
}
|
|
42
|
+
static get minArgs() { return 0; }
|
|
43
|
+
static get maxArgs() { return 1; }
|
|
44
|
+
execute(emph, vp) {
|
|
45
|
+
if (0 /* None */ === (this._type & 1 /* Color */) || emph.overrideSelectedElements(vp, core_common_1.ColorDef.white, undefined, true, false)) {
|
|
46
|
+
emph.wantEmphasis = 0 /* None */ !== (this._type & 2 /* Emphasis */);
|
|
47
|
+
if (emph.emphasizeSelectedElements(vp, undefined, true)) {
|
|
48
|
+
vp.isFadeOutActive = true;
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
// Empty selection set - clear any previous overrides.
|
|
53
|
+
core_frontend_1.EmphasizeElements.clear(vp);
|
|
54
|
+
emph.wantEmphasis = false;
|
|
55
|
+
vp.isFadeOutActive = false;
|
|
56
|
+
}
|
|
57
|
+
async parseAndRun(...args) {
|
|
58
|
+
if (1 === args.length) {
|
|
59
|
+
switch (args[0].toLowerCase()[0]) {
|
|
60
|
+
case "n":
|
|
61
|
+
break;
|
|
62
|
+
case "c":
|
|
63
|
+
this._type = 1 /* Color */;
|
|
64
|
+
break;
|
|
65
|
+
case "e":
|
|
66
|
+
this._type = 2 /* Emphasis */;
|
|
67
|
+
break;
|
|
68
|
+
case "b":
|
|
69
|
+
this._type = 3 /* Both */;
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return this.run(args);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.EmphasizeSelectedElementsTool = EmphasizeSelectedElementsTool;
|
|
77
|
+
EmphasizeSelectedElementsTool.toolId = "EmphasizeSelectedElements";
|
|
78
|
+
/** Isolate all selected elements so that *only* those elements will be drawn.
|
|
79
|
+
* @beta
|
|
80
|
+
*/
|
|
81
|
+
class IsolateSelectedElementsTool extends EmphasizeElementsTool {
|
|
82
|
+
execute(emph, vp) {
|
|
83
|
+
emph.isolateSelectedElements(vp, true, true);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
exports.IsolateSelectedElementsTool = IsolateSelectedElementsTool;
|
|
87
|
+
IsolateSelectedElementsTool.toolId = "IsolateSelectedElements";
|
|
88
|
+
/** Clear the set of isolated elements.
|
|
89
|
+
* @beta
|
|
90
|
+
*/
|
|
91
|
+
class ClearIsolatedElementsTool extends EmphasizeElementsTool {
|
|
92
|
+
get _wantCreate() { return false; }
|
|
93
|
+
execute(emph, vp) {
|
|
94
|
+
emph.clearIsolatedElements(vp);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
exports.ClearIsolatedElementsTool = ClearIsolatedElementsTool;
|
|
98
|
+
ClearIsolatedElementsTool.toolId = "ClearIsolatedElements";
|
|
99
|
+
/** Reset [EmphasizeElements]($frontend) for the active [Viewport]($frontend).
|
|
100
|
+
* @beta
|
|
101
|
+
*/
|
|
102
|
+
class ClearEmphasizedElementsTool extends EmphasizeElementsTool {
|
|
103
|
+
get _wantCreate() { return false; }
|
|
104
|
+
get _wantClear() { return true; }
|
|
105
|
+
execute(emph, vp) {
|
|
106
|
+
emph.clearEmphasizedElements(vp);
|
|
107
|
+
vp.isFadeOutActive = false;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
exports.ClearEmphasizedElementsTool = ClearEmphasizedElementsTool;
|
|
111
|
+
ClearEmphasizedElementsTool.toolId = "ClearEmphasizedElements";
|
|
112
|
+
/** Emphasize the set of elements currently visible in the view based on [Viewport.queryVisibleFeatures]($frontend).
|
|
113
|
+
* @beta
|
|
114
|
+
*/
|
|
115
|
+
class EmphasizeVisibleElementsTool extends EmphasizeElementsTool {
|
|
116
|
+
constructor() {
|
|
117
|
+
super(...arguments);
|
|
118
|
+
this._options = { source: "screen" };
|
|
119
|
+
}
|
|
120
|
+
static get minArgs() { return 1; }
|
|
121
|
+
static get maxArgs() { return 2; }
|
|
122
|
+
get _wantClear() { return true; }
|
|
123
|
+
async parseAndRun(...input) {
|
|
124
|
+
const args = (0, parseArgs_1.parseArgs)(input);
|
|
125
|
+
const includeNonLocatable = args.getBoolean("n");
|
|
126
|
+
let source;
|
|
127
|
+
switch (input[0].toLowerCase()) {
|
|
128
|
+
case "screen":
|
|
129
|
+
source = "screen";
|
|
130
|
+
break;
|
|
131
|
+
case "tiles":
|
|
132
|
+
source = "tiles";
|
|
133
|
+
break;
|
|
134
|
+
default:
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
this._options = { source, includeNonLocatable };
|
|
138
|
+
return this.run(input);
|
|
139
|
+
}
|
|
140
|
+
execute(emph, vp) {
|
|
141
|
+
const elementIds = new Set();
|
|
142
|
+
vp.queryVisibleFeatures(this._options, (features) => {
|
|
143
|
+
for (const feature of features) {
|
|
144
|
+
if (feature.iModel === vp.iModel && core_bentley_1.Id64.isValid(feature.elementId))
|
|
145
|
+
elementIds.add(feature.elementId);
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
emph.wantEmphasis = true;
|
|
149
|
+
if (emph.emphasizeElements(elementIds, vp))
|
|
150
|
+
vp.isFadeOutActive = true;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
exports.EmphasizeVisibleElementsTool = EmphasizeVisibleElementsTool;
|
|
154
|
+
EmphasizeVisibleElementsTool.toolId = "EmphasizeVisibleElements";
|
|
155
|
+
//# sourceMappingURL=EmphasizeElementsTool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EmphasizeElementsTool.js","sourceRoot":"","sources":["../../src/tools/EmphasizeElementsTool.ts"],"names":[],"mappings":"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","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 Tools\r\n */\r\n\r\nimport { Id64 } from \"@itwin/core-bentley\";\r\nimport { ColorDef } from \"@itwin/core-common\";\r\nimport { EmphasizeElements, IModelApp, QueryVisibleFeaturesOptions, ScreenViewport, Tool } from \"@itwin/core-frontend\";\r\nimport { parseArgs } from \"./parseArgs\";\r\n\r\n/** Applies the `EmphasizeElements` API in some way to the selected Viewport.\r\n * @beta\r\n */\r\nexport abstract class EmphasizeElementsTool extends Tool {\r\n protected get _wantCreate(): boolean { return true; }\r\n protected get _wantClear(): boolean { return false; }\r\n protected abstract execute(emph: EmphasizeElements, vp: ScreenViewport): void;\r\n\r\n public override async run(_args: any[]): Promise<boolean> {\r\n const vp = IModelApp.viewManager.selectedView;\r\n if (undefined === vp)\r\n return true;\r\n\r\n if (this._wantClear)\r\n EmphasizeElements.clear(vp);\r\n\r\n const emph = this._wantCreate ? EmphasizeElements.getOrCreate(vp) : EmphasizeElements.get(vp);\r\n if (undefined !== emph)\r\n this.execute(emph, vp);\r\n\r\n return true;\r\n }\r\n}\r\n\r\nconst enum OverrideType { // eslint-disable-line no-restricted-syntax\r\n None = 0,\r\n Color = 1 << 0,\r\n Emphasis = 1 << 1,\r\n Both = Color | Emphasis,\r\n}\r\n\r\n/** If any elements are selected, emphasize them all by overriding their color to be orange; and de-emphasize all other elements by drawing them transparent grey.\r\n * @beta\r\n */\r\nexport class EmphasizeSelectedElementsTool extends EmphasizeElementsTool {\r\n public static override toolId = \"EmphasizeSelectedElements\";\r\n public static override get minArgs() { return 0; }\r\n public static override get maxArgs() { return 1; }\r\n private _type = OverrideType.None;\r\n\r\n public execute(emph: EmphasizeElements, vp: ScreenViewport): void {\r\n if (OverrideType.None === (this._type & OverrideType.Color) || emph.overrideSelectedElements(vp, ColorDef.white, undefined, true, false)) {\r\n emph.wantEmphasis = OverrideType.None !== (this._type & OverrideType.Emphasis);\r\n if (emph.emphasizeSelectedElements(vp, undefined, true)) {\r\n vp.isFadeOutActive = true;\r\n return;\r\n }\r\n }\r\n\r\n // Empty selection set - clear any previous overrides.\r\n EmphasizeElements.clear(vp);\r\n emph.wantEmphasis = false;\r\n vp.isFadeOutActive = false;\r\n }\r\n\r\n public override async parseAndRun(...args: string[]): Promise<boolean> {\r\n if (1 === args.length) {\r\n switch (args[0].toLowerCase()[0]) {\r\n case \"n\":\r\n break;\r\n case \"c\":\r\n this._type = OverrideType.Color;\r\n break;\r\n case \"e\":\r\n this._type = OverrideType.Emphasis;\r\n break;\r\n case \"b\":\r\n this._type = OverrideType.Both;\r\n break;\r\n }\r\n }\r\n\r\n return this.run(args);\r\n }\r\n}\r\n\r\n/** Isolate all selected elements so that *only* those elements will be drawn.\r\n * @beta\r\n */\r\nexport class IsolateSelectedElementsTool extends EmphasizeElementsTool {\r\n public static override toolId = \"IsolateSelectedElements\";\r\n public execute(emph: EmphasizeElements, vp: ScreenViewport): void {\r\n emph.isolateSelectedElements(vp, true, true);\r\n }\r\n}\r\n\r\n/** Clear the set of isolated elements.\r\n * @beta\r\n */\r\nexport class ClearIsolatedElementsTool extends EmphasizeElementsTool {\r\n public static override toolId = \"ClearIsolatedElements\";\r\n protected override get _wantCreate() { return false; }\r\n public execute(emph: EmphasizeElements, vp: ScreenViewport): void {\r\n emph.clearIsolatedElements(vp);\r\n }\r\n}\r\n\r\n/** Reset [EmphasizeElements]($frontend) for the active [Viewport]($frontend).\r\n * @beta\r\n */\r\nexport class ClearEmphasizedElementsTool extends EmphasizeElementsTool {\r\n public static override toolId = \"ClearEmphasizedElements\";\r\n protected override get _wantCreate() { return false; }\r\n protected override get _wantClear() { return true; }\r\n\r\n public execute(emph: EmphasizeElements, vp: ScreenViewport): void {\r\n emph.clearEmphasizedElements(vp);\r\n vp.isFadeOutActive = false;\r\n }\r\n}\r\n\r\n/** Emphasize the set of elements currently visible in the view based on [Viewport.queryVisibleFeatures]($frontend).\r\n * @beta\r\n */\r\nexport class EmphasizeVisibleElementsTool extends EmphasizeElementsTool {\r\n public static override toolId = \"EmphasizeVisibleElements\";\r\n public static override get minArgs() { return 1; }\r\n public static override get maxArgs() { return 2; }\r\n private _options: QueryVisibleFeaturesOptions = { source: \"screen\" };\r\n protected override get _wantClear() { return true; }\r\n\r\n public override async parseAndRun(...input: string[]): Promise<boolean> {\r\n const args = parseArgs(input);\r\n const includeNonLocatable = args.getBoolean(\"n\");\r\n let source: \"screen\" | \"tiles\";\r\n switch (input[0].toLowerCase()) {\r\n case \"screen\":\r\n source = \"screen\";\r\n break;\r\n case \"tiles\":\r\n source = \"tiles\";\r\n break;\r\n default:\r\n return false;\r\n }\r\n\r\n this._options = { source, includeNonLocatable };\r\n return this.run(input);\r\n }\r\n\r\n public execute(emph: EmphasizeElements, vp: ScreenViewport): void {\r\n const elementIds = new Set<string>();\r\n vp.queryVisibleFeatures(this._options, (features) => {\r\n for (const feature of features) {\r\n if (feature.iModel === vp.iModel && Id64.isValid(feature.elementId))\r\n elementIds.add(feature.elementId);\r\n }\r\n });\r\n\r\n emph.wantEmphasis = true;\r\n if (emph.emphasizeElements(elementIds, vp))\r\n vp.isFadeOutActive = true;\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { DecorateContext, Decorator, Tool, Viewport } from "@itwin/core-frontend";
|
|
2
|
+
interface FrustumDecorationOptions {
|
|
3
|
+
showPreloadFrustum?: boolean;
|
|
4
|
+
showBackgroundIntersections?: boolean;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Decorates the viewport with a graphical depiction of a Frustum.
|
|
8
|
+
* This is obviously only useful when drawn inside a viewport using a *different* Frustum.
|
|
9
|
+
* Options for doing so include:
|
|
10
|
+
* - Having more than one viewport, and drawing the frustum of one viewport inside the other viewports; and
|
|
11
|
+
* - Allowing the user to take a snapshot of the current frustum, then navigate the view to inspect it within the same viewport.
|
|
12
|
+
* @beta
|
|
13
|
+
*/
|
|
14
|
+
export declare class FrustumDecorator implements Decorator {
|
|
15
|
+
private readonly _decoration?;
|
|
16
|
+
private constructor();
|
|
17
|
+
/** This will allow the render system to cache and reuse the decorations created by this decorator's decorate() method. */
|
|
18
|
+
readonly useCachedDecorations = true;
|
|
19
|
+
decorate(context: DecorateContext): void;
|
|
20
|
+
private static _instance?;
|
|
21
|
+
/** Add the decoration to the specified viewport. */
|
|
22
|
+
static enable(vp: Viewport, options?: FrustumDecorationOptions): void;
|
|
23
|
+
/** Remove the decoration from the specified viewport. */
|
|
24
|
+
static disable(): void;
|
|
25
|
+
static get isEnabled(): boolean;
|
|
26
|
+
}
|
|
27
|
+
/** Enable ("ON"), disable ("OFF"), or toggle ("TOGGLE" or omitted) the [[FrustumDecorator]].
|
|
28
|
+
* @beta
|
|
29
|
+
*/
|
|
30
|
+
export declare class ToggleFrustumSnapshotTool extends Tool {
|
|
31
|
+
static toolId: string;
|
|
32
|
+
static get minArgs(): number;
|
|
33
|
+
static get maxArgs(): number;
|
|
34
|
+
run(enable?: boolean, showPreloadFrustum?: boolean, showBackgroundIntersections?: boolean): Promise<boolean>;
|
|
35
|
+
parseAndRun(...args: string[]): Promise<boolean>;
|
|
36
|
+
}
|
|
37
|
+
/** Enable ("ON"), disable ("OFF"), or toggle ("TOGGLE" or omitted) the selected view frustum decoration.
|
|
38
|
+
* @beta
|
|
39
|
+
*/
|
|
40
|
+
export declare class ToggleSelectedViewFrustumTool extends Tool {
|
|
41
|
+
static toolId: string;
|
|
42
|
+
static get minArgs(): number;
|
|
43
|
+
static get maxArgs(): number;
|
|
44
|
+
run(enable?: boolean): Promise<boolean>;
|
|
45
|
+
parseAndRun(...args: string[]): Promise<boolean>;
|
|
46
|
+
}
|
|
47
|
+
/** Toggle visualization of the selected viewport's shadow frustum in all other viewports.
|
|
48
|
+
* @beta
|
|
49
|
+
*/
|
|
50
|
+
export declare class ToggleShadowFrustumTool extends Tool {
|
|
51
|
+
static toolId: string;
|
|
52
|
+
static get minArgs(): number;
|
|
53
|
+
static get maxArgs(): number;
|
|
54
|
+
run(enable?: boolean): Promise<boolean>;
|
|
55
|
+
parseAndRun(...args: string[]): Promise<boolean>;
|
|
56
|
+
}
|
|
57
|
+
export {};
|
|
58
|
+
//# sourceMappingURL=FrustumDecoration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FrustumDecoration.d.ts","sourceRoot":"","sources":["../../src/tools/FrustumDecoration.ts"],"names":[],"mappings":"AAWA,OAAO,EACQ,eAAe,EAAE,SAAS,EAA0C,IAAI,EAAE,QAAQ,EAChG,MAAM,sBAAsB,CAAC;AAG9B,UAAU,wBAAwB;IAChC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,2BAA2B,CAAC,EAAE,OAAO,CAAC;CACvC;AAwID;;;;;;;GAOG;AACH,qBAAa,gBAAiB,YAAW,SAAS;IAChD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAoB;IAEjD,OAAO;IAIP,0HAA0H;IAC1H,SAAgB,oBAAoB,QAAQ;IAErC,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI;IAK/C,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAmB;IAE5C,oDAAoD;WACtC,MAAM,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,wBAAwB,GAAG,IAAI;IAM5E,yDAAyD;WAC3C,OAAO,IAAI,IAAI;IAQ7B,WAAkB,SAAS,YAAuD;CACnF;AAED;;GAEG;AACH,qBAAa,yBAA0B,SAAQ,IAAI;IACjD,OAAuB,MAAM,SAA2B;IACxD,WAA2B,OAAO,WAAgB;IAClD,WAA2B,OAAO,WAAgB;IAE5B,GAAG,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,kBAAkB,CAAC,EAAE,OAAO,EAAE,2BAA2B,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAoB5G,WAAW,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;CAgBvE;AA0FD;;GAEG;AACH,qBAAa,6BAA8B,SAAQ,IAAI;IACrD,OAAuB,MAAM,SAA+B;IAC5D,WAA2B,OAAO,WAAgB;IAClD,WAA2B,OAAO,WAAgB;IAE5B,GAAG,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAgBvC,WAAW,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;CAOvE;AAoED;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,IAAI;IAC/C,OAAuB,MAAM,SAAyB;IACtD,WAA2B,OAAO,WAAgB;IAClD,WAA2B,OAAO,WAAgB;IAE5B,GAAG,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAQvC,WAAW,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;CAOvE"}
|
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.ToggleShadowFrustumTool = exports.ToggleSelectedViewFrustumTool = exports.ToggleFrustumSnapshotTool = exports.FrustumDecorator = void 0;
|
|
8
|
+
/** @packageDocumentation
|
|
9
|
+
* @module Tools
|
|
10
|
+
*/
|
|
11
|
+
const core_geometry_1 = require("@itwin/core-geometry");
|
|
12
|
+
const core_common_1 = require("@itwin/core-common");
|
|
13
|
+
const core_frontend_1 = require("@itwin/core-frontend");
|
|
14
|
+
const parseToggle_1 = require("./parseToggle");
|
|
15
|
+
/**
|
|
16
|
+
* Decorates the viewport with a graphical depiction of a Frustum.
|
|
17
|
+
* This is obviously only useful when drawn inside a viewport using a *different* Frustum.
|
|
18
|
+
* Options for doing so include:
|
|
19
|
+
* - Having more than one viewport, and drawing the frustum of one viewport inside the other viewports; and
|
|
20
|
+
* - Allowing the user to take a snapshot of the current frustum, then navigate the view to inspect it within the same viewport.
|
|
21
|
+
*/
|
|
22
|
+
class FrustumDecoration {
|
|
23
|
+
constructor(vp, view, _options) {
|
|
24
|
+
this._options = _options;
|
|
25
|
+
this._worldFrustum = vp.getFrustum(core_frontend_1.CoordSystem.World, false);
|
|
26
|
+
this._adjustedWorldFrustum = vp.getFrustum(core_frontend_1.CoordSystem.World, true);
|
|
27
|
+
this._preloadFrustum = vp.viewingSpace.getPreloadFrustum();
|
|
28
|
+
this._npcFrustum = vp.getFrustum(core_frontend_1.CoordSystem.Npc, true);
|
|
29
|
+
this._worldToNpcMap = vp.viewingSpace.worldToNpcMap.clone();
|
|
30
|
+
this._eyePoint = view.camera.getEyePoint().clone();
|
|
31
|
+
this._focalPlane = vp.worldToNpc(view.getTargetPoint()).z;
|
|
32
|
+
this._isCameraOn = vp.isCameraOn;
|
|
33
|
+
}
|
|
34
|
+
static create(vp, options) {
|
|
35
|
+
const view = vp.view.isSpatialView() ? vp.view : undefined;
|
|
36
|
+
return undefined !== view ? new FrustumDecoration(vp, view, options) : undefined;
|
|
37
|
+
}
|
|
38
|
+
decorate(context) {
|
|
39
|
+
const builder = context.createGraphicBuilder(core_frontend_1.GraphicType.WorldDecoration);
|
|
40
|
+
if (this._isCameraOn)
|
|
41
|
+
FrustumDecoration.drawEyePositionAndFocalPlane(builder, this._npcFrustum, this._worldToNpcMap, this._eyePoint, this._focalPlane, context.viewport);
|
|
42
|
+
FrustumDecoration.drawFrustumBox(builder, this._worldFrustum, false, context.viewport); // show original frustum...
|
|
43
|
+
FrustumDecoration.drawFrustumBox(builder, this._adjustedWorldFrustum, true, context.viewport); // show adjusted frustum...
|
|
44
|
+
const options = this._options;
|
|
45
|
+
if (options !== undefined) {
|
|
46
|
+
if (options.showPreloadFrustum)
|
|
47
|
+
FrustumDecoration.drawPreloadFrustum(builder, this._preloadFrustum);
|
|
48
|
+
if (options === null || options === void 0 ? void 0 : options.showBackgroundIntersections) {
|
|
49
|
+
const backgroundMapGeometry = context.viewport.view.displayStyle.getBackgroundMapGeometry();
|
|
50
|
+
if (backgroundMapGeometry)
|
|
51
|
+
backgroundMapGeometry.addFrustumDecorations(builder, this._adjustedWorldFrustum);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
context.addDecorationFromBuilder(builder);
|
|
55
|
+
}
|
|
56
|
+
static drawPreloadFrustum(builder, frustum) {
|
|
57
|
+
const preloadColor = core_common_1.ColorDef.create(core_common_1.ColorByName.coral);
|
|
58
|
+
builder.setSymbology(preloadColor, preloadColor, 1, 2);
|
|
59
|
+
builder.addFrustum(frustum);
|
|
60
|
+
}
|
|
61
|
+
static drawFrustumBox(builder, frustum, adjustedBox, vp) {
|
|
62
|
+
const backPts = this.getPlanePts(frustum.points, false); // back plane
|
|
63
|
+
const frontPts = this.getPlanePts(frustum.points, true); // front plane
|
|
64
|
+
const bgColor = vp.view.backgroundColor;
|
|
65
|
+
const backAndBottomColor = core_common_1.ColorDef.red.adjustedForContrast(bgColor);
|
|
66
|
+
const frontAndTopLeftColor = core_common_1.ColorDef.blue.adjustedForContrast(bgColor);
|
|
67
|
+
const frontAndTopRightColor = core_common_1.ColorDef.green.adjustedForContrast(bgColor);
|
|
68
|
+
const edgeWeight = adjustedBox ? 2 : 1;
|
|
69
|
+
const edgeStyle = adjustedBox ? core_common_1.LinePixels.Solid : core_common_1.LinePixels.Code2;
|
|
70
|
+
// Back plane
|
|
71
|
+
builder.setSymbology(backAndBottomColor, core_common_1.ColorDef.black, edgeWeight, edgeStyle);
|
|
72
|
+
builder.addLineString(backPts);
|
|
73
|
+
// Front plane
|
|
74
|
+
builder.setSymbology(frontAndTopLeftColor, core_common_1.ColorDef.black, edgeWeight, edgeStyle);
|
|
75
|
+
builder.addLineString(frontPts);
|
|
76
|
+
// Bottom edge
|
|
77
|
+
builder.setSymbology(backAndBottomColor, core_common_1.ColorDef.black, edgeWeight, edgeStyle);
|
|
78
|
+
builder.addLineString(this.getEdgePts(backPts, frontPts, 0));
|
|
79
|
+
builder.addLineString(this.getEdgePts(backPts, frontPts, 1));
|
|
80
|
+
// Top edge
|
|
81
|
+
builder.setSymbology(frontAndTopRightColor, core_common_1.ColorDef.black, edgeWeight, edgeStyle);
|
|
82
|
+
builder.addLineString(this.getEdgePts(backPts, frontPts, 2));
|
|
83
|
+
builder.setSymbology(frontAndTopLeftColor, core_common_1.ColorDef.black, edgeWeight, edgeStyle);
|
|
84
|
+
builder.addLineString(this.getEdgePts(backPts, frontPts, 3));
|
|
85
|
+
}
|
|
86
|
+
static getEdgePts(startPts, endPts, index) {
|
|
87
|
+
return [
|
|
88
|
+
startPts[index],
|
|
89
|
+
endPts[index],
|
|
90
|
+
];
|
|
91
|
+
}
|
|
92
|
+
static getPlanePts(frustPts, front) {
|
|
93
|
+
const baseIndex = front ? core_common_1.Npc._001 : core_common_1.Npc._000;
|
|
94
|
+
const planePts = [
|
|
95
|
+
frustPts[baseIndex + core_common_1.Npc._000],
|
|
96
|
+
frustPts[baseIndex + core_common_1.Npc._100],
|
|
97
|
+
frustPts[baseIndex + core_common_1.Npc._110],
|
|
98
|
+
frustPts[baseIndex + core_common_1.Npc._010],
|
|
99
|
+
];
|
|
100
|
+
planePts.push(planePts[0]);
|
|
101
|
+
return planePts;
|
|
102
|
+
}
|
|
103
|
+
static drawEyePositionAndFocalPlane(builder, npcFrustum, worldToNpcMap, eyePoint, focusPlaneNpc, vp) {
|
|
104
|
+
// Eye position...
|
|
105
|
+
const contrastColor = vp.getContrastToBackgroundColor();
|
|
106
|
+
builder.setSymbology(contrastColor, core_common_1.ColorDef.black, 8);
|
|
107
|
+
builder.addPointString([eyePoint]);
|
|
108
|
+
// Focal plane...
|
|
109
|
+
const focalPtsNpc = FrustumDecoration.getPlanePts(npcFrustum.points, false);
|
|
110
|
+
const focalPtsWorld = [];
|
|
111
|
+
for (const npcPt of focalPtsNpc)
|
|
112
|
+
focalPtsWorld.push(core_geometry_1.Point3d.create(npcPt.x, npcPt.y, focusPlaneNpc));
|
|
113
|
+
worldToNpcMap.transform1.multiplyPoint3dArrayQuietNormalize(focalPtsWorld);
|
|
114
|
+
const bgColor = vp.view.backgroundColor;
|
|
115
|
+
const focalPlaneColor = core_common_1.ColorDef.green.adjustedForContrast(bgColor);
|
|
116
|
+
const focalTransColor = focalPlaneColor.withTransparency(100);
|
|
117
|
+
builder.setSymbology(focalPlaneColor, focalTransColor, 2);
|
|
118
|
+
builder.addLineString(focalPtsWorld);
|
|
119
|
+
builder.addShape(focalPtsWorld);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Decorates the viewport with a graphical depiction of a Frustum.
|
|
124
|
+
* This is obviously only useful when drawn inside a viewport using a *different* Frustum.
|
|
125
|
+
* Options for doing so include:
|
|
126
|
+
* - Having more than one viewport, and drawing the frustum of one viewport inside the other viewports; and
|
|
127
|
+
* - Allowing the user to take a snapshot of the current frustum, then navigate the view to inspect it within the same viewport.
|
|
128
|
+
* @beta
|
|
129
|
+
*/
|
|
130
|
+
class FrustumDecorator {
|
|
131
|
+
constructor(vp, options) {
|
|
132
|
+
/** This will allow the render system to cache and reuse the decorations created by this decorator's decorate() method. */
|
|
133
|
+
this.useCachedDecorations = true;
|
|
134
|
+
this._decoration = FrustumDecoration.create(vp, options);
|
|
135
|
+
}
|
|
136
|
+
decorate(context) {
|
|
137
|
+
if (undefined !== this._decoration)
|
|
138
|
+
this._decoration.decorate(context);
|
|
139
|
+
}
|
|
140
|
+
/** Add the decoration to the specified viewport. */
|
|
141
|
+
static enable(vp, options) {
|
|
142
|
+
FrustumDecorator.disable();
|
|
143
|
+
FrustumDecorator._instance = new FrustumDecorator(vp, options);
|
|
144
|
+
core_frontend_1.IModelApp.viewManager.addDecorator(FrustumDecorator._instance);
|
|
145
|
+
}
|
|
146
|
+
/** Remove the decoration from the specified viewport. */
|
|
147
|
+
static disable() {
|
|
148
|
+
const instance = FrustumDecorator._instance;
|
|
149
|
+
if (undefined !== instance) {
|
|
150
|
+
core_frontend_1.IModelApp.viewManager.dropDecorator(instance);
|
|
151
|
+
FrustumDecorator._instance = undefined;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
static get isEnabled() { return undefined !== FrustumDecorator._instance; }
|
|
155
|
+
}
|
|
156
|
+
exports.FrustumDecorator = FrustumDecorator;
|
|
157
|
+
/** Enable ("ON"), disable ("OFF"), or toggle ("TOGGLE" or omitted) the [[FrustumDecorator]].
|
|
158
|
+
* @beta
|
|
159
|
+
*/
|
|
160
|
+
class ToggleFrustumSnapshotTool extends core_frontend_1.Tool {
|
|
161
|
+
static get minArgs() { return 0; }
|
|
162
|
+
static get maxArgs() { return 2; }
|
|
163
|
+
async run(enable, showPreloadFrustum, showBackgroundIntersections) {
|
|
164
|
+
const vp = core_frontend_1.IModelApp.viewManager.selectedView;
|
|
165
|
+
if (undefined === vp)
|
|
166
|
+
return true;
|
|
167
|
+
if (undefined === enable)
|
|
168
|
+
enable = !FrustumDecorator.isEnabled;
|
|
169
|
+
if (enable !== FrustumDecorator.isEnabled) {
|
|
170
|
+
if (enable) {
|
|
171
|
+
FrustumDecorator.enable(vp, { showPreloadFrustum, showBackgroundIntersections });
|
|
172
|
+
vp.onChangeView.addOnce(() => FrustumDecorator.disable());
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
FrustumDecorator.disable();
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return true;
|
|
179
|
+
}
|
|
180
|
+
async parseAndRun(...args) {
|
|
181
|
+
let showPreload, showBackgroundIntersections, enable;
|
|
182
|
+
for (const arg of args) {
|
|
183
|
+
if (arg === "preload")
|
|
184
|
+
showPreload = true;
|
|
185
|
+
else if (arg === "background")
|
|
186
|
+
showBackgroundIntersections = true;
|
|
187
|
+
else
|
|
188
|
+
enable = (0, parseToggle_1.parseToggle)(arg);
|
|
189
|
+
}
|
|
190
|
+
if (typeof enable !== "string")
|
|
191
|
+
await this.run(enable, showPreload, showBackgroundIntersections);
|
|
192
|
+
return true;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
exports.ToggleFrustumSnapshotTool = ToggleFrustumSnapshotTool;
|
|
196
|
+
ToggleFrustumSnapshotTool.toolId = "ToggleFrustumSnapshot";
|
|
197
|
+
/**
|
|
198
|
+
* Decorates the viewport with a graphical depiction of a Frustum from the currently selected viewport.
|
|
199
|
+
* Only useful when more than one spatial viewport is open.
|
|
200
|
+
*/
|
|
201
|
+
class SelectedViewFrustumDecoration {
|
|
202
|
+
constructor(vp, _options) {
|
|
203
|
+
this._options = _options;
|
|
204
|
+
/** This will allow the render system to cache and reuse the decorations created by this decorator's decorate() method. */
|
|
205
|
+
this.useCachedDecorations = true;
|
|
206
|
+
this._targetVp = vp;
|
|
207
|
+
this._removeDecorationListener = core_frontend_1.IModelApp.viewManager.addDecorator(this);
|
|
208
|
+
this._removeViewChangedListener = vp.onViewChanged.addListener(this.onViewChanged, this); // eslint-disable-line @typescript-eslint/unbound-method
|
|
209
|
+
core_frontend_1.IModelApp.viewManager.invalidateCachedDecorationsAllViews(this);
|
|
210
|
+
}
|
|
211
|
+
stop() {
|
|
212
|
+
if (this._removeDecorationListener) {
|
|
213
|
+
this._removeDecorationListener();
|
|
214
|
+
this._removeDecorationListener = undefined;
|
|
215
|
+
}
|
|
216
|
+
if (this._removeViewChangedListener) {
|
|
217
|
+
this._removeViewChangedListener();
|
|
218
|
+
this._removeViewChangedListener = undefined;
|
|
219
|
+
}
|
|
220
|
+
core_frontend_1.IModelApp.viewManager.invalidateCachedDecorationsAllViews(this);
|
|
221
|
+
}
|
|
222
|
+
onViewChanged(targetVp) {
|
|
223
|
+
if (targetVp !== this._targetVp)
|
|
224
|
+
return;
|
|
225
|
+
const decorator = SelectedViewFrustumDecoration._decorator;
|
|
226
|
+
if (undefined !== decorator) {
|
|
227
|
+
for (const vp of core_frontend_1.IModelApp.viewManager) {
|
|
228
|
+
if (vp !== this._targetVp)
|
|
229
|
+
vp.invalidateCachedDecorations(decorator);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
decorate(context) {
|
|
234
|
+
const vp = context.viewport;
|
|
235
|
+
if (!this._targetVp.view.isSpatialView() || vp === this._targetVp || !vp.view.isSpatialView())
|
|
236
|
+
return;
|
|
237
|
+
const builder = context.createGraphicBuilder(core_frontend_1.GraphicType.WorldDecoration);
|
|
238
|
+
if (this._targetVp.isCameraOn) {
|
|
239
|
+
const npcFrustum = this._targetVp.getFrustum(core_frontend_1.CoordSystem.Npc, true);
|
|
240
|
+
const focalPlane = this._targetVp.worldToNpc(this._targetVp.view.getTargetPoint()).z;
|
|
241
|
+
FrustumDecoration.drawEyePositionAndFocalPlane(builder, npcFrustum, this._targetVp.viewingSpace.worldToNpcMap, this._targetVp.view.camera.getEyePoint(), focalPlane, context.viewport);
|
|
242
|
+
}
|
|
243
|
+
const worldFrustum = this._targetVp.getFrustum(core_frontend_1.CoordSystem.World, false);
|
|
244
|
+
const adjustedWorldFrustum = this._targetVp.getFrustum(core_frontend_1.CoordSystem.World, true);
|
|
245
|
+
FrustumDecoration.drawFrustumBox(builder, worldFrustum, false, context.viewport); // show original frustum...
|
|
246
|
+
FrustumDecoration.drawFrustumBox(builder, adjustedWorldFrustum, true, context.viewport); // show adjusted frustum...
|
|
247
|
+
if (this._options && this._options.showPreloadFrustum)
|
|
248
|
+
FrustumDecoration.drawPreloadFrustum(builder, context.viewport.viewingSpace.getPreloadFrustum());
|
|
249
|
+
context.addDecorationFromBuilder(builder);
|
|
250
|
+
}
|
|
251
|
+
// Returns true if decoration becomes enabled.
|
|
252
|
+
static toggle(vp, enabled) {
|
|
253
|
+
if (undefined !== enabled) {
|
|
254
|
+
const alreadyEnabled = undefined !== SelectedViewFrustumDecoration._decorator;
|
|
255
|
+
if (enabled === alreadyEnabled)
|
|
256
|
+
return alreadyEnabled;
|
|
257
|
+
}
|
|
258
|
+
if (undefined === SelectedViewFrustumDecoration._decorator) {
|
|
259
|
+
SelectedViewFrustumDecoration._decorator = new SelectedViewFrustumDecoration(vp);
|
|
260
|
+
return true;
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
SelectedViewFrustumDecoration._decorator.stop();
|
|
264
|
+
SelectedViewFrustumDecoration._decorator = undefined;
|
|
265
|
+
return false;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
/** Enable ("ON"), disable ("OFF"), or toggle ("TOGGLE" or omitted) the selected view frustum decoration.
|
|
270
|
+
* @beta
|
|
271
|
+
*/
|
|
272
|
+
class ToggleSelectedViewFrustumTool extends core_frontend_1.Tool {
|
|
273
|
+
static get minArgs() { return 0; }
|
|
274
|
+
static get maxArgs() { return 1; }
|
|
275
|
+
async run(enable) {
|
|
276
|
+
const vp = core_frontend_1.IModelApp.viewManager.selectedView;
|
|
277
|
+
if (undefined === vp || !vp.view.isSpatialView())
|
|
278
|
+
return false;
|
|
279
|
+
if (SelectedViewFrustumDecoration.toggle(vp, enable)) {
|
|
280
|
+
const remove = vp.onChangeView.addListener((_vp, prev) => {
|
|
281
|
+
if (!prev.hasSameCoordinates(vp.view)) {
|
|
282
|
+
SelectedViewFrustumDecoration.toggle(vp, false);
|
|
283
|
+
remove();
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
return true;
|
|
288
|
+
}
|
|
289
|
+
async parseAndRun(...args) {
|
|
290
|
+
const enable = (0, parseToggle_1.parseToggle)(args[0]);
|
|
291
|
+
if (typeof enable !== "string")
|
|
292
|
+
await this.run(enable);
|
|
293
|
+
return true;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
exports.ToggleSelectedViewFrustumTool = ToggleSelectedViewFrustumTool;
|
|
297
|
+
ToggleSelectedViewFrustumTool.toolId = "ToggleSelectedViewFrustum";
|
|
298
|
+
class ShadowFrustumDecoration {
|
|
299
|
+
constructor(vp) {
|
|
300
|
+
/** This will allow the render system to cache and reuse the decorations created by this decorator's decorate() method. */
|
|
301
|
+
this.useCachedDecorations = true;
|
|
302
|
+
this._targetVp = vp;
|
|
303
|
+
const removeDecorator = core_frontend_1.IModelApp.viewManager.addDecorator(this);
|
|
304
|
+
const removeOnRender = vp.onRender.addListener((_) => this.onRender());
|
|
305
|
+
this._cleanup = () => { removeDecorator(); removeOnRender(); };
|
|
306
|
+
core_frontend_1.IModelApp.viewManager.invalidateCachedDecorationsAllViews(this);
|
|
307
|
+
}
|
|
308
|
+
stop() {
|
|
309
|
+
if (undefined !== this._cleanup) {
|
|
310
|
+
this._cleanup();
|
|
311
|
+
this._cleanup = undefined;
|
|
312
|
+
}
|
|
313
|
+
core_frontend_1.IModelApp.viewManager.invalidateCachedDecorationsAllViews(this);
|
|
314
|
+
}
|
|
315
|
+
onRender() {
|
|
316
|
+
const decorator = ShadowFrustumDecoration._instance;
|
|
317
|
+
if (undefined !== decorator) {
|
|
318
|
+
for (const vp of core_frontend_1.IModelApp.viewManager) {
|
|
319
|
+
if (vp !== this._targetVp)
|
|
320
|
+
vp.invalidateCachedDecorations(decorator);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
decorate(context) {
|
|
325
|
+
const frustum = this._targetVp.target.debugControl.shadowFrustum;
|
|
326
|
+
if (undefined === frustum)
|
|
327
|
+
return;
|
|
328
|
+
const thisVp = context.viewport;
|
|
329
|
+
if (thisVp === this._targetVp || !thisVp.view.isSpatialView())
|
|
330
|
+
return;
|
|
331
|
+
const builder = context.createGraphicBuilder(core_frontend_1.GraphicType.WorldDecoration);
|
|
332
|
+
FrustumDecoration.drawFrustumBox(builder, frustum, false, thisVp);
|
|
333
|
+
context.addDecorationFromBuilder(builder);
|
|
334
|
+
}
|
|
335
|
+
static toggle(vp, enabled) {
|
|
336
|
+
const instance = ShadowFrustumDecoration._instance;
|
|
337
|
+
if (undefined !== enabled) {
|
|
338
|
+
const alreadyEnabled = undefined !== instance;
|
|
339
|
+
if (enabled === alreadyEnabled)
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
if (undefined === instance) {
|
|
343
|
+
ShadowFrustumDecoration._instance = new ShadowFrustumDecoration(vp);
|
|
344
|
+
}
|
|
345
|
+
else {
|
|
346
|
+
instance.stop();
|
|
347
|
+
ShadowFrustumDecoration._instance = undefined;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
/** Toggle visualization of the selected viewport's shadow frustum in all other viewports.
|
|
352
|
+
* @beta
|
|
353
|
+
*/
|
|
354
|
+
class ToggleShadowFrustumTool extends core_frontend_1.Tool {
|
|
355
|
+
static get minArgs() { return 0; }
|
|
356
|
+
static get maxArgs() { return 1; }
|
|
357
|
+
async run(enable) {
|
|
358
|
+
const vp = core_frontend_1.IModelApp.viewManager.selectedView;
|
|
359
|
+
if (undefined !== vp && vp.view.isSpatialView())
|
|
360
|
+
ShadowFrustumDecoration.toggle(vp, enable);
|
|
361
|
+
return true;
|
|
362
|
+
}
|
|
363
|
+
async parseAndRun(...args) {
|
|
364
|
+
const enable = (0, parseToggle_1.parseToggle)(args[0]);
|
|
365
|
+
if (typeof enable !== "string")
|
|
366
|
+
await this.run(enable);
|
|
367
|
+
return true;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
exports.ToggleShadowFrustumTool = ToggleShadowFrustumTool;
|
|
371
|
+
ToggleShadowFrustumTool.toolId = "ToggleShadowFrustum";
|
|
372
|
+
//# sourceMappingURL=FrustumDecoration.js.map
|