##

MEUserCmdManager.hh
Go to the documentation of this file.
/*
* Copyright (C) 2016 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef GAZEBO_GUI_MODEL_MEUSERCMDMANAGER_HH_
#define GAZEBO_GUI_MODEL_MEUSERCMDMANAGER_HH_
#include <map>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include <sdf/sdf.hh>
#include "gazebo/gui/qt.h"
#include "gazebo/gui/UserCmdHistory.hh"
#include "gazebo/gui/model/ModelEditorTypes.hh"
#include "gazebo/util/system.hh"
namespace gazebo
{
namespace gui
{
class UserCmdHistory;
// Forward declare private data.
class MEUserCmdPrivate;
class MEUserCmdManagerPrivate;
class GZ_GUI_VISIBLE MEUserCmd
{
public: enum CmdType
{
INSERTING_LINK = 0,
DELETING_LINK = 1,
INSERTING_NESTED_MODEL = 2,
DELETING_NESTED_MODEL = 3,
INSERTING_JOINT = 4,
DELETING_JOINT = 5,
MOVING_LINK = 6,
MOVING_NESTED_MODEL = 7,
SCALING_LINK = 8,
INSERTING_MODEL_PLUGIN = 9,
DELETING_MODEL_PLUGIN = 10
};
public: MEUserCmd(const unsigned int _id, const std::string &_description,
MEUserCmd::CmdType _type);
public: virtual ~MEUserCmd();
public: virtual void Undo();
public: virtual void Redo();
public: unsigned int Id() const;
public: std::string Description() const;
public: void SetSDF(sdf::ElementPtr _sdf);
public: void SetScopedName(const std::string &_name);
public: void SetJointId(const std::string &_id);
public: void SetPoseChange(const ignition::math::Pose3d &_before,
const ignition::math::Pose3d &_after);
public: void SetScaleChange(
const std::map<std::string, ignition::math::Vector3d> &_before,
const std::map<std::string, ignition::math::Vector3d> &_after);
protected: std::unique_ptr<MEUserCmdPrivate> dataPtr;
};
class GZ_GUI_VISIBLE MEUserCmdManager : public UserCmdHistory
{
Q_OBJECT
public: MEUserCmdManager();
public: virtual ~MEUserCmdManager();
public: void Reset();
public: MEUserCmdPtr NewCmd(const std::string &_description,
const MEUserCmd::CmdType _type);
private slots: void OnUndoCommand(QAction *_action);
private slots: void OnRedoCommand(QAction *_action);
private: virtual bool HasUndo() const;
private: virtual bool HasRedo() const;
private: virtual std::vector<std::pair<unsigned int, std::string>>
Cmds(const bool _undo) const;
private: std::unique_ptr<MEUserCmdManagerPrivate> dataPtr;
};
}
}
#endif
gazebo::gui::MEUserCmdManager
Class which manages user commands in the model editor.
Definition: MEUserCmdManager.hh:144
gazebo::gui::MEUserCmd::Id
unsigned int Id() const
Return this command's unique ID.
gazebo::gui::MEUserCmd::DELETING_JOINT
Delete a joint.
Definition: MEUserCmdManager.hh:68
gazebo::gui::MEUserCmdManager::MEUserCmdManager
MEUserCmdManager()
Constructor.
gazebo::gui::MEUserCmdManager::~MEUserCmdManager
virtual ~MEUserCmdManager()
Destructor.
gazebo::gui::UserCmdHistory
Class which manages user commands in the client side.
Definition: UserCmdHistory.hh:36
gazebo::gui::MEUserCmd::Undo
virtual void Undo()
Undo this command.
gazebo
Forward declarations for the common classes.
Definition: Animation.hh:26
qt.h
gazebo::gui::MEUserCmd::DELETING_MODEL_PLUGIN
Delete a model plugin.
Definition: MEUserCmdManager.hh:83
gazebo::gui::MEUserCmd::Redo
virtual void Redo()
Redo this command.
gazebo::gui::MEUserCmd::INSERTING_NESTED_MODEL
Insert a nested model.
Definition: MEUserCmdManager.hh:59
gazebo::gui::MEUserCmd
Class which represents a user command, which can be "undone" and "redone".
Definition: MEUserCmdManager.hh:46
gazebo::gui::MEUserCmd::MEUserCmd
MEUserCmd(const unsigned int _id, const std::string &_description, MEUserCmd::CmdType _type)
Constructor.
system.hh
UserCmdHistory.hh
gazebo::gui::MEUserCmd::DELETING_NESTED_MODEL
Delete a nested model.
Definition: MEUserCmdManager.hh:62
gazebo::gui::MEUserCmd::SCALING_LINK
Scale a link.
Definition: MEUserCmdManager.hh:77
gazebo::gui::MEUserCmd::SetPoseChange
void SetPoseChange(const ignition::math::Pose3d &_before, const ignition::math::Pose3d &_after)
Set the pose before and after the command.
gazebo::gui::MEUserCmd::dataPtr
std::unique_ptr< MEUserCmdPrivate > dataPtr
Definition: MEUserCmdManager.hh:139
gazebo::gui::MEUserCmdManager::NewCmd
MEUserCmdPtr NewCmd(const std::string &_description, const MEUserCmd::CmdType _type)
Register that a new command has been executed by the user.
gazebo::gui::MEUserCmd::SetJointId
void SetJointId(const std::string &_id)
Set the unique id of the joint related to this command.
gazebo::gui::MEUserCmd::~MEUserCmd
virtual ~MEUserCmd()
Destructor.
gazebo::gui::MEUserCmd::INSERTING_MODEL_PLUGIN
Insert a model plugin.
Definition: MEUserCmdManager.hh:80
gazebo::gui::MEUserCmd::Description
std::string Description() const
Return this command's description.
gazebo::gui::MEUserCmdManager::Reset
void Reset()
Reset commands.
gazebo::gui::MEUserCmd::MOVING_NESTED_MODEL
Move a nested model.
Definition: MEUserCmdManager.hh:74
gazebo::gui::MEUserCmdPtr
std::shared_ptr< MEUserCmd > MEUserCmdPtr
Definition: ModelEditorTypes.hh:37
gazebo::gui::MEUserCmd::SetSDF
void SetSDF(sdf::ElementPtr _sdf)
Set the SDF element relevant to this command.
gui
gui
Definition: KeyEventHandler.hh:29
gazebo::gui::MEUserCmd::CmdType
CmdType
Types of user commands.
Definition: MEUserCmdManager.hh:50
gazebo::gui::MEUserCmd::SetScopedName
void SetScopedName(const std::string &_name)
Set the scoped name of the entity related to this command.
gazebo::gui::MEUserCmd::DELETING_LINK
Delete a link.
Definition: MEUserCmdManager.hh:56
gazebo::gui::MEUserCmd::INSERTING_JOINT
Insert a joint.
Definition: MEUserCmdManager.hh:65
gazebo::gui::MEUserCmd::MOVING_LINK
Move a link.
Definition: MEUserCmdManager.hh:71
ModelEditorTypes.hh
gazebo::gui::MEUserCmd::INSERTING_LINK
Insert a link.
Definition: MEUserCmdManager.hh:53
gazebo::gui::MEUserCmd::SetScaleChange
void SetScaleChange(const std::map< std::string, ignition::math::Vector3d > &_before, const std::map< std::string, ignition::math::Vector3d > &_after)
Set the scale factors before and after the command.