Engauge Digitizer 2
Loading...
Searching...
No Matches
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
21
25class GraphicsScene;
26class GraphicsView;
27class 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
BackgroundState
Set of possible states of background image.
@ BACKGROUND_STATE_UNLOADED
@ BACKGROUND_STATE_ORIGINAL
Background image state machine state base class.
QGraphicsPixmapItem & imageItem() const
Graphics image item for the current state.
virtual void end()=0
Method that is called at the exact moment a state is exited. Typically called just before begin for t...
GraphicsScene & scene()
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.
BackgroundStateContext & context()
Reference to the BackgroundStateContext that contains all the BackgroundStateAbstractBase subclasses,...
virtual void updateColorFilter(bool isGnuplot, const Transformation &transformation, const DocumentModelGridRemoval &modelGridRemoval, const DocumentModelColorFilter &modelColorFilter, const QString &curveSelected)=0
Apply color filter settings.
virtual QString state() const =0
State name for debugging.
void setImageVisible(bool visible)
Show/hide background image.
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.
QImage image() const
Image for the current state.
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.
virtual void begin()=0
Method that is called at the exact moment a state is entered. Typically called just after end for the...
Context class that manages the background image state machine.
Model for DlgSettingsColorFilter and CmdSettingsColorFilter.
Model for DlgSettingsGridRemoval and CmdSettingsGridRemoval. The settings are unstable until the user...
Add point and line handling to generic QGraphicsScene.
QGraphicsView class with event handling added. Typically the events are sent to the active digitizing...
Affine transformation between screen and graph coordinates, based on digitized axis points.