QElectroTech  0.8-dev
Public Types | Signals | Public Member Functions | Protected Member Functions | Properties | Private Member Functions | Private Attributes | List of all members
QetShapeItem Class Reference

The QetShapeItem class this class is used to draw a basic shape (line, rectangle, ellipse) into a diagram, that can be saved to .qet file. More...

#include <qetshapeitem.h>

Inheritance diagram for QetShapeItem:
Inheritance graph
Collaboration diagram for QetShapeItem:
Collaboration graph

Public Types

enum  ShapeType { Line =1, Rectangle =2, Ellipse =4, Polygon =8 }
 
enum  { Type = UserType + 1008 }
 

Signals

void penChanged ()
 
void brushChanged ()
 
void closeChanged ()
 
void XRadiusChanged ()
 
void YRadiusChanged ()
 

Public Member Functions

 QetShapeItem (QPointF, QPointF=QPointF(0, 0), ShapeType=Line, QGraphicsItem *parent=nullptr)
 QetShapeItem::QetShapeItem Constructor of shape item. point 1 and 2 must be in scene coordinate. More...
 
 ~QetShapeItem () override
 
int type () const override
 
QPen pen () const
 METHODS. More...
 
void setPen (const QPen &pen)
 QetShapeItem::setPen Set the pen to use for draw the shape. More...
 
QBrush brush () const
 
void setBrush (const QBrush &brush)
 QetShapeItem::setBrush Set the brush to use for the fill the shape. More...
 
ShapeType shapeType () const
 
virtual bool fromXml (const QDomElement &)
 QetShapeItem::fromXml Build this item from the xml description. More...
 
virtual QDomElement toXml (QDomDocument &document) const
 QetShapeItem::toXml Save this item to xml element. More...
 
virtual bool toDXF (const QString &filepath, const QPen &pen)
 QetShapeItem::toDXF Draw this element to the dxf document. More...
 
void editProperty () override
 QetShapeItem::editProperty Edit the property of this item. More...
 
QString name () const override
 QetShapeItem::name. More...
 
void setP2 (const QPointF &P2)
 QetShapeItem::setP2 Set the second point of this item. If this item is a polyline, the last point of the polyline is replaced by P2. More...
 
QLineF line () const
 
bool setLine (const QLineF &line)
 QetShapeItem::setLine Set item geometry to line (only available for line shape) More...
 
QRectF rect () const
 
bool setRect (const QRectF &rect)
 QetShapeItem::setRect Set this item geometry to rect (only available if shape is a rectangle or an ellipse) More...
 
QPolygonF polygon () const
 
bool setPolygon (const QPolygonF &polygon)
 QetShapeItem::setPolygon Set this item geometry to polygon (only available if shape is a polyline) More...
 
bool isClosed () const
 
void setClosed (bool close)
 QetShapeItem::setClosed Close this item, have effect only if this item is a polygon. More...
 
qreal XRadius () const
 
void setXRadius (qreal X)
 
qreal YRadius () const
 
void setYRadius (qreal Y)
 
int pointsCount () const
 QetShapeItem::pointCount. More...
 
void setNextPoint (QPointF P)
 QetShapeItem::setNextPoint Add a new point to the curent polygon. More...
 
void removePoints (int number=1)
 QetShapeItem::removePoints Number of point to remove on the polygon If number is superior to number of polygon points-2, all points of polygon will be removed except the first two (minimum point for the polygon);. More...
 
QRectF boundingRect () const override
 QetShapeItem::boundingRect. More...
 
QPainterPath shape () const override
 QetShapeItem::shape. More...
 
- Public Member Functions inherited from QetGraphicsItem
 QetGraphicsItem (QGraphicsItem *parent=nullptr)
 QetGraphicsItem::QetGraphicsItem Default constructor. More...
 
 ~QetGraphicsItem () override=0
 
Diagramdiagram () const
 
