qwt_polar_itemdict.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_itemdict.h"
10 
12 {
13  public:
14  class ItemList : public QList< QwtPolarItem* >
15  {
16  public:
17  void insertItem( QwtPolarItem* item )
18  {
19  if ( item == NULL )
20  return;
21 
22  // Unfortunately there is no inSort operation
23  // for lists in Qt4. The implementation below
24  // is slow, but there shouldn't be many plot items.
25 
27  for ( it = begin(); it != end(); ++it )
28  {
29  if ( *it == item )
30  return;
31 
32  if ( ( *it )->z() > item->z() )
33  {
34  insert( it, item );
35  return;
36  }
37  }
38  append( item );
39  }
40 
41  void removeItem( QwtPolarItem* item )
42  {
43  if ( item == NULL )
44  return;
45 
46  int i = 0;
47 
49  for ( it = begin(); it != end(); ++it )
50  {
51  if ( item == *it )
52  {
53  removeAt( i );
54  return;
55  }
56  i++;
57  }
58  }
59  };
60 
61  ItemList itemList;
62  bool autoDelete;
63 };
64 
72 {
74  m_data->autoDelete = true;
75 }
76 
84 {
86  delete m_data;
87 }
88 
97 void QwtPolarItemDict::setAutoDelete( bool autoDelete )
98 {
100 }
101 
107 {
108  return m_data->autoDelete;
109 }
110 
118 {
119  m_data->itemList.insertItem( item );
120 }
121 
129 {
130  m_data->itemList.removeItem( item );
131 }
132 
140 void QwtPolarItemDict::detachItems( int rtti, bool autoDelete )
141 {
143  QwtPolarItemIterator it = list.constBegin();
144  while ( it != list.constEnd() )
145  {
146  QwtPolarItem* item = *it;
147 
148  ++it; // increment before removing item from the list
149 
150  if ( rtti == QwtPolarItem::Rtti_PolarItem || item->rtti() == rtti )
151  {
152  item->attach( NULL );
153  if ( autoDelete )
154  delete item;
155  }
156  }
157 }
158 
169 {
170  return m_data->itemList;
171 }
QwtPolarItem::Rtti_PolarItem
@ Rtti_PolarItem
Unspecific value, that can be used, when it doesn't matter.
Definition: qwt_polar_item.h:49
QwtPolarItemDict::PrivateData::itemList
ItemList itemList
Definition: qwt_polar_itemdict.cpp:67
QwtPolarItemDict::PrivateData
Definition: qwt_polar_itemdict.cpp:11
QwtPolarItemDict::QwtPolarItemDict
QwtPolarItemDict()
Definition: qwt_polar_itemdict.cpp:71
QwtPolarItemDict::PrivateData::autoDelete
bool autoDelete
Definition: qwt_polar_itemdict.cpp:68
QwtPolarItemDict::PrivateData::ItemList::removeItem
void removeItem(QwtPolarItem *item)
Definition: qwt_polar_itemdict.cpp:53
QwtPolarItemDict::setAutoDelete
void setAutoDelete(bool)
Definition: qwt_polar_itemdict.cpp:97
QwtPolarItem::rtti
virtual int rtti() const
Definition: qwt_polar_item.cpp:112
QwtPolarItemDict::~QwtPolarItemDict
~QwtPolarItemDict()
Definition: qwt_polar_itemdict.cpp:83
QList
Definition: qwt_abstract_legend.h:17
QwtPolarItem::z
double z() const
Definition: qwt_polar_item.cpp:129
QwtPolarItemDict::itemList
const QwtPolarItemList & itemList() const
A QwtPolarItemList of all attached plot items.
Definition: qwt_polar_itemdict.cpp:168
QwtPolarItemDict::PrivateData::ItemList::insertItem
void insertItem(QwtPolarItem *item)
Definition: qwt_polar_itemdict.cpp:29
append
QCXXHighlighter::QCXXHighlighter(QTextDocument *document) m_highlightRule append)({ QRegularExpression(R"(#[a-zA-Z_]+)"), "Preprocessor" })
Definition: QCXXHighlighter.cpp:60
QwtPolarItem
Base class for items on a polar plot.
Definition: qwt_polar_item.h:37
QwtPolarItemDict::autoDelete
bool autoDelete() const
Definition: qwt_polar_itemdict.cpp:106
QwtPolarItemDict::removeItem
void removeItem(QwtPolarItem *)
Definition: qwt_polar_itemdict.cpp:128
QwtPolarItem::attach
void attach(QwtPolarPlot *plot)
Attach the item to a plot.
Definition: qwt_polar_item.cpp:74
QwtPolarItemDict::insertItem
void insertItem(QwtPolarItem *)
Definition: qwt_polar_itemdict.cpp:117
QwtPolarItemDict::detachItems
void detachItems(int rtti=QwtPolarItem::Rtti_PolarItem, bool autoDelete=true)
Definition: qwt_polar_itemdict.cpp:140
QwtPolarItemIterator
QList< QwtPolarItem * >::ConstIterator QwtPolarItemIterator
Definition: qwt_polar_itemdict.h:16
QwtPolarItemDict::PrivateData::ItemList
Definition: qwt_polar_itemdict.cpp:20
QwtPolarItemDict::m_data
PrivateData * m_data
Definition: qwt_polar_itemdict.h:47
qwt_polar_itemdict.h


plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:46