Seamly2D
Code documentation
VGraphicsSimpleTextItem Class Reference

The VGraphicsSimpleTextItem class pointer label. More...

#include <vgraphicssimpletextitem.h>

Inheritance diagram for VGraphicsSimpleTextItem:
Collaboration diagram for VGraphicsSimpleTextItem:

Public Types

enum  { Type = UserType + static_cast<int>(Vis::GraphicsSimpleTextItem) }
 

Signals

void nameChangedPosition (const QPointF &pos)
 nameChangedPosition emit when label change position. More...
 
void showContextMenu (QGraphicsSceneContextMenuEvent *event)
 showContextMenu emit when need show tool context menu. More...
 
void deleteTool ()
 
void pointChosen ()
 
void pointSelected (bool selected)
 

Public Member Functions

 VGraphicsSimpleTextItem (QColor color, QGraphicsItem *parent=nullptr)
 VGraphicsSimpleTextItem default constructor. More...
 
 VGraphicsSimpleTextItem (const QString &text, QColor textColor, QGraphicsItem *parent=nullptr)
 VGraphicsSimpleTextItem constructor. More...
 
virtual ~VGraphicsSimpleTextItem ()=default
 
qint32 BaseFontSize () const
 FontSize return label font size. More...
 
virtual int type () const Q_DECL_OVERRIDE
 
virtual void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=nullptr) Q_DECL_OVERRIDE
 
void setEnabled (bool enabled)
 
void textSelectionType (const SelectionType &type)
 
void setShowParentTooltip (bool show)
 
QColor getTextBrushColor ()
 
void setTextColor (const QColor &color)
 
void setPosition (QPointF pos)
 

Protected Member Functions

virtual QVariant itemChange (GraphicsItemChange change, const QVariant &value) Q_DECL_OVERRIDE
 itemChange handle item change. More...
 
