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

Line version of GuidelineAbstract. More...

#include <GuidelineLine.h>

Inheritance diagram for GuidelineLine:
Inheritance graph
Collaboration diagram for GuidelineLine:
Collaboration graph

Public Member Functions

 GuidelineLine (QGraphicsScene &scene, Guidelines &guidelines, GuidelineState guidelineStateInitial, const QString &identifier)
 Single constructor.
 ~GuidelineLine ()
virtual bool getGraphicsItemAcceptHover () const
 Return true if accepting hover events.
virtual bool getGraphicsItemSelected () const
 Wrapper for QGraphicsItem::isSelected.
virtual QGraphicsItem::GraphicsItemFlags graphicsItemFlags () const
 Wraps QGraphicsItem::flags.
void handleVisibilityChange (bool visible)
 User toggled guideline visibility.
virtual void hoverEnterEvent (QGraphicsSceneHoverEvent *event)
 Highlight this Guideline upon hover enter.
virtual void hoverLeaveEvent (QGraphicsSceneHoverEvent *event)
 Unset highlighting triggered by hover enter.
virtual QString identifier () const
 Unique identifier from QGraphicsItem.
virtual void mouseMoveEvent (QGraphicsSceneMouseEvent *event)
 Forward movements to visible Guideline.
virtual void mousePressEvent (QGraphicsSceneMouseEvent *event)
 Forward press event to state machine.
virtual void mouseReleaseEvent (QGraphicsSceneMouseEvent *event)
 Cleanup after being dragged.
virtual void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=Q_NULLPTR)
 Override painting so this disappears when selected. Selected Guidelines are never visible.
virtual void removeFromScene (QGraphicsScene *scene)
 Make graphics item remove itself from the scene.
virtual void setGraphicsItemAcceptHoverEvents (bool accept)
 Wrapper for QGraphicsItem::setAcceptHoverEvents.
virtual void setGraphicsItemFlags (QGraphicsItem::GraphicsItemFlags flags)
 Wrapper for QGraphicsItem::setFlags.
virtual void setGraphicsItemLine (const QLineF &line)
 Wrapper for QGraphicsLineItem::setLine.
virtual void setGraphicsItemPen (const QColor &color, double lineWidth)
 Wrapper for QGraphicsItem::setPen.
virtual void setGraphicsItemVisible (bool visible)
 Wrapper for QGraphicsItem::setVisible.
virtual void setGraphicsItemZValue (double z)
 Wrapper for QGraphicsItem::setZValue.
virtual void updateColor ()
 Force a color update.
virtual void updateGeometry (double valueGraph)
 Update the geometry so it passes through the specified coordinate value in graph coordinates.
virtual void updateGeometry (const QPointF &posScreen)
 Update the geometry so it passes through the specified point in screen coordinates.
Public Member Functions inherited from GuidelineAbstract
 GuidelineAbstract (QGraphicsScene &scene)
 Single constructor.
 ~GuidelineAbstract ()
void bindGuidelineVisibleToInvisible (GuidelineAbstract *guidelineVisible)
 Bind a newly-created visible Guideline to this Guideline, and make this one invisible.
void handleActiveChange (bool active)
 DigitizeState change so active status may (or may not) be toggled.
void handleGuidelineMode (bool visible, bool locked)
 User toggled Guideline visibility and/or locked mode.
void handleHoverEnterEvent ()
 Highlight this Guideline upon hover enter.
void handleHoverLeaveEvent ()
 Unset highlighting triggered by hover enter.
void handleMouseMoveEvent (const QPointF &posScene)
 Forward movements to visible Guideline.
void handleMousePressEvent (const QPointF &posScene)
 Forward press event to state machine.
void handleMouseReleaseEvent (const QPointF &posScene)
 Cleanup after being dragged.
QPointF posCursorGraph () const
 Get position in graph coordinates.
void sacrificeHandleAndVisibleGuidelines (const QPointF &posScene, GuidelineState guidelineStateForReplacement)
 Replace visible and handle Guidelines after click and drag.
QGraphicsScene & scene ()
 GraphicsScene that owns this class.
