wiRedPanda
Logic Circuit Simulator
Loading...
Searching...
No Matches
InputSwitch.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
11
20{
21 Q_OBJECT
22
23public:
24 // --- Lifecycle ---
25
27 explicit InputSwitch(QGraphicsItem *parent = nullptr);
28
29 // --- State Queries ---
30
32 bool isOn(const int port = 0) const override;
33
34 // --- State Setters ---
35
37 void setOff() override;
38
40 void setOn() override;
41
42 // Bring the base setOn(bool, int) overload into scope (hidden by setOn() above).
44
46 QList<std::pair<int, QString>> appearanceStates() const override;
47
48 // --- Serialization ---
49
51 void load(QDataStream &stream, SerializationContext &context) override;
53 void save(QDataStream &stream, SerializationOptions options) const override;
54
55protected:
56 // --- Event handlers ---
57
59 void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
60};
Abstract base class for user-controllable input elements.
virtual void setOn()=0
Sets all outputs to active (logic-1).
GraphicElementInput(ElementType type, QGraphicsItem *parent=nullptr)
void setOn() override
Sets the switch to the on (logic-1) state (toggles; see implementation).
InputSwitch(QGraphicsItem *parent=nullptr)
Constructs the element with optional parent.
void load(QDataStream &stream, SerializationContext &context) override
void save(QDataStream &stream, SerializationOptions options) const override
bool isOn(const int port=0) const override
Returns true if output port port is driven logic-high.
void mousePressEvent(QGraphicsSceneMouseEvent *event) override
QList< std::pair< int, QString > > appearanceStates() const override
void setOff() override
Drives all output ports logic-low (toggles; see implementation).
Bundles all per-deserialization state so that load() overrides receive it through one explicit parame...
Options passed to GraphicElement::save() (and friends); the save-side counterpart of SerializationCon...