Engauge Digitizer 2
Loading...
Searching...
No Matches
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"
14#include "GridLineLimiter.h"
15#include "Logger.h"
16#include "MainWindowModel.h"
17#include "Point.h"
18#include <qmath.h>
19
20const 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,
34 document);
35}
36
37void 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,
50 document.modelCoords(),
51 modelMainWindow,
52 document.modelGridDisplay(),
53 startX,
54 stepX,
55 stopX);
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}
const bool NOT_FIRST_CURVE_ONLY
CallbackSearchReturn
Return values for search callback methods.
@ CALLBACK_SEARCH_RETURN_CONTINUE
Continue normal execution of the search.
@ COORD_SCALE_LINEAR
Definition CoordScale.h:13
log4cpp::Category * mainCat
Definition Logger.cpp:14
Base callback for collecting X/Theta independent variables, for functions, in preparation for exporti...
const Transformation & transformation() const
Get method for transformation.
void updateMinMax(const QString &curveName, const Point &point)
Update the tracked min and max values for each curve.
void addGraphX(double xGraph)
Save one graph x value.
CallbackGatherXThetasInGridLines(const MainWindowModel &modelMainWindow, const DocumentModelExportFormat &modelExport, const QStringList &curvesIncluded, const Transformation &transformation, const Document &document)
Single constructor.
virtual CallbackSearchReturn callback(const QString &curveName, const Point &point)
Callback method.
CoordScale coordScaleXTheta() const
Get method for linear/log scale on x/theta.
Model for DlgSettingsExportFormat and CmdSettingsExportFormat.
Model for DlgSettingsGridDisplay and CmdSettingsGridDisplay.
double startX() const
Get method for x grid line lower bound (inclusive).
double stepX() const
Get method for x grid line increment.
double stopX() const
Get method for x grid line upper bound (inclusive).
Storage of one imported image and the data attached to that image.
Definition Document.h:42
DocumentModelCoords modelCoords() const
Get method for DocumentModelCoords.
Definition Document.cpp:695
DocumentModelGridDisplay modelGridDisplay() const
Get method for DocumentModelGridDisplay.
Definition Document.cpp:730
Limit the number of grid lines so a bad combination of start/step/stop value will not lead to extreme...
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...
Model for DlgSettingsMainWindow.
Class that represents one digitized point. The screen-to-graph coordinate transformation is always ex...
Definition Point.h:26
QString identifier() const
Unique identifier for a specific Point.
Definition Point.cpp:268
Affine transformation between screen and graph coordinates, based on digitized axis points.
#define LOG4CPP_DEBUG_S(logger)
Definition convenience.h:20