#include <vgrainlineitem.h>
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 |
Definition at line 36 of file vgrainlineitem.h.
anonymous enum |
Enumerator | |
---|---|
Type |
Definition at line 49 of file vgrainlineitem.h.
|
explicit |
VGrainlineItem::VGrainlineItem constructor.
painterarent | pointer to the parent item |
Definition at line 59 of file vgrainlineitem.cpp.
References atBoth, VPieceItem::m_inactiveZ, VPieceItem::Reset(), and UpdateRectangle().
|
virtual |
|
private |
Definition at line 706 of file vgrainlineitem.cpp.
References cursorArrowCloseHand, VPieceItem::m_eMode, VPieceItem::mRotate, SetItemOverrideCursor(), and userMoveAndResize().
Referenced by mousePressEvent().
|
private |
Definition at line 644 of file vgrainlineitem.cpp.
References ARROW_ANGLE, m_dRotation, and MainLine().
Referenced by MainShape(), and paint().
|
protectedvirtual |
GetAngle calculates the angle between the line, which goes from rotation center to pt and x axis.
pt | point of interest |
Reimplemented from VPieceItem.
Definition at line 569 of file vgrainlineitem.cpp.
References VPieceItem::GetAngle().
Referenced by mouseMoveEvent(), and mousePressEvent().
|
protected |
VGrainlineItem::GetInsideCorner calculates a point inside the bounding polygon, dDist away of i-th point in each direction.
i | index of corner |
dDist | distance |
Definition at line 601 of file vgrainlineitem.cpp.
References m_polyBound.
|
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().
|
protectedvirtual |
Definition at line 516 of file vgrainlineitem.cpp.
References m_penWidth.
|
protectedvirtual |
Definition at line 523 of file vgrainlineitem.cpp.
References m_penWidth.
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.
pt | starting point of the grainline. |
dRot | rotation of the grainline in [rad] |
dX | horizontal translation needed to put the arrow inside parent item |
dY | vertical translation needed to put the arrow inside parent item |
Definition at line 220 of file vgrainlineitem.cpp.
References m_dLength.
Referenced by mouseMoveEvent(), and UpdateGeometry().
|
signal |
Referenced by mouseReleaseEvent(), and PatternPieceTool::PatternPieceTool().
|
signal |
Referenced by mouseReleaseEvent(), and PatternPieceTool::PatternPieceTool().
|
private |
Definition at line 636 of file vgrainlineitem.cpp.
References m_dLength, and m_dRotation.
Referenced by FirstArrow(), MainShape(), paint(), and SecondArrow().
|
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().
|
protectedvirtual |
VGrainlineItem::mouseMoveEvent handles mouse move events, making sure that the item is moved properly.
pME | pointer to QGraphicsSceneMouseEvent object |
Definition at line 364 of file vgrainlineitem.cpp.
References GetAngle(), isContained(), VPieceItem::IsMovable, VPieceItem::IsResizable, VPieceItem::IsRotatable, m_dAngle, m_dLength, m_dRotation, m_dStartLength, m_dStartRotation, VPieceItem::m_eMode, VPieceItem::m_moveType, m_ptCenter, VPieceItem::m_ptRotCenter, m_ptStartMove, m_ptStartPos, VPieceItem::mMove, VPieceItem::mResize, VPieceItem::mRotate, Rotate(), Update(), and UpdateRectangle().
|
protectedvirtual |
VGrainlineItem::mousePressEvent handles left button mouse press events.
pME | pointer to QGraphicsSceneMouseEvent object |
Definition at line 277 of file vgrainlineitem.cpp.
References ACTIVE_Z, VPieceItem::AllModifications, allUserModifications(), cursorArrowCloseHand, GetAngle(), VPieceItem::IsMovable, VPieceItem::IsResizable, VPieceItem::IsRotatable, m_dAngle, m_dLength, m_dRotation, m_dStartLength, m_dStartRotation, VPieceItem::m_eMode, VPieceItem::m_moveType, m_ptCenter, VPieceItem::m_ptRotCenter, m_ptStartMove, m_ptStartPos, VPieceItem::mMove, VPieceItem::mRotate, VPieceItem::NotMovable, SetItemOverrideCursor(), Update(), userMoveAndResize(), and userRotateAndMove().
|
protectedvirtual |
VGrainlineItem::mouseReleaseEvent handles mouse release events and emits the proper signal if the item was moved.
pME | pointer to QGraphicsSceneMouseEvent object |
Definition at line 463 of file vgrainlineitem.cpp.
References cursorArrowOpenHand, VPieceItem::IsMovable, VPieceItem::IsResizable, VPieceItem::IsRotatable, VPieceItem::itemMoved(), itemResized(), itemRotated(), VPieceItem::m_bReleased, m_dLength, m_dRotation, VPieceItem::m_eMode, VPieceItem::m_moveType, m_ptStart, m_ptStartMove, VPieceItem::mMove, VPieceItem::mResize, VPieceItem::mRotate, SetItemOverrideCursor(), and Update().
|
virtual |
VGrainlineItem::paint paints the item content.
painter | pointer to the painter object |
option | not used |
widget | not used |
Definition at line 105 of file vgrainlineitem.cpp.
References ARROW_LENGTH, atFront, atRear, FirstArrow(), GetScale(), m_dLength, m_dRotation, m_dScale, m_eArrowType, VPieceItem::m_eMode, m_penWidth, m_polyBound, m_polyResize, MainLine(), Mm, VPieceItem::mNormal, VPieceItem::mResize, VPieceItem::mRotate, qApp, RECT_WIDTH, ROTATE_CIRC_R, SecondArrow(), ToPixel(), and UpdatePolyResize().
|
protected |
VGrainlineItem::Rotate rotates point pt around ptCenter by angle dAng [rad] and returns the resulting point.
pt | point to rotate |
ptCenter | center of rotation |
dAng | angle of rotation |
Definition at line 583 of file vgrainlineitem.cpp.
Referenced by mouseMoveEvent().
|
private |
Definition at line 657 of file vgrainlineitem.cpp.
References ARROW_ANGLE, m_dRotation, and MainLine().
Referenced by MainShape(), and paint().
|
virtual |
Definition at line 84 of file vgrainlineitem.cpp.
References VPieceItem::m_eMode, m_polyBound, MainShape(), and VPieceItem::mNormal.
|
inlinevirtual |
|
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().
void VGrainlineItem::UpdateGeometry | ( | const QPointF & | ptPos, |
qreal | dRotation, | ||
qreal | dLength, | ||
ArrowType | eAT | ||
) |
VGrainlineItem::UpdateGeometry updates the item with grainline parameters.
ptPos | position of one grainline's end |
dRotation | rotation of the grainline in [degrees] |
dLength | length 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().
|
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().
|
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().
|
private |
Definition at line 729 of file vgrainlineitem.cpp.
References cursorArrowCloseHand, VPieceItem::m_eMode, m_polyResize, VPieceItem::mMove, VPieceItem::mResize, and SetItemOverrideCursor().
Referenced by allUserModifications(), and mousePressEvent().
|
private |
Definition at line 719 of file vgrainlineitem.cpp.
References cursorArrowCloseHand, VPieceItem::m_eMode, VPieceItem::mMove, VPieceItem::mRotate, and SetItemOverrideCursor().
Referenced by mousePressEvent().
|
private |
Definition at line 85 of file vgrainlineitem.h.
Referenced by mouseMoveEvent(), and mousePressEvent().
|
private |
Definition at line 75 of file vgrainlineitem.h.
Referenced by isContained(), MainLine(), mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), paint(), UpdateGeometry(), and UpdateRectangle().
|
private |
Definition at line 73 of file vgrainlineitem.h.
Referenced by FirstArrow(), MainLine(), mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), paint(), SecondArrow(), UpdateGeometry(), UpdatePolyResize(), and UpdateRectangle().
|
private |
Definition at line 79 of file vgrainlineitem.h.
Referenced by paint(), and UpdatePolyResize().
|
private |
Definition at line 81 of file vgrainlineitem.h.
Referenced by mouseMoveEvent(), and mousePressEvent().
|
private |
Definition at line 74 of file vgrainlineitem.h.
Referenced by mouseMoveEvent(), and mousePressEvent().
|
private |
Definition at line 86 of file vgrainlineitem.h.
Referenced by MainShape(), paint(), and UpdateGeometry().
|
private |
Definition at line 87 of file vgrainlineitem.h.
Referenced by hoverEnterEvent(), hoverLeaveEvent(), MainShape(), and paint().
|
private |
Definition at line 76 of file vgrainlineitem.h.
Referenced by GetInsideCorner(), paint(), shape(), UpdatePolyResize(), and UpdateRectangle().
|
private |
Definition at line 80 of file vgrainlineitem.h.
Referenced by paint(), UpdatePolyResize(), and userMoveAndResize().
|
private |
Definition at line 84 of file vgrainlineitem.h.
Referenced by mouseMoveEvent(), mousePressEvent(), and UpdateRectangle().
|
private |
Definition at line 83 of file vgrainlineitem.h.
Referenced by UpdateRectangle().
|
private |
Definition at line 82 of file vgrainlineitem.h.
Referenced by mouseReleaseEvent(), and UpdateRectangle().
|
private |
Definition at line 78 of file vgrainlineitem.h.
Referenced by mouseMoveEvent(), mousePressEvent(), and mouseReleaseEvent().
|
private |
Definition at line 77 of file vgrainlineitem.h.
Referenced by mouseMoveEvent(), and mousePressEvent().