Go to the documentation of this file.
17 #ifndef _GAZEBO_GUI_BUILDING_BUILDINGMAKER_HH_
18 #define _GAZEBO_GUI_BUILDING_BUILDINGMAKER_HH_
24 #include <ignition/math/Pose3.hh>
25 #include <ignition/math/Vector3.hh>
38 class BuildingModelManip;
42 class BuildingMakerPrivate;
58 public:
void OnEdit(
bool _checked);
62 public:
void SetModelName(
const std::string &_modelName);
65 public:
void FinishModel();
73 public: std::string AddPart(
const std::string &_type,
74 const QVector3D &_size,
const QVector3D &_pos,
double _angle);
81 public: std::string AddWall(
const QVector3D &_size,
const QVector3D &_pos,
89 public: std::string AddWindow(
const QVector3D &_size,
90 const QVector3D &_pos,
double _angle);
97 public: std::string AddDoor(
const QVector3D &_size,
const QVector3D &_pos,
106 public: std::string AddStairs(
const QVector3D &_size,
107 const QVector3D &_pos,
double _angle,
int _steps);
114 public: std::string AddFloor(
const QVector3D &_size,
115 const QVector3D &_pos,
double _angle);
119 public:
void RemovePart(
const std::string &_partName);
123 public:
void RemoveWall(
const std::string &_wallName);
128 public:
void ConnectItem(
const std::string &_partName,
136 public:
void AttachManip(
const std::string &_child,
137 const std::string &_parent);
141 public:
void DetachFromParent(
const std::string &_child);
145 public:
void DetachAllChildren(
const std::string &_parent);
150 public:
bool IsAttached(
const std::string &_child)
const;
162 public:
static ignition::math::Vector3d ConvertSize(
163 const double _width,
const double _depth,
const double _height);
174 public:
static ignition::math::Pose3d ConvertPose(
const double _x,
175 const double _y,
const double _z,
const double _roll,
176 const double _pitch,
const double _yaw);
181 public:
static double Convert(
double _value);
186 public:
static double ConvertAngle(
double _angle);
189 public:
void Reset();
192 public:
void GenerateSDF();
195 public:
void BuildingChanged();
199 public: std::string ModelSDF()
const;
202 private:
void CreateTheEntity();
205 private:
bool Init();
209 private: std::string CreateModel();
212 private:
void GenerateSDFWithCSG();
216 private: std::string TemplateSDFString()
const;
220 private:
static bool PointCompareY(
const QPointF &_a,
const QPointF &_b);
224 private:
static bool RectCompareX(
const QRectF &_a,
const QRectF &_b);
228 private:
static bool RectCompareY(
const QRectF &_a,
const QRectF &_b);
236 private:
void SubdivideRectSurface(
const QRectF &_surface,
237 const std::vector<QRectF> &_holes, std::vector<QRectF> &_subdivisions);
240 private:
void SaveModelFiles();
244 private:
bool OnSave();
248 private:
bool OnSaveAs();
252 private:
void OnNameChanged(
const std::string &_modelName);
255 private:
void OnNew();
258 private:
void OnExit();
263 private:
void OnChangeLevel(
int _level);
266 private:
void StopMaterialModes();
270 private:
void ResetHoverVis();
275 private:
void OnColorSelected(QColor _color);
280 private:
void OnTextureSelected(QString _texture);
307 private: std::unique_ptr<BuildingMakerPrivate> dataPtr;
void GenerateSDF()
Generate the SDF from building part visuals.
Forward declarations for the common classes.
Definition: Animation.hh:26
void OnEdit(bool _checked)
QT callback when entering or leaving building edit mode.
Base class of an item in the editor.
Definition: EditorItem.hh:42
static double ConvertAngle(double _angle)
Convert an angle from editor unit to Gazebo unit.
BuildingModelManip * ManipByName(const std::string &_name)
Detach all child building parts from the given manip.
void ConnectItem(const std::string &_partName, const EditorItem *_item)
Connect the 2D editor item Qt signals to the 3D building part.
std::string AddFloor(const QVector3D &_size, const QVector3D &_pos, double _angle)
Add a floor to the model.
void SetModelName(const std::string &_modelName)
Set the name of this building model.
GAZEBO_VISIBLE msgs::Vector3d Convert(const ignition::math::Vector3d &_v)
Convert a ignition::math::Vector3 to a msgs::Vector3d.
static ignition::math::Pose3d ConvertPose(const double _x, const double _y, const double _z, const double _roll, const double _pitch, const double _yaw)
Helper method to convert pose from editor coordinate system to Gazebo coordinate system.
~BuildingMaker()
Destructor.
void RemoveWall(const std::string &_wallName)
Remove a wall from the model.
std::string AddDoor(const QVector3D &_size, const QVector3D &_pos, double _angle)
Add a door to the model.
std::string AddWall(const QVector3D &_size, const QVector3D &_pos, double _angle)
Add a wall to the model.
void DetachAllChildren(const std::string &_parent)
Detach all child building parts from the given manip.
static const double conversionScale
Conversion scale used by the Convert helper functions.
Definition: BuildingMaker.hh:303
void FinishModel()
Finish the model and create the entity on the gzserver.
BuildingMaker()
Constructor.
static ignition::math::Vector3d ConvertSize(const double _width, const double _depth, const double _height)
Helper method to convert size from editor coordinate system to Gazebo coordinate system.
Create and manage 3D visuals of a building.
Definition: BuildingMaker.hh:48
Generic description of a keyboard event.
Definition: KeyEvent.hh:32
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
Manipulate a 3D visual associated to a 2D editor item.
Definition: BuildingModelManip.hh:43
std::string AddStairs(const QVector3D &_size, const QVector3D &_pos, double _angle, int _steps)
Add a staircase to the model.
gui
Definition: KeyEventHandler.hh:29
void Reset()
Reset the building maker and the SDF.
std::string AddWindow(const QVector3D &_size, const QVector3D &_pos, double _angle)
Add a window to the model.
std::string ModelSDF() const
Get the last generated SDF as string.
bool IsAttached(const std::string &_child) const
Whether the given manip is attached to another manip or not.
void RemovePart(const std::string &_partName)
Remove a building part from the model.
void AttachManip(const std::string &_child, const std::string &_parent)
Attach a building part to another, this is currently used for making holes in walls and floors.
void DetachFromParent(const std::string &_child)
Detach a child building part from its parent.
static double Convert(double _value)
std::string AddPart(const std::string &_type, const QVector3D &_size, const QVector3D &_pos, double _angle)
Add a building part to the model.
Generic description of a mouse event.
Definition: MouseEvent.hh:35
void BuildingChanged()
Set save state upon a change to the building.