Engauge Digitizer 2
Loading...
Searching...
No Matches
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
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
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");
28}
29
33
38
40{
41 return m_context;
42}
43
45{
46 return m_image;
47}
48
49QGraphicsPixmapItem &BackgroundStateAbstractBase::imageItem () const
50{
51 return *m_imageItem;
52}
53
58
60{
61 return m_scene;
62}
63
65{
66 m_imageItem->setVisible (visible);
67}
68
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}
@ DATA_KEY_GRAPHICS_ITEM_TYPE
Definition DataKey.h:15
@ DATA_KEY_IDENTIFIER
Definition DataKey.h:14
#define ENGAUGE_CHECK_PTR(ptr)
Drop in replacement for Q_CHECK_PTR.
@ GRAPHICS_ITEM_TYPE_IMAGE
log4cpp::Category * mainCat
Definition Logger.cpp:14
const int Z_VALUE_BACKGROUND
Z values for ordering of the various graphics layers, with background at the bottom.
Definition ZValues.cpp:9
BackgroundStateAbstractBase(BackgroundStateContext &context, GraphicsScene &scene)
Single constructor.
QGraphicsPixmapItem & imageItem() const
Graphics image item for the current state.
GraphicsScene & scene()
Reference to the GraphicsScene, without const.
BackgroundStateContext & context()
Reference to the BackgroundStateContext that contains all the BackgroundStateAbstractBase subclasses,...
void setImageVisible(bool visible)
Show/hide background image.
QImage image() const
Image for the current state.
void setProcessedPixmap(const QPixmap &pixmap)
Save the image for this state after it has been processed by the leaf class.
Context class that manages the background image state machine.
Add point and line handling to generic QGraphicsScene.
#define LOG4CPP_INFO_S(logger)
Definition convenience.h:18