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 <QListWidgetItem>
26 #include <string>
27 
28 using namespace armarx;
29 
31 {
32  widget.setupUi(getWidget());
33 
34  connect(widget.pushButton, SIGNAL(clicked()), this, SLOT(triggerSaliencyMapVisualization()));
35 
36  connect(widget.pushButton_2, SIGNAL(clicked()), this, SLOT(clearSaliencyMapVisualization()));
37 
38  connect(widget.pushButton_3, SIGNAL(clicked()), this, SLOT(updateSaliencyMapNames()));
39 
40  connect(widget.checkBox, SIGNAL(toggled(bool)), this, SLOT(toggleViewSelection(bool)));
41 
42 }
43 
44 
46 {
47 
48 }
49 
50 
51 
52 QPointer<QDialog> ViewSelectionWidgetController::getConfigDialog(QWidget* parent)
53 {
54  if (!configDialog)
55  {
56  configDialog = new ViewSelectionConfigDialog(parent);
57  }
58 
59  return qobject_cast<ViewSelectionConfigDialog*>(configDialog);
60 }
61 
62 
64 {
65  viewSelectionName = settings->value("viewSelectionName", "").toString().toStdString();
66 }
67 
69 {
70  viewSelectionName = settings->value("viewSelectionName", QString::fromStdString(viewSelectionName)).toString().toStdString();
71 }
72 
73 
75 {
76  usingProxy(viewSelectionName);
77  usingTopic(viewSelectionName + "Observer");
78 
79 }
80 
81 
83 {
84  viewSelection = getProxy<ViewSelectionInterfacePrx>(viewSelectionName);
85 
86  widget.checkBox->setChecked(viewSelection->isEnabledAutomaticViewSelection());
87 }
88 
89 
91 {
92  widget.checkBox->setChecked(true);
93 }
94 
96 {
97  widget.checkBox->setChecked(false);
98 }
99 
101 {
102 }
103 
105 {
106  ARMARX_LOG << "toggling view selection " << isEnabled;
107 
108  if (isEnabled)
109  {
110  viewSelection->activateAutomaticViewSelection();
111  }
112  else
113  {
114  viewSelection->deactivateAutomaticViewSelection();
115  }
116 }
117 
119 {
120  std::vector<std::string> names;
121 
122  for (int r = 0; r < widget.listWidget->count(); r++)
123  {
124  QListWidgetItem* item = widget.listWidget->item(r);
125 
126  if (item->checkState() == Qt::Checked)
127  {
128  names.push_back(item->text().toStdString());
129  }
130 
131  }
132  viewSelection->drawSaliencySphere(names);
133 
134 }
135 
137 {
138  std::vector<std::string> names = viewSelection->getSaliencyMapNames();
139 
140  widget.listWidget->clear();
141 
142  for (std::string name : names)
143  {
144  QListWidgetItem* item = new QListWidgetItem(QString::fromStdString(name), widget.listWidget);
145  item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
146  item->setCheckState(Qt::Unchecked);
147  }
148 }
149 
150 
152 {
153  viewSelection->clearSaliencySphere();
154 }
155 
157 {
158  viewSelectionName = configDialog->getViewSelectionName();
159 }
armarx::ViewSelectionWidgetController::onConnectComponent
void onConnectComponent() override
Definition: ViewSelectionWidgetController.cpp:82
armarx::ViewSelectionWidgetController::saveSettings
void saveSettings(QSettings *settings) override
Definition: ViewSelectionWidgetController.cpp:68
armarx::ViewSelectionWidgetController::configured
void configured() override
This function must be implemented by the user, if he supplies a config dialog.
Definition: ViewSelectionWidgetController.cpp:156
armarx::ViewSelectionWidgetController::onInitComponent
void onInitComponent() override
Definition: ViewSelectionWidgetController.cpp:74
armarx::ViewSelectionWidgetController::nextViewTarget
void nextViewTarget(Ice::Long, const Ice::Current &c=Ice::emptyCurrent) override
Definition: ViewSelectionWidgetController.cpp:100
armarx::ViewSelectionWidgetController::triggerSaliencyMapVisualization
void triggerSaliencyMapVisualization()
Definition: ViewSelectionWidgetController.cpp:118
armarx::ViewSelectionWidgetController::getConfigDialog
QPointer< QDialog > getConfigDialog(QWidget *parent) override
getConfigDialog returns a pointer to the a configuration widget of this controller.
Definition: ViewSelectionWidgetController.cpp:52
armarx::VariantType::Long
const VariantTypeId Long
Definition: Variant.h:917
armarx::ViewSelectionWidgetController::onActivateAutomaticViewSelection
void onActivateAutomaticViewSelection(const Ice::Current &c=Ice::emptyCurrent) override
Definition: ViewSelectionWidgetController.cpp:90
ARMARX_LOG
#define ARMARX_LOG
Definition: Logging.h:163
armarx::ViewSelectionWidgetController::updateSaliencyMapNames
void updateSaliencyMapNames()
Definition: ViewSelectionWidgetController.cpp:136
ViewSelectionConfigDialog
Definition: ViewSelectionConfigDialog.h:16
armarx::ManagedIceObject::usingTopic
void usingTopic(const std::string &name, bool orderedPublishing=false)
Registers a proxy for subscription after initialization.
Definition: ManagedIceObject.cpp:248
armarx::ViewSelectionWidgetController::toggleViewSelection
void toggleViewSelection(bool enabled)
Definition: ViewSelectionWidgetController.cpp:104
armarx::viz::data::ElementFlags::names
const simox::meta::IntEnumNames names
Definition: json_elements.cpp:14
armarx::ViewSelectionWidgetController::onDeactivateAutomaticViewSelection
void onDeactivateAutomaticViewSelection(const Ice::Current &c=Ice::emptyCurrent) override
Definition: ViewSelectionWidgetController.cpp:95
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:45
armarx::ViewSelectionWidgetController::loadSettings
void loadSettings(QSettings *settings) override
Definition: ViewSelectionWidgetController.cpp:63
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:151
armarx::ViewSelectionWidgetController::clearSaliencyMapVisualization
void clearSaliencyMapVisualization()
Definition: ViewSelectionWidgetController.cpp:151
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::ViewSelectionWidgetController::ViewSelectionWidgetController
ViewSelectionWidgetController()
Controller Constructor.
Definition: ViewSelectionWidgetController.cpp:30
ViewSelectionWidgetController.h