StatechartViewerController.h
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 Mirko Waechter
17 * @author (waechter at kit dot edu)
18 * @date 2014
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22 #pragma once
23 
24 #include <mutex>
25 
26 #include <QTimer>
27 #include <QToolBar>
28 
29 #include <ArmarXCore/interface/statechart/RemoteStateOffererIce.h> //RemoteStateOffererInterfacePrx
30 
33 
34 #include "IceStateConverter.h"
35 #include "StateWatcher.h"
36 #include "layout/LayoutThread.h"
37 #include "view/StatechartView.h"
38 
39 namespace Ui
40 {
41  class StatechartViewer;
42 }
43 
44 namespace armarx
45 {
46 
47 
48  template <typename ProxyType>
50 
51  class StatechartView;
52 
53  /*!
54  \class StatechartViewerController
55  \ingroup ArmarXGui-ArmarXGuiPlugins ArmarXGuiPlugins
56  \see StatechartViewerGuiPlugin
57  */
59  public ArmarXComponentWidgetControllerTemplate<StatechartViewerController>
60  {
61  Q_OBJECT
62 
63  public:
65  ~StatechartViewerController() override;
66  // inherited from Component
67  void onInitComponent() override;
68  void onConnectComponent() override;
69  void onDisconnectComponent() override;
70  void onExitComponent() override;
71 
72  // inherited of ArmarXWidget
73  static QString
75  {
76  return "Statecharts.StatechartViewer";
77  }
78 
79  static QIcon
81  {
82  return QIcon("://icons/statechartviewer.svg");
83  }
84 
85  void loadSettings(QSettings* settings) override;
86  void saveSettings(QSettings* settings) override;
87 
88  // ArmarXWidgetController interface
89  // QPointer<QWidget> getWidget();
90  void updateStatechart();
91  public slots:
92 
93  void connectToStateTab(int index);
96  QPoint mouseScreenPos,
97  QPointF mouseItemPos);
98  signals:
99  void componentConnected();
100 
101  private slots:
102  void connectToIce();
103  void updateStatechartView(StateIceBasePtr stateptr, IceStateConverterPtr converter);
104  void displayParameters(statechartmodel::StateInstancePtr selectedStateInstance);
105  void addNewStateView(QString proxyName, QString stateName);
106  void addNewStateView();
107  void followActiveState();
108  void updateStateComboBox();
109  void updateStateFollower();
110  void removeTab(int index);
111 
112  private:
113  Ui::StatechartViewer* ui;
115  RemoteStateOffererInterfacePrx m_statechartHandler;
116  StateWatcherPtr watcher;
118 
119  struct RemoteStateData
120  {
121  IceStateConverterPtr converter;
122  QString proxyName;
123  QString globalStateName;
124  };
125 
126  QMap<QPointer<StatechartView>, RemoteStateData> converters;
127  QVector<QPair<QString, QString>> delayedConverterAdding;
128  ActiveStateFollower* follower;
129  QPointer<QToolBar> customToolbar;
130  QAction* autoFollowAction;
131  QAction* centerActiveStateAction;
132  std::recursive_mutex mutex;
133  bool shutdown = false;
134  // ArmarXWidgetController interface
135  public:
136  QPointer<QWidget> getCustomTitlebarWidget(QWidget* parent) override;
137  };
138 
139 } // namespace armarx
armarx::StatechartViewerController::GetWidgetIcon
static QIcon GetWidgetIcon()
Definition: StatechartViewerController.h:80
armarx::StatechartViewerController::showTransitionContextMenu
void showTransitionContextMenu(statechartmodel::TransitionCPtr transition, statechartmodel::StatePtr state, QPoint mouseScreenPos, QPointF mouseItemPos)
Definition: StatechartViewerController.cpp:473
armarx::StatechartViewerController::loadSettings
void loadSettings(QSettings *settings) override
Implement to load the settings that are part of the GUI configuration.
Definition: StatechartViewerController.cpp:127
StatechartView.h
armarx::StatechartViewerController::updateStatechart
void updateStatechart()
Definition: StatechartViewerController.cpp:182
index
uint8_t index
Definition: EtherCATFrame.h:59
armarx::StatechartViewerController::saveSettings
void saveSettings(QSettings *settings) override
Implement to save the settings as part of the GUI configuration.
Definition: StatechartViewerController.cpp:141
armarx::StatechartViewerController::connectToStateTab
void connectToStateTab(int index)
Definition: StatechartViewerController.cpp:455
ActiveStateFollower.h
armarx::StatechartViewerController::componentConnected
void componentConnected()
armarx::StatechartViewerController::~StatechartViewerController
~StatechartViewerController() override
Definition: StatechartViewerController.cpp:84
armarx::StatechartViewerController::onInitComponent
void onInitComponent() override
Pure virtual hook for the subclass.
Definition: StatechartViewerController.cpp:91
armarx::ArmarXComponentWidgetControllerTemplate
Definition: ArmarXComponentWidgetController.h:69
armarx::statechartmodel::StateInstancePtr
std::shared_ptr< StateInstance > StateInstancePtr
Definition: StateInstance.h:146
IceInternal::Handle< StateWatcher >
armarx::StatechartViewerController::onConnectComponent
void onConnectComponent() override
Pure virtual hook for the subclass.
Definition: StatechartViewerController.cpp:102
armarx::StatechartView
Definition: StatechartView.h:45
ArmarXComponentWidgetController.h
Ui
ArmarX Headers.
Definition: ArmarXMainWindow.h:54
armarx::StatechartViewerController::onDisconnectComponent
void onDisconnectComponent() override
Hook for subclass.
Definition: StatechartViewerController.cpp:114
armarx::StatechartViewerController::GetWidgetName
static QString GetWidgetName()
Definition: StatechartViewerController.h:74
IceStateConverter.h
LayoutThread.h
armarx::StatechartViewerController::onExitComponent
void onExitComponent() override
Hook for subclass.
Definition: StatechartViewerController.cpp:122
IceUtil::Handle
Definition: forward_declarations.h:30
StateWatcher.h
armarx::IceProxyFinder
Definition: StatechartViewerController.h:49
armarx::statechartmodel::TransitionCPtr
std::shared_ptr< const Transition > TransitionCPtr
Definition: Transition.h:91
armarx::statechartmodel::StatePtr
std::shared_ptr< State > StatePtr
Definition: State.h:48
armarx::StatechartViewerController::StatechartViewerController
StatechartViewerController()
Definition: StatechartViewerController.cpp:55
armarx::StatechartViewerController::getCustomTitlebarWidget
QPointer< QWidget > getCustomTitlebarWidget(QWidget *parent) override
getTitleToolbar returns a pointer to the a toolbar widget of this controller.
Definition: StatechartViewerController.cpp:424
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
armarx::StatechartViewerController
Definition: StatechartViewerController.h:58
armarx::IceStateConverterPtr
std::shared_ptr< IceStateConverter > IceStateConverterPtr
Definition: IceStateConverter.h:220