GraspCandidateViewerWidgetController.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 RobotAPI::gui-plugins::GraspCandidateViewerWidgetController
17  * @author Raphael Grimm ( raphael dot grimm at kit dot edu )
18  * @date 2020
19  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
22 #pragma once
23 
24 #include <deque>
25 
27 
31 
37 
38 #include <RobotAPI/gui-plugins/GraspCandidateViewer/ui_GraspCandidateViewerWidget.h>
39 
40 namespace armarx
41 {
42  /**
43  \page RobotAPI-GuiPlugins-GraspCandidateViewer GraspCandidateViewer
44  \brief The GraspCandidateViewer allows visualizing ...
45 
46  \image html GraspCandidateViewer.png
47  The user can
48 
49  API Documentation \ref GraspCandidateViewerWidgetController
50 
51  \see GraspCandidateViewerGuiPlugin
52  */
53 
54 
55  /**
56  * \class GraspCandidateViewerGuiPlugin
57  * \ingroup ArmarXGuiPlugins
58  * \brief GraspCandidateViewerGuiPlugin brief description
59  *
60  * Detailed description
61  */
62 
63  /**
64  * \class GraspCandidateViewerWidgetController
65  * \brief GraspCandidateViewerWidgetController brief one line description
66  *
67  * Detailed description
68  */
71  public armarx::ArmarXComponentWidgetControllerTemplate < GraspCandidateViewerWidgetController >,
72  virtual public RobotStateComponentPluginUser,
73  virtual public ArVizComponentPluginUser,
75  {
76  Q_OBJECT
77 
78  struct entry_gc;
79  struct entry_prov;
80  public:
83 
84  static QString GetWidgetName()
85  {
86  return "Grasping.GraspCandidateViewer";
87  }
88 
89  void onInitComponent() override {}
90  void onConnectComponent() override
91  {
92  _robot = addRobot("state robot", VirtualRobot::RobotIO::eStructure);
93  }
94  void onDisconnectComponent() override {}
95  void onExitComponent() override {}
96  public:
97  void loadSettings(QSettings* settings) override;
98  void saveSettings(QSettings* settings) override;
99  QPointer<QDialog> getConfigDialog(QWidget* parent) override;
100  void configured() override;
101  public slots:
102  void update_gc();
103  void selected_item_changed();
104  void check_state_changed();
105 
106  private:
107  void show_entry(entry_gc* e);
108  private:
109 
110  struct entry_prov
111  {
112  QTreeWidgetItem* item = nullptr;
113  std::string provider_name;
114  std::deque<entry_gc> candidates;
115  };
116 
117  struct entry_gc
118  {
119  QTreeWidgetItem* item = nullptr;
120  grasping::GraspCandidatePtr gc = nullptr;
121  entry_prov* provider = nullptr;
122  int idx = -1;
123  bool show = false;
124 
125  std::string name() const
126  {
127  return provider->provider_name + "_" + std::to_string(idx + 1);
128  }
129  };
130 
131  mutable std::recursive_mutex _mutex;
132  QPointer<SimpleConfigDialog> _dialog;
133  Ui::GraspCandidateViewerWidget _ui;
134  VirtualRobot::RobotPtr _robot;
135  std::map<std::string, entry_prov> _providers;
136  std::map<QTreeWidgetItem*, entry_gc*> _tree_item_to_gc;
137  };
138 }
139 
140 
ArVizComponentPlugin.h
armarx::GraspCandidateViewerWidgetController::onDisconnectComponent
void onDisconnectComponent() override
Hook for subclass.
Definition: GraspCandidateViewerWidgetController.h:94
armarx::GraspCandidateViewerWidgetController
GraspCandidateViewerWidgetController brief one line description.
Definition: GraspCandidateViewerWidgetController.h:69
Robot.h
RobotStateComponentPlugin.h
armarx::GraspCandidateViewerWidgetController::GetWidgetName
static QString GetWidgetName()
Definition: GraspCandidateViewerWidgetController.h:84
Layer.h
armarx::ArmarXComponentWidgetControllerTemplate
Definition: ArmarXComponentWidgetController.h:69
SimpleConfigDialog.h
GraspCandidateObserverComponentPlugin.h
ArmarXGuiPlugin.h
armarx::ArVizComponentPluginUser
Provides a ready-to-use ArViz client arviz as member variable.
Definition: ArVizComponentPlugin.h:36
ArmarXComponentWidgetController.h
ARMARXCOMPONENT_IMPORT_EXPORT
#define ARMARXCOMPONENT_IMPORT_EXPORT
Definition: ImportExportComponent.h:38
armarx::GraspCandidateObserverComponentPluginUser
Provides a ready-to-use GraspCandidateObserver.
Definition: GraspCandidateObserverComponentPlugin.h:47
armarx::to_string
const std::string & to_string(const std::string &s)
Definition: StringHelpers.h:40
armarx::GraspCandidateViewerWidgetController::onInitComponent
void onInitComponent() override
Pure virtual hook for the subclass.
Definition: GraspCandidateViewerWidgetController.h:89
armarx::GraspCandidateViewerWidgetController::onConnectComponent
void onConnectComponent() override
Pure virtual hook for the subclass.
Definition: GraspCandidateViewerWidgetController.h:90
armarx::GraspCandidateViewerWidgetController::onExitComponent
void onExitComponent() override
Hook for subclass.
Definition: GraspCandidateViewerWidgetController.h:95
armarx::RobotStateComponentPluginUser
Definition: RobotStateComponentPlugin.h:167
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:18
ImportExportComponent.h