CurveStyleConfig.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/CurveStyleConfig.h"
00020 
00021 namespace rqt_multiplot {
00022 
00023 /*****************************************************************************/
00024 /* Constructors and Destructor                                               */
00025 /*****************************************************************************/
00026 
00027 CurveStyleConfig::CurveStyleConfig(QObject* parent, Type type, bool
00028     linesInterpolate, Qt::Orientation sticksOrientation, double
00029     sticksBaseline, bool stepsInvert, size_t penWidth, Qt::PenStyle
00030     penStyle, bool renderAntialias) :
00031   Config(parent),
00032   type_(type),
00033   linesInterpolate_(linesInterpolate),
00034   sticksOrientation_(sticksOrientation),
00035   sticksBaseline_(sticksBaseline),
00036   stepsInvert_(stepsInvert),
00037   penWidth_(penWidth),
00038   penStyle_(penStyle),
00039   renderAntialias_(renderAntialias) {
00040 }
00041 
00042 CurveStyleConfig::~CurveStyleConfig() {
00043 }
00044 
00045 /*****************************************************************************/
00046 /* Accessors                                                                 */
00047 /*****************************************************************************/
00048 
00049 void CurveStyleConfig::setType(Type type) {
00050   if (type != type_) {
00051     type_ = type;
00052     
00053     emit typeChanged(type);
00054     emit changed();
00055   }
00056 }
00057 
00058 CurveStyleConfig::Type CurveStyleConfig::getType() const {
00059   return type_;
00060 }
00061 
00062 void CurveStyleConfig::setLinesInterpolate(bool interpolate) {
00063   if (interpolate != linesInterpolate_) {
00064     linesInterpolate_ = interpolate;
00065     
00066     emit linesInterpolateChanged(interpolate);
00067     emit changed();
00068   }
00069 }
00070 
00071 bool CurveStyleConfig::areLinesInterpolated() const {
00072   return linesInterpolate_;
00073 }
00074 
00075 void CurveStyleConfig::setSticksOrientation(Qt::Orientation orientation) {
00076   if (orientation != sticksOrientation_) {
00077     sticksOrientation_ = orientation;
00078     
00079     emit sticksOrientationChanged(orientation);
00080     emit changed();
00081   }
00082 }
00083 
00084 Qt::Orientation CurveStyleConfig::getSticksOrientation() const {
00085   return sticksOrientation_;
00086 }
00087 
00088 void CurveStyleConfig::setSticksBaseline(double baseline) {
00089   if (baseline != sticksBaseline_) {
00090     sticksBaseline_ = baseline;
00091     
00092     emit sticksBaselineChanged(baseline);
00093     emit changed();
00094   }
00095 }
00096 
00097 double CurveStyleConfig::getSticksBaseline() const {
00098   return sticksBaseline_;
00099 }
00100 
00101 void CurveStyleConfig::setStepsInvert(bool invert) {
00102   if (invert != stepsInvert_) {
00103     stepsInvert_ = invert;
00104     
00105     emit stepsInvertChanged(invert);
00106     emit changed();
00107   }
00108 }
00109 
00110 bool CurveStyleConfig::areStepsInverted() const {
00111   return stepsInvert_;
00112 }
00113 
00114 void CurveStyleConfig::setPenWidth(size_t width) {
00115   if (width != penWidth_) {
00116     penWidth_ = width;
00117     
00118     emit penWidthChanged(width);
00119     emit changed();
00120   }
00121 }
00122 
00123 size_t CurveStyleConfig::getPenWidth() const {
00124   return penWidth_;
00125 }
00126 
00127 void CurveStyleConfig::setPenStyle(Qt::PenStyle style) {
00128   if (style != penStyle_) {
00129     penStyle_ = style;
00130     
00131     emit penStyleChanged(style);
00132     emit changed();
00133   }
00134 }
00135 
00136 Qt::PenStyle CurveStyleConfig::getPenStyle() const {
00137   return penStyle_;
00138 }
00139 
00140 void CurveStyleConfig::setRenderAntialias(bool antialias) {
00141   if (antialias != renderAntialias_) {
00142     renderAntialias_ = antialias;
00143     
00144     emit renderAntialiasChanged(antialias);
00145     emit changed();
00146   }
00147 }
00148 
00149 bool CurveStyleConfig::isRenderAntialiased() const {
00150   return renderAntialias_;
00151 }
00152 
00153 /*****************************************************************************/
00154 /* Methods                                                                   */
00155 /*****************************************************************************/
00156 
00157 void CurveStyleConfig::save(QSettings& settings) const {
00158   settings.setValue("type", type_);
00159   
00160   settings.setValue("lines_interpolate", linesInterpolate_);
00161   settings.setValue("sticks_orientation", sticksOrientation_);
00162   settings.setValue("sticks_baseline", sticksBaseline_);
00163   settings.setValue("steps_invert", stepsInvert_);
00164   
00165   settings.setValue("pen_width", QVariant::fromValue<qulonglong>(penWidth_));
00166   settings.setValue("pen_style", (int)penStyle_);
00167   settings.setValue("render_antialias", renderAntialias_);
00168 }
00169 
00170 void CurveStyleConfig::load(QSettings& settings) {
00171   setType(static_cast<Type>(settings.value("type", Lines).toInt()));
00172   
00173   setLinesInterpolate(settings.value("lines_interpolate", false).toBool());
00174   setSticksOrientation(static_cast<Qt::Orientation>(settings.value(
00175     "sticks_orientation", Qt::Vertical).toInt()));
00176   setSticksBaseline(settings.value("sticks_baseline", 0.0).toDouble());
00177   setStepsInvert(settings.value("steps_invert", false).toBool());
00178   
00179   setPenWidth(settings.value("pen_width", 1).toULongLong());
00180   setPenStyle(static_cast<Qt::PenStyle>(settings.value(
00181     "pen_style", (int)Qt::SolidLine).toInt()));
00182   setRenderAntialias(settings.value("render_antialias", false).toBool());
00183 }
00184 
00185 void CurveStyleConfig::reset() {
00186   setType(Lines);
00187   
00188   setLinesInterpolate(false);
00189   setSticksOrientation(Qt::Vertical);
00190   setSticksBaseline(0.0);
00191   setStepsInvert(false);
00192   
00193   setPenWidth(1);
00194   setPenStyle(Qt::SolidLine);
00195   setRenderAntialias(false);
00196 }
00197 
00198 void CurveStyleConfig::write(QDataStream& stream) const {
00199   stream << (int)type_;
00200   
00201   stream << linesInterpolate_;
00202   stream << (int)sticksOrientation_;
00203   stream << sticksBaseline_;
00204   stream << stepsInvert_;
00205   
00206   stream << (quint64)penWidth_;
00207   stream << (int)penStyle_;
00208   stream << renderAntialias_;
00209 }
00210 
00211 void CurveStyleConfig::read(QDataStream& stream) {
00212   int type, sticksOrientation, penStyle;
00213   bool linesInterpolate, stepsInvert, renderAntialias;
00214   double sticksBaseline;
00215   quint64 penWidth;
00216   
00217   stream >> type;
00218   setType(static_cast<Type>(type));
00219   
00220   stream >> linesInterpolate;
00221   setLinesInterpolate(linesInterpolate);
00222   stream >> sticksOrientation;
00223   setSticksOrientation(static_cast<Qt::Orientation>(sticksOrientation));
00224   stream >> sticksBaseline;
00225   setSticksBaseline(sticksBaseline);
00226   stream >> stepsInvert;
00227   setStepsInvert(stepsInvert);
00228   
00229   stream >> penWidth;
00230   setPenWidth(penWidth);
00231   stream >> penStyle;
00232   setPenStyle(static_cast<Qt::PenStyle>(penStyle));
00233   stream >> renderAntialias;
00234   setRenderAntialias(renderAntialias);
00235 }
00236 
00237 /*****************************************************************************/
00238 /* Operators                                                                 */
00239 /*****************************************************************************/
00240 
00241 CurveStyleConfig& CurveStyleConfig::operator=(const CurveStyleConfig& src) {
00242   setType(src.type_);
00243   
00244   setLinesInterpolate(src.linesInterpolate_);
00245   setSticksOrientation(src.sticksOrientation_);
00246   setSticksBaseline(src.sticksBaseline_);
00247   setStepsInvert(src.stepsInvert_);
00248   
00249   setPenWidth(src.penWidth_);
00250   setPenStyle(src.penStyle_);
00251   setRenderAntialias(src.renderAntialias_);
00252   
00253   return *this;
00254 }
00255 
00256 }


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