Engauge Digitizer
2
Loading...
Searching...
No Matches
Background
BackgroundStateAbstractBase.cpp
Go to the documentation of this file.
1
/******************************************************************************************************
2
* (C) 2014 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 "
BackgroundStateAbstractBase.h
"
8
#include "
DataKey.h
"
9
#include "
EngaugeAssert.h
"
10
#include "
GraphicsItemType.h
"
11
#include "
GraphicsScene.h
"
12
#include "
Logger.h
"
13
#include "
ZValues.h
"
14
15
BackgroundStateAbstractBase::BackgroundStateAbstractBase
(
BackgroundStateContext
&context,
16
GraphicsScene
&scene) :
17
m_context (context),
18
m_scene (scene),
19
m_imageItem (nullptr)
20
{
21
// Create an image but do not show it until the appropriate state is reached
22
QPixmap dummy;
23
m_imageItem = m_scene.addPixmap (dummy);
24
m_imageItem->setVisible (
false
);
25
m_imageItem->setZValue (
Z_VALUE_BACKGROUND
);
26
m_imageItem->setData (
DATA_KEY_IDENTIFIER
,
"view"
);
27
m_imageItem->setData (
DATA_KEY_GRAPHICS_ITEM_TYPE
,
GRAPHICS_ITEM_TYPE_IMAGE
);
28
}
29
30
BackgroundStateAbstractBase::~BackgroundStateAbstractBase
()
31
{
32
}
33
34
BackgroundStateContext
&
BackgroundStateAbstractBase::context
()
35
{
36
return
m_context;
37
}
38
39
const
BackgroundStateContext
&
BackgroundStateAbstractBase::context
()
const
40
{
41
return
m_context;
42
}
43
44
QImage
BackgroundStateAbstractBase::image
()
const
45
{
46
return
m_image;
47
}
48
49
QGraphicsPixmapItem &
BackgroundStateAbstractBase::imageItem
()
const
50
{
51
return
*m_imageItem;
52
}
53
54
GraphicsScene
&
BackgroundStateAbstractBase::scene
()
55
{
56
return
m_scene;
57
}
58
59
const
GraphicsScene
&
BackgroundStateAbstractBase::scene
()
const
60
{
61
return
m_scene;
62
}
63
64
void
BackgroundStateAbstractBase::setImageVisible
(
bool
visible)
65
{
66
m_imageItem->setVisible (visible);
67
}
68
69
void
BackgroundStateAbstractBase::setProcessedPixmap
(
const
QPixmap &pixmap)
70
{
71
LOG4CPP_INFO_S
((*
mainCat
)) <<
"BackgroundStateAbstractBase::setProcessedPixmap"
72
<<
" map=("
<< pixmap.width() <<
"x"
<< pixmap.height() <<
")"
;
73
74
ENGAUGE_CHECK_PTR
(m_imageItem);
75
76
m_imageItem->setPixmap (pixmap);
77
78
// Reset scene rectangle or else small image after large image will be off-center
79
m_scene.setSceneRect (m_imageItem->boundingRect ());
80
81
m_image = pixmap.toImage();
82
}
BackgroundStateAbstractBase.h
DataKey.h
DATA_KEY_GRAPHICS_ITEM_TYPE
@ DATA_KEY_GRAPHICS_ITEM_TYPE
Unique identifier for QGraphicsItem object
Definition
DataKey.h:15
DATA_KEY_IDENTIFIER
@ DATA_KEY_IDENTIFIER
Definition
DataKey.h:14
EngaugeAssert.h
ENGAUGE_CHECK_PTR
#define ENGAUGE_CHECK_PTR(ptr)
#endif
Definition
EngaugeAssert.h:27
GraphicsItemType.h
GRAPHICS_ITEM_TYPE_IMAGE
@ GRAPHICS_ITEM_TYPE_IMAGE
Definition
GraphicsItemType.h:12
GraphicsScene.h
mainCat
log4cpp::Category * mainCat
Definition
Logger.cpp:14
Logger.h
Z_VALUE_BACKGROUND
const int Z_VALUE_BACKGROUND
Z values for ordering of the various graphics layers, with background at the bottom.
Definition
ZValues.cpp:9
ZValues.h
BackgroundStateAbstractBase::BackgroundStateAbstractBase
BackgroundStateAbstractBase(BackgroundStateContext &context, GraphicsScene &scene)
Single constructor.
Definition
BackgroundStateAbstractBase.cpp:15
BackgroundStateAbstractBase::imageItem
QGraphicsPixmapItem & imageItem() const
Graphics image item for the current state.
Definition
BackgroundStateAbstractBase.cpp:49
BackgroundStateAbstractBase::scene
GraphicsScene & scene()
Reference to the GraphicsScene, without const.
Definition
BackgroundStateAbstractBase.cpp:54
BackgroundStateAbstractBase::context
BackgroundStateContext & context()
Reference to the BackgroundStateContext that contains all the BackgroundStateAbstractBase subclasses,...
Definition
BackgroundStateAbstractBase.cpp:34
BackgroundStateAbstractBase::setImageVisible
void setImageVisible(bool visible)
Show/hide background image.
Definition
BackgroundStateAbstractBase.cpp:64
BackgroundStateAbstractBase::image
QImage image() const
Image for the current state.
Definition
BackgroundStateAbstractBase.cpp:44
BackgroundStateAbstractBase::~BackgroundStateAbstractBase
virtual ~BackgroundStateAbstractBase()
Definition
BackgroundStateAbstractBase.cpp:30
BackgroundStateAbstractBase::setProcessedPixmap
void setProcessedPixmap(const QPixmap &pixmap)
Save the image for this state after it has been processed by the leaf class.
Definition
BackgroundStateAbstractBase.cpp:69
BackgroundStateContext
Context class that manages the background image state machine.
Definition
BackgroundStateContext.h:33
GraphicsScene
Add point and line handling to generic QGraphicsScene.
Definition
GraphicsScene.h:37
LOG4CPP_INFO_S
#define LOG4CPP_INFO_S(logger)
Definition
convenience.h:18
Generated on Wed Aug 3 2022 00:00:00 for Engauge Digitizer by
1.10.0