PlotAxisConfig.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright (C) 2015 by Ralf Kaestner *
3  * ralf.kaestner@gmail.com *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the Lesser GNU General Public License as published by*
7  * the Free Software Foundation; either version 3 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * Lesser GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the Lesser GNU General Public License *
16  * along with this program. If not, see <http://www.gnu.org/licenses/>. *
17  ******************************************************************************/
18 
20 
21 namespace rqt_multiplot {
22 
23 /*****************************************************************************/
24 /* Constructors and Destructor */
25 /*****************************************************************************/
26 
27 PlotAxisConfig::PlotAxisConfig(QObject* parent, TitleType titleType, const
28  QString& customTitle, bool titleVisible) :
29  Config(parent),
30  titleType_(titleType),
31  customTitle_(customTitle),
32  titleVisible_(titleVisible) {
33 }
34 
36 }
37 
38 /*****************************************************************************/
39 /* Accessors */
40 /*****************************************************************************/
41 
43  if (type != titleType_) {
44  titleType_ = type;
45 
46  emit titleTypeChanged(type);
47  emit changed();
48  }
49 }
50 
52  return titleType_;
53 }
54 
55 void PlotAxisConfig::setCustomTitle(const QString& title) {
56  if (title != customTitle_) {
57  customTitle_ = title;
58 
59  emit customTitleChanged(title);
60  emit changed();
61  }
62 }
63 
64 const QString& PlotAxisConfig::getCustomTitle() const {
65  return customTitle_;
66 }
67 
68 void PlotAxisConfig::setTitleVisible(bool visible) {
69  if (visible != titleVisible_) {
70  titleVisible_ = visible;
71 
72  emit titleVisibleChanged(visible);
73  emit changed();
74  }
75 }
76 
78  return titleVisible_;
79 }
80 
81 /*****************************************************************************/
82 /* Methods */
83 /*****************************************************************************/
84 
85 void PlotAxisConfig::save(QSettings& settings) const {
86  settings.setValue("title_type", titleType_);
87  settings.setValue("custom_title", customTitle_);
88  settings.setValue("title_visible", titleVisible_);
89 }
90 
91 void PlotAxisConfig::load(QSettings& settings) {
92  setTitleType(static_cast<TitleType>(settings.value("title_type",
93  AutoTitle).toInt()));
94  setCustomTitle(settings.value("custom_title", "Untitled Axis").toString());
95  setTitleVisible(settings.value("title_visible", true).toBool());
96 }
97 
100  setCustomTitle("Untitled Axis");
101  setTitleVisible(true);
102 }
103 
104 void PlotAxisConfig::write(QDataStream& stream) const {
105  stream << (int)titleType_;
106  stream << customTitle_;
107  stream << titleVisible_;
108 }
109 
110 void PlotAxisConfig::read(QDataStream& stream) {
111  int titleType;
112  QString customTitle;
113  bool titleVisible;
114 
115  stream >> titleType;
116  setTitleType(static_cast<TitleType>(titleType));
117  stream >> customTitle;
118  setCustomTitle(customTitle);
119  stream >> titleVisible;
120  setTitleVisible(titleVisible);
121 }
122 
123 /*****************************************************************************/
124 /* Operators */
125 /*****************************************************************************/
126 
131 
132  return *this;
133 }
134 
135 }
void customTitleChanged(const QString &title)
PlotAxisConfig & operator=(const PlotAxisConfig &src)
void read(QDataStream &stream)
void titleVisibleChanged(bool visible)
const QString & getCustomTitle() const
void setCustomTitle(const QString &title)
TitleType getTitleType() const
void setTitleType(TitleType type)
PlotAxisConfig(QObject *parent=0, TitleType titleType=AutoTitle, const QString &customTitle="Untitled Axis", bool titleVisible=true)
void setTitleVisible(bool visible)
void write(QDataStream &stream) const
void load(QSettings &settings)
void save(QSettings &settings) const


rqt_multiplot
Author(s): Ralf Kaestner
autogenerated on Wed Jul 10 2019 03:49:44