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 
29 using 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 
45 {
46 }
47 
48 QPointer<QDialog>
50 {
51  if (!configDialog)
52  {
53  configDialog = new ViewSelectionConfigDialog(parent);
54  }
55 
56  return qobject_cast<ViewSelectionConfigDialog*>(configDialog);
57 }
58 
59 void
61 {
62  viewSelectionName = settings->value("viewSelectionName", "").toString().toStdString();
63 }
64 
65 void
67 {
68  viewSelectionName =
69  settings->value("viewSelectionName", QString::fromStdString(viewSelectionName))
70  .toString()
71  .toStdString();
72 }
73 
74 void
76 {
77  usingProxy(viewSelectionName);
78  usingTopic(viewSelectionName + "Observer");
79 }
80 
81 void
83 {
84  viewSelection = getProxy<ViewSelectionInterfacePrx>(viewSelectionName);
85 
86  widget.checkBox->setChecked(viewSelection->isEnabledAutomaticViewSelection());
87 }
88 
89 void
91 {
92  widget.checkBox->setChecked(true);
93 }
94 
95 void
97 {
98  widget.checkBox->setChecked(false);
99 }
100 
101 void
103 {
104 }
105 
106 void
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 
121 void
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 
138 void
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 
154 void
156 {
157  viewSelection->clearSaliencySphere();
158 }
159 
160 void
162 {
163  viewSelectionName = configDialog->getViewSelectionName();
164 }
armarx::ViewSelectionWidgetController::onConnectComponent
void onConnectComponent() override
Definition: ViewSelectionWidgetController.cpp:82
armarx::ViewSelectionWidgetController::saveSettings
void saveSettings(QSettings *settings) override
Definition: ViewSelectionWidgetController.cpp:66
armarx::ViewSelectionWidgetController::configured
void configured() override
This function must be implemented by the user, if he supplies a config dialog.
Definition: ViewSelectionWidgetController.cpp:161
armarx::ViewSelectionWidgetController::onInitComponent
void onInitComponent() override
Definition: ViewSelectionWidgetController.cpp:75
armarx::ViewSelectionWidgetController::nextViewTarget
void nextViewTarget(Ice::Long, const Ice::Current &c=Ice::emptyCurrent) override
Definition: ViewSelectionWidgetController.cpp:102
armarx::ViewSelectionWidgetController::triggerSaliencyMapVisualization
void triggerSaliencyMapVisualization()
Definition: ViewSelectionWidgetController.cpp:122
armarx::ViewSelectionWidgetController::getConfigDialog
QPointer< QDialog > getConfigDialog(QWidget *parent) override
getConfigDialog returns a pointer to the a configuration widget of this controller.
Definition: ViewSelectionWidgetController.cpp:49
armarx::VariantType::Long
const VariantTypeId Long
Definition: Variant.h:918
armarx::ViewSelectionWidgetController::onActivateAutomaticViewSelection
void onActivateAutomaticViewSelection(const Ice::Current &c=Ice::emptyCurrent) override
Definition: ViewSelectionWidgetController.cpp:90
ARMARX_LOG
#define ARMARX_LOG
Definition: Logging.h:165
armarx::ViewSelectionWidgetController::updateSaliencyMapNames
void updateSaliencyMapNames()
Definition: ViewSelectionWidgetController.cpp:139
ViewSelectionConfigDialog
Definition: ViewSelectionConfigDialog.h:15
armarx::ManagedIceObject::usingTopic
void usingTopic(const std::string &name, bool orderedPublishing=false)
Registers a proxy for subscription after initialization.
Definition: ManagedIceObject.cpp:254
armarx::ViewSelectionWidgetController::toggleViewSelection
void toggleViewSelection(bool enabled)
Definition: ViewSelectionWidgetController.cpp:107
armarx::viz::data::ElementFlags::names
const simox::meta::IntEnumNames names
Definition: json_elements.cpp:13
armarx::ViewSelectionWidgetController::onDeactivateAutomaticViewSelection
void onDeactivateAutomaticViewSelection(const Ice::Current &c=Ice::emptyCurrent) override
Definition: ViewSelectionWidgetController.cpp:96
armarx::ArmarXWidgetController::getWidget
virtual QPointer< QWidget > getWidget()
getWidget returns a pointer to the a widget of this controller.
Definition: ArmarXWidgetController.cpp:54
armarx::ViewSelectionWidgetController::~ViewSelectionWidgetController
~ViewSelectionWidgetController() override
Controller destructor.
Definition: ViewSelectionWidgetController.cpp:44
armarx::ViewSelectionWidgetController::loadSettings
void loadSettings(QSettings *settings) override
Definition: ViewSelectionWidgetController.cpp:60
armarx::ManagedIceObject::usingProxy
bool usingProxy(const std::string &name, const std::string &endpoints="")
Registers a proxy for retrieval after initialization and adds it to the dependency list.
Definition: ManagedIceObject.cpp:154
armarx::ViewSelectionWidgetController::clearSaliencyMapVisualization
void clearSaliencyMapVisualization()
Definition: ViewSelectionWidgetController.cpp:155
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
armarx::ViewSelectionWidgetController::ViewSelectionWidgetController
ViewSelectionWidgetController()
Controller Constructor.
Definition: ViewSelectionWidgetController.cpp:31
ViewSelectionWidgetController.h