CurveAxisConfig.cpp
Go to the documentation of this file.
00001 /******************************************************************************
00002  * Copyright (C) 2015 by Ralf Kaestner                                        *
00003  * ralf.kaestner@gmail.com                                                    *
00004  *                                                                            *
00005  * This program is free software; you can redistribute it and/or modify       *
00006  * it under the terms of the Lesser GNU General Public License as published by*
00007  * the Free Software Foundation; either version 3 of the License, or          *
00008  * (at your option) any later version.                                        *
00009  *                                                                            *
00010  * This program is distributed in the hope that it will be useful,            *
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the               *
00013  * Lesser GNU General Public License for more details.                        *
00014  *                                                                            *
00015  * You should have received a copy of the Lesser GNU General Public License   *
00016  * along with this program. If not, see <http://www.gnu.org/licenses/>.       *
00017  ******************************************************************************/
00018 
00019 #include "rqt_multiplot/CurveAxisConfig.h"
00020 
00021 namespace rqt_multiplot {
00022 
00023 /*****************************************************************************/
00024 /* Constructors and Destructor                                               */
00025 /*****************************************************************************/
00026 
00027 CurveAxisConfig::CurveAxisConfig(QObject* parent, const QString& topic,
00028     const QString& type, FieldType fieldType, const QString& field) :
00029   Config(parent),
00030   topic_(topic),
00031   type_(type),
00032   fieldType_(fieldType),
00033   field_(field),
00034   scaleConfig_(new CurveAxisScaleConfig(this)) {
00035   connect(scaleConfig_, SIGNAL(changed()), this, SLOT(scaleChanged()));
00036 }
00037 
00038 CurveAxisConfig::~CurveAxisConfig() {
00039 }
00040 
00041 /*****************************************************************************/
00042 /* Accessors                                                                 */
00043 /*****************************************************************************/
00044 
00045 void CurveAxisConfig::setTopic(const QString& topic) {
00046   if (topic != topic_) {
00047     topic_ = topic;
00048     
00049     emit topicChanged(topic);
00050     emit changed();
00051   }
00052 }
00053 
00054 const QString& CurveAxisConfig::getTopic() const {
00055   return topic_;
00056 }
00057 
00058 void CurveAxisConfig::setType(const QString& type) {
00059   if (type != type_) {
00060     type_ = type;
00061     
00062     emit typeChanged(type);
00063     emit changed();
00064   }
00065 }
00066 
00067 const QString& CurveAxisConfig::getType() const {
00068   return type_;
00069 }
00070 
00071 void CurveAxisConfig::setFieldType(FieldType fieldType) {
00072   if (fieldType != fieldType_) {
00073     fieldType_ = fieldType;
00074     
00075     emit fieldTypeChanged(fieldType);
00076     emit changed();
00077   }
00078 }
00079 
00080 CurveAxisConfig::FieldType CurveAxisConfig::getFieldType() const {
00081   return fieldType_;
00082 }
00083 
00084 void CurveAxisConfig::setField(const QString& field) {
00085   if (field != field_) {
00086     field_ = field;
00087     
00088     emit fieldChanged(field);
00089     emit changed();
00090   }
00091 }
00092 
00093 const QString& CurveAxisConfig::getField() const {
00094   return field_;
00095 }
00096 
00097 CurveAxisScaleConfig* CurveAxisConfig::getScaleConfig() const {
00098   return scaleConfig_;
00099 }
00100 
00101 /*****************************************************************************/
00102 /* Methods                                                                   */
00103 /*****************************************************************************/
00104 
00105 void CurveAxisConfig::save(QSettings& settings) const {
00106   settings.setValue("topic", topic_);
00107   settings.setValue("type", type_);
00108   settings.setValue("field_type", fieldType_);
00109   settings.setValue("field", field_);
00110   
00111   settings.beginGroup("scale");
00112   scaleConfig_->save(settings);
00113   settings.endGroup();
00114 }
00115 
00116 void CurveAxisConfig::load(QSettings& settings) {
00117   setTopic(settings.value("topic").toString());
00118   setType(settings.value("type").toString());
00119   setFieldType(static_cast<FieldType>(settings.value("field_type").toInt()));
00120   setField(settings.value("field").toString());
00121   
00122   settings.beginGroup("scale");
00123   scaleConfig_->load(settings);
00124   settings.endGroup();
00125 }
00126 
00127 void CurveAxisConfig::reset() {
00128   setTopic(QString());
00129   setType(QString());
00130   setFieldType(MessageData);
00131   setField(QString());
00132   
00133   scaleConfig_->reset();
00134 }
00135 
00136 void CurveAxisConfig::write(QDataStream& stream) const {
00137   stream << topic_;
00138   stream << type_;
00139   stream << (int)fieldType_;
00140   stream << field_;
00141   
00142   scaleConfig_->write(stream);
00143 }
00144 
00145 void CurveAxisConfig::read(QDataStream& stream) {
00146   QString topic, type, field;
00147   int fieldType;
00148   
00149   stream >> topic;
00150   setTopic(topic);
00151   stream >> type;
00152   setType(type);
00153   stream >> fieldType;
00154   setFieldType(static_cast<FieldType>(fieldType));
00155   stream >> field;
00156   setField(field);  
00157   
00158   scaleConfig_->read(stream);
00159 }
00160 
00161 /*****************************************************************************/
00162 /* Operators                                                                 */
00163 /*****************************************************************************/
00164 
00165 CurveAxisConfig& CurveAxisConfig::operator=(const CurveAxisConfig& src) {
00166   setTopic(src.topic_);
00167   setType(src.type_);
00168   setFieldType(src.fieldType_);
00169   setField(src.field_);
00170   
00171   *scaleConfig_ = *src.scaleConfig_;
00172   
00173   return *this;
00174 }
00175 
00176 /*****************************************************************************/
00177 /* Slots                                                                     */
00178 /*****************************************************************************/
00179 
00180 void CurveAxisConfig::scaleChanged() {
00181   emit changed();
00182 }
00183 
00184 }


rqt_multiplot
Author(s): Ralf Kaestner
autogenerated on Thu Jun 6 2019 21:49:10