Engauge Digitizer  2
 All Classes Files Functions Variables Enumerations Enumerator Friends Pages
BackgroundStateAbstractBase.cpp
1 #include "BackgroundStateAbstractBase.h"
2 #include "DataKey.h"
3 #include "EngaugeAssert.h"
4 #include "GraphicsItemType.h"
5 #include "GraphicsScene.h"
6 #include "Logger.h"
7 
9  GraphicsScene &scene) :
10  m_context (context),
11  m_scene (scene),
12  m_imageItem (0)
13 {
14  // Create an image but do not show it until the appropriate state is reached
15  QPixmap dummy;
16  m_imageItem = m_scene.addPixmap (dummy);
17  m_imageItem->setVisible (false);
18  m_imageItem->setData (DATA_KEY_IDENTIFIER, "view");
19  m_imageItem->setData (DATA_KEY_GRAPHICS_ITEM_TYPE, GRAPHICS_ITEM_TYPE_IMAGE);
20 }
21 
22 BackgroundStateAbstractBase::~BackgroundStateAbstractBase()
23 {
24 }
25 
27 {
28  return m_context;
29 }
30 
32 {
33  return m_context;
34 }
35 
37 {
38  return m_image;
39 }
40 
41 QGraphicsPixmapItem &BackgroundStateAbstractBase::imageItem () const
42 {
43  return *m_imageItem;
44 }
45 
47 {
48  return m_scene;
49 }
50 
52 {
53  return m_scene;
54 }
55 
57 {
58  m_imageItem->setVisible (visible);
59 }
60 
62 {
63  LOG4CPP_INFO_S ((*mainCat)) << "BackgroundStateAbstractBase::setProcessedPixmap"
64  << " map=(" << pixmap.width() << "x" << pixmap.height() << ")";
65 
66  ENGAUGE_CHECK_PTR (m_imageItem);
67 
68  m_imageItem->setPixmap (pixmap);
69 
70  // Reset scene rectangle or else small image after large image will be off-center
71  m_scene.setSceneRect (m_imageItem->boundingRect ());
72 
73  m_image = pixmap.toImage();
74 }
QImage image() const
Image for the current state.
QGraphicsPixmapItem & imageItem() const
Graphics image item for the current state.
void setImageVisible(bool visible)
Show/hide background image.
void setProcessedPixmap(const QPixmap &pixmap)
Save the image for this state after it has been processed by the leaf class.
BackgroundStateAbstractBase(BackgroundStateContext &context, GraphicsScene &scene)
Single constructor.
BackgroundStateContext & context()
Reference to the BackgroundStateContext that contains all the BackgroundStateAbstractBase subclasses...
Context class that manages the background image state machine.
Add point and line handling to generic QGraphicsScene.
Definition: GraphicsScene.h:25
GraphicsScene & scene()
Reference to the GraphicsScene, without const.