qwt_plot_graphicitem.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  * Qwt Widget Library
3  * Copyright (C) 1997 Josef Wilgen
4  * Copyright (C) 2002 Uwe Rathmann
5  *
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  *****************************************************************************/
9 
10 #include "qwt_plot_graphicitem.h"
11 #include "qwt_scale_map.h"
12 #include "qwt_painter.h"
13 #include "qwt_text.h"
14 #include "qwt_graphic.h"
15 
17 {
18  public:
19  QRectF boundingRect;
21 };
22 
33  : QwtPlotItem( QwtText( title ) )
34 {
35  init();
36 }
37 
48  : QwtPlotItem( title )
49 {
50  init();
51 }
52 
55 {
56  delete m_data;
57 }
58 
60 {
61  m_data = new PrivateData();
63 
66 
67  setZ( 8.0 );
68 }
69 
72 {
74 }
75 
83  const QRectF& rect, const QwtGraphic& graphic )
84 {
85  m_data->boundingRect = rect;
87 
88  legendChanged();
89  itemChanged();
90 }
91 
97 {
98  return m_data->graphic;
99 }
100 
103 {
104  return m_data->boundingRect;
105 }
106 
115 void QwtPlotGraphicItem::draw( QPainter* painter,
116  const QwtScaleMap& xMap, const QwtScaleMap& yMap,
117  const QRectF& canvasRect ) const
118 {
119  if ( m_data->graphic.isEmpty() )
120  return;
121 
122  QRectF r = QwtScaleMap::transform( xMap, yMap, boundingRect() );
123 
124  if ( !r.intersects( canvasRect ) )
125  return;
126 
127  if ( QwtPainter::roundingAlignment( painter ) )
128  {
129  r.setLeft ( qRound( r.left() ) );
130  r.setRight ( qRound( r.right() ) );
131  r.setTop ( qRound( r.top() ) );
132  r.setBottom ( qRound( r.bottom() ) );
133  }
134 
135  m_data->graphic.render( painter, r );
136 }
qwt_graphic.h
qwt_plot_graphicitem.h
QwtPlotGraphicItem::draw
virtual void draw(QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect) const QWT_OVERRIDE
Definition: qwt_plot_graphicitem.cpp:115
QwtPlotItem::legendChanged
virtual void legendChanged()
Definition: qwt_plot_item.cpp:491
QwtGraphic::isEmpty
bool isEmpty() const
Definition: qwt_graphic.cpp:422
QwtGraphic
A paint device for scalable graphics.
Definition: qwt_graphic.h:75
QwtPlotGraphicItem::rtti
virtual int rtti() const QWT_OVERRIDE
Definition: qwt_plot_graphicitem.cpp:71
QwtPlotGraphicItem::PrivateData
Definition: qwt_plot_graphicitem.cpp:16
QwtPlotItem::Legend
@ Legend
The item is represented on the legend.
Definition: qwt_plot_item.h:150
QwtPlotGraphicItem::m_data
PrivateData * m_data
Definition: qwt_plot_graphicitem.h:58
QwtPainter::roundingAlignment
static bool roundingAlignment()
Definition: qwt_painter.h:183
QwtPlotGraphicItem::PrivateData::graphic
QwtGraphic graphic
Definition: qwt_plot_graphicitem.cpp:27
QwtPlotItem::boundingRect
virtual QRectF boundingRect() const
Definition: qwt_plot_item.cpp:568
QwtPlotItem::AutoScale
@ AutoScale
Definition: qwt_plot_item.h:157
QwtPlotGraphicItem::init
void init()
Definition: qwt_plot_graphicitem.cpp:59
QwtPlotGraphicItem::setGraphic
void setGraphic(const QRectF &rect, const QwtGraphic &)
Definition: qwt_plot_graphicitem.cpp:82
QwtPlotGraphicItem::boundingRect
virtual QRectF boundingRect() const QWT_OVERRIDE
Bounding rectangle of the item.
Definition: qwt_plot_graphicitem.cpp:102
QwtPlotGraphicItem::graphic
QwtGraphic graphic() const
Definition: qwt_plot_graphicitem.cpp:96
QwtPlotGraphicItem::PrivateData::boundingRect
QRectF boundingRect
Definition: qwt_plot_graphicitem.cpp:26
qwt_scale_map.h
QwtText
A class representing a text.
Definition: qwt_text.h:51
QwtPlotItem::setZ
void setZ(double z)
Set the z value.
Definition: qwt_plot_item.cpp:165
QwtPlotItem
Base class for items on the plot canvas.
Definition: qwt_plot_item.h:66
QwtPlotGraphicItem::QwtPlotGraphicItem
QwtPlotGraphicItem(const QString &title=QString())
Constructor.
Definition: qwt_plot_graphicitem.cpp:32
QwtPlotItem::Rtti_PlotGraphic
@ Rtti_PlotGraphic
For QwtPlotGraphicItem, QwtPlotSvgItem.
Definition: qwt_plot_item.h:108
QwtScaleMap::transform
double transform(double s) const
Definition: qwt_scale_map.h:137
QwtPlotItem::itemChanged
virtual void itemChanged()
Definition: qwt_plot_item.cpp:481
QwtScaleMap
A scale map.
Definition: qwt_scale_map.h:26
qwt_painter.h
QwtPlotItem::setItemAttribute
void setItemAttribute(ItemAttribute, bool on=true)
Definition: qwt_plot_item.cpp:228
QwtPlotGraphicItem::~QwtPlotGraphicItem
virtual ~QwtPlotGraphicItem()
Destructor.
Definition: qwt_plot_graphicitem.cpp:54
qwt_text.h
QwtGraphic::render
void render(QPainter *) const
Replay all recorded painter commands.
Definition: qwt_graphic.cpp:624


plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:45