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 
27 #include <ArmarXCore/interface/observers/ObserverInterface.h>
29 #include <QToolBar>
31 
32 namespace armarx
33 {
35  {
36 
37  }
38 
40  {
41  getWidget()->show();
42  ArmarXMainWindow* guiMainWindow = qobject_cast<ArmarXMainWindow*>(getMainWindow());
43  variantInfo = VariantInfo::ReadInfoFiles(guiMainWindow->getDefaultPackageNames(), true, false);
44  }
45 
47  {
48 
49 
50 
51  connect(this, SIGNAL(connected()), __widget.data(), SLOT(createNewModel()));
52  connect(__widget.data(), SIGNAL(createFilterClicked(std::string, DatafieldFilterBasePtr)), this, SLOT(installFilter(std::string, DatafieldFilterBasePtr)));
53  // init widget
54  emit connected();
55 
56  ARMARX_INFO << "Starting ObserverGuiPlugin";
57  }
58 
60  {
61  if (__widget)
62  {
63  __widget->clearDetailedView();
64  }
65  }
66 
68  {
69  if (!__widget)
70  {
71  __widget = new ObserverWidget(this);
72  }
73 
74  return qobject_cast<QWidget*>(__widget);
75  }
76 
77  void ObserverWidgetController::installFilter(const std::string& datafieldStr, DatafieldFilterBasePtr filter)
78  {
79  DataFieldIdentifierPtr id = new DataFieldIdentifier(datafieldStr);
80  ObserverInterfacePrx observer;
81  observer = getProxy<ObserverInterfacePrx>(id->observerName);
83  DatafieldRefPtr ref = new DatafieldRef(observer, id->getChannelName(), id->getDataFieldName());
85  observer->createFilteredDatafield(filter, ref);
86  __widget->updateObservers();
87  }
88  QPointer<QWidget> ObserverWidgetController::getCustomTitlebarWidget(QWidget* parent)
89  {
90  if (customToolbar)
91  {
92  if (parent != customToolbar->parent())
93  {
94  customToolbar->setParent(parent);
95  }
96 
97  return qobject_cast<QToolBar*>(customToolbar);
98  }
99 
100  customToolbar = new QToolBar(parent);
101  customToolbar->setIconSize(QSize(16, 16));
102  QAction* refreshAction = customToolbar->addAction(QIcon(":/icons/view-refresh-7.png"), "Refresh observer data");
103  connect(refreshAction, SIGNAL(triggered()), __widget.data(), SLOT(updateObservers()));
104 
105  return qobject_cast<QToolBar*>(customToolbar);
106  }
107 
109  {
110  return variantInfo;
111  }
112 
113 }
armarx::ObserverWidgetController::ObserverWidgetController
ObserverWidgetController()
Definition: ObserverWidgetController.cpp:34
armarx::ObserverWidgetController::getWidget
QPointer< QWidget > getWidget() override
getWidget returns a pointer to the a widget of this controller.
Definition: ObserverWidgetController.cpp:67
armarx::ObserverWidgetController::observer
ObserverInterfacePrx observer
Definition: ObserverWidgetController.h:96
armarx::ObserverWidget
Definition: ObserverWidget.h:52
armarx::ArmarXMainWindow
The ArmarXMainWindow class.
Definition: ArmarXMainWindow.h:80
DataFieldIdentifier.h
armarx::ObserverWidgetController::getCustomTitlebarWidget
QPointer< QWidget > getCustomTitlebarWidget(QWidget *parent) override
getTitleToolbar returns a pointer to the a toolbar widget of this controller.
Definition: ObserverWidgetController.cpp:88
armarx::ObserverWidgetController::connected
void connected()
armarx::ArmarXWidgetController::getMainWindow
virtual QMainWindow * getMainWindow()
Returns the ArmarX MainWindow.
Definition: ArmarXWidgetController.cpp:125
IceInternal::Handle< DataFieldIdentifier >
DatafieldRef.h
armarx::ObserverWidgetController::getVariantInfo
VariantInfoPtr getVariantInfo() const
Definition: ObserverWidgetController.cpp:108
ArmarXMainWindow.h
armarx::ObserverWidgetController::onConnectComponent
void onConnectComponent() override
Pure virtual hook for the subclass.
Definition: ObserverWidgetController.cpp:46
armarx::ObserverWidgetController::onInitComponent
void onInitComponent() override
Pure virtual hook for the subclass.
Definition: ObserverWidgetController.cpp:39
armarx::ArmarXMainWindow::getDefaultPackageNames
std::vector< std::string > getDefaultPackageNames()
getDefaultPackageNames returns the names of all packages which are searched for plugins when the Arma...
Definition: ArmarXMainWindow.cpp:622
armarx::VariantInfo::ReadInfoFiles
static VariantInfoPtr ReadInfoFiles(const std::vector< std::string > &packages, bool showErrors=true, bool throwOnError=true)
Definition: VariantInfo.cpp:414
armarx::VariantType::DatafieldRef
const VariantTypeId DatafieldRef
Definition: DatafieldRef.h:169
ExpressionException.h
ObserverWidgetController.h
ARMARX_CHECK_EXPRESSION
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
Definition: ExpressionException.h:73
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:174
armarx::VariantInfoPtr
std::shared_ptr< VariantInfo > VariantInfoPtr
Definition: VariantInfo.h:39
armarx::ObserverWidgetController::onExitComponent
void onExitComponent() override
Hook for subclass.
Definition: ObserverWidgetController.cpp:59
Variant.h
armarx::ObserverWidgetController::installFilter
void installFilter(const std::string &datafieldStr, DatafieldFilterBasePtr filter)
Definition: ObserverWidgetController.cpp:77
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::DataFieldIdentifier
DataFieldIdentifier provide the basis to identify data field within a distributed ArmarX scenario.
Definition: DataFieldIdentifier.h:48