QtPdWidgets  2.3.1
Classes | Public Types | Public Member Functions | Protected Member Functions | Properties | Private Slots | Private Member Functions | Private Attributes | Friends | List of all members
Pd::Graph Class Reference

Graph widget. More...

#include <Graph.h>

Inheritance diagram for Pd::Graph:
Inheritance graph
[legend]
Collaboration diagram for Pd::Graph:
Collaboration graph
[legend]

Classes

struct  Impl
 
class  Layer
 
class  TriggerDetector
 

Public Types

enum  Mode { Roll, Trigger }
 Graph mode. More...
 
enum  TriggerLevelMode { AutoLevel, ManualLevel }
 Trigger level mode. More...
 
enum  State { Run, Stop }
 Graph state. More...
 

Public Member Functions

 Graph (QWidget *parent=0)
 Constructor. More...
 
virtual ~Graph ()
 Destructor. More...
 
void setVariable (PdCom::Variable pv, const PdCom::Selector &selector={}, const QtPdCom::Transmission &=QtPdCom::event_mode, double scale=1.0, double offset=0.0, double tau=0.0, QColor color=Qt::blue)
 Subscribe to a process variable. More...
 
void setVariable (PdCom::Process *process, const QString &path, const PdCom::Selector &selector={}, const QtPdCom::Transmission &=QtPdCom::event_mode, double scale=1.0, double offset=0.0, double tau=0.0, QColor color=Qt::blue)
 
void addVariable (PdCom::Variable pv, const PdCom::Selector &selector={}, const QtPdCom::Transmission &=QtPdCom::event_mode, double scale=1.0, double offset=0.0, double tau=0.0, QColor color=Qt::blue)
 
void addVariable (PdCom::Process *process, const QString &path, const PdCom::Selector &selector={}, const QtPdCom::Transmission &=QtPdCom::event_mode, double scale=1.0, double offset=0.0, double tau=0.0, QColor color=Qt::blue)
 
void clearVariables ()
 
void clearData ()
 
void setTriggerVariable (PdCom::Variable pv, const PdCom::Selector &selector={}, const QtPdCom::Transmission &=QtPdCom::event_mode, double scale=1.0, double offset=0.0, double tau=0.0)
 Subscribe to a process variable as trigger variable. More...
 
void setTriggerVariable (PdCom::Process *process, const QString &path, const PdCom::Selector &selector={}, const QtPdCom::Transmission &=QtPdCom::event_mode, double scale=1.0, double offset=0.0, double tau=0.0)
 Subscribe to a process variable as trigger variable. More...
 
void clearTriggerVariable ()
 
Mode getMode () const
 
void setMode (Mode)
 Sets the widget's mode. More...
 
void resetMode ()
 Resets the widget's mode. More...
 
double getTimeRange () const
 
void setTimeRange (double)
 Sets the time range. More...
 
void resetTimeRange ()
 Resets the time range. More...
 
double getScaleMin () const
 
void setScaleMin (double)
 Sets the value scale's minimum value. More...
 
void resetScaleMin ()
 Resets the value scale's minimum value. More...
 
double getScaleMax () const
 
void setScaleMax (double)
 Sets the value scale's maximum value. More...
 
void resetScaleMax ()
 Resets the value scale's maximum value. More...
 
TriggerLevelMode getTriggerLevelMode () const
 
void setTriggerLevelMode (TriggerLevelMode)
 Sets the widget's triggerLevelMode. More...
 
void resetTriggerLevelMode ()
 Resets the widget's triggerLevelMode. More...
 
double getManualTriggerLevel () const
 
void setManualTriggerLevel (double)
 Sets the manualTriggerLevel. More...
 
void resetManualTriggerLevel ()
 Resets the manualTriggerLevel. More...
 
double getTriggerPosition () const
 
void setTriggerPosition (double)
 Sets the triggerPosition. More...
 
void resetTriggerPosition ()
 Resets the triggerPosition. More...
 
double getTriggerTimeout () const
 
void setTriggerTimeout (double)
 Sets the triggerTimeout. More...
 
void resetTriggerTimeout ()
 Resets the triggerTimeout. More...
 
QString getSuffix () const
 
void setSuffix (const QString &)
 Sets the suffix to display after the Y-axis values. More...
 
