Engauge Digitizer  2
Public Member Functions | List of all members
GridRemoval Class Reference

Strategy class for grid removal. More...

#include <GridRemoval.h>

Collaboration diagram for GridRemoval:
Collaboration graph

Public Member Functions

 GridRemoval (bool isGnuplot)
 Single constructor. More...
 
QPixmap remove (const Transformation &transformation, const DocumentModelGridRemoval &modelGridRemoval, const QImage &imageBefore)
 Process QImage into QPixmap, removing the grid lines. More...
 

Detailed Description

Strategy class for grid removal.

Definition at line 24 of file GridRemoval.h.

Constructor & Destructor Documentation

◆ GridRemoval()

GridRemoval::GridRemoval ( bool  isGnuplot)

Single constructor.

Definition at line 20 of file GridRemoval.cpp.

20  :
21  m_gridLog (isGnuplot)
22 {
23 }

Member Function Documentation

◆ remove()

QPixmap GridRemoval::remove ( const Transformation transformation,
const DocumentModelGridRemoval modelGridRemoval,
const QImage &  imageBefore 
)

Process QImage into QPixmap, removing the grid lines.

Definition at line 53 of file GridRemoval.cpp.

56 {
57  LOG4CPP_INFO_S ((*mainCat)) << "GridRemoval::remove"
58  << " transformationIsDefined=" << (transformation.transformIsDefined() ? "true" : "false")
59  << " removeDefinedGridLines=" << (modelGridRemoval.removeDefinedGridLines() ? "true" : "false");
60 
61  QImage image = imageBefore;
62 
63  // Collect GridHealers instances, one per grid line
64  GridHealers gridHealers;
65 
66  // Make sure grid line removal is wanted, and possible. Otherwise all processing is skipped
67  if (modelGridRemoval.removeDefinedGridLines() &&
68  transformation.transformIsDefined()) {
69 
70  double yGraphMin = modelGridRemoval.startY();
71  double yGraphMax = modelGridRemoval.stopY();
72  for (int i = 0; i < modelGridRemoval.countX(); i++) {
73  double xGraph = modelGridRemoval.startX() + i * modelGridRemoval.stepX();
74 
75  // Convert line between graph coordinates (xGraph,yGraphMin) and (xGraph,yGraphMax) to screen coordinates
76  QPointF posScreenMin, posScreenMax;
77  transformation.transformRawGraphToScreen (QPointF (xGraph,
78  yGraphMin),
79  posScreenMin);
80  transformation.transformRawGraphToScreen (QPointF (xGraph,
81  yGraphMax),
82  posScreenMax);
83 
84  removeLine (posScreenMin,
85  posScreenMax,
86  image,
87  modelGridRemoval,
88  gridHealers);
89  }
90 
91  double xGraphMin = modelGridRemoval.startX();
92  double xGraphMax = modelGridRemoval.stopX();
93  for (int j = 0; j < modelGridRemoval.countY(); j++) {
94  double yGraph = modelGridRemoval.startY() + j * modelGridRemoval.stepY();
95 
96  // Convert line between graph coordinates (xGraphMin,yGraph) and (xGraphMax,yGraph) to screen coordinates
97  QPointF posScreenMin, posScreenMax;
98  transformation.transformRawGraphToScreen (QPointF (xGraphMin,
99  yGraph),
100  posScreenMin);
101  transformation.transformRawGraphToScreen (QPointF (xGraphMax,
102  yGraph),
103  posScreenMax);
104 
105  removeLine (posScreenMin,
106  posScreenMax,
107  image,
108  modelGridRemoval,
109  gridHealers);
110  }
111 
112  // Heal the broken lines now that all grid lines have been removed and the image has stabilized
113  GridHealers::iterator itr;
114  for (itr = gridHealers.begin(); itr != gridHealers.end(); itr++) {
115  GridHealerAbstractBase *gridHealer = *itr;
116  gridHealer->healed (image);
117  delete gridHealer;
118  }
119  }
120 
121  return QPixmap::fromImage (image);
122 }
double stopY() const
Get method for y stop.
double stopX() const
Get method for x stop.
int countY() const
Get method for y count.
double startY() const
Get method for y start.
void transformRawGraphToScreen(const QPointF &pointRaw, QPointF &pointScreen) const
Transform from raw graph coordinates to linear cartesian graph coordinates, then to screen coordinate...
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
void healed(QImage &image)
Return healed image after grid removal.
double stepX() const
Get method for x step.
Class that &#39;heals&#39; the curves after one grid line has been removed.
bool removeDefinedGridLines() const
Get method for removing defined grid lines.
bool transformIsDefined() const
Transform is defined when at least three axis points have been digitized.
log4cpp::Category * mainCat
Definition: Logger.cpp:14
int countX() const
Get method for x count.
double startX() const
Get method for x start.
QList< GridHealerAbstractBase * > GridHealers
Storage of GridHealer instances.
Definition: GridRemoval.h:18
double stepY() const
Get method for y step.

The documentation for this class was generated from the following files: