Engauge Digitizer 2
Loading...
Searching...
No Matches
SegmentLine.cpp
Go to the documentation of this file.
1/******************************************************************************************************
2 * (C) 2014 markummitchell@github.com. This file is part of Engauge Digitizer, which is released *
3 * under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file *
4 * LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. *
5 ******************************************************************************************************/
6
7#include "DataKey.h"
8#include "EnumsToQt.h"
9#include "GraphicsItemType.h"
10#include "Logger.h"
11#include <QGraphicsScene>
12#include <QPen>
13#include "Segment.h"
14#include "SegmentLine.h"
15#include "ZValues.h"
16
17SegmentLine::SegmentLine(QGraphicsScene &scene,
18 const DocumentModelSegments &modelSegments,
19 Segment *segment) :
20 m_modelSegments (modelSegments),
21 m_segment (segment)
22{
23 LOG4CPP_DEBUG_S ((*mainCat)) << "SegmentLine::SegmentLine"
24 << " address=0x" << std::hex << static_cast<void *> (this);
25
27
28 // Make this transparent now, but always visible so hover events work
29 scene.addItem (this);
30 setPen (QPen (Qt::transparent));
32 setVisible (true);
34 setHover (false); // Initially the cursor is not hovering over this object. Later a hover event will change this state
35 setFlags (QGraphicsItem::ItemIsFocusable);
36
37 connect (this, SIGNAL (signalHover (bool)), segment, SLOT (slotHover (bool)));
38}
39
41{
42 LOG4CPP_DEBUG_S ((*mainCat)) << "SegmentLine::~SegmentLine"
43 << " address=0x" << std::hex << static_cast<void *> (this);
44}
45
47{
48 LOG4CPP_INFO_S ((*mainCat)) << "SegmentLine::hoverEnterEvent";
49
50 emit (signalHover (true));
51}
52
54{
55 LOG4CPP_INFO_S ((*mainCat)) << "SegmentLine::hoverLeaveEvent";
56
57 emit (signalHover (false));
58}
59
61{
62 LOG4CPP_INFO_S ((*mainCat)) << "SegmentLine::mousePressEvent";
63
64 m_segment->forwardMousePress();
65}
66
68{
69 return m_segment;
70}
71
73{
74 if (hover) {
75
76 QColor color (ColorPaletteToQColor (m_modelSegments.lineColor()));
77
78 setPen (QPen (QBrush (color),
79 m_modelSegments.lineWidth()));
80
81 } else {
82
83 setPen (QPen (Qt::transparent));
84
85 }
86}
87
89{
90 LOG4CPP_INFO_S ((*mainCat)) << "SegmentLine::updateModelSegment";
91
92 m_modelSegments = modelSegments;
93}
@ DATA_KEY_GRAPHICS_ITEM_TYPE
‍Unique identifier for QGraphicsItem object
Definition DataKey.h:15
const int INNER_RADIUS_MIN
QColor ColorPaletteToQColor(ColorPalette color)
Definition EnumsToQt.cpp:15
@ GRAPHICS_ITEM_TYPE_SEGMENT
log4cpp::Category * mainCat
Definition Logger.cpp:14
const int Z_VALUE_CURVE
Definition ZValues.cpp:10
Model for DlgSettingsSegments and CmdSettingsSegments.
ColorPalette lineColor() const
Get method for line color.
double lineWidth() const
Get method for line width.
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event)
Create points along this curve.
void signalHover(bool)
Pass hover enter/leave events to Segment that owns this.
SegmentLine(QGraphicsScene &scene, const DocumentModelSegments &modelSegments, Segment *segment)
Single constructor.
void setHover(bool hover)
Apply/remove highlighting triggered by hover enter/leave.
Segment * segment() const
Segment that owns this line.
void updateModelSegment(const DocumentModelSegments &modelSegments)
Update this segment line with new settings.
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.
Selectable piecewise-defined line that follows a filtered line in the image.
Definition Segment.h:22
void forwardMousePress()
Forward mouse press event from a component SegmentLine that was just clicked on.
Definition Segment.cpp:298
#define LOG4CPP_INFO_S(logger)
Definition convenience.h:18
#define LOG4CPP_DEBUG_S(logger)
Definition convenience.h:20