CurveAxisScaleConfigWidget.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 <QDoubleValidator>
00020 
00021 #include <ui_CurveAxisScaleConfigWidget.h>
00022 
00023 #include "rqt_multiplot/CurveAxisScaleConfigWidget.h"
00024 
00025 namespace rqt_multiplot {
00026 
00027 /*****************************************************************************/
00028 /* Constructors and Destructor                                               */
00029 /*****************************************************************************/
00030 
00031 CurveAxisScaleConfigWidget::CurveAxisScaleConfigWidget(QWidget* parent) :
00032   QWidget(parent),
00033   ui_(new Ui::CurveAxisScaleConfigWidget()),
00034   config_(0) {
00035   ui_->setupUi(this);
00036   
00037   ui_->lineEditAbsoluteMinimum->setEnabled(false);
00038   ui_->lineEditAbsoluteMaximum->setEnabled(false);
00039   ui_->lineEditRelativeMinimum->setEnabled(false);
00040   ui_->lineEditRelativeMaximum->setEnabled(false);
00041   
00042   ui_->lineEditAbsoluteMinimum->setValidator(
00043     new QDoubleValidator(ui_->lineEditAbsoluteMinimum));
00044   ui_->lineEditAbsoluteMaximum->setValidator(
00045     new QDoubleValidator(ui_->lineEditAbsoluteMaximum));
00046   ui_->lineEditRelativeMinimum->setValidator(
00047     new QDoubleValidator(ui_->lineEditRelativeMinimum));
00048   ui_->lineEditRelativeMaximum->setValidator(
00049     new QDoubleValidator(ui_->lineEditRelativeMaximum));
00050   
00051   connect(ui_->radioButtonAbsolute, SIGNAL(toggled(bool)), this,
00052     SLOT(radioButtonAbsoluteToggled(bool)));
00053   connect(ui_->radioButtonRelative, SIGNAL(toggled(bool)), this,
00054     SLOT(radioButtonRelativeToggled(bool)));
00055   connect(ui_->radioButtonAuto, SIGNAL(toggled(bool)), this,
00056     SLOT(radioButtonAutoToggled(bool)));
00057   
00058   connect(ui_->lineEditAbsoluteMinimum, SIGNAL(editingFinished()),
00059     this, SLOT(lineEditAbsoluteMinimumEditingFinished()));
00060   connect(ui_->lineEditAbsoluteMaximum, SIGNAL(editingFinished()),
00061     this, SLOT(lineEditAbsoluteMaximumEditingFinished()));
00062   connect(ui_->lineEditRelativeMinimum, SIGNAL(editingFinished()),
00063     this, SLOT(lineEditRelativeMinimumEditingFinished()));
00064   connect(ui_->lineEditRelativeMaximum, SIGNAL(editingFinished()),
00065     this, SLOT(lineEditRelativeMaximumEditingFinished()));
00066 }
00067 
00068 CurveAxisScaleConfigWidget::~CurveAxisScaleConfigWidget() {
00069   delete ui_;
00070 }
00071 
00072 /*****************************************************************************/
00073 /* Accessors                                                                 */
00074 /*****************************************************************************/
00075 
00076 void CurveAxisScaleConfigWidget::setConfig(CurveAxisScaleConfig* config) {
00077   if (config != config_) {
00078     if (config_) {
00079       disconnect(config_, SIGNAL(typeChanged(int)), this,
00080         SLOT(configTypeChanged(int)));
00081       disconnect(config_, SIGNAL(absoluteMinimumChanged(double)), this,
00082         SLOT(configAbsoluteMinimumChanged(double)));
00083       disconnect(config_, SIGNAL(absoluteMaximumChanged(double)), this,
00084         SLOT(configAbsoluteMaximumChanged(double)));
00085       disconnect(config_, SIGNAL(relativeMinimumChanged(double)), this,
00086         SLOT(configRelativeMinimumChanged(double)));
00087       disconnect(config_, SIGNAL(relativeMaximumChanged(double)), this,
00088         SLOT(configRelativeMaximumChanged(double)));
00089     }
00090     
00091     config_ = config;
00092     
00093     if (config) {
00094       connect(config, SIGNAL(typeChanged(int)), this,
00095         SLOT(configTypeChanged(int)));
00096       connect(config, SIGNAL(absoluteMinimumChanged(double)), this,
00097         SLOT(configAbsoluteMinimumChanged(double)));
00098       connect(config, SIGNAL(absoluteMaximumChanged(double)), this,
00099         SLOT(configAbsoluteMaximumChanged(double)));
00100       connect(config, SIGNAL(relativeMinimumChanged(double)), this,
00101         SLOT(configRelativeMinimumChanged(double)));
00102       connect(config, SIGNAL(relativeMaximumChanged(double)), this,
00103         SLOT(configRelativeMaximumChanged(double)));
00104       
00105       configTypeChanged(config->getType());
00106       configAbsoluteMinimumChanged(config->getAbsoluteMinimum());
00107       configAbsoluteMaximumChanged(config->getAbsoluteMaximum());
00108       configRelativeMinimumChanged(config->getRelativeMinimum());
00109       configRelativeMaximumChanged(config->getRelativeMaximum());
00110     }
00111   }
00112 }
00113 
00114 CurveAxisScaleConfig* CurveAxisScaleConfigWidget::getConfig() const {
00115   return config_;
00116 }
00117 
00118 /*****************************************************************************/
00119 /* Slots                                                                     */
00120 /*****************************************************************************/
00121 
00122 void CurveAxisScaleConfigWidget::configTypeChanged(int type) {
00123   if (type == CurveAxisScaleConfig::Absolute)
00124     ui_->radioButtonAbsolute->setChecked(true);
00125   else if (type == CurveAxisScaleConfig::Relative)
00126     ui_->radioButtonRelative->setChecked(true);
00127   else
00128     ui_->radioButtonAuto->setChecked(true);
00129 }
00130 
00131 void CurveAxisScaleConfigWidget::configAbsoluteMinimumChanged(double minimum) {
00132   ui_->lineEditAbsoluteMinimum->setText(QString::number(minimum));
00133 }
00134 
00135 void CurveAxisScaleConfigWidget::configAbsoluteMaximumChanged(double maximum) {
00136   ui_->lineEditAbsoluteMaximum->setText(QString::number(maximum));
00137 }
00138 
00139 void CurveAxisScaleConfigWidget::configRelativeMinimumChanged(double minimum) {
00140   ui_->lineEditRelativeMinimum->setText(QString::number(minimum));
00141 }
00142 
00143 void CurveAxisScaleConfigWidget::configRelativeMaximumChanged(double maximum) {
00144   ui_->lineEditRelativeMaximum->setText(QString::number(maximum));
00145 }
00146 
00147 void CurveAxisScaleConfigWidget::radioButtonAbsoluteToggled(bool checked) {
00148   ui_->lineEditAbsoluteMinimum->setEnabled(checked);
00149   ui_->lineEditAbsoluteMaximum->setEnabled(checked);
00150   
00151   if (config_ && checked)
00152     config_->setType(CurveAxisScaleConfig::Absolute);
00153 }
00154 
00155 void CurveAxisScaleConfigWidget::radioButtonRelativeToggled(bool checked) {
00156   ui_->lineEditRelativeMinimum->setEnabled(checked);
00157   ui_->lineEditRelativeMaximum->setEnabled(checked);
00158   
00159   if (config_ && checked)
00160     config_->setType(CurveAxisScaleConfig::Relative);
00161 }
00162 
00163 void CurveAxisScaleConfigWidget::radioButtonAutoToggled(bool checked) {
00164   if (config_ && checked)
00165     config_->setType(CurveAxisScaleConfig::Auto);
00166 }
00167 
00168 void CurveAxisScaleConfigWidget::lineEditAbsoluteMinimumEditingFinished() {
00169   if (config_)
00170     config_->setAbsoluteMinimum(ui_->lineEditAbsoluteMinimum->text().
00171       toDouble());
00172 }
00173 
00174 void CurveAxisScaleConfigWidget::lineEditAbsoluteMaximumEditingFinished() {
00175   if (config_)
00176     config_->setAbsoluteMaximum(ui_->lineEditAbsoluteMaximum->text().
00177       toDouble());
00178 }
00179 
00180 void CurveAxisScaleConfigWidget::lineEditRelativeMinimumEditingFinished() {
00181   if (config_)
00182     config_->setRelativeMinimum(ui_->lineEditRelativeMinimum->text().
00183       toDouble());
00184 }
00185 
00186 void CurveAxisScaleConfigWidget::lineEditRelativeMaximumEditingFinished() {
00187   if (config_)
00188     config_->setRelativeMaximum(ui_->lineEditRelativeMaximum->text().
00189       toDouble());
00190 }
00191 
00192 }


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