wiRedPanda
Logic Circuit Simulator
Loading...
Searching...
No Matches
GraphicElementInput.cpp
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
5
6#include "App/Wiring/Port.h"
7
8void GraphicElementInput::setOn(const bool value, const int port)
9{
10 Q_UNUSED(port)
11 m_isOn = value;
12 // Pixmap index 0 = off SVG, index 1 = on SVG (matches bool → int cast)
13 setPixmap(static_cast<int>(m_isOn));
14 if (auto *out = outputPort()) {
15 out->setStatus(static_cast<Status>(m_isOn));
16 }
17}
18
19void GraphicElementInput::setWaveformValue(const bool value, const int port)
20{
21 // Default: a waveform cell drives the port directly to its value.
22 setOn(value, port);
23}
24
25void GraphicElementInput::setAppearance(const bool defaultAppearance, const QString &fileName)
26{
27 if (defaultAppearance) {
28 m_appearance.resetAlternativeToDefault();
29 } else {
30 m_appearance.setAlternativeAppearanceAt(static_cast<int>(m_isOn), fileName);
31 }
32
33 m_appearance.setUsingDefaultAppearance(defaultAppearance);
34 setPixmap(static_cast<int>(m_isOn));
35}
Enums::Status Status
Definition Enums.h:106
Abstract base class for user-controllable input elements.
Port classes: Port (base), InputPort, and OutputPort.
void setAppearance(const bool defaultAppearance, const QString &fileName) override
virtual void setOn()=0
Sets all outputs to active (logic-1).
virtual void setWaveformValue(const bool value, const int port=0)
Applies a waveform-sweep cell value to output port.
ElementAppearance m_appearance
OutputPort * outputPort(const int index=0) const
Returns the output port at index (default 0).
void setPixmap(const QString &pixmapPath)
Loads and applies the pixmap located at pixmapPath.