SceneEditorConfigDialog.cpp
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2012-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5 *
6 * ArmarX is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * ArmarX is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * @package MemoryX::gui-plugins::SceneEditor
19 * @date 2015
20 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
21 * GNU General Public License
22 */
23
25
26#include <filesystem>
27
28#include <QComboBox>
29#include <QDialogButtonBox>
30#include <QFileDialog>
31#include <QMessageBox>
32#include <QPushButton>
33
34#include <IceUtil/UUID.h>
35
37
38#include <MemoryX/gui-plugins/SceneEditor/ui_SceneEditorConfigDialog.h>
39#include <MemoryX/interface/components/PriorKnowledgeInterface.h>
40#include <MemoryX/interface/components/WorkingMemoryInterface.h>
41
42//#include <QtCore/qfsfileengine.h>
43
44
46 QDialog(parent), ui(new Ui::SceneEditorConfigDialog)
47{
48 ui->setupUi(this);
49
50 workingMemoryProxyFinder = new armarx::IceProxyFinder<memoryx::WorkingMemoryInterfacePrx>(this);
51 workingMemoryProxyFinder->setSearchMask("WorkingMemory");
52 workingMemoryProxyFinder->showSearchMaskField(true);
53 workingMemoryProxyFinder->showLabels(false);
54 ui->workingMemoryGridLayout->addWidget(workingMemoryProxyFinder, 0, 1, 1, 2);
55
56 workingMemoryUpdatesTopicFinder = new armarx::IceTopicFinder(this);
57 workingMemoryUpdatesTopicFinder->setSearchMask("WorkingMemoryUpdates");
58 workingMemoryUpdatesTopicFinder->showSearchMaskField(false);
59 workingMemoryUpdatesTopicFinder->showLabels(false);
60 ui->workingMemoryGridLayout->addWidget(workingMemoryUpdatesTopicFinder, 1, 1, 1, 2);
61
62 priorKnowledgeProxyFinder =
64 priorKnowledgeProxyFinder->setSearchMask("PriorKnowledge");
65 priorKnowledgeProxyFinder->showSearchMaskField(true);
66 priorKnowledgeProxyFinder->showLabels(false);
67 ui->priorKnowledgeGridLayout->addWidget(priorKnowledgeProxyFinder, 0, 1, 1, 2);
68
69 connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(verifyConfiguration()));
70 ui->buttonBox->button(QDialogButtonBox::Ok)->setDefault(false);
71
72 std::filesystem::path currentPath(std::filesystem::current_path());
73 std::filesystem::path defaultFile("SceneEditor.ini");
74 this->ui->settingsFileLineEdit->setText(
75 QString::fromStdString((currentPath / defaultFile).string()));
76 connect(
77 ui->fileBrowserToolButton, SIGNAL(released()), this, SLOT(fileBrowserToolButtonReleased()));
78}
79
84
85std::string
87{
88 return "SceneEditorConfigDialog" + IceUtil::generateUUID();
89}
90
91void
93{
94 workingMemoryProxyFinder->setIceManager(this->getIceManager());
95 workingMemoryUpdatesTopicFinder->setIceManager(this->getIceManager());
96 priorKnowledgeProxyFinder->setIceManager(this->getIceManager());
97}
98
99void
103
104void
106{
107 QObject::disconnect();
108}
109
110void
115
116std::string
118{
119 return this->workingMemoryProxyFinder->getSelectedProxyName().toStdString();
120}
121
122std::string
124{
125 return this->workingMemoryUpdatesTopicFinder->getSelectedProxyName().toStdString();
126}
127
128std::string
130{
131 return this->priorKnowledgeProxyFinder->getSelectedProxyName().toStdString();
132}
133
134void
135gui::dialog::SceneEditorConfigDialog::verifyConfiguration()
136{
137 if (this->getWorkingMemoryName().length() == 0)
138 {
139 QMessageBox::critical(
140 this, tr("Invalid Configuration"), tr("The WorkingMemory name must not be empty."));
141 }
142 else if (this->getWorkingMemoryUpdatesTopic().length() == 0)
143 {
144 QMessageBox::critical(this,
145 tr("Invalid Configuration"),
146 tr("The WorkingMemory updates topic name must not be empty."));
147 }
148 else if (!this->isTopicAvailable(this->getWorkingMemoryUpdatesTopic()))
149 {
150 QMessageBox::critical(
151 this,
152 tr("Invalid Configuration"),
153 tr("The WorkingMemory updates topic name does not name an avaiable topic."));
154 }
155 else if (this->getPriorMemoryName().length() == 0)
156 {
157 QMessageBox::critical(
158 this, tr("Invalid Configuration"), tr("The PriorMemory name must not be empty."));
159 }
160 else if (this->ui->settingsFileLineEdit->text().length() == 0)
161 {
162 QMessageBox::critical(this,
163 tr("Invalid Configuration"),
164 tr("The settings file path name must not be empty."));
165 }
166 else
167 {
168 this->accept();
169 }
170}
171
172void
174{
175 this->ui->retranslateUi(this);
176}
177
178QString
180{
181 return this->ui->settingsFileLineEdit->text();
182}
183
184void
185gui::dialog::SceneEditorConfigDialog::fileBrowserToolButtonReleased()
186{
187 std::filesystem::path currentPath(this->ui->settingsFileLineEdit->text().toStdString());
188 QString filePath =
189 QFileDialog::getSaveFileName(this,
190 tr("Open settings file"),
191 QString::fromStdString(currentPath.remove_filename().string()),
192 tr("Settings (*.ini)"),
193 new QString(),
194 QFileDialog::DontConfirmOverwrite);
195
196 if (!filePath.endsWith(".ini", Qt::CaseSensitivity::CaseInsensitive) && !filePath.isEmpty())
197 {
198 filePath.append(".ini");
199 }
200
201 this->ui->settingsFileLineEdit->setText(filePath);
202}
203
204bool
205gui::dialog::SceneEditorConfigDialog::isTopicAvailable(std::string topicName)
206{
207 return this->workingMemoryUpdatesTopicFinder->getProxyNameList("*").contains(
208 QString::fromStdString(topicName));
209}
Widget to conveniently retrieve a proxy instance name of a specific interface type (the template para...
The IceTopicFinder class queries and show all available topic registered with IceStorm.
IceManagerPtr getIceManager() const
Returns the IceManager.
void setName(std::string name)
Override name of well-known object.
void onInitComponent() override
Reimplemented armarx::ManagedIceObject:onInitComponent().
SceneEditorConfigDialog(QWidget *parent=0)
Constructor.
std::string getWorkingMemoryUpdatesTopic()
Returns selected WorkingMemory updates topic.
QString getSettingsFilePath()
Returns the full path to the selected settings file.
void onConnectComponent() override
Reimplemented armarx::ManagedIceObject:onConnectComponent().
std::string getPriorMemoryName()
Returns selected PriorKnowledge name.
void setIceObjectName()
Sets unic name for this widget.
void onExitComponent() override
Reimplemented armarx::ManagedIceObject:onExitComponent().
void retranslate()
Translates all translatable strings in this dialog.
std::string getWorkingMemoryName()
Returns selected WorkingMemory name.
std::string getDefaultName() const override
Reimplemented armarx::ManagedIceObject:getDefaultName().
ArmarX Headers.