CurveDataConfig.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/CurveDataConfig.h"
00020 
00021 namespace rqt_multiplot {
00022 
00023 /*****************************************************************************/
00024 /* Constructors and Destructor                                               */
00025 /*****************************************************************************/
00026 
00027 CurveDataConfig::CurveDataConfig(QObject* parent, Type type, size_t
00028     circularBufferCapacity, double timeFrameLength) :
00029   Config(parent),
00030   type_(type),
00031   circularBufferCapacity_(circularBufferCapacity),
00032   timeFrameLength_(timeFrameLength) {
00033 }
00034 
00035 CurveDataConfig::~CurveDataConfig() {
00036 }
00037 
00038 /*****************************************************************************/
00039 /* Accessors                                                                 */
00040 /*****************************************************************************/
00041 
00042 void CurveDataConfig::setType(Type type) {
00043   if (type != type_) {
00044     type_ = type;
00045     
00046     emit typeChanged(type);
00047     emit changed();
00048   }
00049 }
00050 
00051 CurveDataConfig::Type CurveDataConfig::getType() const {
00052   return type_;
00053 }
00054 
00055 void CurveDataConfig::setCircularBufferCapacity(size_t capacity) {
00056   if (capacity != circularBufferCapacity_) {
00057     circularBufferCapacity_ = capacity;
00058     
00059     emit circularBufferCapacityChanged(capacity);
00060     emit changed();
00061   }
00062 }
00063 
00064 size_t CurveDataConfig::getCircularBufferCapacity() const {
00065   return circularBufferCapacity_;
00066 }
00067 
00068 void CurveDataConfig::setTimeFrameLength(double length) {
00069   if (length != timeFrameLength_) {
00070     timeFrameLength_ = length;
00071 
00072     emit timeFrameLengthChanged(length);
00073     emit changed();
00074   }
00075 }
00076 
00077 double CurveDataConfig::getTimeFrameLength() const {
00078   return timeFrameLength_;
00079 }
00080 
00081 /*****************************************************************************/
00082 /* Methods                                                                   */
00083 /*****************************************************************************/
00084 
00085 void CurveDataConfig::save(QSettings& settings) const {
00086   settings.setValue("type", type_);
00087   settings.setValue("circular_buffer_capacity", QVariant::
00088     fromValue<qulonglong>(circularBufferCapacity_));
00089   settings.setValue("time_frame_length", QVariant::
00090     fromValue<qreal>(timeFrameLength_));
00091 }
00092 
00093 void CurveDataConfig::load(QSettings& settings) {
00094   setType(static_cast<Type>(settings.value("type", Vector).toInt()));
00095   setCircularBufferCapacity(settings.value("circular_buffer_capacity",
00096     10000).toULongLong());
00097   setTimeFrameLength(settings.value("time_frame_length", 10.0).toReal());
00098 }
00099 
00100 void CurveDataConfig::reset() {
00101   setType(Vector);
00102   setCircularBufferCapacity(10000);
00103   setTimeFrameLength(10.0);
00104 }
00105 
00106 void CurveDataConfig::write(QDataStream& stream) const {
00107   stream << (int)type_;
00108   stream << (quint64)circularBufferCapacity_;
00109   stream << (qreal)timeFrameLength_;
00110 }
00111 
00112 void CurveDataConfig::read(QDataStream& stream) {
00113   int type;
00114   quint64 circularBufferCapacity;
00115   qreal timeFrameLength;
00116   
00117   stream >> type;
00118   setType(static_cast<Type>(type));
00119   stream >> circularBufferCapacity;
00120   setCircularBufferCapacity(circularBufferCapacity);
00121   stream >> timeFrameLength;
00122   setTimeFrameLength(timeFrameLength);
00123 }
00124 
00125 /*****************************************************************************/
00126 /* Operators                                                                 */
00127 /*****************************************************************************/
00128 
00129 CurveDataConfig& CurveDataConfig::operator=(const CurveDataConfig& src) {
00130   setType(src.type_);
00131   setCircularBufferCapacity(src.circularBufferCapacity_);
00132   setTimeFrameLength(src.timeFrameLength_);
00133   
00134   return *this;
00135 }
00136 
00137 }


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