Seamly2D
Code documentation
VGrainlineItem Class Reference

#include <vgrainlineitem.h>

Inheritance diagram for VGrainlineItem:
Collaboration diagram for VGrainlineItem:

Public Types

enum  { Type = UserType + static_cast<int>(Vis::GrainlineItem) }
 
- Public Types inherited from VPieceItem
enum  MoveType {
  NotMovable = 0x0 , IsRotatable = 0x1 , IsResizable = 0x2 , IsMovable = 0x4 ,
  AllModifications = IsRotatable | IsResizable | IsMovable , Error = 0x8
}
 
enum  { Type = UserType + static_cast<int>(Vis::PieceItem) }
 

Signals

void itemResized (qreal dLength)
 
void itemRotated (qreal dRot, const QPointF &ptNewPos)
 
- Signals inherited from VPieceItem
void itemMoved (const QPointF &ptPos)
 

Public Member Functions

 VGrainlineItem (QGraphicsItem *pParent=nullptr)
 VGrainlineItem::VGrainlineItem constructor. More...
 
virtual ~VGrainlineItem () Q_DECL_EQ_DEFAULT
 
virtual QPainterPath shape () const Q_DECL_OVERRIDE
 
virtual void paint (QPainter *pP, const QStyleOptionGraphicsItem *pOption, QWidget *pWidget) Q_DECL_OVERRIDE
 VGrainlineItem::paint paints the item content. More...
 
void UpdateGeometry (const QPointF &ptPos, qreal dRotation, qreal dLength, ArrowType eAT)
 VGrainlineItem::UpdateGeometry updates the item with grainline parameters. More...
 
virtual int type () const Q_DECL_OVERRIDE
 
bool isContained (const QPointF &pt, qreal dRot, qreal &dX, qreal &dY) const
 VGrainlineItem::isContained checks, if both ends of the grainline, starting at pt, are contained in parent widget. More...
 
- Public Member Functions inherited from VPieceItem
 VPieceItem (QGraphicsItem *pParent=nullptr)
 
virtual ~VPieceItem ()
 
virtual QRectF boundingRect () const Q_DECL_OVERRIDE
 boundingRect returns the item bounding box More...
 
void Reset ()
 Reset resets the item, putting the mode and z coordinate to normal and redraws it. More...
 
bool IsIdle () const
 IsIdle returns the idle flag. More...
 
VPieceItem::MoveTypes GetMoveType () const
 
void SetMoveType (const VPieceItem::MoveTypes &moveType)
 

Protected Member Functions

virtual void mousePressEvent (QGraphicsSceneMouseEvent *pME) Q_DECL_OVERRIDE
 VGrainlineItem::mousePressEvent handles left button mouse press events. More...
 
virtual void mouseMoveEvent (QGraphicsSceneMouseEvent *pME) Q_DECL_OVERRIDE
 VGrainlineItem::mouseMoveEvent handles mouse move events, making sure that the item is moved properly. More...
 
virtual void mouseReleaseEvent (QGraphicsSceneMouseEvent *pME) Q_DECL_OVERRIDE
 VGrainlineItem::mouseReleaseEvent handles mouse release events and emits the proper signal if the item was moved. More...
 
virtual void hoverEnterEvent (QGraphicsSceneHoverEvent *pME) Q_DECL_OVERRIDE
 
virtual void hoverLeaveEvent (QGraphicsSceneHoverEvent *pME) Q_DECL_OVERRIDE
 
virtual void Update () Q_DECL_OVERRIDE
 VGrainlineItem::Update updates the item. More...
 
void UpdateRectangle ()
 VGrainlineItem::UpdateRectangle updates the polygon for the box around active item and the bounding rectangle. More...
 
virtual double GetAngle (const QPointF &pt) const Q_DECL_OVERRIDE
 GetAngle calculates the angle between the line, which goes from rotation center to pt and x axis. More...
 
QPointF Rotate (const QPointF &pt, const QPointF &ptCenter, qreal dAng) const
 VGrainlineItem::Rotate rotates point pt around ptCenter by angle dAng [rad] and returns the resulting point. More...
 
QPointF GetInsideCorner (int i, qreal dDist) const
 VGrainlineItem::GetInsideCorner calculates a point inside the bounding polygon, dDist away of i-th point in each direction. More...
 

