moveit2
The MoveIt Motion Planning Framework for ROS 2.
controllers_widget.hpp
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2018, Mohamad Ayman.
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  * * The name of Mohamad Ayman may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  *********************************************************************/
33 
34 /* Author: Mohamad Ayman */
35 
36 #pragma once
37 
38 // Qt
39 #include <QHBoxLayout>
40 #include <QPushButton>
41 #include <QStackedWidget>
42 #include <QTreeWidget>
43 #include <QTreeWidgetItem>
44 
45 // SA
50 
51 namespace moveit_setup
52 {
53 namespace controllers
54 {
56 {
57  Q_OBJECT
58 
59 public:
60  // ******************************************************************************************
61  // Public Functions
62  // ******************************************************************************************
63 
64  void onInit() override;
65 
66  void changeScreen(int index);
67 
69  void focusGiven() override;
70 
71  SetupStep& getSetupStep() override
72  {
73  return *setup_step_;
74  }
75 
76 private Q_SLOTS:
77 
78  // ******************************************************************************************
79  // Slot Event Functions
80  // ******************************************************************************************
81 
82  // Expand/Collapse Tree
83  void alterTree(const QString& link);
84 
86  void addController();
87 
89  void editController();
90 
92  void deleteController();
93 
94  // Add a Follow Joint Trajectory action Controller for each Planning Group
95  void addDefaultControllers();
96 
98  void saveControllerScreenJoints();
99  void saveJointsScreen();
100  bool saveControllerScreen();
101  void saveControllerScreenEdit();
102  void saveControllerScreenGroups();
103  void saveJointsGroupsScreen();
104  void cancelEditing();
105 
107  void editSelected();
108 
110  void previewSelectedJoints(const std::vector<std::string>& joints);
111 
113  void previewSelectedGroup(const std::vector<std::string>& groups);
114 
116  void previewSelected(QTreeWidgetItem* selected_item, int column);
117 
119  void itemSelectionChanged();
120 
121 protected:
122  // ******************************************************************************************
123  // Qt Components
124  // ******************************************************************************************
125 
127  QTreeWidget* controllers_tree_;
129 
131  QStackedWidget* stacked_widget_;
133 
134  QPushButton* btn_delete_;
135  QPushButton* btn_add_;
136  QPushButton* btn_edit_;
137  QHBoxLayout* controls_layout_;
140 
143 
146 
147  std::shared_ptr<Controllers> setup_step_;
148 
150  QWidget* createContentsWidget();
151 
152  void loadControllersTree();
153  void loadToControllersTree(const ControllerInfo& controller_it);
154  void showMainScreen();
155  void loadJointsScreen(ControllerInfo* this_controller);
156  void loadGroupsScreen(ControllerInfo* this_controller);
157  void loadControllerScreen(ControllerInfo* this_controller);
158 };
159 
160 } // namespace controllers
161 } // namespace moveit_setup
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
QTreeWidget * controllers_tree_
Main table for holding controllers.
SetupStep & getSetupStep() override
Return a reference to the SetupStep object.
QStackedWidget * stacked_widget_
For changing between table and different add/edit views.
bool adding_new_controller_
Remember whethere we're editing a controller or adding a new one.
void loadJointsScreen(ControllerInfo *this_controller)
void focusGiven() override
Received when this widget is chosen from the navigation menu.
void loadControllerScreen(ControllerInfo *this_controller)
void loadToControllersTree(const ControllerInfo &controller_it)
std::string current_edit_controller_
Remember what controller we are editing when an edit screen is being shown.
void loadGroupsScreen(ControllerInfo *this_controller)
QWidget * createContentsWidget()
Builds the main screen list widget.