wiRedPanda
Logic Circuit Simulator
Loading...
Searching...
No Matches
SignalDelegate.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 <QItemDelegate>
11
12class QPainter;
13
15enum class PlotType {
18};
19
29
43class SignalDelegate : public QItemDelegate
44{
45 Q_OBJECT
46
47public:
49 explicit SignalDelegate(QObject *parent = nullptr);
50
53
55 PlotType plotType() const { return m_plotType; }
56
58 void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
59
66 static WaveSegment segmentFor(int value, bool hasPrev, int prevValue);
67
68private:
70 void drawWaveform(QPainter *painter, const QRectF &cell, WaveSegment seg, bool isInput) const;
71
72 PlotType m_plotType = PlotType::Line;
73};
WaveSegment
Identifies which waveform segment a Line-mode cell draws.
@ Falling
High → low transition (low plateau + leading edge).
@ Low
Logic-low plateau (signal stays at 0).
@ Rising
Low → high transition (high plateau + leading edge).
@ High
Logic-high plateau (signal stays at 1).
@ Unknown
Undefined (Status::Unknown): drawn mid-level in the canvas's "unknown" grey.
@ Error
Conflicting drivers (Status::Error): drawn mid-level in the canvas's red.
PlotType
Controls how signal cells are rendered in the waveform table.
@ Line
Cells display a waveform-style rising/falling edge graphic.
@ Number
Cells display the numeric value (0/1).
Decorative line element used for annotating circuit diagrams.
Definition Line.h:19
void setPlotType(PlotType plotType)
Selects the cell rendering mode (waveform graphics vs. numeric text).
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
PlotType plotType() const
Returns the current cell rendering mode.
static WaveSegment segmentFor(int value, bool hasPrev, int prevValue)
Returns the waveform segment a cell should draw.
SignalDelegate(QObject *parent=nullptr)
Constructs the delegate.