Private Member Functions

qreal GetScale () const
 GetScale gets the scale for keeping the arrows of constant size. More...
 
QLineF MainLine () const
 
QPolygonF FirstArrow (qreal dArrLen) const
 
QPolygonF SecondArrow (qreal dArrLen) const
 
QPainterPath MainShape () const
 
void allUserModifications (const QPointF &pos)
 
void userRotateAndMove ()
 
void userMoveAndResize (const QPointF &pos)
 
void UpdatePolyResize ()
 

Private Attributes

qreal m_dRotation
 
qreal m_dStartRotation
 
qreal m_dLength
 
QPolygonF m_polyBound
 
QPointF m_ptStartPos
 
QPointF m_ptStartMove
 
qreal m_dScale
 
QPolygonF m_polyResize
 
qreal m_dStartLength
 
QPointF m_ptStart
 
QPointF m_ptFinish
 
QPointF m_ptCenter
 
qreal m_dAngle
 
ArrowType m_eArrowType
 
qreal m_penWidth
 

Additional Inherited Members

- Protected Types inherited from VPieceItem
enum  Mode { mNormal , mMove , mResize , mRotate }
 
- Protected Attributes inherited from VPieceItem
QRectF m_rectBoundingBox
 
Mode m_eMode
 
bool m_bReleased
 
QPointF m_ptRotCenter
 
VPieceItem::MoveTypes m_moveType
 
qreal m_inactiveZ
 

Detailed Description

Definition at line 36 of file vgrainlineitem.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
Type 

Definition at line 49 of file vgrainlineitem.h.

Constructor & Destructor Documentation

◆ VGrainlineItem()

VGrainlineItem::VGrainlineItem ( QGraphicsItem *  painterarent = nullptr)
explicit

VGrainlineItem::VGrainlineItem constructor.

Parameters
painterarentpointer to the parent item

Definition at line 59 of file vgrainlineitem.cpp.

References atBoth, VPieceItem::m_inactiveZ, VPieceItem::Reset(), and UpdateRectangle().

◆ ~VGrainlineItem()

virtual VGrainlineItem::~VGrainlineItem ( )
virtual

Member Function Documentation

◆ allUserModifications()

void VGrainlineItem::allUserModifications ( const QPointF &  pos)
private

◆ FirstArrow()

QPolygonF VGrainlineItem::FirstArrow ( qreal  dArrLen) const
private

Definition at line 644 of file vgrainlineitem.cpp.

References ARROW_ANGLE, m_dRotation, and MainLine().

Referenced by MainShape(), and paint().

◆ GetAngle()

double VGrainlineItem::GetAngle ( const QPointF &  pt) const
protectedvirtual

GetAngle calculates the angle between the line, which goes from rotation center to pt and x axis.

Parameters
ptpoint of interest
Returns
the angle between line from rotation center and point of interest and x axis

Reimplemented from VPieceItem.

Definition at line 569 of file vgrainlineitem.cpp.

References VPieceItem::GetAngle().

Referenced by mouseMoveEvent(), and mousePressEvent().

◆ GetInsideCorner()

QPointF VGrainlineItem::GetInsideCorner ( int  i,
qreal  dDist 
) const
protected

VGrainlineItem::GetInsideCorner calculates a point inside the bounding polygon, dDist away of i-th point in each direction.

Parameters
iindex of corner
dDistdistance
Returns
resulting point

Definition at line 601 of file vgrainlineitem.cpp.

References m_polyBound.

◆ GetScale()

qreal VGrainlineItem::GetScale ( ) const
private

GetScale gets the scale for keeping the arrows of constant size.

Definition at line 616 of file vgrainlineitem.cpp.

Referenced by MainShape(), and paint().

◆ hoverEnterEvent()

void VGrainlineItem::hoverEnterEvent ( QGraphicsSceneHoverEvent *  pME)
protectedvirtual

Definition at line 516 of file vgrainlineitem.cpp.

References m_penWidth.

◆ hoverLeaveEvent()

void VGrainlineItem::hoverLeaveEvent ( QGraphicsSceneHoverEvent *  pME)
protectedvirtual

