Engauge Digitizer 2
Loading...
Searching...
No Matches
BackgroundStateAbstractBase Class Referenceabstract

Background image state machine state base class. More...

#include <BackgroundStateAbstractBase.h>

Inheritance diagram for BackgroundStateAbstractBase:
Inheritance graph
Collaboration diagram for BackgroundStateAbstractBase:
Collaboration graph

Public Member Functions

 BackgroundStateAbstractBase (BackgroundStateContext &context, GraphicsScene &scene)
 Single constructor.
virtual ~BackgroundStateAbstractBase ()
virtual void begin ()=0
 Method that is called at the exact moment a state is entered. Typically called just after end for the previous state.
BackgroundStateContextcontext ()
 Reference to the BackgroundStateContext that contains all the BackgroundStateAbstractBase subclasses, without const.
const BackgroundStateContextcontext () const
 Reference to the BackgroundStateContext that contains all the BackgroundStateAbstractBase subclasses, without const.
virtual void end ()=0
 Method that is called at the exact moment a state is exited. Typically called just before begin for the next state.
virtual void fitInView (GraphicsView &view)=0
 Zoom so background fills the window.
QImage image () const
 Image for the current state.
QGraphicsPixmapItem & imageItem () const
 Graphics image item for the current state.
GraphicsScenescene ()
 Reference to the GraphicsScene, without const.
const GraphicsScenescene () const
 Reference to the GraphicsScene, without const.
virtual void setCurveSelected (bool isGnuplot, const Transformation &transformation, const DocumentModelGridRemoval &modelGridRemoval, const DocumentModelColorFilter &colorFilter, const QString &curveSelected)=0
 Update the currently selected curve name.
virtual void setPixmap (bool isGnuplot, const Transformation &transformation, const DocumentModelGridRemoval &modelGridRemoval, const DocumentModelColorFilter &modelColorFilter, const QPixmap &pixmap, const QString &curveSelected)=0
 Update the image for this state, after the leaf class processes it appropriately.
virtual QString state () const =0
 State name for debugging.
virtual void updateColorFilter (bool isGnuplot, const Transformation &transformation, const DocumentModelGridRemoval &modelGridRemoval, const DocumentModelColorFilter &modelColorFilter, const QString &curveSelected)=0
 Apply color filter settings.

Protected Member Functions

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.

Detailed Description

Background image state machine state base class.

Definition at line 30 of file BackgroundStateAbstractBase.h.

Constructor & Destructor Documentation

◆ BackgroundStateAbstractBase()

BackgroundStateAbstractBase::BackgroundStateAbstractBase ( BackgroundStateContext & context,
GraphicsScene & scene )

Single constructor.

Definition at line 15 of file BackgroundStateAbstractBase.cpp.

16 :
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}
@ DATA_KEY_GRAPHICS_ITEM_TYPE
Definition DataKey.h:15
@ DATA_KEY_IDENTIFIER
Definition DataKey.h:14
@ GRAPHICS_ITEM_TYPE_IMAGE
const int Z_VALUE_BACKGROUND
Z values for ordering of the various graphics layers, with background at the bottom.
Definition ZValues.cpp:9
GraphicsScene & scene()
Reference to the GraphicsScene, without const.
BackgroundStateContext & context()
Reference to the BackgroundStateContext that contains all the BackgroundStateAbstractBase subclasses,...

◆ ~BackgroundStateAbstractBase()

BackgroundStateAbstractBase::~BackgroundStateAbstractBase ( )
virtual

Definition at line 30 of file BackgroundStateAbstractBase.cpp.

31{
32}

Member Function Documentation

◆ begin()

virtual void BackgroundStateAbstractBase::begin ( )
pure virtual

Method that is called at the exact moment a state is entered. Typically called just after end for the previous state.

Implemented in BackgroundStateCurve, BackgroundStateNone, BackgroundStateOriginal, and BackgroundStateUnloaded.

◆ context() [1/2]

BackgroundStateContext & BackgroundStateAbstractBase::context ( )

Reference to the BackgroundStateContext that contains all the BackgroundStateAbstractBase subclasses, without const.

Definition at line 34 of file BackgroundStateAbstractBase.cpp.

35{
36 return m_context;
37}

◆ context() [2/2]

