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 <string>
26
27#include <QListWidgetItem>
28
29using namespace armarx;
30
32{
33 widget.setupUi(getWidget());
34
35 connect(widget.pushButton, SIGNAL(clicked()), this, SLOT(triggerSaliencyMapVisualization()));
36
37 connect(widget.pushButton_2, SIGNAL(clicked()), this, SLOT(clearSaliencyMapVisualization()));
38
39 connect(widget.pushButton_3, SIGNAL(clicked()), this, SLOT(updateSaliencyMapNames()));
40
41 connect(widget.checkBox, SIGNAL(toggled(bool)), this, SLOT(toggleViewSelection(bool)));
42}
43
47
48QPointer<QDialog>
50{
51 if (!configDialog)
52 {
53 configDialog = new ViewSelectionConfigDialog(parent);
54 }
55
56 return qobject_cast<ViewSelectionConfigDialog*>(configDialog);
57}
58
59void
61{
62 viewSelectionName = settings->value("viewSelectionName", "").toString().toStdString();
63}
64
65void
67{
68 viewSelectionName =
69 settings->value("viewSelectionName", QString::fromStdString(viewSelectionName))
70 .toString()
71 .toStdString();
72}
73
74void
76{
77 usingProxy(viewSelectionName);
78 usingTopic(viewSelectionName + "Observer");
79}
80
81void
83{
84 viewSelection = getProxy<ViewSelectionInterfacePrx>(viewSelectionName);
85
86 widget.checkBox->setChecked(viewSelection->isEnabledAutomaticViewSelection());
87}
88
89void
91{
92 widget.checkBox->setChecked(true);
93}
94
95void
97{
98 widget.checkBox->setChecked(false);
99}
100
101void
103{
104}
105
106void
108{
109 ARMARX_LOG << "toggling view selection " << isEnabled;
110
111 if (isEnabled)
112 {
113 viewSelection->activateAutomaticViewSelection();
114 }
115 else
116 {
117 viewSelection->deactivateAutomaticViewSelection();
118 }
119}
120
121void
123{
124 std::vector<std::string> names;
125
126 for (int r = 0; r < widget.listWidget->count(); r++)
127 {
128 QListWidgetItem* item = widget.listWidget->item(r);
129
130 if (item->checkState() == Qt::Checked)
131 {
132 names.push_back(item->text().toStdString());
133 }
134 }
135 viewSelection->drawSaliencySphere(names);
136}
137
138void
140{
141 std::vector<std::string> names = viewSelection->getSaliencyMapNames();
142
143 widget.listWidget->clear();
144
145 for (std::string name : names)
146 {
147 QListWidgetItem* item =
148 new QListWidgetItem(QString::fromStdString(name), widget.listWidget);
149 item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
150 item->setCheckState(Qt::Unchecked);
151 }
152}
153
154void
156{
157 viewSelection->clearSaliencySphere();
158}
159
160void
162{
163 viewSelectionName = configDialog->getViewSelectionName();
164}
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:165
This file offers overloads of toIce() and fromIce() functions for STL container types.