##

RectItem.hh
Go to the documentation of this file.
/*
* Copyright (C) 2012 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_BUILDING_RECTITEM_HH_
#define _GAZEBO_GUI_BUILDING_RECTITEM_HH_
#include <memory>
#include <vector>
#include <ignition/math/Vector2.hh>
#include <ignition/math/Vector3.hh>
#include <ignition/math/Color.hh>
#include "gazebo/gui/qt.h"
#include "gazebo/gui/building/EditorItem.hh"
#include "gazebo/util/system.hh"
namespace gazebo
{
namespace gui
{
class GrabberHandle;
class MeasureItem;
class RotateHandle;
// Forward declare private data.
class RectItemPrivate;
class GZ_GUI_VISIBLE RectItem :
public EditorItem, public QGraphicsRectItem
{
Q_OBJECT
public: enum ResizeFlags
{
NONE = 0x00,
ITEM_WIDTH = 0x01,
ITEM_HEIGHT = 0x02
};
public: RectItem();
public: virtual ~RectItem();
public: void SetWidth(const int _width);
public: void SetHeight(const int _height);
public: void SetSize(const ignition::math::Vector2i &_size);
public: double Width() const;
public: double Height() const;
public: void SetPositionOnWall(const double _positionOnWall);
public: double PositionOnWall() const;
public: void SetAngleOnWall(const double _angleOnWall);
public: double AngleOnWall() const;
public: void ShowHandles(const bool _show);
// Documentation inherited
public: void SetHighlighted(const bool _highlighted);
public: void DetachFromParent();
protected: void UpdateCornerPositions();
protected: void DrawBoundingBox(QPainter *_painter);
public: virtual void SetPosition(const ignition::math::Vector2d &_pos);
public: virtual void SetPosition(const double _x, const double _y);
public: virtual void SetRotation(const double _angle);
public: virtual void SetResizeFlag(const unsigned int _flag);
public: virtual double Rotation() const;
// Documentation inherited
public: virtual ignition::math::Vector3d Size() const;
// Documentation inherited
public: virtual ignition::math::Vector3d ScenePosition() const;
// Documentation inherited
public: virtual double SceneRotation() const;
protected: virtual QRectF boundingRect() const;
protected: void UpdateMeasures();
private: virtual bool RotateEventFilter(RotateHandle *_rotateHandle,
QEvent *_event);
private: virtual bool GrabberEventFilter(GrabberHandle *_grabber,
QEvent *_event);
private: virtual void paint(QPainter *_painter,
const QStyleOptionGraphicsItem *_option, QWidget *_widget);
private: void hoverEnterEvent(QGraphicsSceneHoverEvent *_event);
private: void hoverMoveEvent(QGraphicsSceneHoverEvent *_event);
private: void hoverLeaveEvent(QGraphicsSceneHoverEvent *_event);
private: virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *_event);
private: virtual void mousePressEvent(QGraphicsSceneMouseEvent *_event);
private: virtual void mouseReleaseEvent(
QGraphicsSceneMouseEvent *_event);
private: virtual void mousePressEvent(
QGraphicsSceneDragDropEvent *_event);
private: virtual void mouseMoveEvent(
QGraphicsSceneDragDropEvent *_event);
private: virtual void mouseDoubleClickEvent(
QGraphicsSceneMouseEvent *_event);
private: virtual bool sceneEventFilter(QGraphicsItem *_watched,
QEvent *_event);
private: QVariant itemChange(GraphicsItemChange _change,
const QVariant &_value);
private: virtual void contextMenuEvent(
QGraphicsSceneContextMenuEvent *_event);
private: virtual void SizeChanged();
private: void AdjustSize(const double _x, const double _y);
private slots: virtual void OnOpenInspector();
private slots: virtual void OnDeleteItem();
protected: double width;
protected: double height;
protected: double drawingWidth;
protected: double drawingHeight;
protected: double drawingOriginX;
protected: double drawingOriginY;
protected: ignition::math::Color borderColor;
protected: double rotationAngle;
protected: QAction *openInspectorAct;
protected: QAction *deleteItemAct;
protected: std::vector<MeasureItem *> measures;
private: std::unique_ptr<RectItemPrivate> dataPtr;
};
}
}
#endif
gazebo::gui::RectItem::SceneRotation
virtual double SceneRotation() const
Get the scene rotation of the editor item.
gazebo::gui::RectItem::drawingWidth
double drawingWidth
Actual width of rect item drawn in pixels.
Definition: RectItem.hh:263
gazebo::gui::RectItem::PositionOnWall
double PositionOnWall() const
Get the position of this item inside its parent wall.
gazebo::gui::RectItem::SetPosition
virtual void SetPosition(const ignition::math::Vector2d &_pos)
Set the position of the rect item.
gazebo::gui::RectItem::Rotation
virtual double Rotation() const
Get the rotation of the rect item.
gazebo
Forward declarations for the common classes.
Definition: Animation.hh:26
gazebo::gui::RectItem::DrawBoundingBox
void DrawBoundingBox(QPainter *_painter)
Draw bounding box.
qt.h
gazebo::gui::RectItem::SetHeight
void SetHeight(const int _height)
Set the height of the rect item.
gazebo::gui::EditorItem
Base class of an item in the editor.
Definition: EditorItem.hh:42
gazebo::gui::RectItem::~RectItem
virtual ~RectItem()
Destructor.
gazebo::gui::RectItem::rotationAngle
double rotationAngle
Rotation angle of the rect item in degrees.
Definition: RectItem.hh:278
EditorItem.hh
gazebo::gui::RectItem::Size
virtual ignition::math::Vector3d Size() const
Get the size of the item in pixels.
gazebo::gui::RectItem::ResizeFlags
ResizeFlags
Resize flags used to indicate which dimension can be resized.
Definition: RectItem.hh:55
gazebo::gui::RectItem::borderColor
ignition::math::Color borderColor
Border color of the rect item.
Definition: RectItem.hh:275
system.hh
gazebo::gui::RectItem::height
double height
Height of rect item in pixels.
Definition: RectItem.hh:260
gazebo::gui::RectItem::AngleOnWall
double AngleOnWall() const
Get the angle of this item inside its parent wall.
gazebo::gui::GrabberHandle
Definition: GrabberHandle.hh:38
gazebo::gui::RectItem::ITEM_WIDTH
Width.
Definition: RectItem.hh:61
gazebo::gui::RectItem::DetachFromParent
void DetachFromParent()
Detach the rect item from its parent.
gazebo::gui::RectItem::Width
double Width() const
Get the width of the rect item.
gazebo::gui::RectItem::SetResizeFlag
virtual void SetResizeFlag(const unsigned int _flag)
Set the resize flag of the rect item.
gazebo::gui::RectItem::drawingOriginX
double drawingOriginX
X origin of the rect item in pixels.
Definition: RectItem.hh:269
gazebo::gui::RectItem::deleteItemAct
QAction * deleteItemAct
Qt action for deleting the item.
Definition: RectItem.hh:284
gazebo::gui::RectItem::ShowHandles
void ShowHandles(const bool _show)
Show the grabber and rotate handles of the rect item.
gazebo::gui::RectItem::ITEM_HEIGHT
Height.
Definition: RectItem.hh:64
gazebo::gui::RectItem::SetSize
void SetSize(const ignition::math::Vector2i &_size)
Set the size of the rect item.
gazebo::gui::RectItem
2D rectangle.
Definition: RectItem.hh:49
gazebo::gui::RectItem::width
double width
Width of rect item in pixels.
Definition: RectItem.hh:257
gazebo::gui::RectItem::drawingHeight
double drawingHeight
Actual height of rect item drawn in pixels.
Definition: RectItem.hh:266
gazebo::gui::RectItem::RectItem
RectItem()
Constructor.
gazebo::gui::RotateHandle
Handle for rotating an editor item.
Definition: RotateHandle.hh:37
gazebo::gui::RectItem::SetWidth
void SetWidth(const int _width)
Set the width of the rect item.
gazebo::gui::RectItem::UpdateMeasures
void UpdateMeasures()
Update this item's measures.
gazebo::gui::RectItem::measures
std::vector< MeasureItem * > measures
A vector containing this item's measure items.
Definition: RectItem.hh:289
gui
gui
Definition: KeyEventHandler.hh:29
gazebo::gui::RectItem::Height
double Height() const
Get the height of the rect item.
gazebo::gui::RectItem::drawingOriginY
double drawingOriginY
Y origin of the rect item in pixels.
Definition: RectItem.hh:272
gazebo::gui::RectItem::boundingRect
virtual QRectF boundingRect() const
Get the bounding box of the rect item.
gazebo::gui::RectItem::SetRotation
virtual void SetRotation(const double _angle)
Set the rotation of the rect item.
gazebo::gui::RectItem::SetPositionOnWall
void SetPositionOnWall(const double _positionOnWall)
Set the position of this item inside its parent wall.
gazebo::gui::RectItem::NONE
No dimensions.
Definition: RectItem.hh:58
gazebo::gui::RectItem::SetAngleOnWall
void SetAngleOnWall(const double _angleOnWall)
Set the angle of this item inside its parent wall.
gazebo::gui::RectItem::UpdateCornerPositions
void UpdateCornerPositions()
Helper method for Updating the corner positions of the rect item.
gazebo::gui::RectItem::SetHighlighted
void SetHighlighted(const bool _highlighted)
Set whether this item should be highlighted or not.
gazebo::gui::RectItem::ScenePosition
virtual ignition::math::Vector3d ScenePosition() const
Get the scene position of editor item.
gazebo::gui::RectItem::openInspectorAct
QAction * openInspectorAct
Qt action for opening the inspector.
Definition: RectItem.hh:281