ViewSelectionWidgetController.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 RobotAPI::gui-plugins::ViewSelectionWidgetController
17 * \author Markus Grotz ( markus dot grotz 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
25#include <RobotAPI/gui-plugins/ViewSelection/ui_ViewSelectionWidget.h>
26
27#include <string>
28
29#include <QListWidgetItem>
30
31using namespace armarx;
32
34{
35 widget = std::make_unique<Ui::ViewSelectionWidget>();
36 widget->setupUi(getWidget());
37
38 connect(widget->pushButton, SIGNAL(clicked()), this, SLOT(triggerSaliencyMapVisualization()));
39
40 connect(widget->pushButton_2, SIGNAL(clicked()), this, SLOT(clearSaliencyMapVisualization()));
41
42 connect(widget->pushButton_3, SIGNAL(clicked()), this, SLOT(updateSaliencyMapNames()));
43
44 connect(widget->checkBox, SIGNAL(toggled(bool)), this, SLOT(toggleViewSelection(bool)));
45}
46
50
51QPointer<QDialog>
53{
54 if (!configDialog)
55 {
56 configDialog = new ViewSelectionConfigDialog(parent);
57 }
58
59 return qobject_cast<ViewSelectionConfigDialog*>(configDialog);
60}
61
62void
64{
65 viewSelectionName = settings->value("viewSelectionName", "").toString().toStdString();
66}
67
68void
70{
71 viewSelectionName =
72 settings->value("viewSelectionName", QString::fromStdString(viewSelectionName))
73 .toString()
74 .toStdString();
75}
76
77void
79{
80 usingProxy(viewSelectionName);
81 usingTopic(viewSelectionName + "Observer");
82}
83
84void
86{
87 viewSelection = getProxy<ViewSelectionInterfacePrx>(viewSelectionName);
88
89 widget->checkBox->setChecked(viewSelection->isEnabledAutomaticViewSelection());
90}
91
92void
94{
95 widget->checkBox->setChecked(true);
96}
97
98void
100{
101 widget->checkBox->setChecked(false);
102}
103
104void
106{
107}
108
109void
111{
112 ARMARX_LOG << "toggling view selection " << isEnabled;
113
114 if (isEnabled)
115 {
116 viewSelection->activateAutomaticViewSelection();
117 }
118 else
119 {
120 viewSelection->deactivateAutomaticViewSelection();
121 }
122}
123
124void
126{
127 std::vector<std::string> names;
128
129 for (int r = 0; r < widget->listWidget->count(); r++)
130 {
131 QListWidgetItem* item = widget->listWidget->item(r);
132
133 if (item->checkState() == Qt::Checked)
134 {
135 names.push_back(item->text().toStdString());
136 }
137 }
138 viewSelection->drawSaliencySphere(names);
139}
140
141void
143{
144 std::vector<std::string> names = viewSelection->getSaliencyMapNames();
145
146 widget->listWidget->clear();
147
148 for (std::string name : names)
149 {
150 QListWidgetItem* item =
151 new QListWidgetItem(QString::fromStdString(name), widget->listWidget);
152 item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
153 item->setCheckState(Qt::Unchecked);
154 }
155}
156
157void
159{
160 viewSelection->clearSaliencySphere();
161}
162
163void
165{
166 viewSelectionName = configDialog->getViewSelectionName();
167}
virtual QPointer< QWidget > getWidget()
getWidget returns a pointer to the a widget of this controller.
bool usingProxy(const std::string &name, const std::string &endpoints="")
Registers a proxy for retrieval after initialization and adds it to the dependency list.
void usingTopic(const std::string &name, bool orderedPublishing=false)
Registers a proxy for subscription after initialization.
Ice::ObjectPrx getProxy(long timeoutMs=0, bool waitForScheduler=true) const
Returns the proxy of this object (optionally it waits for the proxy)
~ViewSelectionWidgetController() override
Controller destructor.
void onDeactivateAutomaticViewSelection(const Ice::Current &c=Ice::emptyCurrent) override
void loadSettings(QSettings *settings) override
void saveSettings(QSettings *settings) override
void onActivateAutomaticViewSelection(const Ice::Current &c=Ice::emptyCurrent) override
void nextViewTarget(Ice::Long, const Ice::Current &c=Ice::emptyCurrent) override
void configured() override
This function must be implemented by the user, if he supplies a config dialog.
QPointer< QDialog > getConfigDialog(QWidget *parent) override
getConfigDialog returns a pointer to the a configuration widget of this controller.
#define ARMARX_LOG
Definition Logging.h:163
This file offers overloads of toIce() and fromIce() functions for STL container types.