wiRedPanda
Logic Circuit Simulator
Loading...
Searching...
No Matches
SignalDelegate Class Reference

Item delegate that draws digital waveform graphics inside table cells. More...

#include <SignalDelegate.h>

Inheritance diagram for SignalDelegate:
[legend]

Public Member Functions

void paint (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
PlotType plotType () const
 Returns the current cell rendering mode.
void setPlotType (PlotType plotType)
 Selects the cell rendering mode (waveform graphics vs. numeric text).
 SignalDelegate (QObject *parent=nullptr)
 Constructs the delegate.

Static Public Member Functions

static WaveSegment segmentFor (int value, bool hasPrev, int prevValue)
 Returns the waveform segment a cell should draw.

Detailed Description

Item delegate that draws digital waveform graphics inside table cells.

Replaces the default text rendering with vector waveforms representing logic-high, logic-low, rising-edge, and falling-edge states, painted directly with QPainter at the cell's real size. Everything is derived at paint time from the SignalModel: the WaveSegment from the cell value and its left neighbour, and the input/output colour from SignalModel::isInputRow(). Nothing is stored per cell.

In Number mode (see setPlotType()) the delegate falls back to centered QItemDelegate text rendering.

Definition at line 41 of file SignalDelegate.h.

Constructor & Destructor Documentation

◆ SignalDelegate()

SignalDelegate::SignalDelegate ( QObject * parent = nullptr)
explicit

Constructs the delegate.

Definition at line 26 of file SignalDelegate.cpp.

Member Function Documentation

◆ paint()

void SignalDelegate::paint ( QPainter * painter,
const QStyleOptionViewItem & option,
const QModelIndex & index ) const
override
Reimplemented from base class.

Definition at line 74 of file SignalDelegate.cpp.

References Number, and segmentFor().

◆ plotType()

PlotType SignalDelegate::plotType ( ) const
inline

Returns the current cell rendering mode.

Definition at line 53 of file SignalDelegate.h.

Referenced by setPlotType().

◆ segmentFor()

WaveSegment SignalDelegate::segmentFor ( int value,
bool hasPrev,
int prevValue )
static

Returns the waveform segment a cell should draw.

Parameters
valueCurrent cell value (0 or 1).
hasPrevtrue if a cell exists to the left of this one.
prevValueValue of the previous cell (only meaningful when hasPrev is true).

Definition at line 36 of file SignalDelegate.cpp.

References Falling, High, Low, and Rising.

Referenced by paint().

◆ setPlotType()

void SignalDelegate::setPlotType ( PlotType plotType)

Selects the cell rendering mode (waveform graphics vs. numeric text).

Definition at line 31 of file SignalDelegate.cpp.

References plotType().


The documentation for this class was generated from the following files: