Engauge Digitizer  2
CallbackScaleBar.cpp
1 /******************************************************************************************************
2  * (C) 2017 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 
7 #include "CallbackScaleBar.h"
8 #include "Curve.h"
9 #include "DocumentModelExportFormat.h"
10 #include "ExportAlignLinear.h"
11 #include "ExportAlignLog.h"
12 #include "ExportLayoutFunctions.h"
13 #include "ExportPointsSelectionFunctions.h"
14 #include "Logger.h"
15 #include "Point.h"
16 
18  m_scaleBarLength (0)
19 {
20 }
21 
23 {
24  return m_axisCurvePointIdentifiers;
25 }
26 
27 CallbackSearchReturn CallbackScaleBar::callback (const QString &curveName,
28  const Point &point)
29 {
30  LOG4CPP_DEBUG_S ((*mainCat)) << "CallbackScaleBar::callback"
31  << " curveName=" << curveName.toLatin1().data()
32  << " point=" << point.identifier().toLatin1().data();
33 
34  if (curveName == AXIS_CURVE_NAME) {
35 
36  bool isNonzeroX = (point.posGraph ().x () != 0);
37  bool isNonzeroY = (point.posGraph ().y () != 0);
38 
39  if (isNonzeroX || isNonzeroY) {
40 
41  m_scaleBarPointIdentifier = point.identifier ();
42  m_scaleBarLength = (isNonzeroX ?
43  point.posGraph ().x () :
44  point.posGraph ().y ());
45  }
46 
47  m_axisCurvePointIdentifiers << point.identifier ();
48  }
49 
50  return CALLBACK_SEARCH_RETURN_CONTINUE;
51 }
52 
54 {
55  return m_scaleBarLength;
56 }
57 
59 {
60  LOG4CPP_INFO_S ((*mainCat)) << "CallbackScaleBar::scaleBarPointIdentifier";
61 
62  return m_scaleBarPointIdentifier;
63 }
CallbackSearchReturn callback(const QString &curveName, const Point &point)
Callback method.
QString scaleBarPointIdentifier() const
Identified axis point.
QStringList axisCurvePointIdentifiers() const
Points in axis curve.
Class that represents one digitized point. The screen-to-graph coordinate transformation is always ex...
Definition: Point.h:23
double scaleBarLength() const
Length of scale bar.
QString identifier() const
Unique identifier for a specific Point.
Definition: Point.cpp:256
QPointF posGraph(ApplyHasCheck applyHasCheck=KEEP_HAS_CHECK) const
Accessor for graph position. Skip check if copying one instance to another.
Definition: Point.cpp:383
CallbackScaleBar()
Single constructor.