@itwin/core-frontend 3.6.0-dev.1 → 3.6.0-dev.3
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/lib/cjs/GraphicalEditingScope.d.ts.map +1 -1
- package/lib/cjs/GraphicalEditingScope.js +8 -2
- package/lib/cjs/GraphicalEditingScope.js.map +1 -1
- package/lib/cjs/SelectionSet.d.ts.map +1 -1
- package/lib/cjs/SelectionSet.js +3 -1
- package/lib/cjs/SelectionSet.js.map +1 -1
- package/lib/esm/GraphicalEditingScope.d.ts.map +1 -1
- package/lib/esm/GraphicalEditingScope.js +8 -2
- package/lib/esm/GraphicalEditingScope.js.map +1 -1
- package/lib/esm/SelectionSet.d.ts.map +1 -1
- package/lib/esm/SelectionSet.js +3 -1
- package/lib/esm/SelectionSet.js.map +1 -1
- package/package.json +20 -20
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GraphicalEditingScope.d.ts","sourceRoot":"","sources":["../../src/GraphicalEditingScope.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAU,OAAO,
|
|
1
|
+
{"version":3,"file":"GraphicalEditingScope.d.ts","sourceRoot":"","sources":["../../src/GraphicalEditingScope.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAU,OAAO,EAAkE,UAAU,EAAe,MAAM,qBAAqB,CAAC;AAE/I,OAAO,EACL,yBAAyB,EAAE,qBAAqB,EAAE,aAAa,EAAE,oBAAoB,EAAE,yBAAyB,EACjH,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAc5D;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBAAa,qBAAsB,SAAQ,4BAA6B,YAAW,yBAAyB;IAC1G,IAAW,oBAAoB,kBAAyC;IAExE,8FAA8F;IAC9F,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAuC;IACxE,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,CAAiB;IAElC,iDAAiD;IACjD,SAAgB,MAAM,EAAE,mBAAmB,CAAC;IAE5C;;OAEG;IACH,gBAAuB,OAAO,kBAAuB,qBAAqB,KAAK,IAAI,EAAI;IAEvF;;;OAGG;IACH,SAAgB,SAAS,kBAAuB,qBAAqB,KAAK,IAAI,EAAI;IAElF;;;OAGG;IACH,SAAgB,QAAQ,kBAAuB,qBAAqB,KAAK,IAAI,EAAI;IAEjF,sEAAsE;IACtE,SAAgB,iBAAiB,oBAAyB,SAAS,oBAAoB,CAAC,SAAS,qBAAqB,KAAK,IAAI,EAAI;IAEnI;;OAEG;WACiB,KAAK,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAmBtF;;;OAGG;IACU,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAkBlC,yGAAyG;IAClG,0BAA0B,CAAC,OAAO,EAAE,UAAU,GAAG,QAAQ,CAAC,qBAAqB,CAAC,GAAG,SAAS;IAInG,4EAA4E;IACrE,kBAAkB,IAAI,QAAQ,CAAC,oBAAoB,CAAC;IAI3D,gBAAgB;IAChB,IAAW,UAAU,YAEpB;IAED,OAAO,CAAG,sBAAsB;IAWhC,OAAO;IAMP,OAAO,CAAC,OAAO;IAef,gBAAgB;IACT,qBAAqB,CAAC,KAAK,EAAE,yBAAyB,EAAE;CAiChE"}
|
|
@@ -145,6 +145,7 @@ class GraphicalEditingScope extends BriefcaseTxns_1.BriefcaseNotificationHandler
|
|
|
145
145
|
notifyGeometryChanged(props) {
|
|
146
146
|
const changes = core_common_1.ModelGeometryChanges.iterable(props);
|
|
147
147
|
const modelIds = [];
|
|
148
|
+
let deletedIds;
|
|
148
149
|
for (const modelChanges of changes) {
|
|
149
150
|
// ###TODO do we care about the model range?
|
|
150
151
|
let list = this._geometryChanges.get(modelChanges.id);
|
|
@@ -159,11 +160,16 @@ class GraphicalEditingScope extends BriefcaseTxns_1.BriefcaseNotificationHandler
|
|
|
159
160
|
}
|
|
160
161
|
list.insert(elementChange);
|
|
161
162
|
if (core_bentley_1.DbOpcode.Delete === elementChange.type) {
|
|
162
|
-
|
|
163
|
-
|
|
163
|
+
if (undefined === deletedIds)
|
|
164
|
+
deletedIds = new Set();
|
|
165
|
+
deletedIds.add(elementChange.id);
|
|
164
166
|
}
|
|
165
167
|
}
|
|
166
168
|
}
|
|
169
|
+
if (deletedIds) {
|
|
170
|
+
this.iModel.selectionSet.remove(deletedIds);
|
|
171
|
+
this.iModel.hilited.setHilite(deletedIds, false);
|
|
172
|
+
}
|
|
167
173
|
this.onGeometryChanges.raiseEvent(changes, this);
|
|
168
174
|
}
|
|
169
175
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GraphicalEditingScope.js","sourceRoot":"","sources":["../../src/GraphicalEditingScope.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAsI;AAEtI,oDAE4B;AAC5B,mDAA+D;AAE/D,qCAAkC;AAElC,MAAM,YAAa,SAAQ,0BAAkC;IAI3D,YAAmB,YAAwB,EAAE,KAAc;QACzD,KAAK,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,IAAA,6BAAc,EAAC,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE,CAAC,EAAE,8BAAe,CAAC,OAAO,CAAC,CAAC;QAC7E,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAa,qBAAsB,SAAQ,4CAA4B;IAqGrE,YAAoB,MAA2B;QAC7C,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAnGpB,8FAA8F;QAC7E,qBAAgB,GAA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xD;aACF;SACF;QAED,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACnD,CAAC;;AAnJH,sDAoJC;AAzIC;;GAEG;AACoB,6BAAO,GAAG,IAAI,sBAAO,EAA0C,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 IModelConnection\r\n */\r\n\r\nimport { assert, BeEvent, compareStrings, DbOpcode, DuplicatePolicy, GuidString, Id64String, SortedArray } from \"@itwin/core-bentley\";\r\nimport { Range3d } from \"@itwin/core-geometry\";\r\nimport {\r\n EditingScopeNotifications, ElementGeometryChange, IpcAppChannel, ModelGeometryChanges, ModelGeometryChangesProps, RemoveFunction,\r\n} from \"@itwin/core-common\";\r\nimport { BriefcaseNotificationHandler } from \"./BriefcaseTxns\";\r\nimport { BriefcaseConnection } from \"./BriefcaseConnection\";\r\nimport { IpcApp } from \"./IpcApp\";\r\n\r\nclass ModelChanges extends SortedArray<ElementGeometryChange> {\r\n public geometryGuid: GuidString;\r\n public readonly range: Range3d;\r\n\r\n public constructor(geometryGuid: GuidString, range: Range3d) {\r\n super((lhs, rhs) => compareStrings(lhs.id, rhs.id), DuplicatePolicy.Replace);\r\n this.geometryGuid = geometryGuid;\r\n this.range = range;\r\n }\r\n}\r\n\r\n/** Represents a period of time within an [interactive editing]($docs/learning/InteractiveEditing.md) session during which the\r\n * geometry of elements being displayed in one or more [[Viewport]]s is being modified. Outside of such a scope, whenever the\r\n * geometry within a [GeometricModel]($backend) changes new [[Tile]]s must be generated to reflect those changes in a viewport.\r\n * Regenerating entire tiles each time individual elements change can be time-consuming, which may introduce an unacceptable delay\r\n * between making a modification and seeing its result on the screen.\r\n *\r\n * Within the context of a graphical editing scope, no new tiles are generated. Instead, the geometry for any deleted or modified elements\r\n * is hidden in the tile graphics, and additional temporary graphics are displayed for any newly-inserted or modified elements. Only when the\r\n * scope exits are new tiles produced.\r\n *\r\n * The application decides when to enter and exit a graphical editing scope. A single interactive editing session may involve any number of\r\n * editing scopes. Typically, applications will enter a new editing scope (after first exiting a previous scope, if one exists):\r\n * - When switching from a non-graphical workflow to one that involves editing geometry; or\r\n * - When changing which geometric model is being edited; or\r\n * - After performing an operation that creates or modifies a \"large\" number (perhaps hundreds?) of elements.\r\n *\r\n * An application should typically exit any graphical editing scope before:\r\n * - Pulling changesets; or\r\n * - Switching from a graphical editing workflow to some non-graphical workflow.\r\n *\r\n * Graphical editing scopes are only supported for [[BriefcaseConnection]]s opened in read-write mode that contain version 1.0.11 or newer of the BisCore schema.\r\n * @see [[BriefcaseConnection.enterEditingScope]] to create a scope for a briefcase.\r\n * @see [[BriefcaseConnection.editingScope]] to obtain a briefcase's current scope.\r\n * @see [[exit]] to terminate a scope.\r\n * @public\r\n */\r\nexport class GraphicalEditingScope extends BriefcaseNotificationHandler implements EditingScopeNotifications {\r\n public get briefcaseChannelName() { return IpcAppChannel.EditingScope; }\r\n\r\n /** Maps model Id to accumulated changes to geometric elements within the associated model. */\r\n private readonly _geometryChanges = new Map<Id64String, ModelChanges>();\r\n private _disposed = false;\r\n private _cleanup?: RemoveFunction;\r\n\r\n /** The connection to the iModel being edited. */\r\n public readonly iModel: BriefcaseConnection;\r\n\r\n /** Event raised when a new scope is created for any [[BriefcaseConnection]].\r\n * @see [[onExiting]] and [[onExited]] for complementary events.\r\n */\r\n public static readonly onEnter = new BeEvent<(scope: GraphicalEditingScope) => void>();\r\n\r\n /** Event raised when this scope is about to exit.\r\n * @see [[onEnter]] for the complementary event.\r\n * @see [[onExited]] for an event raised after the scope exits.\r\n */\r\n public readonly onExiting = new BeEvent<(scope: GraphicalEditingScope) => void>();\r\n\r\n /** Event raised when this scope has exited.\r\n * @see [[onEnter]] for the complementary event.\r\n * @see [[onExiting]] for an event raised just before the scope is exited.\r\n */\r\n public readonly onExited = new BeEvent<(scope: GraphicalEditingScope) => void>();\r\n\r\n /** Event raised after geometric changes are written to the iModel. */\r\n public readonly onGeometryChanges = new BeEvent<(changes: Iterable<ModelGeometryChanges>, scope: GraphicalEditingScope) => void>();\r\n\r\n /** Don't call this directly - use BriefcaseConnection.enterEditingScope.\r\n * @internal\r\n */\r\n public static async enter(imodel: BriefcaseConnection): Promise<GraphicalEditingScope> {\r\n if (imodel.editingScope)\r\n throw new Error(\"Cannot create an editing scope for an iModel that already has one\");\r\n\r\n // Register the scope synchronously, in case enter() is called again for same iModel while awaiting asynchronous initialization.\r\n const scope = new GraphicalEditingScope(imodel);\r\n try {\r\n const scopeStarted = await IpcApp.appFunctionIpc.toggleGraphicalEditingScope(imodel.key, true);\r\n assert(scopeStarted); // If it didn't, the backend threw an error.\r\n } catch (e) {\r\n scope.dispose();\r\n throw e;\r\n }\r\n\r\n this.onEnter.raiseEvent(scope);\r\n\r\n return scope;\r\n }\r\n\r\n /** Exits this editing scope. The associated [[BriefcaseConnection]]'s `editingScope` will be reset to `undefined`.\r\n * @throws Error if the scope could not be exited, e.g., if it has already been exited.\r\n * @see [[BriefcaseConnection.enterEditingScope]] to enter an editing scope.\r\n */\r\n public async exit(): Promise<void> {\r\n if (this._disposed || this.iModel.editingScope !== this)\r\n throw new Error(\"Cannot exit editing scope after it is disconnected from the iModel\");\r\n\r\n this._disposed = true;\r\n try {\r\n this.onExiting.raiseEvent(this);\r\n } finally {\r\n const scopeExited = await IpcApp.appFunctionIpc.toggleGraphicalEditingScope(this.iModel.key, false);\r\n assert(!scopeExited);\r\n try {\r\n this.onExited.raiseEvent(this);\r\n } finally {\r\n this.dispose();\r\n }\r\n }\r\n }\r\n\r\n /** Obtain all geometric changes to elements within the specified model accumulated within this scope. */\r\n public getGeometryChangesForModel(modelId: Id64String): Iterable<ElementGeometryChange> | undefined {\r\n return this._geometryChanges.get(modelId);\r\n }\r\n\r\n /** Obtain all geometric changes to models accumulated within this scope. */\r\n public getGeometryChanges(): Iterable<ModelGeometryChanges> {\r\n return { [Symbol.iterator]: () => this.geometryChangeIterator() };\r\n }\r\n\r\n /** @internal */\r\n public get isDisposed() {\r\n return this._disposed;\r\n }\r\n\r\n private * geometryChangeIterator(): Iterator<ModelGeometryChanges> {\r\n for (const [key, value] of this._geometryChanges) {\r\n yield {\r\n id: key,\r\n geometryGuid: value.geometryGuid,\r\n range: value.range,\r\n elements: value,\r\n };\r\n }\r\n }\r\n\r\n private constructor(iModel: BriefcaseConnection) {\r\n super(iModel.key);\r\n this.iModel = iModel;\r\n this._cleanup = this.registerImpl();\r\n }\r\n\r\n private dispose(): void {\r\n this._disposed = true;\r\n\r\n this.onExiting.clear();\r\n this.onGeometryChanges.clear();\r\n this.onExited.clear();\r\n\r\n this._geometryChanges.clear();\r\n\r\n if (this._cleanup) {\r\n this._cleanup();\r\n this._cleanup = undefined;\r\n }\r\n }\r\n\r\n /** @internal */\r\n public notifyGeometryChanged(props: ModelGeometryChangesProps[]) {\r\n const changes = ModelGeometryChanges.iterable(props);\r\n const modelIds: Id64String[] = [];\r\n for (const modelChanges of changes) {\r\n // ###TODO do we care about the model range?\r\n let list = this._geometryChanges.get(modelChanges.id);\r\n modelIds.push(modelChanges.id);\r\n for (const elementChange of modelChanges.elements) {\r\n if (!list) {\r\n this._geometryChanges.set(modelChanges.id, list = new ModelChanges(modelChanges.geometryGuid, modelChanges.range));\r\n } else {\r\n list.geometryGuid = modelChanges.geometryGuid;\r\n modelChanges.range.clone(list.range);\r\n }\r\n\r\n list.insert(elementChange);\r\n if (DbOpcode.Delete === elementChange.type) {\r\n this.iModel.selectionSet.remove(elementChange.id);\r\n this.iModel.hilited.setHilite(elementChange.id, false);\r\n }\r\n }\r\n }\r\n\r\n this.onGeometryChanges.raiseEvent(changes, this);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"GraphicalEditingScope.js","sourceRoot":"","sources":["../../src/GraphicalEditingScope.ts"],"names":[],"mappings":";AAAA;;;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AI,CAAC,IAAI,EAAE;oBACT,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,EAAE,IAAI,GAAG,IAAI,YAAY,CAAC,YAAY,CAAC,YAAY,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;iBACpH;qBAAM;oBACL,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC,YAAY,CAAC;oBAC9C,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;iBACtC;gBAED,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;gBAC3B,IAAI,uBAAQ,CAAC,MAAM,KAAK,aAAa,CAAC,IAAI,EAAE;oBAC1C,IAAI,SAAS,KAAK,UAAU;wBAC1B,UAAU,GAAG,IAAI,GAAG,EAAc,CAAC;oBACrC,UAAU,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;iBAClC;aACF;SACF;QAED,IAAI,UAAU,EAAE;YACd,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;YAC5C,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;SAClD;QAED,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACnD,CAAC;;AA3JH,sDA4JC;AAjJC;;GAEG;AACoB,6BAAO,GAAG,IAAI,sBAAO,EAA0C,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 IModelConnection\r\n */\r\n\r\nimport { assert, BeEvent, compareStrings, DbOpcode, DuplicatePolicy, GuidString, Id64Set, Id64String, SortedArray } from \"@itwin/core-bentley\";\r\nimport { Range3d } from \"@itwin/core-geometry\";\r\nimport {\r\n EditingScopeNotifications, ElementGeometryChange, IpcAppChannel, ModelGeometryChanges, ModelGeometryChangesProps, RemoveFunction,\r\n} from \"@itwin/core-common\";\r\nimport { BriefcaseNotificationHandler } from \"./BriefcaseTxns\";\r\nimport { BriefcaseConnection } from \"./BriefcaseConnection\";\r\nimport { IpcApp } from \"./IpcApp\";\r\n\r\nclass ModelChanges extends SortedArray<ElementGeometryChange> {\r\n public geometryGuid: GuidString;\r\n public readonly range: Range3d;\r\n\r\n public constructor(geometryGuid: GuidString, range: Range3d) {\r\n super((lhs, rhs) => compareStrings(lhs.id, rhs.id), DuplicatePolicy.Replace);\r\n this.geometryGuid = geometryGuid;\r\n this.range = range;\r\n }\r\n}\r\n\r\n/** Represents a period of time within an [interactive editing]($docs/learning/InteractiveEditing.md) session during which the\r\n * geometry of elements being displayed in one or more [[Viewport]]s is being modified. Outside of such a scope, whenever the\r\n * geometry within a [GeometricModel]($backend) changes new [[Tile]]s must be generated to reflect those changes in a viewport.\r\n * Regenerating entire tiles each time individual elements change can be time-consuming, which may introduce an unacceptable delay\r\n * between making a modification and seeing its result on the screen.\r\n *\r\n * Within the context of a graphical editing scope, no new tiles are generated. Instead, the geometry for any deleted or modified elements\r\n * is hidden in the tile graphics, and additional temporary graphics are displayed for any newly-inserted or modified elements. Only when the\r\n * scope exits are new tiles produced.\r\n *\r\n * The application decides when to enter and exit a graphical editing scope. A single interactive editing session may involve any number of\r\n * editing scopes. Typically, applications will enter a new editing scope (after first exiting a previous scope, if one exists):\r\n * - When switching from a non-graphical workflow to one that involves editing geometry; or\r\n * - When changing which geometric model is being edited; or\r\n * - After performing an operation that creates or modifies a \"large\" number (perhaps hundreds?) of elements.\r\n *\r\n * An application should typically exit any graphical editing scope before:\r\n * - Pulling changesets; or\r\n * - Switching from a graphical editing workflow to some non-graphical workflow.\r\n *\r\n * Graphical editing scopes are only supported for [[BriefcaseConnection]]s opened in read-write mode that contain version 1.0.11 or newer of the BisCore schema.\r\n * @see [[BriefcaseConnection.enterEditingScope]] to create a scope for a briefcase.\r\n * @see [[BriefcaseConnection.editingScope]] to obtain a briefcase's current scope.\r\n * @see [[exit]] to terminate a scope.\r\n * @public\r\n */\r\nexport class GraphicalEditingScope extends BriefcaseNotificationHandler implements EditingScopeNotifications {\r\n public get briefcaseChannelName() { return IpcAppChannel.EditingScope; }\r\n\r\n /** Maps model Id to accumulated changes to geometric elements within the associated model. */\r\n private readonly _geometryChanges = new Map<Id64String, ModelChanges>();\r\n private _disposed = false;\r\n private _cleanup?: RemoveFunction;\r\n\r\n /** The connection to the iModel being edited. */\r\n public readonly iModel: BriefcaseConnection;\r\n\r\n /** Event raised when a new scope is created for any [[BriefcaseConnection]].\r\n * @see [[onExiting]] and [[onExited]] for complementary events.\r\n */\r\n public static readonly onEnter = new BeEvent<(scope: GraphicalEditingScope) => void>();\r\n\r\n /** Event raised when this scope is about to exit.\r\n * @see [[onEnter]] for the complementary event.\r\n * @see [[onExited]] for an event raised after the scope exits.\r\n */\r\n public readonly onExiting = new BeEvent<(scope: GraphicalEditingScope) => void>();\r\n\r\n /** Event raised when this scope has exited.\r\n * @see [[onEnter]] for the complementary event.\r\n * @see [[onExiting]] for an event raised just before the scope is exited.\r\n */\r\n public readonly onExited = new BeEvent<(scope: GraphicalEditingScope) => void>();\r\n\r\n /** Event raised after geometric changes are written to the iModel. */\r\n public readonly onGeometryChanges = new BeEvent<(changes: Iterable<ModelGeometryChanges>, scope: GraphicalEditingScope) => void>();\r\n\r\n /** Don't call this directly - use BriefcaseConnection.enterEditingScope.\r\n * @internal\r\n */\r\n public static async enter(imodel: BriefcaseConnection): Promise<GraphicalEditingScope> {\r\n if (imodel.editingScope)\r\n throw new Error(\"Cannot create an editing scope for an iModel that already has one\");\r\n\r\n // Register the scope synchronously, in case enter() is called again for same iModel while awaiting asynchronous initialization.\r\n const scope = new GraphicalEditingScope(imodel);\r\n try {\r\n const scopeStarted = await IpcApp.appFunctionIpc.toggleGraphicalEditingScope(imodel.key, true);\r\n assert(scopeStarted); // If it didn't, the backend threw an error.\r\n } catch (e) {\r\n scope.dispose();\r\n throw e;\r\n }\r\n\r\n this.onEnter.raiseEvent(scope);\r\n\r\n return scope;\r\n }\r\n\r\n /** Exits this editing scope. The associated [[BriefcaseConnection]]'s `editingScope` will be reset to `undefined`.\r\n * @throws Error if the scope could not be exited, e.g., if it has already been exited.\r\n * @see [[BriefcaseConnection.enterEditingScope]] to enter an editing scope.\r\n */\r\n public async exit(): Promise<void> {\r\n if (this._disposed || this.iModel.editingScope !== this)\r\n throw new Error(\"Cannot exit editing scope after it is disconnected from the iModel\");\r\n\r\n this._disposed = true;\r\n try {\r\n this.onExiting.raiseEvent(this);\r\n } finally {\r\n const scopeExited = await IpcApp.appFunctionIpc.toggleGraphicalEditingScope(this.iModel.key, false);\r\n assert(!scopeExited);\r\n try {\r\n this.onExited.raiseEvent(this);\r\n } finally {\r\n this.dispose();\r\n }\r\n }\r\n }\r\n\r\n /** Obtain all geometric changes to elements within the specified model accumulated within this scope. */\r\n public getGeometryChangesForModel(modelId: Id64String): Iterable<ElementGeometryChange> | undefined {\r\n return this._geometryChanges.get(modelId);\r\n }\r\n\r\n /** Obtain all geometric changes to models accumulated within this scope. */\r\n public getGeometryChanges(): Iterable<ModelGeometryChanges> {\r\n return { [Symbol.iterator]: () => this.geometryChangeIterator() };\r\n }\r\n\r\n /** @internal */\r\n public get isDisposed() {\r\n return this._disposed;\r\n }\r\n\r\n private * geometryChangeIterator(): Iterator<ModelGeometryChanges> {\r\n for (const [key, value] of this._geometryChanges) {\r\n yield {\r\n id: key,\r\n geometryGuid: value.geometryGuid,\r\n range: value.range,\r\n elements: value,\r\n };\r\n }\r\n }\r\n\r\n private constructor(iModel: BriefcaseConnection) {\r\n super(iModel.key);\r\n this.iModel = iModel;\r\n this._cleanup = this.registerImpl();\r\n }\r\n\r\n private dispose(): void {\r\n this._disposed = true;\r\n\r\n this.onExiting.clear();\r\n this.onGeometryChanges.clear();\r\n this.onExited.clear();\r\n\r\n this._geometryChanges.clear();\r\n\r\n if (this._cleanup) {\r\n this._cleanup();\r\n this._cleanup = undefined;\r\n }\r\n }\r\n\r\n /** @internal */\r\n public notifyGeometryChanged(props: ModelGeometryChangesProps[]) {\r\n const changes = ModelGeometryChanges.iterable(props);\r\n const modelIds: Id64String[] = [];\r\n let deletedIds: Id64Set | undefined;\r\n\r\n for (const modelChanges of changes) {\r\n // ###TODO do we care about the model range?\r\n let list = this._geometryChanges.get(modelChanges.id);\r\n modelIds.push(modelChanges.id);\r\n for (const elementChange of modelChanges.elements) {\r\n if (!list) {\r\n this._geometryChanges.set(modelChanges.id, list = new ModelChanges(modelChanges.geometryGuid, modelChanges.range));\r\n } else {\r\n list.geometryGuid = modelChanges.geometryGuid;\r\n modelChanges.range.clone(list.range);\r\n }\r\n\r\n list.insert(elementChange);\r\n if (DbOpcode.Delete === elementChange.type) {\r\n if (undefined === deletedIds)\r\n deletedIds = new Set<Id64String>();\r\n deletedIds.add(elementChange.id);\r\n }\r\n }\r\n }\r\n\r\n if (deletedIds) {\r\n this.iModel.selectionSet.remove(deletedIds);\r\n this.iModel.hilited.setHilite(deletedIds, false);\r\n }\r\n\r\n this.onGeometryChanges.raiseEvent(changes, this);\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectionSet.d.ts","sourceRoot":"","sources":["../../src/SelectionSet.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD;;;GAGG;AACH,oBAAY,qBAAqB;IAC/B,2CAA2C;IAC3C,GAAG,IAAA;IACH,+CAA+C;IAC/C,MAAM,IAAA;IACN,6EAA6E;IAC7E,OAAO,IAAA;IACP,yDAAyD;IACzD,KAAK,IAAA;CACN;A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,EAAE,OAAO,GAAG,IAAI;CAarD;AAED;;;;;GAKG;AACH,qBAAa,YAAY;IAWG,MAAM,EAAE,gBAAgB;IAVlD,OAAO,CAAC,SAAS,CAAqB;IAEtC;;OAEG;IACH,IAAW,QAAQ,IAAI,GAAG,CAAC,MAAM,CAAC,CAA2B;IAE7D,2EAA2E;IAC3E,SAAgB,SAAS,eAAoB,iBAAiB,KAAK,IAAI,EAAI;gBAEjD,MAAM,EAAE,gBAAgB;IAElD,OAAO,CAAC,gBAAgB;IAKxB,uDAAuD;IACvD,IAAW,IAAI,WAAiC;IAEhD,qDAAqD;IACrD,IAAW,QAAQ,YAA8B;IAEjD;;OAEG;IACI,GAAG,CAAC,MAAM,CAAC,EAAE,MAAM;IAE1B;;OAEG;IACI,UAAU,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,OAAO;IAE/C;;OAEG;IACI,QAAQ,IAAI,IAAI;IASvB;;;;OAIG;IACI,GAAG,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO;IAIlC,OAAO,CAAC,IAAI;IAYZ;;;;OAIG;IACI,MAAM,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO;IAIrC,OAAO,CAAC,OAAO;IAYf;;;OAGG;IACI,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO;IAc7D,2DAA2D;IACpD,MAAM,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO;IAarC,0DAA0D;IACnD,OAAO,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI;CAiBpC"}
|
package/lib/cjs/SelectionSet.js
CHANGED
|
@@ -167,13 +167,15 @@ class HiliteSet {
|
|
|
167
167
|
* @param onOff True to add the elements to the hilited set, false to remove them.
|
|
168
168
|
*/
|
|
169
169
|
setHilite(arg, onOff) {
|
|
170
|
+
const oldSize = this.elements.size;
|
|
170
171
|
for (const id of core_bentley_1.Id64.iterable(arg)) {
|
|
171
172
|
if (onOff)
|
|
172
173
|
this.elements.addId(id);
|
|
173
174
|
else
|
|
174
175
|
this.elements.deleteId(id);
|
|
175
176
|
}
|
|
176
|
-
|
|
177
|
+
if (oldSize !== this.elements.size)
|
|
178
|
+
IModelApp_1.IModelApp.viewManager.onSelectionSetChanged(this.iModel);
|
|
177
179
|
}
|
|
178
180
|
}
|
|
179
181
|
exports.HiliteSet = HiliteSet;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectionSet.js","sourceRoot":"","sources":["../../src/SelectionSet.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,sDAAyE;AACzE,2CAAwC;AAGxC;;;GAGG;AACH,IAAY,qBASX;AATD,WAAY,qBAAqB;IAC/B,2CAA2C;IAC3C,+DAAG,CAAA;IACH,+CAA+C;IAC/C,qEAAM,CAAA;IACN,6EAA6E;IAC7E,uEAAO,CAAA;IACP,yDAAyD;IACzD,mEAAK,CAAA;AACP,CAAC,EATW,qBAAqB,GAArB,6BAAqB,KAArB,6BAAqB,QAShC;AAyDD;;GAEG;AACH,MAAM,UAAW,SAAQ,mBAAI,CAAC,SAAS;IAIrC,YAAmB,MAAwB;QACzC,KAAK,EAAE,CAAC;QAHA,cAAS,GAAG,KAAK,CAAC;QAI1B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAEe,GAAG,CAAC,GAAW,EAAE,IAAY;QAC3C,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QACrB,IAAI,CAAC,SAAS,EAAE,CAAC;IACnB,CAAC;IAEe,MAAM,CAAC,GAAW,EAAE,IAAY;QAC9C,KAAK,CAAC,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QACxB,IAAI,CAAC,SAAS,EAAE,CAAC;IACnB,CAAC;IAEe,KAAK;QACnB,KAAK,CAAC,KAAK,EAAE,CAAC;QACd,IAAI,CAAC,SAAS,EAAE,CAAC;IACnB,CAAC;IAEe,MAAM,CAAC,GAAY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AI,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC;YAC/B,OAAO;QAET,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC;QAC/B,IAAI,CAAC,SAAS,GAAG,IAAI,GAAG,EAAU,CAAC;QACnC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAEvB,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,EAAE;YACpB,KAAK,MAAM,EAAE,IAAI,mBAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;gBACpC,IAAI,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;oBACjB,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;aACtB;SACF;QAED,IAAI,CAAC,gBAAgB,CAAC,EAAE,IAAI,EAAE,qBAAqB,CAAC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;IAClG,CAAC;CACF;AA1ID,oCA0IC;AAED,SAAS,QAAQ,CAAC,GAAgB,EAAE,GAAY;IAC9C,wDAAwD;IACxD,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;QACpB,GAAG,GAAG,mBAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAE1B,IAAI,GAAG,CAAC,IAAI,KAAK,mBAAI,CAAC,MAAM,CAAC,GAAG,CAAC;QAC/B,OAAO,KAAK,CAAC;IAEf,KAAK,MAAM,EAAE,IAAI,mBAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;QACjC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YACd,OAAO,KAAK,CAAC;IAEjB,OAAO,IAAI,CAAC;AACd,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 SelectionSet\r\n */\r\nimport { BeEvent, Id64, Id64Arg, Id64String } from \"@itwin/core-bentley\";\r\nimport { IModelApp } from \"./IModelApp\";\r\nimport { IModelConnection } from \"./IModelConnection\";\r\n\r\n/** Identifies the type of changes made to the [[SelectionSet]] to produce a [[SelectionSetEvent]].\r\n * @public\r\n * @extensions\r\n */\r\nexport enum SelectionSetEventType {\r\n /** Elements have been added to the set. */\r\n Add,\r\n /** Elements have been removed from the set. */\r\n Remove,\r\n /** Some elements have been added to the set and others have been removed. */\r\n Replace,\r\n /** All elements are about to be removed from the set. */\r\n Clear,\r\n}\r\n\r\n/** Passed to [[SelectionSet.onChanged]] event listeners when elements are added to the selection set.\r\n * @public\r\n * @extensions\r\n */\r\nexport interface SelectAddEvent {\r\n type: SelectionSetEventType.Add;\r\n /** The Ids of the elements added to the set. */\r\n added: Id64Arg;\r\n /** The affected SelectionSet. */\r\n set: SelectionSet;\r\n}\r\n\r\n/** Passed to [[SelectionSet.onChanged]] event listeners when elements are removed from the selection set.\r\n * @public\r\n * @extensions\r\n */\r\nexport interface SelectRemoveEvent {\r\n /** The type of operation that produced this event. */\r\n type: SelectionSetEventType.Remove | SelectionSetEventType.Clear;\r\n /** The element Ids removed from the set. */\r\n removed: Id64Arg;\r\n /** The affected SelectionSet. */\r\n set: SelectionSet;\r\n}\r\n\r\n/** Passed to [[SelectionSet.onChanged]] event listeners when elements are simultaneously added to and removed from the selection set.\r\n * @public\r\n * @extensions\r\n */\r\nexport interface SelectReplaceEvent {\r\n type: SelectionSetEventType.Replace;\r\n /** The element Ids added to the set. */\r\n added: Id64Arg;\r\n /** The element Ids removed from the set. */\r\n removed: Id64Arg;\r\n /** The affected SelectionSet. */\r\n set: SelectionSet;\r\n}\r\n\r\n/** Payload sent to [[SelectionSet.onChanged]] event listeners to describe how the contents of the set have changed.\r\n * The `type` property of the event serves as a type assertion. For example, the following code will output the added and/or removed Ids:\r\n * ```ts\r\n * processSelectionSetEvent(ev: SelectionSetEvent): void {\r\n * if (SelectionSetEventType.Add === ev.type || SelectionSetEventType.Replace === ev.type)\r\n * console.log(\"Added \" + ev.added.size + \" elements\");\r\n *\r\n * if (SelectionSetEventType.Add !== ev.type)\r\n * console.log(\"Removed \" + ev.removed.size + \" elements\");\r\n * }\r\n * ```\r\n * @public\r\n * @extensions\r\n */\r\nexport type SelectionSetEvent = SelectAddEvent | SelectRemoveEvent | SelectReplaceEvent;\r\n\r\n/** Tracks a set of hilited entities. When the set changes, notifies ViewManager so that symbology overrides can be updated in active Viewports.\r\n * @internal\r\n */\r\nclass HilitedIds extends Id64.Uint32Set {\r\n protected _iModel: IModelConnection;\r\n protected _changing = false;\r\n\r\n public constructor(iModel: IModelConnection) {\r\n super();\r\n this._iModel = iModel;\r\n }\r\n\r\n public override add(low: number, high: number) {\r\n super.add(low, high);\r\n this.onChanged();\r\n }\r\n\r\n public override delete(low: number, high: number) {\r\n super.delete(low, high);\r\n this.onChanged();\r\n }\r\n\r\n public override clear() {\r\n super.clear();\r\n this.onChanged();\r\n }\r\n\r\n public override addIds(ids: Id64Arg) {\r\n this.change(() => super.addIds(ids));\r\n }\r\n\r\n public override deleteIds(ids: Id64Arg) {\r\n this.change(() => super.deleteIds(ids));\r\n }\r\n\r\n protected onChanged() {\r\n if (!this._changing)\r\n IModelApp.viewManager.onSelectionSetChanged(this._iModel);\r\n }\r\n\r\n protected change(func: () => void) {\r\n const changing = this._changing;\r\n this._changing = false;\r\n func();\r\n this._changing = changing;\r\n this.onChanged();\r\n }\r\n}\r\n\r\n/** Keeps the set of hilited elements in sync with the selection set.\r\n * @internal\r\n */\r\nclass HilitedElementIds extends HilitedIds {\r\n private _removeListener?: () => void;\r\n\r\n public constructor(iModel: IModelConnection, syncWithSelectionSet = true) {\r\n super(iModel);\r\n this.wantSyncWithSelectionSet = syncWithSelectionSet;\r\n }\r\n\r\n public get wantSyncWithSelectionSet(): boolean { return undefined !== this._removeListener; }\r\n public set wantSyncWithSelectionSet(want: boolean) {\r\n if (want === this.wantSyncWithSelectionSet)\r\n return;\r\n\r\n if (want) {\r\n const set = this._iModel.selectionSet;\r\n this._removeListener = set.onChanged.addListener((ev) => this.change(() => this.processSelectionSetEvent(ev)));\r\n this.processSelectionSetEvent({\r\n set,\r\n type: SelectionSetEventType.Add,\r\n added: set.elements,\r\n });\r\n } else {\r\n this._removeListener!();\r\n this._removeListener = undefined;\r\n }\r\n }\r\n\r\n private processSelectionSetEvent(ev: SelectionSetEvent): void {\r\n if (SelectionSetEventType.Add !== ev.type)\r\n this.deleteIds(ev.removed);\r\n\r\n if (ev.type === SelectionSetEventType.Add || ev.type === SelectionSetEventType.Replace)\r\n this.addIds(ev.added);\r\n }\r\n}\r\n\r\n/** Describes how the sets of hilited models and subcategories in a [[HiliteSet]] interact.\r\n * - \"union\" indicates a [Feature]($common) will be hilited if either its model **or** its subcategory is present in the HiliteSet.\r\n * - \"intersection\" indicates a [Feature]($common) will be hilited only if both its model **and** its subcategory are present in the HiliteSet.\r\n *\r\n * @see [[HiliteSet.modelSubCategoryMode]] to change the mode for a HiliteSet.\r\n * @public\r\n */\r\nexport type ModelSubCategoryHiliteMode = \"union\" | \"intersection\";\r\n\r\n/** A set of *hilited* elements for an [[IModelConnection]], by element id.\r\n * Hilited elements are displayed with a customizable hilite effect within a [[Viewport]].\r\n * The set exposes 3 types of elements in 3 separate collections: [GeometricElement]($backend), [GeometricModel]($backend), and [SubCategory]($backend).\r\n * The [[models]] and [[subcategories]] can be hilited independently or as an intersection of the two sets, as specified by [[modelSubCategoryMode]].\r\n *\r\n * Technically, the hilite effect is applied to [Feature]($common)s, not [Element]($backend)s. An element's geometry stream can contain multiple\r\n * features belonging to different subcategories.\r\n *\r\n * Because Javascript lacks efficient support for 64-bit integers, the Ids are stored as pairs of 32-bit integers via [Id64.Uint32Set]($bentley).\r\n *\r\n * @note Typically, elements are hilited by virtue of their presence in the IModelConnection's [[SelectionSet]]. The HiliteSet allows additional\r\n * elements to be displayed with the hilite effect without adding them to the [[SelectionSet]]. If you add elements to the HiliteSet directly, you\r\n * are also responsible for removing them as appropriate.\r\n * @see [[IModelConnection.hilited]] for the HiliteSet associated with an iModel.\r\n * @see [Hilite.Settings]($common) for customization of the hilite effect.\r\n * @public\r\n * @extensions\r\n */\r\nexport class HiliteSet {\r\n private readonly _elements: HilitedElementIds;\r\n private _mode: ModelSubCategoryHiliteMode = \"union\";\r\n\r\n /** The set of hilited subcategories.\r\n * @see [[modelSubCategoryMode]] to control how this set interacts with the set of hilited [[models]].\r\n * @see [[IModelConnection.Categories]] to obtain the set of subcategories associated with one or more [Category]($backend)'s.\r\n */\r\n public readonly subcategories: Id64.Uint32Set;\r\n\r\n /** The set of hilited [[GeometricModelState]]s.\r\n * @see [[modelSubCategoryMode]] to control how this set interacts with the set of hilited [[subcategories]].\r\n */\r\n public readonly models: Id64.Uint32Set;\r\n\r\n /** The set of hilited elements. */\r\n public get elements(): Id64.Uint32Set { return this._elements; }\r\n\r\n /** Controls how the sets of hilited [[models]] and [[subcategories]] interact with one another.\r\n * By default they are treated as a union: a [Feature]($common) is hilited if either its model **or** its subcategory is hilited.\r\n * This can be changed to an intersection such that a [Feature]($common) is hilited only if both its model **and** subcategory are hilited.\r\n * @note The sets of hilited models and subcategories are independent of the set of hilited [[elements]] - an element whose Id is present in\r\n * [[elements]] is always hilited regardless of its model or subcategories.\r\n */\r\n public get modelSubCategoryMode(): ModelSubCategoryHiliteMode {\r\n return this._mode;\r\n }\r\n public set modelSubCategoryMode(mode: ModelSubCategoryHiliteMode) {\r\n if (mode === this._mode)\r\n return;\r\n\r\n this.onModelSubCategoryModeChanged.raiseEvent(mode);\r\n this._mode = mode;\r\n }\r\n\r\n /** Event raised just before changing the value of [[modelSubCategoryMode]]. */\r\n public readonly onModelSubCategoryModeChanged = new BeEvent<(newMode: ModelSubCategoryHiliteMode) => void>();\r\n\r\n /** Construct a HiliteSet\r\n * @param iModel The iModel containing the entities to be hilited.\r\n * @param syncWithSelectionSet If true, the contents of the `elements` set will be synchronized with those in the `iModel`'s [[SelectionSet]].\r\n * @internal\r\n */\r\n public constructor(public iModel: IModelConnection, syncWithSelectionSet = true) {\r\n this._elements = new HilitedElementIds(iModel, syncWithSelectionSet);\r\n this.subcategories = new HilitedIds(iModel);\r\n this.models = new HilitedIds(iModel);\r\n }\r\n\r\n /** Control whether the hilited elements will be synchronized with the contents of the [[SelectionSet]].\r\n * By default they are synchronized. Applications that override this take responsibility for managing the set of hilited entities.\r\n * When turning synchronization off, the contents of the HiliteSet will remain unchanged.\r\n * When turning synchronization on, the current contents of the HiliteSet will be preserved, and the contents of the selection set will be added to them.\r\n */\r\n public get wantSyncWithSelectionSet(): boolean { return this._elements.wantSyncWithSelectionSet; }\r\n public set wantSyncWithSelectionSet(want: boolean) { this._elements.wantSyncWithSelectionSet = want; }\r\n\r\n /** Remove all elements from the hilited set. */\r\n public clear() {\r\n this.elements.clear();\r\n this.subcategories.clear();\r\n this.models.clear();\r\n }\r\n\r\n /** Returns true if nothing is hilited. */\r\n public get isEmpty(): boolean { return this.elements.isEmpty && this.subcategories.isEmpty && this.models.isEmpty; }\r\n\r\n /** Toggle the hilited state of one or more elements.\r\n * @param arg the ID(s) of the elements whose state is to be toggled.\r\n * @param onOff True to add the elements to the hilited set, false to remove them.\r\n */\r\n public setHilite(arg: Id64Arg, onOff: boolean): void {\r\n for (const id of Id64.iterable(arg)) {\r\n if (onOff)\r\n this.elements.addId(id);\r\n else\r\n this.elements.deleteId(id);\r\n }\r\n\r\n IModelApp.viewManager.onSelectionSetChanged(this.iModel);\r\n }\r\n}\r\n\r\n/** A set of *currently selected* elements for an IModelConnection.\r\n * Selected elements are displayed with a customizable hilite effect within a [[Viewport]].\r\n * @see [Hilite.Settings]($common) for customization of the hilite effect.\r\n * @public\r\n * @extensions\r\n */\r\nexport class SelectionSet {\r\n private _elements = new Set<string>();\r\n\r\n /** The IDs of the selected elements.\r\n * @note Do not modify this set directly. Instead, use methods like [[SelectionSet.add]].\r\n */\r\n public get elements(): Set<string> { return this._elements; }\r\n\r\n /** Called whenever elements are added or removed from this SelectionSet */\r\n public readonly onChanged = new BeEvent<(ev: SelectionSetEvent) => void>();\r\n\r\n public constructor(public iModel: IModelConnection) { }\r\n\r\n private sendChangedEvent(ev: SelectionSetEvent) {\r\n IModelApp.viewManager.onSelectionSetChanged(this.iModel);\r\n this.onChanged.raiseEvent(ev);\r\n }\r\n\r\n /** Get the number of entries in this selection set. */\r\n public get size() { return this.elements.size; }\r\n\r\n /** Check whether there are any selected elements. */\r\n public get isActive() { return this.size !== 0; }\r\n\r\n /** Return true if elemId is in this SelectionSet.\r\n * @see [[isSelected]]\r\n */\r\n public has(elemId?: string) { return !!elemId && this.elements.has(elemId); }\r\n\r\n /** Query whether an Id is in the selection set.\r\n * @see [[has]]\r\n */\r\n public isSelected(elemId?: Id64String): boolean { return !!elemId && this.elements.has(elemId); }\r\n\r\n /** Clear current selection set.\r\n * @note raises the [[onChanged]] event with [[SelectionSetEventType.Clear]].\r\n */\r\n public emptyAll(): void {\r\n if (!this.isActive)\r\n return;\r\n\r\n const removed = this._elements;\r\n this._elements = new Set<string>();\r\n this.sendChangedEvent({ set: this, type: SelectionSetEventType.Clear, removed });\r\n }\r\n\r\n /**\r\n * Add one or more Ids to the current selection set.\r\n * @param elem The set of Ids to add.\r\n * @returns true if any elements were added.\r\n */\r\n public add(elem: Id64Arg): boolean {\r\n return this._add(elem);\r\n }\r\n\r\n private _add(elem: Id64Arg, sendEvent = true): boolean {\r\n const oldSize = this.elements.size;\r\n for (const id of Id64.iterable(elem))\r\n this.elements.add(id);\r\n\r\n const changed = oldSize !== this.elements.size;\r\n if (sendEvent && changed)\r\n this.sendChangedEvent({ type: SelectionSetEventType.Add, set: this, added: elem });\r\n\r\n return changed;\r\n }\r\n\r\n /**\r\n * Remove one or more Ids from the current selection set.\r\n * @param elem The set of Ids to remove.\r\n * @returns true if any elements were removed.\r\n */\r\n public remove(elem: Id64Arg): boolean {\r\n return this._remove(elem);\r\n }\r\n\r\n private _remove(elem: Id64Arg, sendEvent = true): boolean {\r\n const oldSize = this.elements.size;\r\n for (const id of Id64.iterable(elem))\r\n this.elements.delete(id);\r\n\r\n const changed = oldSize !== this.elements.size;\r\n if (sendEvent && changed)\r\n this.sendChangedEvent({ type: SelectionSetEventType.Remove, set: this, removed: elem });\r\n\r\n return changed;\r\n }\r\n\r\n /**\r\n * Add one set of Ids, and remove another set of Ids. Any Ids that are in both sets are removed.\r\n * @returns True if any Ids were either added or removed.\r\n */\r\n public addAndRemove(adds: Id64Arg, removes: Id64Arg): boolean {\r\n const added = this._add(adds, false);\r\n const removed = this._remove(removes, false);\r\n\r\n if (added && removed)\r\n this.sendChangedEvent({ type: SelectionSetEventType.Replace, set: this, added: adds, removed: removes });\r\n else if (added)\r\n this.sendChangedEvent({ type: SelectionSetEventType.Add, set: this, added: adds });\r\n else if (removed)\r\n this.sendChangedEvent({ type: SelectionSetEventType.Remove, set: this, removed: removes });\r\n\r\n return (added || removed);\r\n }\r\n\r\n /** Invert the state of a set of Ids in the SelectionSet */\r\n public invert(elem: Id64Arg): boolean {\r\n const elementsToAdd = new Set<string>();\r\n const elementsToRemove = new Set<string>();\r\n for (const id of Id64.iterable(elem)) {\r\n if (this.elements.has(id))\r\n elementsToRemove.add(id);\r\n else\r\n elementsToAdd.add(id);\r\n }\r\n\r\n return this.addAndRemove(elementsToAdd, elementsToRemove);\r\n }\r\n\r\n /** Change selection set to be the supplied set of Ids. */\r\n public replace(elem: Id64Arg): void {\r\n if (areEqual(this.elements, elem))\r\n return;\r\n\r\n const removed = this._elements;\r\n this._elements = new Set<string>();\r\n this._add(elem, false);\r\n\r\n if (0 < removed.size) {\r\n for (const id of Id64.iterable(elem)) {\r\n if (removed.has(id))\r\n removed.delete(id);\r\n }\r\n }\r\n\r\n this.sendChangedEvent({ type: SelectionSetEventType.Replace, set: this, added: elem, removed });\r\n }\r\n}\r\n\r\nfunction areEqual(lhs: Set<string>, rhs: Id64Arg): boolean {\r\n // Size is unreliable if input can contain duplicates...\r\n if (Array.isArray(rhs))\r\n rhs = Id64.toIdSet(rhs);\r\n\r\n if (lhs.size !== Id64.sizeOf(rhs))\r\n return false;\r\n\r\n for (const id of Id64.iterable(rhs))\r\n if (!lhs.has(id))\r\n return false;\r\n\r\n return true;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"SelectionSet.js","sourceRoot":"","sources":["../../src/SelectionSet.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,sDAAyE;AACzE,2CAAwC;AAGxC;;;GAGG;AACH,IAAY,qBASX;AATD,WAAY,qBAAqB;IAC/B,2CAA2C;IAC3C,+DAAG,CAAA;IACH,+CAA+C;IAC/C,qEAAM,CAAA;IACN,6EAA6E;IAC7E,uEAAO,CAAA;IACP,yDAAyD;IACzD,mEAAK,CAAA;AACP,CAAC,EATW,qBAAqB,GAArB,6BAAqB,KAArB,6BAAqB,QAShC;AAyDD;;GAEG;AACH,MAAM,UAAW,SAAQ,mBAAI,CAAC,SAAS;IAIrC,YAAmB,MAAwB;QACzC,KAAK,EAAE,CAAC;QAHA,cAAS,GAAG,KAAK,CAAC;QAI1B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAEe,GAAG,CAAC,GAAW,EAAE,IAAY;QAC3C,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QACrB,IAAI,CAAC,SAAS,EAAE,CAAC;IACnB,CAAC;IAEe,MAAM,CAAC,GAAW,EAAE,IAAY;QAC9C,KAAK,CAAC,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QACxB,IAAI,CAAC,SAAS,EAAE,CAAC;IACnB,CAAC;IAEe,KAAK;QACnB,KAAK,CAAC,KAAK,EAAE,CAAC;QACd,IAAI,CAAC,SAAS,EAAE,CAAC;IACnB,CAAC;IAEe,MAAM,CAAC,GAAY;QACjC,IAAI,CAAC,MAAM,CAAC,GAAG,EAA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gB,CAAC,CAAC;IAC5D,CAAC;IAED,0DAA0D;IACnD,OAAO,CAAC,IAAa;QAC1B,IAAI,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC;YAC/B,OAAO;QAET,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC;QAC/B,IAAI,CAAC,SAAS,GAAG,IAAI,GAAG,EAAU,CAAC;QACnC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAEvB,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,EAAE;YACpB,KAAK,MAAM,EAAE,IAAI,mBAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;gBACpC,IAAI,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;oBACjB,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;aACtB;SACF;QAED,IAAI,CAAC,gBAAgB,CAAC,EAAE,IAAI,EAAE,qBAAqB,CAAC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;IAClG,CAAC;CACF;AA1ID,oCA0IC;AAED,SAAS,QAAQ,CAAC,GAAgB,EAAE,GAAY;IAC9C,wDAAwD;IACxD,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;QACpB,GAAG,GAAG,mBAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAE1B,IAAI,GAAG,CAAC,IAAI,KAAK,mBAAI,CAAC,MAAM,CAAC,GAAG,CAAC;QAC/B,OAAO,KAAK,CAAC;IAEf,KAAK,MAAM,EAAE,IAAI,mBAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;QACjC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YACd,OAAO,KAAK,CAAC;IAEjB,OAAO,IAAI,CAAC;AACd,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 SelectionSet\r\n */\r\nimport { BeEvent, Id64, Id64Arg, Id64String } from \"@itwin/core-bentley\";\r\nimport { IModelApp } from \"./IModelApp\";\r\nimport { IModelConnection } from \"./IModelConnection\";\r\n\r\n/** Identifies the type of changes made to the [[SelectionSet]] to produce a [[SelectionSetEvent]].\r\n * @public\r\n * @extensions\r\n */\r\nexport enum SelectionSetEventType {\r\n /** Elements have been added to the set. */\r\n Add,\r\n /** Elements have been removed from the set. */\r\n Remove,\r\n /** Some elements have been added to the set and others have been removed. */\r\n Replace,\r\n /** All elements are about to be removed from the set. */\r\n Clear,\r\n}\r\n\r\n/** Passed to [[SelectionSet.onChanged]] event listeners when elements are added to the selection set.\r\n * @public\r\n * @extensions\r\n */\r\nexport interface SelectAddEvent {\r\n type: SelectionSetEventType.Add;\r\n /** The Ids of the elements added to the set. */\r\n added: Id64Arg;\r\n /** The affected SelectionSet. */\r\n set: SelectionSet;\r\n}\r\n\r\n/** Passed to [[SelectionSet.onChanged]] event listeners when elements are removed from the selection set.\r\n * @public\r\n * @extensions\r\n */\r\nexport interface SelectRemoveEvent {\r\n /** The type of operation that produced this event. */\r\n type: SelectionSetEventType.Remove | SelectionSetEventType.Clear;\r\n /** The element Ids removed from the set. */\r\n removed: Id64Arg;\r\n /** The affected SelectionSet. */\r\n set: SelectionSet;\r\n}\r\n\r\n/** Passed to [[SelectionSet.onChanged]] event listeners when elements are simultaneously added to and removed from the selection set.\r\n * @public\r\n * @extensions\r\n */\r\nexport interface SelectReplaceEvent {\r\n type: SelectionSetEventType.Replace;\r\n /** The element Ids added to the set. */\r\n added: Id64Arg;\r\n /** The element Ids removed from the set. */\r\n removed: Id64Arg;\r\n /** The affected SelectionSet. */\r\n set: SelectionSet;\r\n}\r\n\r\n/** Payload sent to [[SelectionSet.onChanged]] event listeners to describe how the contents of the set have changed.\r\n * The `type` property of the event serves as a type assertion. For example, the following code will output the added and/or removed Ids:\r\n * ```ts\r\n * processSelectionSetEvent(ev: SelectionSetEvent): void {\r\n * if (SelectionSetEventType.Add === ev.type || SelectionSetEventType.Replace === ev.type)\r\n * console.log(\"Added \" + ev.added.size + \" elements\");\r\n *\r\n * if (SelectionSetEventType.Add !== ev.type)\r\n * console.log(\"Removed \" + ev.removed.size + \" elements\");\r\n * }\r\n * ```\r\n * @public\r\n * @extensions\r\n */\r\nexport type SelectionSetEvent = SelectAddEvent | SelectRemoveEvent | SelectReplaceEvent;\r\n\r\n/** Tracks a set of hilited entities. When the set changes, notifies ViewManager so that symbology overrides can be updated in active Viewports.\r\n * @internal\r\n */\r\nclass HilitedIds extends Id64.Uint32Set {\r\n protected _iModel: IModelConnection;\r\n protected _changing = false;\r\n\r\n public constructor(iModel: IModelConnection) {\r\n super();\r\n this._iModel = iModel;\r\n }\r\n\r\n public override add(low: number, high: number) {\r\n super.add(low, high);\r\n this.onChanged();\r\n }\r\n\r\n public override delete(low: number, high: number) {\r\n super.delete(low, high);\r\n this.onChanged();\r\n }\r\n\r\n public override clear() {\r\n super.clear();\r\n this.onChanged();\r\n }\r\n\r\n public override addIds(ids: Id64Arg) {\r\n this.change(() => super.addIds(ids));\r\n }\r\n\r\n public override deleteIds(ids: Id64Arg) {\r\n this.change(() => super.deleteIds(ids));\r\n }\r\n\r\n protected onChanged() {\r\n if (!this._changing)\r\n IModelApp.viewManager.onSelectionSetChanged(this._iModel);\r\n }\r\n\r\n protected change(func: () => void) {\r\n const changing = this._changing;\r\n this._changing = false;\r\n func();\r\n this._changing = changing;\r\n this.onChanged();\r\n }\r\n}\r\n\r\n/** Keeps the set of hilited elements in sync with the selection set.\r\n * @internal\r\n */\r\nclass HilitedElementIds extends HilitedIds {\r\n private _removeListener?: () => void;\r\n\r\n public constructor(iModel: IModelConnection, syncWithSelectionSet = true) {\r\n super(iModel);\r\n this.wantSyncWithSelectionSet = syncWithSelectionSet;\r\n }\r\n\r\n public get wantSyncWithSelectionSet(): boolean { return undefined !== this._removeListener; }\r\n public set wantSyncWithSelectionSet(want: boolean) {\r\n if (want === this.wantSyncWithSelectionSet)\r\n return;\r\n\r\n if (want) {\r\n const set = this._iModel.selectionSet;\r\n this._removeListener = set.onChanged.addListener((ev) => this.change(() => this.processSelectionSetEvent(ev)));\r\n this.processSelectionSetEvent({\r\n set,\r\n type: SelectionSetEventType.Add,\r\n added: set.elements,\r\n });\r\n } else {\r\n this._removeListener!();\r\n this._removeListener = undefined;\r\n }\r\n }\r\n\r\n private processSelectionSetEvent(ev: SelectionSetEvent): void {\r\n if (SelectionSetEventType.Add !== ev.type)\r\n this.deleteIds(ev.removed);\r\n\r\n if (ev.type === SelectionSetEventType.Add || ev.type === SelectionSetEventType.Replace)\r\n this.addIds(ev.added);\r\n }\r\n}\r\n\r\n/** Describes how the sets of hilited models and subcategories in a [[HiliteSet]] interact.\r\n * - \"union\" indicates a [Feature]($common) will be hilited if either its model **or** its subcategory is present in the HiliteSet.\r\n * - \"intersection\" indicates a [Feature]($common) will be hilited only if both its model **and** its subcategory are present in the HiliteSet.\r\n *\r\n * @see [[HiliteSet.modelSubCategoryMode]] to change the mode for a HiliteSet.\r\n * @public\r\n */\r\nexport type ModelSubCategoryHiliteMode = \"union\" | \"intersection\";\r\n\r\n/** A set of *hilited* elements for an [[IModelConnection]], by element id.\r\n * Hilited elements are displayed with a customizable hilite effect within a [[Viewport]].\r\n * The set exposes 3 types of elements in 3 separate collections: [GeometricElement]($backend), [GeometricModel]($backend), and [SubCategory]($backend).\r\n * The [[models]] and [[subcategories]] can be hilited independently or as an intersection of the two sets, as specified by [[modelSubCategoryMode]].\r\n *\r\n * Technically, the hilite effect is applied to [Feature]($common)s, not [Element]($backend)s. An element's geometry stream can contain multiple\r\n * features belonging to different subcategories.\r\n *\r\n * Because Javascript lacks efficient support for 64-bit integers, the Ids are stored as pairs of 32-bit integers via [Id64.Uint32Set]($bentley).\r\n *\r\n * @note Typically, elements are hilited by virtue of their presence in the IModelConnection's [[SelectionSet]]. The HiliteSet allows additional\r\n * elements to be displayed with the hilite effect without adding them to the [[SelectionSet]]. If you add elements to the HiliteSet directly, you\r\n * are also responsible for removing them as appropriate.\r\n * @see [[IModelConnection.hilited]] for the HiliteSet associated with an iModel.\r\n * @see [Hilite.Settings]($common) for customization of the hilite effect.\r\n * @public\r\n * @extensions\r\n */\r\nexport class HiliteSet {\r\n private readonly _elements: HilitedElementIds;\r\n private _mode: ModelSubCategoryHiliteMode = \"union\";\r\n\r\n /** The set of hilited subcategories.\r\n * @see [[modelSubCategoryMode]] to control how this set interacts with the set of hilited [[models]].\r\n * @see [[IModelConnection.Categories]] to obtain the set of subcategories associated with one or more [Category]($backend)'s.\r\n */\r\n public readonly subcategories: Id64.Uint32Set;\r\n\r\n /** The set of hilited [[GeometricModelState]]s.\r\n * @see [[modelSubCategoryMode]] to control how this set interacts with the set of hilited [[subcategories]].\r\n */\r\n public readonly models: Id64.Uint32Set;\r\n\r\n /** The set of hilited elements. */\r\n public get elements(): Id64.Uint32Set { return this._elements; }\r\n\r\n /** Controls how the sets of hilited [[models]] and [[subcategories]] interact with one another.\r\n * By default they are treated as a union: a [Feature]($common) is hilited if either its model **or** its subcategory is hilited.\r\n * This can be changed to an intersection such that a [Feature]($common) is hilited only if both its model **and** subcategory are hilited.\r\n * @note The sets of hilited models and subcategories are independent of the set of hilited [[elements]] - an element whose Id is present in\r\n * [[elements]] is always hilited regardless of its model or subcategories.\r\n */\r\n public get modelSubCategoryMode(): ModelSubCategoryHiliteMode {\r\n return this._mode;\r\n }\r\n public set modelSubCategoryMode(mode: ModelSubCategoryHiliteMode) {\r\n if (mode === this._mode)\r\n return;\r\n\r\n this.onModelSubCategoryModeChanged.raiseEvent(mode);\r\n this._mode = mode;\r\n }\r\n\r\n /** Event raised just before changing the value of [[modelSubCategoryMode]]. */\r\n public readonly onModelSubCategoryModeChanged = new BeEvent<(newMode: ModelSubCategoryHiliteMode) => void>();\r\n\r\n /** Construct a HiliteSet\r\n * @param iModel The iModel containing the entities to be hilited.\r\n * @param syncWithSelectionSet If true, the contents of the `elements` set will be synchronized with those in the `iModel`'s [[SelectionSet]].\r\n * @internal\r\n */\r\n public constructor(public iModel: IModelConnection, syncWithSelectionSet = true) {\r\n this._elements = new HilitedElementIds(iModel, syncWithSelectionSet);\r\n this.subcategories = new HilitedIds(iModel);\r\n this.models = new HilitedIds(iModel);\r\n }\r\n\r\n /** Control whether the hilited elements will be synchronized with the contents of the [[SelectionSet]].\r\n * By default they are synchronized. Applications that override this take responsibility for managing the set of hilited entities.\r\n * When turning synchronization off, the contents of the HiliteSet will remain unchanged.\r\n * When turning synchronization on, the current contents of the HiliteSet will be preserved, and the contents of the selection set will be added to them.\r\n */\r\n public get wantSyncWithSelectionSet(): boolean { return this._elements.wantSyncWithSelectionSet; }\r\n public set wantSyncWithSelectionSet(want: boolean) { this._elements.wantSyncWithSelectionSet = want; }\r\n\r\n /** Remove all elements from the hilited set. */\r\n public clear() {\r\n this.elements.clear();\r\n this.subcategories.clear();\r\n this.models.clear();\r\n }\r\n\r\n /** Returns true if nothing is hilited. */\r\n public get isEmpty(): boolean { return this.elements.isEmpty && this.subcategories.isEmpty && this.models.isEmpty; }\r\n\r\n /** Toggle the hilited state of one or more elements.\r\n * @param arg the ID(s) of the elements whose state is to be toggled.\r\n * @param onOff True to add the elements to the hilited set, false to remove them.\r\n */\r\n public setHilite(arg: Id64Arg, onOff: boolean): void {\r\n const oldSize = this.elements.size;\r\n\r\n for (const id of Id64.iterable(arg)) {\r\n if (onOff)\r\n this.elements.addId(id);\r\n else\r\n this.elements.deleteId(id);\r\n }\r\n\r\n if (oldSize !== this.elements.size)\r\n IModelApp.viewManager.onSelectionSetChanged(this.iModel);\r\n }\r\n}\r\n\r\n/** A set of *currently selected* elements for an IModelConnection.\r\n * Selected elements are displayed with a customizable hilite effect within a [[Viewport]].\r\n * @see [Hilite.Settings]($common) for customization of the hilite effect.\r\n * @public\r\n * @extensions\r\n */\r\nexport class SelectionSet {\r\n private _elements = new Set<string>();\r\n\r\n /** The IDs of the selected elements.\r\n * @note Do not modify this set directly. Instead, use methods like [[SelectionSet.add]].\r\n */\r\n public get elements(): Set<string> { return this._elements; }\r\n\r\n /** Called whenever elements are added or removed from this SelectionSet */\r\n public readonly onChanged = new BeEvent<(ev: SelectionSetEvent) => void>();\r\n\r\n public constructor(public iModel: IModelConnection) { }\r\n\r\n private sendChangedEvent(ev: SelectionSetEvent) {\r\n IModelApp.viewManager.onSelectionSetChanged(this.iModel);\r\n this.onChanged.raiseEvent(ev);\r\n }\r\n\r\n /** Get the number of entries in this selection set. */\r\n public get size() { return this.elements.size; }\r\n\r\n /** Check whether there are any selected elements. */\r\n public get isActive() { return this.size !== 0; }\r\n\r\n /** Return true if elemId is in this SelectionSet.\r\n * @see [[isSelected]]\r\n */\r\n public has(elemId?: string) { return !!elemId && this.elements.has(elemId); }\r\n\r\n /** Query whether an Id is in the selection set.\r\n * @see [[has]]\r\n */\r\n public isSelected(elemId?: Id64String): boolean { return !!elemId && this.elements.has(elemId); }\r\n\r\n /** Clear current selection set.\r\n * @note raises the [[onChanged]] event with [[SelectionSetEventType.Clear]].\r\n */\r\n public emptyAll(): void {\r\n if (!this.isActive)\r\n return;\r\n\r\n const removed = this._elements;\r\n this._elements = new Set<string>();\r\n this.sendChangedEvent({ set: this, type: SelectionSetEventType.Clear, removed });\r\n }\r\n\r\n /**\r\n * Add one or more Ids to the current selection set.\r\n * @param elem The set of Ids to add.\r\n * @returns true if any elements were added.\r\n */\r\n public add(elem: Id64Arg): boolean {\r\n return this._add(elem);\r\n }\r\n\r\n private _add(elem: Id64Arg, sendEvent = true): boolean {\r\n const oldSize = this.elements.size;\r\n for (const id of Id64.iterable(elem))\r\n this.elements.add(id);\r\n\r\n const changed = oldSize !== this.elements.size;\r\n if (sendEvent && changed)\r\n this.sendChangedEvent({ type: SelectionSetEventType.Add, set: this, added: elem });\r\n\r\n return changed;\r\n }\r\n\r\n /**\r\n * Remove one or more Ids from the current selection set.\r\n * @param elem The set of Ids to remove.\r\n * @returns true if any elements were removed.\r\n */\r\n public remove(elem: Id64Arg): boolean {\r\n return this._remove(elem);\r\n }\r\n\r\n private _remove(elem: Id64Arg, sendEvent = true): boolean {\r\n const oldSize = this.elements.size;\r\n for (const id of Id64.iterable(elem))\r\n this.elements.delete(id);\r\n\r\n const changed = oldSize !== this.elements.size;\r\n if (sendEvent && changed)\r\n this.sendChangedEvent({ type: SelectionSetEventType.Remove, set: this, removed: elem });\r\n\r\n return changed;\r\n }\r\n\r\n /**\r\n * Add one set of Ids, and remove another set of Ids. Any Ids that are in both sets are removed.\r\n * @returns True if any Ids were either added or removed.\r\n */\r\n public addAndRemove(adds: Id64Arg, removes: Id64Arg): boolean {\r\n const added = this._add(adds, false);\r\n const removed = this._remove(removes, false);\r\n\r\n if (added && removed)\r\n this.sendChangedEvent({ type: SelectionSetEventType.Replace, set: this, added: adds, removed: removes });\r\n else if (added)\r\n this.sendChangedEvent({ type: SelectionSetEventType.Add, set: this, added: adds });\r\n else if (removed)\r\n this.sendChangedEvent({ type: SelectionSetEventType.Remove, set: this, removed: removes });\r\n\r\n return (added || removed);\r\n }\r\n\r\n /** Invert the state of a set of Ids in the SelectionSet */\r\n public invert(elem: Id64Arg): boolean {\r\n const elementsToAdd = new Set<string>();\r\n const elementsToRemove = new Set<string>();\r\n for (const id of Id64.iterable(elem)) {\r\n if (this.elements.has(id))\r\n elementsToRemove.add(id);\r\n else\r\n elementsToAdd.add(id);\r\n }\r\n\r\n return this.addAndRemove(elementsToAdd, elementsToRemove);\r\n }\r\n\r\n /** Change selection set to be the supplied set of Ids. */\r\n public replace(elem: Id64Arg): void {\r\n if (areEqual(this.elements, elem))\r\n return;\r\n\r\n const removed = this._elements;\r\n this._elements = new Set<string>();\r\n this._add(elem, false);\r\n\r\n if (0 < removed.size) {\r\n for (const id of Id64.iterable(elem)) {\r\n if (removed.has(id))\r\n removed.delete(id);\r\n }\r\n }\r\n\r\n this.sendChangedEvent({ type: SelectionSetEventType.Replace, set: this, added: elem, removed });\r\n }\r\n}\r\n\r\nfunction areEqual(lhs: Set<string>, rhs: Id64Arg): boolean {\r\n // Size is unreliable if input can contain duplicates...\r\n if (Array.isArray(rhs))\r\n rhs = Id64.toIdSet(rhs);\r\n\r\n if (lhs.size !== Id64.sizeOf(rhs))\r\n return false;\r\n\r\n for (const id of Id64.iterable(rhs))\r\n if (!lhs.has(id))\r\n return false;\r\n\r\n return true;\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GraphicalEditingScope.d.ts","sourceRoot":"","sources":["../../src/GraphicalEditingScope.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAU,OAAO,
|
|
1
|
+
{"version":3,"file":"GraphicalEditingScope.d.ts","sourceRoot":"","sources":["../../src/GraphicalEditingScope.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAU,OAAO,EAAkE,UAAU,EAAe,MAAM,qBAAqB,CAAC;AAE/I,OAAO,EACL,yBAAyB,EAAE,qBAAqB,EAAE,aAAa,EAAE,oBAAoB,EAAE,yBAAyB,EACjH,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAc5D;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBAAa,qBAAsB,SAAQ,4BAA6B,YAAW,yBAAyB;IAC1G,IAAW,oBAAoB,kBAAyC;IAExE,8FAA8F;IAC9F,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAuC;IACxE,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,CAAiB;IAElC,iDAAiD;IACjD,SAAgB,MAAM,EAAE,mBAAmB,CAAC;IAE5C;;OAEG;IACH,gBAAuB,OAAO,kBAAuB,qBAAqB,KAAK,IAAI,EAAI;IAEvF;;;OAGG;IACH,SAAgB,SAAS,kBAAuB,qBAAqB,KAAK,IAAI,EAAI;IAElF;;;OAGG;IACH,SAAgB,QAAQ,kBAAuB,qBAAqB,KAAK,IAAI,EAAI;IAEjF,sEAAsE;IACtE,SAAgB,iBAAiB,oBAAyB,SAAS,oBAAoB,CAAC,SAAS,qBAAqB,KAAK,IAAI,EAAI;IAEnI;;OAEG;WACiB,KAAK,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAmBtF;;;OAGG;IACU,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAkBlC,yGAAyG;IAClG,0BAA0B,CAAC,OAAO,EAAE,UAAU,GAAG,QAAQ,CAAC,qBAAqB,CAAC,GAAG,SAAS;IAInG,4EAA4E;IACrE,kBAAkB,IAAI,QAAQ,CAAC,oBAAoB,CAAC;IAI3D,gBAAgB;IAChB,IAAW,UAAU,YAEpB;IAED,OAAO,CAAG,sBAAsB;IAWhC,OAAO;IAMP,OAAO,CAAC,OAAO;IAef,gBAAgB;IACT,qBAAqB,CAAC,KAAK,EAAE,yBAAyB,EAAE;CAiChE"}
|
|
@@ -142,6 +142,7 @@ export class GraphicalEditingScope extends BriefcaseNotificationHandler {
|
|
|
142
142
|
notifyGeometryChanged(props) {
|
|
143
143
|
const changes = ModelGeometryChanges.iterable(props);
|
|
144
144
|
const modelIds = [];
|
|
145
|
+
let deletedIds;
|
|
145
146
|
for (const modelChanges of changes) {
|
|
146
147
|
// ###TODO do we care about the model range?
|
|
147
148
|
let list = this._geometryChanges.get(modelChanges.id);
|
|
@@ -156,11 +157,16 @@ export class GraphicalEditingScope extends BriefcaseNotificationHandler {
|
|
|
156
157
|
}
|
|
157
158
|
list.insert(elementChange);
|
|
158
159
|
if (DbOpcode.Delete === elementChange.type) {
|
|
159
|
-
|
|
160
|
-
|
|
160
|
+
if (undefined === deletedIds)
|
|
161
|
+
deletedIds = new Set();
|
|
162
|
+
deletedIds.add(elementChange.id);
|
|
161
163
|
}
|
|
162
164
|
}
|
|
163
165
|
}
|
|
166
|
+
if (deletedIds) {
|
|
167
|
+
this.iModel.selectionSet.remove(deletedIds);
|
|
168
|
+
this.iModel.hilited.setHilite(deletedIds, false);
|
|
169
|
+
}
|
|
164
170
|
this.onGeometryChanges.raiseEvent(changes, this);
|
|
165
171
|
}
|
|
166
172
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GraphicalEditingScope.js","sourceRoot":"","sources":["../../src/GraphicalEditingScope.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,eAAe,EAA0B,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEtI,OAAO,EAC6C,aAAa,EAAE,oBAAoB,GACtF,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAE/D,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,YAAa,SAAQ,WAAkC;IAI3D,YAAmB,YAAwB,EAAE,KAAc;QACzD,KAAK,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE,CAAC,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC;QAC7E,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,OAAO,qBAAsB,SAAQ,4BAA4B;IAqGrE,YAAoB,MAA2B;QAC7C,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAnGpB,8FAA8F;QAC7E,qBAAgB,GAAG,IAAI,GAAG,EAA4B,CAAC;QAChE,cA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OAAO,EAAE,IAAI,CAAC,CAAC;IACnD,CAAC;;AAxID;;GAEG;AACoB,6BAAO,GAAG,IAAI,OAAO,EAA0C,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 IModelConnection\r\n */\r\n\r\nimport { assert, BeEvent, compareStrings, DbOpcode, DuplicatePolicy, GuidString, Id64String, SortedArray } from \"@itwin/core-bentley\";\r\nimport { Range3d } from \"@itwin/core-geometry\";\r\nimport {\r\n EditingScopeNotifications, ElementGeometryChange, IpcAppChannel, ModelGeometryChanges, ModelGeometryChangesProps, RemoveFunction,\r\n} from \"@itwin/core-common\";\r\nimport { BriefcaseNotificationHandler } from \"./BriefcaseTxns\";\r\nimport { BriefcaseConnection } from \"./BriefcaseConnection\";\r\nimport { IpcApp } from \"./IpcApp\";\r\n\r\nclass ModelChanges extends SortedArray<ElementGeometryChange> {\r\n public geometryGuid: GuidString;\r\n public readonly range: Range3d;\r\n\r\n public constructor(geometryGuid: GuidString, range: Range3d) {\r\n super((lhs, rhs) => compareStrings(lhs.id, rhs.id), DuplicatePolicy.Replace);\r\n this.geometryGuid = geometryGuid;\r\n this.range = range;\r\n }\r\n}\r\n\r\n/** Represents a period of time within an [interactive editing]($docs/learning/InteractiveEditing.md) session during which the\r\n * geometry of elements being displayed in one or more [[Viewport]]s is being modified. Outside of such a scope, whenever the\r\n * geometry within a [GeometricModel]($backend) changes new [[Tile]]s must be generated to reflect those changes in a viewport.\r\n * Regenerating entire tiles each time individual elements change can be time-consuming, which may introduce an unacceptable delay\r\n * between making a modification and seeing its result on the screen.\r\n *\r\n * Within the context of a graphical editing scope, no new tiles are generated. Instead, the geometry for any deleted or modified elements\r\n * is hidden in the tile graphics, and additional temporary graphics are displayed for any newly-inserted or modified elements. Only when the\r\n * scope exits are new tiles produced.\r\n *\r\n * The application decides when to enter and exit a graphical editing scope. A single interactive editing session may involve any number of\r\n * editing scopes. Typically, applications will enter a new editing scope (after first exiting a previous scope, if one exists):\r\n * - When switching from a non-graphical workflow to one that involves editing geometry; or\r\n * - When changing which geometric model is being edited; or\r\n * - After performing an operation that creates or modifies a \"large\" number (perhaps hundreds?) of elements.\r\n *\r\n * An application should typically exit any graphical editing scope before:\r\n * - Pulling changesets; or\r\n * - Switching from a graphical editing workflow to some non-graphical workflow.\r\n *\r\n * Graphical editing scopes are only supported for [[BriefcaseConnection]]s opened in read-write mode that contain version 1.0.11 or newer of the BisCore schema.\r\n * @see [[BriefcaseConnection.enterEditingScope]] to create a scope for a briefcase.\r\n * @see [[BriefcaseConnection.editingScope]] to obtain a briefcase's current scope.\r\n * @see [[exit]] to terminate a scope.\r\n * @public\r\n */\r\nexport class GraphicalEditingScope extends BriefcaseNotificationHandler implements EditingScopeNotifications {\r\n public get briefcaseChannelName() { return IpcAppChannel.EditingScope; }\r\n\r\n /** Maps model Id to accumulated changes to geometric elements within the associated model. */\r\n private readonly _geometryChanges = new Map<Id64String, ModelChanges>();\r\n private _disposed = false;\r\n private _cleanup?: RemoveFunction;\r\n\r\n /** The connection to the iModel being edited. */\r\n public readonly iModel: BriefcaseConnection;\r\n\r\n /** Event raised when a new scope is created for any [[BriefcaseConnection]].\r\n * @see [[onExiting]] and [[onExited]] for complementary events.\r\n */\r\n public static readonly onEnter = new BeEvent<(scope: GraphicalEditingScope) => void>();\r\n\r\n /** Event raised when this scope is about to exit.\r\n * @see [[onEnter]] for the complementary event.\r\n * @see [[onExited]] for an event raised after the scope exits.\r\n */\r\n public readonly onExiting = new BeEvent<(scope: GraphicalEditingScope) => void>();\r\n\r\n /** Event raised when this scope has exited.\r\n * @see [[onEnter]] for the complementary event.\r\n * @see [[onExiting]] for an event raised just before the scope is exited.\r\n */\r\n public readonly onExited = new BeEvent<(scope: GraphicalEditingScope) => void>();\r\n\r\n /** Event raised after geometric changes are written to the iModel. */\r\n public readonly onGeometryChanges = new BeEvent<(changes: Iterable<ModelGeometryChanges>, scope: GraphicalEditingScope) => void>();\r\n\r\n /** Don't call this directly - use BriefcaseConnection.enterEditingScope.\r\n * @internal\r\n */\r\n public static async enter(imodel: BriefcaseConnection): Promise<GraphicalEditingScope> {\r\n if (imodel.editingScope)\r\n throw new Error(\"Cannot create an editing scope for an iModel that already has one\");\r\n\r\n // Register the scope synchronously, in case enter() is called again for same iModel while awaiting asynchronous initialization.\r\n const scope = new GraphicalEditingScope(imodel);\r\n try {\r\n const scopeStarted = await IpcApp.appFunctionIpc.toggleGraphicalEditingScope(imodel.key, true);\r\n assert(scopeStarted); // If it didn't, the backend threw an error.\r\n } catch (e) {\r\n scope.dispose();\r\n throw e;\r\n }\r\n\r\n this.onEnter.raiseEvent(scope);\r\n\r\n return scope;\r\n }\r\n\r\n /** Exits this editing scope. The associated [[BriefcaseConnection]]'s `editingScope` will be reset to `undefined`.\r\n * @throws Error if the scope could not be exited, e.g., if it has already been exited.\r\n * @see [[BriefcaseConnection.enterEditingScope]] to enter an editing scope.\r\n */\r\n public async exit(): Promise<void> {\r\n if (this._disposed || this.iModel.editingScope !== this)\r\n throw new Error(\"Cannot exit editing scope after it is disconnected from the iModel\");\r\n\r\n this._disposed = true;\r\n try {\r\n this.onExiting.raiseEvent(this);\r\n } finally {\r\n const scopeExited = await IpcApp.appFunctionIpc.toggleGraphicalEditingScope(this.iModel.key, false);\r\n assert(!scopeExited);\r\n try {\r\n this.onExited.raiseEvent(this);\r\n } finally {\r\n this.dispose();\r\n }\r\n }\r\n }\r\n\r\n /** Obtain all geometric changes to elements within the specified model accumulated within this scope. */\r\n public getGeometryChangesForModel(modelId: Id64String): Iterable<ElementGeometryChange> | undefined {\r\n return this._geometryChanges.get(modelId);\r\n }\r\n\r\n /** Obtain all geometric changes to models accumulated within this scope. */\r\n public getGeometryChanges(): Iterable<ModelGeometryChanges> {\r\n return { [Symbol.iterator]: () => this.geometryChangeIterator() };\r\n }\r\n\r\n /** @internal */\r\n public get isDisposed() {\r\n return this._disposed;\r\n }\r\n\r\n private * geometryChangeIterator(): Iterator<ModelGeometryChanges> {\r\n for (const [key, value] of this._geometryChanges) {\r\n yield {\r\n id: key,\r\n geometryGuid: value.geometryGuid,\r\n range: value.range,\r\n elements: value,\r\n };\r\n }\r\n }\r\n\r\n private constructor(iModel: BriefcaseConnection) {\r\n super(iModel.key);\r\n this.iModel = iModel;\r\n this._cleanup = this.registerImpl();\r\n }\r\n\r\n private dispose(): void {\r\n this._disposed = true;\r\n\r\n this.onExiting.clear();\r\n this.onGeometryChanges.clear();\r\n this.onExited.clear();\r\n\r\n this._geometryChanges.clear();\r\n\r\n if (this._cleanup) {\r\n this._cleanup();\r\n this._cleanup = undefined;\r\n }\r\n }\r\n\r\n /** @internal */\r\n public notifyGeometryChanged(props: ModelGeometryChangesProps[]) {\r\n const changes = ModelGeometryChanges.iterable(props);\r\n const modelIds: Id64String[] = [];\r\n for (const modelChanges of changes) {\r\n // ###TODO do we care about the model range?\r\n let list = this._geometryChanges.get(modelChanges.id);\r\n modelIds.push(modelChanges.id);\r\n for (const elementChange of modelChanges.elements) {\r\n if (!list) {\r\n this._geometryChanges.set(modelChanges.id, list = new ModelChanges(modelChanges.geometryGuid, modelChanges.range));\r\n } else {\r\n list.geometryGuid = modelChanges.geometryGuid;\r\n modelChanges.range.clone(list.range);\r\n }\r\n\r\n list.insert(elementChange);\r\n if (DbOpcode.Delete === elementChange.type) {\r\n this.iModel.selectionSet.remove(elementChange.id);\r\n this.iModel.hilited.setHilite(elementChange.id, false);\r\n }\r\n }\r\n }\r\n\r\n this.onGeometryChanges.raiseEvent(changes, this);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"GraphicalEditingScope.js","sourceRoot":"","sources":["../../src/GraphicalEditingScope.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,EAA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,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;YAC/B,KAAK,MAAM,aAAa,IAAI,YAAY,CAAC,QAAQ,EAAE;gBACjD,IAAI,CAAC,IAAI,EAAE;oBACT,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,EAAE,IAAI,GAAG,IAAI,YAAY,CAAC,YAAY,CAAC,YAAY,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;iBACpH;qBAAM;oBACL,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC,YAAY,CAAC;oBAC9C,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;iBACtC;gBAED,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;gBAC3B,IAAI,QAAQ,CAAC,MAAM,KAAK,aAAa,CAAC,IAAI,EAAE;oBAC1C,IAAI,SAAS,KAAK,UAAU;wBAC1B,UAAU,GAAG,IAAI,GAAG,EAAc,CAAC;oBACrC,UAAU,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;iBAClC;aACF;SACF;QAED,IAAI,UAAU,EAAE;YACd,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;YAC5C,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;SAClD;QAED,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACnD,CAAC;;AAhJD;;GAEG;AACoB,6BAAO,GAAG,IAAI,OAAO,EAA0C,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 IModelConnection\r\n */\r\n\r\nimport { assert, BeEvent, compareStrings, DbOpcode, DuplicatePolicy, GuidString, Id64Set, Id64String, SortedArray } from \"@itwin/core-bentley\";\r\nimport { Range3d } from \"@itwin/core-geometry\";\r\nimport {\r\n EditingScopeNotifications, ElementGeometryChange, IpcAppChannel, ModelGeometryChanges, ModelGeometryChangesProps, RemoveFunction,\r\n} from \"@itwin/core-common\";\r\nimport { BriefcaseNotificationHandler } from \"./BriefcaseTxns\";\r\nimport { BriefcaseConnection } from \"./BriefcaseConnection\";\r\nimport { IpcApp } from \"./IpcApp\";\r\n\r\nclass ModelChanges extends SortedArray<ElementGeometryChange> {\r\n public geometryGuid: GuidString;\r\n public readonly range: Range3d;\r\n\r\n public constructor(geometryGuid: GuidString, range: Range3d) {\r\n super((lhs, rhs) => compareStrings(lhs.id, rhs.id), DuplicatePolicy.Replace);\r\n this.geometryGuid = geometryGuid;\r\n this.range = range;\r\n }\r\n}\r\n\r\n/** Represents a period of time within an [interactive editing]($docs/learning/InteractiveEditing.md) session during which the\r\n * geometry of elements being displayed in one or more [[Viewport]]s is being modified. Outside of such a scope, whenever the\r\n * geometry within a [GeometricModel]($backend) changes new [[Tile]]s must be generated to reflect those changes in a viewport.\r\n * Regenerating entire tiles each time individual elements change can be time-consuming, which may introduce an unacceptable delay\r\n * between making a modification and seeing its result on the screen.\r\n *\r\n * Within the context of a graphical editing scope, no new tiles are generated. Instead, the geometry for any deleted or modified elements\r\n * is hidden in the tile graphics, and additional temporary graphics are displayed for any newly-inserted or modified elements. Only when the\r\n * scope exits are new tiles produced.\r\n *\r\n * The application decides when to enter and exit a graphical editing scope. A single interactive editing session may involve any number of\r\n * editing scopes. Typically, applications will enter a new editing scope (after first exiting a previous scope, if one exists):\r\n * - When switching from a non-graphical workflow to one that involves editing geometry; or\r\n * - When changing which geometric model is being edited; or\r\n * - After performing an operation that creates or modifies a \"large\" number (perhaps hundreds?) of elements.\r\n *\r\n * An application should typically exit any graphical editing scope before:\r\n * - Pulling changesets; or\r\n * - Switching from a graphical editing workflow to some non-graphical workflow.\r\n *\r\n * Graphical editing scopes are only supported for [[BriefcaseConnection]]s opened in read-write mode that contain version 1.0.11 or newer of the BisCore schema.\r\n * @see [[BriefcaseConnection.enterEditingScope]] to create a scope for a briefcase.\r\n * @see [[BriefcaseConnection.editingScope]] to obtain a briefcase's current scope.\r\n * @see [[exit]] to terminate a scope.\r\n * @public\r\n */\r\nexport class GraphicalEditingScope extends BriefcaseNotificationHandler implements EditingScopeNotifications {\r\n public get briefcaseChannelName() { return IpcAppChannel.EditingScope; }\r\n\r\n /** Maps model Id to accumulated changes to geometric elements within the associated model. */\r\n private readonly _geometryChanges = new Map<Id64String, ModelChanges>();\r\n private _disposed = false;\r\n private _cleanup?: RemoveFunction;\r\n\r\n /** The connection to the iModel being edited. */\r\n public readonly iModel: BriefcaseConnection;\r\n\r\n /** Event raised when a new scope is created for any [[BriefcaseConnection]].\r\n * @see [[onExiting]] and [[onExited]] for complementary events.\r\n */\r\n public static readonly onEnter = new BeEvent<(scope: GraphicalEditingScope) => void>();\r\n\r\n /** Event raised when this scope is about to exit.\r\n * @see [[onEnter]] for the complementary event.\r\n * @see [[onExited]] for an event raised after the scope exits.\r\n */\r\n public readonly onExiting = new BeEvent<(scope: GraphicalEditingScope) => void>();\r\n\r\n /** Event raised when this scope has exited.\r\n * @see [[onEnter]] for the complementary event.\r\n * @see [[onExiting]] for an event raised just before the scope is exited.\r\n */\r\n public readonly onExited = new BeEvent<(scope: GraphicalEditingScope) => void>();\r\n\r\n /** Event raised after geometric changes are written to the iModel. */\r\n public readonly onGeometryChanges = new BeEvent<(changes: Iterable<ModelGeometryChanges>, scope: GraphicalEditingScope) => void>();\r\n\r\n /** Don't call this directly - use BriefcaseConnection.enterEditingScope.\r\n * @internal\r\n */\r\n public static async enter(imodel: BriefcaseConnection): Promise<GraphicalEditingScope> {\r\n if (imodel.editingScope)\r\n throw new Error(\"Cannot create an editing scope for an iModel that already has one\");\r\n\r\n // Register the scope synchronously, in case enter() is called again for same iModel while awaiting asynchronous initialization.\r\n const scope = new GraphicalEditingScope(imodel);\r\n try {\r\n const scopeStarted = await IpcApp.appFunctionIpc.toggleGraphicalEditingScope(imodel.key, true);\r\n assert(scopeStarted); // If it didn't, the backend threw an error.\r\n } catch (e) {\r\n scope.dispose();\r\n throw e;\r\n }\r\n\r\n this.onEnter.raiseEvent(scope);\r\n\r\n return scope;\r\n }\r\n\r\n /** Exits this editing scope. The associated [[BriefcaseConnection]]'s `editingScope` will be reset to `undefined`.\r\n * @throws Error if the scope could not be exited, e.g., if it has already been exited.\r\n * @see [[BriefcaseConnection.enterEditingScope]] to enter an editing scope.\r\n */\r\n public async exit(): Promise<void> {\r\n if (this._disposed || this.iModel.editingScope !== this)\r\n throw new Error(\"Cannot exit editing scope after it is disconnected from the iModel\");\r\n\r\n this._disposed = true;\r\n try {\r\n this.onExiting.raiseEvent(this);\r\n } finally {\r\n const scopeExited = await IpcApp.appFunctionIpc.toggleGraphicalEditingScope(this.iModel.key, false);\r\n assert(!scopeExited);\r\n try {\r\n this.onExited.raiseEvent(this);\r\n } finally {\r\n this.dispose();\r\n }\r\n }\r\n }\r\n\r\n /** Obtain all geometric changes to elements within the specified model accumulated within this scope. */\r\n public getGeometryChangesForModel(modelId: Id64String): Iterable<ElementGeometryChange> | undefined {\r\n return this._geometryChanges.get(modelId);\r\n }\r\n\r\n /** Obtain all geometric changes to models accumulated within this scope. */\r\n public getGeometryChanges(): Iterable<ModelGeometryChanges> {\r\n return { [Symbol.iterator]: () => this.geometryChangeIterator() };\r\n }\r\n\r\n /** @internal */\r\n public get isDisposed() {\r\n return this._disposed;\r\n }\r\n\r\n private * geometryChangeIterator(): Iterator<ModelGeometryChanges> {\r\n for (const [key, value] of this._geometryChanges) {\r\n yield {\r\n id: key,\r\n geometryGuid: value.geometryGuid,\r\n range: value.range,\r\n elements: value,\r\n };\r\n }\r\n }\r\n\r\n private constructor(iModel: BriefcaseConnection) {\r\n super(iModel.key);\r\n this.iModel = iModel;\r\n this._cleanup = this.registerImpl();\r\n }\r\n\r\n private dispose(): void {\r\n this._disposed = true;\r\n\r\n this.onExiting.clear();\r\n this.onGeometryChanges.clear();\r\n this.onExited.clear();\r\n\r\n this._geometryChanges.clear();\r\n\r\n if (this._cleanup) {\r\n this._cleanup();\r\n this._cleanup = undefined;\r\n }\r\n }\r\n\r\n /** @internal */\r\n public notifyGeometryChanged(props: ModelGeometryChangesProps[]) {\r\n const changes = ModelGeometryChanges.iterable(props);\r\n const modelIds: Id64String[] = [];\r\n let deletedIds: Id64Set | undefined;\r\n\r\n for (const modelChanges of changes) {\r\n // ###TODO do we care about the model range?\r\n let list = this._geometryChanges.get(modelChanges.id);\r\n modelIds.push(modelChanges.id);\r\n for (const elementChange of modelChanges.elements) {\r\n if (!list) {\r\n this._geometryChanges.set(modelChanges.id, list = new ModelChanges(modelChanges.geometryGuid, modelChanges.range));\r\n } else {\r\n list.geometryGuid = modelChanges.geometryGuid;\r\n modelChanges.range.clone(list.range);\r\n }\r\n\r\n list.insert(elementChange);\r\n if (DbOpcode.Delete === elementChange.type) {\r\n if (undefined === deletedIds)\r\n deletedIds = new Set<Id64String>();\r\n deletedIds.add(elementChange.id);\r\n }\r\n }\r\n }\r\n\r\n if (deletedIds) {\r\n this.iModel.selectionSet.remove(deletedIds);\r\n this.iModel.hilited.setHilite(deletedIds, false);\r\n }\r\n\r\n this.onGeometryChanges.raiseEvent(changes, this);\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectionSet.d.ts","sourceRoot":"","sources":["../../src/SelectionSet.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD;;;GAGG;AACH,oBAAY,qBAAqB;IAC/B,2CAA2C;IAC3C,GAAG,IAA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A0C;IAC1C,IAAW,OAAO,IAAI,OAAO,CAAuF;IAEpH;;;OAGG;IACI,SAAS,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI;CAarD;AAED;;;;;GAKG;AACH,qBAAa,YAAY;IAWG,MAAM,EAAE,gBAAgB;IAVlD,OAAO,CAAC,SAAS,CAAqB;IAEtC;;OAEG;IACH,IAAW,QAAQ,IAAI,GAAG,CAAC,MAAM,CAAC,CAA2B;IAE7D,2EAA2E;IAC3E,SAAgB,SAAS,eAAoB,iBAAiB,KAAK,IAAI,EAAI;gBAEjD,MAAM,EAAE,gBAAgB;IAElD,OAAO,CAAC,gBAAgB;IAKxB,uDAAuD;IACvD,IAAW,IAAI,WAAiC;IAEhD,qDAAqD;IACrD,IAAW,QAAQ,YAA8B;IAEjD;;OAEG;IACI,GAAG,CAAC,MAAM,CAAC,EAAE,MAAM;IAE1B;;OAEG;IACI,UAAU,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,OAAO;IAE/C;;OAEG;IACI,QAAQ,IAAI,IAAI;IASvB;;;;OAIG;IACI,GAAG,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO;IAIlC,OAAO,CAAC,IAAI;IAYZ;;;;OAIG;IACI,MAAM,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO;IAIrC,OAAO,CAAC,OAAO;IAYf;;;OAGG;IACI,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO;IAc7D,2DAA2D;IACpD,MAAM,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO;IAarC,0DAA0D;IACnD,OAAO,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI;CAiBpC"}
|
package/lib/esm/SelectionSet.js
CHANGED
|
@@ -164,13 +164,15 @@ export class HiliteSet {
|
|
|
164
164
|
* @param onOff True to add the elements to the hilited set, false to remove them.
|
|
165
165
|
*/
|
|
166
166
|
setHilite(arg, onOff) {
|
|
167
|
+
const oldSize = this.elements.size;
|
|
167
168
|
for (const id of Id64.iterable(arg)) {
|
|
168
169
|
if (onOff)
|
|
169
170
|
this.elements.addId(id);
|
|
170
171
|
else
|
|
171
172
|
this.elements.deleteId(id);
|
|
172
173
|
}
|
|
173
|
-
|
|
174
|
+
if (oldSize !== this.elements.size)
|
|
175
|
+
IModelApp.viewManager.onSelectionSetChanged(this.iModel);
|
|
174
176
|
}
|
|
175
177
|
}
|
|
176
178
|
/** A set of *currently selected* elements for an IModelConnection.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectionSet.js","sourceRoot":"","sources":["../../src/SelectionSet.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAuB,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC;;;GAGG;AACH,MAAM,CAAN,IAAY,qBASX;AATD,WAAY,qBAAqB;IAC/B,2CAA2C;IAC3C,+DAAG,CAAA;IACH,+CAA+C;IAC/C,qEAAM,CAAA;IACN,6EAA6E;IAC7E,uEAAO,CAAA;IACP,yDAAyD;IACzD,mEAAK,CAAA;AACP,CAAC,EATW,qBAAqB,KAArB,qBAAqB,QAShC;AAyDD;;GAEG;AACH,MAAM,UAAW,SAAQ,IAAI,CAAC,SAAS;IAIrC,YAAmB,MAAwB;QACzC,KAAK,EAAE,CAAC;QAHA,cAAS,GAAG,KAAK,CAAC;QAI1B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAEe,GAAG,CAAC,GAAW,EAAE,IAAY;QAC3C,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QACrB,IAAI,CAAC,SAAS,EAAE,CAAC;IACnB,CAAC;IAEe,MAAM,CAAC,GAAW,EAAE,IAAY;QAC9C,KAAK,CAAC,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,CAA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Content":["/*---------------------------------------------------------------------------------------------\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 SelectionSet\r\n */\r\nimport { BeEvent, Id64, Id64Arg, Id64String } from \"@itwin/core-bentley\";\r\nimport { IModelApp } from \"./IModelApp\";\r\nimport { IModelConnection } from \"./IModelConnection\";\r\n\r\n/** Identifies the type of changes made to the [[SelectionSet]] to produce a [[SelectionSetEvent]].\r\n * @public\r\n * @extensions\r\n */\r\nexport enum SelectionSetEventType {\r\n /** Elements have been added to the set. */\r\n Add,\r\n /** Elements have been removed from the set. */\r\n Remove,\r\n /** Some elements have been added to the set and others have been removed. */\r\n Replace,\r\n /** All elements are about to be removed from the set. */\r\n Clear,\r\n}\r\n\r\n/** Passed to [[SelectionSet.onChanged]] event listeners when elements are added to the selection set.\r\n * @public\r\n * @extensions\r\n */\r\nexport interface SelectAddEvent {\r\n type: SelectionSetEventType.Add;\r\n /** The Ids of the elements added to the set. */\r\n added: Id64Arg;\r\n /** The affected SelectionSet. */\r\n set: SelectionSet;\r\n}\r\n\r\n/** Passed to [[SelectionSet.onChanged]] event listeners when elements are removed from the selection set.\r\n * @public\r\n * @extensions\r\n */\r\nexport interface SelectRemoveEvent {\r\n /** The type of operation that produced this event. */\r\n type: SelectionSetEventType.Remove | SelectionSetEventType.Clear;\r\n /** The element Ids removed from the set. */\r\n removed: Id64Arg;\r\n /** The affected SelectionSet. */\r\n set: SelectionSet;\r\n}\r\n\r\n/** Passed to [[SelectionSet.onChanged]] event listeners when elements are simultaneously added to and removed from the selection set.\r\n * @public\r\n * @extensions\r\n */\r\nexport interface SelectReplaceEvent {\r\n type: SelectionSetEventType.Replace;\r\n /** The element Ids added to the set. */\r\n added: Id64Arg;\r\n /** The element Ids removed from the set. */\r\n removed: Id64Arg;\r\n /** The affected SelectionSet. */\r\n set: SelectionSet;\r\n}\r\n\r\n/** Payload sent to [[SelectionSet.onChanged]] event listeners to describe how the contents of the set have changed.\r\n * The `type` property of the event serves as a type assertion. For example, the following code will output the added and/or removed Ids:\r\n * ```ts\r\n * processSelectionSetEvent(ev: SelectionSetEvent): void {\r\n * if (SelectionSetEventType.Add === ev.type || SelectionSetEventType.Replace === ev.type)\r\n * console.log(\"Added \" + ev.added.size + \" elements\");\r\n *\r\n * if (SelectionSetEventType.Add !== ev.type)\r\n * console.log(\"Removed \" + ev.removed.size + \" elements\");\r\n * }\r\n * ```\r\n * @public\r\n * @extensions\r\n */\r\nexport type SelectionSetEvent = SelectAddEvent | SelectRemoveEvent | SelectReplaceEvent;\r\n\r\n/** Tracks a set of hilited entities. When the set changes, notifies ViewManager so that symbology overrides can be updated in active Viewports.\r\n * @internal\r\n */\r\nclass HilitedIds extends Id64.Uint32Set {\r\n protected _iModel: IModelConnection;\r\n protected _changing = false;\r\n\r\n public constructor(iModel: IModelConnection) {\r\n super();\r\n this._iModel = iModel;\r\n }\r\n\r\n public override add(low: number, high: number) {\r\n super.add(low, high);\r\n this.onChanged();\r\n }\r\n\r\n public override delete(low: number, high: number) {\r\n super.delete(low, high);\r\n this.onChanged();\r\n }\r\n\r\n public override clear() {\r\n super.clear();\r\n this.onChanged();\r\n }\r\n\r\n public override addIds(ids: Id64Arg) {\r\n this.change(() => super.addIds(ids));\r\n }\r\n\r\n public override deleteIds(ids: Id64Arg) {\r\n this.change(() => super.deleteIds(ids));\r\n }\r\n\r\n protected onChanged() {\r\n if (!this._changing)\r\n IModelApp.viewManager.onSelectionSetChanged(this._iModel);\r\n }\r\n\r\n protected change(func: () => void) {\r\n const changing = this._changing;\r\n this._changing = false;\r\n func();\r\n this._changing = changing;\r\n this.onChanged();\r\n }\r\n}\r\n\r\n/** Keeps the set of hilited elements in sync with the selection set.\r\n * @internal\r\n */\r\nclass HilitedElementIds extends HilitedIds {\r\n private _removeListener?: () => void;\r\n\r\n public constructor(iModel: IModelConnection, syncWithSelectionSet = true) {\r\n super(iModel);\r\n this.wantSyncWithSelectionSet = syncWithSelectionSet;\r\n }\r\n\r\n public get wantSyncWithSelectionSet(): boolean { return undefined !== this._removeListener; }\r\n public set wantSyncWithSelectionSet(want: boolean) {\r\n if (want === this.wantSyncWithSelectionSet)\r\n return;\r\n\r\n if (want) {\r\n const set = this._iModel.selectionSet;\r\n this._removeListener = set.onChanged.addListener((ev) => this.change(() => this.processSelectionSetEvent(ev)));\r\n this.processSelectionSetEvent({\r\n set,\r\n type: SelectionSetEventType.Add,\r\n added: set.elements,\r\n });\r\n } else {\r\n this._removeListener!();\r\n this._removeListener = undefined;\r\n }\r\n }\r\n\r\n private processSelectionSetEvent(ev: SelectionSetEvent): void {\r\n if (SelectionSetEventType.Add !== ev.type)\r\n this.deleteIds(ev.removed);\r\n\r\n if (ev.type === SelectionSetEventType.Add || ev.type === SelectionSetEventType.Replace)\r\n this.addIds(ev.added);\r\n }\r\n}\r\n\r\n/** Describes how the sets of hilited models and subcategories in a [[HiliteSet]] interact.\r\n * - \"union\" indicates a [Feature]($common) will be hilited if either its model **or** its subcategory is present in the HiliteSet.\r\n * - \"intersection\" indicates a [Feature]($common) will be hilited only if both its model **and** its subcategory are present in the HiliteSet.\r\n *\r\n * @see [[HiliteSet.modelSubCategoryMode]] to change the mode for a HiliteSet.\r\n * @public\r\n */\r\nexport type ModelSubCategoryHiliteMode = \"union\" | \"intersection\";\r\n\r\n/** A set of *hilited* elements for an [[IModelConnection]], by element id.\r\n * Hilited elements are displayed with a customizable hilite effect within a [[Viewport]].\r\n * The set exposes 3 types of elements in 3 separate collections: [GeometricElement]($backend), [GeometricModel]($backend), and [SubCategory]($backend).\r\n * The [[models]] and [[subcategories]] can be hilited independently or as an intersection of the two sets, as specified by [[modelSubCategoryMode]].\r\n *\r\n * Technically, the hilite effect is applied to [Feature]($common)s, not [Element]($backend)s. An element's geometry stream can contain multiple\r\n * features belonging to different subcategories.\r\n *\r\n * Because Javascript lacks efficient support for 64-bit integers, the Ids are stored as pairs of 32-bit integers via [Id64.Uint32Set]($bentley).\r\n *\r\n * @note Typically, elements are hilited by virtue of their presence in the IModelConnection's [[SelectionSet]]. The HiliteSet allows additional\r\n * elements to be displayed with the hilite effect without adding them to the [[SelectionSet]]. If you add elements to the HiliteSet directly, you\r\n * are also responsible for removing them as appropriate.\r\n * @see [[IModelConnection.hilited]] for the HiliteSet associated with an iModel.\r\n * @see [Hilite.Settings]($common) for customization of the hilite effect.\r\n * @public\r\n * @extensions\r\n */\r\nexport class HiliteSet {\r\n private readonly _elements: HilitedElementIds;\r\n private _mode: ModelSubCategoryHiliteMode = \"union\";\r\n\r\n /** The set of hilited subcategories.\r\n * @see [[modelSubCategoryMode]] to control how this set interacts with the set of hilited [[models]].\r\n * @see [[IModelConnection.Categories]] to obtain the set of subcategories associated with one or more [Category]($backend)'s.\r\n */\r\n public readonly subcategories: Id64.Uint32Set;\r\n\r\n /** The set of hilited [[GeometricModelState]]s.\r\n * @see [[modelSubCategoryMode]] to control how this set interacts with the set of hilited [[subcategories]].\r\n */\r\n public readonly models: Id64.Uint32Set;\r\n\r\n /** The set of hilited elements. */\r\n public get elements(): Id64.Uint32Set { return this._elements; }\r\n\r\n /** Controls how the sets of hilited [[models]] and [[subcategories]] interact with one another.\r\n * By default they are treated as a union: a [Feature]($common) is hilited if either its model **or** its subcategory is hilited.\r\n * This can be changed to an intersection such that a [Feature]($common) is hilited only if both its model **and** subcategory are hilited.\r\n * @note The sets of hilited models and subcategories are independent of the set of hilited [[elements]] - an element whose Id is present in\r\n * [[elements]] is always hilited regardless of its model or subcategories.\r\n */\r\n public get modelSubCategoryMode(): ModelSubCategoryHiliteMode {\r\n return this._mode;\r\n }\r\n public set modelSubCategoryMode(mode: ModelSubCategoryHiliteMode) {\r\n if (mode === this._mode)\r\n return;\r\n\r\n this.onModelSubCategoryModeChanged.raiseEvent(mode);\r\n this._mode = mode;\r\n }\r\n\r\n /** Event raised just before changing the value of [[modelSubCategoryMode]]. */\r\n public readonly onModelSubCategoryModeChanged = new BeEvent<(newMode: ModelSubCategoryHiliteMode) => void>();\r\n\r\n /** Construct a HiliteSet\r\n * @param iModel The iModel containing the entities to be hilited.\r\n * @param syncWithSelectionSet If true, the contents of the `elements` set will be synchronized with those in the `iModel`'s [[SelectionSet]].\r\n * @internal\r\n */\r\n public constructor(public iModel: IModelConnection, syncWithSelectionSet = true) {\r\n this._elements = new HilitedElementIds(iModel, syncWithSelectionSet);\r\n this.subcategories = new HilitedIds(iModel);\r\n this.models = new HilitedIds(iModel);\r\n }\r\n\r\n /** Control whether the hilited elements will be synchronized with the contents of the [[SelectionSet]].\r\n * By default they are synchronized. Applications that override this take responsibility for managing the set of hilited entities.\r\n * When turning synchronization off, the contents of the HiliteSet will remain unchanged.\r\n * When turning synchronization on, the current contents of the HiliteSet will be preserved, and the contents of the selection set will be added to them.\r\n */\r\n public get wantSyncWithSelectionSet(): boolean { return this._elements.wantSyncWithSelectionSet; }\r\n public set wantSyncWithSelectionSet(want: boolean) { this._elements.wantSyncWithSelectionSet = want; }\r\n\r\n /** Remove all elements from the hilited set. */\r\n public clear() {\r\n this.elements.clear();\r\n this.subcategories.clear();\r\n this.models.clear();\r\n }\r\n\r\n /** Returns true if nothing is hilited. */\r\n public get isEmpty(): boolean { return this.elements.isEmpty && this.subcategories.isEmpty && this.models.isEmpty; }\r\n\r\n /** Toggle the hilited state of one or more elements.\r\n * @param arg the ID(s) of the elements whose state is to be toggled.\r\n * @param onOff True to add the elements to the hilited set, false to remove them.\r\n */\r\n public setHilite(arg: Id64Arg, onOff: boolean): void {\r\n for (const id of Id64.iterable(arg)) {\r\n if (onOff)\r\n this.elements.addId(id);\r\n else\r\n this.elements.deleteId(id);\r\n }\r\n\r\n IModelApp.viewManager.onSelectionSetChanged(this.iModel);\r\n }\r\n}\r\n\r\n/** A set of *currently selected* elements for an IModelConnection.\r\n * Selected elements are displayed with a customizable hilite effect within a [[Viewport]].\r\n * @see [Hilite.Settings]($common) for customization of the hilite effect.\r\n * @public\r\n * @extensions\r\n */\r\nexport class SelectionSet {\r\n private _elements = new Set<string>();\r\n\r\n /** The IDs of the selected elements.\r\n * @note Do not modify this set directly. Instead, use methods like [[SelectionSet.add]].\r\n */\r\n public get elements(): Set<string> { return this._elements; }\r\n\r\n /** Called whenever elements are added or removed from this SelectionSet */\r\n public readonly onChanged = new BeEvent<(ev: SelectionSetEvent) => void>();\r\n\r\n public constructor(public iModel: IModelConnection) { }\r\n\r\n private sendChangedEvent(ev: SelectionSetEvent) {\r\n IModelApp.viewManager.onSelectionSetChanged(this.iModel);\r\n this.onChanged.raiseEvent(ev);\r\n }\r\n\r\n /** Get the number of entries in this selection set. */\r\n public get size() { return this.elements.size; }\r\n\r\n /** Check whether there are any selected elements. */\r\n public get isActive() { return this.size !== 0; }\r\n\r\n /** Return true if elemId is in this SelectionSet.\r\n * @see [[isSelected]]\r\n */\r\n public has(elemId?: string) { return !!elemId && this.elements.has(elemId); }\r\n\r\n /** Query whether an Id is in the selection set.\r\n * @see [[has]]\r\n */\r\n public isSelected(elemId?: Id64String): boolean { return !!elemId && this.elements.has(elemId); }\r\n\r\n /** Clear current selection set.\r\n * @note raises the [[onChanged]] event with [[SelectionSetEventType.Clear]].\r\n */\r\n public emptyAll(): void {\r\n if (!this.isActive)\r\n return;\r\n\r\n const removed = this._elements;\r\n this._elements = new Set<string>();\r\n this.sendChangedEvent({ set: this, type: SelectionSetEventType.Clear, removed });\r\n }\r\n\r\n /**\r\n * Add one or more Ids to the current selection set.\r\n * @param elem The set of Ids to add.\r\n * @returns true if any elements were added.\r\n */\r\n public add(elem: Id64Arg): boolean {\r\n return this._add(elem);\r\n }\r\n\r\n private _add(elem: Id64Arg, sendEvent = true): boolean {\r\n const oldSize = this.elements.size;\r\n for (const id of Id64.iterable(elem))\r\n this.elements.add(id);\r\n\r\n const changed = oldSize !== this.elements.size;\r\n if (sendEvent && changed)\r\n this.sendChangedEvent({ type: SelectionSetEventType.Add, set: this, added: elem });\r\n\r\n return changed;\r\n }\r\n\r\n /**\r\n * Remove one or more Ids from the current selection set.\r\n * @param elem The set of Ids to remove.\r\n * @returns true if any elements were removed.\r\n */\r\n public remove(elem: Id64Arg): boolean {\r\n return this._remove(elem);\r\n }\r\n\r\n private _remove(elem: Id64Arg, sendEvent = true): boolean {\r\n const oldSize = this.elements.size;\r\n for (const id of Id64.iterable(elem))\r\n this.elements.delete(id);\r\n\r\n const changed = oldSize !== this.elements.size;\r\n if (sendEvent && changed)\r\n this.sendChangedEvent({ type: SelectionSetEventType.Remove, set: this, removed: elem });\r\n\r\n return changed;\r\n }\r\n\r\n /**\r\n * Add one set of Ids, and remove another set of Ids. Any Ids that are in both sets are removed.\r\n * @returns True if any Ids were either added or removed.\r\n */\r\n public addAndRemove(adds: Id64Arg, removes: Id64Arg): boolean {\r\n const added = this._add(adds, false);\r\n const removed = this._remove(removes, false);\r\n\r\n if (added && removed)\r\n this.sendChangedEvent({ type: SelectionSetEventType.Replace, set: this, added: adds, removed: removes });\r\n else if (added)\r\n this.sendChangedEvent({ type: SelectionSetEventType.Add, set: this, added: adds });\r\n else if (removed)\r\n this.sendChangedEvent({ type: SelectionSetEventType.Remove, set: this, removed: removes });\r\n\r\n return (added || removed);\r\n }\r\n\r\n /** Invert the state of a set of Ids in the SelectionSet */\r\n public invert(elem: Id64Arg): boolean {\r\n const elementsToAdd = new Set<string>();\r\n const elementsToRemove = new Set<string>();\r\n for (const id of Id64.iterable(elem)) {\r\n if (this.elements.has(id))\r\n elementsToRemove.add(id);\r\n else\r\n elementsToAdd.add(id);\r\n }\r\n\r\n return this.addAndRemove(elementsToAdd, elementsToRemove);\r\n }\r\n\r\n /** Change selection set to be the supplied set of Ids. */\r\n public replace(elem: Id64Arg): void {\r\n if (areEqual(this.elements, elem))\r\n return;\r\n\r\n const removed = this._elements;\r\n this._elements = new Set<string>();\r\n this._add(elem, false);\r\n\r\n if (0 < removed.size) {\r\n for (const id of Id64.iterable(elem)) {\r\n if (removed.has(id))\r\n removed.delete(id);\r\n }\r\n }\r\n\r\n this.sendChangedEvent({ type: SelectionSetEventType.Replace, set: this, added: elem, removed });\r\n }\r\n}\r\n\r\nfunction areEqual(lhs: Set<string>, rhs: Id64Arg): boolean {\r\n // Size is unreliable if input can contain duplicates...\r\n if (Array.isArray(rhs))\r\n rhs = Id64.toIdSet(rhs);\r\n\r\n if (lhs.size !== Id64.sizeOf(rhs))\r\n return false;\r\n\r\n for (const id of Id64.iterable(rhs))\r\n if (!lhs.has(id))\r\n return false;\r\n\r\n return true;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"SelectionSet.js","sourceRoot":"","sources":["../../src/SelectionSet.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAuB,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC;;;GAGG;AACH,MAAM,CAAN,IAAY,qBASX;AATD,WAAY,qBAAqB;IAC/B,2CAA2C;IAC3C,+DAAG,CAAA;IACH,+CAA+C;IAC/C,qEAAM,CAAA;IACN,6EAA6E;IAC7E,uEAAO,CAAA;IACP,yDAAyD;IACzD,mEAAK,CAAA;AACP,CAAC,EATW,qBAAqB,KAArB,qBAAqB,QAShC;AAyDD;;GAEG;AACH,MAAM,UAAW,SAAQ,IAAI,CAAC,SAAS;IAIrC,YAAmB,MAAwB;QACzC,KAAK,EAAE,CAAC;QAHA,cAAS,GAAG,KAAK,CAAC;QAI1B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAEe,GAAG,CAAC,GAAW,EAAE,IAAY;QAC3C,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QACrB,IAAI,CAAC,SAAS,EAAE,CAAC;IACnB,CAAC;IAEe,MAAM,CAAC,GAAW,EAAE,IAAY;QAC9C,KAAK,CAAC,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,CA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;QACjC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YACd,OAAO,KAAK,CAAC;IAEjB,OAAO,IAAI,CAAC;AACd,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 SelectionSet\r\n */\r\nimport { BeEvent, Id64, Id64Arg, Id64String } from \"@itwin/core-bentley\";\r\nimport { IModelApp } from \"./IModelApp\";\r\nimport { IModelConnection } from \"./IModelConnection\";\r\n\r\n/** Identifies the type of changes made to the [[SelectionSet]] to produce a [[SelectionSetEvent]].\r\n * @public\r\n * @extensions\r\n */\r\nexport enum SelectionSetEventType {\r\n /** Elements have been added to the set. */\r\n Add,\r\n /** Elements have been removed from the set. */\r\n Remove,\r\n /** Some elements have been added to the set and others have been removed. */\r\n Replace,\r\n /** All elements are about to be removed from the set. */\r\n Clear,\r\n}\r\n\r\n/** Passed to [[SelectionSet.onChanged]] event listeners when elements are added to the selection set.\r\n * @public\r\n * @extensions\r\n */\r\nexport interface SelectAddEvent {\r\n type: SelectionSetEventType.Add;\r\n /** The Ids of the elements added to the set. */\r\n added: Id64Arg;\r\n /** The affected SelectionSet. */\r\n set: SelectionSet;\r\n}\r\n\r\n/** Passed to [[SelectionSet.onChanged]] event listeners when elements are removed from the selection set.\r\n * @public\r\n * @extensions\r\n */\r\nexport interface SelectRemoveEvent {\r\n /** The type of operation that produced this event. */\r\n type: SelectionSetEventType.Remove | SelectionSetEventType.Clear;\r\n /** The element Ids removed from the set. */\r\n removed: Id64Arg;\r\n /** The affected SelectionSet. */\r\n set: SelectionSet;\r\n}\r\n\r\n/** Passed to [[SelectionSet.onChanged]] event listeners when elements are simultaneously added to and removed from the selection set.\r\n * @public\r\n * @extensions\r\n */\r\nexport interface SelectReplaceEvent {\r\n type: SelectionSetEventType.Replace;\r\n /** The element Ids added to the set. */\r\n added: Id64Arg;\r\n /** The element Ids removed from the set. */\r\n removed: Id64Arg;\r\n /** The affected SelectionSet. */\r\n set: SelectionSet;\r\n}\r\n\r\n/** Payload sent to [[SelectionSet.onChanged]] event listeners to describe how the contents of the set have changed.\r\n * The `type` property of the event serves as a type assertion. For example, the following code will output the added and/or removed Ids:\r\n * ```ts\r\n * processSelectionSetEvent(ev: SelectionSetEvent): void {\r\n * if (SelectionSetEventType.Add === ev.type || SelectionSetEventType.Replace === ev.type)\r\n * console.log(\"Added \" + ev.added.size + \" elements\");\r\n *\r\n * if (SelectionSetEventType.Add !== ev.type)\r\n * console.log(\"Removed \" + ev.removed.size + \" elements\");\r\n * }\r\n * ```\r\n * @public\r\n * @extensions\r\n */\r\nexport type SelectionSetEvent = SelectAddEvent | SelectRemoveEvent | SelectReplaceEvent;\r\n\r\n/** Tracks a set of hilited entities. When the set changes, notifies ViewManager so that symbology overrides can be updated in active Viewports.\r\n * @internal\r\n */\r\nclass HilitedIds extends Id64.Uint32Set {\r\n protected _iModel: IModelConnection;\r\n protected _changing = false;\r\n\r\n public constructor(iModel: IModelConnection) {\r\n super();\r\n this._iModel = iModel;\r\n }\r\n\r\n public override add(low: number, high: number) {\r\n super.add(low, high);\r\n this.onChanged();\r\n }\r\n\r\n public override delete(low: number, high: number) {\r\n super.delete(low, high);\r\n this.onChanged();\r\n }\r\n\r\n public override clear() {\r\n super.clear();\r\n this.onChanged();\r\n }\r\n\r\n public override addIds(ids: Id64Arg) {\r\n this.change(() => super.addIds(ids));\r\n }\r\n\r\n public override deleteIds(ids: Id64Arg) {\r\n this.change(() => super.deleteIds(ids));\r\n }\r\n\r\n protected onChanged() {\r\n if (!this._changing)\r\n IModelApp.viewManager.onSelectionSetChanged(this._iModel);\r\n }\r\n\r\n protected change(func: () => void) {\r\n const changing = this._changing;\r\n this._changing = false;\r\n func();\r\n this._changing = changing;\r\n this.onChanged();\r\n }\r\n}\r\n\r\n/** Keeps the set of hilited elements in sync with the selection set.\r\n * @internal\r\n */\r\nclass HilitedElementIds extends HilitedIds {\r\n private _removeListener?: () => void;\r\n\r\n public constructor(iModel: IModelConnection, syncWithSelectionSet = true) {\r\n super(iModel);\r\n this.wantSyncWithSelectionSet = syncWithSelectionSet;\r\n }\r\n\r\n public get wantSyncWithSelectionSet(): boolean { return undefined !== this._removeListener; }\r\n public set wantSyncWithSelectionSet(want: boolean) {\r\n if (want === this.wantSyncWithSelectionSet)\r\n return;\r\n\r\n if (want) {\r\n const set = this._iModel.selectionSet;\r\n this._removeListener = set.onChanged.addListener((ev) => this.change(() => this.processSelectionSetEvent(ev)));\r\n this.processSelectionSetEvent({\r\n set,\r\n type: SelectionSetEventType.Add,\r\n added: set.elements,\r\n });\r\n } else {\r\n this._removeListener!();\r\n this._removeListener = undefined;\r\n }\r\n }\r\n\r\n private processSelectionSetEvent(ev: SelectionSetEvent): void {\r\n if (SelectionSetEventType.Add !== ev.type)\r\n this.deleteIds(ev.removed);\r\n\r\n if (ev.type === SelectionSetEventType.Add || ev.type === SelectionSetEventType.Replace)\r\n this.addIds(ev.added);\r\n }\r\n}\r\n\r\n/** Describes how the sets of hilited models and subcategories in a [[HiliteSet]] interact.\r\n * - \"union\" indicates a [Feature]($common) will be hilited if either its model **or** its subcategory is present in the HiliteSet.\r\n * - \"intersection\" indicates a [Feature]($common) will be hilited only if both its model **and** its subcategory are present in the HiliteSet.\r\n *\r\n * @see [[HiliteSet.modelSubCategoryMode]] to change the mode for a HiliteSet.\r\n * @public\r\n */\r\nexport type ModelSubCategoryHiliteMode = \"union\" | \"intersection\";\r\n\r\n/** A set of *hilited* elements for an [[IModelConnection]], by element id.\r\n * Hilited elements are displayed with a customizable hilite effect within a [[Viewport]].\r\n * The set exposes 3 types of elements in 3 separate collections: [GeometricElement]($backend), [GeometricModel]($backend), and [SubCategory]($backend).\r\n * The [[models]] and [[subcategories]] can be hilited independently or as an intersection of the two sets, as specified by [[modelSubCategoryMode]].\r\n *\r\n * Technically, the hilite effect is applied to [Feature]($common)s, not [Element]($backend)s. An element's geometry stream can contain multiple\r\n * features belonging to different subcategories.\r\n *\r\n * Because Javascript lacks efficient support for 64-bit integers, the Ids are stored as pairs of 32-bit integers via [Id64.Uint32Set]($bentley).\r\n *\r\n * @note Typically, elements are hilited by virtue of their presence in the IModelConnection's [[SelectionSet]]. The HiliteSet allows additional\r\n * elements to be displayed with the hilite effect without adding them to the [[SelectionSet]]. If you add elements to the HiliteSet directly, you\r\n * are also responsible for removing them as appropriate.\r\n * @see [[IModelConnection.hilited]] for the HiliteSet associated with an iModel.\r\n * @see [Hilite.Settings]($common) for customization of the hilite effect.\r\n * @public\r\n * @extensions\r\n */\r\nexport class HiliteSet {\r\n private readonly _elements: HilitedElementIds;\r\n private _mode: ModelSubCategoryHiliteMode = \"union\";\r\n\r\n /** The set of hilited subcategories.\r\n * @see [[modelSubCategoryMode]] to control how this set interacts with the set of hilited [[models]].\r\n * @see [[IModelConnection.Categories]] to obtain the set of subcategories associated with one or more [Category]($backend)'s.\r\n */\r\n public readonly subcategories: Id64.Uint32Set;\r\n\r\n /** The set of hilited [[GeometricModelState]]s.\r\n * @see [[modelSubCategoryMode]] to control how this set interacts with the set of hilited [[subcategories]].\r\n */\r\n public readonly models: Id64.Uint32Set;\r\n\r\n /** The set of hilited elements. */\r\n public get elements(): Id64.Uint32Set { return this._elements; }\r\n\r\n /** Controls how the sets of hilited [[models]] and [[subcategories]] interact with one another.\r\n * By default they are treated as a union: a [Feature]($common) is hilited if either its model **or** its subcategory is hilited.\r\n * This can be changed to an intersection such that a [Feature]($common) is hilited only if both its model **and** subcategory are hilited.\r\n * @note The sets of hilited models and subcategories are independent of the set of hilited [[elements]] - an element whose Id is present in\r\n * [[elements]] is always hilited regardless of its model or subcategories.\r\n */\r\n public get modelSubCategoryMode(): ModelSubCategoryHiliteMode {\r\n return this._mode;\r\n }\r\n public set modelSubCategoryMode(mode: ModelSubCategoryHiliteMode) {\r\n if (mode === this._mode)\r\n return;\r\n\r\n this.onModelSubCategoryModeChanged.raiseEvent(mode);\r\n this._mode = mode;\r\n }\r\n\r\n /** Event raised just before changing the value of [[modelSubCategoryMode]]. */\r\n public readonly onModelSubCategoryModeChanged = new BeEvent<(newMode: ModelSubCategoryHiliteMode) => void>();\r\n\r\n /** Construct a HiliteSet\r\n * @param iModel The iModel containing the entities to be hilited.\r\n * @param syncWithSelectionSet If true, the contents of the `elements` set will be synchronized with those in the `iModel`'s [[SelectionSet]].\r\n * @internal\r\n */\r\n public constructor(public iModel: IModelConnection, syncWithSelectionSet = true) {\r\n this._elements = new HilitedElementIds(iModel, syncWithSelectionSet);\r\n this.subcategories = new HilitedIds(iModel);\r\n this.models = new HilitedIds(iModel);\r\n }\r\n\r\n /** Control whether the hilited elements will be synchronized with the contents of the [[SelectionSet]].\r\n * By default they are synchronized. Applications that override this take responsibility for managing the set of hilited entities.\r\n * When turning synchronization off, the contents of the HiliteSet will remain unchanged.\r\n * When turning synchronization on, the current contents of the HiliteSet will be preserved, and the contents of the selection set will be added to them.\r\n */\r\n public get wantSyncWithSelectionSet(): boolean { return this._elements.wantSyncWithSelectionSet; }\r\n public set wantSyncWithSelectionSet(want: boolean) { this._elements.wantSyncWithSelectionSet = want; }\r\n\r\n /** Remove all elements from the hilited set. */\r\n public clear() {\r\n this.elements.clear();\r\n this.subcategories.clear();\r\n this.models.clear();\r\n }\r\n\r\n /** Returns true if nothing is hilited. */\r\n public get isEmpty(): boolean { return this.elements.isEmpty && this.subcategories.isEmpty && this.models.isEmpty; }\r\n\r\n /** Toggle the hilited state of one or more elements.\r\n * @param arg the ID(s) of the elements whose state is to be toggled.\r\n * @param onOff True to add the elements to the hilited set, false to remove them.\r\n */\r\n public setHilite(arg: Id64Arg, onOff: boolean): void {\r\n const oldSize = this.elements.size;\r\n\r\n for (const id of Id64.iterable(arg)) {\r\n if (onOff)\r\n this.elements.addId(id);\r\n else\r\n this.elements.deleteId(id);\r\n }\r\n\r\n if (oldSize !== this.elements.size)\r\n IModelApp.viewManager.onSelectionSetChanged(this.iModel);\r\n }\r\n}\r\n\r\n/** A set of *currently selected* elements for an IModelConnection.\r\n * Selected elements are displayed with a customizable hilite effect within a [[Viewport]].\r\n * @see [Hilite.Settings]($common) for customization of the hilite effect.\r\n * @public\r\n * @extensions\r\n */\r\nexport class SelectionSet {\r\n private _elements = new Set<string>();\r\n\r\n /** The IDs of the selected elements.\r\n * @note Do not modify this set directly. Instead, use methods like [[SelectionSet.add]].\r\n */\r\n public get elements(): Set<string> { return this._elements; }\r\n\r\n /** Called whenever elements are added or removed from this SelectionSet */\r\n public readonly onChanged = new BeEvent<(ev: SelectionSetEvent) => void>();\r\n\r\n public constructor(public iModel: IModelConnection) { }\r\n\r\n private sendChangedEvent(ev: SelectionSetEvent) {\r\n IModelApp.viewManager.onSelectionSetChanged(this.iModel);\r\n this.onChanged.raiseEvent(ev);\r\n }\r\n\r\n /** Get the number of entries in this selection set. */\r\n public get size() { return this.elements.size; }\r\n\r\n /** Check whether there are any selected elements. */\r\n public get isActive() { return this.size !== 0; }\r\n\r\n /** Return true if elemId is in this SelectionSet.\r\n * @see [[isSelected]]\r\n */\r\n public has(elemId?: string) { return !!elemId && this.elements.has(elemId); }\r\n\r\n /** Query whether an Id is in the selection set.\r\n * @see [[has]]\r\n */\r\n public isSelected(elemId?: Id64String): boolean { return !!elemId && this.elements.has(elemId); }\r\n\r\n /** Clear current selection set.\r\n * @note raises the [[onChanged]] event with [[SelectionSetEventType.Clear]].\r\n */\r\n public emptyAll(): void {\r\n if (!this.isActive)\r\n return;\r\n\r\n const removed = this._elements;\r\n this._elements = new Set<string>();\r\n this.sendChangedEvent({ set: this, type: SelectionSetEventType.Clear, removed });\r\n }\r\n\r\n /**\r\n * Add one or more Ids to the current selection set.\r\n * @param elem The set of Ids to add.\r\n * @returns true if any elements were added.\r\n */\r\n public add(elem: Id64Arg): boolean {\r\n return this._add(elem);\r\n }\r\n\r\n private _add(elem: Id64Arg, sendEvent = true): boolean {\r\n const oldSize = this.elements.size;\r\n for (const id of Id64.iterable(elem))\r\n this.elements.add(id);\r\n\r\n const changed = oldSize !== this.elements.size;\r\n if (sendEvent && changed)\r\n this.sendChangedEvent({ type: SelectionSetEventType.Add, set: this, added: elem });\r\n\r\n return changed;\r\n }\r\n\r\n /**\r\n * Remove one or more Ids from the current selection set.\r\n * @param elem The set of Ids to remove.\r\n * @returns true if any elements were removed.\r\n */\r\n public remove(elem: Id64Arg): boolean {\r\n return this._remove(elem);\r\n }\r\n\r\n private _remove(elem: Id64Arg, sendEvent = true): boolean {\r\n const oldSize = this.elements.size;\r\n for (const id of Id64.iterable(elem))\r\n this.elements.delete(id);\r\n\r\n const changed = oldSize !== this.elements.size;\r\n if (sendEvent && changed)\r\n this.sendChangedEvent({ type: SelectionSetEventType.Remove, set: this, removed: elem });\r\n\r\n return changed;\r\n }\r\n\r\n /**\r\n * Add one set of Ids, and remove another set of Ids. Any Ids that are in both sets are removed.\r\n * @returns True if any Ids were either added or removed.\r\n */\r\n public addAndRemove(adds: Id64Arg, removes: Id64Arg): boolean {\r\n const added = this._add(adds, false);\r\n const removed = this._remove(removes, false);\r\n\r\n if (added && removed)\r\n this.sendChangedEvent({ type: SelectionSetEventType.Replace, set: this, added: adds, removed: removes });\r\n else if (added)\r\n this.sendChangedEvent({ type: SelectionSetEventType.Add, set: this, added: adds });\r\n else if (removed)\r\n this.sendChangedEvent({ type: SelectionSetEventType.Remove, set: this, removed: removes });\r\n\r\n return (added || removed);\r\n }\r\n\r\n /** Invert the state of a set of Ids in the SelectionSet */\r\n public invert(elem: Id64Arg): boolean {\r\n const elementsToAdd = new Set<string>();\r\n const elementsToRemove = new Set<string>();\r\n for (const id of Id64.iterable(elem)) {\r\n if (this.elements.has(id))\r\n elementsToRemove.add(id);\r\n else\r\n elementsToAdd.add(id);\r\n }\r\n\r\n return this.addAndRemove(elementsToAdd, elementsToRemove);\r\n }\r\n\r\n /** Change selection set to be the supplied set of Ids. */\r\n public replace(elem: Id64Arg): void {\r\n if (areEqual(this.elements, elem))\r\n return;\r\n\r\n const removed = this._elements;\r\n this._elements = new Set<string>();\r\n this._add(elem, false);\r\n\r\n if (0 < removed.size) {\r\n for (const id of Id64.iterable(elem)) {\r\n if (removed.has(id))\r\n removed.delete(id);\r\n }\r\n }\r\n\r\n this.sendChangedEvent({ type: SelectionSetEventType.Replace, set: this, added: elem, removed });\r\n }\r\n}\r\n\r\nfunction areEqual(lhs: Set<string>, rhs: Id64Arg): boolean {\r\n // Size is unreliable if input can contain duplicates...\r\n if (Array.isArray(rhs))\r\n rhs = Id64.toIdSet(rhs);\r\n\r\n if (lhs.size !== Id64.sizeOf(rhs))\r\n return false;\r\n\r\n for (const id of Id64.iterable(rhs))\r\n if (!lhs.has(id))\r\n return false;\r\n\r\n return true;\r\n}\r\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/core-frontend",
|
|
3
|
-
"version": "3.6.0-dev.
|
|
3
|
+
"version": "3.6.0-dev.3",
|
|
4
4
|
"description": "iTwin.js frontend components",
|
|
5
5
|
"main": "lib/cjs/core-frontend.js",
|
|
6
6
|
"module": "lib/esm/core-frontend.js",
|
|
@@ -22,29 +22,29 @@
|
|
|
22
22
|
"url": "http://www.bentley.com"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"@itwin/appui-abstract": "^3.6.0-dev.
|
|
26
|
-
"@itwin/core-bentley": "^3.6.0-dev.
|
|
27
|
-
"@itwin/core-common": "^3.6.0-dev.
|
|
28
|
-
"@itwin/core-geometry": "^3.6.0-dev.
|
|
29
|
-
"@itwin/core-orbitgt": "^3.6.0-dev.
|
|
30
|
-
"@itwin/core-quantity": "^3.6.0-dev.
|
|
31
|
-
"@itwin/webgl-compatibility": "^3.6.0-dev.
|
|
25
|
+
"@itwin/appui-abstract": "^3.6.0-dev.3",
|
|
26
|
+
"@itwin/core-bentley": "^3.6.0-dev.3",
|
|
27
|
+
"@itwin/core-common": "^3.6.0-dev.3",
|
|
28
|
+
"@itwin/core-geometry": "^3.6.0-dev.3",
|
|
29
|
+
"@itwin/core-orbitgt": "^3.6.0-dev.3",
|
|
30
|
+
"@itwin/core-quantity": "^3.6.0-dev.3",
|
|
31
|
+
"@itwin/webgl-compatibility": "^3.6.0-dev.3"
|
|
32
32
|
},
|
|
33
33
|
"//devDependencies": [
|
|
34
34
|
"NOTE: All peerDependencies should also be listed as devDependencies since peerDependencies are not considered by npm install",
|
|
35
35
|
"NOTE: All tools used by scripts in this package must be listed as devDependencies"
|
|
36
36
|
],
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@itwin/appui-abstract": "3.6.0-dev.
|
|
39
|
-
"@itwin/build-tools": "3.6.0-dev.
|
|
40
|
-
"@itwin/core-bentley": "3.6.0-dev.
|
|
41
|
-
"@itwin/core-common": "3.6.0-dev.
|
|
42
|
-
"@itwin/core-geometry": "3.6.0-dev.
|
|
43
|
-
"@itwin/core-orbitgt": "3.6.0-dev.
|
|
44
|
-
"@itwin/core-quantity": "3.6.0-dev.
|
|
45
|
-
"@itwin/certa": "3.6.0-dev.
|
|
46
|
-
"@itwin/eslint-plugin": "3.6.0-dev.
|
|
47
|
-
"@itwin/webgl-compatibility": "3.6.0-dev.
|
|
38
|
+
"@itwin/appui-abstract": "3.6.0-dev.3",
|
|
39
|
+
"@itwin/build-tools": "3.6.0-dev.3",
|
|
40
|
+
"@itwin/core-bentley": "3.6.0-dev.3",
|
|
41
|
+
"@itwin/core-common": "3.6.0-dev.3",
|
|
42
|
+
"@itwin/core-geometry": "3.6.0-dev.3",
|
|
43
|
+
"@itwin/core-orbitgt": "3.6.0-dev.3",
|
|
44
|
+
"@itwin/core-quantity": "3.6.0-dev.3",
|
|
45
|
+
"@itwin/certa": "3.6.0-dev.3",
|
|
46
|
+
"@itwin/eslint-plugin": "3.6.0-dev.3",
|
|
47
|
+
"@itwin/webgl-compatibility": "3.6.0-dev.3",
|
|
48
48
|
"@types/chai": "4.3.1",
|
|
49
49
|
"@types/chai-as-promised": "^7",
|
|
50
50
|
"@types/deep-assign": "^0.1.0",
|
|
@@ -78,8 +78,8 @@
|
|
|
78
78
|
"@itwin/object-storage-azure": "~1.4.0",
|
|
79
79
|
"@itwin/cloud-agnostic-core": "~1.4.0",
|
|
80
80
|
"@itwin/object-storage-core": "~1.4.0",
|
|
81
|
-
"@itwin/core-i18n": "3.6.0-dev.
|
|
82
|
-
"@itwin/core-telemetry": "3.6.0-dev.
|
|
81
|
+
"@itwin/core-i18n": "3.6.0-dev.3",
|
|
82
|
+
"@itwin/core-telemetry": "3.6.0-dev.3",
|
|
83
83
|
"@loaders.gl/core": "^3.1.6",
|
|
84
84
|
"@loaders.gl/draco": "^3.1.6",
|
|
85
85
|
"deep-assign": "^2.0.0",
|