PlotAxisConfigWidget.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_PlotAxisConfigWidget.h>
00020 
00021 #include "rqt_multiplot/PlotAxisConfigWidget.h"
00022 
00023 namespace rqt_multiplot {
00024 
00025 /*****************************************************************************/
00026 /* Constructors and Destructor                                               */
00027 /*****************************************************************************/
00028 
00029 PlotAxisConfigWidget::PlotAxisConfigWidget(QWidget* parent) :
00030   QWidget(parent),
00031   ui_(new Ui::PlotAxisConfigWidget()),
00032   config_(0) {
00033   ui_->setupUi(this);
00034   
00035   connect(ui_->lineEditTitle, SIGNAL(editingFinished()),
00036     this, SLOT(lineEditTitleEditingFinished()));
00037   connect(ui_->checkBoxTitleAuto, SIGNAL(stateChanged(int)),
00038     this, SLOT(checkBoxTitleAutoStateChanged(int)));
00039   connect(ui_->checkBoxTitleVisible, SIGNAL(stateChanged(int)),
00040     this, SLOT(checkBoxTitleVisibleStateChanged(int)));
00041 }
00042 
00043 PlotAxisConfigWidget::~PlotAxisConfigWidget() {
00044   delete ui_;
00045 }
00046 
00047 /*****************************************************************************/
00048 /* Accessors                                                                 */
00049 /*****************************************************************************/
00050 
00051 void PlotAxisConfigWidget::setConfig(PlotAxisConfig* config) {
00052   if (config != config_) {
00053     if (config_) {
00054       disconnect(config_, SIGNAL(titleTypeChanged(int)),
00055         this, SLOT(configTitleTypeChanged(int)));
00056       disconnect(config_, SIGNAL(customTitleChanged(const QString&)),
00057         this, SLOT(configCustomTitleChanged(const QString&)));
00058       disconnect(config_, SIGNAL(titleVisibleChanged(bool)),
00059         this, SLOT(configTitleVisibleChanged(bool)));
00060     }
00061     
00062     config_ = config;
00063     
00064     if (config) {
00065       connect(config, SIGNAL(titleTypeChanged(int)),
00066         this, SLOT(configTitleTypeChanged(int)));
00067       connect(config, SIGNAL(customTitleChanged(const QString&)),
00068         this, SLOT(configCustomTitleChanged(const QString&)));
00069       connect(config, SIGNAL(titleVisibleChanged(bool)),
00070         this, SLOT(configTitleVisibleChanged(bool)));
00071       
00072       configTitleTypeChanged(config->getTitleType());
00073       configCustomTitleChanged(config->getCustomTitle());
00074       configTitleVisibleChanged(config->isTitleVisible());
00075     }
00076   }
00077 }
00078 
00079 PlotAxisConfig* PlotAxisConfigWidget::getConfig() const {
00080   return config_;
00081 }
00082 
00083 /*****************************************************************************/
00084 /* Slots                                                                     */
00085 /*****************************************************************************/
00086 
00087 void PlotAxisConfigWidget::configTitleTypeChanged(int type) {
00088   ui_->checkBoxTitleAuto->setCheckState((type == PlotAxisConfig::AutoTitle) ?
00089     Qt::Checked : Qt::Unchecked);
00090 }
00091 
00092 void PlotAxisConfigWidget::configCustomTitleChanged(const QString& title) {
00093   ui_->lineEditTitle->setText(title);
00094 }
00095 
00096 void PlotAxisConfigWidget::configTitleVisibleChanged(bool visible) {
00097   ui_->checkBoxTitleVisible->setCheckState(visible ? Qt::Checked :
00098     Qt::Unchecked);
00099 }
00100 
00101 void PlotAxisConfigWidget::checkBoxTitleAutoStateChanged(int state) {
00102   ui_->lineEditTitle->setEnabled(state != Qt::Checked);
00103   
00104   if (config_)
00105     config_->setTitleType((state == Qt::Checked) ? PlotAxisConfig::AutoTitle :
00106        PlotAxisConfig::CustomTitle);
00107 }
00108 
00109 void PlotAxisConfigWidget::lineEditTitleEditingFinished() {
00110   if (config_)
00111     config_->setCustomTitle(ui_->lineEditTitle->text());
00112 }
00113 
00114 void PlotAxisConfigWidget::checkBoxTitleVisibleStateChanged(int state) {
00115   if (config_)
00116     config_->setTitleVisible(state == Qt::Checked);
00117 }
00118 
00119 }


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