void resetSuffix ()
 Resets the suffix to display after the Y-axis values. More...
 
QColor getGridColor () const
 
void setGridColor (const QColor &)
 Sets the gridColor. More...
 
void resetGridColor ()
 Resets the gridColor. More...
 
bool getAutoScaleWidth () const
 
void setAutoScaleWidth (bool)
 Sets the autoScaleWidth flag. More...
 
void resetAutoScaleWidth ()
 Resets the gridColor. More...
 
Mode getEffectiveMode () const
 
virtual QSize sizeHint () const
 Gives a hint aboute the optimal size. More...
 
bool getState () const
 
void setState (State)
 Set the graph state. More...
 
void toggleState ()
 Toggle the graph state. More...
 

Protected Member Functions

bool event (QEvent *) override
 Event handler. More...
 
void resizeEvent (QResizeEvent *) override
 Handles the widget's resize event. More...
 
void paintEvent (QPaintEvent *) override
 Paint function. More...
 
void contextMenuEvent (QContextMenuEvent *) override
 Shows the context menu. More...
 

Properties

Mode mode
 
double timeRange
 The time range to display. More...
 
double scaleMin
 The minimum value on the value scale. More...
 
double scaleMax
 The maximum value on the value scale. More...
 
TriggerLevelMode triggerLevelMode
 
double manualTriggerLevel
 
double triggerPosition
 
double triggerTimeout
 
QString suffix
 
QColor gridColor
 
bool autoScaleWidth
 

Private Slots

PD_PRIVATE void redrawEvent ()
 Redraw event slot, that is called by the redraw timer. More...
 
PD_PRIVATE void run ()
 Set the graph to Run state. More...
 
PD_PRIVATE void stop ()
 Set the graph to Stop state. More...
 

Private Member Functions

PD_PRIVATE void setRedraw ()
 Mark the graph widget for redrawing. More...
 
PD_PRIVATE void notifySampled ()
 Called by the layers if the data were sampled. More...
 
PD_PRIVATE void triggerConditionDetected (std::chrono::nanoseconds)
 Called by the trgger detector, if the trigger condition was detected. More...
 
PD_PRIVATE void triggerIdle ()
 Called by the trigger detector, if no trigger condition is detected for a while. More...
 

Private Attributes

struct PD_PRIVATE Impl
 
std::unique_ptr< Implimpl
 
class PD_PRIVATE Layer
 
class PD_PRIVATE TriggerDetector
 

Friends

class Layer
 
class TriggerDetector
 

Detailed Description

Graph widget.

Member Enumeration Documentation

◆ Mode

Graph mode.

The general behaviour of the graph.

Enumerator
Roll 

Roll mode.

The right border of the widget always represents the current time, so the displayed data values 'roll' over the widget from right to left.

Trigger 

Trigger mode.

The data are recorded in a circular buffer and analyzed continuously. If the trigger condition is fulfilled, the recording is continued, until there are enough data in the buffer to display a complete snapshot.

◆ State

Graph state.

Enumerator
Run 

Incoming data shall be displayed immediately.

Stop 

Incoming data shall be processed in background, but the display shall not be changed.

◆ TriggerLevelMode

Trigger level mode.

Determines, how the trigger level is generated.

Enumerator
AutoLevel 

Automatic trigger level calculation.

ManualLevel 

Use the manualTriggerLevel property.

Constructor & Destructor Documentation

◆ Graph()

Graph::Graph ( QWidget *  parent = 0)

Constructor.

Parameters
parentparent widget

References Pd::Widget::getTimer(), impl, redrawEvent(), run(), and stop().

◆ ~Graph()

Graph::~Graph ( )
virtual

Destructor.

References clearTriggerVariable(), and clearVariables().

Member Function Documentation

◆ addVariable() [1/2]

void Graph::addVariable ( PdCom::Variable  pv,
const PdCom::Selector &  selector = {},
const QtPdCom::Transmission &  transmission = QtPdCom::event_mode,
double  scale = 1.0,
double  offset = 0.0,
double  tau = 0.0,
QColor  color = Qt::blue 
)
Parameters
pvProcess variable.
selectorSelector.
transmissionTransmission.
scaleScale factor.
offsetOffset (applied after scaling).
tauPT1 filter time constant. A value less or equal to 0.0 means, that no filter is applied.
colorGraph color.

