Layer Management
Relevant source files
The following files were used as context for generating this wiki page:
Layer Management is a core feature of the Nextcloud CAD Viewer that allows users to organize and control the visibility of different drawing elements within DWG and DXF files. This system enables users to toggle specific groups of entities on or off, facilitating focused analysis of complex engineering drawings by reducing visual clutter.
The system integrates directly with the underlying @mlightcad/cad-viewer library to extract layer metadata from the CAD file and present an interactive management interface within the Nextcloud environment.
Sources: appinfo/info.xml:13, wiki/User-Guide.md:148-150, README.md:12
Component Architecture and UI
The Layer Management interface is accessed via a dedicated button in the viewer's primary toolbar. When activated, it presents a panel that lists all layers defined within the loaded CAD document.
UI Components
The layer panel provides several visual indicators and controls for each layer:
- Layer Name: Displays the unique identifier for the layer as defined in the source CAD software.
- Visibility Toggle: Represented by an eye icon (👁️ for visible, 👁️🗨️ for hidden).
- Color Indicator: A visual block showing the specific color assigned to that layer in the drawing.
Sources: wiki/User-Guide.md:152-162, README.md:14
Component Interaction Flow
The following diagram illustrates how the frontend components interact when a user modifies layer visibility:
Implementation Logic
Layer management is implemented through the interaction between the Vue.js frontend and the @mlightcad utility wrappers. The loadCADViewer utility initializes the core MlCadViewer component, which handles the parsing of layer tables from the binary CAD data.
Initialization and Settings
Layer behaviors and initial states can be influenced by the AcApSettings managed via the AcApSettingManager. While layers are typically loaded from the file metadata, the viewer's theme (light/dark) can affect how layer colors are rendered for optimal contrast.
Sources: src/utils/cadLoader.ts:18-35, src/utils/cadLoader.ts:77-90, wiki/User-Guide.md:182-185
Data Structure for Layer Visibility
The viewer manages layer states through a reactive internal model. The following table describes the primary layer attributes:
| Attribute | Description | Impact on Viewport |
|---|---|---|
| Name | The alphanumeric ID of the layer | Used for identification in the list |
| Visibility | Boolean state (Visible/Hidden) | Determines if entities on this layer are rendered |
| Color | Hex or RGB value | Defines the stroke/fill color of layer entities |
Sources: wiki/User-Guide.md:158-162, src/utils/cadLoader.ts:25-30
User Operations and Best Practices
Layer Management allows for several critical workflows to improve drawing readability and performance.
Visibility Controls
Users can immediately apply changes to the drawing area by toggling the eye icon next to the layer name. Hiding complex or unnecessary layers (such as construction lines or dense annotations) can significantly improve rendering performance on large files.
Troubleshooting Layers
If layers are not appearing as expected, it is often due to the state of the layer in the source file or browser limitations.
| Issue | Potential Cause | Source Reference |
|---|---|---|
| Missing Layers | Layers may be "Frozen" or "Locked" in the source file | wiki/Troubleshooting.md:139-142 |
| Empty List | Complex nested blocks or xrefs may hide layer hierarchy | wiki/Troubleshooting.md:144-146 |
| Performance Lag | Too many visible complex layers | wiki/Troubleshooting.md:156-158 |
Sources: wiki/User-Guide.md:170-173, wiki/Troubleshooting.md:139-146
Sequence of Visibility Update
This sequence diagram shows the internal event flow when a layer's visibility is changed:
Conclusion
The Layer Management system provides the necessary granularity for viewing complex CAD data within Nextcloud. By leveraging the @mlightcad/cad-viewer engine, the application ensures that layer metadata is accurately represented and that visibility toggles result in immediate, hardware-accelerated updates to the WebGL canvas. This feature is essential for professional engineering workflows where isolating specific systems (e.g., electrical, plumbing, or structural) within a single drawing is required.
Sources: README.md:12-16, wiki/User-Guide.md:170-173