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, MainWindow &mainWindow, 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 22 of file GuidelineLine.h.

Constructor & Destructor Documentation

◆ GuidelineLine()

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

Single constructor.

Definition at line 25 of file GuidelineLine.cpp.

29 :
31 m_mainWindow (mainWindow)
32{
33 LOG4CPP_DEBUG_S ((*mainCat)) << "GuidelineLine::Guideline identifier=" << identifier.toLatin1().data();
34
35 // Create context after all virtual methods have been created
36 setContext (new GuidelineStateContext (*this,
37 mainWindow,
38 guidelines,
39 guidelineStateInitial));
40
42 setData (DATA_KEY_IDENTIFIER, QVariant (identifier));
43
44 scene.addItem (this);
45}
@ 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 47 of file GuidelineLine.cpp.

48{
49}

Member Function Documentation

◆ getGraphicsItemAcceptHover()

bool GuidelineLine::getGraphicsItemAcceptHover ( ) const
virtual

Return true if accepting hover events.

Implements GuidelineAbstract.

Definition at line 51 of file GuidelineLine.cpp.

52{
53 return acceptHoverEvents();
54}

◆ getGraphicsItemSelected()

bool GuidelineLine::getGraphicsItemSelected ( ) const
virtual

Wrapper for QGraphicsItem::isSelected.

Implements GuidelineAbstract.

Definition at line 56 of file GuidelineLine.cpp.

57{
58 return QGraphicsLineItem::isSelected();
59}

◆ graphicsItemFlags()

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

Wraps QGraphicsItem::flags.

Implements GuidelineAbstract.

Definition at line 61 of file GuidelineLine.cpp.

62{
63 return QGraphicsLineItem::flags ();
64}

◆ 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 66 of file GuidelineLine.cpp.

67{
69
70 QGraphicsLineItem::hoverEnterEvent (event);
71}
void handleHoverEnterEvent()
Highlight this Guideline upon hover enter.

◆ hoverLeaveEvent()

void GuidelineLine::hoverLeaveEvent ( QGraphicsSceneHoverEvent * event)
virtual

Unset highlighting triggered by hover enter.

Definition at line 73 of file GuidelineLine.cpp.

74{
76
77 QGraphicsLineItem::hoverLeaveEvent (event);
78}
void handleHoverLeaveEvent()
Unset highlighting triggered by hover enter.

◆ identifier()

QString GuidelineLine::identifier ( ) const
virtual

Unique identifier from QGraphicsItem.

Implements GuidelineAbstract.

Definition at line 80 of file GuidelineLine.cpp.

81{
82 return data (DATA_KEY_IDENTIFIER).toString ();
83}

◆ mouseMoveEvent()

void GuidelineLine::mouseMoveEvent ( QGraphicsSceneMouseEvent * event)
virtual

Forward movements to visible Guideline.

Definition at line 85 of file GuidelineLine.cpp.

86{
87 handleMouseMoveEvent (event->scenePos ());
88
89 QGraphicsLineItem::mouseMoveEvent (event);
90}
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 92 of file GuidelineLine.cpp.

93{
94 LOG4CPP_DEBUG_S ((*mainCat)) << "GuidelineLine::mousePressEvent";
95
96 handleMousePressEvent (event->scenePos ());
97
98 QGraphicsLineItem::mousePressEvent (event);
99}
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 101 of file GuidelineLine.cpp.

102{
103 LOG4CPP_DEBUG_S ((*mainCat)) << "GuidelineLine::mouseReleaseEvent";
104
105 QGraphicsLineItem::mouseReleaseEvent (event);
106
107 handleMouseReleaseEvent (event->scenePos ());
108}
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 110 of file GuidelineLine.cpp.

113{
114 if (context()->doPaint ()) {
115
116 QGraphicsLineItem::paint (painter,
117 option,
118 widget);
119 }
120}
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 122 of file GuidelineLine.cpp.

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

◆ setGraphicsItemAcceptHoverEvents()

void GuidelineLine::setGraphicsItemAcceptHoverEvents ( bool accept)
virtual

Wrapper for QGraphicsItem::setAcceptHoverEvents.

Implements GuidelineAbstract.

Definition at line 130 of file GuidelineLine.cpp.

131{
132 QGraphicsLineItem::setAcceptHoverEvents (accept);
133}

◆ setGraphicsItemFlags()

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

Wrapper for QGraphicsItem::setFlags.

Implements GuidelineAbstract.

Definition at line 135 of file GuidelineLine.cpp.

136{
137 QGraphicsLineItem::setFlags (flags);
138}

◆ setGraphicsItemLine()

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

Wrapper for QGraphicsLineItem::setLine.

Implements GuidelineAbstract.

Definition at line 140 of file GuidelineLine.cpp.

141{
142 QGraphicsLineItem::setLine (line);
143}

◆ setGraphicsItemPen()

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

Wrapper for QGraphicsItem::setPen.

Implements GuidelineAbstract.

Definition at line 145 of file GuidelineLine.cpp.

147{
148 QBrush brush (color);
149
150 setPen (QPen (brush,
151 lineWidth));
152}

◆ setGraphicsItemVisible()

void GuidelineLine::setGraphicsItemVisible ( bool visible)
virtual

Wrapper for QGraphicsItem::setVisible.

Implements GuidelineAbstract.

Definition at line 154 of file GuidelineLine.cpp.

155{
156 QGraphicsLineItem::setVisible (visible);
157}

◆ setGraphicsItemZValue()

void GuidelineLine::setGraphicsItemZValue ( double z)
virtual

Wrapper for QGraphicsItem::setZValue.

Implements GuidelineAbstract.

Definition at line 159 of file GuidelineLine.cpp.

160{
161 QGraphicsLineItem::setZValue (z);
162}

◆ updateColor()

void GuidelineLine::updateColor ( )
virtual

Force a color update.

Implements GuidelineAbstract.

Definition at line 164 of file GuidelineLine.cpp.

165{
166 // Apply color to brush and pen defined in setGraphicsItemPen.
167 // Alpha from alphaF() on QColor on QBrush is unused
168
169 QPen p = QGraphicsLineItem::pen();
170 QBrush br = p.brush();
171 double alphaF = br.color().alphaF();
172 double lineWidth = p.width ();
173
174 QColor color = ColorPaletteToQColor (context()->color());
175 color.setAlphaF (alphaF);
176
177 setGraphicsItemPen (color,
178 lineWidth);
179}
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 188 of file GuidelineLine.cpp.

189{
190 QLineF line = context()->pointToLine (posScreen);
191
192 setLine (line);
193
194 // Save the graph value for later
195 QPointF posGraph;
197 posGraph);
198 context()->setPosCursorGraph (posGraph);
199}
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 181 of file GuidelineLine.cpp.

182{
183 // Convert single graph coordinate, which is range, into screen point pair,
184 // then update with the screen point
185 updateGeometry (context ()->convertGraphCoordinateToScreenPoint (valueGraph));
186}
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: