wiRedPanda
Logic Circuit Simulator
Loading...
Searching...
No Matches
ElementEditor.h
Go to the documentation of this file.
1// Copyright 2015 - 2026, GIBIS-UNIFESP and the wiRedPanda contributors
2// SPDX-License-Identifier: GPL-3.0-or-later
3
7
8#pragma once
9
10#include <memory>
11#include <utility>
12
13#include <QDialog>
14#include <QTableWidget>
15#include <QVBoxLayout>
16#include <QWidget>
17
19#include "App/Scene/Scene.h"
22
24
34class ElementEditor : public QWidget
35{
36 Q_OBJECT
37
38public:
39 // --- Lifecycle ---
40
42 explicit ElementEditor(QWidget *parent = nullptr);
43 ~ElementEditor() override;
44
45 // --- Scene Binding ---
46
48 void setScene(Scene *scene);
49
50 // --- UI Refresh ---
51
53 void update();
55 void retranslateUi();
57 void updateTheme();
59 void fillColorComboBox();
60
61 // --- User Actions ---
62
64 void renameAction();
68 void audioBox();
70 void truthTable();
73
74 // --- Context Menu ---
75
77 void contextMenu(QPoint screenPos, QGraphicsItem *itemAtMouse);
78
79signals:
84 void sendCommand(QUndoCommand *cmd);
85
87 void editSubcircuitRequested(const QString &blobName, int icElementId);
88
90 void openSubcircuitFileRequested(const QString &filePath);
91
94
97
98private:
99 Q_DISABLE_COPY(ElementEditor)
100
102
103 // --- Helpers ---
104
106 void apply();
108 void applyCapabilitiesToUi();
110 void applyProperty(GraphicElement *elm, PropertyDescriptor::Type type);
112 void defaultAppearance();
114 void rebuildAppearanceStateTiles(const QList<std::pair<int, QString>> &states);
116 void inputIndexChanged(const int index);
118 void inputLocked(const bool value);
120 void outputIndexChanged(const int index);
122 void outputValueChanged(const QString &value);
124 void selectionChanged();
126 void setCurrentElements(const QList<GraphicElement *> &elements);
128 void setTruthTableProposition(const int row, const int column);
130 void triggerChanged(const QString &cmd);
132 void blobNameEditingFinished();
133
134 // --- Members ---
135
136 std::unique_ptr<ElementEditorUi> m_ui;
137 QDialog *m_tableBox = nullptr;
138 QTableWidget *m_table = nullptr;
139 Scene *m_scene = nullptr;
140 ElementTabNavigator *m_tabNavigator = nullptr;
141 QList<GraphicElement *> m_elements;
142 SelectionCapabilities m_caps;
143
144 // Appearance state
145 QString m_appearanceName;
146 bool m_isDefaultAppearance = true;
147 bool m_isUpdatingAppearance = false;
148
149 // Placeholder strings for multi-selection display
150 QString m_manyAudios = tr("<Many sounds>");
151 QString m_manyColors = tr("<Many colors>");
152 QString m_manyDelay = tr("<Many values>");
153 QString m_manyFreq = tr("<Many values>");
154 QString m_manyIS = tr("<Many values>");
155 QString m_manyLabels = tr("<Many labels>");
156 QString m_manyOS = tr("<Many values>");
157 QString m_manyOV = tr("<Many values>");
158 QString m_manyTriggers = tr("<Many triggers>");
159 QString m_manyWirelessModes = tr("<Many modes>");
160};
ElementEditorUi: hand-written UI class for the ElementEditor widget.
PropertyDescriptor struct for describing editable element properties.
Main circuit editing scene with undo/redo and user interaction.
SelectionCapabilities struct and computeCapabilities() free function.
void openSubcircuitFileRequested(const QString &filePath)
Emitted when the user requests editing a file-backed IC's sub-circuit file.
void setScene(Scene *scene)
Associates the editor with scene to read/write selected elements.
void audioBox()
Opens the audio file selector for the selected element(s).
void update()
Refreshes the editor UI to reflect the current selection.
void sendCommand(QUndoCommand *cmd)
Emitted when a property change should be pushed onto the undo stack.
~ElementEditor() override
void fillColorComboBox()
Repopulates the color combo box with available color options.
void contextMenu(QPoint screenPos, QGraphicsItem *itemAtMouse)
Shows the element context menu at screenPos for the item under itemAtMouse.
void updateElementAppearance()
Applies the chosen appearance to the selected element(s).
void editSubcircuitRequested(const QString &blobName, int icElementId)
Emitted when the user requests editing an embedded IC sub-circuit.
void truthTable()
Opens the truth table editor for the selected element(s).
void renameAction()
Opens an inline editor to rename the selected element(s).
ElementEditor(QWidget *parent=nullptr)
Constructs the element editor with optional parent.
void updateTheme()
Applies the current theme colors to the editor widgets.
friend class ElementTabNavigator
void extractToFileRequested()
Emitted when the user requests extracting an embedded IC to file.
void changeTriggerAction()
Opens a dialog to change the trigger key for the selected element(s).
void embedSubcircuitRequested()
Emitted when the user requests embedding a file-backed IC.
void retranslateUi()
Re-applies translatable strings to all editor widgets.
Event filter that cycles scene element selection on Tab / Shift+Tab.
Abstract base class for all graphical circuit elements in wiRedPanda.
Main circuit editing scene.
Definition Scene.h:56
Describes one editable property that a GraphicElement exposes in the ElementEditor.
Computed capabilities and consensus state of the current element selection.