virtual void setPos (const QPointF &p)
 
virtual void setPos (qreal x, qreal y)
 
virtual bool isMovable () const
 
virtual void setMovable (bool movable)
 
QET::GraphicsItemState state () const
 QetGraphicsItem::state. More...
 

Protected Member Functions

void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
 QetShapeItem::paint Paint this item. More...
 
void hoverEnterEvent (QGraphicsSceneHoverEvent *event) override
 QetShapeItem::hoverEnterEvent Handle hover enter event. More...
 
void hoverLeaveEvent (QGraphicsSceneHoverEvent *event) override
 QetShapeItem::hoverLeaveEvent Handle hover leave event. More...
 
void mousePressEvent (QGraphicsSceneMouseEvent *event) override
 
QVariant itemChange (GraphicsItemChange change, const QVariant &value) override
 QetShapeItem::itemChange. More...
 
bool sceneEventFilter (QGraphicsItem *watched, QEvent *event) override
 QetShapeItem::sceneEventFilter. More...
 
void contextMenuEvent (QGraphicsSceneContextMenuEvent *event) override
 QetShapeItem::contextMenuEvent. More...
 
- Protected Member Functions inherited from QetGraphicsItem
void mousePressEvent (QGraphicsSceneMouseEvent *event) override
 
void mouseDoubleClickEvent (QGraphicsSceneMouseEvent *event) override
 
void mouseMoveEvent (QGraphicsSceneMouseEvent *event) override
 
void mouseReleaseEvent (QGraphicsSceneMouseEvent *event) override
 QetGraphicsItem::mouseReleaseEvent handle mouse release click. More...
 

Properties

QPen pen
 
QBrush brush
 
QRectF rect
 
QLineF line
 
QPolygonF polygon
 
bool close
 
qreal xRadius
 
qreal yRadius
 

Private Member Functions

void switchResizeMode ()
 QetShapeItem::switchResizeMode. More...
 
void addHandler ()
 
void adjusteHandlerPos ()
 QetShapeItem::adjusteHandlerPos Adjust the position of the handler item. More...
 
void insertPoint ()
 
void removePoint ()
 
void handlerMousePressEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
 QetShapeItem::handlerMousePressEvent. More...
 
void handlerMouseMoveEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
 QetShapeItem::handlerMouseMoveEvent. More...
 
void handlerMouseReleaseEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
 QetShapeItem::handlerMouseReleaseEvent. More...
 

Private Attributes

ShapeType m_shapeType
 ATTRIBUTES. More...
 
QPen m_pen
 
QBrush m_brush
 
QPointF m_P1
 
QPointF m_P2
 
QPointF m_old_P1
 
QPointF m_old_P2
 
QPointF m_context_menu_pos
 
QPolygonF m_polygon
 
QPolygonF m_old_polygon
 
bool m_hovered
 
int m_vector_index
 
bool m_closed = false
 
bool m_modifie_radius_equaly = false
 
int m_resize_mode = 1
 
QVector< QetGraphicsHandlerItem * > m_handler_vector
 
QAction * m_insert_point
 
QAction * m_remove_point
 
qreal m_xRadius = 0
 
qreal m_yRadius = 0
 
qreal m_old_xRadius
 
qreal m_old_yRadius
 

Additional Inherited Members

- Protected Attributes inherited from QetGraphicsItem
bool is_movable_
 
bool m_first_move
 
bool snap_to_grid_
 
QPointF m_mouse_to_origin_movement
 
QET::GraphicsItemState m_state = QET:: GIOK
 

Detailed Description

The QetShapeItem class this class is used to draw a basic shape (line, rectangle, ellipse) into a diagram, that can be saved to .qet file.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
Type 

◆ ShapeType

Enumerator
Line 
Rectangle 
Ellipse 
Polygon 

Constructor & Destructor Documentation

◆ QetShapeItem()