virtual void hoverEnterEvent (QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE
 hoverEnterEvent handle hover enter events. More...
 
virtual void hoverLeaveEvent (QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE
 hoverLeaveEvent handle hover leave events. More...
 
virtual void contextMenuEvent (QGraphicsSceneContextMenuEvent *event) Q_DECL_OVERRIDE
 contextMenuEvent handle context menu events. More...
 
virtual void mousePressEvent (QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE
 
virtual void mouseReleaseEvent (QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE
 
virtual void keyReleaseEvent (QKeyEvent *event) Q_DECL_OVERRIDE
 

Private Member Functions

void initItem ()
 
void scalePointName (const qreal &scale)
 scalePointName handle point name scaling to maintain same size when scene scale changes. More...
 
void scalePosition ()
 scalePosition handle point name position scaling to maintain same distance when scene scale changes. More...
 
void updateLeader ()
 

Private Attributes

qint32 m_fontSize
 fontSize label font size. More...
 
qreal m_scale
 
QColor m_textColor
 
bool m_isNameHovered
 
SelectionType selectionType
 
bool m_showParentTooltip
 
QPointF m_pointNamePos {}
 

Detailed Description

The VGraphicsSimpleTextItem class pointer label.

Definition at line 71 of file vgraphicssimpletextitem.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
Type 

Definition at line 81 of file vgraphicssimpletextitem.h.

Constructor & Destructor Documentation

◆ VGraphicsSimpleTextItem() [1/2]

VGraphicsSimpleTextItem::VGraphicsSimpleTextItem ( QColor  textColor,
QGraphicsItem *  parent = nullptr 
)
explicit

VGraphicsSimpleTextItem default constructor.

Parameters
parentparent object.

Definition at line 81 of file vgraphicssimpletextitem.cpp.

References ByMouseRelease, and initItem().

◆ VGraphicsSimpleTextItem() [2/2]

VGraphicsSimpleTextItem::VGraphicsSimpleTextItem ( const QString &  text,
QColor  textColor,
QGraphicsItem *  parent = nullptr 
)
explicit

VGraphicsSimpleTextItem constructor.

Parameters
texttext.
parentparent object.

Definition at line 99 of file vgraphicssimpletextitem.cpp.

References ByMouseRelease, and initItem().

◆ ~VGraphicsSimpleTextItem()

virtual VGraphicsSimpleTextItem::~VGraphicsSimpleTextItem ( )
virtualdefault

Member Function Documentation

◆ BaseFontSize()

qint32 VGraphicsSimpleTextItem::BaseFontSize ( ) const
inline

FontSize return label font size.

Returns
font size.

Definition at line 140 of file vgraphicssimpletextitem.h.

References m_fontSize.

◆ contextMenuEvent()

void VGraphicsSimpleTextItem::contextMenuEvent ( QGraphicsSceneContextMenuEvent *  event)
protectedvirtual

contextMenuEvent handle context menu events.

Parameters
eventcontext menu event.

Definition at line 291 of file vgraphicssimpletextitem.cpp.

References showContextMenu().

◆ deleteTool

void VGraphicsSimpleTextItem::deleteTool ( )
signal

◆ getTextBrushColor()

QColor VGraphicsSimpleTextItem::getTextBrushColor ( )

Definition at line 362 of file vgraphicssimpletextitem.cpp.

References correctColor(), m_textColor, and qApp.

Referenced by initItem(), paint(), setEnabled(), and setTextColor().

◆ hoverEnterEvent()

void VGraphicsSimpleTextItem::hoverEnterEvent ( QGraphicsSceneHoverEvent *  event)
protectedvirtual

hoverEnterEvent handle hover enter events.

Parameters
eventhover enter event.

Definition at line 249 of file vgraphicssimpletextitem.cpp.

References cursorArrowOpenHand, m_isNameHovered, m_showParentTooltip, qApp, and SetItemOverrideCursor().

◆ hoverLeaveEvent()

void VGraphicsSimpleTextItem::hoverLeaveEvent ( QGraphicsSceneHoverEvent *  event)
protectedvirtual

hoverLeaveEvent handle hover leave events.

Parameters
eventhover leave event.

Definition at line 275 of file vgraphicssimpletextitem.cpp.

References m_isNameHovered.

◆ initItem()

void VGraphicsSimpleTextItem::initItem ( )
private

Definition at line 392 of file vgraphicssimpletextitem.cpp.

References getTextBrushColor(), m_fontSize, m_scale, and qApp.

Referenced by VGraphicsSimpleTextItem().

◆ itemChange()

QVariant VGraphicsSimpleTextItem::itemChange ( GraphicsItemChange  change,
const QVariant &  value 
)
protectedvirtual

itemChange handle item change.

Parameters
changechange.
valuevalue.
Returns
value.

Definition at line 178 of file vgraphicssimpletextitem.cpp.

References VMainGraphicsScene::getScenePos(), m_pointNamePos, nameChangedPosition(), pointSelected(), SCASSERT, sceneScale(), and VMainGraphicsView::SceneVisibleArea().

◆ keyReleaseEvent()

void VGraphicsSimpleTextItem::keyReleaseEvent ( QKeyEvent *  event)
protectedvirtual

Definition at line 349 of file vgraphicssimpletextitem.cpp.

References deleteTool().

◆ mousePressEvent()

void VGraphicsSimpleTextItem::mousePressEvent ( QGraphicsSceneMouseEvent *  event)
protectedvirtual

◆ mouseReleaseEvent()

void VGraphicsSimpleTextItem::mouseReleaseEvent ( QGraphicsSceneMouseEvent *  event)
protectedvirtual

◆ nameChangedPosition

void VGraphicsSimpleTextItem::nameChangedPosition ( const QPointF &  pos)
signal

nameChangedPosition emit when label change position.

Parameters
posnew posotion.

Referenced by itemChange(), VNodePoint::VNodePoint(), VSimplePoint::VSimplePoint(), and VToolSinglePoint::VToolSinglePoint().

◆ paint()

void VGraphicsSimpleTextItem::paint ( QPainter *  painter,
const QStyleOptionGraphicsItem *  option,
QWidget *  widget = nullptr 
)
virtual

◆ pointChosen

◆ pointSelected

void VGraphicsSimpleTextItem::pointSelected ( bool  selected)
signal

◆ scalePointName()

void VGraphicsSimpleTextItem::scalePointName ( const qreal &  scale)
private

scalePointName handle point name scaling to maintain same size when scene scale changes.

Parameters
scaleparent scene scale.

Definition at line 415 of file vgraphicssimpletextitem.cpp.

References m_scale, scalePosition(), and updateLeader().

Referenced by paint().

◆ scalePosition()

void VGraphicsSimpleTextItem::scalePosition ( )
private

scalePosition handle point name position scaling to maintain same distance when scene scale changes.

Definition at line 427 of file vgraphicssimpletextitem.cpp.

References m_pointNamePos, and sceneScale().

Referenced by scalePointName(), and setPosition().

◆ setEnabled()

void VGraphicsSimpleTextItem::setEnabled ( bool  enabled)

◆ setPosition()

void VGraphicsSimpleTextItem::setPosition ( QPointF  pos)

◆ setShowParentTooltip()

void VGraphicsSimpleTextItem::setShowParentTooltip ( bool  show)

Definition at line 166 of file vgraphicssimpletextitem.cpp.

References m_showParentTooltip.

Referenced by VNodePoint::VNodePoint().

◆ setTextColor()

void VGraphicsSimpleTextItem::setTextColor ( const QColor &  color)

Definition at line 378 of file vgraphicssimpletextitem.cpp.

References getTextBrushColor(), and m_textColor.

Referenced by VScenePoint::refreshPointGeometry().

◆ showContextMenu

void VGraphicsSimpleTextItem::showContextMenu ( QGraphicsSceneContextMenuEvent *  event)
signal

showContextMenu emit when need show tool context menu.

Parameters
eventcontext menu event.

Referenced by contextMenuEvent(), VNodePoint::VNodePoint(), VSimplePoint::VSimplePoint(), and VToolSinglePoint::VToolSinglePoint().

◆ textSelectionType()

void VGraphicsSimpleTextItem::textSelectionType ( const SelectionType type)

◆ type()

virtual int VGraphicsSimpleTextItem::type ( ) const
inlinevirtual

Definition at line 80 of file vgraphicssimpletextitem.h.

References Type.

Referenced by textSelectionType().

◆ updateLeader()

void VGraphicsSimpleTextItem::updateLeader ( )
private

Definition at line 447 of file vgraphicssimpletextitem.cpp.

Referenced by scalePointName().

Member Data Documentation

◆ m_fontSize

qint32 VGraphicsSimpleTextItem::m_fontSize
private

fontSize label font size.

Definition at line 121 of file vgraphicssimpletextitem.h.

Referenced by BaseFontSize(), and initItem().

◆ m_isNameHovered

bool VGraphicsSimpleTextItem::m_isNameHovered
private

Definition at line 124 of file vgraphicssimpletextitem.h.

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

◆ m_pointNamePos

QPointF VGraphicsSimpleTextItem::m_pointNamePos {}
private

Definition at line 127 of file vgraphicssimpletextitem.h.

Referenced by itemChange(), scalePosition(), and setPosition().

◆ m_scale

qreal VGraphicsSimpleTextItem::m_scale
private

Definition at line 122 of file vgraphicssimpletextitem.h.

Referenced by initItem(), paint(), and scalePointName().

◆ m_showParentTooltip

bool VGraphicsSimpleTextItem::m_showParentTooltip
private

Definition at line 126 of file vgraphicssimpletextitem.h.

Referenced by hoverEnterEvent(), and setShowParentTooltip().

◆ m_textColor

QColor VGraphicsSimpleTextItem::m_textColor
private

Definition at line 123 of file vgraphicssimpletextitem.h.

Referenced by getTextBrushColor(), and setTextColor().

◆ selectionType

SelectionType VGraphicsSimpleTextItem::selectionType
private

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