wiRedPanda
Logic Circuit Simulator
Loading...
Searching...
No Matches
Scene Class Reference

Main circuit editing scene. More...

#include <Scene.h>

Inheritance diagram for Scene:
[legend]

Public Member Functions

void addItem (QGraphicsItem *item)
 Adds item to the scene and registers it in the per-scene ID registry.
void addItem (QMimeData *mimeData, std::optional< QPointF > scenePos=std::nullopt)
void alignBottom ()
 Aligns selected elements' bottom edges to the bottommost selected edge. No-op below 2 elements.
void alignHorizontalCenter ()
void alignLeft ()
 Aligns selected elements' left edges to the leftmost selected edge. No-op below 2 elements.
void alignRight ()
 Aligns selected elements' right edges to the rightmost selected edge. No-op below 2 elements.
void alignTop ()
 Aligns selected elements' top edges to the topmost selected edge. No-op below 2 elements.
void alignVerticalCenter ()
QRectF cachedItemsBoundingRect () const
void circuitHasChanged ()
 Emitted whenever the circuit changes (element added/removed/moved).
ClipboardManagerclipboardManager ()
 Returns the clipboard manager that handles copy, cut, paste and clone-drag.
ConnectionManagerconnectionManager ()
 Returns the connection manager that handles wire creation, deletion, and hover feedback.
bool contains (int id) const
 Returns true if an item with id is registered in this scene.
QString contextDir () const override
 Returns the directory of the .panda file associated with this scene.
void contextMenu (const QPoint screenPos)
 Opens the element/selection context menu at screenPos (driven by SceneInteraction on right-click).
void contextMenuPos (QPoint screenPos, QGraphicsItem *itemAtMouse)
 Emitted when a context menu should appear.
void copyAction ()
 Copies the selected items to the internal clipboard.
void cutAction ()
 Cuts the selected items to the internal clipboard.
void deleteAction ()
 Deletes the currently selected items.
SerializationContext deserializationContext (QHash< quint64, Port * > &portMap, const QVersionNumber &version, SerializationPurpose purpose)
void distributeHorizontally ()
void distributeVertically ()
void duplicateAction ()
 Duplicates the selection in place (leaves the system clipboard untouched).
const QVector< GraphicElement * > elements () const
 Returns all graphic elements in the scene.
const QVector< GraphicElement * > elements (const QRectF &rect) const
 Returns all graphic elements within rect.
bool eventFilter (QObject *watched, QEvent *event) override
void fileDropRequested (const QString &filePath)
 Emitted when a .panda file is dropped onto the canvas from the file manager.
void flipHorizontally ()
 Flips selected elements horizontally.
void flipVertically ()
 Flips selected elements vertically.
void forgetItemId (int id)
void icOpenRequested (int elementId, const QString &blobName, const QString &filePath)
 Emitted when an IC element is double-clicked to request opening its sub-circuit.
void icPreviewCancelRequested (IC *ic)
void icPreviewHideRequested ()
void icPreviewMoved (IC *ic, const QPoint &screenPos)
void icPreviewRequested (IC *ic, const QPoint &screenPos)
ICRegistryicRegistry ()
 Returns the IC definition registry for this scene.
QGraphicsItem * itemAt (QPointF pos) const
 Returns the topmost item at pos, prioritising ports over elements.
ItemWithIditemById (int id) const
 Returns the item registered under id, or nullptr if not found.
QList< QGraphicsItem * > items (const QRectF &rect, Qt::ItemSelectionMode mode=Qt::IntersectsItemShape, Qt::SortOrder order=Qt::AscendingOrder, const QTransform &deviceTransform=QTransform()) const
QList< QGraphicsItem * > items (QPointF pos, Qt::ItemSelectionMode mode=Qt::IntersectsItemShape, Qt::SortOrder order=Qt::AscendingOrder, const QTransform &deviceTransform=QTransform()) const
QList< QGraphicsItem * > items (Qt::SortOrder order=Qt::AscendingOrder) const
int lastId () const
 Returns the current highest ID in use by this scene.
QPointF mousePos () const
 Returns the last known mouse position in scene coordinates.
void mute (const bool mute=true)
 Mutes or unmutes selected elements according to mute.
void nextElm ()
 Cycles selection forward to the next element.
int nextId ()
 Returns the next available scene-local ID (does not assign it).
void nextMainPropShortcut ()
 Advances the main property of selected elements to the next value.
void nextSecndPropShortcut ()
 Advances the secondary property of selected elements to the next value.