QetShapeItem::QetShapeItem ( QPointF  p1,
QPointF  p2 = QPointF(0,0),
ShapeType  type = Line,
QGraphicsItem *  parent = nullptr 
)

QetShapeItem::QetShapeItem Constructor of shape item. point 1 and 2 must be in scene coordinate.

Parameters
p1first point
p2second point
typetype of item (line, rectangle, ellipse)
parentparent item
Here is the call graph for this function:

◆ ~QetShapeItem()

QetShapeItem::~QetShapeItem ( )
override

Member Function Documentation

◆ addHandler()

void QetShapeItem::addHandler ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ adjusteHandlerPos()

void QetShapeItem::adjusteHandlerPos ( )
private

QetShapeItem::adjusteHandlerPos Adjust the position of the handler item.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ boundingRect()

QRectF QetShapeItem::boundingRect ( ) const
override

QetShapeItem::boundingRect.

Returns
the bounding rect of this item
Here is the call graph for this function:
Here is the caller graph for this function:

◆ brush()

QBrush QetShapeItem::brush ( ) const
inline

◆ brushChanged

void QetShapeItem::brushChanged ( )
signal
Here is the caller graph for this function:

◆ closeChanged

void QetShapeItem::closeChanged ( )
signal
Here is the caller graph for this function:

◆ contextMenuEvent()

void QetShapeItem::contextMenuEvent ( QGraphicsSceneContextMenuEvent *  event)
overrideprotected

QetShapeItem::contextMenuEvent.

Parameters
event
Here is the call graph for this function:

◆ editProperty()

void QetShapeItem::editProperty ( )
overridevirtual

QetShapeItem::editProperty Edit the property of this item.

Reimplemented from QetGraphicsItem.

Here is the call graph for this function:

◆ fromXml()

bool QetShapeItem::fromXml ( const QDomElement &  e)
virtual

QetShapeItem::fromXml Build this item from the xml description.

Parameters
eelement where is stored this item
Returns
true if load success
Here is the call graph for this function:

◆ handlerMouseMoveEvent()

void QetShapeItem::handlerMouseMoveEvent ( QetGraphicsHandlerItem qghi,
QGraphicsSceneMouseEvent *  event 
)
private

QetShapeItem::handlerMouseMoveEvent.

Parameters
qghi
event
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handlerMousePressEvent()

void QetShapeItem::handlerMousePressEvent ( QetGraphicsHandlerItem qghi,
QGraphicsSceneMouseEvent *  event 
)
private

QetShapeItem::handlerMousePressEvent.

Parameters
qghi
event
Here is the caller graph for this function:

◆ handlerMouseReleaseEvent()

void QetShapeItem::handlerMouseReleaseEvent ( QetGraphicsHandlerItem qghi,
QGraphicsSceneMouseEvent *  event 
)
private

QetShapeItem::handlerMouseReleaseEvent.

Parameters
qghi
event
Here is the call graph for this function:
Here is the caller graph for this function:

◆ hoverEnterEvent()

void QetShapeItem::hoverEnterEvent ( QGraphicsSceneHoverEvent *  event)
overrideprotected

QetShapeItem::hoverEnterEvent Handle hover enter event.

Parameters
event

◆ hoverLeaveEvent()

void QetShapeItem::hoverLeaveEvent ( QGraphicsSceneHoverEvent *  event)
overrideprotected

QetShapeItem::hoverLeaveEvent Handle hover leave event.

Parameters
event

◆ insertPoint()

void QetShapeItem::insertPoint ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isClosed()

bool QetShapeItem::isClosed ( ) const
inline
Here is the caller graph for this function:

◆ itemChange()

QVariant QetShapeItem::itemChange ( GraphicsItemChange  change,
const QVariant &  value 
)
overrideprotected

QetShapeItem::itemChange.

Parameters
change
value
Returns
Here is the call graph for this function:

◆ line()

QLineF QetShapeItem::line ( ) const
inline