References impl, Layer, and Pd::Graph::Layer::resizeExtrema().

Referenced by setVariable().

◆ addVariable() [2/2]

void Graph::addVariable ( PdCom::Process *  process,
const QString &  path,
const PdCom::Selector &  selector = {},
const QtPdCom::Transmission &  transmission = QtPdCom::event_mode,
double  scale = 1.0,
double  offset = 0.0,
double  tau = 0.0,
QColor  color = Qt::blue 
)
Parameters
processProcess.
pathVariable path.
selectorSelector.
transmissionTransmission.
scaleScale factor.
offsetOffset (applied after scaling).
tauPT1 filter time constant. A value less or equal to 0.0 means, that no filter is applied.
colorGraph color.

References impl, Layer, and Pd::Graph::Layer::resizeExtrema().

◆ clearData()

void Graph::clearData ( )

References impl.

Referenced by setMode(), and setTriggerPosition().

◆ clearTriggerVariable()

void Graph::clearTriggerVariable ( )

References impl.

Referenced by setTriggerVariable(), and ~Graph().

◆ clearVariables()

void Graph::clearVariables ( )

References impl.

Referenced by setVariable(), and ~Graph().

◆ contextMenuEvent()

void Graph::contextMenuEvent ( QContextMenuEvent *  event)
overrideprotected

Shows the context menu.

References event(), impl, Run, and Stop.

◆ event()

bool Graph::event ( QEvent *  event)
overrideprotected

Event handler.

Parameters
eventPaint event flags.

References impl, and toggleState().

Referenced by contextMenuEvent(), paintEvent(), and resizeEvent().

◆ getAutoScaleWidth()

bool Graph::getAutoScaleWidth ( ) const

References impl.

◆ getEffectiveMode()

Graph::Mode Graph::getEffectiveMode ( ) const

References impl.

◆ getGridColor()

QColor Graph::getGridColor ( ) const

References impl.

◆ getManualTriggerLevel()

double Graph::getManualTriggerLevel ( ) const
Returns
The manualTriggerLevel.

References impl.

◆ getMode()

Graph::Mode Graph::getMode ( ) const
Returns
The mode.

References impl.

◆ getScaleMax()

double Graph::getScaleMax ( ) const
Returns
The value scale maximum.

References impl.

◆ getScaleMin()

double Graph::getScaleMin ( ) const
Returns
The value scale minimum.

References impl.

◆ getState()

bool Graph::getState ( ) const

References impl.

◆ getSuffix()

QString Graph::getSuffix ( ) const
Returns
The suffix.

References impl.

Referenced by setSuffix().

◆ getTimeRange()

double Graph::getTimeRange ( ) const
Returns
The timeRange.

References impl.

◆ getTriggerLevelMode()

Graph::TriggerLevelMode Graph::getTriggerLevelMode ( ) const
Returns
The triggerLevelMode.

References impl.

◆ getTriggerPosition()

double Graph::getTriggerPosition ( ) const
Returns
The triggerPosition.

References impl.

◆ getTriggerTimeout()

double Graph::getTriggerTimeout ( ) const

References impl.

◆ notifySampled()

void Graph::notifySampled ( )
private

Called by the layers if the data were sampled.

References impl.

◆ paintEvent()

void Graph::paintEvent ( QPaintEvent *  event)
overrideprotected

Paint function.

Parameters
eventpaint event flags

References event(), impl, Stop, and Trigger.

◆ redrawEvent

void Graph::redrawEvent ( )
privateslot

Redraw event slot, that is called by the redraw timer.

References impl, Run, and Trigger.

Referenced by Graph().

◆ resetAutoScaleWidth()

void Graph::resetAutoScaleWidth ( )

◆ resetGridColor()

void Graph::resetGridColor ( )

Resets the gridColor.

References DEFAULT_GRID_COLOR, and setGridColor().

◆ resetManualTriggerLevel()

void Graph::resetManualTriggerLevel ( )

◆ resetMode()

void Graph::resetMode ( )

Resets the widget's mode.

References DEFAULT_MODE, and setMode().

