CurveDataConfigWidget.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 <ui_CurveDataConfigWidget.h>
00020 
00021 #include "rqt_multiplot/CurveDataConfigWidget.h"
00022 
00023 namespace rqt_multiplot {
00024 
00025 /*****************************************************************************/
00026 /* Constructors and Destructor                                               */
00027 /*****************************************************************************/
00028 
00029 CurveDataConfigWidget::CurveDataConfigWidget(QWidget* parent) :
00030   QWidget(parent),
00031   ui_(new Ui::CurveDataConfigWidget()),
00032   config_(0) {
00033   ui_->setupUi(this);
00034   
00035   ui_->spinBoxCircularBufferCapacity->setEnabled(false);
00036   ui_->doubleSpinBoxTimeFrameLength->setEnabled(false);
00037   
00038   connect(ui_->radioButtonVector, SIGNAL(toggled(bool)), this,
00039     SLOT(radioButtonVectorToggled(bool)));
00040   connect(ui_->radioButtonList, SIGNAL(toggled(bool)), this,
00041     SLOT(radioButtonListToggled(bool)));
00042   connect(ui_->radioButtonCircularBuffer, SIGNAL(toggled(bool)), this,
00043     SLOT(radioButtonCircularBufferToggled(bool)));
00044   connect(ui_->radioButtonTimeFrame, SIGNAL(toggled(bool)), this,
00045     SLOT(radioButtonTimeFrameToggled(bool)));
00046   
00047   connect(ui_->spinBoxCircularBufferCapacity, SIGNAL(valueChanged(int)),
00048     this, SLOT(spinBoxCircularBufferCapacityValueChanged(int)));
00049   connect(ui_->doubleSpinBoxTimeFrameLength, SIGNAL(valueChanged(double)),
00050     this, SLOT(doubleSpinBoxTimeFrameLengthValueChanged(double)));
00051 }
00052 
00053 CurveDataConfigWidget::~CurveDataConfigWidget() {
00054   delete ui_;
00055 }
00056 
00057 /*****************************************************************************/
00058 /* Accessors                                                                 */
00059 /*****************************************************************************/
00060 
00061 void CurveDataConfigWidget::setConfig(CurveDataConfig* config) {
00062   if (config != config_) {
00063     if (config_) {
00064       disconnect(config_, SIGNAL(typeChanged(int)), this,
00065         SLOT(configTypeChanged(int)));
00066       disconnect(config_, SIGNAL(circularBufferCapacityChanged(size_t)),
00067         this, SLOT(configCircularBufferCapacityChanged(size_t)));
00068       disconnect(config_, SIGNAL(timeFrameLengthChanged(double)),
00069         this, SLOT(configTimeFrameLengthChanged(double)));
00070     }
00071     
00072     config_ = config;
00073     
00074     if (config) {
00075       connect(config, SIGNAL(typeChanged(int)), this,
00076         SLOT(configTypeChanged(int)));
00077       connect(config, SIGNAL(circularBufferCapacityChanged(size_t)),
00078         this, SLOT(configCircularBufferCapacityChanged(size_t)));
00079       connect(config, SIGNAL(timeFrameLengthChanged(double)),
00080         this, SLOT(configTimeFrameLengthChanged(double)));
00081       
00082       configTypeChanged(config->getType());
00083       configCircularBufferCapacityChanged(config->
00084         getCircularBufferCapacity());
00085       configTimeFrameLengthChanged(config->getTimeFrameLength());
00086     }
00087   }
00088 }
00089 
00090 CurveDataConfig* CurveDataConfigWidget::getConfig() const {
00091   return config_;
00092 }
00093 
00094 /*****************************************************************************/
00095 /* Slots                                                                     */
00096 /*****************************************************************************/
00097 
00098 void CurveDataConfigWidget::configTypeChanged(int type) {
00099   if (type == CurveDataConfig::List)
00100     ui_->radioButtonList->setChecked(true);
00101   else if (type == CurveDataConfig::CircularBuffer)
00102     ui_->radioButtonCircularBuffer->setChecked(true);
00103   else if (type == CurveDataConfig::TimeFrame)
00104     ui_->radioButtonTimeFrame->setChecked(true);
00105   else
00106     ui_->radioButtonVector->setChecked(true);
00107 }
00108 
00109 void CurveDataConfigWidget::configCircularBufferCapacityChanged(size_t
00110     capacity) {
00111   ui_->spinBoxCircularBufferCapacity->setValue(capacity);
00112 }
00113 
00114 void CurveDataConfigWidget::configTimeFrameLengthChanged(double length) {
00115   ui_->doubleSpinBoxTimeFrameLength->setValue(length);
00116 }
00117 
00118 void CurveDataConfigWidget::radioButtonVectorToggled(bool checked) {
00119   if (config_ && checked)
00120     config_->setType(CurveDataConfig::Vector);
00121 }
00122 
00123 void CurveDataConfigWidget::radioButtonListToggled(bool checked) {
00124   if (config_ && checked)
00125     config_->setType(CurveDataConfig::List);
00126 }
00127 
00128 void CurveDataConfigWidget::radioButtonCircularBufferToggled(bool checked) {
00129   ui_->spinBoxCircularBufferCapacity->setEnabled(checked);
00130   
00131   if (config_ && checked)
00132     config_->setType(CurveDataConfig::CircularBuffer);
00133 }
00134 
00135 void CurveDataConfigWidget::radioButtonTimeFrameToggled(bool checked) {
00136   ui_->doubleSpinBoxTimeFrameLength->setEnabled(checked);
00137 
00138   if (config_ && checked)
00139     config_->setType(CurveDataConfig::TimeFrame);
00140 }
00141 
00142 void CurveDataConfigWidget::spinBoxCircularBufferCapacityValueChanged(
00143     int value) {
00144   if (config_)
00145     config_->setCircularBufferCapacity(value);
00146 }
00147 
00148 void CurveDataConfigWidget::doubleSpinBoxTimeFrameLengthValueChanged(
00149     double value) {
00150   if (config_) {
00151     config_->setTimeFrameLength(value);
00152   }
00153 }
00154 
00155 }


rqt_multiplot
Author(s): Ralf Kaestner
autogenerated on Thu Jun 6 2019 21:49:10