00001
00002
00003
00004
00005
00006
00007 #include "BackgroundStateContext.h"
00008 #include "BackgroundStateCurve.h"
00009 #include "DocumentModelColorFilter.h"
00010 #include "DocumentModelGridRemoval.h"
00011 #include "FilterImage.h"
00012 #include "GraphicsScene.h"
00013 #include "GraphicsView.h"
00014 #include "Logger.h"
00015 #include <QPixmap>
00016 #include "Transformation.h"
00017
00018 BackgroundStateCurve::BackgroundStateCurve(BackgroundStateContext &context,
00019 GraphicsScene &scene) :
00020 BackgroundStateAbstractBase(context,
00021 scene)
00022 {
00023 }
00024
00025 void BackgroundStateCurve::begin()
00026 {
00027 LOG4CPP_INFO_S ((*mainCat)) << "BackgroundStateCurve::begin";
00028
00029 setImageVisible (true);
00030 }
00031
00032 void BackgroundStateCurve::end()
00033 {
00034 LOG4CPP_INFO_S ((*mainCat)) << "BackgroundStateCurve::end";
00035
00036 setImageVisible (false);
00037 }
00038
00039 void BackgroundStateCurve::fitInView (GraphicsView &view)
00040 {
00041 LOG4CPP_INFO_S ((*mainCat)) << "BackgroundStateCurve::fitInView";
00042
00043 view.fitInView (imageItem ().boundingRect());
00044 }
00045
00046 void BackgroundStateCurve::processImageFromSavedInputs (const Transformation &transformation,
00047 const DocumentModelGridRemoval &modelGridRemoval,
00048 const DocumentModelColorFilter &modelColorFilter,
00049 const QString &curveSelected)
00050 {
00051 LOG4CPP_INFO_S ((*mainCat)) << "BackgroundStateCurve::processImageFromSavedInputs";
00052
00053
00054 if (!curveSelected.isEmpty()) {
00055
00056
00057 FilterImage filterImage;
00058 QPixmap pixmapFiltered = filterImage.filter (m_pixmapOriginal.toImage(),
00059 transformation,
00060 curveSelected,
00061 modelColorFilter,
00062 modelGridRemoval);
00063
00064 setProcessedPixmap (pixmapFiltered);
00065
00066 } else {
00067
00068
00069 setProcessedPixmap (m_pixmapOriginal);
00070
00071 }
00072 }
00073
00074 void BackgroundStateCurve::setCurveSelected (const Transformation &transformation,
00075 const DocumentModelGridRemoval &modelGridRemoval,
00076 const DocumentModelColorFilter &modelColorFilter,
00077 const QString &curveSelected)
00078 {
00079 LOG4CPP_INFO_S ((*mainCat)) << "BackgroundStateCurve::setCurveSelected"
00080 << " curve=" << curveSelected.toLatin1().data();
00081
00082
00083
00084 processImageFromSavedInputs (transformation,
00085 modelGridRemoval,
00086 modelColorFilter,
00087 curveSelected);
00088 }
00089
00090 void BackgroundStateCurve::setPixmap (const Transformation &transformation,
00091 const DocumentModelGridRemoval &modelGridRemoval,
00092 const DocumentModelColorFilter &modelColorFilter,
00093 const QPixmap &pixmapOriginal,
00094 const QString &curveSelected)
00095 {
00096 LOG4CPP_INFO_S ((*mainCat)) << "BackgroundStateCurve::setPixmap";
00097
00098 m_pixmapOriginal = pixmapOriginal;
00099 processImageFromSavedInputs (transformation,
00100 modelGridRemoval,
00101 modelColorFilter,
00102 curveSelected);
00103 }
00104
00105 QString BackgroundStateCurve::state () const
00106 {
00107 return "BackgroundStateCurve";
00108 }
00109
00110 void BackgroundStateCurve::updateColorFilter (const Transformation &transformation,
00111 const DocumentModelGridRemoval &modelGridRemoval,
00112 const DocumentModelColorFilter &modelColorFilter,
00113 const QString &curveSelected)
00114 {
00115 LOG4CPP_INFO_S ((*mainCat)) << "BackgroundStateCurve::updateColorFilter";
00116
00117 processImageFromSavedInputs (transformation,
00118 modelGridRemoval,
00119 modelColorFilter,
00120 curveSelected);
00121 }