CurveConfigWidget.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 <ros/package.h>
00020 
00021 #include <ui_CurveConfigWidget.h>
00022 
00023 #include "rqt_multiplot/CurveConfigWidget.h"
00024 
00025 namespace rqt_multiplot {
00026 
00027 /*****************************************************************************/
00028 /* Constructors and Destructor                                               */
00029 /*****************************************************************************/
00030 
00031 CurveConfigWidget::CurveConfigWidget(QWidget* parent) :
00032   QWidget(parent),
00033   ui_(new Ui::CurveConfigWidget()),
00034   config_(new CurveConfig(this)),
00035   messageTopicRegistry_(new MessageTopicRegistry(this)) {
00036   ui_->setupUi(this);
00037 
00038   ui_->pushButtonCopyRight->setIcon(
00039     QIcon(QString::fromStdString(ros::package::getPath("rqt_multiplot").
00040     append("/resource/22x22/arrow_right.png"))));
00041   ui_->pushButtonCopyLeft->setIcon(
00042     QIcon(QString::fromStdString(ros::package::getPath("rqt_multiplot").
00043     append("/resource/22x22/arrow_left.png"))));
00044   ui_->pushButtonSwap->setIcon(
00045     QIcon(QString::fromStdString(ros::package::getPath("rqt_multiplot").
00046     append("/resource/22x22/arrows_right_left.png"))));
00047   
00048   ui_->curveAxisConfigWidgetX->setConfig(config_->getAxisConfig(
00049     CurveConfig::X));
00050   ui_->curveAxisConfigWidgetY->setConfig(config_->getAxisConfig(
00051     CurveConfig::Y));
00052   ui_->curveColorConfigWidget->setConfig(config_->getColorConfig());
00053   ui_->curveStyleConfigWidget->setConfig(config_->getStyleConfig());
00054   ui_->curveDataConfigWidget->setConfig(config_->getDataConfig());
00055   
00056   connect(config_, SIGNAL(titleChanged(const QString&)), this,
00057     SLOT(configTitleChanged(const QString&)));
00058   connect(config_, SIGNAL(subscriberQueueSizeChanged(size_t)), this,
00059     SLOT(configSubscriberQueueSizeChanged(size_t)));
00060   
00061   connect(config_->getAxisConfig(CurveConfig::X),
00062     SIGNAL(topicChanged(const QString&)), this,
00063     SLOT(configAxisConfigTopicChanged(const QString&)));
00064   connect(config_->getAxisConfig(CurveConfig::Y),
00065     SIGNAL(topicChanged(const QString&)), this,
00066     SLOT(configAxisConfigTopicChanged(const QString&)));
00067 
00068   connect(config_->getAxisConfig(CurveConfig::X),
00069     SIGNAL(typeChanged(const QString&)), this,
00070     SLOT(configAxisConfigTypeChanged(const QString&)));
00071   connect(config_->getAxisConfig(CurveConfig::Y),
00072     SIGNAL(typeChanged(const QString&)), this,
00073     SLOT(configAxisConfigTypeChanged(const QString&)));
00074   
00075   connect(ui_->lineEditTitle, SIGNAL(editingFinished()), this,
00076     SLOT(lineEditTitleEditingFinished()));
00077   connect(ui_->pushButtonCopyRight, SIGNAL(clicked()), this,
00078     SLOT(pushButtonCopyRightClicked()));
00079   connect(ui_->pushButtonCopyLeft, SIGNAL(clicked()), this,
00080     SLOT(pushButtonCopyLeftClicked()));
00081   connect(ui_->pushButtonSwap, SIGNAL(clicked()), this,
00082     SLOT(pushButtonSwapClicked()));
00083   connect(ui_->spinBoxSubscriberQueueSize, SIGNAL(valueChanged(int)),
00084     this, SLOT(spinBoxSubscriberQueueSizeValueChanged(int)));
00085   
00086   messageTopicRegistry_->update();
00087   
00088   configTitleChanged(config_->getTitle());
00089   configSubscriberQueueSizeChanged(config_->getSubscriberQueueSize());
00090 }
00091 
00092 CurveConfigWidget::~CurveConfigWidget() {
00093   delete ui_;
00094 }
00095 
00096 /*****************************************************************************/
00097 /* Accessors                                                                 */
00098 /*****************************************************************************/
00099 
00100 void CurveConfigWidget::setConfig(const CurveConfig& config) {
00101   *config_ = config;
00102 }
00103 
00104 CurveConfig& CurveConfigWidget::getConfig() {
00105   return *config_;
00106 }
00107 
00108 const CurveConfig& CurveConfigWidget::getConfig() const {
00109   return *config_;
00110 }
00111 
00112 /*****************************************************************************/
00113 /* Slots                                                                     */
00114 /*****************************************************************************/
00115 
00116 void CurveConfigWidget::configTitleChanged(const QString& title) {
00117   ui_->lineEditTitle->setText(title);
00118 }
00119 
00120 void CurveConfigWidget::configSubscriberQueueSizeChanged(size_t queueSize) {
00121   ui_->spinBoxSubscriberQueueSize->setValue(queueSize);
00122 }
00123 
00124 void CurveConfigWidget::configAxisConfigTopicChanged(const QString& topic) {
00125   CurveAxisConfig* source = static_cast<CurveAxisConfig*>(sender());
00126   CurveAxisConfig* destination = 0;
00127   
00128   if (source == config_->getAxisConfig(CurveConfig::X))
00129     destination = config_->getAxisConfig(CurveConfig::Y);
00130   else
00131     destination = config_->getAxisConfig(CurveConfig::X);  
00132   
00133   if (destination->getTopic().isEmpty())
00134     destination->setTopic(topic);
00135 }
00136 
00137 void CurveConfigWidget::configAxisConfigTypeChanged(const QString& type) {
00138   CurveAxisConfig* source = static_cast<CurveAxisConfig*>(sender());
00139   CurveAxisConfig* destination = 0;
00140   
00141   if (source == config_->getAxisConfig(CurveConfig::X))
00142     destination = config_->getAxisConfig(CurveConfig::Y);
00143   else
00144     destination = config_->getAxisConfig(CurveConfig::X);  
00145   
00146   if (destination->getType().isEmpty())
00147     destination->setType(type);
00148 }
00149 
00150 void CurveConfigWidget::lineEditTitleEditingFinished() {
00151   config_->setTitle(ui_->lineEditTitle->text());
00152 }
00153 
00154 void CurveConfigWidget::pushButtonCopyRightClicked() {
00155   *config_->getAxisConfig(CurveConfig::Y) = *config_->getAxisConfig(
00156     CurveConfig::X);
00157 }
00158 
00159 void CurveConfigWidget::pushButtonCopyLeftClicked() {
00160   *config_->getAxisConfig(CurveConfig::X) = *config_->getAxisConfig(
00161     CurveConfig::Y);
00162 }
00163 
00164 void CurveConfigWidget::pushButtonSwapClicked() {
00165   CurveAxisConfig xAxisConfig;
00166   
00167   xAxisConfig = *config_->getAxisConfig(CurveConfig::X);
00168   *config_->getAxisConfig(CurveConfig::X) = *config_->getAxisConfig(
00169     CurveConfig::Y);
00170   *config_->getAxisConfig(CurveConfig::Y) = xAxisConfig;
00171 }
00172 
00173 void CurveConfigWidget::spinBoxSubscriberQueueSizeValueChanged(int value) {
00174   config_->setSubscriberQueueSize(value);
00175 }
00176 
00177 }


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