CurveAxisConfig.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 CurveAxisConfig::CurveAxisConfig(QObject* parent, const QString& topic,
28  const QString& type, FieldType fieldType, const QString& field) :
29  Config(parent),
30  topic_(topic),
31  type_(type),
32  fieldType_(fieldType),
33  field_(field),
34  scaleConfig_(new CurveAxisScaleConfig(this)) {
35  connect(scaleConfig_, SIGNAL(changed()), this, SLOT(scaleChanged()));
36 }
37 
39 }
40 
41 /*****************************************************************************/
42 /* Accessors */
43 /*****************************************************************************/
44 
45 void CurveAxisConfig::setTopic(const QString& topic) {
46  if (topic != topic_) {
47  topic_ = topic;
48 
49  emit topicChanged(topic);
50  emit changed();
51  }
52 }
53 
54 const QString& CurveAxisConfig::getTopic() const {
55  return topic_;
56 }
57 
58 void CurveAxisConfig::setType(const QString& type) {
59  if (type != type_) {
60  type_ = type;
61 
62  emit typeChanged(type);
63  emit changed();
64  }
65 }
66 
67 const QString& CurveAxisConfig::getType() const {
68  return type_;
69 }
70 
72  if (fieldType != fieldType_) {
73  fieldType_ = fieldType;
74 
75  emit fieldTypeChanged(fieldType);
76  emit changed();
77  }
78 }
79 
81  return fieldType_;
82 }
83 
84 void CurveAxisConfig::setField(const QString& field) {
85  if (field != field_) {
86  field_ = field;
87 
88  emit fieldChanged(field);
89  emit changed();
90  }
91 }
92 
93 const QString& CurveAxisConfig::getField() const {
94  return field_;
95 }
96 
98  return scaleConfig_;
99 }
100 
101 /*****************************************************************************/
102 /* Methods */
103 /*****************************************************************************/
104 
105 void CurveAxisConfig::save(QSettings& settings) const {
106  settings.setValue("topic", topic_);
107  settings.setValue("type", type_);
108  settings.setValue("field_type", fieldType_);
109  settings.setValue("field", field_);
110 
111  settings.beginGroup("scale");
112  scaleConfig_->save(settings);
113  settings.endGroup();
114 }
115 
116 void CurveAxisConfig::load(QSettings& settings) {
117  setTopic(settings.value("topic").toString());
118  setType(settings.value("type").toString());
119  setFieldType(static_cast<FieldType>(settings.value("field_type").toInt()));
120  setField(settings.value("field").toString());
121 
122  settings.beginGroup("scale");
123  scaleConfig_->load(settings);
124  settings.endGroup();
125 }
126 
128  setTopic(QString());
129  setType(QString());
131  setField(QString());
132 
133  scaleConfig_->reset();
134 }
135 
136 void CurveAxisConfig::write(QDataStream& stream) const {
137  stream << topic_;
138  stream << type_;
139  stream << (int)fieldType_;
140  stream << field_;
141 
142  scaleConfig_->write(stream);
143 }
144 
145 void CurveAxisConfig::read(QDataStream& stream) {
146  QString topic, type, field;
147  int fieldType;
148 
149  stream >> topic;
150  setTopic(topic);
151  stream >> type;
152  setType(type);
153  stream >> fieldType;
154  setFieldType(static_cast<FieldType>(fieldType));
155  stream >> field;
156  setField(field);
157 
158  scaleConfig_->read(stream);
159 }
160 
161 /*****************************************************************************/
162 /* Operators */
163 /*****************************************************************************/
164 
166  setTopic(src.topic_);
167  setType(src.type_);
169  setField(src.field_);
170 
171  *scaleConfig_ = *src.scaleConfig_;
172 
173  return *this;
174 }
175 
176 /*****************************************************************************/
177 /* Slots */
178 /*****************************************************************************/
179 
181  emit changed();
182 }
183 
184 }
const QString & getTopic() const
void topicChanged(const QString &topic)
void write(QDataStream &stream) const
void load(QSettings &settings)
CurveAxisScaleConfig * getScaleConfig() const
const QString & getType() const
void typeChanged(const QString &type)
void save(QSettings &settings) const
void setField(const QString &field)
CurveAxisConfig(QObject *parent=0, const QString &topic=QString(), const QString &type=QString(), FieldType fieldType=MessageData, const QString &field=QString())
void read(QDataStream &stream)
CurveAxisScaleConfig * scaleConfig_
void fieldTypeChanged(int fieldType)
void setTopic(const QString &topic)
const QString & getField() const
void setType(const QString &type)
void write(QDataStream &stream) const
CurveAxisConfig & operator=(const CurveAxisConfig &src)
void save(QSettings &settings) const
void setFieldType(FieldType fieldType)
void fieldChanged(const QString &field)


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