Engauge Digitizer  2
BackgroundStateAbstractBase.h
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 #ifndef BACKGROUND_STATE_ABSTRACT_BASE_H
8 #define BACKGROUND_STATE_ABSTRACT_BASE_H
9 
10 #include <QGraphicsPixmapItem>
11 #include <QImage>
12 
14 enum BackgroundState {
20 };
21 
25 class GraphicsScene;
26 class GraphicsView;
27 class Transformation;
28 
31 {
32  public:
37 
39  virtual void begin() = 0;
40 
43 
45  const BackgroundStateContext &context() const;
46 
48  virtual void end() = 0;
49 
51  virtual void fitInView (GraphicsView &view) = 0;
52 
54  QImage image () const;
55 
57  QGraphicsPixmapItem &imageItem () const;
58 
61 
63  const GraphicsScene &scene() const;
64 
66  virtual void setCurveSelected (bool isGnuplot,
67  const Transformation &transformation,
68  const DocumentModelGridRemoval &modelGridRemoval,
69  const DocumentModelColorFilter &colorFilter,
70  const QString &curveSelected) = 0;
71 
73  virtual void setPixmap (bool isGnuplot,
74  const Transformation &transformation,
75  const DocumentModelGridRemoval &modelGridRemoval,
76  const DocumentModelColorFilter &modelColorFilter,
77  const QPixmap &pixmap,
78  const QString &curveSelected) = 0;
79 
81  virtual QString state() const = 0;
82 
84  virtual void updateColorFilter (bool isGnuplot,
85  const Transformation &transformation,
86  const DocumentModelGridRemoval &modelGridRemoval,
87  const DocumentModelColorFilter &modelColorFilter,
88  const QString &curveSelected) = 0;
89 
90  protected:
91 
93  void setImageVisible (bool visible);
94 
96  void setProcessedPixmap (const QPixmap &pixmap);
97 
98  private:
100 
101  BackgroundStateContext &m_context;
102  GraphicsScene &m_scene;
103 
104  // Each state has its own image, although only one is shown at a time. This is null if an image has not been defined yet,
105  // so we can eliminate a dependency on the ordering of the state transitions and the update of the image by setPixmap
106  QGraphicsPixmapItem *m_imageItem;
107 
108  QImage m_image; // Original image. This is stored in addition to m_imageItem since m_imageItem cannot be used when invisible
109 };
110 
111 #endif // BACKGROUND_STATE_ABSTRACT_BASE_H
BackgroundStateAbstractBase::~BackgroundStateAbstractBase
virtual ~BackgroundStateAbstractBase()
Definition: BackgroundStateAbstractBase.cpp:30
BACKGROUND_STATE_ORIGINAL
Definition: BackgroundStateAbstractBase.h:19
NUM_BACKGROUND_STATES
Definition: BackgroundStateAbstractBase.h:21
BackgroundStateAbstractBase::setImageVisible
void setImageVisible(bool visible)
Show/hide background image.
Definition: BackgroundStateAbstractBase.cpp:64
BackgroundState
BackgroundState
Set of possible states of background image.
Definition: BackgroundStateAbstractBase.h:13
Transformation
Affine transformation between screen and graph coordinates, based on digitized axis points.
Definition: Transformation.h:30
BackgroundStateAbstractBase::setCurveSelected
virtual void setCurveSelected(bool isGnuplot, const Transformation &transformation, const DocumentModelGridRemoval &modelGridRemoval, const DocumentModelColorFilter &colorFilter, const QString &curveSelected)=0
Update the currently selected curve name.
DocumentModelColorFilter
Model for DlgSettingsColorFilter and CmdSettingsColorFilter.
Definition: DocumentModelColorFilter.h:20
BackgroundStateAbstractBase::imageItem
QGraphicsPixmapItem & imageItem() const
Graphics image item for the current state.
Definition: BackgroundStateAbstractBase.cpp:49
BackgroundStateAbstractBase
Background image state machine state base class.
Definition: BackgroundStateAbstractBase.h:29
GraphicsView
QGraphicsView class with event handling added. Typically the events are sent to the active digitizing...
Definition: GraphicsView.h:19
BACKGROUND_STATE_CURVE
Definition: BackgroundStateAbstractBase.h:17
GraphicsScene
Add point and line handling to generic QGraphicsScene.
Definition: GraphicsScene.h:35
BackgroundStateAbstractBase::context
BackgroundStateContext & context()
Reference to the BackgroundStateContext that contains all the BackgroundStateAbstractBase subclasses,...
Definition: BackgroundStateAbstractBase.cpp:34
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
BACKGROUND_STATE_UNLOADED
Definition: BackgroundStateAbstractBase.h:20
BACKGROUND_STATE_NONE
Definition: BackgroundStateAbstractBase.h:18
BackgroundStateAbstractBase::end
virtual void end()=0
Method that is called at the exact moment a state is exited. Typically called just before begin for t...
BackgroundStateAbstractBase::scene
GraphicsScene & scene()
Reference to the GraphicsScene, without const.
Definition: BackgroundStateAbstractBase.cpp:54
BackgroundStateAbstractBase::begin
virtual void begin()=0
Method that is called at the exact moment a state is entered. Typically called just after end for the...
BackgroundStateAbstractBase::state
virtual QString state() const =0
State name for debugging.
BackgroundStateAbstractBase::setPixmap
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.
DocumentModelGridRemoval
Model for DlgSettingsGridRemoval and CmdSettingsGridRemoval. The settings are unstable until the user...
Definition: DocumentModelGridRemoval.h:16
BackgroundStateAbstractBase::image
QImage image() const
Image for the current state.
Definition: BackgroundStateAbstractBase.cpp:44
BackgroundStateAbstractBase::updateColorFilter
virtual void updateColorFilter(bool isGnuplot, const Transformation &transformation, const DocumentModelGridRemoval &modelGridRemoval, const DocumentModelColorFilter &modelColorFilter, const QString &curveSelected)=0
Apply color filter settings.
BackgroundStateAbstractBase::fitInView
virtual void fitInView(GraphicsView &view)=0
Zoom so background fills the window.
BackgroundStateContext
Context class that manages the background image state machine.
Definition: BackgroundStateContext.h:31