00001 /********************************************************************* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Copyright (c) 2012, Willow Garage, Inc. 00005 * All rights reserved. 00006 * 00007 * Redistribution and use in source and binary forms, with or without 00008 * modification, are permitted provided that the following conditions 00009 * are met: 00010 * 00011 * * Redistributions of source code must retain the above copyright 00012 * notice, this list of conditions and the following disclaimer. 00013 * * Redistributions in binary form must reproduce the above 00014 * copyright notice, this list of conditions and the following 00015 * disclaimer in the documentation and/or other materials provided 00016 * with the distribution. 00017 * * Neither the name of the Willow Garage nor the names of its 00018 * contributors may be used to endorse or promote products derived 00019 * from this software without specific prior written permission. 00020 * 00021 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00022 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00023 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00024 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00025 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00026 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00027 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00028 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00029 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00031 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00032 * POSSIBILITY OF SUCH DAMAGE. 00033 *********************************************************************/ 00034 00035 /* Author: Dave Coleman */ 00036 00037 #ifndef MOVEIT_MOVEIT_SETUP_ASSISTANT_WIDGETS_PLANNING_GROUPS_WIDGET_ 00038 #define MOVEIT_MOVEIT_SETUP_ASSISTANT_WIDGETS_PLANNING_GROUPS_WIDGET_ 00039 00040 // Qt 00041 #include <QWidget> 00042 #include <QTreeWidget> 00043 #include <QSplitter> 00044 #include <QStackedLayout> 00045 00046 // Setup Asst 00047 #ifndef Q_MOC_RUN 00048 #include <moveit/setup_assistant/tools/moveit_config_data.h> 00049 #endif 00050 00051 #include "double_list_widget.h" // for joints, links and subgroups pages 00052 #include "kinematic_chain_widget.h" // for kinematic chain page 00053 #include "group_edit_widget.h" // for group rename page 00054 #include "setup_screen_widget.h" // a base class for screens in the setup assistant 00055 00056 // Forward Declaration (outside of namespace for Qt) 00057 class PlanGroupType; 00058 00059 namespace moveit_setup_assistant 00060 { 00061 00062 // Custom Type 00063 enum GroupType { 00064 JOINT, 00065 LINK, 00066 CHAIN, 00067 SUBGROUP, 00068 GROUP 00069 }; 00070 00071 // ****************************************************************************************** 00072 // ****************************************************************************************** 00073 // CLASS 00074 // ****************************************************************************************** 00075 // ****************************************************************************************** 00076 class PlanningGroupsWidget : public SetupScreenWidget 00077 { 00078 Q_OBJECT 00079 00080 public: 00081 // ****************************************************************************************** 00082 // Public Functions 00083 // ****************************************************************************************** 00084 00085 PlanningGroupsWidget( QWidget *parent, moveit_setup_assistant::MoveItConfigDataPtr config_data ); 00086 00087 void changeScreen( int index ); 00088 00090 virtual void focusGiven(); 00091 00092 private Q_SLOTS: 00093 00094 // ****************************************************************************************** 00095 // Slot Event Functions 00096 // ****************************************************************************************** 00097 00099 void loadGroupsTree(); 00100 00102 void previewSelected(); 00103 00105 void editSelected(); 00106 00108 void addGroup(); 00109 00111 void saveJointsScreen(); 00112 void saveLinksScreen(); 00113 void saveChainScreen(); 00114 void saveSubgroupsScreen(); 00115 void saveGroupScreenEdit(); 00116 void saveGroupScreenJoints(); 00117 void saveGroupScreenLinks(); 00118 void saveGroupScreenChain(); 00119 void saveGroupScreenSubgroups(); 00120 00121 // Delete a group 00122 void deleteGroup(); 00123 00125 void cancelEditing(); 00126 00128 void alterTree( const QString &link ); 00129 00131 void previewSelectedLink( std::vector<std::string> links ); 00132 00134 //void previewClickedJoint( std::string name ); 00135 void previewSelectedJoints( std::vector<std::string> joints ); 00136 00138 void previewSelectedSubgroup( std::vector<std::string> groups ); 00139 00140 private: 00141 00142 // ****************************************************************************************** 00143 // Qt Components 00144 // ****************************************************************************************** 00145 00147 QTreeWidget* groups_tree_; 00148 00150 QStackedLayout* stacked_layout_; 00151 00153 QPushButton* btn_edit_; 00154 00155 QPushButton* btn_delete_; 00156 00157 // Stacked Layout SUBPAGES ------------------------------------------- 00158 00159 QWidget* groups_tree_widget_; 00160 DoubleListWidget* joints_widget_; 00161 DoubleListWidget* links_widget_; 00162 DoubleListWidget* subgroups_widget_; 00163 KinematicChainWidget* chain_widget_; 00164 GroupEditWidget* group_edit_widget_; 00165 00166 // ****************************************************************************************** 00167 // Variables 00168 // ****************************************************************************************** 00169 00171 moveit_setup_assistant::MoveItConfigDataPtr config_data_; 00172 00174 std::string current_edit_group_; 00175 00177 GroupType current_edit_element_; 00178 00180 bool adding_new_group_; 00181 00182 // ****************************************************************************************** 00183 // Private Functions 00184 // ****************************************************************************************** 00185 00187 QWidget* createContentsWidget(); 00188 00190 void loadGroupsTreeRecursive( srdf::Model::Group &group_it, QTreeWidgetItem* parent ); 00191 00192 // Convenience function for getting a group pointer 00193 srdf::Model::Group* findGroupByName( const std::string &name ); 00194 00195 // Load edit screen 00196 void loadJointsScreen( srdf::Model::Group* this_group ); 00197 void loadLinksScreen( srdf::Model::Group* this_group ); 00198 void loadChainScreen( srdf::Model::Group* this_group ); 00199 void loadSubgroupsScreen( srdf::Model::Group* this_group ); 00200 void loadGroupScreen( srdf::Model::Group* this_group ); 00201 00202 // Save group screen 00203 bool saveGroupScreen(); 00204 00206 void showMainScreen(); 00207 00208 }; 00209 00210 } 00211 00212 // ****************************************************************************************** 00213 // ****************************************************************************************** 00214 // Metatype Class For Holding Points to Group Parts 00215 // ****************************************************************************************** 00216 // ****************************************************************************************** 00217 00218 class PlanGroupType 00219 { 00220 public: 00221 00222 // explicit PlanGroupType(); 00223 PlanGroupType() {} 00224 PlanGroupType( srdf::Model::Group* group, const moveit_setup_assistant::GroupType type ); 00225 virtual ~PlanGroupType() { ; } 00226 00227 srdf::Model::Group* group_; 00228 00229 moveit_setup_assistant::GroupType type_; 00230 }; 00231 00232 Q_DECLARE_METATYPE(PlanGroupType); 00233 00234 00235 #endif