OpenCurves  0.9
PlotView Class Reference

An plot view viewing a Curves model. More...

#include <plotview.h>

Inheritance diagram for PlotView:

Public Types

enum  ToolMode { MultiTool, PanTool, ZoomTool, ToolModeCount }
 Modes for various interaction tools. More...
 
typedef QFrame Super
 Parent class alias.
 

Public Slots

void zoomToFit ()
 Change the current zoom level to fit the currently selected plots. More...
 
void setSynchronised (bool sync)
 Set or clear the synchronisation flag for this view. More...
 
void setToolMode (ToolMode mode)
 Set the tool mode for this view. More...
 
void setMultiTool ()
 Set the tool mode to MultiTool.
 
void setPanTool ()
 Set the tool mode to PanTool.
 
void setZoomTool ()
 Set the tool mode to ZoomTool.
 
void setLegendPosition (int pos)
 Set the legend position. More...
 
void copyToClipboard ()
 Copies the current plot view content to the clipboard. More...
 

Signals

void focusGained ()
 Emitted when this PlotView gains focus. More...
 
void focusLost ()
 Emitted when this PlotView looses focus. More...
 
void synchronisedChanged (bool sync)
 Emitted when the synchronised() flag changed. More...
 
void toolModeChanged (ToolMode mode)
 Emitted when the current tool mode is changed. More...
 
void legendChanged (QwtLegend *legend, int position)
 The legend or its position has been changed, possibly to null. More...
 

Public Member Functions

 PlotView (Curves *curves, QWidget *parent=nullptr)
 Create a view into curves.
 
 ~PlotView ()
 Destructor.
 
void showNone ()
 Clear viewing of all items. No notification triggered.
 
void loadSettings (QSettings &settings)
 Load settings for this view. More...
 
void saveSettings (QSettings &settings)
 Save settings for this view. More...
 
QwtPlot * plot ()
 Access the primary plotting widget. More...
 
const QwtPlot * plot () const
 Access the primary plotting widget. More...
 
ToolMode toolMode () const
 Get the current tool mode. More...
 
int legendPosition () const
 Request the current legend position. More...
 
bool synchronised () const
 Get the synchronisation state. More...
 
PlotZoomerzoomer () const
 Access the zooming tool. More...
 
PlotPannerpanner () const
 Access the panning tool. More...
 
void setHighlight (bool active)
 Set to display in the highlight or not. More...
 
bool isHighlighted () const
 Request the current highlight state (as per setHighlight()). More...
 
void updateActive (const QStringList &sourceNames, const QStringList &curveNames)
 Updates which plots and files this view is showing. More...
 
const QStringList & activeSourceNames () const
 Retrieves the list of active sources this view is displaying, or expecting to display. More...
 
const QStringList & visibleCurveNames () const
 Retrieves the list of visible curves this view is displaying, or expecting to display. More...
 

Static Public Attributes

static const int SharedLegend
 Special index for shared legend.
 

Protected Slots

void addCurve (PlotInstance *curve)
 Handles a new curve definition by creating an appropriate display interface. More...
 
void removeCurve (const PlotInstance *curve)
 Handles curve removal or deletion, removing the corresponding display adaptor. More...
 
void curveDataChanged (const PlotInstance *curve)
 Handles changes to curve data. More...
 
void curvesCleared ()
 Handles removal of all curves. More...
 
void legendSelectionChanged (int index)
 Handles changes to the legend position combo box. More...
 
void toolActionToggled (bool checked)
 Ensures the current tool action stays checked. More...
 

Friends

class FocusPlot
 

Detailed Description

An plot view viewing a Curves model.

The view maintains its own visibility status including list of visible files, curves zoom level and position.

Member Enumeration Documentation

Modes for various interaction tools.

Enumerator
MultiTool 

Pan/zoom combined tool.

PanTool 

Pan only tool.

ZoomTool 

Zoom only tool.

Member Function Documentation

const QStringList& PlotView::activeSourceNames ( ) const
inline

Retrieves the list of active sources this view is displaying, or expecting to display.

This is set in updateActive().

Returns
A list of source names this view can display.
void PlotView::addCurve ( PlotInstance curve)
protectedslot

Handles a new curve definition by creating an appropriate display interface.

The new curve is initially visible only if its source and name are present in activeSourceNames() and visibleCurveNames() respectively.

Handler for Curves::curveAdded()

Parameters
curveThe new curve.
void PlotView::copyToClipboard ( )
slot

Copies the current plot view content to the clipboard.

The current curves and legend (if not shared) are rendered to a bitmap and added to the system clipboard. The size of the bitmap matches the plot() size.

This call does nothing if there is no system clipboard, determined by whether QApplication::clipboard() is null or not.

void PlotView::curveDataChanged ( const PlotInstance curve)
protectedslot

Handles changes to curve data.

This updates the display adaptor for curve and may replot if the curve is visible. The method assumes all data may be invalidated as there is no specification for what has changed.

Parameters
curveThe curve which has been modified or invalidated.
void PlotView::curvesCleared ( )
protectedslot

Handles removal of all curves.

The activeSourceNames() and visibleCurveNames() remain unchanged.

Handler for Curves::curvesCleared()

void PlotView::focusGained ( )
signal

Emitted when this PlotView gains focus.

