wiRedPanda
Logic Circuit Simulator
Loading...
Searching...
No Matches
Display16.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
13
14class QSvgRenderer;
15
24{
25 Q_OBJECT
26
27public:
30 static constexpr const char *kDefaultColor = "Red";
31
32 // --- Lifecycle ---
33
35 explicit Display16(QGraphicsItem *parent = nullptr);
36
37 // --- Color State ---
38
40 QString color() const override;
41
46 void setColor(const QString &color) override;
47
48 // --- Visual ---
49
51 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
52
54 void refresh() override;
55
57 void updatePortsProperties() override;
58
59 // --- Serialization ---
60
62 void load(QDataStream &stream, SerializationContext &context) override;
63
65 void save(QDataStream &stream, SerializationOptions options) const override;
66
67private:
68 // --- Members ---
69
70 QString m_color = kDefaultColor;
71 QVector<QPixmap> bkg;
72 QVector<std::shared_ptr<QSvgRenderer>> a1, a2, b, c, d1, d2, e, f, g1, g2, h, j, k, l, m, n, dp;
73 int m_colorNumber = 1;
74};
Abstract base class for all graphical circuit elements.
void load(QDataStream &stream, SerializationContext &context) override
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
void setColor(const QString &color) override
Sets the display color.
void refresh() override
Refreshes the displayed segments based on current input states.
Definition Display16.cpp:92
Display16(QGraphicsItem *parent=nullptr)
Constructs the element with optional parent.
Definition Display16.cpp:68
QString color() const override
Returns the current display color name.
static constexpr const char * kDefaultColor
Definition Display16.h:30
void updatePortsProperties() override
Updates port positions (fixed at 17 inputs).
Definition Display16.cpp:97
void save(QDataStream &stream, SerializationOptions options) const override
Serializes the color selection to stream.
GraphicElement(ElementType type, QGraphicsItem *parent=nullptr)
Constructs a graphic element of the given type, fetching all properties from the metadata registry.
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...