CurveStyleConfig.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 CurveStyleConfig::CurveStyleConfig(QObject* parent, Type type, bool
28  linesInterpolate, Qt::Orientation sticksOrientation, double
29  sticksBaseline, bool stepsInvert, size_t penWidth, Qt::PenStyle
30  penStyle, bool renderAntialias) :
31  Config(parent),
32  type_(type),
33  linesInterpolate_(linesInterpolate),
34  sticksOrientation_(sticksOrientation),
35  sticksBaseline_(sticksBaseline),
36  stepsInvert_(stepsInvert),
37  penWidth_(penWidth),
38  penStyle_(penStyle),
39  renderAntialias_(renderAntialias) {
40 }
41 
43 }
44 
45 /*****************************************************************************/
46 /* Accessors */
47 /*****************************************************************************/
48 
50  if (type != type_) {
51  type_ = type;
52 
53  emit typeChanged(type);
54  emit changed();
55  }
56 }
57 
59  return type_;
60 }
61 
62 void CurveStyleConfig::setLinesInterpolate(bool interpolate) {
63  if (interpolate != linesInterpolate_) {
64  linesInterpolate_ = interpolate;
65 
66  emit linesInterpolateChanged(interpolate);
67  emit changed();
68  }
69 }
70 
72  return linesInterpolate_;
73 }
74 
75 void CurveStyleConfig::setSticksOrientation(Qt::Orientation orientation) {
76  if (orientation != sticksOrientation_) {
77  sticksOrientation_ = orientation;
78 
79  emit sticksOrientationChanged(orientation);
80  emit changed();
81  }
82 }
83 
84 Qt::Orientation CurveStyleConfig::getSticksOrientation() const {
85  return sticksOrientation_;
86 }
87 
88 void CurveStyleConfig::setSticksBaseline(double baseline) {
89  if (baseline != sticksBaseline_) {
90  sticksBaseline_ = baseline;
91 
92  emit sticksBaselineChanged(baseline);
93  emit changed();
94  }
95 }
96 
98  return sticksBaseline_;
99 }
100 
102  if (invert != stepsInvert_) {
103  stepsInvert_ = invert;
104 
105  emit stepsInvertChanged(invert);
106  emit changed();
107  }
108 }
109 
111  return stepsInvert_;
112 }
113 
114 void CurveStyleConfig::setPenWidth(size_t width) {
115  if (width != penWidth_) {
116  penWidth_ = width;
117 
118  emit penWidthChanged(width);
119  emit changed();
120  }
121 }
122 
124  return penWidth_;
125 }
126 
127 void CurveStyleConfig::setPenStyle(Qt::PenStyle style) {
128  if (style != penStyle_) {
129  penStyle_ = style;
130 
131  emit penStyleChanged(style);
132  emit changed();
133  }
134 }
135 
136 Qt::PenStyle CurveStyleConfig::getPenStyle() const {
137  return penStyle_;
138 }
139 
141  if (antialias != renderAntialias_) {
142  renderAntialias_ = antialias;
143 
144  emit renderAntialiasChanged(antialias);
145  emit changed();
146  }
147 }
148 
150  return renderAntialias_;
151 }
152 
153 /*****************************************************************************/
154 /* Methods */
155 /*****************************************************************************/
156 
157 void CurveStyleConfig::save(QSettings& settings) const {
158  settings.setValue("type", type_);
159 
160  settings.setValue("lines_interpolate", linesInterpolate_);
161  settings.setValue("sticks_orientation", sticksOrientation_);
162  settings.setValue("sticks_baseline", sticksBaseline_);
163  settings.setValue("steps_invert", stepsInvert_);
164 
165  settings.setValue("pen_width", QVariant::fromValue<qulonglong>(penWidth_));
166  settings.setValue("pen_style", (int)penStyle_);
167  settings.setValue("render_antialias", renderAntialias_);
168 }
169 
170 void CurveStyleConfig::load(QSettings& settings) {
171  setType(static_cast<Type>(settings.value("type", Lines).toInt()));
172 
173  setLinesInterpolate(settings.value("lines_interpolate", false).toBool());
174  setSticksOrientation(static_cast<Qt::Orientation>(settings.value(
175  "sticks_orientation", Qt::Vertical).toInt()));
176  setSticksBaseline(settings.value("sticks_baseline", 0.0).toDouble());
177  setStepsInvert(settings.value("steps_invert", false).toBool());
178 
179  setPenWidth(settings.value("pen_width", 1).toULongLong());
180  setPenStyle(static_cast<Qt::PenStyle>(settings.value(
181  "pen_style", (int)Qt::SolidLine).toInt()));
182  setRenderAntialias(settings.value("render_antialias", false).toBool());
183 }
184 
186  setType(Lines);
187 
188  setLinesInterpolate(false);
189  setSticksOrientation(Qt::Vertical);
190  setSticksBaseline(0.0);
191  setStepsInvert(false);
192 
193  setPenWidth(1);
194  setPenStyle(Qt::SolidLine);
195  setRenderAntialias(false);
196 }
197 
198 void CurveStyleConfig::write(QDataStream& stream) const {
199  stream << (int)type_;
200 
201  stream << linesInterpolate_;
202  stream << (int)sticksOrientation_;
203  stream << sticksBaseline_;
204  stream << stepsInvert_;
205 
206  stream << (quint64)penWidth_;
207  stream << (int)penStyle_;
208  stream << renderAntialias_;
209 }
210 
211 void CurveStyleConfig::read(QDataStream& stream) {
212  int type, sticksOrientation, penStyle;
213  bool linesInterpolate, stepsInvert, renderAntialias;
214  double sticksBaseline;
215  quint64 penWidth;
216 
217  stream >> type;
218  setType(static_cast<Type>(type));
219 
220  stream >> linesInterpolate;
221  setLinesInterpolate(linesInterpolate);
222  stream >> sticksOrientation;
223  setSticksOrientation(static_cast<Qt::Orientation>(sticksOrientation));
224  stream >> sticksBaseline;
225  setSticksBaseline(sticksBaseline);
226  stream >> stepsInvert;
227  setStepsInvert(stepsInvert);
228 
229  stream >> penWidth;
230  setPenWidth(penWidth);
231  stream >> penStyle;
232  setPenStyle(static_cast<Qt::PenStyle>(penStyle));
233  stream >> renderAntialias;
234  setRenderAntialias(renderAntialias);
235 }
236 
237 /*****************************************************************************/
238 /* Operators */
239 /*****************************************************************************/
240 
242  setType(src.type_);
243 
248 
249  setPenWidth(src.penWidth_);
250  setPenStyle(src.penStyle_);
252 
253  return *this;
254 }
255 
256 }
void sticksOrientationChanged(int orientation)
CurveStyleConfig(QObject *parent=0, Type type=Lines, bool linesInterpolate=false, Qt::Orientation sticksOrientation=Qt::Vertical, double sticksBaseline=0.0, bool stepsInvert=false, size_t penWidth=1, Qt::PenStyle penStyle=Qt::SolidLine, bool renderAntialias=false)
void setLinesInterpolate(bool interpolate)
void renderAntialiasChanged(bool antialias)
void save(QSettings &settings) const
void sticksBaselineChanged(double baseline)
void setSticksBaseline(double baseline)
void write(QDataStream &stream) const
void penWidthChanged(size_t width)
void setPenStyle(Qt::PenStyle style)
void setSticksOrientation(Qt::Orientation orientation)
void linesInterpolateChanged(bool interpolate)
Qt::Orientation getSticksOrientation() const
void load(QSettings &settings)
void setRenderAntialias(bool antialias)
CurveStyleConfig & operator=(const CurveStyleConfig &src)
void read(QDataStream &stream)
void stepsInvertChanged(bool invert)


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