Go to the documentation of this file.00001 #include "rqt_mrta/config/application/robot.h"
00002 #include "rqt_mrta/config/application/robots.h"
00003 #include "rqt_mrta/config/application/rqt_mrta_application.h"
00004 #include "rqt_mrta/config/architecture/rqt_mrta_architecture.h"
00005 #include "rqt_mrta/define_parameters_widget.h"
00006 #include "rqt_mrta/param_tree_widget.h"
00007 #include "rqt_mrta/ui_define_parameters_widget.h"
00008
00009 namespace rqt_mrta
00010 {
00011 DefineParametersWidget::DefineParametersWidget(
00012 QWidget* parent, RqtMrtaApplicationConfig* application_config,
00013 RqtMrtaArchitectureConfig* architecture_config)
00014 : QWidget(parent), ui_(new Ui::DefineParametersWidget()),
00015 application_config_(NULL), architecture_config_(NULL)
00016 {
00017 ui_->setupUi(this);
00018 ui_->parameters_tab_widget->clear();
00019 setArchitectureConfig(architecture_config);
00020 setApplicationConfig(application_config);
00021 }
00022
00023 DefineParametersWidget::~DefineParametersWidget()
00024 {
00025 architecture_config_ = NULL;
00026 application_config_ = NULL;
00027 if (ui_)
00028 {
00029 delete ui_;
00030 ui_ = NULL;
00031 }
00032 }
00033
00034 RqtMrtaArchitectureConfig* DefineParametersWidget::getArchitectureConfig() const
00035 {
00036 return architecture_config_;
00037 }
00038
00039 RqtMrtaApplicationConfig* DefineParametersWidget::getApplicationConfig() const
00040 {
00041 return application_config_;
00042 }
00043
00044 void DefineParametersWidget::setArchitectureConfig(
00045 RqtMrtaArchitectureConfig* config)
00046 {
00047 if (config != architecture_config_)
00048 {
00049 if (architecture_config_)
00050 {
00051 disconnect(architecture_config_, SIGNAL(changed()), this,
00052 SIGNAL(changed()));
00053 }
00054 architecture_config_ = config;
00055 if (architecture_config_)
00056 {
00057 connect(config, SIGNAL(changed()), this, SIGNAL(changed()));
00058 }
00059 }
00060 }
00061
00062 QString DefineParametersWidget::validate() const
00063 {
00064 QString validation;
00065 for (size_t index(0); index < ui_->parameters_tab_widget->count(); index++)
00066 {
00067 ParamTreeWidget* tree = static_cast<ParamTreeWidget*>(
00068 ui_->parameters_tab_widget->widget(index));
00069 validation = tree->validate();
00070 if (!validation.isEmpty())
00071 {
00072 return validation;
00073 }
00074 }
00075 return validation;
00076 }
00077
00078 void DefineParametersWidget::setApplicationConfig(
00079 RqtMrtaApplicationConfig* config)
00080 {
00081 if (config != application_config_)
00082 {
00083 if (application_config_)
00084 {
00085 disconnect(application_config_, SIGNAL(changed()), this,
00086 SIGNAL(changed()));
00087 ui_->parameters_tab_widget->clear();
00088 }
00089 application_config_ = config;
00090 if (application_config_)
00091 {
00092 connect(application_config_, SIGNAL(changed()), this, SIGNAL(changed()));
00093 }
00094 }
00095 }
00096
00097 void DefineParametersWidget::loadTabs()
00098 {
00099 ui_->parameters_tab_widget->clear();
00100 config::Configs* application_configs = application_config_->getConfigs();
00101 config::Launches* application_launches = application_config_->getLaunches();
00102 config::Configs* architecture_configs = architecture_config_->getConfigs();
00103 config::Launches* architecture_launches = architecture_config_->getLaunches();
00104 RobotsConfig* robots = application_config_->getApplication()->getRobots();
00105 QString robots_config_id(architecture_config_->getArchitecture()->getRobots()->getConfigId());
00106 QString robots_launch_id(architecture_config_->getArchitecture()->getRobots()->getLaunchId());
00107 application_configs->setConfigs(*architecture_configs, *robots, robots_config_id);
00108 application_launches->setLaunches(*architecture_launches, *robots, robots_launch_id);
00109 for (size_t index(0); index < application_configs->count(); index++)
00110 {
00111 config::Config* config = application_configs->getConfig(index);
00112 ParamTreeWidget* tree = new ParamTreeWidget(ui_->parameters_tab_widget);
00113 tree->setConfig(config);
00114 ui_->parameters_tab_widget->addTab(tree, config->getId());
00115 }
00116 }
00117 }