Definition at line 523 of file vgrainlineitem.cpp.

References m_penWidth.

◆ isContained()

bool VGrainlineItem::isContained ( const QPointF &  pt,
qreal  dRot,
qreal &  dX,
qreal &  dY 
) const

VGrainlineItem::isContained checks, if both ends of the grainline, starting at pt, are contained in parent widget.

Parameters
ptstarting point of the grainline.
dRotrotation of the grainline in [rad]
dXhorizontal translation needed to put the arrow inside parent item
dYvertical translation needed to put the arrow inside parent item
Returns
true, if both ends of the grainline, starting at pt, are contained in the parent widget and false otherwise.

Definition at line 220 of file vgrainlineitem.cpp.

References m_dLength.

Referenced by mouseMoveEvent(), and UpdateGeometry().

◆ itemResized

void VGrainlineItem::itemResized ( qreal  dLength)
signal

◆ itemRotated

void VGrainlineItem::itemRotated ( qreal  dRot,
const QPointF &  ptNewPos 
)
signal

◆ MainLine()

QLineF VGrainlineItem::MainLine ( ) const
private

Definition at line 636 of file vgrainlineitem.cpp.

References m_dLength, and m_dRotation.

Referenced by FirstArrow(), MainShape(), paint(), and SecondArrow().

◆ MainShape()

QPainterPath VGrainlineItem::MainShape ( ) const
private

Definition at line 670 of file vgrainlineitem.cpp.

References ARROW_LENGTH, atFront, atRear, FirstArrow(), GetScale(), m_eArrowType, m_penWidth, MainLine(), and SecondArrow().

Referenced by shape().

◆ mouseMoveEvent()

void VGrainlineItem::mouseMoveEvent ( QGraphicsSceneMouseEvent *  pME)
protectedvirtual

◆ mousePressEvent()

◆ mouseReleaseEvent()

void VGrainlineItem::mouseReleaseEvent ( QGraphicsSceneMouseEvent *  pME)
protectedvirtual

◆ paint()

void VGrainlineItem::paint ( QPainter *  painter,
const QStyleOptionGraphicsItem *  option,
QWidget *  widget 
)
virtual

◆ Rotate()

QPointF VGrainlineItem::Rotate ( const QPointF &  pt,
const QPointF &  ptCenter,
qreal  dAng 
) const
protected

VGrainlineItem::Rotate rotates point pt around ptCenter by angle dAng [rad] and returns the resulting point.

Parameters
ptpoint to rotate
ptCentercenter of rotation
dAngangle of rotation
Returns
point, which is a result of rotating pt around ptCenter by angle dAng

Definition at line 583 of file vgrainlineitem.cpp.

Referenced by mouseMoveEvent().

◆ SecondArrow()

QPolygonF VGrainlineItem::SecondArrow ( qreal  dArrLen) const
private

Definition at line 657 of file vgrainlineitem.cpp.

References ARROW_ANGLE, m_dRotation, and MainLine().

Referenced by MainShape(), and paint().

◆ shape()

QPainterPath VGrainlineItem::shape ( ) const
virtual

Definition at line 84 of file vgrainlineitem.cpp.

References VPieceItem::m_eMode, m_polyBound, MainShape(), and VPieceItem::mNormal.

◆ type()

virtual int VGrainlineItem::type ( ) const
inlinevirtual

Reimplemented from VPieceItem.

Definition at line 48 of file vgrainlineitem.h.

References Type.

◆ Update()

void VGrainlineItem::Update ( )
protectedvirtual

VGrainlineItem::Update updates the item.

Implements VPieceItem.

Definition at line 533 of file vgrainlineitem.cpp.

References VPieceItem::m_rectBoundingBox.

Referenced by mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), and UpdateGeometry().

◆ UpdateGeometry()

void VGrainlineItem::UpdateGeometry ( const QPointF &  ptPos,
qreal  dRotation,
qreal  dLength,
ArrowType  eAT 
)

VGrainlineItem::UpdateGeometry updates the item with grainline parameters.

Parameters
ptPosposition of one grainline's end
dRotationrotation of the grainline in [degrees]
dLengthlength of the grainline in user's units

Definition at line 189 of file vgrainlineitem.cpp.

