Workspace 6.21.5
Signals | Public Member Functions | Protected Member Functions | List of all members
PlotWidget Class Reference

Renders a plot and stores it as an image until the next render. More...

#include <DataAnalysis/Plot2D/Widgets/plotwidget.h>

Inherits QFrame.

Signals

void message (const QString &message)
 
void resized (QSize s)
 
void titleChanged (const QString &title)
 

Public Member Functions

 PlotWidget (QWidget *parent=nullptr)
 
void render (const Plot &plot, const QSize &plotSize)
 

Protected Member Functions

void contextMenuEvent (QContextMenuEvent *event) override
 
bool event (QEvent *event) override
 
void paintEvent (QPaintEvent *event) override
 
void resizeEvent (QResizeEvent *event) override
 

Detailed Description

Think of this as a caching plotter. Once a Plot has been rendered, it is saved as an image. If the widget is resized, the image is also resized. The resultant image will be distorted, but at least it should be a sufficiently suitable image to show until the plot can be re-rendered. This makes repaints very quick when the widget size is not changed, but more importantly the Plot object only needs to be available for the short period when the image is being updated. The Plot doesn't even have to exist any more after that because only the cached image is used after render() returns. This is the main reason why the widget works as it does, since it allows the widget to be connected to a Plot input/output on a workspace and only require interactions with the workspace itself when the plot changes or the widget is resized. Ordinary repaints don't involve the underlying workspace at all.

Constructor & Destructor Documentation

◆ PlotWidget()

PlotWidget ( QWidget *  parent = nullptr)

Member Function Documentation

◆ contextMenuEvent()

void contextMenuEvent ( QContextMenuEvent *  event)
overrideprotected

◆ event()

bool event ( QEvent *  event)
overrideprotected

Silently absorbs tooltip events. All other events are passed through to the base class for normal event handling.

◆ message

void message ( const QString &  message)
signal

◆ paintEvent()

void paintEvent ( QPaintEvent *  event)
overrideprotected

Shows the last rendered image, scaled to fit if necessary.

◆ render()

void render ( const Plot plot,
const QSize &  plotSize 
)
Parameters
plotThe plot whose data should be rendered.
plotSizeThe desired size to render to. Note that because calls to render() can be made from any thread, not just the widget's thread, it cannot be assumed that the widget's size is what should be used. Update the cached image used during repaints. The current size of the widget determines the size of the image. Once render() returns, no further reference is made to plot. In fact, plot can safely be deleted immediately after render() returns.

◆ resized

void resized ( QSize  s)
signal

◆ resizeEvent()

void resizeEvent ( QResizeEvent *  event)
overrideprotected

Normally, a resize event triggers an immediate repaint. That's fine, but we also emit a resized() event to allow an external entity to update the image to be painted because the image is now a different size. This means we get a lower quality image immediately and then an improved image after whatever responds to resized() causes the image to be updated via a call to render().

◆ titleChanged

void titleChanged ( const QString &  title)
signal