◆ resetScaleMax()

void Graph::resetScaleMax ( )

Resets the value scale's maximum value.

References DEFAULT_SCALEMAX, and setScaleMax().

◆ resetScaleMin()

void Graph::resetScaleMin ( )

Resets the value scale's minimum value.

References DEFAULT_SCALEMIN, and setScaleMin().

◆ resetSuffix()

void Graph::resetSuffix ( )

Resets the suffix to display after the Y-axis values.

References impl.

◆ resetTimeRange()

void Graph::resetTimeRange ( )

Resets the time range.

References DEFAULT_TIMERANGE, and setTimeRange().

◆ resetTriggerLevelMode()

void Graph::resetTriggerLevelMode ( )

Resets the widget's triggerLevelMode.

References DEFAULT_TRIGGER_LEVEL_MODE, and setTriggerLevelMode().

◆ resetTriggerPosition()

void Graph::resetTriggerPosition ( )

◆ resetTriggerTimeout()

void Graph::resetTriggerTimeout ( )

◆ resizeEvent()

void Graph::resizeEvent ( QResizeEvent *  event)
overrideprotected

Handles the widget's resize event.

References event(), and impl.

◆ run

void Graph::run ( )
privateslot

Set the graph to Run state.

References Run, and setState().

Referenced by Graph().

◆ setAutoScaleWidth()

void Graph::setAutoScaleWidth ( bool  a)

Sets the autoScaleWidth flag.

References impl.

Referenced by resetAutoScaleWidth().

◆ setGridColor()

void Graph::setGridColor ( const QColor &  col)

Sets the gridColor.

References impl.

Referenced by resetGridColor().

◆ setManualTriggerLevel()

void Graph::setManualTriggerLevel ( double  l)

Sets the manualTriggerLevel.

References impl, and ManualLevel.

Referenced by resetManualTriggerLevel().

◆ setMode()

void Graph::setMode ( Mode  mode)

Sets the widget's mode.

References clearData(), impl, mode, and Roll.

Referenced by resetMode().

◆ setRedraw()

void Graph::setRedraw ( )
private

Mark the graph widget for redrawing.

References impl.

◆ setScaleMax()

void Graph::setScaleMax ( double  scale)

Sets the value scale's maximum value.

References impl.

Referenced by resetScaleMax().

◆ setScaleMin()

void Graph::setScaleMin ( double  scale)

Sets the value scale's minimum value.

References impl.

Referenced by resetScaleMin().

◆ setState()

void Graph::setState ( State  s)

Set the graph state.

References impl.

Referenced by run(), stop(), and toggleState().

◆ setSuffix()

void Graph::setSuffix ( const QString &  suffix)

Sets the suffix to display after the Y-axis values.

References getSuffix(), impl, and suffix.

◆ setTimeRange()

void Graph::setTimeRange ( double  range)

Sets the time range.

References impl.

Referenced by resetTimeRange().

◆ setTriggerLevelMode()

void Graph::setTriggerLevelMode ( TriggerLevelMode  m)

Sets the widget's triggerLevelMode.

References impl, and ManualLevel.

Referenced by resetTriggerLevelMode().

◆ setTriggerPosition()

void Graph::setTriggerPosition ( double  triggerPosition)

Sets the triggerPosition.

References clearData(), impl, and triggerPosition.

Referenced by resetTriggerPosition().

◆ setTriggerTimeout()

void Graph::setTriggerTimeout ( double  triggerTimeout)

Sets the triggerTimeout.

References impl, and triggerTimeout.

Referenced by resetTriggerTimeout().

◆ setTriggerVariable() [1/2]

void Graph::setTriggerVariable ( PdCom::Variable  pv,
const PdCom::Selector &  selector = {},
const QtPdCom::Transmission &  transmission = QtPdCom::event_mode,
double  scale = 1.0,
double  offset = 0.0,
double  tau = 0.0 
)

Subscribe to a process variable as trigger variable.

Parameters
pvProcess variable.
selectorSelector.
transmissionTransmission.
scaleScale factor.
offsetOffset (applied after scaling).
tauPT1 filter time constant. A value less or equal to 0.0 means, that no filter is applied.

References clearTriggerVariable(), and impl.

◆ setTriggerVariable() [2/2]

