MultiplotWidget.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_MultiplotWidget.h>
00022 
00023 #include "rqt_multiplot/MultiplotWidget.h"
00024 
00025 namespace rqt_multiplot {
00026 
00027 /*****************************************************************************/
00028 /* Constructors and Destructor                                               */
00029 /*****************************************************************************/
00030 
00031 MultiplotWidget::MultiplotWidget(QWidget* parent) :
00032   QWidget(parent),
00033   ui_(new Ui::MultiplotWidget()),
00034   config_(new MultiplotConfig(this)),
00035   messageTypeRegistry_(new MessageTypeRegistry(this)),
00036   packageRegistry_(new PackageRegistry(this)) {
00037   ui_->setupUi(this);
00038 
00039   ui_->configWidget->setConfig(config_);
00040   ui_->plotTableConfigWidget->setConfig(config_->getTableConfig());
00041   ui_->plotTableConfigWidget->setPlotTable(ui_->plotTableWidget);
00042   ui_->plotTableWidget->setConfig(config_->getTableConfig());
00043 
00044   connect(ui_->configWidget, SIGNAL(currentConfigModifiedChanged(bool)),
00045     this, SLOT(configWidgetCurrentConfigModifiedChanged(bool)));
00046   connect(ui_->configWidget, SIGNAL(currentConfigUrlChanged(const QString&)),
00047     this, SLOT(configWidgetCurrentConfigUrlChanged(const QString&)));
00048 
00049   configWidgetCurrentConfigUrlChanged(QString());
00050 
00051   messageTypeRegistry_->update();
00052   packageRegistry_->update();
00053 }
00054 
00055 MultiplotWidget::~MultiplotWidget() {
00056   confirmClose();
00057 
00058   delete ui_;
00059 }
00060 
00061 /*****************************************************************************/
00062 /* Accessors                                                                 */
00063 /*****************************************************************************/
00064 
00065 MultiplotConfig* MultiplotWidget::getConfig() const {
00066   return config_;
00067 }
00068 
00069 QDockWidget* MultiplotWidget::getDockWidget() const {
00070   QDockWidget* dockWidget = 0;
00071   QObject* currentParent = parent();
00072 
00073   while (currentParent) {
00074     dockWidget = qobject_cast<QDockWidget*>(currentParent);
00075 
00076     if (dockWidget)
00077       break;
00078 
00079     currentParent = currentParent->parent();
00080   }
00081 
00082   return dockWidget;
00083 }
00084 
00085 void MultiplotWidget::setMaxConfigHistoryLength(size_t length) {
00086   ui_->configWidget->setMaxConfigUrlHistoryLength(length);
00087 }
00088 
00089 size_t MultiplotWidget::getMaxConfigHistoryLength() const {
00090   return ui_->configWidget->getMaxConfigUrlHistoryLength();
00091 }
00092 
00093 void MultiplotWidget::setConfigHistory(const QStringList& history) {
00094   ui_->configWidget->setConfigUrlHistory(history);
00095 }
00096 
00097 QStringList MultiplotWidget::getConfigHistory() const {
00098   return ui_->configWidget->getConfigUrlHistory();
00099 }
00100 
00101 void MultiplotWidget::runPlots() {
00102   ui_->plotTableConfigWidget->runPlots();
00103 }
00104 
00105 /*****************************************************************************/
00106 /* Methods                                                                   */
00107 /*****************************************************************************/
00108 
00109 void MultiplotWidget::loadConfig(const QString& url) {
00110   ui_->configWidget->loadConfig(url);
00111 }
00112 
00113 
00114 void MultiplotWidget::readBag(const QString& url) {
00115 //   ui_->bagReaderWidget->readBag(url);
00116 }
00117 
00118 bool MultiplotWidget::confirmClose() {
00119   return ui_->configWidget->confirmSave(false);
00120 }
00121 
00122 /*****************************************************************************/
00123 /* Slots                                                                     */
00124 /*****************************************************************************/
00125 
00126 void MultiplotWidget::configWidgetCurrentConfigModifiedChanged(bool
00127     modified) {
00128   configWidgetCurrentConfigUrlChanged(ui_->configWidget->
00129     getCurrentConfigUrl());
00130 }
00131 
00132 void MultiplotWidget::configWidgetCurrentConfigUrlChanged(const QString&
00133     url) {
00134   QString windowTitle = "Multiplot";
00135 
00136   if (!url.isEmpty())
00137     windowTitle += " - ["+url+"]";
00138   else
00139     windowTitle += " - [untitled]";
00140 
00141   if (ui_->configWidget->isCurrentConfigModified())
00142     windowTitle += "*";
00143 
00144   setWindowTitle(windowTitle);
00145 }
00146 
00147 }


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