Engauge Digitizer  2
BackgroundStateNone.cpp
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 #include "BackgroundStateContext.h"
8 #include "BackgroundStateNone.h"
9 #include "DocumentModelColorFilter.h"
10 #include "DocumentModelGridRemoval.h"
11 #include "GraphicsScene.h"
12 #include "GraphicsView.h"
13 #include "Logger.h"
14 #include <QPixmap>
15 
17  GraphicsScene &scene) :
19  scene)
20 {
21 }
22 
24 {
25  LOG4CPP_INFO_S ((*mainCat)) << "BackgroundStateNone::begin";
26 
27  setImageVisible (true);
28 }
29 
31 {
32  LOG4CPP_INFO_S ((*mainCat)) << "BackgroundStateNone::end";
33 
34  setImageVisible (false);
35 }
36 
38 {
39  LOG4CPP_INFO_S ((*mainCat)) << "BackgroundStateNone::fitInView";
40 
41  view.fitInView (imageItem ().boundingRect());
42 }
43 
44 void BackgroundStateNone::setCurveSelected (const Transformation & /* transformation */,
45  const DocumentModelGridRemoval & /* modelGridRemoval */,
46  const DocumentModelColorFilter & /* modelColorFilter */,
47  const QString & /* curveSelected */)
48 {
49  LOG4CPP_INFO_S ((*mainCat)) << "BackgroundStateNone::setCurveSelected";
50 }
51 
52 void BackgroundStateNone::setPixmap (const Transformation & /* transformation */,
53  const DocumentModelGridRemoval & /* modelGridRemoval */,
54  const DocumentModelColorFilter & /* modelColorFilter */,
55  const QPixmap &pixmapOriginal,
56  const QString & /* curveSelected */)
57 {
58  LOG4CPP_INFO_S ((*mainCat)) << "BackgroundStateNone::setPixmap";
59 
60  // Empty background
61  QPixmap pixmapNone (pixmapOriginal);
62  pixmapNone.fill (Qt::white);
63  setProcessedPixmap (pixmapNone);
64 
65 }
66 
68 {
69  return "BackgroundStateNone";
70 }
71 
72 void BackgroundStateNone::updateColorFilter (const Transformation & /* transformation */,
73  const DocumentModelGridRemoval & /* modelGridRemoval */,
74  const DocumentModelColorFilter & /* modelColorFilter */,
75  const QString & /* curveSelected */)
76 {
77  LOG4CPP_INFO_S ((*mainCat)) << "BackgroundStateNone::updateColorFilter";
78 }
virtual void setCurveSelected(const Transformation &transformation, const DocumentModelGridRemoval &modelGridRemoval, const DocumentModelColorFilter &colorFilter, const QString &curveSelected)
Update the currently selected curve name.
virtual void end()
Method that is called at the exact moment a state is exited. Typically called just before begin for t...
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.
Affine transformation between screen and graph coordinates, based on digitized axis points...
Model for DlgSettingsColorFilter and CmdSettingsColorFilter.
BackgroundStateNone(BackgroundStateContext &context, GraphicsScene &scene)
Single constructor.
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
virtual void updateColorFilter(const Transformation &transformation, const DocumentModelGridRemoval &modelGridRemoval, const DocumentModelColorFilter &colorFilter, const QString &curveSelected)
Apply color filter settings.
Background image state machine state base class.
virtual void fitInView(GraphicsView &view)
Zoom so background fills the window.
virtual void begin()
Method that is called at the exact moment a state is entered. Typically called just after end for the...
virtual void setPixmap(const Transformation &transformation, const DocumentModelGridRemoval &modelGridRemoval, const DocumentModelColorFilter &modelColorFilter, const QPixmap &pixmap, const QString &curveSelected)
Update the image for this state, after the leaf class processes it appropriately. ...
virtual QString state() const
State name for debugging.
Add point and line handling to generic QGraphicsScene.
Definition: GraphicsScene.h:31
Model for DlgSettingsGridRemoval and CmdSettingsGridRemoval. The settings are unstable until the user...