/** * 3D Foundation Project * Copyright 2025 Smithsonian Institution * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import "@ff/ui/Button"; import "../ui/properties/PropertyOptions"; import "../ui/properties/PropertyEvent"; import CVDocument from "./CVDocument"; import { EViewPreset } from "./CVOrbitNavigation"; import CVTool, { customElement, html, ToolView } from "./CVTool"; import CVSetup from "./CVSetup"; import { ENavigationType } from "client/schema/setup"; //////////////////////////////////////////////////////////////////////////////// export default class CVViewTool extends CVTool { static readonly typeName: string = "CVViewTool"; static readonly text = "View"; static readonly icon = "eye"; get enabled() { return this.getSystemComponent(CVSetup).navigation.ins.mode.value === ENavigationType.Orbit; } createView() { return new ViewToolView(this); } } //////////////////////////////////////////////////////////////////////////////// @customElement("sv-view-tool-view") export class ViewToolView extends ToolView { protected firstConnected() { super.firstConnected(); this.classList.add("sv-view-tool-view"); } protected render() { const document = this.activeDocument; if (!document) { return html``; } const tool = this.tool; const navigation = document.setup.navigation; const language = document.setup.language; const projection = navigation.ins.projection; const preset = navigation.ins.preset; const zoom = navigation.ins.zoomExtents; const presetMap = [ EViewPreset.Front, EViewPreset.Back, EViewPreset.Left, EViewPreset.Right, EViewPreset.Top, EViewPreset.Bottom ]; return tool.enabled ? html`` : null; } protected onActiveDocument(previous: CVDocument, next: CVDocument) { this.requestUpdate(); } protected async setFocus() { await this.updateComplete; const focusElement = this.getElementsByTagName("sv-property-options")[0] as HTMLElement; focusElement ? focusElement.focus() : null; } protected onClose(event: MouseEvent) { this.parentElement.dispatchEvent(new CustomEvent("close")); event.stopPropagation(); } }