/////////////////////////////////////////////////////////////////////////////// // Copyright (C) 2002-2026, Open Design Alliance (the "Alliance"). // All rights reserved. // // This software and its documentation and related materials are owned by // the Alliance. The software may only be incorporated into application // programs owned by members of the Alliance, subject to a signed // Membership Agreement and Supplemental Software License Agreement with the // Alliance. The structure and organization of this software are the valuable // trade secrets of the Alliance and its suppliers. The software is also // protected by copyright law and international treaty provisions. Application // programs incorporating this software must include the following statement // with their copyright notices: // // This application incorporates Open Design Alliance software pursuant to a // license agreement with Open Design Alliance. // Open Design Alliance Copyright (C) 2002-2026 by Open Design Alliance. // All rights reserved. // // By use of this software, its documentation or related materials, you // acknowledge and accept the above terms. /////////////////////////////////////////////////////////////////////////////// import { IModelImpl } from "./ModelImpl.types"; export class ModelImpl implements IModelImpl { public id = ""; public visualizeJs: any; constructor(visualizeJs: any) { this.id = ""; this.visualizeJs = visualizeJs; } dispose(): void {} initialize(): void { // reserved for future use } getHandlesByEntityIterator(iterator: any): string[] { const handles2: string[] = []; while (!iterator.done()) { const entityId = iterator.getEntity(); const entityType = entityId.getType(); let entityPtr = null; if (entityType === this.visualizeJs.OdTvEntityType.kEntity.value) entityPtr = entityId.openObject(); if (entityType === this.visualizeJs.OdTvEntityType.kInsert.value) entityPtr = entityId.openObjectAsInsert(); if (entityPtr) { const handle = entityPtr.getNativeDatabaseHandle(); if (handle !== "-1") handles2.push(handle); entityPtr.delete(); } iterator.step(); } return handles2; } getHandlesBySelectionSet(selectionSet: any): string[] { const iterator = selectionSet.getIterator(); const handles = this.getHandlesByEntityIterator(iterator); iterator.delete(); return handles; } getSelectionSetByHandles(handles: string[]): any { const viewer = this.visualizeJs.getViewer(); const selectionSet = viewer.getEntitySetByOriginalHandles(handles); return selectionSet; } // IModel hide(handles: string[]): this { const viewer = this.visualizeJs.getViewer(); const model = viewer.getActiveModel(); const selectionSet = this.getSelectionSetByHandles(handles); model.hideBySelectionSet(selectionSet, false); selectionSet.delete(); return this; } hideAll(): this { const viewer = this.visualizeJs.getViewer(); const model = viewer.getActiveModel(); const selectionSet = new this.visualizeJs.OdTvSelectionSet(); const entityItr = model.getEntitiesIterator(); while (!entityItr.done()) { const entityId = entityItr.getEntity(); const entityType = entityId.getType(); const isEntity = entityType === this.visualizeJs.OdTvEntityType.kEntity.value; const isInsert = entityType === this.visualizeJs.OdTvEntityType.kInsert.value; if (isEntity || isInsert) selectionSet.appendEntity(entityId); entityItr.step(); } entityItr.delete(); model.hideBySelectionSet(selectionSet, false); selectionSet.delete(); return this; } isolate(handles: string[]): this { if (handles.length > 0) { const viewer = this.visualizeJs.getViewer(); const model = viewer.getActiveModel(); const selectionSet = this.getSelectionSetByHandles(handles); model.isolateBySelectionSet(selectionSet, false); selectionSet.delete(); } else { this.hideAll(); } return this; } show(handles: string[]): this { const viewer = this.visualizeJs.getViewer(); const model = viewer.getActiveModel(); const selectionSet = this.getSelectionSetByHandles(handles); model.unHideBySelectionSet(selectionSet, true, false); selectionSet.delete(); return this; } showAll(): this { const viewer = this.visualizeJs.getViewer(); const model = viewer.getActiveModel(); model.unIsolate(false); return this; } highlight(handles: string[]): this { const viewer = this.visualizeJs.getViewer(); const view = viewer.activeView; const selectionSet = this.getSelectionSetByHandles(handles); view.highlightAll(selectionSet, true); selectionSet.delete(); return this; } unhighlight(handles: string[]): this { const viewer = this.visualizeJs.getViewer(); const view = viewer.activeView; const selectionSet = this.getSelectionSetByHandles(handles); view.highlightAll(selectionSet, false); selectionSet.delete(); return this; } explode(scale: 0, coeff = 4): this { const viewer = this.visualizeJs.getViewer(); viewer.explode(scale); return this; } }