CurveDataVector.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright (C) 2015 by Ralf Kaestner *
3  * ralf.kaestner@gmail.com *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the Lesser GNU General Public License as published by*
7  * the Free Software Foundation; either version 3 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * Lesser GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the Lesser GNU General Public License *
16  * along with this program. If not, see <http://www.gnu.org/licenses/>. *
17  ******************************************************************************/
18 
20 
21 namespace rqt_multiplot {
22 
23 /*****************************************************************************/
24 /* Constructors and Destructor */
25 /*****************************************************************************/
26 
28 }
29 
31 }
32 
33 /*****************************************************************************/
34 /* Accessors */
35 /*****************************************************************************/
36 
38  return points_.count();
39 }
40 
41 QPointF CurveDataVector::getPoint(size_t index) const {
42  return points_[index];
43 }
44 
45 QVector<size_t> CurveDataVector::getPointsInDistance(double x, double
46  maxDistance) const {
47  QVector<size_t> indexes;
48 
49  XCoordinateRefSet::const_iterator it = x_.lower_bound(x-maxDistance);
50 
51  while (it != x_.end()) {
52  if (fabs(x-it->x_) <= maxDistance) {
53  indexes.push_back(it->index_);
54  ++it;
55  }
56  else
57  break;
58  }
59 
60  return indexes;
61 }
62 
64  return bounds_;
65 }
66 
67 /*****************************************************************************/
68 /* Methods */
69 /*****************************************************************************/
70 
71 void CurveDataVector::appendPoint(const QPointF& point) {
72  bounds_ += point;
73 
74  if (points_.capacity() < points_.count()+1)
75  points_.reserve(points_.capacity() ? 2*points_.capacity() : 1);
76 
77  points_.append(point);
78 
79  if (x_.capacity() < x_.size()+1)
80  x_.reserve(x_.capacity() ? 2*x_.capacity() : 1);
81 
82  x_.insert(XCoordinateRef(point.x(), points_.size()-1));
83 }
84 
86  points_.clear();
87  x_.clear();
88 
89  bounds_.clear();
90 }
91 
92 }
QPointF getPoint(size_t index) const
BoundingRectangle getBounds() const
QVector< size_t > getPointsInDistance(double x, double maxDistance) const
void appendPoint(const QPointF &point)


rqt_multiplot_plugin
Author(s): Ralf Kaestner
autogenerated on Fri Jan 15 2021 03:47:53