Engauge Digitizer  2
BackgroundStateAbstractBase.h
1 #ifndef BACKGROUND_STATE_ABSTRACT_BASE_H
2 #define BACKGROUND_STATE_ABSTRACT_BASE_H
3 
4 #include <QGraphicsPixmapItem>
5 #include <QImage>
6 
8 enum BackgroundState {
9  BACKGROUND_STATE_CURVE,
10  BACKGROUND_STATE_NONE,
11  BACKGROUND_STATE_ORIGINAL,
12  BACKGROUND_STATE_UNLOADED,
13  NUM_BACKGROUND_STATES
14 };
15 
19 class GraphicsScene;
20 class GraphicsView;
21 class Transformation;
22 
25 {
26  public:
31 
33  virtual void begin() = 0;
34 
37 
39  const BackgroundStateContext &context() const;
40 
42  virtual void end() = 0;
43 
45  virtual void fitInView (GraphicsView &view) = 0;
46 
48  QImage image () const;
49 
51  QGraphicsPixmapItem &imageItem () const;
52 
55 
57  const GraphicsScene &scene() const;
58 
60  virtual void setCurveSelected (const Transformation &transformation,
61  const DocumentModelGridRemoval &modelGridRemoval,
62  const DocumentModelColorFilter &colorFilter,
63  const QString &curveSelected) = 0;
64 
66  virtual void setPixmap (const Transformation &transformation,
67  const DocumentModelGridRemoval &modelGridRemoval,
68  const DocumentModelColorFilter &modelColorFilter,
69  const QPixmap &pixmap) = 0;
70 
72  virtual QString state() const = 0;
73 
75  virtual void updateColorFilter (const Transformation &transformation,
76  const DocumentModelGridRemoval &modelGridRemoval,
77  const DocumentModelColorFilter &modelColorFilter) = 0;
78 
79  protected:
80 
82  void setImageVisible (bool visible);
83 
85  void setProcessedPixmap (const QPixmap &pixmap);
86 
87  private:
89 
90  BackgroundStateContext &m_context;
91  GraphicsScene &m_scene;
92 
93  // 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,
94  // so we can eliminate a dependency on the ordering of the state transitions and the update of the image by setPixmap
95  QGraphicsPixmapItem *m_imageItem;
96 
97  QImage m_image; // Original image. This is stored in addition to m_imageItem since m_imageItem cannot be used when invisible
98 };
99 
100 #endif // BACKGROUND_STATE_ABSTRACT_BASE_H
QImage image() const
Image for the current state.
virtual void updateColorFilter(const Transformation &transformation, const DocumentModelGridRemoval &modelGridRemoval, const DocumentModelColorFilter &modelColorFilter)=0
Apply color filter settings.
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.
virtual void fitInView(GraphicsView &view)=0
Zoom so background fills the window.
BackgroundStateContext & context()
Reference to the BackgroundStateContext that contains all the BackgroundStateAbstractBase subclasses...
virtual QString state() const =0
State name for debugging.
virtual void setPixmap(const Transformation &transformation, const DocumentModelGridRemoval &modelGridRemoval, const DocumentModelColorFilter &modelColorFilter, const QPixmap &pixmap)=0
Update the image for this state, after the leaf class processes it appropriately. ...
virtual void begin()=0
Method that is called at the exact moment a state is entered. Typically called just after end for the...
Affine transformation between screen and graph coordinates, based on digitized axis points...
virtual void end()=0
Method that is called at the exact moment a state is exited. Typically called just before begin for t...
Model for DlgSettingsColorFilter and CmdSettingsColorFilter.
Context class that manages the background image state machine.
QGraphicsView class with event handling added. Typically the events are sent to the active digitizing...
Definition: GraphicsView.h:14
Background image state machine state base class.
virtual void setCurveSelected(const Transformation &transformation, const DocumentModelGridRemoval &modelGridRemoval, const DocumentModelColorFilter &colorFilter, const QString &curveSelected)=0
Update the currently selected curve name.
Add point and line handling to generic QGraphicsScene.
Definition: GraphicsScene.h:25
GraphicsScene & scene()
Reference to the GraphicsScene, without const.
Model for DlgSettingsGridRemoval and CmdSettingsGridRemoval. The settings are unstable until the user...