This intercepts focusing of the contained plot().

void PlotView::focusLost ( )
signal

Emitted when this PlotView looses focus.

This based on focus loss of the contained plot().

bool PlotView::isHighlighted ( ) const

Request the current highlight state (as per setHighlight()).

Returns
True if the highlight is active.
void PlotView::legendChanged ( QwtLegend *  legend,
int  position 
)
signal

The legend or its position has been changed, possibly to null.

Parameters
legendThe new legend object, or null if position is SharedLegend.
positionThe new legend position; one of QwtLegend::LegendPosition or SharedLegend.
int PlotView::legendPosition ( ) const

Request the current legend position.

The result corresponds to QwtPlot::LegendPosition with an additional possible value of SharedLegend.

The SharedLeged is not handled by this view as the semantics imply higher level handling at a single, shared level.

Returns
The current legend position, as indicated by QwtPlot::LegendPosition or SharedLegend.
void PlotView::legendSelectionChanged ( int  index)
protectedslot

Handles changes to the legend position combo box.

May emit legendChanged()

Parameters
indexThe new legend position index.
void PlotView::loadSettings ( QSettings &  settings)

Load settings for this view.

Parameters
settingsThe settings object to use.
See also
saveSettings()
PlotPanner* PlotView::panner ( ) const
inline

Access the panning tool.

Returns
The panning tool belonging to this view.
QwtPlot* PlotView::plot ( )
inline

Access the primary plotting widget.

The widget is a child of this object.

Returns
The QwtPlot used to display the curves.
const QwtPlot* PlotView::plot ( ) const
inline

Access the primary plotting widget.

The widget is a child of this object.

Returns
The QwtPlot used to display the curves.
void PlotView::removeCurve ( const PlotInstance curve)
protectedslot

Handles curve removal or deletion, removing the corresponding display adaptor.

The visibleCurveNames() remains unchanged.

Handler for Curves::curveRemoved()

Parameters
curveThe curve being removed (and likely to be deleted).
void PlotView::saveSettings ( QSettings &  settings)

Save settings for this view.

Stores the following items:

Key Data Item
sources list of activeSourceNames()
visible list of visibleCurveNames()
sync synchronised() state
legend The legendPosition()
tool The toolMode()
Zoom settings See PlotZoomer::saveSettings()
Parameters
settingsThe settings object to use.
void PlotView::setHighlight ( bool  active)

Set to display in the highlight or not.

This affects the display border.

Parameters
activeTrue to activate the highlight.
void PlotView::setLegendPosition ( int  pos)
slot

Set the legend position.

The pos must be in range or the call is ignored.

On changing the legend position, the legendChanged() signal is raised.

Parameters
posThe new legend position. Must be one of QwtLegend::LegendPosition values, or SharedLegend.
void PlotView::setSynchronised ( bool  sync)
slot

Set or clear the synchronisation flag for this view.

Raises the synchronisedChanged() signal.

Parameters
syncTrue to enable view synchronisation.
See also
synchronised()
void PlotView::setToolMode ( ToolMode  mode)
slot

Set the tool mode for this view.

Raises the toolModeChanged() signal.

Parameters
modeThe mode to set.
See also
ToolMode

Referenced by setMultiTool(), setPanTool(), and setZoomTool().

bool PlotView::synchronised ( ) const
inline

Get the synchronisation state.

A synchronised plot view is expected to keep its panning and zoom levels in sync with one or more other PlotView objects. This flag simply indicates the desired internal state and synchronisation is managed at a higher level.

Returns
True if the view should be synchronised with other views.
void PlotView::synchronisedChanged ( bool  sync)
signal

Emitted when the synchronised() flag changed.

Parameters
syncThe new flag value.
void PlotView::toolActionToggled ( bool  checked)
protectedslot

Ensures the current tool action stays checked.

Handler for all tool mode actions.

Todo:
Validate if this is made obsolete by the PlotViewToolbar.
Parameters
checkedThe new checked state for the QAction sending the signal.
ToolMode PlotView::toolMode ( ) const
inline

Get the current tool mode.

Returns
The current tool mode.
void PlotView::toolModeChanged ( ToolMode  mode)
signal

Emitted when the current tool mode is changed.

Parameters
modeThe new ToolMode.
void PlotView::updateActive ( const QStringList &  sourceNames,
const QStringList &  curveNames 
)

Updates which plots and files this view is showing.

To display, a curve must have a source name matching one of the sourceNames and a curve name matching one of the curveNames.

The allActiveSources may be used as the collated list of sources being displayed by any active view. This ensures all curves are colour shifted the same way when provided to all views.

Parameters
sourceNamesThe list of sources to display.
curveNamesThe list of curves to display from the sources.
const QStringList& PlotView::visibleCurveNames ( ) const
inline

Retrieves the list of visible curves this view is displaying, or expecting to display.

This is set in updateActive().

Returns
A list of curve names this view can display.
PlotZoomer* PlotView::zoomer ( ) const
inline

Access the zooming tool.

Returns
The zooming tool belonging to this view.
void PlotView::zoomToFit ( )
slot

Change the current zoom level to fit the currently selected plots.

This resets the zoom-stack and enabled auto-scaling on both axes.

Raises the PlotZoomer::zoomed() signal from zoomer().


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