CurveColorConfig.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 
22 
23 namespace rqt_multiplot {
24 
25 /*****************************************************************************/
26 /* Constructors and Destructor */
27 /*****************************************************************************/
28 
29 CurveColorConfig::CurveColorConfig(QObject* parent, Type type, unsigned char
30  autoColorIndex, const QColor& customColor) :
31  Config(parent),
32  type_(type),
33  autoColorIndex_(autoColorIndex),
34  customColor_(customColor) {
35 }
36 
38 }
39 
40 /*****************************************************************************/
41 /* Accessors */
42 /*****************************************************************************/
43 
45  if (type != type_) {
46  type_ = type;
47 
48  emit typeChanged(type);
50  emit changed();
51  }
52 }
53 
55  return type_;
56 }
57 
58 void CurveColorConfig::setAutoColorIndex(unsigned char index) {
59  if (index != autoColorIndex_) {
60  autoColorIndex_ = index;
61 
62  emit autoColorIndexChanged(index);
64  emit changed();
65  }
66 }
67 
68 unsigned char CurveColorConfig::getAutoColorIndex() const {
69  return autoColorIndex_;
70 }
71 
72 void CurveColorConfig::setCustomColor(const QColor& color) {
73  if (color != customColor_) {
74  customColor_ = color;
75 
76  emit customColorChanged(color);
77  if (type_ == Custom)
79  emit changed();
80  }
81 }
82 
83 const QColor& CurveColorConfig::getCustomColor() const {
84  return customColor_;
85 }
86 
88  if (type_ == Auto)
90  else
91  return customColor_;
92 }
93 
94 /*****************************************************************************/
95 /* Methods */
96 /*****************************************************************************/
97 
98 void CurveColorConfig::save(QSettings& settings) const {
99  settings.setValue("type", type_);
100  settings.setValue("custom_color", QVariant::fromValue<QColor>(
101  customColor_));
102 }
103 
104 void CurveColorConfig::load(QSettings& settings) {
105  setType(static_cast<Type>(settings.value("type", Auto).toInt()));
106  setCustomColor(settings.value("custom_color", QColor(Qt::black)).
107  value<QColor>());
108 }
109 
111  setType(Auto);
112  setCustomColor(Qt::black);
113 }
114 
115 void CurveColorConfig::write(QDataStream& stream) const {
116  stream << type_;
117  stream << customColor_;
118 }
119 
120 void CurveColorConfig::read(QDataStream& stream) {
121  int type;
122  QColor customColor;
123 
124  stream >> type;
125  setType(static_cast<Type>(type));
126  stream >> customColor;
127  setCustomColor(customColor);
128 }
129 
130 /*****************************************************************************/
131 /* Operators */
132 /*****************************************************************************/
133 
135  setType(src.type_);
138 
139  return *this;
140 }
141 
142 }
CurveColorConfig(QObject *parent=0, Type type=Auto, unsigned char autoColorIndex=0, const QColor &customColor=Qt::black)
const QColor & getCustomColor() const
void customColorChanged(const QColor &color)
void load(QSettings &settings)
void save(QSettings &settings) const
CurveColorConfig & operator=(const CurveColorConfig &src)
unsigned char getAutoColorIndex() const
void write(QDataStream &stream) const
void setAutoColorIndex(unsigned char index)
void read(QDataStream &stream)
void currentColorChanged(const QColor &color)
static QColor intToRgb(unsigned char val)
void autoColorIndexChanged(unsigned char index)
void setCustomColor(const QColor &color)


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