wiRedPanda
Logic Circuit Simulator
Loading...
Searching...
No Matches
TruthTable.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 TruthTable(QGraphicsItem *parent = nullptr);
28
29 // --- Key Access ---
30
32 QBitArray &key();
34 void setkey(const QBitArray &key);
35
36 // --- Visual ---
37
39 QRectF boundingRect() const override;
41 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
43 void update();
44
46 void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override;
47
48signals:
51
52public:
54 void updateLogic() override;
55
57 void updatePortsProperties() override;
58
59 // --- Serialization ---
60
62 void load(QDataStream &stream, SerializationContext &context) override;
64 void save(QDataStream &stream, SerializationOptions options) const override;
65
66private:
67 // --- Internal methods ---
68
69 void generatePixmap();
70
73 void drawBody(QPainter *painter);
74
75 QBitArray m_key;
76};
Abstract base class for all graphical circuit elements.
GraphicElement(ElementType type, QGraphicsItem *parent=nullptr)
Constructs a graphic element of the given type, fetching all properties from the metadata registry.
void setkey(const QBitArray &key)
Sets the truth-table output bit-array to key.
void updatePortsProperties() override
Resizes the truth-table key when input or output count changes.
void requestOpenTruthTableEditor()
Emitted on double-click to request opening the truth table editor.
QBitArray & key()
Returns a reference to the truth-table output bit-array.
QRectF boundingRect() const override
void load(QDataStream &stream, SerializationContext &context) override
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
void save(QDataStream &stream, SerializationOptions options) const override
void update()
Forces a repaint of the element.
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override
void updateLogic() override
Looks up the current input pattern in the truth table and drives outputs.
TruthTable(QGraphicsItem *parent=nullptr)
Constructs the element with optional parent.
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...