16#include <QGraphicsLineItem>
17#include <QGraphicsScene>
18#include <QGraphicsSceneMouseEvent>
31 m_guidelineVisible (nullptr)
44 m_guidelineVisible = guidelineVisible;
68 m_context->handleGuidelineMode (visible,
74 m_context->handleHoverEnterEvent ();
79 m_context->handleHoverLeaveEvent ();
85 << posScene.x() <<
", " << posScene.y() <<
")";
88 if (m_guidelineVisible !=
nullptr) {
98 m_context->handleMousePress(posScene);
105 m_context->handleMouseRelease (posScene);
112 <<
" keeping identifier=" <<
identifier().toLatin1().data()
113 <<
" in " <<
stateName ().toLatin1().data();
115 if (m_guidelineVisible !=
nullptr) {
118 bool offscreen = !m_scene.sceneRect().contains (posScene);
121 LOG4CPP_DEBUG_S ((*
mainCat)) <<
"GuidelineAbstract::sacrificeHandleAndVisibleGuidelines identifierDeleting="
122 << m_guidelineVisible->identifier().toLatin1().data();
125 m_guidelineVisible->removeFromScene (&m_scene);
126 delete m_guidelineVisible;
127 m_guidelineVisible =
nullptr;
135 guidelineStateForReplacement);
146 return m_context->posCursorGraph ();
164 QTextStream str (&out);
166 str <<
" " << m_context->stateName ();
170 str << ((
graphicsItemFlags () & QGraphicsItem::ItemIsFocusable ) != 0 ?
"focusable" :
"unfocusable") <<
" ";
171 str << ((
graphicsItemFlags () & QGraphicsItem::ItemIsMovable ) != 0 ?
"movable" :
"unmovable") <<
" ";
172 str << ((
graphicsItemFlags () & QGraphicsItem::ItemIsSelectable) != 0 ?
"selectable" :
"unselectable") <<
" ";
180 return m_context->stateName ();
185 m_context->updateWithLatestTransformation ();
GuidelineState
Set of possible Guideline states. See class Guideline for more information.
log4cpp::Category * mainCat
void sacrificeHandleAndVisibleGuidelines(const QPointF &posScene, GuidelineState guidelineStateForReplacement)
Replace visible and handle Guidelines after click and drag.
virtual QString identifier() const =0
Unique identifier from QGraphicsItem.
QGraphicsScene & scene()
GraphicsScene that owns this class.
void handleMousePressEvent(const QPointF &posScene)
Forward press event to state machine.
void setContext(GuidelineStateContext *context)
Create state machine after virtual methods of child classes have been defined.
QPointF posCursorGraph() const
Get position in graph coordinates.
virtual void updateGeometry(double valueGraph)=0
Update the geometry so it passes through the specified coordinate value in graph coordinates.
void handleMouseMoveEvent(const QPointF &posScene)
Forward movements to visible Guideline.
void updateWithLatestTransformation()
Update given Transformation in GuidelineStateContext. This is called after a command has been execute...
void bindGuidelineVisibleToInvisible(GuidelineAbstract *guidelineVisible)
Bind a newly-created visible Guideline to this Guideline, and make this one invisible.
virtual bool getGraphicsItemAcceptHover() const =0
Return true if accepting hover events.
void handleGuidelineMode(bool visible, bool locked)
User toggled Guideline visibility and/or locked mode.
void slotHandleMoved(QPointF posScreen)
Slot for signal from cloned deployed Guideline from handle Guideline.
void signalHandleMoved(QPointF)
Signal for cloned deployed Guideline from handle Guideline.
void handleMouseReleaseEvent(const QPointF &posScene)
Cleanup after being dragged.
void handleActiveChange(bool active)
DigitizeState change so active status may (or may not) be toggled.
virtual QGraphicsItem::GraphicsItemFlags graphicsItemFlags() const =0
Wraps QGraphicsItem::flags.
QString stateDump() const
Dump of state as a string for debugging only. Context like the QGraphicsItem flags is included.
GuidelineStateContext * context()
State machine context owned by this class.
void handleHoverEnterEvent()
Highlight this Guideline upon hover enter.
virtual bool getGraphicsItemSelected() const =0
Wrapper for QGraphicsItem::isSelected.
void handleHoverLeaveEvent()
Unset highlighting triggered by hover enter.
GuidelineAbstract(QGraphicsScene &scene)
Single constructor.
void signalGuidelineDragged(QString, double, bool, GuidelineState)
Signal indicating end of Guideline drag.
QString stateName() const
Current state name for debugging and unit test only.
Context class for state machine that belongs to the Guideline class.
void handleActiveChange(bool active)
DigitizeState change so active status may (or may not) be toggled.
double convertScreenPointToGraphCoordinate(const QPointF &posScreen) const
Convert screen point pair into single graph coordinate.
#define LOG4CPP_INFO_S(logger)
#define LOG4CPP_DEBUG_S(logger)