Changeset 11158 in ntrip for trunk/BNC/qwt/qwt_plot_dict.cpp
- Timestamp:
- Nov 3, 2026, 10:53:35 AM (3 weeks ago)
- File:
-
- 1 edited
-
trunk/BNC/qwt/qwt_plot_dict.cpp (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/qwt/qwt_plot_dict.cpp
r9383 r11158 1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*-*****************************1 /****************************************************************************** 2 2 * Qwt Widget Library 3 3 * Copyright (C) 1997 Josef Wilgen … … 9 9 10 10 #include "qwt_plot_dict.h" 11 #include <algorithm> 11 12 12 13 class QwtPlotDict::PrivateData 13 14 { 14 public: 15 public: 15 16 16 class ItemList: public QList<QwtPlotItem *>17 class ItemList : public QList< QwtPlotItem* > 17 18 { 18 public: 19 void insertItem( QwtPlotItem *item )19 public: 20 void insertItem( QwtPlotItem* item ) 20 21 { 21 22 if ( item == NULL ) 22 23 return; 23 24 24 QList<QwtPlotItem *>::iterator it =25 qUpperBound( begin(), end(), item, LessZThan() );25 QList< QwtPlotItem* >::iterator it = 26 std::upper_bound( begin(), end(), item, LessZThan() ); 26 27 insert( it, item ); 27 28 } 28 29 29 void removeItem( QwtPlotItem *item )30 void removeItem( QwtPlotItem* item ) 30 31 { 31 32 if ( item == NULL ) 32 33 return; 33 34 34 QList<QwtPlotItem *>::iterator it =35 qLowerBound( begin(), end(), item, LessZThan() );35 QList< QwtPlotItem* >::iterator it = 36 std::lower_bound( begin(), end(), item, LessZThan() ); 36 37 37 38 for ( ; it != end(); ++it ) … … 44 45 } 45 46 } 46 private: 47 private: 47 48 class LessZThan 48 49 { 49 public: 50 inline bool operator()( const QwtPlotItem *item1,51 const QwtPlotItem *item2 ) const50 public: 51 inline bool operator()( const QwtPlotItem* item1, 52 const QwtPlotItem* item2 ) const 52 53 { 53 54 return item1->z() < item2->z(); … … 65 66 Auto deletion is enabled. 66 67 \sa setAutoDelete(), QwtPlotItem::attach() 67 */ 68 */ 68 69 QwtPlotDict::QwtPlotDict() 69 70 { 70 d_data = new QwtPlotDict::PrivateData;71 d_data->autoDelete = true;71 m_data = new QwtPlotDict::PrivateData; 72 m_data->autoDelete = true; 72 73 } 73 74 … … 77 78 If autoDelete() is on, all attached items will be deleted 78 79 \sa setAutoDelete(), autoDelete(), QwtPlotItem::attach() 79 */ 80 */ 80 81 QwtPlotDict::~QwtPlotDict() 81 82 { 82 detachItems( QwtPlotItem::Rtti_PlotItem, d_data->autoDelete );83 delete d_data;83 detachItems( QwtPlotItem::Rtti_PlotItem, m_data->autoDelete ); 84 delete m_data; 84 85 } 85 86 … … 91 92 92 93 \sa autoDelete(), insertItem() 93 */ 94 */ 94 95 void QwtPlotDict::setAutoDelete( bool autoDelete ) 95 96 { 96 d_data->autoDelete = autoDelete;97 m_data->autoDelete = autoDelete; 97 98 } 98 99 … … 100 101 \return true if auto deletion is enabled 101 102 \sa setAutoDelete(), insertItem() 102 */ 103 */ 103 104 bool QwtPlotDict::autoDelete() const 104 105 { 105 return d_data->autoDelete;106 return m_data->autoDelete; 106 107 } 107 108 108 109 /*! 109 Insert a plot item 110 Insert a plot item 110 111 111 \param item PlotItem 112 \sa removeItem() 112 \param item PlotItem 113 \sa removeItem() 113 114 */ 114 void QwtPlotDict::insertItem( QwtPlotItem *item )115 void QwtPlotDict::insertItem( QwtPlotItem* item ) 115 116 { 116 d_data->itemList.insertItem( item );117 m_data->itemList.insertItem( item ); 117 118 } 118 119 119 120 /*! 120 Remove a plot item 121 Remove a plot item 121 122 122 \param item PlotItem 123 \sa insertItem() 123 \param item PlotItem 124 \sa insertItem() 124 125 */ 125 void QwtPlotDict::removeItem( QwtPlotItem *item )126 void QwtPlotDict::removeItem( QwtPlotItem* item ) 126 127 { 127 d_data->itemList.removeItem( item );128 m_data->itemList.removeItem( item ); 128 129 } 129 130 … … 134 135 otherwise only those items of the type rtti. 135 136 \param autoDelete If true, delete all detached items 136 */ 137 */ 137 138 void QwtPlotDict::detachItems( int rtti, bool autoDelete ) 138 139 { 139 PrivateData::ItemList list = d_data->itemList;140 PrivateData::ItemList list = m_data->itemList; 140 141 QwtPlotItemIterator it = list.constBegin(); 141 142 while ( it != list.constEnd() ) 142 143 { 143 QwtPlotItem *item = *it;144 QwtPlotItem* item = *it; 144 145 145 146 ++it; // increment before removing item from the list … … 155 156 156 157 /*! 157 \brief A QwtPlotItemList of all attached plot items. 158 \brief A QwtPlotItemList of all attached plot items. 158 159 159 Use caution when iterating these lists, as removing/detaching an item will 160 invalidate the iterator. Instead you can place pointers to objects to be 161 removed in a removal list, and traverse that list later. 160 Use caution when iterating these lists, as removing/detaching an item will 161 invalidate the iterator. Instead you can place pointers to objects to be 162 removed in a removal list, and traverse that list later. 162 163 163 \return List of all attached plot items. 164 */ 165 const QwtPlotItemList &QwtPlotDict::itemList() const164 \return List of all attached plot items. 165 */ 166 const QwtPlotItemList& QwtPlotDict::itemList() const 166 167 { 167 return d_data->itemList;168 return m_data->itemList; 168 169 } 169 170 170 171 /*! 171 \return List of all attached plot items of a specific type. 172 \param rtti See QwtPlotItem::RttiValues 173 \sa QwtPlotItem::rtti() 174 */ 172 \return List of all attached plot items of a specific type. 173 \param rtti See QwtPlotItem::RttiValues 174 \sa QwtPlotItem::rtti() 175 */ 175 176 QwtPlotItemList QwtPlotDict::itemList( int rtti ) const 176 177 { 177 178 if ( rtti == QwtPlotItem::Rtti_PlotItem ) 178 return d_data->itemList;179 return m_data->itemList; 179 180 180 181 QwtPlotItemList items; 181 182 182 PrivateData::ItemList list = d_data->itemList;183 PrivateData::ItemList list = m_data->itemList; 183 184 for ( QwtPlotItemIterator it = list.constBegin(); it != list.constEnd(); ++it ) 184 185 { 185 QwtPlotItem *item = *it;186 QwtPlotItem* item = *it; 186 187 if ( item->rtti() == rtti ) 187 188 items += item;
Note:
See TracChangeset
for help on using the changeset viewer.
