CurveDataListTimeFrame.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright (C) 2015 by Ralf Kaestner, Samuel Bachmann *
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  timeFrameLength_(length) {
29 }
30 
32 }
33 
34 /*****************************************************************************/
35 /* Accessors */
36 /*****************************************************************************/
37 
39  return points_.count();
40 }
41 
42 QPointF CurveDataListTimeFrame::getPoint(size_t index) const {
43  return points_[index];
44 }
45 
47  return bounds_;
48 }
49 
50 /*****************************************************************************/
51 /* Methods */
52 /*****************************************************************************/
53 
54 void CurveDataListTimeFrame::appendPoint(const QPointF& point) {
55  points_.append(point);
56 
57  double timeCutoff = point.x() - timeFrameLength_;
58 
59 // QMutableListIterator<QPointF> iterator(points_);
60 // while (iterator.hasNext()) {
61 // if (iterator.next().x() < timeCutoff)
62 // iterator.remove();
63 // else
64 // break;
65 // }
66 
67  QList<QPointF>::iterator it = points_.begin();
68  while (it != points_.end()) {
69  if ((*it).x() < timeCutoff)
70  it = points_.erase(it);
71  else
72  break;
73  }
74 
75  auto min_max_x = std::minmax_element(points_.begin(), points_.end(),
76  [](const QPointF &a, const QPointF &b) {
77  return a.x() < b.x();
78  });
79 
80  auto min_max_y = std::minmax_element(points_.begin(), points_.end(),
81  [](const QPointF &a, const QPointF &b) {
82  return a.y() < b.y();
83  });
84 
85  bounds_.setMinimum(QPointF(min_max_x.first->x(), min_max_y.first->y()));
86  bounds_.setMaximum(QPointF(min_max_x.second->x(), min_max_y.second->y()));
87 }
88 
90  points_.clear();
91  bounds_.clear();
92 }
93 
94 }
void setMaximum(const QPointF &maximum)
void setMinimum(const QPointF &minimum)


rqt_multiplot
Author(s): Ralf Kaestner
autogenerated on Wed Jul 10 2019 03:49:44