◆ mousePressEvent()

void QetShapeItem::mousePressEvent ( QGraphicsSceneMouseEvent *  event)
overrideprotected
Here is the call graph for this function:

◆ name()

QString QetShapeItem::name ( ) const
overridevirtual

QetShapeItem::name.

Returns
the name of the curent shape.

Reimplemented from QetGraphicsItem.

Here is the caller graph for this function:

◆ paint()

void QetShapeItem::paint ( QPainter *  painter,
const QStyleOptionGraphicsItem *  option,
QWidget *  widget 
)
overrideprotected

QetShapeItem::paint Paint this item.

Parameters
painter
option
widget
Here is the call graph for this function:

◆ pen()

QPen QetShapeItem::pen ( ) const
inline

METHODS.

◆ penChanged

void QetShapeItem::penChanged ( )
signal
Here is the caller graph for this function:

◆ pointsCount()

int QetShapeItem::pointsCount ( ) const

QetShapeItem::pointCount.

Returns
the number of point in the polygon
Here is the caller graph for this function:

◆ polygon()

QPolygonF QetShapeItem::polygon ( ) const
inline

◆ rect()

QRectF QetShapeItem::rect ( ) const
inline

◆ removePoint()

void QetShapeItem::removePoint ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ removePoints()

void QetShapeItem::removePoints ( int  number = 1)

QetShapeItem::removePoints Number of point to remove on the polygon If number is superior to number of polygon points-2, all points of polygon will be removed except the first two (minimum point for the polygon);.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sceneEventFilter()

bool QetShapeItem::sceneEventFilter ( QGraphicsItem *  watched,
QEvent *  event 
)
overrideprotected

QetShapeItem::sceneEventFilter.

Parameters
watched
event
Returns
Here is the call graph for this function:

◆ setBrush()

void QetShapeItem::setBrush ( const QBrush &  brush)

QetShapeItem::setBrush Set the brush to use for the fill the shape.

Parameters
brush
Here is the caller graph for this function:

◆ setClosed()

void QetShapeItem::setClosed ( bool  close)

QetShapeItem::setClosed Close this item, have effect only if this item is a polygon.

Parameters
close
Here is the caller graph for this function:

◆ setLine()

bool QetShapeItem::setLine ( const QLineF &  line)

QetShapeItem::setLine Set item geometry to line (only available for line shape)

Parameters
line
Returns
: true when shape is a Line, else false
Here is the call graph for this function:

◆ setNextPoint()

void QetShapeItem::setNextPoint ( QPointF  P)

QetShapeItem::setNextPoint Add a new point to the curent polygon.

Parameters
Pthe new point.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setP2()

void QetShapeItem::setP2 ( const QPointF &  P2)

QetShapeItem::setP2 Set the second point of this item. If this item is a polyline, the last point of the polyline is replaced by P2.

Parameters
P2
Here is the caller graph for this function:

◆ setPen()

void QetShapeItem::setPen ( const QPen &  pen)

QetShapeItem::setPen Set the pen to use for draw the shape.

Parameters
pen
Here is the caller graph for this function:

◆ setPolygon()

bool QetShapeItem::setPolygon ( const QPolygonF &  polygon)

QetShapeItem::setPolygon Set this item geometry to polygon (only available if shape is a polyline)

Parameters
polygon: new polygon
Returns
true if item is polygon, else false
Here is the call graph for this function:

◆ setRect()

bool QetShapeItem::setRect ( const QRectF &  rect)

QetShapeItem::setRect Set this item geometry to rect (only available if shape is a rectangle or an ellipse)

Parameters
rect: new rect
Returns
: true when shape is rectangle or ellipse, else false
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setXRadius()

void QetShapeItem::setXRadius ( qreal  X)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setYRadius()

void QetShapeItem::setYRadius ( qreal  Y)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ shape()

QPainterPath QetShapeItem::shape ( ) const
override