QString stateDump () const
 Dump of state as a string for debugging only. Context like the QGraphicsItem flags is included.
QString stateName () const
 Current state name for debugging and unit test only.
void updateActive (bool active)
 Update active versus inactive state.
void updateWithLatestTransformation ()
 Update given Transformation in GuidelineStateContext. This is called after a command has been executed.

Additional Inherited Members

Public Slots inherited from GuidelineAbstract
void slotHandleMoved (QPointF posScreen)
 Slot for signal from cloned deployed Guideline from handle Guideline.
Signals inherited from GuidelineAbstract
void signalGuidelineDragged (QString, double, bool, GuidelineState)
 Signal indicating end of Guideline drag.
void signalHandleMoved (QPointF)
 Signal for cloned deployed Guideline from handle Guideline.
Protected Member Functions inherited from GuidelineAbstract
GuidelineStateContextcontext ()
 State machine context owned by this class.
const GuidelineStateContextcontext () const
 State machine context owned by this class as a const.
void setContext (GuidelineStateContext *context)
 Create state machine after virtual methods of child classes have been defined.

Detailed Description

Line version of GuidelineAbstract.

Definition at line 21 of file GuidelineLine.h.

Constructor & Destructor Documentation

◆ GuidelineLine()

GuidelineLine::GuidelineLine ( QGraphicsScene & scene,
Guidelines & guidelines,
GuidelineState guidelineStateInitial,
const QString & identifier )

Single constructor.

Definition at line 25 of file GuidelineLine.cpp.

28 :
30{
31 LOG4CPP_DEBUG_S ((*mainCat)) << "GuidelineLine::Guideline identifier=" << identifier.toLatin1().data();
32
33 // Create context after all virtual methods have been created
34 setContext (new GuidelineStateContext (*this,
35 guidelines,
36 guidelineStateInitial));
37
39 setData (DATA_KEY_IDENTIFIER, QVariant (identifier));
40
41 scene.addItem (this);
42}
@ DATA_KEY_GRAPHICS_ITEM_TYPE
Definition DataKey.h:15
@ DATA_KEY_IDENTIFIER
Definition DataKey.h:14
@ GRAPHICS_ITEM_TYPE_GUIDELINE
log4cpp::Category * mainCat
Definition Logger.cpp:14
QGraphicsScene & scene()
GraphicsScene that owns this class.
void setContext(GuidelineStateContext *context)
Create state machine after virtual methods of child classes have been defined.
GuidelineAbstract(QGraphicsScene &scene)
Single constructor.
virtual QString identifier() const
Unique identifier from QGraphicsItem.
#define LOG4CPP_DEBUG_S(logger)
Definition convenience.h:20

◆ ~GuidelineLine()

GuidelineLine::~GuidelineLine ( )

Definition at line 44 of file GuidelineLine.cpp.

45{
46}

Member Function Documentation

◆ getGraphicsItemAcceptHover()

bool GuidelineLine::getGraphicsItemAcceptHover ( ) const
virtual

Return true if accepting hover events.

Implements GuidelineAbstract.

Definition at line 48 of file GuidelineLine.cpp.

49{
50 return acceptHoverEvents();
51}

◆ getGraphicsItemSelected()

bool GuidelineLine::getGraphicsItemSelected ( ) const
virtual

Wrapper for QGraphicsItem::isSelected.

Implements GuidelineAbstract.

Definition at line 53 of file GuidelineLine.cpp.

54{
55 return QGraphicsLineItem::isSelected();
56}

◆ graphicsItemFlags()

QGraphicsItem::GraphicsItemFlags GuidelineLine::graphicsItemFlags ( ) const
virtual

Wraps QGraphicsItem::flags.

Implements GuidelineAbstract.

Definition at line 58 of file GuidelineLine.cpp.

59{
60 return QGraphicsLineItem::flags ();
61}

◆ handleVisibilityChange()

void GuidelineLine::handleVisibilityChange ( bool visible)

User toggled guideline visibility.

◆ hoverEnterEvent()

void GuidelineLine::hoverEnterEvent ( QGraphicsSceneHoverEvent * event)
virtual