void noteWireActivity ()
void openTruthTableRequested ()
 Emitted when a TruthTable element is double-clicked to request opening its editor.
void pasteAction ()
 Pastes items from the internal clipboard into the scene.
PortportAt (QPointF pos) const
void prevElm ()
 Cycles selection backward to the previous element.
void prevMainPropShortcut ()
 Retreats the main property of selected elements to the previous value.
void prevSecndPropShortcut ()
 Retreats the secondary property of selected elements to the previous value.
PropertyShortcutHandlerpropertyShortcutHandler ()
 Returns the handler for keyboard shortcuts that cycle element properties.
void receiveCommand (QUndoCommand *cmd)
 Pushes cmd onto the undo stack (immediately executes its redo()).
void recordWirePaintPass (qint64 elapsedNs)
QAction * redoAction () const
 Returns the redo QAction bound to the undo stack.
void removeItem (QGraphicsItem *item)
 Removes item from the scene and unregisters it from the per-scene ID registry.
void resizeScene ()
 Tightens the scene rect to item bounds while preserving the viewport position.
void restoreWireAntialiasing ()
void retranslateUi ()
 Updates undo/redo action text to reflect the current UI language.
void rotateLeft ()
 Rotates selected elements 90 degrees counter-clockwise.
void rotateRight ()
 Rotates selected elements 90 degrees clockwise.
 Scene (QObject *parent=nullptr)
 Constructs a Scene and initialises the undo stack and simulation.
void selectAll ()
 Selects all items in the scene.
const QList< GraphicElement * > selectedElements () const
 Returns the list of currently selected graphic elements.
void setAutosaveRequired ()
 Schedules an autosave of the current circuit state.
void setCircuitUpdateRequired ()
 Marks the simulation mapping as stale so it is rebuilt on the next tick.
void setContextDir (const QString &dir)
 Sets the directory of the .panda file associated with this scene.
void setLastId (int newLastId)
 Advances the scene's ID counter to at least newLastId.
void setMuted (const bool muted) override
void setPropertyUpdateRequired ()
void setView (GraphicsView *view)
 Sets the GraphicsView that displays this scene to view.
void showGates (bool checked)
 Shows or hides gate elements. Delegates to VisibilityManager.
void showStatusMessage (const QString &message)
void showStatusMessageRequested (const QString &message)
void showWires (bool checked)
 Shows or hides connection wires. Delegates to VisibilityManager.
Simulationsimulation ()
 Returns the simulation engine associated with this scene.
QList< QGraphicsItem * > simulationItems () const override
void truthTableElementChanged (GraphicElement *element)
 Emitted after a TruthTable element's output bit is toggled (redo or undo).
QAction * undoAction () const
 Returns the undo QAction bound to the undo stack.
QUndoStack * undoStack ()
 Returns the scene's undo stack.
const QVector< GraphicElement * > unsortedElements () const
void updateItemId (ItemWithId *item, int newId)
 Reassigns the ID of item to newId without adding it to the scene.
void updateTheme ()
 Propagates the current theme to all elements and connections.
GraphicsViewview () const
 Returns the GraphicsView currently displaying this scene.
VisibilityManagervisibilityManager ()
 Returns the visibility manager for this scene.
const QVector< GraphicElement * > visibleElements () const
 Returns all visible (non-hidden) graphic elements in the scene.
bool wireAntialiasingEnabled () const
 true while wires should stroke with antialiasing; Connection::paint() consults this.
Public Member Functions inherited from ContextDirProvider
virtual ~ContextDirProvider ()=default
Public Member Functions inherited from SimulationHost
virtual ~SimulationHost ()=default

Static Public Member Functions

static QString droppedPandaFile (const QMimeData *mimeData)
static bool isConnectionAllowed (OutputPort *startPort, InputPort *endPort)
 Returns true if a wire from startPort to endPort is permitted.
static QVector< GraphicElement * > sortByTopology (QVector< GraphicElement * > elements)
 Returns elements sorted in topological dependency order (inputs first).
static QHash< QString, InputPort * > wirelessTxInputPorts (const QVector< GraphicElement * > &elements)
 Returns a map from wireless channel label to the Tx node's input port.

Protected Member Functions

