Engauge Digitizer  2
BackgroundStateContext.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_CONTEXT_H
8 #define BACKGROUND_STATE_CONTEXT_H
9 
10 #include "BackgroundImage.h"
12 #include <QVector>
13 
16 class GraphicsView;
17 class MainWindow;
18 class QGraphicsPixmapItem;
19 class Transformation;
20 
33 {
34  public:
37 
40 
42  void close();
43 
45  void fitInView (GraphicsView &view);
46 
48  QImage imageForCurveState () const;
49 
51  void requestStateTransition (BackgroundState backgroundState);
52 
54  void setBackgroundImage (BackgroundImage backgroundImage);
55 
58  void setCurveSelected (bool isGnuplot,
59  const Transformation &transformation,
60  const DocumentModelGridRemoval &modelGridRemoval,
61  const DocumentModelColorFilter &modelColorFilter,
62  const QString &curveSelected);
63 
65  void setPixmap (bool isGnuplot,
66  const Transformation &transformation,
67  const DocumentModelGridRemoval &modelGridRemoval,
68  const DocumentModelColorFilter &modelColorFilter,
69  const QPixmap &pixmapOriginal,
70  const QString &curveSelected);
71 
73  void updateColorFilter (bool isGnuplot,
74  const Transformation &transformation,
75  const DocumentModelGridRemoval &modelGridRemoval,
76  const DocumentModelColorFilter &colorFilter,
77  const QString &curveSelected);
78 
79  private:
81 
82  void completeRequestedStateTransitionIfExists ();
83 
84  const MainWindow &m_mainWindow;
85 
86  QVector<BackgroundStateAbstractBase*> m_states;
87  BackgroundState m_currentState;
88  BackgroundState m_requestedState; // Same as m_currentState until requestStateTransition is called
89 };
90 
91 #endif // BACKGROUND_STATE_CONTEXT_H
BackgroundStateContext::requestStateTransition
void requestStateTransition(BackgroundState backgroundState)
Initiate state transition to be performed later, when BackgroundState is off the stack.
Definition: BackgroundStateContext.cpp:98
BackgroundState
BackgroundState
Set of possible states of background image.
Definition: BackgroundStateAbstractBase.h:13
BackgroundStateContext::imageForCurveState
QImage imageForCurveState() const
Image for the Curve state, even if the current state is different.
Definition: BackgroundStateContext.cpp:93
BackgroundImage.h
BackgroundStateContext::setBackgroundImage
void setBackgroundImage(BackgroundImage backgroundImage)
Transition to the specified state. This method is used by classes outside of the state machine to tri...
Definition: BackgroundStateContext.cpp:105
BackgroundStateContext::~BackgroundStateContext
~BackgroundStateContext()
Destructor deallocates memory.
Definition: BackgroundStateContext.cpp:38
Transformation
Affine transformation between screen and graph coordinates, based on digitized axis points.
Definition: Transformation.h:30
BackgroundStateAbstractBase.h
DocumentModelColorFilter
Model for DlgSettingsColorFilter and CmdSettingsColorFilter.
Definition: DocumentModelColorFilter.h:20
GraphicsView
QGraphicsView class with event handling added. Typically the events are sent to the active digitizing...
Definition: GraphicsView.h:19
MainWindow
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
Definition: MainWindow.h:90
BackgroundStateContext::updateColorFilter
void updateColorFilter(bool isGnuplot, const Transformation &transformation, const DocumentModelGridRemoval &modelGridRemoval, const DocumentModelColorFilter &colorFilter, const QString &curveSelected)
Apply color filter settings.
Definition: BackgroundStateContext.cpp:172
BackgroundStateContext::fitInView
void fitInView(GraphicsView &view)
Zoom so background fills the window.
Definition: BackgroundStateContext.cpp:72
BackgroundStateContext::setPixmap
void setPixmap(bool isGnuplot, 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.
Definition: BackgroundStateContext.cpp:150
BackgroundImage
BackgroundImage
Background selection.
Definition: BackgroundImage.h:12
DocumentModelGridRemoval
Model for DlgSettingsGridRemoval and CmdSettingsGridRemoval. The settings are unstable until the user...
Definition: DocumentModelGridRemoval.h:16
BackgroundStateContext
Context class that manages the background image state machine.
Definition: BackgroundStateContext.h:31
BackgroundStateContext::close
void close()
Open Document is being closed so remove the background.
Definition: BackgroundStateContext.cpp:43
BackgroundStateContext::setCurveSelected
void setCurveSelected(bool isGnuplot, const Transformation &transformation, const DocumentModelGridRemoval &modelGridRemoval, const DocumentModelColorFilter &modelColorFilter, const QString &curveSelected)
Update the selected curve.
Definition: BackgroundStateContext.cpp:131