qwt_plot_graphicitem.cpp
Go to the documentation of this file.
1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
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:
20  {
21  }
22 
23  QRectF boundingRect;
25 };
26 
37  QwtPlotItem( QwtText( title ) )
38 {
39  init();
40 }
41 
52  QwtPlotItem( title )
53 {
54  init();
55 }
56 
59 {
60  delete d_data;
61 }
62 
64 {
65  d_data = new PrivateData();
67 
70 
71  setZ( 8.0 );
72 }
73 
76 {
78 }
79 
87  const QRectF &rect, const QwtGraphic &graphic )
88 {
89  d_data->boundingRect = rect;
91 
92  legendChanged();
93  itemChanged();
94 }
95 
101 {
102  return d_data->graphic;
103 }
104 
107 {
108  return d_data->boundingRect;
109 }
110 
119 void QwtPlotGraphicItem::draw( QPainter *painter,
120  const QwtScaleMap &xMap, const QwtScaleMap &yMap,
121  const QRectF &canvasRect ) const
122 {
123  if ( d_data->graphic.isEmpty() )
124  return;
125 
126  QRectF r = QwtScaleMap::transform( xMap, yMap, boundingRect() );
127 
128  if ( !r.intersects( canvasRect ) )
129  return;
130 
131  if ( QwtPainter::roundingAlignment( painter ) )
132  {
133  r.setLeft ( qRound( r.left() ) );
134  r.setRight ( qRound( r.right() ) );
135  r.setTop ( qRound( r.top() ) );
136  r.setBottom ( qRound( r.bottom() ) );
137  }
138 
139  d_data->graphic.render( painter, r );
140 }
virtual void legendChanged()
For QwtPlotGraphicItem, QwtPlotSvgItem.
virtual int rtti() const QWT_OVERRIDE
void render(QPainter *) const
Replay all recorded painter commands.
virtual QRectF boundingRect() const QWT_OVERRIDE
Bounding rectangle of the item.
virtual ~QwtPlotGraphicItem()
Destructor.
The item is represented on the legend.
QwtGraphic graphic() const
A class representing a text.
Definition: qwt_text.h:51
void setZ(double z)
Set the z value.
A paint device for scalable graphics.
Definition: qwt_graphic.h:75
A scale map.
Definition: qwt_scale_map.h:26
virtual void itemChanged()
virtual void draw(QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect) const QWT_OVERRIDE
QwtPlotGraphicItem(const QString &title=QString())
Constructor.
bool isEmpty() const
Base class for items on the plot canvas.
Definition: qwt_plot_item.h:65
void setItemAttribute(ItemAttribute, bool on=true)
double transform(double s) const
void setGraphic(const QRectF &rect, const QwtGraphic &)
static bool roundingAlignment()
Definition: qwt_painter.h:181
const QwtText & title() const
virtual QRectF boundingRect() const


plotjuggler
Author(s): Davide Faconti
autogenerated on Sun Dec 6 2020 03:48:10