Engauge Digitizer 2
Loading...
Searching...
No Matches
ScaleBarAxisPointsUnite.cpp
Go to the documentation of this file.
1/******************************************************************************************************
2 * (C) 2014 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 "CmdMediator.h"
9#include "Document.h"
10#include "Logger.h"
11#include <QVector>
13
15{
16 LOG4CPP_INFO_S ((*mainCat)) << "ScaleBarAxisPointsUnite::ScaleBarAxisPointsUnite";
17}
18
22
23QStringList ScaleBarAxisPointsUnite::axisPointIdentifiers (CmdMediator *cmdMediator) const
24{
26
27 Functor2wRet<const QString &, const Point&, CallbackSearchReturn> ftorWithCallback = functor_ret (ftor,
29 cmdMediator->iterateThroughCurvePointsAxes (ftorWithCallback);
30
31 return ftor.axisCurvePointIdentifiers ();
32}
33
35 const QStringList &pointIdentifiersIn) const
36{
37 const int AXIS_POINT_COUNT_IF_UNITING = 2;
38
39 QStringList pointIdentifiersOut (pointIdentifiersIn);
40
41 // Collect axis point identifiers
42 QStringList axisIdentifiers = axisPointIdentifiers (cmdMediator);
43
44 // Skip if not a map with scale bar
46 (axisIdentifiers.count () == AXIS_POINT_COUNT_IF_UNITING)) {
47
48 // Calculate occurrence counts
49 QVector<int> counts (AXIS_POINT_COUNT_IF_UNITING);
50 for (int i = 0; i < AXIS_POINT_COUNT_IF_UNITING; i++) {
51 counts [i] = 0;
52
53 QStringList::const_iterator itr;
54 for (itr = pointIdentifiersIn.begin (); itr != pointIdentifiersIn.end (); itr++) {
55 QString pointIdentifier = *itr;
56
57 if (axisIdentifiers [i] == pointIdentifier) {
58 ++counts [i];
59 }
60 }
61 }
62
63 // Add in either of two cases
64 if (counts [0] == 0 && counts [1] == 1) {
65 // Add first
66 pointIdentifiersOut << axisIdentifiers [0];
67 } else if (counts [0] == 1 && counts [1] == 0) {
68 // Add second
69 pointIdentifiersOut << axisIdentifiers [1];
70 }
71 }
72
73 return pointIdentifiersOut;
74}
@ DOCUMENT_AXES_POINTS_REQUIRED_2
log4cpp::Category * mainCat
Definition Logger.cpp:14
Callback for identifying, for the scale bar of a map, various quantities.
CallbackSearchReturn callback(const QString &curveName, const Point &point)
Callback method.
QStringList axisCurvePointIdentifiers() const
Points in axis curve.
Command queue stack.
Definition CmdMediator.h:24
void iterateThroughCurvePointsAxes(const Functor2wRet< const QString &, const Point &, CallbackSearchReturn > &ftorWithCallback)
See Curve::iterateThroughCurvePoints, for the single axes curve.
Document & document()
Provide the Document to commands, primarily for undo/redo processing.
DocumentAxesPointsRequired documentAxesPointsRequired() const
Get method for DocumentAxesPointsRequired.
Definition Document.cpp:369
QStringList unite(CmdMediator *cmdMediator, const QStringList &pointIdentifiersIn) const
Add.
ScaleBarAxisPointsUnite()
Single constructor.
#define LOG4CPP_INFO_S(logger)
Definition convenience.h:18