Engauge Digitizer 2
Loading...
Searching...
No Matches
SegmentLine Class Reference

This class is a special case of the standard QGraphicsLineItem for segments. More...

#include <SegmentLine.h>

Inheritance diagram for SegmentLine:
Inheritance graph
Collaboration diagram for SegmentLine:
Collaboration graph

Signals

void signalHover (bool)
 Pass hover enter/leave events to Segment that owns this.

Public Member Functions

 SegmentLine (QGraphicsScene &scene, const DocumentModelSegments &modelSegments, Segment *segment)
 Single constructor.
 ~SegmentLine ()
virtual void hoverEnterEvent (QGraphicsSceneHoverEvent *event)
 Highlight this and all other SegmentLines belonging to the same Segment upon hover enter.
virtual void hoverLeaveEvent (QGraphicsSceneHoverEvent *event)
 Unset highlighting triggered by hover enter.
virtual void mousePressEvent (QGraphicsSceneMouseEvent *event)
 Create points along this curve.
Segmentsegment () const
 Segment that owns this line.
void setHover (bool hover)
 Apply/remove highlighting triggered by hover enter/leave.
void updateModelSegment (const DocumentModelSegments &modelSegments)
 Update this segment line with new settings.

Detailed Description

This class is a special case of the standard QGraphicsLineItem for segments.

Definition at line 17 of file SegmentLine.h.

Constructor & Destructor Documentation

◆ SegmentLine()

SegmentLine::SegmentLine ( QGraphicsScene & scene,
const DocumentModelSegments & modelSegments,
Segment * segment )

Single constructor.

Definition at line 18 of file SegmentLine.cpp.

20 :
21 m_modelSegments (modelSegments),
22 m_segment (segment)
23{
24 LOG4CPP_DEBUG_S ((*mainCat)) << "SegmentLine::SegmentLine"
25 << " address=0x" << std::hex << static_cast<void *> (this);
26
28
29 // Make this transparent now, but always visible so hover events work
30 scene.addItem (this);
31 setPen (QPen (Qt::transparent));
32 setZValue (Z_VALUE_CURVE);
33 setVisible (true);
34 setAcceptHoverEvents (true);
35 setHover (false); // Initially the cursor is not hovering over this object. Later a hover event will change this state
36 setFlags (QGraphicsItem::ItemIsFocusable);
37
38 connect (this, SIGNAL (signalHover (bool)), segment, SLOT (slotHover (bool)));
39}
@ DATA_KEY_GRAPHICS_ITEM_TYPE
Definition DataKey.h:15
@ GRAPHICS_ITEM_TYPE_SEGMENT
log4cpp::Category * mainCat
Definition Logger.cpp:14
const int Z_VALUE_CURVE
Definition ZValues.cpp:10
void signalHover(bool)
Pass hover enter/leave events to Segment that owns this.
void setHover(bool hover)
Apply/remove highlighting triggered by hover enter/leave.
Segment * segment() const
Segment that owns this line.
#define LOG4CPP_DEBUG_S(logger)
Definition convenience.h:20

◆ ~SegmentLine()

SegmentLine::~SegmentLine ( )

Definition at line 41 of file SegmentLine.cpp.

42{
43 LOG4CPP_DEBUG_S ((*mainCat)) << "SegmentLine::~SegmentLine"
44 << " address=0x" << std::hex << static_cast<void *> (this);
45}

Member Function Documentation

◆ hoverEnterEvent()

void SegmentLine::hoverEnterEvent ( QGraphicsSceneHoverEvent * event)
virtual

Highlight this and all other SegmentLines belonging to the same Segment upon hover enter.

Definition at line 47 of file SegmentLine.cpp.

48{
49 LOG4CPP_INFO_S ((*mainCat)) << "SegmentLine::hoverEnterEvent";
50
51 emit (signalHover (true));
52}
#define LOG4CPP_INFO_S(logger)
Definition convenience.h:18

◆ hoverLeaveEvent()

void SegmentLine::hoverLeaveEvent ( QGraphicsSceneHoverEvent * event)
virtual

Unset highlighting triggered by hover enter.

Definition at line 54 of file SegmentLine.cpp.

55{
56 LOG4CPP_INFO_S ((*mainCat)) << "SegmentLine::hoverLeaveEvent";
57
58 emit (signalHover (false));
59}

◆ mousePressEvent()

void SegmentLine::mousePressEvent ( QGraphicsSceneMouseEvent * event)
virtual

Create points along this curve.

Definition at line 61 of file SegmentLine.cpp.

62{
63 LOG4CPP_INFO_S ((*mainCat)) << "SegmentLine::mousePressEvent";
64
65 m_segment->forwardMousePress();
66}

◆ segment()

Segment * SegmentLine::segment ( ) const

Segment that owns this line.

Definition at line 68 of file SegmentLine.cpp.

69{
70 return m_segment;
71}

◆ setHover()

void SegmentLine::setHover ( bool hover)

Apply/remove highlighting triggered by hover enter/leave.

Definition at line 73 of file SegmentLine.cpp.

74{
75 QColor colorOpaque (ColorPaletteToQColor (m_modelSegments.lineColor()));
76
77 if (hover) {
78
79 setPen (QPen (QBrush (colorOpaque),
80 m_modelSegments.lineWidthActive()));
81
82 } else {
83
84 QColor colorSoft (colorOpaque.red (),
85 colorOpaque.green (),
86 colorOpaque.blue (),
87 inactiveOpacityEnumToAlpha (m_modelSegments.inactiveOpacity()));
88
89 setPen (QPen (QBrush (colorSoft),
90 m_modelSegments.lineWidthInactive()));
91
92 }
93}
QColor ColorPaletteToQColor(ColorPalette color)
Definition EnumsToQt.cpp:16
int inactiveOpacityEnumToAlpha(InactiveOpacity inactiveOpacity)
Map InactiveOpacity enum to corresponding alpha value.

◆ signalHover

void SegmentLine::signalHover ( bool )
signal

Pass hover enter/leave events to Segment that owns this.

◆ updateModelSegment()

void SegmentLine::updateModelSegment ( const DocumentModelSegments & modelSegments)

Update this segment line with new settings.

Definition at line 95 of file SegmentLine.cpp.

96{
97 LOG4CPP_INFO_S ((*mainCat)) << "SegmentLine::updateModelSegment";
98
99 m_modelSegments = modelSegments;
100}

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