Engauge Digitizer 2
Loading...
Searching...
No Matches
GuidelineStateDeployedAbstract.cpp
Go to the documentation of this file.
1/******************************************************************************************************
2 * (C) 2019 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 "EngaugeAssert.h"
8#include "GraphicsScene.h"
9#include "GuidelineAbstract.h"
10#include "GuidelineFormat.h"
13#include "Logger.h"
14#include <QPen>
15#include "ZValues.h"
16
21
25
27 bool locked)
28{
29 GuidelineFormat guidelineFormat (context().color());
30
33
34 if (locked) {
35
36 // Prevent interaction. ItemIsSelectable is overkill, and in special cases adds ugly selected dashes
37 QGraphicsItem::GraphicsItemFlags flags = context().guideline ().graphicsItemFlags();
38 flags &= ~QGraphicsItem::ItemIsFocusable;
39 flags &= ~QGraphicsItem::ItemIsMovable;
42
44 guidelineFormat.lineWidthNonHover ());
45
46 } else {
47
48 // Give feedback when user hovers
49 context().guideline().setGraphicsItemFlags (QGraphicsItem::ItemIsFocusable |
50 QGraphicsItem::ItemIsMovable);
52
54 guidelineFormat.colorDeployedHover () :
55 guidelineFormat.colorDeployedNonHover (),
56 hoverOption == GuidelineFormat::HOVER_ON ?
57 guidelineFormat.lineWidthHover () :
58 guidelineFormat.lineWidthNonHover ());
59 }
60}
61
63{
64 LOG4CPP_DEBUG_S ((*mainCat)) << "GuidelineStateDeployedAbstract::end";
65}
66
67void GuidelineStateDeployedAbstract::handleMouseRelease (const QPointF & /* posScene */)
68{
69 // Noop
70}
71
76
log4cpp::Category * mainCat
Definition Logger.cpp:14
const int Z_VALUE_GUIDELINE_DEPLOYED
Definition ZValues.cpp:12
virtual void setGraphicsItemVisible(bool visible)=0
Wrapper for QGraphicsItem::setVisible.
virtual QGraphicsItem::GraphicsItemFlags graphicsItemFlags() const =0
Wraps QGraphicsItem::flags.
virtual void setGraphicsItemAcceptHoverEvents(bool accept)=0
Wrapper for QGraphicsItem::setAcceptHoverEvents.
virtual void setGraphicsItemZValue(double z)=0
Wrapper for QGraphicsItem::setZValue.
virtual void setGraphicsItemPen(const QColor &color, double lineWidth)=0
Wrapper for QGraphicsItem::setPen.
virtual void setGraphicsItemFlags(QGraphicsItem::GraphicsItemFlags flags)=0
Wrapper for QGraphicsItem::setFlags.
This class centralizes the formatting information (color, line width, alpha) for the Guidelines.
QColor colorDeployedNonHover() const
Guideline color when not hovering.
double lineWidthHover() const
Guideline line width.
double lineWidthNonHover() const
Guideline line width for narrow lines.
QColor colorDeployedHover() const
Guideline color when hovering.
HoverOption
Public enum.
GuidelineStateContext & context() const
Context in charge of the state classes.
GuidelineStateAbstractBase(GuidelineStateContext &context)
Single constructor.
Context class for state machine that belongs to the Guideline class.
GuidelineAbstract & guideline()
Guideline that owns this context class.
virtual void handleTimeout()
Handle timeout from Appearing state.
GuidelineStateDeployedAbstract(GuidelineStateContext &context)
Single constructor.
virtual void handleMouseRelease(const QPointF &posScene)
At the end of dragging, clone the Guideline that owns the state machine where these states live.
virtual void end()
Transition out of state.
void beginCommon(GuidelineFormat::HoverOption hoverOption, bool locked)
Initialization common to all states.
#define LOG4CPP_DEBUG_S(logger)
Definition convenience.h:20