Skip to content

Layer system for circuit organization #349

@darktorres

Description

@darktorres

Description

Add a layer system that lets users organize complex circuits into visual layers. Elements can be placed on different layers, and layers can be shown/hidden independently. Useful for separating data paths, control logic, and annotations.

Acceptance Criteria

  • Multiple named layers supported
  • Drag and drop elements between layers
  • Per-layer visibility toggle
  • Per-layer lock (prevent accidental edits)
  • Layers serialized in .panda files

Implementation Guide

1. Layer model

  • Add a Layer struct: { int id, QString name, bool visible, bool locked, int zOrder }
  • Add QList<Layer> m_layers to Scene
  • Each GraphicElement gets a m_layerId property
  • Default layer (id=0) for backward compatibility

2. Visibility and locking

  • In Scene::drawBackground() and element paint, skip elements on hidden layers
  • When a layer is locked, elements on it are not selectable or movable
  • Use QGraphicsItem::setFlag(ItemIsSelectable/ItemIsMovable) based on layer lock state

3. Layer panel UI

  • Dockable widget listing all layers with visibility eye icon and lock icon
  • Right-click: Rename, Delete, Merge layers
  • Drag to reorder z-depth
  • "Move selection to layer" context menu action

4. Serialization

  • Store layer definitions in file metadata
  • Store per-element layer assignment in the element's QMap
  • Gate with VersionInfo::hasLayers(version) — older versions load everything onto layer 0

Key files

  • App/Scene/Scene.h/.cpp — layer storage, visibility filtering
  • App/Element/GraphicElement.h/.cpp — layer assignment
  • App/Element/GraphicElementSerializer.cpp — serialize layer ID
  • App/UI/MainWindow.cpp — layer panel integration
  • New files: App/Scene/LayerManager.h/.cpp, App/UI/LayerPanel.h/.cpp

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions