Go to the documentation of this file.00001 #include "mrta/architecture.h"
00002 #include "rqt_mrta/config/application/rqt_mrta_application.h"
00003 #include "rqt_mrta/config/architecture/rqt_mrta_architecture.h"
00004 #include "rqt_mrta/define_architecture_widget.h"
00005 #include "rqt_mrta/ui_define_architecture_widget.h"
00006 #include "utilities/exception.h"
00007
00008 namespace rqt_mrta
00009 {
00010 DefineArchitectureWidget::DefineArchitectureWidget(
00011 QWidget* parent, RqtMrtaApplicationConfig* application_config,
00012 RqtMrtaArchitectureConfig* architecture_config)
00013 : QWidget(parent), ui_(new Ui::DefineArchitectureWidget()),
00014 application_config_(NULL), architecture_config_(NULL)
00015 {
00016 if (!application_config)
00017 {
00018 throw utilities::Exception(
00019 "[DefineApplicationWidget] The application config must not be NULL.");
00020 }
00021 if (!architecture_config)
00022 {
00023 throw utilities::Exception(
00024 "[DefineApplicationWidget] The architecture config must not be NULL.");
00025 }
00026 ui_->setupUi(this);
00027 connect(ui_->allocations_type_combo_box, SIGNAL(currentIndexChanged(int)),
00028 this, SLOT(setFilterAllocationType()));
00029 connect(ui_->robots_type_combo_box, SIGNAL(currentIndexChanged(int)), this,
00030 SLOT(setFilterRobotType()));
00031 connect(ui_->tasks_type_combo_box, SIGNAL(currentIndexChanged(int)), this,
00032 SLOT(setFilterTaskType()));
00033 connect(ui_->architectures_combo_box, SIGNAL(unknownAchitecture()), this,
00034 SLOT(unknownAchitecture()));
00035 connect(ui_->architectures_combo_box,
00036 SIGNAL(currentArchitectureChanged(mrta::Architecture*)), this,
00037 SLOT(currentArchitectureChanged(mrta::Architecture*)));
00038 setApplicationConfig(application_config);
00039 setArchitectureConfig(architecture_config);
00040 }
00041
00042 DefineArchitectureWidget::~DefineArchitectureWidget()
00043 {
00044 architecture_config_ = NULL;
00045 application_config_ = NULL;
00046 if (ui_)
00047 {
00048 delete ui_;
00049 ui_ = NULL;
00050 }
00051 }
00052
00053 RqtMrtaArchitectureConfig*
00054 DefineArchitectureWidget::getArchitectureConfig() const
00055 {
00056 return architecture_config_;
00057 }
00058
00059 RqtMrtaApplicationConfig* DefineArchitectureWidget::getApplicationConfig() const
00060 {
00061 return application_config_;
00062 }
00063
00064 void DefineArchitectureWidget::setArchitectureConfig(
00065 RqtMrtaArchitectureConfig* config)
00066 {
00067 if (architecture_config_ != config)
00068 {
00069 if (architecture_config_)
00070 {
00071 disconnect(architecture_config_, SIGNAL(changed()), this, SIGNAL(changed()));
00072 }
00073 architecture_config_ = config;
00074 if (architecture_config_)
00075 {
00076 connect(config, SIGNAL(changed()), this, SIGNAL(changed()));
00077 }
00078 }
00079 }
00080
00081 void DefineArchitectureWidget::setApplicationConfig(
00082 RqtMrtaApplicationConfig* config)
00083 {
00084 if (application_config_ != config)
00085 {
00086 if (application_config_)
00087 {
00088 disconnect(application_config_, SIGNAL(changed()), this, SIGNAL(changed()));
00089 }
00090 application_config_ = config;
00091 if (application_config_)
00092 {
00093 connect(config, SIGNAL(changed()), this, SIGNAL(changed()));
00094 }
00095 }
00096 }
00097
00098 void DefineArchitectureWidget::setFilterAllocationType()
00099 {
00100 mrta::Taxonomy::AllocationType allocation_type(
00101 mrta::Taxonomy::getAllocationType(
00102 ui_->allocations_type_combo_box->currentText()));
00103 ui_->architectures_combo_box->setFilterAllocationType(allocation_type);
00104 }
00105
00106 void DefineArchitectureWidget::setFilterRobotType()
00107 {
00108 mrta::Taxonomy::RobotType robot_type(
00109 mrta::Taxonomy::getRobotType(ui_->robots_type_combo_box->currentText()));
00110 ui_->architectures_combo_box->setFilterRobotType(robot_type);
00111 }
00112
00113 void DefineArchitectureWidget::setFilterTaskType()
00114 {
00115 mrta::Taxonomy::TaskType task_type(
00116 mrta::Taxonomy::getTaskType(ui_->tasks_type_combo_box->currentText()));
00117 ui_->architectures_combo_box->setFilterTaskType(task_type);
00118 }
00119
00120 void DefineArchitectureWidget::unknownAchitecture()
00121 {
00122 ui_->taxonomy_label->setText("");
00123 application_config_->getApplication()->setArchitecturePackage("");
00124 }
00125
00126 void DefineArchitectureWidget::currentArchitectureChanged(
00127 mrta::Architecture* architecture)
00128 {
00129 ui_->taxonomy_label->setText(
00130 architecture ? mrta::Taxonomy::toQString(*architecture) : "");
00131 application_config_->getApplication()->setArchitecturePackage(
00132 architecture ? architecture->getPackage() : "");
00133 }
00134 }