Highlight this Guideline upon hover enter.

Definition at line 63 of file GuidelineLine.cpp.

64{
66
67 QGraphicsLineItem::hoverEnterEvent (event);
68}
void handleHoverEnterEvent()
Highlight this Guideline upon hover enter.

◆ hoverLeaveEvent()

void GuidelineLine::hoverLeaveEvent ( QGraphicsSceneHoverEvent * event)
virtual

Unset highlighting triggered by hover enter.

Definition at line 70 of file GuidelineLine.cpp.

71{
73
74 QGraphicsLineItem::hoverLeaveEvent (event);
75}
void handleHoverLeaveEvent()
Unset highlighting triggered by hover enter.

◆ identifier()

QString GuidelineLine::identifier ( ) const
virtual

Unique identifier from QGraphicsItem.

Implements GuidelineAbstract.

Definition at line 77 of file GuidelineLine.cpp.

78{
79 return data (DATA_KEY_IDENTIFIER).toString ();
80}

◆ mouseMoveEvent()

void GuidelineLine::mouseMoveEvent ( QGraphicsSceneMouseEvent * event)
virtual

Forward movements to visible Guideline.

Definition at line 82 of file GuidelineLine.cpp.

83{
84 handleMouseMoveEvent (event->scenePos ());
85
86 QGraphicsLineItem::mouseMoveEvent (event);
87}
void handleMouseMoveEvent(const QPointF &posScene)
Forward movements to visible Guideline.

◆ mousePressEvent()

void GuidelineLine::mousePressEvent ( QGraphicsSceneMouseEvent * event)
virtual

Forward press event to state machine.

Definition at line 89 of file GuidelineLine.cpp.

90{
91 LOG4CPP_DEBUG_S ((*mainCat)) << "GuidelineLine::mousePressEvent";
92
93 handleMousePressEvent (event->scenePos ());
94
95 QGraphicsLineItem::mousePressEvent (event);
96}
void handleMousePressEvent(const QPointF &posScene)
Forward press event to state machine.

◆ mouseReleaseEvent()

void GuidelineLine::mouseReleaseEvent ( QGraphicsSceneMouseEvent * event)
virtual

Cleanup after being dragged.

Definition at line 98 of file GuidelineLine.cpp.

99{
100 LOG4CPP_DEBUG_S ((*mainCat)) << "GuidelineLine::mouseReleaseEvent";
101
102 QGraphicsLineItem::mouseReleaseEvent (event);
103
104 handleMouseReleaseEvent (event->scenePos ());
105}
void handleMouseReleaseEvent(const QPointF &posScene)
Cleanup after being dragged.

◆ paint()

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

Override painting so this disappears when selected. Selected Guidelines are never visible.

Definition at line 107 of file GuidelineLine.cpp.

110{
111 if (context()->doPaint ()) {
112
113 QGraphicsLineItem::paint (painter,
114 option,
115 widget);
116 }
117}
GuidelineStateContext * context()
State machine context owned by this class.

◆ removeFromScene()

void GuidelineLine::removeFromScene ( QGraphicsScene * scene)
virtual

Make graphics item remove itself from the scene.

Implements GuidelineAbstract.

Definition at line 119 of file GuidelineLine.cpp.

120{
121 LOG4CPP_DEBUG_S ((*mainCat)) << "GuidelineLine::removeFromScene identifier="
122 << identifier().toLatin1().data();
123
124 scene->removeItem (this);
125}

◆ setGraphicsItemAcceptHoverEvents()

void GuidelineLine::setGraphicsItemAcceptHoverEvents ( bool accept)
virtual

Wrapper for QGraphicsItem::setAcceptHoverEvents.

Implements GuidelineAbstract.

Definition at line 127 of file GuidelineLine.cpp.

128{
129 QGraphicsLineItem::setAcceptHoverEvents (accept);
130}

◆ setGraphicsItemFlags()

void GuidelineLine::setGraphicsItemFlags ( QGraphicsItem::GraphicsItemFlags flags)
virtual

Wrapper for QGraphicsItem::setFlags.