QetShapeItem::shape.

Returns
the shape of this item
Here is the caller graph for this function:

◆ shapeType()

ShapeType QetShapeItem::shapeType ( ) const
inline
Here is the caller graph for this function:

◆ switchResizeMode()

void QetShapeItem::switchResizeMode ( )
private

QetShapeItem::switchResizeMode.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toDXF()

bool QetShapeItem::toDXF ( const QString &  filepath,
const QPen &  pen 
)
virtual

QetShapeItem::toDXF Draw this element to the dxf document.

Parameters
filepathfile path of the the dxf document
pen
Returns
true if draw success
Here is the call graph for this function:
Here is the caller graph for this function:

◆ toXml()

QDomElement QetShapeItem::toXml ( QDomDocument &  document) const
virtual

QetShapeItem::toXml Save this item to xml element.

Parameters
documentparent document xml
Returns
element xml where is write this item
Here is the call graph for this function:

◆ type()

int QetShapeItem::type ( ) const
inlineoverride
Here is the caller graph for this function:

◆ XRadius()

qreal QetShapeItem::XRadius ( ) const
inline
Here is the caller graph for this function:

◆ XRadiusChanged

void QetShapeItem::XRadiusChanged ( )
signal
Here is the caller graph for this function:

◆ YRadius()

qreal QetShapeItem::YRadius ( ) const
inline

◆ YRadiusChanged

void QetShapeItem::YRadiusChanged ( )
signal
Here is the caller graph for this function:

Member Data Documentation

◆ m_brush

QBrush QetShapeItem::m_brush
private

◆ m_closed

bool QetShapeItem::m_closed = false
private

◆ m_context_menu_pos

QPointF QetShapeItem::m_context_menu_pos
private

◆ m_handler_vector

QVector<QetGraphicsHandlerItem *> QetShapeItem::m_handler_vector
private

◆ m_hovered

bool QetShapeItem::m_hovered
private

◆ m_insert_point

QAction* QetShapeItem::m_insert_point
private

◆ m_modifie_radius_equaly

bool QetShapeItem::m_modifie_radius_equaly = false
private

◆ m_old_P1

QPointF QetShapeItem::m_old_P1
private

◆ m_old_P2

QPointF QetShapeItem::m_old_P2
private

◆ m_old_polygon

QPolygonF QetShapeItem::m_old_polygon
private

◆ m_old_xRadius

qreal QetShapeItem::m_old_xRadius
private

◆ m_old_yRadius

qreal QetShapeItem::m_old_yRadius
private

◆ m_P1

QPointF QetShapeItem::m_P1
private

◆ m_P2

QPointF QetShapeItem::m_P2
private

◆ m_pen

QPen QetShapeItem::m_pen
private

◆ m_polygon

QPolygonF QetShapeItem::m_polygon
private

◆ m_remove_point

QAction * QetShapeItem::m_remove_point
private

◆ m_resize_mode

int QetShapeItem::m_resize_mode = 1
private

◆ m_shapeType

ShapeType QetShapeItem::m_shapeType
private

ATTRIBUTES.

◆ m_vector_index

int QetShapeItem::m_vector_index
private

◆ m_xRadius

qreal QetShapeItem::m_xRadius = 0
private

◆ m_yRadius

qreal QetShapeItem::m_yRadius = 0
private

Property Documentation

◆ brush

QBrush QetShapeItem::brush
readwrite

◆ close

bool QetShapeItem::close
readwrite

◆ line

QLineF QetShapeItem::line
readwrite

◆ pen

QPen QetShapeItem::pen
readwrite

◆ polygon

QPolygonF QetShapeItem::polygon
readwrite

◆ rect

QRectF QetShapeItem::rect
readwrite

◆ xRadius

qreal QetShapeItem::xRadius
readwrite

◆ yRadius

qreal QetShapeItem::yRadius
readwrite

The documentation for this class was generated from the following files: