wiRedPanda
Logic Circuit Simulator
Loading...
Searching...
No Matches
Demux.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
19class Demux : public GraphicElement
20{
21 Q_OBJECT
22
23public:
24 // --- Lifecycle ---
25
27 explicit Demux(QGraphicsItem *parent = nullptr);
28
29 // --- Visual / Port Configuration ---
30
32 QRectF boundingRect() const override;
33
35 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
36
38 void setOutputSize(const int size) override;
39
41 void updatePortsProperties() override;
42
44 void updateLogic() override;
45
46private:
47 void generatePixmap();
48
51 void drawBody(QPainter *painter);
52
53 // Prevent direct input size setting - inputs are derived from output size
54 void setInputSize(const int size) override;
55
60 static int calculateSelectLines(int dataCount);
61};
Abstract base class for all graphical circuit elements.
void updateLogic() override
Routes the data input to the output selected by the select lines.
Definition Demux.cpp:196
QRectF boundingRect() const override
Definition Demux.cpp:121
void updatePortsProperties() override
Recalculates port positions for the current port count.
Definition Demux.cpp:81
void setOutputSize(const int size) override
Definition Demux.cpp:60
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
Definition Demux.cpp:179
Demux(QGraphicsItem *parent=nullptr)
Constructs the element with optional parent.
Definition Demux.cpp:46
GraphicElement(ElementType type, QGraphicsItem *parent=nullptr)
Constructs a graphic element of the given type, fetching all properties from the metadata registry.