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:
19  PrivateData()
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;
33  uint renderThreadCount;
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 
175 void QwtPolarItem::setTitle( const QwtText& title )
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 
435  data.setValue( QwtLegendData::TitleRole,
436  QVariant::fromValue( label ) );
437 
438  const QwtGraphic graphic = legendIcon( 0, legendIconSize() );
439  if ( !graphic.isNull() )
440  {
441  data.setValue( QwtLegendData::IconRole,
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 }
QwtPolarItem::detach
void detach()
This method detaches a QwtPolarItem from the QwtPolarPlot it has been associated with.
Definition: qwt_polar_item.cpp:95
QwtPolarItem::PrivateData
Definition: qwt_polar_item.cpp:16
QwtPolarPlot::updateLegend
void updateLegend()
Definition: qwt_polar_plot.cpp:252
QwtPolarItem::Rtti_PolarItem
@ Rtti_PolarItem
Unspecific value, that can be used, when it doesn't matter.
Definition: qwt_polar_item.h:49
QwtLegendData
Attributes of an entry on a legend.
Definition: qwt_legend_data.h:36
QwtPolarItem::~QwtPolarItem
virtual ~QwtPolarItem()
Destroy the QwtPolarItem.
Definition: qwt_polar_item.cpp:55
QwtPolarItem::testItemAttribute
bool testItemAttribute(ItemAttribute) const
Definition: qwt_polar_item.cpp:221
QwtPolarPlot
A plotting widget, displaying a polar coordinate system.
Definition: qwt_polar_plot.h:46
QwtPolarItem::setItemAttribute
void setItemAttribute(ItemAttribute, bool on=true)
Definition: qwt_polar_item.cpp:201
QwtPolarItem::PrivateData::isVisible
bool isVisible
Definition: qwt_polar_item.cpp:36
qwt_scale_div.h
QwtPolarItem::Legend
@ Legend
The item is represented on the legend.
Definition: qwt_polar_item.h:77
QwtPolarItem::legendData
virtual QList< QwtLegendData > legendData() const
Return all information, that is needed to represent the item on the legend.
Definition: qwt_polar_item.cpp:428
QwtGraphic
A paint device for scalable graphics.
Definition: qwt_graphic.h:75
QwtPolarItem::marginHint
virtual int marginHint() const
Definition: qwt_polar_item.cpp:478
QwtPolarItem::setTitle
void setTitle(const QString &title)
Definition: qwt_polar_item.cpp:164
QwtPolarItem::boundingInterval
virtual QwtInterval boundingInterval(int scaleId) const
Definition: qwt_polar_item.cpp:381
QwtPolarItem::rtti
virtual int rtti() const
Definition: qwt_polar_item.cpp:112
QwtPolarItem::renderThreadCount
uint renderThreadCount() const
Definition: qwt_polar_item.cpp:282
QwtLegendData::TitleRole
@ TitleRole
Definition: qwt_legend_data.h:59
QwtText::setRenderFlags
void setRenderFlags(int)
Change the render flags.
Definition: qwt_text.cpp:304
QList
Definition: qwt_abstract_legend.h:17
QwtPolarItem::PrivateData::legendIconSize
QSize legendIconSize
Definition: qwt_polar_item.cpp:44
QwtPolarItem::z
double z() const
Definition: qwt_polar_item.cpp:129
QwtPolarItem::legendChanged
virtual void legendChanged()
Definition: qwt_polar_item.cpp:365
QwtPolarItem::setZ
void setZ(double z)
Set the z value.
Definition: qwt_polar_item.cpp:142
mqtt_test_proto.z
z
Definition: mqtt_test_proto.py:36
QwtPolarPlot::attachItem
void attachItem(QwtPolarItem *, bool)
Attach/Detach a plot item.
Definition: qwt_polar_plot.cpp:1293
QwtPolarPlot::autoRefresh
void autoRefresh()
Replots the plot if QwtPlot::autoReplot() is true.
Definition: qwt_polar_plot.cpp:847
QwtPolarItem::PrivateData::renderHints
QwtPolarItem::RenderHints renderHints
Definition: qwt_polar_item.cpp:38
QwtPolarItem::RenderHint
RenderHint
Render hints.
Definition: qwt_polar_item.h:92
nonstd::span_lite::size
span_constexpr std::size_t size(span< T, Extent > const &spn)
Definition: span.hpp:1554
QwtPolarItem::ItemAttribute
ItemAttribute
Plot Item Attributes.
Definition: qwt_polar_item.h:74
QwtPolarItem::PrivateData::plot
QwtPolarPlot * plot
Definition: qwt_polar_item.cpp:34
QwtInterval
A class representing an interval.
Definition: qwt_interval.h:22
QwtPolarItem::title
const QwtText & title() const
Definition: qwt_polar_item.cpp:188
QwtText
A class representing a text.
Definition: qwt_text.h:51
QwtPolarItem::m_data
PrivateData * m_data
Definition: qwt_polar_item.h:165
QwtPolarItem::itemChanged
virtual void itemChanged()
Definition: qwt_polar_item.cpp:355
QwtPolarItem::QwtPolarItem
QwtPolarItem(const QwtText &title=QwtText())
Definition: qwt_polar_item.cpp:48
QwtPolarItem::setRenderHint
void setRenderHint(RenderHint, bool on=true)
Definition: qwt_polar_item.cpp:234
QwtPolarItem::PrivateData::z
double z
Definition: qwt_polar_item.cpp:41
QwtText::renderFlags
int renderFlags() const
Definition: qwt_text.cpp:317
QwtPolarItem::legendIconSize
QSize legendIconSize() const
Definition: qwt_polar_item.cpp:308
qwt_legend.h
QwtPolarItem::setVisible
virtual void setVisible(bool)
Definition: qwt_polar_item.cpp:331
QwtGraphic::isNull
bool isNull() const
Definition: qwt_graphic.cpp:413
QwtPolarItem::PrivateData::attributes
QwtPolarItem::ItemAttributes attributes
Definition: qwt_polar_item.cpp:37
QwtPolarItem::PrivateData::title
QwtText title
Definition: qwt_polar_item.cpp:43
QwtPolarItem::updateScaleDiv
virtual void updateScaleDiv(const QwtScaleDiv &, const QwtScaleDiv &, const QwtInterval &)
Update the item to changes of the axes scale division.
Definition: qwt_polar_item.cpp:403
QwtPolarItem::attach
void attach(QwtPolarPlot *plot)
Attach the item to a plot.
Definition: qwt_polar_item.cpp:74
QwtPolarItem::isVisible
bool isVisible() const
Definition: qwt_polar_item.cpp:344
mqtt_test.data
dictionary data
Definition: mqtt_test.py:22
QwtPolarItem::hide
void hide()
Hide the item.
Definition: qwt_polar_item.cpp:320
qwt_polar_item.h
qwt_polar_plot.h
QwtPolarItem::setLegendIconSize
void setLegendIconSize(const QSize &)
Definition: qwt_polar_item.cpp:295
QwtPolarItem::legendIcon
virtual QwtGraphic legendIcon(int index, const QSizeF &) const
Definition: qwt_polar_item.cpp:462
QwtScaleDiv
A class representing a scale division.
Definition: qwt_scale_div.h:33
QwtPolarItem::testRenderHint
bool testRenderHint(RenderHint) const
Definition: qwt_polar_item.cpp:254
QwtPolarItem::plot
QwtPolarPlot * plot() const
Definition: qwt_polar_item.cpp:118
QwtPolarItem::PrivateData::PrivateData
PrivateData()
Definition: qwt_polar_item.cpp:25
QwtPolarItem::show
void show()
Show the item.
Definition: qwt_polar_item.cpp:314
QwtLegendData::IconRole
@ IconRole
Definition: qwt_legend_data.h:62
QwtPolarItem::PrivateData::renderThreadCount
uint renderThreadCount
Definition: qwt_polar_item.cpp:39
QwtPolarItem::setRenderThreadCount
void setRenderThreadCount(uint numThreads)
Definition: qwt_polar_item.cpp:272


plotjuggler
Author(s): Davide Faconti
autogenerated on Sun Aug 11 2024 02:24:24