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 
35 namespace armarx
36 {
38  {
39  }
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
armarx::ObserverWidgetController::ObserverWidgetController
ObserverWidgetController()
Definition: ObserverWidgetController.cpp:37
armarx::ObserverWidgetController::getWidget
QPointer< QWidget > getWidget() override
getWidget returns a pointer to the a widget of this controller.
Definition: ObserverWidgetController.cpp:76
armarx::ObserverWidgetController::observer
ObserverInterfacePrx observer
Definition: ObserverWidgetController.h:108
armarx::ObserverWidget
Definition: ObserverWidget.h:52
armarx::ArmarXMainWindow
The ArmarXMainWindow class.
Definition: ArmarXMainWindow.h:76
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:102
armarx::ObserverWidgetController::connected
void connected()
armarx::ArmarXWidgetController::getMainWindow
virtual QMainWindow * getMainWindow()
Returns the ArmarX MainWindow.
Definition: ArmarXWidgetController.cpp:136
IceInternal::Handle< DataFieldIdentifier >
DatafieldRef.h
armarx::ObserverWidgetController::getVariantInfo
VariantInfoPtr getVariantInfo() const
Definition: ObserverWidgetController.cpp:124
ArmarXMainWindow.h
armarx::ObserverWidgetController::onConnectComponent
void onConnectComponent() override
Pure virtual hook for the subclass.
Definition: ObserverWidgetController.cpp:51
armarx::ObserverWidgetController::onInitComponent
void onInitComponent() override
Pure virtual hook for the subclass.
Definition: ObserverWidgetController.cpp:42
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:623
armarx::VariantInfo::ReadInfoFiles
static VariantInfoPtr ReadInfoFiles(const std::vector< std::string > &packages, bool showErrors=true, bool throwOnError=true)
Definition: VariantInfo.cpp:453
armarx::VariantType::DatafieldRef
const VariantTypeId DatafieldRef
Definition: DatafieldRef.h:197
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:181
armarx::VariantInfoPtr
std::shared_ptr< VariantInfo > VariantInfoPtr
Definition: VariantInfo.h:39
armarx::ObserverWidgetController::onExitComponent
void onExitComponent() override
Hook for subclass.
Definition: ObserverWidgetController.cpp:67
Variant.h
armarx::ObserverWidgetController::installFilter
void installFilter(const std::string &datafieldStr, DatafieldFilterBasePtr filter)
Definition: ObserverWidgetController.cpp:87
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
armarx::DataFieldIdentifier
DataFieldIdentifier provide the basis to identify data field within a distributed ArmarX scenario.
Definition: DataFieldIdentifier.h:48