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
27
41class SignalDelegate : public QItemDelegate
42{
43 Q_OBJECT
44
45public:
47 explicit SignalDelegate(QObject *parent = nullptr);
48
51
53 PlotType plotType() const { return m_plotType; }
54
56 void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
57
64 static WaveSegment segmentFor(int value, bool hasPrev, int prevValue);
65
66private:
68 void drawWaveform(QPainter *painter, const QRectF &cell, WaveSegment seg, bool isInput) const;
69
70 PlotType m_plotType = PlotType::Line;
71};
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).
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.