void Graph::setTriggerVariable ( PdCom::Process *  process,
const QString &  path,
const PdCom::Selector &  selector = {},
const QtPdCom::Transmission &  transmission = QtPdCom::event_mode,
double  scale = 1.0,
double  offset = 0.0,
double  tau = 0.0 
)

Subscribe to a process variable as trigger variable.

Parameters
processProcess.
pathVariable path.
selectorSelector.
transmissionTransmission.
scaleScale factor.
offsetOffset (applied after scaling).
tauPT1 filter time constant. A value less or equal to 0.0 means, that no filter is applied.

References clearTriggerVariable(), and impl.

◆ setVariable() [1/2]

void Graph::setVariable ( PdCom::Variable  pv,
const PdCom::Selector &  selector = {},
const QtPdCom::Transmission &  transmission = QtPdCom::event_mode,
double  scale = 1.0,
double  offset = 0.0,
double  tau = 0.0,
QColor  color = Qt::blue 
)

Subscribe to a process variable.

Parameters
pvProcess variable.
selectorSelector.
transmissionTransmission.
scaleScale factor.
offsetOffset (applied after scaling).
tauPT1 filter time constant. A value less or equal to 0.0 means, that no filter is applied.
colorGraph color.

References addVariable(), and clearVariables().

◆ setVariable() [2/2]

void Graph::setVariable ( PdCom::Process *  process,
const QString &  path,
const PdCom::Selector &  selector = {},
const QtPdCom::Transmission &  transmission = QtPdCom::event_mode,
double  scale = 1.0,
double  offset = 0.0,
double  tau = 0.0,
QColor  color = Qt::blue 
)
Parameters
processProcess.
pathVariable path.
selectorSelector.
transmissionTransmission.
scaleScale factor.
offsetOffset (applied after scaling).
tauPT1 filter time constant. A value less or equal to 0.0 means, that no filter is applied.
colorGraph color.

References addVariable(), and clearVariables().

◆ sizeHint()

QSize Graph::sizeHint ( ) const
virtual

Gives a hint aboute the optimal size.

◆ stop

void Graph::stop ( )
privateslot

Set the graph to Stop state.

References setState(), and Stop.

Referenced by Graph().

◆ toggleState()

void Graph::toggleState ( )

Toggle the graph state.

References impl, Run, setState(), and Stop.

Referenced by event().

◆ triggerConditionDetected()

void Graph::triggerConditionDetected ( std::chrono::nanoseconds  triggerTime)
private

Called by the trgger detector, if the trigger condition was detected.

References impl, and Trigger.

◆ triggerIdle()

void Graph::triggerIdle ( )
private

Called by the trigger detector, if no trigger condition is detected for a while.

References impl, and Roll.

Friends And Related Function Documentation

◆ Layer

friend class Layer
friend

◆ TriggerDetector

friend class TriggerDetector
friend

Member Data Documentation

◆ Impl

struct PD_PRIVATE Pd::Graph::Impl
private

◆ impl

std::unique_ptr<Impl> Pd::Graph::impl
private

◆ Layer

Referenced by addVariable().

◆ TriggerDetector

Property Documentation

◆ autoScaleWidth

bool Pd::Graph::autoScaleWidth
readwrite

◆ gridColor

QColor Pd::Graph::gridColor
readwrite

◆ manualTriggerLevel

double Pd::Graph::manualTriggerLevel
readwrite

◆ mode

Mode Pd::Graph::mode
readwrite

Referenced by setMode().

◆ scaleMax

double Pd::Graph::scaleMax
readwrite

The maximum value on the value scale.

◆ scaleMin

double Pd::Graph::scaleMin
readwrite

The minimum value on the value scale.

◆ suffix

QString Pd::Graph::suffix
readwrite

Referenced by setSuffix().

◆ timeRange

double Pd::Graph::timeRange
readwrite

The time range to display.

◆ triggerLevelMode

TriggerLevelMode Pd::Graph::triggerLevelMode
readwrite

◆ triggerPosition

double Pd::Graph::triggerPosition
readwrite

Referenced by setTriggerPosition().

◆ triggerTimeout

double Pd::Graph::triggerTimeout
readwrite

Referenced by setTriggerTimeout().


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