Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "rqt_multiplot/CurveAxisScaleConfig.h"
00020
00021 namespace rqt_multiplot {
00022
00023
00024
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
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
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
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 }