10#include "qwt_plot_item.h"
13#include "qwt_legend_data.h"
14#include "qwt_scale_map.h"
15#include "qwt_graphic.h"
19class QwtPlotItem::PrivateData
25 , renderThreadCount( 1 )
29 , legendIconSize( 8, 8 )
41 uint renderThreadCount;
57 m_data =
new PrivateData;
66 m_data =
new PrivateData;
67 m_data->title =
title;
76 m_data =
new PrivateData;
77 m_data->title =
title;
100 if (
plot == m_data->plot )
104 m_data->plot->attachItem(
this,
false );
109 m_data->plot->attachItem(
this,
true );
167 if ( m_data->z !=
z )
170 m_data->plot->attachItem(
this,
false );
175 m_data->plot->attachItem(
this,
true );
200 if ( m_data->title !=
title )
202 m_data->title =
title;
217 return m_data->title;
230 if ( m_data->attributes.testFlag( attribute ) != on )
233 m_data->attributes |= attribute;
235 m_data->attributes &= ~attribute;
268 return m_data->attributes.testFlag( attribute );
281 if ( m_data->interests.testFlag( interest ) != on )
284 m_data->interests |= interest;
286 m_data->interests &= ~interest;
301 return m_data->interests.testFlag( interest );
314 if ( m_data->renderHints.testFlag( hint ) != on )
317 m_data->renderHints |= hint;
319 m_data->renderHints &= ~hint;
334 return m_data->renderHints.testFlag( hint );
352 m_data->renderThreadCount = numThreads;
362 return m_data->renderThreadCount;
375 if ( m_data->legendIconSize != size )
377 m_data->legendIconSize = size;
388 return m_data->legendIconSize;
403 int index,
const QSizeF& size )
const
423 const QBrush& brush,
const QSizeF& size )
const
426 if ( !size.isEmpty() )
430 QRectF r( 0, 0, size.width(), size.height() );
432 QPainter painter( &icon );
433 painter.fillRect( r, brush );
459 if ( on != m_data->isVisible )
461 m_data->isVisible = on;
472 return m_data->isVisible;
510 m_data->xAxisId = xAxisId;
513 m_data->yAxisId = yAxisId;
530 m_data->xAxisId = axisId;
547 m_data->yAxisId = axisId;
555 return m_data->xAxisId;
561 return m_data->yAxisId;
570 return QRectF( 1.0, 1.0, -2.0, -2.0 );
597 double& left,
double& top,
double& right,
double& bottom )
const
601 Q_UNUSED( canvasRect );
604 left = top = right = bottom = 0.0;
633 data.
setValue( QwtLegendData::TitleRole,
634 QVariant::fromValue( label ) );
639 data.
setValue( QwtLegendData::IconRole,
640 QVariant::fromValue( graphic ) );
668 Q_UNUSED( xScaleDiv );
669 Q_UNUSED( yScaleDiv );
708 return QRectF( xMap.
s1(), yMap.
s1(),
723 const QRectF rect( xMap.
p1(), yMap.
p1(),
A paint device for scalable graphics.
void setDefaultSize(const QSizeF &)
Set a default size.
Attributes of an entry on a legend.
void setValue(int role, const QVariant &)
void autoRefresh()
Replots the plot if autoReplot() is true.
Base class for items on the plot canvas.
QwtAxisId yAxis() const
Return yAxis.
void setLegendIconSize(const QSize &)
QRectF paintRect(const QwtScaleMap &, const QwtScaleMap &) const
Calculate the bounding paint rectangle of 2 maps.
QFlags< ItemInterest > ItemInterests
void setRenderThreadCount(uint numThreads)
virtual QwtGraphic legendIcon(int index, const QSizeF &) const
void setTitle(const QString &title)
void hide()
Hide the item.
virtual ~QwtPlotItem()
Destroy the QwtPlotItem.
virtual QList< QwtLegendData > legendData() const
Return all information, that is needed to represent the item on the legend.
virtual void legendChanged()
const QwtText & title() const
QRectF scaleRect(const QwtScaleMap &, const QwtScaleMap &) const
Calculate the bounding scale rectangle of 2 maps.
QFlags< RenderHint > RenderHints
QFlags< ItemAttribute > ItemAttributes
void setZ(double z)
Set the z value.
void setItemAttribute(ItemAttribute, bool on=true)
virtual void setVisible(bool)
QwtPlot * plot() const
Return attached plot.
QwtAxisId xAxis() const
Return xAxis.
bool testItemInterest(ItemInterest) const
void show()
Show the item.
QwtGraphic defaultIcon(const QBrush &, const QSizeF &) const
Return a default icon from a brush.
@ Rtti_PlotItem
Unspecific value, that can be used, when it doesn't matter.
void detach()
This method detaches a QwtPlotItem from any QwtPlot it has been associated with.
void setItemInterest(ItemInterest, bool on=true)
virtual void updateScaleDiv(const QwtScaleDiv &, const QwtScaleDiv &)
Update the item to changes of the axes scale division.
bool testItemAttribute(ItemAttribute) const
void setAxes(QwtAxisId xAxis, QwtAxisId yAxis)
bool testRenderHint(RenderHint) const
void setRenderHint(RenderHint, bool on=true)
virtual void itemChanged()
ItemAttribute
Plot Item Attributes.
@ Legend
The item is represented on the legend.
uint renderThreadCount() const
virtual void getCanvasMarginHint(const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, double &left, double &top, double &right, double &bottom) const
Calculate a hint for the canvas margin.
void attach(QwtPlot *plot)
Attach the item to a plot.
virtual QRectF boundingRect() const
virtual void updateLegend(const QwtPlotItem *, const QList< QwtLegendData > &)
Update the item to changes of the legend info.
QSize legendIconSize() const
ItemInterest
Plot Item Interests.
A class representing a scale division.
A class representing a text.
void setRenderFlags(int)
Change the render flags.
bool isYAxis(int axisPos)
@ XBottom
X axis below the canvas.
@ YLeft
Y axis left of the canvas.
bool isXAxis(int axisPos)