Qwt User's Guide 6.3.0
Loading...
Searching...
No Matches
qwt_polar_item.cpp
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
16class QwtPolarItem::PrivateData
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;
32 QwtPolarItem::RenderHints renderHints;
33 uint renderThreadCount;
34
35 double z;
36
37 QwtText title;
38 QSize legendIconSize;
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
129double QwtPolarItem::z() const
130{
131 return m_data->z;
132}
133
142void 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
164void QwtPolarItem::setTitle( const QString& title )
165{
166 setTitle( QwtText( title ) );
167}
168
175void 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
273{
274 m_data->renderThreadCount = numThreads;
275}
276
283{
284 return m_data->renderThreadCount;
285}
286
295void QwtPolarItem::setLegendIconSize( const QSize& size )
296{
297 if ( m_data->legendIconSize != size )
298 {
299 m_data->legendIconSize = size;
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{
367 if ( testItemAttribute( QwtPolarItem::Legend ) && m_data->plot )
368 m_data->plot->updateLegend( this );
369}
370
382{
383 Q_UNUSED( scaleId );
384
385 return QwtInterval(); // invalid
386}
387
403void 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{
430 QwtLegendData data;
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}
A paint device for scalable graphics.
Definition qwt_graphic.h:76
bool isNull() const
A class representing an interval.
Attributes of an entry on a legend.
void setValue(int role, const QVariant &)
bool testItemAttribute(ItemAttribute) const
virtual QwtInterval boundingInterval(int scaleId) const
QSize legendIconSize() const
virtual void itemChanged()
void setLegendIconSize(const QSize &)
QwtPolarItem(const QwtText &title=QwtText())
bool isVisible() const
void detach()
This method detaches a QwtPolarItem from the QwtPolarPlot it has been associated with.
void setRenderThreadCount(uint numThreads)
ItemAttribute
Plot Item Attributes.
@ Legend
The item is represented on the legend.
double z() const
virtual void updateScaleDiv(const QwtScaleDiv &, const QwtScaleDiv &, const QwtInterval &)
Update the item to changes of the axes scale division.
virtual QList< QwtLegendData > legendData() const
Return all information, that is needed to represent the item on the legend.
void setTitle(const QString &title)
const QwtText & title() const
QFlags< ItemAttribute > ItemAttributes
bool testRenderHint(RenderHint) const
@ Rtti_PolarItem
Unspecific value, that can be used, when it doesn't matter.
void hide()
Hide the item.
virtual void setVisible(bool)
QwtPolarPlot * plot() const
virtual ~QwtPolarItem()
Destroy the QwtPolarItem.
virtual int marginHint() const
QFlags< RenderHint > RenderHints
void attach(QwtPolarPlot *plot)
Attach the item to a plot.
virtual QwtGraphic legendIcon(int index, const QSizeF &) const
uint renderThreadCount() const
void setItemAttribute(ItemAttribute, bool on=true)
RenderHint
Render hints.
void show()
Show the item.
virtual void legendChanged()
void setRenderHint(RenderHint, bool on=true)
void setZ(double z)
Set the z value.
virtual int rtti() const
A plotting widget, displaying a polar coordinate system.
void autoRefresh()
Replots the plot if QwtPlot::autoReplot() is true.
A class representing a scale division.
A class representing a text.
Definition qwt_text.h:52
int renderFlags() const
Definition qwt_text.cpp:317
void setRenderFlags(int)
Change the render flags.
Definition qwt_text.cpp:304