1
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
3
* Copyright (C) 1997 Josef Wilgen
4
* Copyright (C) 2002 Uwe Rathmann
6
* This library is free software; you can redistribute it and/or
7
* modify it under the terms of the Qwt License, Version 1.0
8
*****************************************************************************/
10
#ifndef QWT_PLOT_ITEM_H
11
#define QWT_PLOT_ITEM_H
13
#include "qwt_global.h"
14
#include "qwt_legend_itemmanager.h"
27
\brief Base class for items on the plot canvas
29
A plot item is "something", that can be painted on the plot canvas,
30
or only affects the scales of the plot widget. They can be categorized as:
33
A "Representator" is an item that represents some sort of data
34
on the plot canvas. The different representator classes are organized
35
according to the characteristics of the data:
37
Represents a point or a horizontal/vertical coordinate
39
Represents a series of points
40
- QwtPlotSpectrogram ( QwtPlotRasterItem )
41
Represents raster data
45
A "Decorator" is an item, that displays additional information, that
46
is not related to any data:
52
Depending on the QwtPlotItem::ItemAttribute flags, an item is included
53
into autoscaling or has an entry on the legnd.
55
Before misusing the existing item classes it might be better to
56
implement a new type of plot item
57
( don't implement a watermark as spectrogram ).
58
Deriving a new type of QwtPlotItem primarily means to implement
59
the YourPlotItem::draw() method.
61
\sa The cpuplot example shows the implementation of additional plot items.
64
class QWT_EXPORT QwtPlotItem: public QwtLegendItemManager
68
\brief Runtime type information
70
RttiValues is used to cast plot items, without
71
having to enable runtime type information of the compiler.
81
Rtti_PlotSpectroCurve,
82
Rtti_PlotIntervalCurve,
87
Rtti_PlotUserItem = 1000
92
\sa setItemAttribute(), testItemAttribute()
96
//! The item is represented on the legend.
100
The boundingRect() of the item is included in the
101
autoscaling calculation.
106
//! Plot Item Attributes
107
typedef QFlags<ItemAttribute> ItemAttributes;
112
//! Enable antialiasing
113
RenderAntialiased = 1
117
typedef QFlags<RenderHint> RenderHints;
119
explicit QwtPlotItem( const QwtText &title = QwtText() );
120
virtual ~QwtPlotItem();
122
void attach( QwtPlot *plot );
125
QwtPlot *plot() const;
127
void setTitle( const QString &title );
128
void setTitle( const QwtText &title );
129
const QwtText &title() const;
131
virtual int rtti() const;
133
void setItemAttribute( ItemAttribute, bool on = true );
134
bool testItemAttribute( ItemAttribute ) const;
136
void setRenderHint( RenderHint, bool on = true );
137
bool testRenderHint( RenderHint ) const;
140
void setZ( double z );
144
virtual void setVisible( bool );
145
bool isVisible () const;
147
void setAxes( int xAxis, int yAxis );
149
void setXAxis( int axis );
152
void setYAxis( int axis );
155
virtual void itemChanged();
160
\param painter Painter
161
\param xMap Maps x-values into pixel coordinates.
162
\param yMap Maps y-values into pixel coordinates.
163
\param canvasRect Contents rect of the canvas in painter coordinates
165
virtual void draw( QPainter *painter,
166
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
167
const QRectF &canvasRect ) const = 0;
169
virtual QRectF boundingRect() const;
171
virtual void updateLegend( QwtLegend * ) const;
172
virtual void updateScaleDiv(
173
const QwtScaleDiv&, const QwtScaleDiv& );
175
virtual QWidget *legendItem() const;
177
QRectF scaleRect( const QwtScaleMap &, const QwtScaleMap & ) const;
178
QRectF paintRect( const QwtScaleMap &, const QwtScaleMap & ) const;
181
// Disabled copy constructor and operator=
182
QwtPlotItem( const QwtPlotItem & );
183
QwtPlotItem &operator=( const QwtPlotItem & );
189
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotItem::ItemAttributes );
190
Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotItem::RenderHints );