Engauge Digitizer  2
BackgroundStateContext.h
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_CONTEXT_H
8 #define BACKGROUND_STATE_CONTEXT_H
9 
10 #include "BackgroundImage.h"
11 #include "BackgroundStateAbstractBase.h"
12 #include <QVector>
13 
16 class GraphicsView;
17 class MainWindow;
18 class QGraphicsPixmapItem;
19 class Transformation;
20 
33 {
34  public:
37 
39  void close();
40 
42  void fitInView (GraphicsView &view);
43 
45  QImage imageForCurveState () const;
46 
48  void requestStateTransition (BackgroundState backgroundState);
49 
51  void setBackgroundImage (BackgroundImage backgroundImage);
52 
55  void setCurveSelected (const Transformation &transformation,
56  const DocumentModelGridRemoval &modelGridRemoval,
57  const DocumentModelColorFilter &modelColorFilter,
58  const QString &curveSelected);
59 
61  void setPixmap (const Transformation &transformation,
62  const DocumentModelGridRemoval &modelGridRemoval,
63  const DocumentModelColorFilter &modelColorFilter,
64  const QPixmap &pixmapOriginal,
65  const QString &curveSelected);
66 
68  void updateColorFilter (const Transformation &transformation,
69  const DocumentModelGridRemoval &modelGridRemoval,
70  const DocumentModelColorFilter &colorFilter,
71  const QString &curveSelected);
72 
73  private:
75 
76  void completeRequestedStateTransitionIfExists ();
77 
78  const MainWindow &m_mainWindow;
79 
80  QVector<BackgroundStateAbstractBase*> m_states;
81  BackgroundState m_currentState;
82  BackgroundState m_requestedState; // Same as m_currentState until requestStateTransition is called
83 };
84 
85 #endif // BACKGROUND_STATE_CONTEXT_H
void setPixmap(const Transformation &transformation, const DocumentModelGridRemoval &modelGridRemoval, const DocumentModelColorFilter &modelColorFilter, const QPixmap &pixmapOriginal, const QString &curveSelected)
Update the images of all states, rather than just the current state.
void updateColorFilter(const Transformation &transformation, const DocumentModelGridRemoval &modelGridRemoval, const DocumentModelColorFilter &colorFilter, const QString &curveSelected)
Apply color filter settings.
void fitInView(GraphicsView &view)
Zoom so background fills the window.
void requestStateTransition(BackgroundState backgroundState)
Initiate state transition to be performed later, when BackgroundState is off the stack.
Affine transformation between screen and graph coordinates, based on digitized axis points...
void setBackgroundImage(BackgroundImage backgroundImage)
Transition to the specified state. This method is used by classes outside of the state machine to tri...
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:20
void close()
Open Document is being closed so remove the background.
void setCurveSelected(const Transformation &transformation, const DocumentModelGridRemoval &modelGridRemoval, const DocumentModelColorFilter &modelColorFilter, const QString &curveSelected)
Update the selected curve.
QImage imageForCurveState() const
Image for the Curve state, even if the current state is different.
Model for DlgSettingsGridRemoval and CmdSettingsGridRemoval. The settings are unstable until the user...
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
Definition: MainWindow.h:89