|
8 | 8 | minimum-scale=1.0, |
9 | 9 | maximum-scale=1.0, |
10 | 10 | user-scalable=no"> |
11 | | - <link rel="icon" href="/favicon.ico"> |
| 11 | + <link rel="icon" href="./favicon.ico"> |
12 | 12 | <link rel="stylesheet" type="text/css" href="./global.css"> |
13 | 13 | <link rel="stylesheet" type="text/css" href="./iconfont/iconfont.css" /> |
14 | 14 | <link rel="stylesheet" type="text/css" href="./iconfont/iconfont2.css" /> |
15 | | - <link rel="stylesheet" href="./settings/SettingsPanel.css"> |
16 | 15 |
|
17 | 16 | <style> |
18 | 17 | #app { |
|
122 | 121 | MarkupPlugin, |
123 | 122 | MeasurementPlugin, |
124 | 123 | ScreenshotPlugin, |
| 124 | + Settings2dPlugin, |
125 | 125 | StatsPlugin, |
126 | 126 | ToolbarMenuId, |
127 | 127 | } from "@x-viewer/plugins"; |
128 | | - import Viewer2dSettingsPanel from './settings/Viewer2dSettingsPanel.js'; |
129 | 128 |
|
130 | 129 | const models = [{ |
131 | 130 | modelId: "dxf_0", |
132 | 131 | name: "dxf_0", |
133 | 132 | src: "./models/dxf/dxf_0.dxf", |
134 | 133 | merge: true, |
135 | 134 | visible: true, |
136 | | - }, /*{ |
| 135 | + }, { |
137 | 136 | modelId: "dxf_0_1", |
138 | 137 | name: "dxf_0_1", |
139 | 138 | src: "./models/dxf/dxf_0_1.dxf", |
140 | 139 | merge: true, |
141 | 140 | visible: true, |
142 | | - }*/]; |
| 141 | + }]; |
143 | 142 | const language = "en"; // "en" or "cn" |
144 | 143 | const viewerCfg = { |
145 | 144 | containerId: "myCanvas", |
|
157 | 156 | window.viewer = viewer; |
158 | 157 |
|
159 | 158 | const menuConfig = { |
160 | | - [ToolbarMenuId.Settings]: { |
161 | | - onActive: () => { |
162 | | - console.log("[Toolbar]", "Activate Settings"); |
163 | | - if (!window.settingsPanel) { |
164 | | - window.settingsPanel = new Viewer2dSettingsPanel(window.viewer); |
165 | | - } |
166 | | - window.settingsPanel.show(); |
167 | | - }, |
168 | | - onDeactive: () => { |
169 | | - console.log("[Toolbar]", "Deactivate Settings"); |
170 | | - window.settingsPanel.hide(); |
171 | | - }, |
172 | | - mutexIds: [ |
173 | | - ToolbarMenuId.Measure, |
174 | | - ToolbarMenuId.MeasureDistance, |
175 | | - ToolbarMenuId.MeasureArea, |
176 | | - ToolbarMenuId.MeasureAngle, |
177 | | - ToolbarMenuId.MeasureCoordinate, |
178 | | - ], |
179 | | - }, |
180 | 159 | [ToolbarMenuId.Layers]: { |
181 | 160 | onActive: () => { |
182 | 161 | console.log("[Toolbar]", "Activate Layers"); |
183 | 162 | if (!window.layerManager) { |
184 | | - window.layerManager = new LayerManagerPlugin(window.viewer) |
185 | | - window.layerManager.addEventListener("Visibilitychange", (visible) => { |
186 | | - window.toolbar.setActive("Layers", visible); |
| 163 | + window.layerManager = new LayerManagerPlugin(window.viewer); |
| 164 | + window.layerManager.addEventListener("visibilitychange", (visible) => { |
| 165 | + const isActive = toolbarPlugin.isActive(ToolbarMenuId.Layers); |
| 166 | + // do this check to avoid recursive call |
| 167 | + if (isActive !== visible) { |
| 168 | + toolbarPlugin.setActive(ToolbarMenuId.Layers, visible); |
| 169 | + } |
187 | 170 | }); |
188 | 171 | } |
189 | | - window.layerManager.show(); |
| 172 | + window.layerManager.setVisible(true); |
190 | 173 | }, |
191 | 174 | onDeactive: () => { |
192 | 175 | console.log("[Toolbar]", "Deactivate Layers"); |
193 | | - window.layerManager.hide(); |
| 176 | + window.layerManager.setVisible(false); |
194 | 177 | }, |
195 | 178 | mutexIds: [ |
196 | 179 | ToolbarMenuId.Measure, |
|
206 | 189 | const markupPlugin = new MarkupPlugin(viewer); |
207 | 190 | const measurementPlugin = new MeasurementPlugin(viewer, { language }); |
208 | 191 | new ScreenshotPlugin(viewer); |
| 192 | + new Settings2dPlugin(viewer, { language, visible: false }); |
209 | 193 | new StatsPlugin(viewer); |
210 | 194 | const hotpointPlugin = new HotpointPlugin(viewer); |
211 | | - window.toolbar = new Viewer2dToolbarPlugin(viewer, { menuConfig, language }); |
| 195 | + window.toolbarPlugin = new Viewer2dToolbarPlugin(viewer, { menuConfig, language }); |
212 | 196 |
|
213 | 197 | let counter = 0; // to indicate how many models are loading |
214 | 198 | models.forEach((modelCfg) => { |
|
0 commit comments