CurveDataConfig.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 
27 CurveDataConfig::CurveDataConfig(QObject* parent, Type type, size_t
28  circularBufferCapacity, double timeFrameLength) :
29  Config(parent),
30  type_(type),
31  circularBufferCapacity_(circularBufferCapacity),
32  timeFrameLength_(timeFrameLength) {
33 }
34 
36 }
37 
38 /*****************************************************************************/
39 /* Accessors */
40 /*****************************************************************************/
41 
43  if (type != type_) {
44  type_ = type;
45 
46  emit typeChanged(type);
47  emit changed();
48  }
49 }
50 
52  return type_;
53 }
54 
56  if (capacity != circularBufferCapacity_) {
57  circularBufferCapacity_ = capacity;
58 
59  emit circularBufferCapacityChanged(capacity);
60  emit changed();
61  }
62 }
63 
66 }
67 
69  if (length != timeFrameLength_) {
70  timeFrameLength_ = length;
71 
72  emit timeFrameLengthChanged(length);
73  emit changed();
74  }
75 }
76 
78  return timeFrameLength_;
79 }
80 
81 /*****************************************************************************/
82 /* Methods */
83 /*****************************************************************************/
84 
85 void CurveDataConfig::save(QSettings& settings) const {
86  settings.setValue("type", type_);
87  settings.setValue("circular_buffer_capacity", QVariant::
88  fromValue<qulonglong>(circularBufferCapacity_));
89  settings.setValue("time_frame_length", QVariant::
90  fromValue<qreal>(timeFrameLength_));
91 }
92 
93 void CurveDataConfig::load(QSettings& settings) {
94  setType(static_cast<Type>(settings.value("type", Vector).toInt()));
95  setCircularBufferCapacity(settings.value("circular_buffer_capacity",
96  10000).toULongLong());
97  setTimeFrameLength(settings.value("time_frame_length", 10.0).toReal());
98 }
99 
101  setType(Vector);
103  setTimeFrameLength(10.0);
104 }
105 
106 void CurveDataConfig::write(QDataStream& stream) const {
107  stream << (int)type_;
108  stream << (quint64)circularBufferCapacity_;
109  stream << (qreal)timeFrameLength_;
110 }
111 
112 void CurveDataConfig::read(QDataStream& stream) {
113  int type;
114  quint64 circularBufferCapacity;
115  qreal timeFrameLength;
116 
117  stream >> type;
118  setType(static_cast<Type>(type));
119  stream >> circularBufferCapacity;
120  setCircularBufferCapacity(circularBufferCapacity);
121  stream >> timeFrameLength;
122  setTimeFrameLength(timeFrameLength);
123 }
124 
125 /*****************************************************************************/
126 /* Operators */
127 /*****************************************************************************/
128 
130  setType(src.type_);
133 
134  return *this;
135 }
136 
137 }
size_t getCircularBufferCapacity() const
CurveDataConfig(QObject *parent=0, Type type=Vector, size_t circularBufferCapacity=1000, double timeFrameLength=10.0)
void save(QSettings &settings) const
void read(QDataStream &stream)
void circularBufferCapacityChanged(size_t capacity)
void setCircularBufferCapacity(size_t capacity)
void setTimeFrameLength(double length)
void write(QDataStream &stream) const
void timeFrameLengthChanged(double length)
void load(QSettings &settings)
CurveDataConfig & operator=(const CurveDataConfig &src)


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