Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "rqt_multiplot/CurveConfig.h"
00020
00021 namespace rqt_multiplot {
00022
00023
00024
00025
00026
00027 const QString CurveConfig::MimeType = "application/rqt-multiplot-curve-config";
00028
00029
00030
00031
00032
00033 CurveConfig::CurveConfig(QObject* parent, const QString& title, size_t
00034 subscriberQueueSize) :
00035 Config(parent),
00036 title_(title),
00037 colorConfig_(new CurveColorConfig(this)),
00038 styleConfig_(new CurveStyleConfig(this)),
00039 dataConfig_(new CurveDataConfig(this)),
00040 subscriberQueueSize_(subscriberQueueSize) {
00041 axisConfig_[X] = new CurveAxisConfig(this);
00042 axisConfig_[Y] = new CurveAxisConfig(this);
00043
00044 connect(axisConfig_[X], SIGNAL(changed()), this, SLOT(axisConfigChanged()));
00045 connect(axisConfig_[Y], SIGNAL(changed()), this, SLOT(axisConfigChanged()));
00046
00047 connect(colorConfig_, SIGNAL(changed()), this, SLOT(colorConfigChanged()));
00048 connect(styleConfig_, SIGNAL(changed()), this, SLOT(styleConfigChanged()));
00049
00050 connect(dataConfig_, SIGNAL(changed()), this, SLOT(dataConfigChanged()));
00051 }
00052
00053 CurveConfig::~CurveConfig() {
00054 }
00055
00056
00057
00058
00059
00060 void CurveConfig::setTitle(const QString& title) {
00061 if (title != title_) {
00062 title_ = title;
00063
00064 emit titleChanged(title);
00065 emit changed();
00066 }
00067 }
00068
00069 const QString& CurveConfig::getTitle() const {
00070 return title_;
00071 }
00072
00073 CurveAxisConfig* CurveConfig::getAxisConfig(Axis axis) const {
00074 QMap<Axis, CurveAxisConfig*>::const_iterator it = axisConfig_.find(axis);
00075
00076 if (it != axisConfig_.end())
00077 return it.value();
00078 else
00079 return 0;
00080 }
00081
00082 CurveColorConfig* CurveConfig::getColorConfig() const {
00083 return colorConfig_;
00084 }
00085
00086 CurveStyleConfig* CurveConfig::getStyleConfig() const {
00087 return styleConfig_;
00088 }
00089
00090 CurveDataConfig* CurveConfig::getDataConfig() const {
00091 return dataConfig_;
00092 }
00093
00094 void CurveConfig::setSubscriberQueueSize(size_t queueSize) {
00095 if (queueSize != subscriberQueueSize_) {
00096 subscriberQueueSize_ = queueSize;
00097
00098 emit subscriberQueueSizeChanged(queueSize);
00099 emit changed();
00100 }
00101 }
00102
00103 size_t CurveConfig::getSubscriberQueueSize() const {
00104 return subscriberQueueSize_;
00105 }
00106
00107
00108
00109
00110
00111 void CurveConfig::save(QSettings& settings) const {
00112 settings.setValue("title", title_);
00113
00114 settings.beginGroup("axes");
00115 settings.beginGroup("x_axis");
00116 axisConfig_[X]->save(settings);
00117 settings.endGroup();
00118 settings.beginGroup("y_axis");
00119 axisConfig_[Y]->save(settings);
00120 settings.endGroup();
00121 settings.endGroup();
00122
00123 settings.beginGroup("color");
00124 colorConfig_->save(settings);
00125 settings.endGroup();
00126
00127 settings.beginGroup("style");
00128 styleConfig_->save(settings);
00129 settings.endGroup();
00130
00131 settings.beginGroup("data");
00132 dataConfig_->save(settings);
00133 settings.endGroup();
00134
00135 settings.setValue("subscriber_queue_size", QVariant::
00136 fromValue<qulonglong>(subscriberQueueSize_));
00137 }
00138
00139 void CurveConfig::load(QSettings& settings) {
00140 setTitle(settings.value("title", "Untitled Curve").toString());
00141
00142 settings.beginGroup("axes");
00143 settings.beginGroup("x_axis");
00144 axisConfig_[X]->load(settings);
00145 settings.endGroup();
00146 settings.beginGroup("y_axis");
00147 axisConfig_[Y]->load(settings);
00148 settings.endGroup();
00149 settings.endGroup();
00150
00151 settings.beginGroup("color");
00152 colorConfig_->load(settings);
00153 settings.endGroup();
00154
00155 settings.beginGroup("style");
00156 styleConfig_->load(settings);
00157 settings.endGroup();
00158
00159 settings.beginGroup("data");
00160 dataConfig_->load(settings);
00161 settings.endGroup();
00162
00163 setSubscriberQueueSize(settings.value("subscriber_queue_size", 100).
00164 toULongLong());
00165 }
00166
00167 void CurveConfig::reset() {
00168 setTitle("Untitled Curve");
00169
00170 axisConfig_[X]->reset();
00171 axisConfig_[Y]->reset();
00172
00173 colorConfig_->reset();
00174 styleConfig_->reset();
00175
00176 dataConfig_->reset();
00177
00178 setSubscriberQueueSize(100);
00179 }
00180
00181 void CurveConfig::write(QDataStream& stream) const {
00182 stream << title_;
00183
00184 axisConfig_[X]->write(stream);
00185 axisConfig_[Y]->write(stream);
00186
00187 colorConfig_->write(stream);
00188 styleConfig_->write(stream);
00189
00190 dataConfig_->write(stream);
00191
00192 stream << (quint64)subscriberQueueSize_;
00193 }
00194
00195 void CurveConfig::read(QDataStream& stream) {
00196 QString title;
00197 quint64 subscriberQueueSize;
00198
00199 stream >> title;
00200 setTitle(title);
00201
00202 axisConfig_[X]->read(stream);
00203 axisConfig_[Y]->read(stream);
00204
00205 colorConfig_->read(stream);
00206 styleConfig_->read(stream);
00207
00208 dataConfig_->read(stream);
00209
00210 stream >> subscriberQueueSize;
00211 setSubscriberQueueSize(subscriberQueueSize);
00212 }
00213
00214
00215
00216
00217
00218 CurveConfig& CurveConfig::operator=(const CurveConfig& src) {
00219 setTitle(src.title_);
00220
00221 *axisConfig_[X] = *src.axisConfig_[X];
00222 *axisConfig_[Y] = *src.axisConfig_[Y];
00223
00224 *colorConfig_ = *src.colorConfig_;
00225 *styleConfig_ = *src.styleConfig_;
00226
00227 *dataConfig_ = *src.dataConfig_;
00228
00229 setSubscriberQueueSize(src.subscriberQueueSize_);
00230
00231 return *this;
00232 }
00233
00234
00235
00236
00237
00238 void CurveConfig::axisConfigChanged() {
00239 emit changed();
00240 }
00241
00242 void CurveConfig::colorConfigChanged() {
00243 emit changed();
00244 }
00245
00246 void CurveConfig::styleConfigChanged() {
00247 emit changed();
00248 }
00249
00250 void CurveConfig::dataConfigChanged() {
00251 emit changed();
00252 }
00253
00254 }