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 
34 #include <RobotAPI/gui-plugins/GraspCandidateViewer/ui_GraspCandidateViewerWidget.h>
38 
39 namespace armarx
40 {
41  /**
42  \page RobotAPI-GuiPlugins-GraspCandidateViewer GraspCandidateViewer
43  \brief The GraspCandidateViewer allows visualizing ...
44 
45  \image html GraspCandidateViewer.png
46  The user can
47 
48  API Documentation \ref GraspCandidateViewerWidgetController
49 
50  \see GraspCandidateViewerGuiPlugin
51  */
52 
53 
54  /**
55  * \class GraspCandidateViewerGuiPlugin
56  * \ingroup ArmarXGuiPlugins
57  * \brief GraspCandidateViewerGuiPlugin brief description
58  *
59  * Detailed description
60  */
61 
62  /**
63  * \class GraspCandidateViewerWidgetController
64  * \brief GraspCandidateViewerWidgetController brief one line description
65  *
66  * Detailed description
67  */
70  GraspCandidateViewerWidgetController>,
71  virtual public RobotStateComponentPluginUser,
72  virtual public ArVizComponentPluginUser,
74  {
75  Q_OBJECT
76 
77  struct entry_gc;
78  struct entry_prov;
79 
80  public:
83 
84  static QString
86  {
87  return "Grasping.GraspCandidateViewer";
88  }
89 
90  void
91  onInitComponent() override
92  {
93  }
94 
95  void
96  onConnectComponent() override
97  {
98  _robot = addRobot("state robot", VirtualRobot::RobotIO::eStructure);
99  }
100 
101  void
103  {
104  }
105 
106  void
107  onExitComponent() override
108  {
109  }
110 
111  public:
112  void loadSettings(QSettings* settings) override;
113  void saveSettings(QSettings* settings) override;
114  QPointer<QDialog> getConfigDialog(QWidget* parent) override;
115  void configured() override;
116  public slots:
117  void update_gc();
118  void selected_item_changed();
119  void check_state_changed();
120 
121  private:
122  void show_entry(entry_gc* e);
123 
124  private:
125  struct entry_prov
126  {
127  QTreeWidgetItem* item = nullptr;
128  std::string provider_name;
129  std::deque<entry_gc> candidates;
130  };
131 
132  struct entry_gc
133  {
134  QTreeWidgetItem* item = nullptr;
135  grasping::GraspCandidatePtr gc = nullptr;
136  entry_prov* provider = nullptr;
137  int idx = -1;
138  bool show = false;
139 
140  std::string
141  name() const
142  {
143  return provider->provider_name + "_" + std::to_string(idx + 1);
144  }
145  };
146 
147  mutable std::recursive_mutex _mutex;
148  QPointer<SimpleConfigDialog> _dialog;
149  Ui::GraspCandidateViewerWidget _ui;
150  VirtualRobot::RobotPtr _robot;
151  std::map<std::string, entry_prov> _providers;
152  std::map<QTreeWidgetItem*, entry_gc*> _tree_item_to_gc;
153  };
154 } // namespace armarx
ArVizComponentPlugin.h
armarx::GraspCandidateViewerWidgetController::onDisconnectComponent
void onDisconnectComponent() override
Hook for subclass.
Definition: GraspCandidateViewerWidgetController.h:102
armarx::GraspCandidateViewerWidgetController
GraspCandidateViewerWidgetController brief one line description.
Definition: GraspCandidateViewerWidgetController.h:68
Robot.h
RobotStateComponentPlugin.h
armarx::GraspCandidateViewerWidgetController::GetWidgetName
static QString GetWidgetName()
Definition: GraspCandidateViewerWidgetController.h:85
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:35
ArmarXComponentWidgetController.h
ARMARXCOMPONENT_IMPORT_EXPORT
#define ARMARXCOMPONENT_IMPORT_EXPORT
Definition: ImportExportComponent.h:38
armarx::GraspCandidateObserverComponentPluginUser
Provides a ready-to-use GraspCandidateObserver.
Definition: GraspCandidateObserverComponentPlugin.h:49
armarx::to_string
const std::string & to_string(const std::string &s)
Definition: StringHelpers.h:41
armarx::GraspCandidateViewerWidgetController::onInitComponent
void onInitComponent() override
Pure virtual hook for the subclass.
Definition: GraspCandidateViewerWidgetController.h:91
armarx::GraspCandidateViewerWidgetController::onConnectComponent
void onConnectComponent() override
Pure virtual hook for the subclass.
Definition: GraspCandidateViewerWidgetController.h:96
armarx::GraspCandidateViewerWidgetController::onExitComponent
void onExitComponent() override
Hook for subclass.
Definition: GraspCandidateViewerWidgetController.h:107
armarx::RobotStateComponentPluginUser
Definition: RobotStateComponentPlugin.h:165
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:19
ImportExportComponent.h