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

Class that does special logging for GridLog and GridRemoval classes. More...

#include <GridLog.h>

Collaboration diagram for GridLog:
Collaboration graph

Public Member Functions

 GridLog (bool isGnuplot)
 Single constructor. More...
 
virtual ~GridLog ()
 
void showInputPixel (const QPoint &p, double halfWidth)
 Show pixels that are inputs to GridHealer. More...
 
void showOutputScanLinePixel (int x, int y, double radius)
 Show scan line pixel that is the output of GridHealer. More...
 
void showOutputTrapezoid (const QPoint &p0, const QPoint &p1, const QPoint &p2, const QPoint &p3)
 Show trapezoids that are intermediate results in GridHealer. More...
 

Detailed Description

Class that does special logging for GridLog and GridRemoval classes.

Output file is appended to since multiple instances of this class are expected to be used each time this application is executed

Definition at line 16 of file GridLog.h.

Constructor & Destructor Documentation

◆ GridLog()

GridLog::GridLog ( bool  isGnuplot)

Single constructor.

Definition at line 26 of file GridLog.cpp.

26  :
27  m_isGnuplot (isGnuplot),
28  m_logStr (&m_log)
29 {
30  if (m_isGnuplot) {
31 
32  // Show border around region of interest
33  m_logStr << DETAILED_X_MIN << " " << - DETAILED_Y_MIN << "\n";
34  m_logStr << DETAILED_X_MAX << " " << - DETAILED_Y_MIN << "\n";
35  m_logStr << DETAILED_X_MAX << " " << - DETAILED_Y_MAX << "\n";
36  m_logStr << DETAILED_X_MIN << " " << - DETAILED_Y_MAX << "\n";
37  m_logStr << DETAILED_X_MIN << " " << - DETAILED_Y_MIN << "\n";
38  m_logStr << "\n";
39  }
40 }
const int DETAILED_Y_MIN
Definition: GridLog.cpp:23
const int DETAILED_X_MIN
Definition: GridLog.cpp:21
const int DETAILED_Y_MAX
Definition: GridLog.cpp:24
const int DETAILED_X_MAX
Definition: GridLog.cpp:22

◆ ~GridLog()

GridLog::~GridLog ( )
virtual

Definition at line 42 of file GridLog.cpp.

43 {
44  if (m_isGnuplot) {
45 
46  // Save the log stream that has been accumulated in memory
47  QString filename ("grid.gnuplot");
48  QFile file (filename);
49  QTextStream fileStr (&file);
50 
51  std::cout << GNUPLOT_FILE_MESSAGE.toLatin1().data() << filename.toLatin1().data() << "\n";
52 
53  file.open (QIODevice::WriteOnly | QIODevice::Append);
54  fileStr << m_log;
55  file.close ();
56  }
57 }
const QString GNUPLOT_FILE_MESSAGE

Member Function Documentation

◆ showInputPixel()

void GridLog::showInputPixel ( const QPoint &  p,
double  halfWidth 
)

Show pixels that are inputs to GridHealer.

Definition at line 68 of file GridLog.cpp.

70 {
71  int x = p.x();
72  int y = p.y();
73 
74  if (DETAILED_X_MIN <= x &&
75  DETAILED_Y_MIN <= y &&
76  x <= DETAILED_X_MAX &&
77  y <= DETAILED_Y_MAX) {
78 
79  m_logStr << x - halfWidth << " " << - (y - halfWidth) << "\n";
80  m_logStr << x + halfWidth << " " << - (y - halfWidth) << "\n";
81  m_logStr << x + halfWidth << " " << - (y + halfWidth) << "\n";
82  m_logStr << x - halfWidth << " " << - (y + halfWidth) << "\n";
83  m_logStr << x - halfWidth << " " << - (y - halfWidth) << "\n";
84  m_logStr << "\n";
85  }
86 }
const int DETAILED_Y_MIN
Definition: GridLog.cpp:23
const int DETAILED_X_MIN
Definition: GridLog.cpp:21
const int DETAILED_Y_MAX
Definition: GridLog.cpp:24
const int DETAILED_X_MAX
Definition: GridLog.cpp:22

◆ showOutputScanLinePixel()

void GridLog::showOutputScanLinePixel ( int  x,
int  y,
double  radius 
)

Show scan line pixel that is the output of GridHealer.

Definition at line 88 of file GridLog.cpp.

91 {
92  if (m_isGnuplot && inBounds (x, y)) {
93 
94  // Draw a diamond
95  m_logStr << x << " " << - (y - radius) << "\n";
96  m_logStr << x + radius << " " << - (y ) << "\n";
97  m_logStr << x << " " << - (y + radius) << "\n";
98  m_logStr << x - radius << " " << - (y ) << "\n";
99  m_logStr << x << " " << - (y - radius) << "\n";
100  m_logStr << "\n";
101  }
102 }

◆ showOutputTrapezoid()

void GridLog::showOutputTrapezoid ( const QPoint &  p0,
const QPoint &  p1,
const QPoint &  p2,
const QPoint &  p3 
)

Show trapezoids that are intermediate results in GridHealer.

Definition at line 104 of file GridLog.cpp.

108 {
109  if (m_isGnuplot) {
110 
111  // Log if any pixel is in the region of interest
112  if (inBounds (p0.x(), p0.y()) ||
113  inBounds (p1.x(), p1.y()) ||
114  inBounds (p2.x(), p2.y()) ||
115  inBounds (p3.x(), p3.y())) {
116 
117  m_logStr << p0.x() << " " << - p0.y() << "\n";
118  m_logStr << p1.x() << " " << - p1.y() << "\n";
119  m_logStr << p2.x() << " " << - p2.y() << "\n";
120  m_logStr << p3.x() << " " << - p3.y() << "\n";
121  m_logStr << p0.x() << " " << - p0.y() << "\n";
122  m_logStr << "\n";
123  }
124  }
125 }

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