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,
26 const Document &document) :
28 modelExport.extrapolateOutsideEndpoints (),
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 unsigned int numX = document.modelGridDisplay().countX();
49 gridLineLimiter.limitForXTheta (document,
51 document.modelCoords(),
52 modelMainWindow,
53 startX,
54 stepX,
55 stopX,
56 numX);
58 // Linear
59 int countX = qFloor (0.5 + 1 + (stopX - startX) / stepX);
60 for (int i = 0; i < countX; i++) {
61 double x = startX + i * stepX;
62 addGraphX (x);
63 }
64 } else {
65 // Log
66 int countX = qFloor (1.0 + (qLn (stopX) - qLn (startX)) / qLn (stepX));
67 for (int i = 0; i < countX; i++) {
68 double x = startX * qPow (stepX, i);
69 addGraphX (x);
70 }
71 }
72}
73
75 const Point &point)
76{
77 LOG4CPP_DEBUG_S ((*mainCat)) << "CallbackGatherXThetasInGridLines::callback"
78 << " curveName=" << curveName.toLatin1().data()
79 << " point=" << point.identifier().toLatin1().data();
80
81 updateMinMax (curveName,
82 point);
83
85}
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
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.
QStringList curvesIncluded() const
Get method for included names.
CallbackGatherXThetasAbstractBase(bool firstCurveOnly, bool extrapolateOutsideEndpoints, const QStringList &curvesIncluded, const Transformation &transformation)
Single constructor.
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.
unsigned int countX() const
Get method for x grid line count.
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:44
DocumentModelCoords modelCoords() const
Get method for DocumentModelCoords.
Definition Document.cpp:707
DocumentModelGridDisplay modelGridDisplay() const
Get method for DocumentModelGridDisplay.
Definition Document.cpp:742
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, double &startX, double &stepX, double &stopX, unsigned int numX) 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