wiRedPanda
Logic Circuit Simulator
Loading...
Searching...
No Matches
Display7.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 Port;
15class QSvgRenderer;
16
25{
26 Q_OBJECT
27
28public:
31 static constexpr const char *kDefaultColor = "Red";
32
33 // --- Lifecycle ---
34
36 explicit Display7(QGraphicsItem *parent = nullptr);
37
38 // --- Color utilities ---
39
43 static QVector<std::shared_ptr<QSvgRenderer>> cachedSegmentRenderers(const QString &resourcePath);
44
45 // --- Color State ---
46
48 QString color() const override;
49
54 void setColor(const QString &color) override;
55
56 // --- Visual ---
57
59 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
60
62 void refresh() override;
63
65 void updatePortsProperties() override;
66
67 // --- Serialization ---
68
70 void load(QDataStream &stream, SerializationContext &context) override;
71
73 void save(QDataStream &stream, SerializationOptions options) const override;
74
75private:
76 // --- Members ---
77
78 QString m_color = kDefaultColor;
79 QVector<std::shared_ptr<QSvgRenderer>> a, b, c, d, e, f, g, dp;
80 int m_colorNumber = 1;
81};
Abstract base class for all graphical circuit elements.
QString color() const override
Returns the current display color name.
Definition Display7.cpp:177
void load(QDataStream &stream, SerializationContext &context) override
Definition Display7.cpp:196
void save(QDataStream &stream, SerializationOptions options) const override
Serializes the color selection to stream.
Definition Display7.cpp:182
void updatePortsProperties() override
Updates port positions (fixed at 8 inputs).
Definition Display7.cpp:128
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
Definition Display7.cpp:153
void refresh() override
Refreshes the displayed segments based on current input states.
Definition Display7.cpp:123
static constexpr const char * kDefaultColor
Definition Display7.h:31
static QVector< std::shared_ptr< QSvgRenderer > > cachedSegmentRenderers(const QString &resourcePath)
Definition Display7.cpp:94
Display7(QGraphicsItem *parent=nullptr)
Constructs the element with optional parent.
Definition Display7.cpp:79
void setColor(const QString &color) override
Sets the display color.
Definition Display7.cpp:171
GraphicElement(ElementType type, QGraphicsItem *parent=nullptr)
Constructs a graphic element of the given type, fetching all properties from the metadata registry.
Abstract base class for circuit element ports (connection endpoints).
Definition Port.h:39
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...