moveit2
The MoveIt Motion Planning Framework for ROS 2.
planning_groups_widget.hpp
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2012, Willow Garage, Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of Willow Garage nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *********************************************************************/
34 
35 /* Author: Dave Coleman */
36 
37 #pragma once
38 
39 // Qt
40 #include <QPushButton>
41 #include <QStackedWidget>
42 #include <QTreeWidget>
43 #include <QTreeWidgetItem>
44 
45 // SA
49 #include <moveit_setup_srdf_plugins/kinematic_chain_widget.hpp> // for kinematic chain page
50 #include <moveit_setup_srdf_plugins/group_edit_widget.hpp> // for group rename page
51 
52 // Forward Declaration (outside of namespace for Qt)
53 class PlanGroupType;
54 
55 namespace moveit_setup
56 {
57 namespace srdf_setup
58 {
59 // Custom Type
61 {
62  JOINT = 1,
63  LINK = 2,
64  CHAIN = 3,
65  SUBGROUP = 4,
66  GROUP = 5
67 };
68 
69 // ******************************************************************************************
70 // ******************************************************************************************
71 // CLASS
72 // ******************************************************************************************
73 // ******************************************************************************************
75 {
76  Q_OBJECT
77 
78 public:
79  // ******************************************************************************************
80  // Public Functions
81  // ******************************************************************************************
82 
83  void onInit() override;
84 
85  void changeScreen(int index);
86 
88  void focusGiven() override;
89 
90  SetupStep& getSetupStep() override
91  {
92  return setup_step_;
93  }
94 
95 private Q_SLOTS:
96 
97  // ******************************************************************************************
98  // Slot Event Functions
99  // ******************************************************************************************
100 
102  void loadGroupsTree();
103 
105  void previewSelected();
106 
108  void editSelected();
109 
111  void addGroup();
112 
114  void saveJointsScreen();
115  void saveLinksScreen();
116  void saveChainScreen();
117  void saveSubgroupsScreen();
118  void saveGroupScreenEdit();
119  void saveGroupScreenJoints();
120  void saveGroupScreenLinks();
121  void saveGroupScreenChain();
122  void saveGroupScreenSubgroups();
123 
124  // Delete a group
125  void deleteGroup();
126 
128  void cancelEditing();
129 
131  void alterTree(const QString& link);
132 
134  void previewSelectedLink(const std::vector<std::string>& links);
135 
137  // void previewClickedJoint( std::string name );
138  void previewSelectedJoints(const std::vector<std::string>& joints);
139 
141  void previewSelectedSubgroup(const std::vector<std::string>& groups);
142 
143 private:
144  // ******************************************************************************************
145  // Qt Components
146  // ******************************************************************************************
147 
149  QTreeWidget* groups_tree_;
150 
152  QStackedWidget* stacked_widget_;
153 
155  QPushButton* btn_edit_;
156 
157  QPushButton* btn_delete_;
158 
159  // Stacked Layout SUBPAGES -------------------------------------------
160 
161  QWidget* groups_tree_widget_;
162  DoubleListWidget* joints_widget_;
163  DoubleListWidget* links_widget_;
164  DoubleListWidget* subgroups_widget_;
165  KinematicChainWidget* chain_widget_;
166  GroupEditWidget* group_edit_widget_;
167 
168  // ******************************************************************************************
169  // Variables
170  // ******************************************************************************************
171 
172  PlanningGroups setup_step_;
173 
175  std::string current_edit_group_;
176 
178  int return_screen_;
179 
181  bool adding_new_group_;
182 
183  // ******************************************************************************************
184  // Private Functions
185  // ******************************************************************************************
186 
188  QWidget* createContentsWidget();
189 
191  void loadGroupsTreeRecursive(srdf::Model::Group& group_it, QTreeWidgetItem* parent);
192 
193  // Load edit screen
194  void loadJointsScreen(srdf::Model::Group* this_group);
195  void loadLinksScreen(srdf::Model::Group* this_group);
196  void loadChainScreen(srdf::Model::Group* this_group);
197  void loadSubgroupsScreen(srdf::Model::Group* this_group);
198  void loadGroupScreen(srdf::Model::Group* this_group);
199 
200  // Save group screen
201  bool saveGroupScreen();
202 
204  void showMainScreen();
205 };
206 
207 // ******************************************************************************************
208 // ******************************************************************************************
209 // Metatype Class For Holding Points to Group Parts
210 // ******************************************************************************************
211 // ******************************************************************************************
212 
214 {
215 public:
216  // explicit PlanGroupType();
218  {
219  }
220  PlanGroupType(srdf::Model::Group* group, const GroupType type);
221  virtual ~PlanGroupType()
222  {
223  ;
224  }
225 
226  srdf::Model::Group* group_;
227 
229 };
230 
231 } // namespace srdf_setup
232 } // namespace moveit_setup
233 
The GUI code for one SetupStep.
Contains all of the non-GUI code necessary for doing one "screen" worth of setup.
Definition: setup_step.hpp:47
SetupStep & getSetupStep() override
Return a reference to the SetupStep object.
void focusGiven() override
Received when this widget is chosen from the navigation menu.
Q_DECLARE_METATYPE(moveit_setup::srdf_setup::PlanGroupType)