References isContained(), m_dLength, m_dRotation, m_eArrowType, Update(), and UpdateRectangle().

Referenced by PatternPieceTool::UpdateGrainline().

◆ UpdatePolyResize()

void VGrainlineItem::UpdatePolyResize ( )
private

Definition at line 744 of file vgrainlineitem.cpp.

References m_dRotation, m_dScale, m_polyBound, m_polyResize, and RESIZE_RECT_SIZE.

Referenced by paint(), and UpdateRectangle().

◆ UpdateRectangle()

void VGrainlineItem::UpdateRectangle ( )
protected

VGrainlineItem::UpdateRectangle updates the polygon for the box around active item and the bounding rectangle.

Definition at line 543 of file vgrainlineitem.cpp.

References m_dLength, m_dRotation, m_polyBound, m_ptCenter, m_ptFinish, m_ptStart, VPieceItem::m_rectBoundingBox, RECT_WIDTH, and UpdatePolyResize().

Referenced by mouseMoveEvent(), UpdateGeometry(), and VGrainlineItem().

◆ userMoveAndResize()

void VGrainlineItem::userMoveAndResize ( const QPointF &  pos)
private

◆ userRotateAndMove()

void VGrainlineItem::userRotateAndMove ( )
private

Member Data Documentation

◆ m_dAngle

qreal VGrainlineItem::m_dAngle
private

Definition at line 85 of file vgrainlineitem.h.

Referenced by mouseMoveEvent(), and mousePressEvent().

◆ m_dLength

qreal VGrainlineItem::m_dLength
private

◆ m_dRotation

qreal VGrainlineItem::m_dRotation
private

◆ m_dScale

qreal VGrainlineItem::m_dScale
private

Definition at line 79 of file vgrainlineitem.h.

Referenced by paint(), and UpdatePolyResize().

◆ m_dStartLength

qreal VGrainlineItem::m_dStartLength
private

Definition at line 81 of file vgrainlineitem.h.

Referenced by mouseMoveEvent(), and mousePressEvent().

◆ m_dStartRotation

qreal VGrainlineItem::m_dStartRotation
private

Definition at line 74 of file vgrainlineitem.h.

Referenced by mouseMoveEvent(), and mousePressEvent().

◆ m_eArrowType

ArrowType VGrainlineItem::m_eArrowType
private

Definition at line 86 of file vgrainlineitem.h.

Referenced by MainShape(), paint(), and UpdateGeometry().

◆ m_penWidth

qreal VGrainlineItem::m_penWidth
private

Definition at line 87 of file vgrainlineitem.h.

Referenced by hoverEnterEvent(), hoverLeaveEvent(), MainShape(), and paint().

◆ m_polyBound

QPolygonF VGrainlineItem::m_polyBound
private

Definition at line 76 of file vgrainlineitem.h.

Referenced by GetInsideCorner(), paint(), shape(), UpdatePolyResize(), and UpdateRectangle().

◆ m_polyResize

QPolygonF VGrainlineItem::m_polyResize
private

Definition at line 80 of file vgrainlineitem.h.

Referenced by paint(), UpdatePolyResize(), and userMoveAndResize().

◆ m_ptCenter

QPointF VGrainlineItem::m_ptCenter
private

Definition at line 84 of file vgrainlineitem.h.

Referenced by mouseMoveEvent(), mousePressEvent(), and UpdateRectangle().

◆ m_ptFinish

QPointF VGrainlineItem::m_ptFinish
private

Definition at line 83 of file vgrainlineitem.h.

Referenced by UpdateRectangle().

◆ m_ptStart

QPointF VGrainlineItem::m_ptStart
private

Definition at line 82 of file vgrainlineitem.h.

Referenced by mouseReleaseEvent(), and UpdateRectangle().

◆ m_ptStartMove

QPointF VGrainlineItem::m_ptStartMove
private

Definition at line 78 of file vgrainlineitem.h.

Referenced by mouseMoveEvent(), mousePressEvent(), and mouseReleaseEvent().

◆ m_ptStartPos

QPointF VGrainlineItem::m_ptStartPos
private

Definition at line 77 of file vgrainlineitem.h.

Referenced by mouseMoveEvent(), and mousePressEvent().


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