qwt_polar_item.cpp
Go to the documentation of this file.
1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
2  * QwtPolar Widget Library
3  * Copyright (C) 2008 Uwe Rathmann
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the Qwt License, Version 1.0
7  *****************************************************************************/
8 
9 #include "qwt_polar_plot.h"
10 #include "qwt_polar_item.h"
11 #include "qwt_legend.h"
12 #include "qwt_scale_div.h"
13 
14 #include <qpainter.h>
15 
17 {
18 public:
20  plot( NULL ),
21  isVisible( true ),
22  renderThreadCount( 1 ),
23  z( 0.0 ),
24  legendIconSize( 8, 8 )
25  {
26  }
27 
28  mutable QwtPolarPlot *plot;
29 
30  bool isVisible;
34 
35  double z;
36 
39 };
40 
49 {
50  d_data = new PrivateData;
51  d_data->title = title;
52 }
53 
56 {
57  attach( NULL );
58  delete d_data;
59 }
60 
75 {
76  if ( plot == d_data->plot )
77  return;
78 
79  if ( d_data->plot )
80  d_data->plot->attachItem( this, false );
81 
82  d_data->plot = plot;
83 
84  if ( d_data->plot )
85  d_data->plot->attachItem( this, true );
86 }
87 
96 {
97  attach( NULL );
98 }
99 
113 {
114  return Rtti_PolarItem;
115 }
116 
119 {
120  return d_data->plot;
121 }
122 
129 double QwtPolarItem::z() const
130 {
131  return d_data->z;
132 }
133 
142 void QwtPolarItem::setZ( double z )
143 {
144  if ( d_data->z != z )
145  {
146  if ( d_data->plot )
147  d_data->plot->attachItem( this, false );
148 
149  d_data->z = z;
150 
151  if ( d_data->plot )
152  d_data->plot->attachItem( this, true );
153 
154  itemChanged();
155  }
156 }
157 
164 void QwtPolarItem::setTitle( const QString &title )
165 {
166  setTitle( QwtText( title ) );
167 }
168 
176 {
177  if ( d_data->title != title )
178  {
179  d_data->title = title;
180  itemChanged();
181  }
182 }
183 
189 {
190  return d_data->title;
191 }
192 
202 {
203  if ( bool( d_data->attributes & attribute ) != on )
204  {
205  if ( on )
206  d_data->attributes |= attribute;
207  else
208  d_data->attributes &= ~attribute;
209 
210  itemChanged();
211  }
212 }
213 
222 {
223  return d_data->attributes & attribute;
224 }
225 
235 {
236  if ( ( ( d_data->renderHints & hint ) != 0 ) != on )
237  {
238  if ( on )
239  d_data->renderHints |= hint;
240  else
241  d_data->renderHints &= ~hint;
242 
243  itemChanged();
244  }
245 }
246 
255 {
256  return ( d_data->renderHints & hint );
257 }
258 
272 void QwtPolarItem::setRenderThreadCount( uint numThreads )
273 {
274  d_data->renderThreadCount = numThreads;
275 }
276 
283 {
284  return d_data->renderThreadCount;
285 }
286 
295 void QwtPolarItem::setLegendIconSize( const QSize &size )
296 {
297  if ( d_data->legendIconSize != size )
298  {
299  d_data->legendIconSize = size;
300  legendChanged();
301  }
302 }
303 
309 {
310  return d_data->legendIconSize;
311 }
312 
315 {
316  setVisible( true );
317 }
318 
321 {
322  setVisible( false );
323 }
324 
332 {
333  if ( on != d_data->isVisible )
334  {
335  d_data->isVisible = on;
336  itemChanged();
337  }
338 }
339 
345 {
346  return d_data->isVisible;
347 }
348 
356 {
357  if ( d_data->plot )
358  d_data->plot->autoRefresh();
359 }
360 
366 {
368  d_data->plot->updateLegend( this );
369 }
370 
382 {
383  Q_UNUSED( scaleId );
384 
385  return QwtInterval(); // invalid
386 }
387 
403 void QwtPolarItem::updateScaleDiv( const QwtScaleDiv &azimuthScaleDiv,
404  const QwtScaleDiv &radialScaleDiv, const QwtInterval &interval )
405 {
406  Q_UNUSED( azimuthScaleDiv );
407  Q_UNUSED( radialScaleDiv );
408  Q_UNUSED( interval );
409 }
410 
429 {
431 
432  QwtText label = title();
433  label.setRenderFlags( label.renderFlags() & Qt::AlignLeft );
434 
436  QVariant::fromValue( label ) );
437 
438  const QwtGraphic graphic = legendIcon( 0, legendIconSize() );
439  if ( !graphic.isNull() )
440  {
442  QVariant::fromValue( graphic ) );
443  }
444 
446  list += data;
447 
448  return list;
449 }
450 
463  int index, const QSizeF &size ) const
464 {
465  Q_UNUSED( index )
466  Q_UNUSED( size )
467 
468  return QwtGraphic();
469 }
470 
479 {
480  return 0;
481 }
bool isVisible() const
A plotting widget, displaying a polar coordinate system.
virtual QwtInterval boundingInterval(int scaleId) const
bool testItemAttribute(ItemAttribute) const
Unspecific value, that can be used, when it doesn&#39;t matter.
int renderFlags() const
Definition: qwt_text.cpp:294
A class representing an interval.
Definition: qwt_interval.h:22
void setRenderFlags(int)
Change the render flags.
Definition: qwt_text.cpp:281
void attach(QwtPolarPlot *plot)
Attach the item to a plot.
QwtPolarPlot * plot() const
QwtPolarItem::RenderHints renderHints
A class representing a scale division.
Definition: qwt_scale_div.h:33
void setLegendIconSize(const QSize &)
QFlags< RenderHint > RenderHints
Item attributes.
QSize legendIconSize() const
virtual void updateScaleDiv(const QwtScaleDiv &, const QwtScaleDiv &, const QwtInterval &)
Update the item to changes of the axes scale division.
PrivateData * d_data
QwtPolarItem(const QwtText &title=QwtText())
QFlags< ItemAttribute > ItemAttributes
Item attributes.
bool testRenderHint(RenderHint) const
void setItemAttribute(ItemAttribute, bool on=true)
void setRenderThreadCount(uint numThreads)
virtual QList< QwtLegendData > legendData() const
Return all information, that is needed to represent the item on the legend.
void setZ(double z)
Set the z value.
A class representing a text.
Definition: qwt_text.h:51
void autoRefresh()
Replots the plot if QwtPlot::autoReplot() is true.
ItemAttribute
Plot Item Attributes.
void detach()
This method detaches a QwtPolarItem from the QwtPolarPlot it has been associated with.
void attachItem(QwtPolarItem *, bool)
Attach/Detach a plot item.
A paint device for scalable graphics.
Definition: qwt_graphic.h:75
virtual ~QwtPolarItem()
Destroy the QwtPolarItem.
virtual int marginHint() const
virtual int rtti() const
void setTitle(const QString &title)
void show()
Show the item.
double z() const
virtual QwtGraphic legendIcon(int index, const QSizeF &) const
void setValue(int role, const QVariant &)
QwtPolarItem::ItemAttributes attributes
The item is represented on the legend.
virtual void setVisible(bool)
const QwtText & title() const
virtual void legendChanged()
RenderHint
Render hints.
bool isNull() const
dictionary data
Definition: mqtt_test.py:22
uint renderThreadCount() const
virtual void itemChanged()
Attributes of an entry on a legend.
void hide()
Hide the item.
void setRenderHint(RenderHint, bool on=true)


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