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 <QTimer>
25 
26 #include <ArmarXCore/interface/statechart/RemoteStateOffererIce.h> //RemoteStateOffererInterfacePrx
27 
29 
30 #include "IceStateConverter.h"
31 #include "StateWatcher.h"
32 #include "view/StatechartView.h"
33 #include "layout/LayoutThread.h"
34 
36 
37 #include <QToolBar>
38 
39 #include <mutex>
40 
41 namespace Ui
42 {
43  class StatechartViewer;
44 }
45 
46 namespace armarx
47 {
48 
49 
50  template <typename ProxyType>
52 
53  class StatechartView;
54  /*!
55  \class StatechartViewerController
56  \ingroup ArmarXGui-ArmarXGuiPlugins ArmarXGuiPlugins
57  \see StatechartViewerGuiPlugin
58  */
60  public ArmarXComponentWidgetControllerTemplate<StatechartViewerController>
61  {
62  Q_OBJECT
63 
64  public:
66  ~StatechartViewerController() override;
67  // inherited from Component
68  void onInitComponent() override;
69  void onConnectComponent() override;
70  void onDisconnectComponent() override;
71  void onExitComponent() override;
72 
73  // inherited of ArmarXWidget
74  static QString GetWidgetName()
75  {
76  return "Statecharts.StatechartViewer";
77  }
78  static QIcon GetWidgetIcon()
79  {
80  return QIcon("://icons/statechartviewer.svg");
81  }
82  void loadSettings(QSettings* settings) override;
83  void saveSettings(QSettings* settings) override;
84 
85  // ArmarXWidgetController interface
86  // QPointer<QWidget> getWidget();
87  void updateStatechart();
88  public slots:
89 
90  void connectToStateTab(int index);
91  void showTransitionContextMenu(statechartmodel::TransitionCPtr transition, statechartmodel::StatePtr state, QPoint mouseScreenPos, QPointF mouseItemPos);
92  signals:
93  void componentConnected();
94 
95  private slots:
96  void connectToIce();
97  void updateStatechartView(StateIceBasePtr stateptr, IceStateConverterPtr converter);
98  void displayParameters(statechartmodel::StateInstancePtr selectedStateInstance);
99  void addNewStateView(QString proxyName, QString stateName);
100  void addNewStateView();
101  void followActiveState();
102  void updateStateComboBox();
103  void updateStateFollower();
104  void removeTab(int index);
105  private:
106  Ui::StatechartViewer* ui;
108  RemoteStateOffererInterfacePrx m_statechartHandler;
109  StateWatcherPtr watcher;
111  struct RemoteStateData
112  {
113  IceStateConverterPtr converter;
114  QString proxyName;
115  QString globalStateName;
116  };
117 
118  QMap<QPointer<StatechartView>, RemoteStateData> converters;
119  QVector<QPair<QString, QString>> delayedConverterAdding;
120  ActiveStateFollower* follower;
121  QPointer<QToolBar> customToolbar;
122  QAction* autoFollowAction;
123  QAction* centerActiveStateAction;
124  std::recursive_mutex mutex;
125  bool shutdown = false;
126  // ArmarXWidgetController interface
127  public:
128  QPointer<QWidget> getCustomTitlebarWidget(QWidget* parent) override;
129  };
130 
131 }
armarx::StatechartViewerController::GetWidgetIcon
static QIcon GetWidgetIcon()
Definition: StatechartViewerController.h:78
armarx::StatechartViewerController::showTransitionContextMenu
void showTransitionContextMenu(statechartmodel::TransitionCPtr transition, statechartmodel::StatePtr state, QPoint mouseScreenPos, QPointF mouseItemPos)
Definition: StatechartViewerController.cpp:422
armarx::StatechartViewerController::loadSettings
void loadSettings(QSettings *settings) override
Implement to load the settings that are part of the GUI configuration.
Definition: StatechartViewerController.cpp:116
StatechartView.h
armarx::StatechartViewerController::updateStatechart
void updateStatechart()
Definition: StatechartViewerController.cpp:165
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:129
armarx::StatechartViewerController::connectToStateTab
void connectToStateTab(int index)
Definition: StatechartViewerController.cpp:412
ActiveStateFollower.h
armarx::StatechartViewerController::componentConnected
void componentConnected()
armarx::StatechartViewerController::~StatechartViewerController
~StatechartViewerController() override
Definition: StatechartViewerController.cpp:81
armarx::StatechartViewerController::onInitComponent
void onInitComponent() override
Pure virtual hook for the subclass.
Definition: StatechartViewerController.cpp:88
armarx::ArmarXComponentWidgetControllerTemplate
Definition: ArmarXComponentWidgetController.h:69
armarx::statechartmodel::StateInstancePtr
std::shared_ptr< StateInstance > StateInstancePtr
Definition: StateInstance.h:138
IceInternal::Handle< StateWatcher >
armarx::StatechartViewerController::onConnectComponent
void onConnectComponent() override
Pure virtual hook for the subclass.
Definition: StatechartViewerController.cpp:94
armarx::StatechartView
Definition: StatechartView.h:44
ArmarXComponentWidgetController.h
Ui
ArmarX Headers.
Definition: ArmarXMainWindow.h:54
armarx::StatechartViewerController::onDisconnectComponent
void onDisconnectComponent() override
Hook for subclass.
Definition: StatechartViewerController.cpp:105
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:112
IceUtil::Handle
Definition: forward_declarations.h:29
StateWatcher.h
armarx::IceProxyFinder
Definition: StatechartViewerController.h:51
armarx::statechartmodel::TransitionCPtr
std::shared_ptr< const Transition > TransitionCPtr
Definition: Transition.h:94
armarx::statechartmodel::StatePtr
std::shared_ptr< State > StatePtr
Definition: State.h:46
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:387
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::StatechartViewerController
Definition: StatechartViewerController.h:59
armarx::IceStateConverterPtr
std::shared_ptr< IceStateConverter > IceStateConverterPtr
Definition: IceStateConverter.h:206