Implements GuidelineAbstract.

Definition at line 132 of file GuidelineLine.cpp.

133{
134 QGraphicsLineItem::setFlags (flags);
135}

◆ setGraphicsItemLine()

void GuidelineLine::setGraphicsItemLine ( const QLineF & line)
virtual

Wrapper for QGraphicsLineItem::setLine.

Implements GuidelineAbstract.

Definition at line 137 of file GuidelineLine.cpp.

138{
139 QGraphicsLineItem::setLine (line);
140}

◆ setGraphicsItemPen()

void GuidelineLine::setGraphicsItemPen ( const QColor & color,
double lineWidth )
virtual

Wrapper for QGraphicsItem::setPen.

Implements GuidelineAbstract.

Definition at line 142 of file GuidelineLine.cpp.

144{
145 QBrush brush (color);
146
147 setPen (QPen (brush,
148 lineWidth));
149}

◆ setGraphicsItemVisible()

void GuidelineLine::setGraphicsItemVisible ( bool visible)
virtual

Wrapper for QGraphicsItem::setVisible.

Implements GuidelineAbstract.

Definition at line 151 of file GuidelineLine.cpp.

152{
153 QGraphicsLineItem::setVisible (visible);
154}

◆ setGraphicsItemZValue()

void GuidelineLine::setGraphicsItemZValue ( double z)
virtual

Wrapper for QGraphicsItem::setZValue.

Implements GuidelineAbstract.

Definition at line 156 of file GuidelineLine.cpp.

157{
158 QGraphicsLineItem::setZValue (z);
159}

◆ updateColor()

void GuidelineLine::updateColor ( )
virtual

Force a color update.

Implements GuidelineAbstract.

Definition at line 161 of file GuidelineLine.cpp.

162{
163 // Apply color to brush and pen defined in setGraphicsItemPen.
164 // Alpha from alphaF() on QColor on QBrush is unused
165
166 QPen p = QGraphicsLineItem::pen();
167 QBrush br = p.brush();
168 double alphaF = br.color().alphaF();
169 double lineWidth = p.width ();
170
171 QColor color = ColorPaletteToQColor (context()->color());
172 color.setAlphaF (alphaF);
173
174 setGraphicsItemPen (color,
175 lineWidth);
176}
QColor ColorPaletteToQColor(ColorPalette color)
Definition EnumsToQt.cpp:16
virtual void setGraphicsItemPen(const QColor &color, double lineWidth)
Wrapper for QGraphicsItem::setPen.

◆ updateGeometry() [1/2]

void GuidelineLine::updateGeometry ( const QPointF & posScreen)
virtual

Update the geometry so it passes through the specified point in screen coordinates.

Implements GuidelineAbstract.

Definition at line 185 of file GuidelineLine.cpp.

186{
187 QLineF line = context()->pointToLine (posScreen);
188
189 setLine (line);
190
191 // Save the graph value for later
192 QPointF posGraph;
194 posGraph);
195 context()->setPosCursorGraph (posGraph);
196}
Transformation transformation() const
Return copy of transformation owned by MainWindow.
void setPosCursorGraph(const QPointF &posGraph)
Pass the current cursor coordinate to the state so it can save the relevant coordinate for later adju...
QLineF pointToLine(const QPointF &posScreen) const
Return line parallel to an axis line, that passes through the specified point.
void transformScreenToRawGraph(const QPointF &coordScreen, QPointF &coordGraph) const
Transform from cartesian pixel screen coordinates to cartesian/polar graph coordinates.

◆ updateGeometry() [2/2]

void GuidelineLine::updateGeometry ( double valueGraph)
virtual

Update the geometry so it passes through the specified coordinate value in graph coordinates.

Implements GuidelineAbstract.

Definition at line 178 of file GuidelineLine.cpp.

179{
180 // Convert single graph coordinate, which is range, into screen point pair,
181 // then update with the screen point
182 updateGeometry (context ()->convertGraphCoordinateToScreenPoint (valueGraph));
183}
virtual void updateGeometry(double valueGraph)
Update the geometry so it passes through the specified coordinate value in graph coordinates.

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