Engauge Digitizer  2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CallbackGatherXThetasInGridLines.cpp
Go to the documentation of this file.
1 /******************************************************************************************************
2  * (C) 2019 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 
8 #include "Document.h"
9 #include "EngaugeAssert.h"
10 #include "ExportAlignLinear.h"
11 #include "ExportAlignLog.h"
12 #include "ExportLayoutFunctions.h"
14 #include "GridLineLimiter.h"
15 #include "Logger.h"
16 #include "MainWindowModel.h"
17 #include "Point.h"
18 #include <qmath.h>
19 
20 const bool NOT_FIRST_CURVE_ONLY = false;
21 
23  const DocumentModelExportFormat &modelExport,
24  const QStringList &curvesIncluded,
25  const Transformation &transformation,
26  const Document &document) :
28  modelExport.extrapolateOutsideEndpoints (),
29  curvesIncluded,
30  transformation)
31 {
32  addGridLines (modelMainWindow,
33  transformation,
34  document);
35 }
36 
37 void CallbackGatherXThetasInGridLines::addGridLines (const MainWindowModel &modelMainWindow,
38  const Transformation &transformation,
39  const Document &document)
40 {
41  DocumentModelGridDisplay gridLines = document.modelGridDisplay();
42 
43  // Prevent overflow
44  GridLineLimiter gridLineLimiter;
45  double startX = document.modelGridDisplay().startX();
46  double stepX = document.modelGridDisplay().stepX();
47  double stopX = document.modelGridDisplay().stopX();
48  gridLineLimiter.limitForXTheta (document,
49  transformation,
50  document.modelCoords(),
51  modelMainWindow,
52  document.modelGridDisplay(),
53  startX,
54  stepX,
55  stopX);
56  if (document.modelCoords().coordScaleXTheta() == COORD_SCALE_LINEAR) {
57  // Linear
58  int countX = qFloor (0.5 + 1 + (stopX - startX) / stepX);
59  for (int i = 0; i < countX; i++) {
60  double x = startX + i * stepX;
61  addGraphX (x);
62  }
63  } else {
64  // Log
65  int countX = qFloor (1.0 + (qLn (stopX) - qLn (startX)) / qLn (stepX));
66  for (int i = 0; i < countX; i++) {
67  double x = startX * qPow (stepX, i);
68  addGraphX (x);
69  }
70  }
71 }
72 
74  const Point &point)
75 {
76  LOG4CPP_DEBUG_S ((*mainCat)) << "CallbackGatherXThetasInGridLines::callback"
77  << " curveName=" << curveName.toLatin1().data()
78  << " point=" << point.identifier().toLatin1().data();
79 
80  updateMinMax (curveName,
81  point);
82 
84 }
double stopX() const
Get method for x grid line upper bound (inclusive).
void limitForXTheta(const Document &document, const Transformation &transformation, const DocumentModelCoords &modelCoords, const MainWindowModel &modelMainWindow, const DocumentModelGridDisplay &modelGrid, double &startX, double &stepX, double &stopX) const
Limit step value for x/theta coordinate. This is a noop if the maximum grid line limit in MainWindowM...
double stepX() const
Get method for x grid line increment.
Model for DlgSettingsGridDisplay and CmdSettingsGridDisplay.
Model for DlgSettingsExportFormat and CmdSettingsExportFormat.
Base callback for collecting X/Theta independent variables, for functions, in preparation for exporti...
DocumentModelCoords modelCoords() const
Get method for DocumentModelCoords.
Definition: Document.cpp:695
void updateMinMax(const QString &curveName, const Point &point)
Update the tracked min and max values for each curve.
double startX() const
Get method for x grid line lower bound (inclusive).
Class that represents one digitized point. The screen-to-graph coordinate transformation is always ex...
Definition: Point.h:25
void addGraphX(double xGraph)
Save one graph x value.
CallbackSearchReturn
Return values for search callback methods.
QString identifier() const
Unique identifier for a specific Point.
Definition: Point.cpp:268
Continue normal execution of the search.
Affine transformation between screen and graph coordinates, based on digitized axis points...
CoordScale coordScaleXTheta() const
Get method for linear/log scale on x/theta.
Model for DlgSettingsMainWindow.
const bool NOT_FIRST_CURVE_ONLY
Storage of one imported image and the data attached to that image.
Definition: Document.h:41
virtual CallbackSearchReturn callback(const QString &curveName, const Point &point)
Callback method.
log4cpp::Category * mainCat
Definition: Logger.cpp:14
DocumentModelGridDisplay modelGridDisplay() const
Get method for DocumentModelGridDisplay.
Definition: Document.cpp:730
CallbackGatherXThetasInGridLines(const MainWindowModel &modelMainWindow, const DocumentModelExportFormat &modelExport, const QStringList &curvesIncluded, const Transformation &transformation, const Document &document)
Single constructor.
Limit the number of grid lines so a bad combination of start/step/stop value will not lead to extreme...
#define LOG4CPP_DEBUG_S(logger)
Definition: convenience.h:20