void dragEnterEvent (QGraphicsSceneDragDropEvent *event) override
void dragMoveEvent (QGraphicsSceneDragDropEvent *event) override
void dropEvent (QGraphicsSceneDragDropEvent *event) override
void helpEvent (QGraphicsSceneHelpEvent *event) override
void keyPressEvent (QKeyEvent *event) override
void keyReleaseEvent (QKeyEvent *event) override
void mouseDoubleClickEvent (QGraphicsSceneMouseEvent *event) override
void mouseMoveEvent (QGraphicsSceneMouseEvent *event) override
void mousePressEvent (QGraphicsSceneMouseEvent *event) override
void mouseReleaseEvent (QGraphicsSceneMouseEvent *event) override

Detailed Description

Main circuit editing scene.

The Scene class extends QGraphicsScene to provide the main circuit editing environment. It manages circuit elements and their connections, handles user interactions like selection, copying, pasting and rotation. Scene also implements undo/redo functionality and handles various user interface events like drag-and-drop, keyboard shortcuts, and mouse operations.

Definition at line 55 of file Scene.h.

Constructor & Destructor Documentation

◆ Scene()

Scene::Scene ( QObject * parent = nullptr)
explicit

Constructs a Scene and initialises the undo stack and simulation.

Definition at line 69 of file Scene.cpp.

References ThemeManager::instance(), ThemeManager::themeChanged(), and updateTheme().

Member Function Documentation

◆ addItem() [1/2]

◆ addItem() [2/2]

void Scene::addItem ( QMimeData * mimeData,
std::optional< QPointF > scenePos = std::nullopt )

