qwt_plot_dict.cpp
Go to the documentation of this file.
1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
2  * Qwt Widget Library
3  * Copyright (C) 1997 Josef Wilgen
4  * Copyright (C) 2002 Uwe Rathmann
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the Qwt License, Version 1.0
8  *****************************************************************************/
9 
10 #include "qwt_plot_dict.h"
11 
13 {
14 public:
15 
16  class ItemList: public QList<QwtPlotItem *>
17  {
18  public:
19  void insertItem( QwtPlotItem *item )
20  {
21  if ( item == NULL )
22  return;
23 
24  QList<QwtPlotItem *>::iterator it =
25  qUpperBound( begin(), end(), item, LessZThan() );
26  insert( it, item );
27  }
28 
29  void removeItem( QwtPlotItem *item )
30  {
31  if ( item == NULL )
32  return;
33 
34  QList<QwtPlotItem *>::iterator it =
35  qLowerBound( begin(), end(), item, LessZThan() );
36 
37  for ( ; it != end(); ++it )
38  {
39  if ( item == *it )
40  {
41  erase( it );
42  break;
43  }
44  }
45  }
46  private:
47  class LessZThan
48  {
49  public:
50  inline bool operator()( const QwtPlotItem *item1,
51  const QwtPlotItem *item2 ) const
52  {
53  return item1->z() < item2->z();
54  }
55  };
56  };
57 
59  bool autoDelete;
60 };
61 
69 {
71  d_data->autoDelete = true;
72 }
73 
81 {
83  delete d_data;
84 }
85 
95 {
97 }
98 
104 {
105  return d_data->autoDelete;
106 }
107 
115 {
116  d_data->itemList.insertItem( item );
117 }
118 
126 {
127  d_data->itemList.removeItem( item );
128 }
129 
137 void QwtPlotDict::detachItems( int rtti, bool autoDelete )
138 {
140  QwtPlotItemIterator it = list.begin();
141  while ( it != list.end() )
142  {
143  QwtPlotItem *item = *it;
144 
145  ++it; // increment before removing item from the list
146 
147  if ( rtti == QwtPlotItem::Rtti_PlotItem || item->rtti() == rtti )
148  {
149  item->attach( NULL );
150  if ( autoDelete )
151  delete item;
152  }
153  }
154 }
155 
166 {
167  return d_data->itemList;
168 }
169 
176 {
177  if ( rtti == QwtPlotItem::Rtti_PlotItem )
178  return d_data->itemList;
179 
181 
183  for ( QwtPlotItemIterator it = list.begin(); it != list.end(); ++it )
184  {
185  QwtPlotItem *item = *it;
186  if ( item->rtti() == rtti )
187  items += item;
188  }
189 
190  return items;
191 }
auto items(const Map &m) -> std::vector< std::pair< typename Map::key_type, typename Map::mapped_type >>
virtual int rtti() const
char * begin
void insertItem(QwtPlotItem *)
QList< QwtPlotItem * > QwtPlotItemList
See QT 4.x assistant documentation for QList.
Definition: qwt_plot_dict.h:20
const QwtPlotItemList & itemList() const
A QwtPlotItemList of all attached plot items.
PrivateData * d_data
Definition: qwt_plot_dict.h:54
QList< QwtPlotItem * >::ConstIterator QwtPlotItemIterator
Definition: qwt_plot_dict.h:21
char * end
void insertItem(QwtPlotItem *item)
bool autoDelete() const
void detachItems(int rtti=QwtPlotItem::Rtti_PlotItem, bool autoDelete=true)
double z() const
void setAutoDelete(bool)
void attach(QwtPlot *plot)
Attach the item to a plot.
bool operator()(const QwtPlotItem *item1, const QwtPlotItem *item2) const
void removeItem(QwtPlotItem *item)
virtual ~QwtPlotDict()
Base class for items on the plot canvas.
Definition: qwt_plot_item.h:64
void removeItem(QwtPlotItem *)
Unspecific value, that can be used, when it doesn&#39;t matter.
Definition: qwt_plot_item.h:76


plotjuggler
Author(s): Davide Faconti
autogenerated on Sat Jul 6 2019 03:44:17