qwt_polar_item.cpp
Go to the documentation of this file.
1 /******************************************************************************
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;
31  QwtPolarItem::ItemAttributes attributes;
32  QwtPolarItem::RenderHints renderHints;
34 
35  double z;
36 
39 };
40 
49 {
50  m_data = new PrivateData;
51  m_data->title = title;
52 }
53 
56 {
57  attach( NULL );
58  delete m_data;
59 }
60 
75 {
76  if ( plot == m_data->plot )
77  return;
78 
79  if ( m_data->plot )
80  m_data->plot->attachItem( this, false );
81 
82  m_data->plot = plot;
83 
84  if ( m_data->plot )
85  m_data->plot->attachItem( this, true );
86 }
87 
96 {
97  attach( NULL );
98 }
99 
113 {
114  return Rtti_PolarItem;
115 }
116 
119 {
120  return m_data->plot;
121 }
122 
129 double QwtPolarItem::z() const
130 {
131  return m_data->z;
132 }
133 
142 void QwtPolarItem::setZ( double z )
143 {
144  if ( m_data->z != z )
145  {
146  if ( m_data->plot )
147  m_data->plot->attachItem( this, false );
148 
149  m_data->z = z;
150 
151  if ( m_data->plot )
152  m_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 ( m_data->title != title )
178  {
179  m_data->title = title;
180  itemChanged();
181  }
182 }
183 
189 {
190  return m_data->title;
191 }
192 
202 {
203  if ( bool( m_data->attributes & attribute ) != on )
204  {
205  if ( on )
206  m_data->attributes |= attribute;
207  else
208  m_data->attributes &= ~attribute;
209 
210  itemChanged();
211  }
212 }
213 
222 {
223  return m_data->attributes & attribute;
224 }
225 
235 {
236  if ( ( ( m_data->renderHints & hint ) != 0 ) != on )
237  {
238  if ( on )
239  m_data->renderHints |= hint;
240  else
241  m_data->renderHints &= ~hint;
242 
243  itemChanged();
244  }
245 }
246 
255 {
256  return ( m_data->renderHints & hint );
257 }
258 
272 void QwtPolarItem::setRenderThreadCount( uint numThreads )
273 {
274  m_data->renderThreadCount = numThreads;
275 }
276 
283 {
284  return m_data->renderThreadCount;
285 }
286 
296 {
297  if ( m_data->legendIconSize != size )
298  {
300  legendChanged();
301  }
302 }
303 
309 {
310  return m_data->legendIconSize;
311 }
312 
315 {
316  setVisible( true );
317 }
318 
321 {
322  setVisible( false );
323 }
324 
332 {
333  if ( on != m_data->isVisible )
334  {
335  m_data->isVisible = on;
336  itemChanged();
337  }
338 }
339 
345 {
346  return m_data->isVisible;
347 }
348 
356 {
357  if ( m_data->plot )
358  m_data->plot->autoRefresh();
359 }
360 
366 {
368  m_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 }
const QwtText & title() const
bool testRenderHint(RenderHint) const
A plotting widget, displaying a polar coordinate system.
uint renderThreadCount() const
QSize legendIconSize() const
Unspecific value, that can be used, when it doesn&#39;t matter.
A class representing an interval.
Definition: qwt_interval.h:22
void setRenderFlags(int)
Change the render flags.
Definition: qwt_text.cpp:304
void attach(QwtPolarPlot *plot)
Attach the item to a plot.
QwtPolarItem::RenderHints renderHints
bool isVisible() const
A class representing a scale division.
Definition: qwt_scale_div.h:33
void setLegendIconSize(const QSize &)
virtual QList< QwtLegendData > legendData() const
Return all information, that is needed to represent the item on the legend.
QwtPolarPlot * plot() const
virtual void updateScaleDiv(const QwtScaleDiv &, const QwtScaleDiv &, const QwtInterval &)
Update the item to changes of the axes scale division.
virtual QwtGraphic legendIcon(int index, const QSizeF &) const
QwtPolarItem(const QwtText &title=QwtText())
virtual QwtInterval boundingInterval(int scaleId) const
void setItemAttribute(ItemAttribute, bool on=true)
void setRenderThreadCount(uint numThreads)
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
PrivateData * m_data
void setTitle(const QString &title)
void show()
Show the item.
void setValue(int role, const QVariant &)
QwtPolarItem::ItemAttributes attributes
The item is represented on the legend.
virtual int rtti() const
virtual void setVisible(bool)
double z() const
virtual void legendChanged()
bool isNull() const
span_constexpr std::size_t size(span< T, Extent > const &spn)
Definition: span.hpp:1485
bool testItemAttribute(ItemAttribute) const
RenderHint
Render hints.
dictionary data
Definition: mqtt_test.py:22
virtual void itemChanged()
int renderFlags() const
Definition: qwt_text.cpp:317
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 Mon Jun 19 2023 03:01:39