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/CurveDataConfig.h"
00020
00021 namespace rqt_multiplot {
00022
00023
00024
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
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
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
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 }