|
wiRedPanda
Logic Circuit Simulator
|
Graphic element representing an Integrated Circuit (sub-circuit) box. More...
#include <IC.h>
Classes | |
| struct | PortMetadata |
| Port count and label metadata extracted from Input/Output elements. More... | |
Public Member Functions | |
| const QString & | blobName () const override |
| Returns the blob name for embedded ICs, empty if file-backed. | |
| QRectF | boundingRect () const override |
| QString | displayName () const |
| QStringList | externalFiles () const override |
| const QString & | file () const |
| IC (QGraphicsItem *parent=nullptr) | |
| Constructs an IC element without loading a file. | |
| void | initializeSimulation () |
| Builds the internal simulation graph (connection graph + sort) for direct simulation. | |
| const QVector< GraphicElement * > & | internalElements () const |
| const QVector< Port * > & | internalInputs () const |
| const QVector< Port * > & | internalOutputs () const |
| bool | isEmbedded () const override |
| Returns true if this element is an embedded IC (not file-backed). Base returns false. | |
| void | load (QDataStream &stream, SerializationContext &context) override |
| void | loadFile (const QString &fileName, const QString &contextDir={}) |
| Loads the IC circuit from fileName and rebuilds the logic mapping. | |
| void | loadFromBlob (const QByteArray &blob, const QString &contextDir) |
| Loads the IC from in-memory blob bytes (full .panda file format). | |
| void | loadFromDrop (const QString &fileName, const QString &contextDir) override |
| Polymorphic interface for drag-drop initialization (replaces elementType() == IC checks). | |
| void | paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override |
| void | previewCancelRequested (IC *ic) |
| void | previewHideRequested () |
| void | previewMoved (IC *ic, const QPoint &screenPos) |
| const QPixmap & | previewPixmap () const |
| void | previewRequested (IC *ic, const QPoint &screenPos) |
| void | refresh () override |
| void | requestOpenSubCircuit (int elementId, const QString &blobName, const QString &filePath) |
| Emitted on double-click to request opening the sub-circuit in a new tab. | |
| void | resettleCombinational () override |
| void | save (QDataStream &stream, SerializationOptions options) const override |
| void | setBlobName (const QString &name) |
| void | updateLogic () override |
| ~IC () override | |
| Public Member Functions inherited from GraphicElement | |
| QVector< Port * > | allPorts () const |
| Returns a combined list of all input and output ports as Port pointers. | |
| QPixmap | appearancePreviewPixmap (const int index, const QSize &size) const |
| Returns a small preview pixmap for the appearance at index (see appearanceStates()). | |
| virtual QList< std::pair< int, QString > > | appearanceStates () const |
| Returns the list of editable appearance states for this element. Each pair is (appearance list index, human-readable state description). Override in subclasses with multi-state appearances (e.g., Led). | |
| virtual QString | audio () const |
| Returns the name of the audio file currently associated with this element. | |
| void | beginDeferredCommit () |
| QRectF | boundingRect () const override |
| Returns the bounding rectangle of this element in local coordinates. | |
| bool | canChangeAppearance () const |
Returns true if the user is allowed to choose a custom appearance for this element. | |
| void | clearOutputChanged () |
| Clears the simulation output-changed flag. | |
| virtual QString | color () const |
| Returns the name of the color currently applied to this element. | |
| void | commitDeferredOutputs () |
| void | connectPredecessor (const int inputIndex, GraphicElement *source, const int outputPort) |
| Connects simulation input inputIndex to output outputPort of source element. | |
| virtual double | delay () const |
| Returns the clock phase delay in seconds (overridden by Clock; returns 0 for other elements). | |
| QList< PropertyDescriptor > | editableProperties () const |
| Returns the list of editable properties this element exposes in the ElementEditor. | |
| ElementGroup | elementGroup () const |
| Returns the group this element belongs to. | |
| ElementType | elementType () const |
| Returns the type identifier for this element. | |
| virtual double | frequency () const |
| Returns the clock frequency in Hz (overridden by Clock; returns 0 for other elements). | |
| virtual QString | genericProperties () |
| Returns a string encoding element-specific properties for serialization or display. | |
| GraphicElement (ElementType type, QGraphicsItem *parent=nullptr) | |
| Constructs a graphic element of the given type, fetching all properties from the metadata registry. | |
| bool | hasAudio () const |
Returns true if this element type supports audio output. | |
| bool | hasAudioBox () const |
Returns true if this element type shows an audio selection box. | |
| bool | hasColors () const |
Returns true if this element type supports color selection. | |
| bool | hasDelay () const |
Returns true if this element type exposes a configurable clock phase delay. | |
| bool | hasFrequency () const |
Returns true if this element type exposes a configurable clock frequency. | |
| bool | hasLabel () const |
Returns true if this element type supports a user-editable label. | |
| bool | hasTrigger () const |
Returns true if this element type supports a keyboard trigger. | |
| bool | hasTruthTable () const |
Returns true if this element type has an editable truth table. | |
| bool | hasVolume () const |
Returns true if this element type supports volume control. | |
| virtual bool | hasWirelessMode () const |
| Returns true if this element supports a configurable wireless routing mode. | |
| void | initSimulationVectors (const int inputCount, const int outputCount) |
| Allocates simulation I/O vectors with inputs inputs and outputs outputs. | |
| void | inlineEditRequested (GraphicElement *element) |
| InputPort * | inputPort (const int index=0) const |
| Returns the input port at index (default 0). | |
| const QVector< InputPort * > & | inputs () const |
| Returns a const reference to the vector of all input ports. | |
| int | inputSize () const |
| Returns the current number of input ports. | |
| bool | isFlippedX () const |
Returns true if this element is mirrored along the X axis (horizontal flip). | |
| bool | isFlippedY () const |
Returns true if this element is mirrored along the Y axis (vertical flip). | |
| bool | isValid () |
Returns true if the element is fully initialised and connected correctly. | |
| QString | label () const |
| Returns the user-visible label text for this element. | |
| QRectF | labelSceneBoundingRect () const |
| int | maxInputSize () const |
| Returns the maximum allowed number of input ports. | |
| int | maxOutputSize () const |
| Returns the maximum allowed number of output ports. | |
| int | minInputSize () const |
| Returns the minimum allowed number of input ports. | |
| int | minOutputSize () const |
| Returns the minimum allowed number of output ports. | |
| QString | nextColor () const |
| Returns the name of the next color in the element's color list. | |
| bool | outputChanged () const |
| OutputPort * | outputPort (const int index=0) const |
| Returns the output port at index (default 0). | |
| const QVector< OutputPort * > & | outputs () const |
| Returns a const reference to the vector of all output ports. | |
| int | outputSize () const |
| Returns the current number of output ports. | |
| Status | outputValue (const int index=0) const |
| Returns the four-state signal value on simulation output port index. | |
| void | paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override |
| Paints the element onto the scene. | |
| QPointF | pixmapCenter () const |
| Returns the centre point of the element's pixmap in local coordinates. | |
| QString | previousColor () const |
| Returns the name of the previous color in the element's color list. | |
| void | reapplyAppearanceOrientation () |
| virtual void | resetSimState () |
| Resets all simulation-visible state to power-on defaults. | |
| void | retranslate () |
| Updates the translated display name, tooltip, and port object name after a locale change. | |
| void | rotatePorts () |
| bool | rotatesGraphic () const |
| qreal | rotation () const |
| Returns the current rotation angle of this element in degrees. | |
| virtual void | setAppearance (const bool defaultAppearance, const QString &fileName) |
| Switches the element's appearance. | |
| void | setAppearanceAt (const int index, const QString &fileName) |
| Sets a custom appearance at a specific index in the appearance list. | |
| virtual void | setAudio (const QString &audio) |
| Sets the audio file associated with this element to audio. | |
| virtual void | setColor (const QString &color) |
| Sets the element color to color and refreshes the pixmap. | |
| virtual void | setDelay (const double delay) |
| Sets the clock phase delay to delay (overridden by clock elements). | |
| void | setFlippedX (bool flipped) |
| Sets the horizontal mirror state and updates the item transform. | |
| void | setFlippedY (bool flipped) |
| Sets the vertical mirror state and updates the item transform. | |
| virtual void | setFrequency (const double freq) |
| Sets the clock frequency to freq (overridden by clock elements). | |
| void | setInputs (const QVector< InputPort * > &inputs) |
| Replaces the input port vector with inputs. | |
| virtual void | setInputSize (const int size) |
| Adjusts the number of input ports to size, adding or removing ports as needed. | |
| void | setLabel (const QString &label) |
| Sets the label text to label and refreshes the display. | |
| virtual void | setOutputSize (const int size) |
| Adjusts the number of output ports to size, adding or removing ports as needed. | |
| void | setOutputValue (const bool value) |
Convenience overload — converts bool to Active/Inactive for port 0. | |
| void | setOutputValue (const int index, const bool value) |
Convenience overload — converts bool to Active/Inactive for port index. | |
| void | setOutputValue (const int index, const Status value) |
| Sets simulation output port index to value. | |
| void | setOutputValue (const Status value) |
| Sets simulation output port 0 to value. | |
| void | setPixmap (const int index) |
| Loads and applies the appearance at position index in the appearance list. | |
| void | setPixmap (const QString &pixmapPath) |
| Loads and applies the pixmap located at pixmapPath. | |
| void | setPortName (const QString &name) |
| Sets the object name of all ports to name for identification. | |
| void | setRotation (const qreal angle) |
| Rotates the element to angle degrees and updates port positions. | |
| void | setTrigger (const QKeySequence &trigger) |
| Sets the keyboard shortcut to trigger and updates the label. | |
| virtual void | setVolume (float vol) |
| Sets the audio playback volume to vol (0.0–1.0). | |
| const QVector< Status > & | simInputs () const |
| Read-only view of the cached simulation input values. | |
| const QVector< Status > & | simOutputs () const |
| Read-only view of the current simulation output values. | |
| qsizetype | simOutputSize () const |
| Returns the number of simulation output slots. | |
| QKeySequence | trigger () const |
| Returns the keyboard shortcut that activates this element. | |
| int | type () const override |
| Returns the custom type identifier for this item. | |
| void | updateLabel () |
| Repositions and updates the label child item to reflect current state. | |
| virtual void | updatePortsProperties () |
| Repositions and reconfigures all ports after the port count changes. | |
| virtual void | updateTheme () |
| Updates the element's visual theme according to the current dark/light palette. | |
| virtual float | volume () const |
| Returns the audio playback volume (0.0–1.0). | |
| virtual WirelessMode | wirelessMode () const |
| Returns the wireless routing mode for this element. | |
| ~GraphicElement () override | |
| Out-of-line so the unique_ptr to the forward-declared QSvgRenderer can be destroyed. | |
| Public Member Functions inherited from ItemWithId | |
| int | id () const |
| Returns the unique integer identifier of this item, or -1 if unassigned. | |
| ItemWithId ()=default | |
| Constructs a new ItemWithId with an unassigned ID of -1. | |
| void | setId (const int id) |
| Sets the identifier to id. | |
| virtual | ~ItemWithId () |
| Self-unregisters from the current SceneItemRegistry, if any. | |
Static Public Member Functions | |
| static PortMetadata | buildPortMetadata (const QVector< GraphicElement * > &elements) |
| Scans elements for Input/Output groups, sorts by Y/X position, and builds labels. | |
| Static Public Member Functions inherited from GraphicElement | |
| static int | colorNameToIndex (const QString &color) |
| Maps a color name ("White","Red","Green","Blue","Purple") to indices 0–4. | |
Protected Member Functions | |
| void | hoverEnterEvent (QGraphicsSceneHoverEvent *event) override |
| void | hoverLeaveEvent (QGraphicsSceneHoverEvent *event) override |
| void | hoverMoveEvent (QGraphicsSceneHoverEvent *event) override |
| void | mouseDoubleClickEvent (QGraphicsSceneMouseEvent *event) override |
| Protected Member Functions inherited from GraphicElement | |
| int | decodeSelectValue (int offset, int count) const |
| Decodes count select-line statuses from simInputs() into a binary index. | |
| QVariant | itemChange (GraphicsItemChange change, const QVariant &value) override |
| Handles item state changes such as position, rotation, and selection. | |
| virtual void | labelContentChanged () |
| void | mouseDoubleClickEvent (QGraphicsSceneMouseEvent *event) override |
| Requests inline label editing on double-click. | |
| QPixmap | pixmap () const |
| Returns the pixmap currently displayed by this element. | |
| QRectF | portsBoundingRect () const |
| Returns the bounding rectangle that encompasses all child ports. | |
| QRectF | renderBodyBounds () const |
| Footprint of a "procedural render body" (IC/Mux/Demux/TruthTable): the nominal 64x64 body unioned with wherever the ports actually land, which extends past it once an instance has enough ports. | |
| bool | sceneEvent (QEvent *event) override |
| Intercepts mouse-press and mouse-release events to handle Ctrl+click. | |
| void | setHasColors (const bool hasColors) |
| Sets whether this element type supports color selection. | |
| void | setLabelAnchor (const QPointF &pos) |
| void | setMaxInputSize (const int maxInputSize) |
| Sets the maximum number of input ports to maxInputSize. | |
| void | setMaxOutputSize (const int maxOutputSize) |
| Sets the maximum number of output ports to maxOutputSize. | |
| void | setMinInputSize (const int minInputSize) |
| Sets the minimum number of input ports to minInputSize. | |
| void | setMinOutputSize (const int minOutputSize) |
| Sets the minimum number of output ports to minOutputSize. | |
| bool | simUpdateInputs () |
| Snapshots each predecessor's output into the simulation input cache. | |
| bool | simUpdateInputsAllowUnknown () |
| Like simUpdateInputs(), but allows Unknown/Error values through. | |
Friends | |
| class | ICLoader |
| class | ICRenderer |
| class | ICSimulation |
| class | TestArduino |
| class | TestDanglingPointer |
| class | TestIC |
Additional Inherited Members | |
| Public Types inherited from GraphicElement | |
| enum | { Type = QGraphicsItem::UserType + 3 } |
| Protected Attributes inherited from GraphicElement | |
| ElementAppearance | m_appearance {this} |
| QGraphicsSimpleTextItem * | m_label = new QGraphicsSimpleTextItem(this) |
| Child text item that displays the label and optional trigger shortcut. | |
| QPointF | m_labelAnchor |
| The label's intended anchor point in the element's un-rotated local frame; see setLabelAnchor(). | |
| ElementPorts | m_ports {this} |
| QString | m_titleText |
| Translated title text shown in UI panels (from metadata). | |
| QString | m_translatedName |
| Translated element name used as tooltip and port object name. | |
Graphic element representing an Integrated Circuit (sub-circuit) box.
An IC element wraps a sub-circuit, exposing its input and output elements as ports on the IC box. File watching is handled by ICRegistry (centralized per-scene, one watcher per unique file path). The internal simulation graph is built lazily via initializeSimulation().
|
explicit |
Constructs an IC element without loading a file.
Definition at line 53 of file IC.cpp.
References GraphicElement::GraphicElement(), IC(), and GraphicElement::m_label.
Referenced by IC(), previewCancelRequested(), previewMoved(), and previewRequested().
|
inlineoverridevirtual |
Returns the blob name for embedded ICs, empty if file-backed.
Reimplemented from GraphicElement.
Definition at line 79 of file IC.h.
Referenced by SceneDropHandler::addFromMimeData(), SceneDropHandler::handleNewElementDrop(), icModuleKey(), and requestOpenSubCircuit().
|
override |
Definition at line 322 of file IC.cpp.
References GraphicElement::renderBodyBounds().
Referenced by ICRenderer::drawBody(), and paint().
|
static |
Scans elements for Input/Output groups, sorts by Y/X position, and builds labels.
Definition at line 259 of file IC.cpp.
References ICLoader::buildPortMetadata().
Referenced by WorkSpace::save().
| QString IC::displayName | ( | ) | const |
|
overridevirtual |
Reimplemented from GraphicElement.
Definition at line 74 of file IC.cpp.
References isEmbedded().
|
inline |
Definition at line 72 of file IC.h.
Referenced by icModuleKey(), and WorkSpace::save().
|
overrideprotected |
Definition at line 290 of file IC.cpp.
References previewHideRequested(), and previewRequested().
|
overrideprotected |
Definition at line 316 of file IC.cpp.
References previewHideRequested().
|
overrideprotected |
Definition at line 302 of file IC.cpp.
References previewHideRequested(), and previewMoved().
| void IC::initializeSimulation | ( | ) |
Builds the internal simulation graph (connection graph + sort) for direct simulation.
Definition at line 344 of file IC.cpp.
References ICSimulation::initialize().
|
inline |
|
inlineoverridevirtual |
Returns true if this element is an embedded IC (not file-backed). Base returns false.
Reimplemented from GraphicElement.
Definition at line 81 of file IC.h.
Referenced by ICRenderer::drawBody(), externalFiles(), icModuleKey(), and save().
|
overridevirtual |
Reimplemented from GraphicElement.
Definition at line 98 of file IC.cpp.
References SerializationContext::blobRegistry, SerializationContext::contextDir, VersionInfo::hasLabels(), VersionInfo::hasQMapFormat(), GraphicElement::inputs(), GraphicElement::load(), loadFile(), loadFromBlob(), GraphicElement::outputs(), PANDACEPTION, SerializationContext::portMap, Serialization::readBoundedMetadata(), Serialization::readBoundedString(), and SerializationContext::version.
| void IC::loadFile | ( | const QString & | fileName, |
| const QString & | contextDir = {} ) |
Loads the IC circuit from fileName and rebuilds the logic mapping.
Definition at line 243 of file IC.cpp.
References ICLoader::loadFile().
Referenced by ICRegistry::extractToFile(), load(), and loadFromDrop().
| void IC::loadFromBlob | ( | const QByteArray & | blob, |
| const QString & | contextDir ) |
Loads the IC from in-memory blob bytes (full .panda file format).
Definition at line 248 of file IC.cpp.
References ICLoader::loadFromBlob().
Referenced by ICRegistry::createEmbeddedIC(), ICRegistry::embedICsByFile(), ICRegistry::initEmbeddedIC(), load(), and WorkSpace::onChildICBlobSaved().
|
overridevirtual |
Polymorphic interface for drag-drop initialization (replaces elementType() == IC checks).
Reimplemented from GraphicElement.
Definition at line 254 of file IC.cpp.
References loadFile().
|
overrideprotected |
Definition at line 264 of file IC.cpp.
References previewCancelRequested(), and requestOpenSubCircuit().
|
override |
Definition at line 327 of file IC.cpp.
References boundingRect(), ICRenderer::drawBody(), and GraphicElement::m_appearance.
| void IC::previewCancelRequested | ( | IC * | ic | ) |
References IC().
Referenced by Scene::addItem(), and mouseDoubleClickEvent().
| void IC::previewHideRequested | ( | ) |
Referenced by Scene::addItem(), hoverEnterEvent(), hoverLeaveEvent(), and hoverMoveEvent().
| void IC::previewMoved | ( | IC * | ic, |
| const QPoint & | screenPos ) |
References IC().
Referenced by Scene::addItem(), and hoverMoveEvent().
|
inline |
Returns the cached preview pixmap of the designed circuit. The snapshot is taken once during load (before boundary elements are substituted with proxy Nodes), so the preview reflects what the user actually placed — buttons, switches, LEDs — not the simulation graph.
| void IC::previewRequested | ( | IC * | ic, |
| const QPoint & | screenPos ) |
Hover-preview lifecycle signals. The UI layer (SceneUiBinder) drives the shared ICPreviewPopup off these, so IC needs no dependency on MainWindow. ic is this.
References IC().
Referenced by Scene::addItem(), and hoverEnterEvent().
|
overridevirtual |
Reimplemented from GraphicElement.
| void IC::requestOpenSubCircuit | ( | int | elementId, |
| const QString & | blobName, | ||
| const QString & | filePath ) |
Emitted on double-click to request opening the sub-circuit in a new tab.
References blobName().
Referenced by Scene::addItem(), and mouseDoubleClickEvent().
|
overridevirtual |
Reimplemented from GraphicElement.
Definition at line 354 of file IC.cpp.
References ICSimulation::resettle().
|
overridevirtual |
Reimplemented from GraphicElement.
Definition at line 83 of file IC.cpp.
References ExternalFilePath::forWriting(), isEmbedded(), SerializationOptions::purpose, and GraphicElement::save().
Referenced by ICRenderer::drawBody().
|
inline |
Definition at line 80 of file IC.h.
Referenced by ICRegistry::createEmbeddedIC(), ICRegistry::embedICsByFile(), ICRegistry::initEmbeddedIC(), and ICRegistry::renameBlob().
|
overridevirtual |
Reimplemented from GraphicElement.
Definition at line 349 of file IC.cpp.
References ICSimulation::update().
|
friend |
Reach ic's internal-element/port vectors and protected GraphicElement members (pixmap(), portsBoundingRect(), setMax/MinInputSize/OutputSize(), etc.) directly; see ICLoader / ICRenderer / ICSimulation.
Definition at line 41 of file IC.h.
References ICLoader.
Referenced by ICLoader.
|
friend |
|
friend |
|
friend |
|
friend |
Definition at line 36 of file IC.h.
References TestDanglingPointer.
Referenced by TestDanglingPointer.
|
friend |