PlotAxisConfig.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/PlotAxisConfig.h"
00020 
00021 namespace rqt_multiplot {
00022 
00023 /*****************************************************************************/
00024 /* Constructors and Destructor                                               */
00025 /*****************************************************************************/
00026 
00027 PlotAxisConfig::PlotAxisConfig(QObject* parent, TitleType titleType, const
00028     QString& customTitle, bool titleVisible) :
00029   Config(parent),
00030   titleType_(titleType),
00031   customTitle_(customTitle),
00032   titleVisible_(titleVisible) {
00033 }
00034 
00035 PlotAxisConfig::~PlotAxisConfig() {
00036 }
00037 
00038 /*****************************************************************************/
00039 /* Accessors                                                                 */
00040 /*****************************************************************************/
00041 
00042 void PlotAxisConfig::setTitleType(TitleType type) {
00043   if (type != titleType_) {
00044     titleType_ = type;
00045     
00046     emit titleTypeChanged(type);
00047     emit changed();
00048   }
00049 }
00050 
00051 PlotAxisConfig::TitleType PlotAxisConfig::getTitleType() const {
00052   return titleType_;
00053 }
00054 
00055 void PlotAxisConfig::setCustomTitle(const QString& title) {
00056   if (title != customTitle_) {
00057     customTitle_ = title;
00058     
00059     emit customTitleChanged(title);
00060     emit changed();
00061   }
00062 }
00063 
00064 const QString& PlotAxisConfig::getCustomTitle() const {
00065   return customTitle_;
00066 }
00067 
00068 void PlotAxisConfig::setTitleVisible(bool visible) {
00069   if (visible != titleVisible_) {
00070     titleVisible_ = visible;
00071     
00072     emit titleVisibleChanged(visible);
00073     emit changed();
00074   }
00075 }
00076 
00077 bool PlotAxisConfig::isTitleVisible() const {
00078   return titleVisible_;
00079 }
00080 
00081 /*****************************************************************************/
00082 /* Methods                                                                   */
00083 /*****************************************************************************/
00084 
00085 void PlotAxisConfig::save(QSettings& settings) const {
00086   settings.setValue("title_type", titleType_);
00087   settings.setValue("custom_title", customTitle_);
00088   settings.setValue("title_visible", titleVisible_);
00089 }
00090 
00091 void PlotAxisConfig::load(QSettings& settings) {
00092   setTitleType(static_cast<TitleType>(settings.value("title_type",
00093     AutoTitle).toInt()));
00094   setCustomTitle(settings.value("custom_title", "Untitled Axis").toString());
00095   setTitleVisible(settings.value("title_visible", true).toBool());
00096 }
00097 
00098 void PlotAxisConfig::reset() {
00099   setTitleType(AutoTitle);
00100   setCustomTitle("Untitled Axis");
00101   setTitleVisible(true);
00102 }
00103 
00104 void PlotAxisConfig::write(QDataStream& stream) const {
00105   stream << (int)titleType_;
00106   stream << customTitle_;
00107   stream << titleVisible_;
00108 }
00109 
00110 void PlotAxisConfig::read(QDataStream& stream) {
00111   int titleType;
00112   QString customTitle;
00113   bool titleVisible;
00114   
00115   stream >> titleType;
00116   setTitleType(static_cast<TitleType>(titleType));
00117   stream >> customTitle;
00118   setCustomTitle(customTitle);
00119   stream >> titleVisible;
00120   setTitleVisible(titleVisible);
00121 }
00122 
00123 /*****************************************************************************/
00124 /* Operators                                                                 */
00125 /*****************************************************************************/
00126 
00127 PlotAxisConfig& PlotAxisConfig::operator=(const PlotAxisConfig& src) {
00128   setTitleType(src.titleType_);
00129   setCustomTitle(src.customTitle_);
00130   setTitleVisible(src.titleVisible_);
00131   
00132   return *this;
00133 }
00134 
00135 }


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