Engauge Digitizer
2
Loading...
Searching...
No Matches
Background
BackgroundStateAbstractBase.cpp
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
14
BackgroundStateAbstractBase::BackgroundStateAbstractBase
(
BackgroundStateContext
&context,
15
GraphicsScene
&scene) :
16
m_context (context),
17
m_scene (scene),
18
m_imageItem (0)
19
{
20
// Create an image but do not show it until the appropriate state is reached
21
QPixmap dummy;
22
m_imageItem = m_scene.addPixmap (dummy);
23
m_imageItem->setVisible (
false
);
24
m_imageItem->setData (DATA_KEY_IDENTIFIER,
"view"
);
25
m_imageItem->setData (DATA_KEY_GRAPHICS_ITEM_TYPE, GRAPHICS_ITEM_TYPE_IMAGE);
26
}
27
28
BackgroundStateAbstractBase::~BackgroundStateAbstractBase()
29
{
30
}
31
32
BackgroundStateContext
&
BackgroundStateAbstractBase::context
()
33
{
34
return
m_context;
35
}
36
37
const
BackgroundStateContext
&
BackgroundStateAbstractBase::context
()
const
38
{
39
return
m_context;
40
}
41
42
QImage
BackgroundStateAbstractBase::image
()
const
43
{
44
return
m_image;
45
}
46
47
QGraphicsPixmapItem &
BackgroundStateAbstractBase::imageItem
()
const
48
{
49
return
*m_imageItem;
50
}
51
52
GraphicsScene
&
BackgroundStateAbstractBase::scene
()
53
{
54
return
m_scene;
55
}
56
57
const
GraphicsScene
&
BackgroundStateAbstractBase::scene
()
const
58
{
59
return
m_scene;
60
}
61
62
void
BackgroundStateAbstractBase::setImageVisible
(
bool
visible)
63
{
64
m_imageItem->setVisible (visible);
65
}
66
67
void
BackgroundStateAbstractBase::setProcessedPixmap
(
const
QPixmap &pixmap)
68
{
69
LOG4CPP_INFO_S ((*mainCat)) <<
"BackgroundStateAbstractBase::setProcessedPixmap"
70
<<
" map=("
<< pixmap.width() <<
"x"
<< pixmap.height() <<
")"
;
71
72
ENGAUGE_CHECK_PTR(m_imageItem);
73
74
m_imageItem->setPixmap (pixmap);
75
76
// Reset scene rectangle or else small image after large image will be off-center
77
m_scene.setSceneRect (m_imageItem->boundingRect ());
78
79
m_image = pixmap.toImage();
80
}
BackgroundStateAbstractBase::BackgroundStateAbstractBase
BackgroundStateAbstractBase(BackgroundStateContext &context, GraphicsScene &scene)
Single constructor.
Definition
BackgroundStateAbstractBase.cpp:14
BackgroundStateAbstractBase::imageItem
QGraphicsPixmapItem & imageItem() const
Graphics image item for the current state.
Definition
BackgroundStateAbstractBase.cpp:47
BackgroundStateAbstractBase::scene
GraphicsScene & scene()
Reference to the GraphicsScene, without const.
Definition
BackgroundStateAbstractBase.cpp:52
BackgroundStateAbstractBase::context
BackgroundStateContext & context()
Reference to the BackgroundStateContext that contains all the BackgroundStateAbstractBase subclasses,...
Definition
BackgroundStateAbstractBase.cpp:32
BackgroundStateAbstractBase::setImageVisible
void setImageVisible(bool visible)
Show/hide background image.
Definition
BackgroundStateAbstractBase.cpp:62
BackgroundStateAbstractBase::image
QImage image() const
Image for the current state.
Definition
BackgroundStateAbstractBase.cpp:42
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:67
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:32
Generated on Mon Jan 8 2024 05:59:39 for Engauge Digitizer by
1.9.8