Engauge Digitizer 2
Loading...
Searching...
No Matches
ScaleBarAxisPointsUnite Class Reference

Given a set of point identifiers, if a map is in effect (with its two axis endpoints) then both axis points must be handled as a unit. More...

#include <ScaleBarAxisPointsUnite.h>

Collaboration diagram for ScaleBarAxisPointsUnite:
Collaboration graph

Public Member Functions

 ScaleBarAxisPointsUnite ()
 Single constructor.
 ~ScaleBarAxisPointsUnite ()
QStringList unite (CmdMediator *cmdMediator, const QStringList &pointIdentifiersIn) const
 Add.

Detailed Description

Given a set of point identifiers, if a map is in effect (with its two axis endpoints) then both axis points must be handled as a unit.

For that to happen, for maps this class looks for one axis endpoint in a point identifier list, and if just one is in the list then the other is also added

This class has absolutely no effect (=noop) when a map is not in effect, or a map is in effect but zero or both axis endpoints are in the list

Definition at line 21 of file ScaleBarAxisPointsUnite.h.

Constructor & Destructor Documentation

◆ ScaleBarAxisPointsUnite()

ScaleBarAxisPointsUnite::ScaleBarAxisPointsUnite ( )

Single constructor.

Definition at line 14 of file ScaleBarAxisPointsUnite.cpp.

15{
16 LOG4CPP_INFO_S ((*mainCat)) << "ScaleBarAxisPointsUnite::ScaleBarAxisPointsUnite";
17}
log4cpp::Category * mainCat
Definition Logger.cpp:14
#define LOG4CPP_INFO_S(logger)
Definition convenience.h:18

◆ ~ScaleBarAxisPointsUnite()

ScaleBarAxisPointsUnite::~ScaleBarAxisPointsUnite ( )

Definition at line 19 of file ScaleBarAxisPointsUnite.cpp.

20{
21}

Member Function Documentation

◆ unite()

QStringList ScaleBarAxisPointsUnite::unite ( CmdMediator * cmdMediator,
const QStringList & pointIdentifiersIn ) const

Add.

Definition at line 34 of file ScaleBarAxisPointsUnite.cpp.

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
Document & document()
Provide the Document to commands, primarily for undo/redo processing.
DocumentAxesPointsRequired documentAxesPointsRequired() const
Get method for DocumentAxesPointsRequired.
Definition Document.cpp:369

The documentation for this class was generated from the following files: