Engauge Digitizer
2
Toggle main menu visibility
Loading...
Searching...
No Matches
Guideline
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 "
EnumsToQt.h
"
9
#include "
GraphicsScene.h
"
10
#include "
GuidelineAbstract.h
"
11
#include "
GuidelineStateContext.h
"
12
#include "
GuidelineStateDeployedAbstract.h
"
13
#include "
Logger.h
"
14
#include <QPen>
15
#include "
ZValues.h
"
16
17
GuidelineStateDeployedAbstract::GuidelineStateDeployedAbstract
(
GuidelineStateContext
&
context
) :
18
GuidelineStateAbstractBase
(
context
)
19
{
20
}
21
22
GuidelineStateDeployedAbstract::~GuidelineStateDeployedAbstract
()
23
{
24
}
25
26
void
GuidelineStateDeployedAbstract::beginCommon
(
bool
hovering,
27
bool
locked)
28
{
29
context
().
guideline
().
setGraphicsItemZValue
(
Z_VALUE_GUIDELINE_DEPLOYED
);
30
context
().
guideline
().
setGraphicsItemVisible
(
true
);
31
32
if
(locked) {
33
34
// Prevent interaction. ItemIsSelectable is overkill, and in special cases adds ugly selected dashes
35
QGraphicsItem::GraphicsItemFlags flags =
context
().
guideline
().
graphicsItemFlags
();
36
flags &= ~QGraphicsItem::ItemIsFocusable;
37
flags &= ~QGraphicsItem::ItemIsMovable;
38
context
().
guideline
().
setGraphicsItemFlags
(flags);
39
context
().
guideline
().
setGraphicsItemAcceptHoverEvents
(
false
);
40
41
const
DocumentModelGuideline
&modelGuideline =
context
().
modelGuideline
();
42
43
context
().
guideline
().
setGraphicsItemPen
(
ColorPaletteToQColor
(modelGuideline.
lineColor
()),
44
modelGuideline.
lineWidthInactive
());
45
46
}
else
{
47
48
// Give feedback when user hovers
49
context
().
guideline
().
setGraphicsItemFlags
(QGraphicsItem::ItemIsFocusable |
50
QGraphicsItem::ItemIsMovable);
51
context
().
guideline
().
setGraphicsItemAcceptHoverEvents
(
true
);
52
53
const
DocumentModelGuideline
&modelGuideline =
context
().
modelGuideline
();
54
55
context
().
guideline
().
setGraphicsItemPen
(
ColorPaletteToQColor
(modelGuideline.
lineColor
()),
56
hovering ? modelGuideline.
lineWidthActive
() : modelGuideline.
lineWidthInactive
());
57
}
58
}
59
60
void
GuidelineStateDeployedAbstract::end
()
61
{
62
qCDebug(ENGAUGE_LOG) <<
"GuidelineStateDeployedAbstract::end"
;
63
}
64
65
void
GuidelineStateDeployedAbstract::handleMouseRelease
(
const
QPointF &
/* posScene */
)
66
{
67
// Noop
68
}
69
70
void
GuidelineStateDeployedAbstract::handleTimeout
()
71
{
72
// Noop
73
}
74
EngaugeAssert.h
ColorPaletteToQColor
QColor ColorPaletteToQColor(ColorPalette color)
Definition
EnumsToQt.cpp:16
EnumsToQt.h
GraphicsScene.h
GuidelineAbstract.h
GuidelineStateContext.h
GuidelineStateDeployedAbstract.h
Logger.h
Z_VALUE_GUIDELINE_DEPLOYED
const int Z_VALUE_GUIDELINE_DEPLOYED
Definition
ZValues.cpp:12
ZValues.h
DocumentModelGuideline
Model for managing the coordinate values corresponding Guidelines.
Definition
DocumentModelGuideline.h:22
DocumentModelGuideline::lineWidthInactive
double lineWidthInactive() const
Get method for line width when inactive.
Definition
DocumentModelGuideline.cpp:78
DocumentModelGuideline::lineColor
ColorPalette lineColor() const
Get method for line color.
Definition
DocumentModelGuideline.cpp:68
DocumentModelGuideline::lineWidthActive
double lineWidthActive() const
Get method for line width when active.
Definition
DocumentModelGuideline.cpp:73
GuidelineAbstract::setGraphicsItemVisible
virtual void setGraphicsItemVisible(bool visible)=0
Wrapper for QGraphicsItem::setVisible.
GuidelineAbstract::graphicsItemFlags
virtual QGraphicsItem::GraphicsItemFlags graphicsItemFlags() const =0
Wraps QGraphicsItem::flags.
GuidelineAbstract::setGraphicsItemAcceptHoverEvents
virtual void setGraphicsItemAcceptHoverEvents(bool accept)=0
Wrapper for QGraphicsItem::setAcceptHoverEvents.
GuidelineAbstract::setGraphicsItemZValue
virtual void setGraphicsItemZValue(double z)=0
Wrapper for QGraphicsItem::setZValue.
GuidelineAbstract::setGraphicsItemPen
virtual void setGraphicsItemPen(const QColor &color, double lineWidth)=0
Wrapper for QGraphicsItem::setPen.
GuidelineAbstract::setGraphicsItemFlags
virtual void setGraphicsItemFlags(QGraphicsItem::GraphicsItemFlags flags)=0
Wrapper for QGraphicsItem::setFlags.
GuidelineStateAbstractBase::context
GuidelineStateContext & context() const
Context in charge of the state classes.
Definition
GuidelineStateAbstractBase.cpp:27
GuidelineStateAbstractBase::GuidelineStateAbstractBase
GuidelineStateAbstractBase(GuidelineStateContext &context)
Single constructor.
Definition
GuidelineStateAbstractBase.cpp:18
GuidelineStateContext
Context class for state machine that belongs to the Guideline class.
Definition
GuidelineStateContext.h:132
GuidelineStateContext::guideline
GuidelineAbstract & guideline()
Guideline that owns this context class.
Definition
GuidelineStateContext.cpp:155
GuidelineStateContext::modelGuideline
DocumentModelGuideline modelGuideline() const
Up-to-date guideline settings.
Definition
GuidelineStateContext.cpp:209
GuidelineStateDeployedAbstract::~GuidelineStateDeployedAbstract
virtual ~GuidelineStateDeployedAbstract()
Definition
GuidelineStateDeployedAbstract.cpp:22
GuidelineStateDeployedAbstract::handleTimeout
virtual void handleTimeout()
Handle timeout from Appearing state.
Definition
GuidelineStateDeployedAbstract.cpp:70
GuidelineStateDeployedAbstract::GuidelineStateDeployedAbstract
GuidelineStateDeployedAbstract(GuidelineStateContext &context)
Single constructor.
Definition
GuidelineStateDeployedAbstract.cpp:17
GuidelineStateDeployedAbstract::beginCommon
void beginCommon(bool hovering, bool locked)
Initialization common to all states.
Definition
GuidelineStateDeployedAbstract.cpp:26
GuidelineStateDeployedAbstract::handleMouseRelease
virtual void handleMouseRelease(const QPointF &posScene)
At the end of dragging, clone the Guideline that owns the state machine where these states live.
Definition
GuidelineStateDeployedAbstract.cpp:65
GuidelineStateDeployedAbstract::end
virtual void end()
Transition out of state.
Definition
GuidelineStateDeployedAbstract.cpp:60
Generated on
for Engauge Digitizer by
1.17.0