CurveAxisScaleConfig.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/CurveAxisScaleConfig.h"
00020 
00021 namespace rqt_multiplot {
00022 
00023 /*****************************************************************************/
00024 /* Constructors and Destructor                                               */
00025 /*****************************************************************************/
00026 
00027 CurveAxisScaleConfig::CurveAxisScaleConfig(QObject* parent, Type type,
00028     double absoluteMinimum, double absoluteMaximum, double relativeMinimum,
00029     double relativeMaximum) :
00030   Config(parent),
00031   type_(type),
00032   absoluteMinimum_(absoluteMinimum),
00033   absoluteMaximum_(absoluteMaximum),
00034   relativeMinimum_(relativeMinimum),
00035   relativeMaximum_(relativeMaximum) {
00036 }
00037 
00038 CurveAxisScaleConfig::~CurveAxisScaleConfig() {
00039 }
00040 
00041 /*****************************************************************************/
00042 /* Accessors                                                                 */
00043 /*****************************************************************************/
00044 
00045 void CurveAxisScaleConfig::setType(Type type) {
00046   if (type != type_) {
00047     type_ = type;
00048     
00049     emit typeChanged(type);
00050     emit changed();
00051   }
00052 }
00053 
00054 CurveAxisScaleConfig::Type CurveAxisScaleConfig::getType() const {
00055   return type_;
00056 }
00057 
00058 void CurveAxisScaleConfig::setAbsoluteMinimum(double minimum) {
00059   if (minimum != absoluteMinimum_) {
00060     absoluteMinimum_ = minimum;
00061     
00062     emit absoluteMinimumChanged(minimum);
00063     emit changed();
00064   }
00065 }
00066 
00067 double CurveAxisScaleConfig::getAbsoluteMinimum() const {
00068   return absoluteMinimum_;
00069 }
00070 
00071 void CurveAxisScaleConfig::setAbsoluteMaximum(double maximum) {
00072   if (maximum != absoluteMaximum_) {
00073     absoluteMaximum_ = maximum;
00074     
00075     emit absoluteMaximumChanged(maximum);
00076     emit changed();
00077   }
00078 }
00079 
00080 double CurveAxisScaleConfig::getAbsoluteMaximum() const {
00081   return absoluteMaximum_;
00082 }
00083 
00084 void CurveAxisScaleConfig::setRelativeMinimum(double minimum) {
00085   if (minimum != relativeMinimum_) {
00086     relativeMinimum_ = minimum;
00087     
00088     emit relativeMinimumChanged(minimum);
00089     emit changed();
00090   }
00091 }
00092 
00093 double CurveAxisScaleConfig::getRelativeMinimum() const {
00094   return relativeMinimum_;
00095 }
00096 
00097 void CurveAxisScaleConfig::setRelativeMaximum(double maximum) {
00098   if (maximum != relativeMaximum_) {
00099     relativeMaximum_ = maximum;
00100     
00101     emit relativeMaximumChanged(maximum);
00102     emit changed();
00103   }
00104 }
00105 
00106 double CurveAxisScaleConfig::getRelativeMaximum() const {
00107   return relativeMaximum_;
00108 }
00109 
00110 bool CurveAxisScaleConfig::isValid() const {
00111   if (type_ == Absolute)
00112     return (absoluteMaximum_ != absoluteMinimum_);
00113   if (type_ == Relative)
00114     return (relativeMaximum_ != relativeMinimum_);
00115   else
00116     return true;
00117 }
00118 
00119 /*****************************************************************************/
00120 /* Methods                                                                   */
00121 /*****************************************************************************/
00122 
00123 void CurveAxisScaleConfig::save(QSettings& settings) const {
00124   settings.setValue("type", type_);
00125   
00126   settings.setValue("absolute_minimum", absoluteMinimum_);
00127   settings.setValue("absolute_maximum", absoluteMaximum_);
00128   
00129   settings.setValue("relative_minimum", relativeMinimum_);
00130   settings.setValue("relative_maximum", relativeMaximum_);
00131 }
00132 
00133 void CurveAxisScaleConfig::load(QSettings& settings) {
00134   setType(static_cast<Type>(settings.value("type", Auto).toInt()));
00135   
00136   setAbsoluteMinimum(settings.value("absolute_minimum", 0.0).toDouble());
00137   setAbsoluteMaximum(settings.value("absolute_maximum", 1000.0).toDouble());
00138   
00139   setRelativeMinimum(settings.value("relative_minimum", -1000.0).toDouble());
00140   setRelativeMaximum(settings.value("relative_maximum", 0.0).toDouble());
00141 }
00142 
00143 void CurveAxisScaleConfig::reset() {
00144   setType(Auto);
00145   
00146   setAbsoluteMinimum(0.0);
00147   setAbsoluteMaximum(1000.0);
00148   
00149   setRelativeMinimum(-1000.0);
00150   setRelativeMaximum(0.0);
00151 }
00152 
00153 void CurveAxisScaleConfig::write(QDataStream& stream) const {
00154   stream << (int)type_;
00155   
00156   stream << absoluteMinimum_;
00157   stream << absoluteMaximum_;
00158   
00159   stream << relativeMinimum_;
00160   stream << relativeMaximum_;
00161 }
00162 
00163 void CurveAxisScaleConfig::read(QDataStream& stream) {
00164   int type;
00165   double absoluteMinimum, absoluteMaximum, relativeMinimum, relativeMaximum;
00166   
00167   stream >> type;
00168   setType(static_cast<Type>(type));
00169   
00170   stream >> absoluteMinimum;
00171   setAbsoluteMinimum(absoluteMinimum);
00172   stream >> absoluteMaximum;
00173   setAbsoluteMaximum(absoluteMaximum);
00174   
00175   stream >> relativeMinimum;
00176   setRelativeMinimum(relativeMinimum);
00177   stream >> relativeMaximum;
00178   setRelativeMaximum(relativeMaximum);
00179 }
00180 
00181 /*****************************************************************************/
00182 /* Operators                                                                 */
00183 /*****************************************************************************/
00184 
00185 CurveAxisScaleConfig& CurveAxisScaleConfig::operator=(const
00186     CurveAxisScaleConfig& src) {
00187   setType(src.type_);
00188   
00189   setAbsoluteMinimum(src.absoluteMinimum_);
00190   setAbsoluteMaximum(src.absoluteMaximum_);
00191   
00192   setRelativeMinimum(src.relativeMinimum_);
00193   setRelativeMaximum(src.relativeMaximum_);
00194   
00195   return *this;
00196 }
00197 
00198 }


rqt_multiplot
Author(s): Ralf Kaestner
autogenerated on Tue May 9 2017 02:16:02