Deserializes and adds items from mimeData to the scene. If scenePos is set, the new element is placed there (used by the palette's double-click / search add so it lands in view); otherwise it keeps its default position (drop path).

Definition at line 1383 of file Scene.cpp.

◆ alignBottom()

void Scene::alignBottom ( )

Aligns selected elements' bottom edges to the bottommost selected edge. No-op below 2 elements.

Definition at line 1001 of file Scene.cpp.

References selectedElements().

◆ alignHorizontalCenter()

void Scene::alignHorizontalCenter ( )

Aligns selected elements' horizontal (X) centers so they share one vertical line. No-op below 2 elements.

Definition at line 1023 of file Scene.cpp.

References selectedElements().

◆ alignLeft()

void Scene::alignLeft ( )

Aligns selected elements' left edges to the leftmost selected edge. No-op below 2 elements.

Definition at line 935 of file Scene.cpp.

References selectedElements().

◆ alignRight()

void Scene::alignRight ( )

Aligns selected elements' right edges to the rightmost selected edge. No-op below 2 elements.

Definition at line 957 of file Scene.cpp.

References selectedElements().

◆ alignTop()

void Scene::alignTop ( )

Aligns selected elements' top edges to the topmost selected edge. No-op below 2 elements.

Definition at line 979 of file Scene.cpp.

References selectedElements().

◆ alignVerticalCenter()

void Scene::alignVerticalCenter ( )

Aligns selected elements' vertical (Y) centers so they share one horizontal line. No-op below 2 elements.

Definition at line 1046 of file Scene.cpp.

References selectedElements().

◆ cachedItemsBoundingRect()

QRectF Scene::cachedItemsBoundingRect ( ) const
nodiscard

Returns itemsBoundingRect(), cached and invalidated on structural/positional edits (see setPropertyUpdateRequired()) — an O(total items) call this project's zoom/pan/ scroll paths (resizeScene(), MinimapWidget) would otherwise redo on every step even though panning/zooming never changes which items exist or where they are. Bypasses the cache during an active element drag, where the live (uncached) value is required: see resizeScene()'s isDraggingElement() branch.

Definition at line 527 of file Scene.cpp.

Referenced by resizeScene().

◆ circuitHasChanged()

void Scene::circuitHasChanged ( )

◆ clipboardManager()

ClipboardManager * Scene::clipboardManager ( )
inline

Returns the clipboard manager that handles copy, cut, paste and clone-drag.

Definition at line 225 of file Scene.h.

◆ connectionManager()

ConnectionManager * Scene::connectionManager ( )
inline

Returns the connection manager that handles wire creation, deletion, and hover feedback.

Definition at line 220 of file Scene.h.

◆ contains()

bool Scene::contains ( int id) const
nodiscard

Returns true if an item with id is registered in this scene.

Definition at line 176 of file Scene.cpp.

Referenced by contextMenu().

◆ contextDir()

QString Scene::contextDir ( ) const
inlineoverridevirtual

Returns the directory of the .panda file associated with this scene.

Implements ContextDirProvider.

Definition at line 352 of file Scene.h.

Referenced by deserializationContext(), ICController::embedICByFile(), ICController::embedSelectedIC(), ICController::extractICByBlobName(), ICController::extractSelectedIC(), and ICController::makeSelfContained().

◆ contextMenu()

void Scene::contextMenu ( const QPoint screenPos)

Opens the element/selection context menu at screenPos (driven by SceneInteraction on right-click).

Definition at line 781 of file Scene.cpp.

References ClipboardManager::canPaste(), contains(), contextMenuPos(), elements(), itemAt(), pasteAction(), selectAll(), and GraphicElement::Type.

◆ contextMenuPos()

void Scene::contextMenuPos ( QPoint screenPos,
QGraphicsItem * itemAtMouse )

Emitted when a context menu should appear.

Parameters
screenPosScreen coordinates of the right-click.
itemAtMouseItem under the mouse pointer (may be nullptr).

Referenced by contextMenu(), and ElementEditor::setScene().

◆ copyAction()

void Scene::copyAction ( )

Copies the selected items to the internal clipboard.

Definition at line 814 of file Scene.cpp.

References sentryBreadcrumb().

Referenced by ElementContextMenu::exec().

◆ cutAction()

void Scene::cutAction ( )

Cuts the selected items to the internal clipboard.

Definition at line 820 of file Scene.cpp.

References sentryBreadcrumb().

Referenced by ElementContextMenu::exec().

◆ deleteAction()

void Scene::deleteAction ( )

Deletes the currently selected items.

Definition at line 838 of file Scene.cpp.

References receiveCommand(), and sentryBreadcrumb().

Referenced by ElementContextMenu::exec().

◆ deserializationContext()

SerializationContext Scene::deserializationContext ( QHash< quint64, Port * > & portMap,
const QVersionNumber & version,
SerializationPurpose purpose )

Creates a deserialization context with the scene's contextDir and blob registry. purpose has no default – every caller must state whether this deserializes a genuine .panda file or an in-session snapshot; see SerializationPurpose.

Definition at line 216 of file Scene.cpp.

References SerializationContext::blobRegistry, and contextDir().

Referenced by CommandUtils::loadItems(), and ICRegistry::rollbackElements().

◆ distributeHorizontally()

void Scene::distributeHorizontally ( )

Redistributes selected elements with equal horizontal gaps between edges, keeping the leftmost and rightmost elements fixed as anchors. No-op below 3 elements.

Definition at line 1069 of file Scene.cpp.

References selectedElements().

◆ distributeVertically()

void Scene::distributeVertically ( )

Redistributes selected elements with equal vertical gaps between edges, keeping the topmost and bottommost elements fixed as anchors. No-op below 3 elements.

Definition at line 1106 of file Scene.cpp.

References selectedElements().

◆ dragEnterEvent()

void Scene::dragEnterEvent ( QGraphicsSceneDragDropEvent * event)
overrideprotected
Reimplemented from base class.

Definition at line 1160 of file Scene.cpp.

References droppedPandaFile(), and SceneDropHandler::isSupportedDropFormat().

◆ dragMoveEvent()

void Scene::dragMoveEvent ( QGraphicsSceneDragDropEvent * event)
overrideprotected
Reimplemented from base class.

Definition at line 1171 of file Scene.cpp.

References droppedPandaFile(), and SceneDropHandler::isSupportedDropFormat().

◆ dropEvent()

void Scene::dropEvent ( QGraphicsSceneDragDropEvent * event)
overrideprotected

◆ droppedPandaFile()

QString Scene::droppedPandaFile ( const QMimeData * mimeData)
static

Returns the path of the first local .panda file in mimeData's URL list (the file a file-manager drop would open), or an empty string if there is none.

Definition at line 1143 of file Scene.cpp.

Referenced by dragEnterEvent(), dragMoveEvent(), and dropEvent().

◆ duplicateAction()

void Scene::duplicateAction ( )

Duplicates the selection in place (leaves the system clipboard untouched).

Definition at line 832 of file Scene.cpp.

References sentryBreadcrumb().

◆ elements() [1/2]

const QVector< GraphicElement * > Scene::elements ( ) const

◆ elements() [2/2]

const QVector< GraphicElement * > Scene::elements ( const QRectF & rect) const

Returns all graphic elements within rect.

Definition at line 356 of file Scene.cpp.

References items(), sortByTopology(), and GraphicElement::Type.

◆ eventFilter()

bool Scene::eventFilter ( QObject * watched,
QEvent * event )
override
Reimplemented from base class.

Definition at line 1301 of file Scene.cpp.

References itemAt(), Connection::Type, and GraphicElement::Type.

◆ fileDropRequested()

void Scene::fileDropRequested ( const QString & filePath)

Emitted when a .panda file is dropped onto the canvas from the file manager.

Referenced by dropEvent().

◆ flipHorizontally()

void Scene::flipHorizontally ( )

Flips selected elements horizontally.

Definition at line 893 of file Scene.cpp.

References receiveCommand(), selectedElements(), and sentryBreadcrumb().

◆ flipVertically()

void Scene::flipVertically ( )

Flips selected elements vertically.

Definition at line 903 of file Scene.cpp.

References receiveCommand(), selectedElements(), and sentryBreadcrumb().

◆ forgetItemId()

void Scene::forgetItemId ( int id)

Drops a stale registry entry by ID without dereferencing the item. Needed when Qt's parent-child cascade destroys an item: it removes the item from QGraphicsScene via the non-virtual base removeItem, bypassing our override and leaving the m_elementRegistry entry pointing at freed memory.

Definition at line 201 of file Scene.cpp.

◆ helpEvent()

void Scene::helpEvent ( QGraphicsSceneHelpEvent * event)
overrideprotected
Reimplemented from base class.

Definition at line 1369 of file Scene.cpp.

References portAt().

◆ icOpenRequested()

void Scene::icOpenRequested ( int elementId,
const QString & blobName,
const QString & filePath )

Emitted when an IC element is double-clicked to request opening its sub-circuit.

Referenced by addItem(), and SceneUiBinder::unbind().

◆ icPreviewCancelRequested()

void Scene::icPreviewCancelRequested ( IC * ic)

Referenced by addItem(), and SceneUiBinder::unbind().

◆ icPreviewHideRequested()

void Scene::icPreviewHideRequested ( )

Referenced by addItem(), and SceneUiBinder::unbind().

◆ icPreviewMoved()

void Scene::icPreviewMoved ( IC * ic,
const QPoint & screenPos )

Referenced by addItem(), and SceneUiBinder::unbind().

◆ icPreviewRequested()

void Scene::icPreviewRequested ( IC * ic,
const QPoint & screenPos )

Referenced by addItem(), and SceneUiBinder::unbind().

◆ icRegistry()

◆ isConnectionAllowed()

bool Scene::isConnectionAllowed ( OutputPort * startPort,
InputPort * endPort )
static

Returns true if a wire from startPort to endPort is permitted.

Delegates to ConnectionManager::isConnectionAllowed().

Definition at line 677 of file Scene.cpp.

References ConnectionManager::isConnectionAllowed().

◆ itemAt()

QGraphicsItem * Scene::itemAt ( QPointF pos) const

Returns the topmost item at pos, prioritising ports over elements.

Definition at line 441 of file Scene.cpp.

References items(), GraphicElement::Type, and Port::Type.

Referenced by contextMenu(), and eventFilter().

◆ itemById()

ItemWithId * Scene::itemById ( int id) const
nodiscard

◆ items() [1/3]

QList< QGraphicsItem * > Scene::items ( const QRectF & rect,
Qt::ItemSelectionMode mode = Qt::IntersectsItemShape,
Qt::SortOrder order = Qt::AscendingOrder,
const QTransform & deviceTransform = QTransform() ) const
Reimplemented from base class.

Definition at line 728 of file Scene.cpp.

◆ items() [2/3]

QList< QGraphicsItem * > Scene::items ( QPointF pos,
Qt::ItemSelectionMode mode = Qt::IntersectsItemShape,
Qt::SortOrder order = Qt::AscendingOrder,
const QTransform & deviceTransform = QTransform() ) const
Reimplemented from base class.

Definition at line 723 of file Scene.cpp.

◆ items() [3/3]

QList< QGraphicsItem * > Scene::items ( Qt::SortOrder order = Qt::AscendingOrder) const
Reimplemented from base class.

Definition at line 718 of file Scene.cpp.

Referenced by elements(), itemAt(), portAt(), selectAll(), simulationItems(), and unsortedElements().

◆ keyPressEvent()

void Scene::keyPressEvent ( QKeyEvent * event)
overrideprotected
Reimplemented from base class.

Definition at line 1249 of file Scene.cpp.

References unsortedElements().

◆ keyReleaseEvent()

void Scene::keyReleaseEvent ( QKeyEvent * event)
overrideprotected
Reimplemented from base class.

Definition at line 1278 of file Scene.cpp.

References unsortedElements().

◆ lastId()

int Scene::lastId ( ) const

Returns the current highest ID in use by this scene.

Definition at line 181 of file Scene.cpp.

◆ mouseDoubleClickEvent()

void Scene::mouseDoubleClickEvent ( QGraphicsSceneMouseEvent * event)
overrideprotected
Reimplemented from base class.

Definition at line 1362 of file Scene.cpp.

◆ mouseMoveEvent()

void Scene::mouseMoveEvent ( QGraphicsSceneMouseEvent * event)
overrideprotected
Reimplemented from base class.

Definition at line 1334 of file Scene.cpp.

◆ mousePos()

QPointF Scene::mousePos ( ) const
inlinenodiscard

Returns the last known mouse position in scene coordinates.

Definition at line 243 of file Scene.h.

◆ mousePressEvent()

void Scene::mousePressEvent ( QGraphicsSceneMouseEvent * event)
overrideprotected
Reimplemented from base class.

Definition at line 1327 of file Scene.cpp.

◆ mouseReleaseEvent()

void Scene::mouseReleaseEvent ( QGraphicsSceneMouseEvent * event)
overrideprotected
Reimplemented from base class.

Definition at line 1355 of file Scene.cpp.

◆ mute()

void Scene::mute ( const bool mute = true)

Mutes or unmutes selected elements according to mute.

Definition at line 884 of file Scene.cpp.

References mute(), and unsortedElements().

Referenced by mute(), and setMuted().

◆ nextElm()

void Scene::nextElm ( )

Cycles selection forward to the next element.

Definition at line 695 of file Scene.cpp.

◆ nextId()

int Scene::nextId ( )

Returns the next available scene-local ID (does not assign it).

Definition at line 191 of file Scene.cpp.

Referenced by addItem().

◆ nextMainPropShortcut()

void Scene::nextMainPropShortcut ( )

Advances the main property of selected elements to the next value.

Definition at line 689 of file Scene.cpp.

◆ nextSecndPropShortcut()

void Scene::nextSecndPropShortcut ( )

Advances the secondary property of selected elements to the next value.

Definition at line 693 of file Scene.cpp.

◆ noteWireActivity()

void Scene::noteWireActivity ( )

Marks wire activity for idle detection; Connection::setStatus() calls this on every real status change. Cheap (timestamp restart), safe at simulation flip rates.

Definition at line 578 of file Scene.cpp.

◆ openTruthTableRequested()

void Scene::openTruthTableRequested ( )

Emitted when a TruthTable element is double-clicked to request opening its editor.

Referenced by addItem(), and SceneUiBinder::unbind().

◆ pasteAction()

void Scene::pasteAction ( )

Pastes items from the internal clipboard into the scene.

Definition at line 826 of file Scene.cpp.

References sentryBreadcrumb().

Referenced by contextMenu().

◆ portAt()

Port * Scene::portAt ( QPointF pos) const
nodiscard

Returns the topmost port within itemsAt()'s hit area of pos, or nullptr. Bounding-box-based fast path for per-mouse-move consumers – unlike itemAt(), never exact-shape-tests wires or elements (see the implementation comment).

Definition at line 480 of file Scene.cpp.

References items(), and Port::Type.

Referenced by helpEvent().

◆ prevElm()

void Scene::prevElm ( )

Cycles selection backward to the previous element.

Definition at line 697 of file Scene.cpp.

◆ prevMainPropShortcut()

void Scene::prevMainPropShortcut ( )

Retreats the main property of selected elements to the previous value.

Definition at line 687 of file Scene.cpp.

◆ prevSecndPropShortcut()

void Scene::prevSecndPropShortcut ( )

Retreats the secondary property of selected elements to the previous value.

Definition at line 691 of file Scene.cpp.

◆ propertyShortcutHandler()

PropertyShortcutHandler * Scene::propertyShortcutHandler ( )
inline

Returns the handler for keyboard shortcuts that cycle element properties.

Definition at line 230 of file Scene.h.

◆ receiveCommand()

void Scene::receiveCommand ( QUndoCommand * cmd)

Pushes cmd onto the undo stack (immediately executes its redo()).

Definition at line 520 of file Scene.cpp.

References sentryBreadcrumb().

Referenced by ICController::addEmbeddedICFromFile(), deleteAction(), ICController::embedICByFile(), flipHorizontally(), flipVertically(), and ElementEditor::setScene().

◆ recordWirePaintPass()

void Scene::recordWirePaintPass ( qint64 elapsedNs)

Feeds one measured view paint pass (GraphicsView::paintEvent times its base call). MinimapWidget's off-view scene renders never reach this, so they can't skew decisions.

Definition at line 549 of file Scene.cpp.

References restoreWireAntialiasing().

◆ redoAction()

QAction * Scene::redoAction ( ) const

Returns the redo QAction bound to the undo stack.

Definition at line 758 of file Scene.cpp.

◆ removeItem()

void Scene::removeItem ( QGraphicsItem * item)

Removes item from the scene and unregisters it from the per-scene ID registry.

Definition at line 160 of file Scene.cpp.

Referenced by CommandUtils::deleteItems(), and CommandUtils::drainPortConnections().

◆ resizeScene()

void Scene::resizeScene ( )

Tightens the scene rect to item bounds while preserving the viewport position.

Definition at line 635 of file Scene.cpp.

References cachedItemsBoundingRect(), and view().

Referenced by WorkSpace::WorkSpace().

◆ restoreWireAntialiasing()

void Scene::restoreWireAntialiasing ( )

Restores wire antialiasing and schedules the refinement repaint. Invoked by the idle timer and the sustained-headroom path; public so a pass-free quality reset is possible (and directly drivable from tests).

Definition at line 599 of file Scene.cpp.

Referenced by recordWirePaintPass().

◆ retranslateUi()

void Scene::retranslateUi ( )

Updates undo/redo action text to reflect the current UI language.

Definition at line 763 of file Scene.cpp.

◆ rotateLeft()

void Scene::rotateLeft ( )

Rotates selected elements 90 degrees counter-clockwise.

Definition at line 869 of file Scene.cpp.

References sentryBreadcrumb().

◆ rotateRight()

void Scene::rotateRight ( )

Rotates selected elements 90 degrees clockwise.

Definition at line 863 of file Scene.cpp.

References sentryBreadcrumb().

◆ selectAll()

void Scene::selectAll ( )

Selects all items in the scene.

Definition at line 854 of file Scene.cpp.

References items().

Referenced by contextMenu().

◆ selectedElements()

const QList< GraphicElement * > Scene::selectedElements ( ) const

Returns the list of currently selected graphic elements.

Definition at line 427 of file Scene.cpp.

References GraphicElement::Type.

Referenced by alignBottom(), alignHorizontalCenter(), alignLeft(), alignRight(), alignTop(), alignVerticalCenter(), distributeHorizontally(), distributeVertically(), flipHorizontally(), and flipVertically().

◆ setAutosaveRequired()

void Scene::setAutosaveRequired ( )

Schedules an autosave of the current circuit state.

Definition at line 293 of file Scene.cpp.

◆ setCircuitUpdateRequired()

void Scene::setCircuitUpdateRequired ( )

Marks the simulation mapping as stale so it is rebuilt on the next tick.

Definition at line 298 of file Scene.cpp.

References setPropertyUpdateRequired().

◆ setContextDir()

void Scene::setContextDir ( const QString & dir)
inline

Sets the directory of the .panda file associated with this scene.

Definition at line 354 of file Scene.h.

◆ setLastId()

void Scene::setLastId ( int newLastId)

Advances the scene's ID counter to at least newLastId.

Definition at line 186 of file Scene.cpp.

Referenced by addItem().

◆ setMuted()

void Scene::setMuted ( const bool muted)
inlineoverridevirtual
Reimplemented from base class. SimulationHost

Implements SimulationHost.

Definition at line 347 of file Scene.h.

References mute().

◆ setPropertyUpdateRequired()

void Scene::setPropertyUpdateRequired ( )

Refreshes visuals and marks the scene dirty without rebuilding the simulation graph, for property-only edits (label, color, delay, ...) that don't add, remove, or reconnect elements.

Definition at line 313 of file Scene.cpp.

Referenced by setCircuitUpdateRequired().

◆ setView()

void Scene::setView ( GraphicsView * view)

Sets the GraphicsView that displays this scene to view.

Definition at line 748 of file Scene.cpp.

References view().

◆ showGates()

void Scene::showGates ( bool checked)

Shows or hides gate elements. Delegates to VisibilityManager.

Definition at line 733 of file Scene.cpp.

◆ showStatusMessage()

void Scene::showStatusMessage ( const QString & message)

Emits showStatusMessageRequested() so the bound chrome can surface message in the status bar (used to explain a rejected wire instead of dropping it silently).

Definition at line 682 of file Scene.cpp.

References showStatusMessageRequested().

◆ showStatusMessageRequested()

void Scene::showStatusMessageRequested ( const QString & message)

Requests that message be shown transiently in the status bar (e.g. why a wire was rejected). Routed to the status bar by SceneUiBinder.

Referenced by SceneUiBinder::bind(), showStatusMessage(), and SceneUiBinder::unbind().

◆ showWires()

void Scene::showWires ( bool checked)

Shows or hides connection wires. Delegates to VisibilityManager.

Definition at line 738 of file Scene.cpp.

◆ simulation()

Simulation * Scene::simulation ( )

Returns the simulation engine associated with this scene.

Definition at line 288 of file Scene.cpp.

◆ simulationItems()

QList< QGraphicsItem * > Scene::simulationItems ( ) const
inlineoverridevirtual
Reimplemented from base class. SimulationHost

Implements SimulationHost.

Definition at line 345 of file Scene.h.

References items().

◆ sortByTopology()

QVector< GraphicElement * > Scene::sortByTopology ( QVector< GraphicElement * > elements)
static

Returns elements sorted in topological dependency order (inputs first).

Definition at line 371 of file Scene.cpp.

References calculatePriorities(), and elements().

Referenced by elements(), and elements().

◆ truthTableElementChanged()

void Scene::truthTableElementChanged ( GraphicElement * element)

Emitted after a TruthTable element's output bit is toggled (redo or undo).

Parameters
elementThe TruthTable element that changed.

Referenced by ElementEditor::setScene().

◆ undoAction()

QAction * Scene::undoAction ( ) const

Returns the undo QAction bound to the undo stack.

Definition at line 753 of file Scene.cpp.

◆ undoStack()

QUndoStack * Scene::undoStack ( )

Returns the scene's undo stack.

Definition at line 672 of file Scene.cpp.

◆ unsortedElements()

const QVector< GraphicElement * > Scene::unsortedElements ( ) const

Returns all graphic elements without the topological sort — for hot paths (key triggers, mute) that don't care about evaluation order.

Definition at line 341 of file Scene.cpp.

References items(), and GraphicElement::Type.

Referenced by elements(), keyPressEvent(), keyReleaseEvent(), and mute().

◆ updateItemId()

void Scene::updateItemId ( ItemWithId * item,
int newId )

Reassigns the ID of item to newId without adding it to the scene.

Used by undo/redo commands (loadItems, SplitCommand, MorphCommand) to restore an element's original ID before calling addItem(). The item must NOT be in the scene registry yet when this is called.

Definition at line 196 of file Scene.cpp.

Referenced by CommandUtils::loadItems().

◆ updateTheme()

void Scene::updateTheme ( )

Propagates the current theme to all elements and connections.

Definition at line 699 of file Scene.cpp.

References ThemeManager::attributes(), elements(), ThemeAttributes::m_sceneBgBrush, ThemeAttributes::m_sceneBgDots, and qCDebug.

Referenced by Scene().

◆ view()

GraphicsView * Scene::view ( ) const

Returns the GraphicsView currently displaying this scene.

Definition at line 743 of file Scene.cpp.

Referenced by ClipboardManager::cloneDrag(), resizeScene(), and setView().

◆ visibilityManager()

VisibilityManager * Scene::visibilityManager ( )
inline

Returns the visibility manager for this scene.

Definition at line 173 of file Scene.h.

◆ visibleElements()

const QVector< GraphicElement * > Scene::visibleElements ( ) const

Returns all visible (non-hidden) graphic elements in the scene.

Definition at line 329 of file Scene.cpp.

References elements().

Referenced by ElementTabNavigator::eventFilter().

◆ wireAntialiasingEnabled()

bool Scene::wireAntialiasingEnabled ( ) const
nodiscard

true while wires should stroke with antialiasing; Connection::paint() consults this.

Definition at line 544 of file Scene.cpp.

◆ wirelessTxInputPorts()

QHash< QString, InputPort * > Scene::wirelessTxInputPorts ( const QVector< GraphicElement * > & elements)
static

Returns a map from wireless channel label to the Tx node's input port.

Scans elements for nodes in WirelessMode::Tx, keyed by label. If two Tx nodes share the same label the first one wins. Used by codegens to resolve Rx node signals without duplicating the wireless scan.

Definition at line 399 of file Scene.cpp.

References elements().

Referenced by ArduinoCodeGen::generate(), and SystemVerilogCodeGen::generate().


The documentation for this class was generated from the following files: