ObserverWidgetController.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 ArmarX::Gui::ObserverWidgetController
17* @author ( at kit dot edu)
18* @date
19* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20* GNU General Public License
21*/
22
24
25#include <QToolBar>
26
28#include <ArmarXCore/interface/observers/ObserverInterface.h>
32
34
35namespace armarx
36{
40
41 void
43 {
44 getWidget()->show();
45 ArmarXMainWindow* guiMainWindow = qobject_cast<ArmarXMainWindow*>(getMainWindow());
46 variantInfo =
47 VariantInfo::ReadInfoFiles(guiMainWindow->getDefaultPackageNames(), true, false);
48 }
49
50 void
52 {
53
54
55 connect(this, SIGNAL(connected()), __widget.data(), SLOT(createNewModel()));
56 connect(__widget.data(),
57 SIGNAL(createFilterClicked(std::string, DatafieldFilterBasePtr)),
58 this,
59 SLOT(installFilter(std::string, DatafieldFilterBasePtr)));
60 // init widget
61 emit connected();
62
63 ARMARX_INFO << "Starting ObserverGuiPlugin";
64 }
65
66 void
68 {
69 if (__widget)
70 {
71 __widget->clearDetailedView();
72 }
73 }
74
75 QPointer<QWidget>
77 {
78 if (!__widget)
79 {
80 __widget = new ObserverWidget(this);
81 }
82
83 return qobject_cast<QWidget*>(__widget);
84 }
85
86 void
87 ObserverWidgetController::installFilter(const std::string& datafieldStr,
88 DatafieldFilterBasePtr filter)
89 {
90 DataFieldIdentifierPtr id = new DataFieldIdentifier(datafieldStr);
91 ObserverInterfacePrx observer;
92 observer = getProxy<ObserverInterfacePrx>(id->observerName);
94 DatafieldRefPtr ref =
95 new DatafieldRef(observer, id->getChannelName(), id->getDataFieldName());
97 observer->createFilteredDatafield(filter, ref);
98 __widget->updateObservers();
99 }
100
101 QPointer<QWidget>
103 {
104 if (customToolbar)
105 {
106 if (parent != customToolbar->parent())
107 {
108 customToolbar->setParent(parent);
109 }
110
111 return qobject_cast<QToolBar*>(customToolbar);
112 }
113
114 customToolbar = new QToolBar(parent);
115 customToolbar->setIconSize(QSize(16, 16));
116 QAction* refreshAction =
117 customToolbar->addAction(QIcon(":/icons/view-refresh-7.png"), "Refresh observer data");
118 connect(refreshAction, SIGNAL(triggered()), __widget.data(), SLOT(updateObservers()));
119
120 return qobject_cast<QToolBar*>(customToolbar);
121 }
122
125 {
126 return variantInfo;
127 }
128
129} // namespace armarx
The ArmarXMainWindow class.
std::vector< std::string > getDefaultPackageNames()
getDefaultPackageNames returns the names of all packages which are searched for plugins when the Arma...
virtual QMainWindow * getMainWindow()
Returns the ArmarX MainWindow.
DataFieldIdentifier provide the basis to identify data field within a distributed ArmarX scenario.
The DatafieldRef class is similar to the ChannelRef, but points to a specific Datafield instead of to...
Ice::ObjectPrx getProxy(long timeoutMs=0, bool waitForScheduler=true) const
Returns the proxy of this object (optionally it waits for the proxy)
void installFilter(const std::string &datafieldStr, DatafieldFilterBasePtr filter)
void onInitComponent() override
Pure virtual hook for the subclass.
QPointer< QWidget > getCustomTitlebarWidget(QWidget *parent) override
getTitleToolbar returns a pointer to the a toolbar widget of this controller.
QPointer< QWidget > getWidget() override
getWidget returns a pointer to the a widget of this controller.
void onConnectComponent() override
Pure virtual hook for the subclass.
void onExitComponent() override
Hook for subclass.
static VariantInfoPtr ReadInfoFiles(const std::vector< std::string > &packages, bool showErrors=true, bool throwOnError=true)
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
#define ARMARX_INFO
The normal logging level.
Definition Logging.h:181
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceInternal::Handle< DatafieldRef > DatafieldRefPtr
Definition Observer.h:43
std::shared_ptr< VariantInfo > VariantInfoPtr
Definition VariantInfo.h:39
IceInternal::Handle< DataFieldIdentifier > DataFieldIdentifierPtr
Typedef of DataFieldIdentifierPtr as IceInternal::Handle<DataFieldIdentifier> for convenience.