AffordancePipelineGuiConfigDialog.cpp
Go to the documentation of this file.
1 /*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @package VisionX
17 * @author Peter Kaiser (peter dot kaiser at kit dot edu)
18 * @date 2016
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22 
24 #include "ui_AffordancePipelineGuiConfigDialog.h"
25 
26 #include <QTimer>
27 #include <QPushButton>
28 #include <QMessageBox>
29 
31 
32 #include <VisionX/interface/core/PointCloudProviderInterface.h>
33 #include <VisionX/interface/core/PointCloudProcessorInterface.h>
34 #include <VisionX/interface/components/PointCloudSegmenter.h>
35 #include <VisionX/interface/components/PrimitiveMapper.h>
36 #include <VisionX/interface/components/AffordanceExtraction.h>
37 #include <VisionX/interface/components/AffordancePipelineVisualization.h>
38 
39 #include <RobotAPI/interface/core/RobotState.h>
40 
41 #include <boost/algorithm/string/split.hpp>
42 #include <boost/algorithm/string.hpp>
43 
44 #include <IceUtil/UUID.h>
45 
46 using namespace armarx;
47 
49  QDialog(parent),
51  uuid(IceUtil::generateUUID())
52 {
53  ui->setupUi(this);
54 
55  connect(this->ui->buttonBox, SIGNAL(accepted()), this, SLOT(verifyConfig()));
56  ui->buttonBox->button(QDialogButtonBox::Ok)->setDefault(true);
57 
58  pointCloudSegmenterProxyFinder = new IceProxyFinder<visionx::PointCloudSegmenterInterfacePrx>(this);
59  primitiveExtractorProxyFinder = new IceProxyFinder<visionx::PrimitiveMapperInterfacePrx>(this);
60  affordanceExtractionProxyFinder = new IceProxyFinder<AffordanceExtractionInterfacePrx>(this);
61  pipelineVisualizationProxyFinder = new IceProxyFinder<AffordancePipelineVisualizationInterfacePrx>(this);
62  robotStateComponentProxyFinder = new IceProxyFinder<RobotStateComponentInterfacePrx>(this);
63 
64  pointCloudSegmenterProxyFinder->setSearchMask("*");
65  primitiveExtractorProxyFinder->setSearchMask("*");
66  affordanceExtractionProxyFinder->setSearchMask("*");
67  pipelineVisualizationProxyFinder->setSearchMask("*");
68  robotStateComponentProxyFinder->setSearchMask("*");
69 
70  ui->gridLayout->addWidget(pointCloudSegmenterProxyFinder, 3, 1, 1, 2);
71  ui->gridLayout->addWidget(primitiveExtractorProxyFinder, 4, 1, 1, 2);
72  ui->gridLayout->addWidget(affordanceExtractionProxyFinder, 5, 1, 1, 2);
73  ui->gridLayout->addWidget(pipelineVisualizationProxyFinder, 6, 1, 1, 2);
74  ui->gridLayout->addWidget(robotStateComponentProxyFinder, 7, 1, 1, 2);
75 }
76 
78 {
79  delete ui;
80 }
81 
83 {
84  pointCloudSegmenterProxyFinder->setIceManager(getIceManager());
85  primitiveExtractorProxyFinder->setIceManager(getIceManager());
86  affordanceExtractionProxyFinder->setIceManager(getIceManager());
87  pipelineVisualizationProxyFinder->setIceManager(getIceManager());
88  robotStateComponentProxyFinder->setIceManager(getIceManager());
89 }
90 
92 {
93 }
94 
96 {
97  QObject::disconnect();
98 }
99 
101 {
102  return ui->lineEditPlatform->text().toStdString();
103 }
104 
106 {
107  std::vector<std::string> result;
108  std::string s = ui->lineEditProviderNames->text().toStdString();
109  boost::split(result, s, boost::is_any_of(","));
110  return result;
111 }
112 
114 {
115  std::vector<std::string> result;
116  std::string s = ui->lineEditProviderDisplayNames->text().toStdString();
117  boost::split(result, s, boost::is_any_of(","));
118  return result;
119 }
120 
122 {
123  std::vector<std::string> result;
124  std::string s = ui->lineEditFilteredProviderNames->text().toStdString();
125  boost::split(result, s, boost::is_any_of(","));
126  return result;
127 }
128 
130 {
131  std::vector<std::string> result;
132  std::string s = ui->lineEditConfigFiles->text().toStdString();
133  boost::split(result, s, boost::is_any_of(","));
134  return result;
135 }
136 
138 {
139  unsigned int l1 = pointCloudSegmenterProxyFinder->getSelectedProxyName().trimmed().length();
140  unsigned int l2 = primitiveExtractorProxyFinder->getSelectedProxyName().trimmed().length();
141  unsigned int l3 = affordanceExtractionProxyFinder->getSelectedProxyName().trimmed().length();
142  unsigned int l4 = pipelineVisualizationProxyFinder->getSelectedProxyName().trimmed().length();
143  unsigned int l5 = robotStateComponentProxyFinder->getSelectedProxyName().trimmed().length();
144 
145  if (!l1 || !l2 || !l3 || !l4 || !l5)
146  {
147  QMessageBox::critical(this, "Invalid Configuration", "The proxy names must not be empty");
148  return;
149  }
150 
151  if ((getProviderNames().size() != getProviderDisplayNames().size()) || (getProviderNames().size() != getFilteredProviderNames().size()))
152  {
153  QMessageBox::critical(this, "Invalid Configuration", "The provider name lists must be of equal size");
154  return;
155  }
156 
157  accept();
158 }
armarx::ManagedIceObject::getIceManager
IceManagerPtr getIceManager() const
Returns the IceManager.
Definition: ManagedIceObject.cpp:353
armarx::IceProxyFinderBase::setSearchMask
void setSearchMask(const QString &searchMask)
Definition: IceProxyFinder.cpp:88
armarx::AffordancePipelineGuiConfigDialog::onConnectComponent
void onConnectComponent() override
Pure virtual hook for the subclass.
Definition: AffordancePipelineGuiConfigDialog.cpp:91
armarx::IceProxyFinderBase::setIceManager
void setIceManager(IceManagerPtr icemanager, bool fetchProxies=true)
Definition: IceProxyFinder.cpp:64
armarx::AffordancePipelineGuiConfigDialog::getFilteredProviderNames
std::vector< std::string > getFilteredProviderNames()
Definition: AffordancePipelineGuiConfigDialog.cpp:121
AffordancePipelineGuiConfigDialog.h
IceUtil
Definition: Instance.h:21
armarx::AffordancePipelineGuiConfigDialog::getProviderNames
std::vector< std::string > getProviderNames()
Definition: AffordancePipelineGuiConfigDialog.cpp:105
armarx::AffordancePipelineGuiConfigDialog
Definition: AffordancePipelineGuiConfigDialog.h:40
Ui
ArmarX Headers.
Definition: ArmarXMainWindow.h:54
IceProxyFinder.h
armarx::AffordancePipelineGuiConfigDialog::onInitComponent
void onInitComponent() override
Pure virtual hook for the subclass.
Definition: AffordancePipelineGuiConfigDialog.cpp:82
armarx::AffordancePipelineGuiConfigDialog::onExitComponent
void onExitComponent() override
Hook for subclass.
Definition: AffordancePipelineGuiConfigDialog.cpp:95
armarx::AffordancePipelineGuiConfigDialog::getProviderDisplayNames
std::vector< std::string > getProviderDisplayNames()
Definition: AffordancePipelineGuiConfigDialog.cpp:113
armarx::IceProxyFinderBase::getSelectedProxyName
QString getSelectedProxyName() const
Definition: IceProxyFinder.cpp:73
armarx::AffordancePipelineGuiConfigDialog::verifyConfig
void verifyConfig()
Definition: AffordancePipelineGuiConfigDialog.cpp:137
armarx::IceProxyFinder
Definition: StatechartViewerController.h:51
armarx::AffordancePipelineGuiConfigDialog::getPlatform
std::string getPlatform()
Definition: AffordancePipelineGuiConfigDialog.cpp:100
armarx::AffordancePipelineGuiConfigDialog::AffordancePipelineGuiConfigDialog
AffordancePipelineGuiConfigDialog(QWidget *parent=0)
Definition: AffordancePipelineGuiConfigDialog.cpp:48
armarx::ctrlutil::s
double s(double t, double s0, double v0, double a0, double j)
Definition: CtrlUtil.h:33
armarx::AffordancePipelineGuiConfigDialog::getPipelineConfigurationFiles
std::vector< std::string > getPipelineConfigurationFiles()
Definition: AffordancePipelineGuiConfigDialog.cpp:129
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::AffordancePipelineGuiConfigDialog::~AffordancePipelineGuiConfigDialog
~AffordancePipelineGuiConfigDialog() override
Definition: AffordancePipelineGuiConfigDialog.cpp:77
armarx::split
std::vector< std::string > split(const std::string &source, const std::string &splitBy, bool trimElements=false, bool removeEmptyElements=false)
Definition: StringHelpers.cpp:36