Program Listing for File planning_groups_widget.hpp
↰ Return to documentation for file (include/moveit_setup_srdf_plugins/planning_groups_widget.hpp
)
/*********************************************************************
* Software License Agreement (BSD License)
*
* Copyright (c) 2012, Willow Garage, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Willow Garage nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*********************************************************************/
/* Author: Dave Coleman */
#pragma once
// Qt
#include <QPushButton>
#include <QStackedWidget>
#include <QTreeWidget>
#include <QTreeWidgetItem>
// SA
#include <moveit_setup_framework/qt/setup_step_widget.hpp>
#include <moveit_setup_framework/qt/double_list_widget.hpp>
#include <moveit_setup_srdf_plugins/planning_groups.hpp>
#include <moveit_setup_srdf_plugins/kinematic_chain_widget.hpp> // for kinematic chain page
#include <moveit_setup_srdf_plugins/group_edit_widget.hpp> // for group rename page
// Forward Declaration (outside of namespace for Qt)
class PlanGroupType;
namespace moveit_setup
{
namespace srdf_setup
{
// Custom Type
enum GroupType
{
JOINT = 1,
LINK = 2,
CHAIN = 3,
SUBGROUP = 4,
GROUP = 5
};
// ******************************************************************************************
// ******************************************************************************************
// CLASS
// ******************************************************************************************
// ******************************************************************************************
class PlanningGroupsWidget : public SetupStepWidget
{
Q_OBJECT
public:
// ******************************************************************************************
// Public Functions
// ******************************************************************************************
void onInit() override;
void changeScreen(int index);
void focusGiven() override;
SetupStep& getSetupStep() override
{
return setup_step_;
}
private Q_SLOTS:
// ******************************************************************************************
// Slot Event Functions
// ******************************************************************************************
void loadGroupsTree();
void previewSelected();
void editSelected();
void addGroup();
void saveJointsScreen();
void saveLinksScreen();
void saveChainScreen();
void saveSubgroupsScreen();
void saveGroupScreenEdit();
void saveGroupScreenJoints();
void saveGroupScreenLinks();
void saveGroupScreenChain();
void saveGroupScreenSubgroups();
// Delete a group
void deleteGroup();
void cancelEditing();
void alterTree(const QString& link);
void previewSelectedLink(const std::vector<std::string>& links);
// void previewClickedJoint( std::string name );
void previewSelectedJoints(const std::vector<std::string>& joints);
void previewSelectedSubgroup(const std::vector<std::string>& groups);
private:
// ******************************************************************************************
// Qt Components
// ******************************************************************************************
QTreeWidget* groups_tree_;
QStackedWidget* stacked_widget_;
QPushButton* btn_edit_;
QPushButton* btn_delete_;
// Stacked Layout SUBPAGES -------------------------------------------
QWidget* groups_tree_widget_;
DoubleListWidget* joints_widget_;
DoubleListWidget* links_widget_;
DoubleListWidget* subgroups_widget_;
KinematicChainWidget* chain_widget_;
GroupEditWidget* group_edit_widget_;
// ******************************************************************************************
// Variables
// ******************************************************************************************
PlanningGroups setup_step_;
std::string current_edit_group_;
int return_screen_;
bool adding_new_group_;
// ******************************************************************************************
// Private Functions
// ******************************************************************************************
QWidget* createContentsWidget();
void loadGroupsTreeRecursive(srdf::Model::Group& group_it, QTreeWidgetItem* parent);
// Load edit screen
void loadJointsScreen(srdf::Model::Group* this_group);
void loadLinksScreen(srdf::Model::Group* this_group);
void loadChainScreen(srdf::Model::Group* this_group);
void loadSubgroupsScreen(srdf::Model::Group* this_group);
void loadGroupScreen(srdf::Model::Group* this_group);
// Save group screen
bool saveGroupScreen();
void showMainScreen();
};
// ******************************************************************************************
// ******************************************************************************************
// Metatype Class For Holding Points to Group Parts
// ******************************************************************************************
// ******************************************************************************************
class PlanGroupType
{
public:
// explicit PlanGroupType();
PlanGroupType()
{
}
PlanGroupType(srdf::Model::Group* group, const GroupType type);
virtual ~PlanGroupType()
{
;
}
srdf::Model::Group* group_;
GroupType type_;
};
} // namespace srdf_setup
} // namespace moveit_setup
Q_DECLARE_METATYPE(moveit_setup::srdf_setup::PlanGroupType);