##

SegmentItem.hh
Go to the documentation of this file.
/*
* Copyright (C) 2014 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_SEGMENTITEM_HH_
#define GAZEBO_GUI_BUILDING_SEGMENTITEM_HH_
#include <memory>
#include <vector>
#include <ignition/math/Vector2.hh>
#include <ignition/math/Vector3.hh>
#include "gazebo/gui/qt.h"
#include "gazebo/gui/building/EditorItem.hh"
#include "gazebo/util/system.hh"
namespace gazebo
{
namespace gui
{
class GrabberHandle;
// Forward declare private data.
class SegmentItemPrivate;
class GZ_GUI_VISIBLE SegmentItem
: public EditorItem, public QGraphicsLineItem
{
public: explicit SegmentItem(QGraphicsItem *_parent = 0);
public: ~SegmentItem();
public: void SetLine(const ignition::math::Vector2d &_start,
const ignition::math::Vector2d &_end);
public: void SetStartPoint(const ignition::math::Vector2d &_start);
public: ignition::math::Vector2d StartPoint() const;
public: void SetEndPoint(const ignition::math::Vector2d &_end);
public: ignition::math::Vector2d EndPoint() const;
public: void SetThickness(const double _thickness);
public: double Thickness() const;
public: double Scale() const;
public: void SetScale(const double _scale);
public: void SetColor(const ignition::math::Color &_color);
public: void ShowHandles(const bool _show);
public: void SegmentChanged();
// Documentation Inherited
public: ignition::math::Vector3d Size() const;
// Documentation Inherited
public: ignition::math::Vector3d ScenePosition() const;
// Documentation Inherited
public: double SceneRotation() const;
public: std::vector<GrabberHandle *>Grabbers() const;
protected: virtual void SegmentUpdated();
protected: void UpdateLinkedGrabbers(GrabberHandle *_grabber,
const ignition::math::Vector2d &_pos);
private: bool sceneEventFilter(QGraphicsItem *watched,
QEvent *_event);
private: bool GrabberEventFilter(GrabberHandle *_grabber,
QEvent *_event);
private: void hoverEnterEvent(QGraphicsSceneHoverEvent *_event);
private: void hoverMoveEvent(QGraphicsSceneHoverEvent *_event);
private: void hoverLeaveEvent(QGraphicsSceneHoverEvent *_event);
private: void mouseMoveEvent(QGraphicsSceneMouseEvent *_event);
private: void mousePressEvent(QGraphicsSceneMouseEvent *_event);
private: void mouseReleaseEvent(QGraphicsSceneMouseEvent *_event);
private: void paint(QPainter *_painter,
const QStyleOptionGraphicsItem *_option, QWidget *_widget);
public: static const double SnapAngle;
public: static const double SnapLength;
protected: std::vector<GrabberHandle *> grabbers;
private: std::unique_ptr<SegmentItemPrivate> dataPtr;
};
}
}
#endif
gazebo::gui::SegmentItem::~SegmentItem
~SegmentItem()
Destructor.
gazebo::gui::SegmentItem::Grabbers
std::vector< GrabberHandle * > Grabbers() const
Get the grabber handles.
gazebo::gui::SegmentItem::Scale
double Scale() const
Get the scale of the segment item.
gazebo::gui::SegmentItem::Size
ignition::math::Vector3d Size() const
Get the size of the item in pixels.
gazebo
Forward declarations for the common classes.
Definition: Animation.hh:26
qt.h
gazebo::gui::EditorItem
Base class of an item in the editor.
Definition: EditorItem.hh:42
gazebo::gui::SegmentItem::SegmentUpdated
virtual void SegmentUpdated()
Update item.
EditorItem.hh
gazebo::gui::SegmentItem::SnapLength
static const double SnapLength
Length to snap in meters.
Definition: SegmentItem.hh:174
gazebo::gui::SegmentItem::StartPoint
ignition::math::Vector2d StartPoint() const
Get the start point of the segment.
system.hh
gazebo::gui::SegmentItem::Thickness
double Thickness() const
Get the thickness of the segment item.
gazebo::gui::GrabberHandle
Definition: GrabberHandle.hh:38
gazebo::gui::SegmentItem::SetEndPoint
void SetEndPoint(const ignition::math::Vector2d &_end)
Set the end point of the segment.
gazebo::gui::SegmentItem::SetColor
void SetColor(const ignition::math::Color &_color)
Set the color of the segment item.
gazebo::gui::SegmentItem::SetThickness
void SetThickness(const double _thickness)
Set the thickness of the segment item on the 2d view.
gazebo::gui::SegmentItem::ScenePosition
ignition::math::Vector3d ScenePosition() const
Get the scene position of editor item.
gazebo::gui::SegmentItem::SetScale
void SetScale(const double _scale)
Set the scale of the segment item.
gazebo::gui::SegmentItem::SetLine
void SetLine(const ignition::math::Vector2d &_start, const ignition::math::Vector2d &_end)
Set the segment's line.
gazebo::gui::SegmentItem::SetStartPoint
void SetStartPoint(const ignition::math::Vector2d &_start)
Set the start point of the segment.
gazebo::gui::SegmentItem::EndPoint
ignition::math::Vector2d EndPoint() const
Get the end point of the segment.
gazebo::gui::SegmentItem::SegmentChanged
void SegmentChanged()
Emit segment changed Qt signals.
gui
gui
Definition: KeyEventHandler.hh:29
gazebo::gui::SegmentItem
2D line segment.
Definition: SegmentItem.hh:44
gazebo::gui::SegmentItem::UpdateLinkedGrabbers
void UpdateLinkedGrabbers(GrabberHandle *_grabber, const ignition::math::Vector2d &_pos)
Update the position of all grabbers linked to the given one.
gazebo::gui::SegmentItem::SceneRotation
double SceneRotation() const
Get the scene rotation of the editor item.
gazebo::gui::SegmentItem::SnapAngle
static const double SnapAngle
Angle to snap in degrees.
Definition: SegmentItem.hh:171
gazebo::gui::SegmentItem::SegmentItem
SegmentItem(QGraphicsItem *_parent=0)
Constructor.
gazebo::gui::SegmentItem::ShowHandles
void ShowHandles(const bool _show)
Show the grabber handles of the segment item.
gazebo::gui::SegmentItem::grabbers
std::vector< GrabberHandle * > grabbers
A list of grabber handles for this item.
Definition: SegmentItem.hh:178