const BackgroundStateContext & BackgroundStateAbstractBase::context ( ) const

Reference to the BackgroundStateContext that contains all the BackgroundStateAbstractBase subclasses, without const.

Definition at line 39 of file BackgroundStateAbstractBase.cpp.

40{
41 return m_context;
42}

◆ end()

virtual void BackgroundStateAbstractBase::end ( )
pure virtual

Method that is called at the exact moment a state is exited. Typically called just before begin for the next state.

Implemented in BackgroundStateCurve, BackgroundStateNone, BackgroundStateOriginal, and BackgroundStateUnloaded.

◆ fitInView()

virtual void BackgroundStateAbstractBase::fitInView ( GraphicsView & view)
pure virtual

Zoom so background fills the window.

Implemented in BackgroundStateCurve, BackgroundStateNone, BackgroundStateOriginal, and BackgroundStateUnloaded.

◆ image()

QImage BackgroundStateAbstractBase::image ( ) const

Image for the current state.

Definition at line 44 of file BackgroundStateAbstractBase.cpp.

45{
46 return m_image;
47}

◆ imageItem()

QGraphicsPixmapItem & BackgroundStateAbstractBase::imageItem ( ) const

Graphics image item for the current state.

Definition at line 49 of file BackgroundStateAbstractBase.cpp.

50{
51 return *m_imageItem;
52}

◆ scene() [1/2]

GraphicsScene & BackgroundStateAbstractBase::scene ( )

Reference to the GraphicsScene, without const.

Definition at line 54 of file BackgroundStateAbstractBase.cpp.

55{
56 return m_scene;
57}

◆ scene() [2/2]

const GraphicsScene & BackgroundStateAbstractBase::scene ( ) const

Reference to the GraphicsScene, without const.

Definition at line 59 of file BackgroundStateAbstractBase.cpp.

60{
61 return m_scene;
62}

◆ setCurveSelected()

virtual void BackgroundStateAbstractBase::setCurveSelected ( bool isGnuplot,
const Transformation & transformation,
const DocumentModelGridRemoval & modelGridRemoval,
const DocumentModelColorFilter & colorFilter,
const QString & curveSelected )
pure virtual

Update the currently selected curve name.

Implemented in BackgroundStateCurve, BackgroundStateNone, BackgroundStateOriginal, and BackgroundStateUnloaded.

◆ setImageVisible()

void BackgroundStateAbstractBase::setImageVisible ( bool visible)
protected

Show/hide background image.

Definition at line 64 of file BackgroundStateAbstractBase.cpp.

65{
66 m_imageItem->setVisible (visible);
67}

◆ setPixmap()

virtual void BackgroundStateAbstractBase::setPixmap ( bool isGnuplot,
const Transformation & transformation,
const DocumentModelGridRemoval & modelGridRemoval,
const DocumentModelColorFilter & modelColorFilter,
const QPixmap & pixmap,
const QString & curveSelected )
pure virtual

Update the image for this state, after the leaf class processes it appropriately.

Implemented in BackgroundStateCurve, BackgroundStateNone, BackgroundStateOriginal, and BackgroundStateUnloaded.

◆ setProcessedPixmap()

void BackgroundStateAbstractBase::setProcessedPixmap ( const QPixmap & pixmap)
protected

Save the image for this state after it has been processed by the leaf class.

Definition at line 69 of file BackgroundStateAbstractBase.cpp.

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}
#define ENGAUGE_CHECK_PTR(ptr)
Drop in replacement for Q_CHECK_PTR.
log4cpp::Category * mainCat
Definition Logger.cpp:14
#define LOG4CPP_INFO_S(logger)
Definition convenience.h:18

◆ state()

virtual QString BackgroundStateAbstractBase::state ( ) const
pure virtual

◆ updateColorFilter()

virtual void BackgroundStateAbstractBase::updateColorFilter ( bool isGnuplot,
const Transformation & transformation,
const DocumentModelGridRemoval & modelGridRemoval,
const DocumentModelColorFilter & modelColorFilter,
const QString & curveSelected )
pure virtual

Apply color filter settings.

Implemented in BackgroundStateCurve, BackgroundStateNone, BackgroundStateOriginal, and BackgroundStateUnloaded.


The documentation for this class was generated from the following files: