Engauge Digitizer 2
Loading...
Searching...
No Matches
Public Member Functions | List of all members
CurvesGraphs Class Reference

Container for all graph curves. The axes point curve is external to this class. More...

#include <CurvesGraphs.h>

Collaboration diagram for CurvesGraphs:
Collaboration graph

Public Member Functions

 CurvesGraphs ()
 
void addGraphCurveAtEnd (const Curve &curve)
 Append new graph Curve to end of Curve list.
 
void addPoint (const Point &point)
 Append new Point to the specified Curve.
 
CurvecurveForCurveName (const QString &curveName)
 Return the axis or graph curve for the specified curve name.
 
const CurvecurveForCurveName (const QString &curveName) const
 Return the axis or graph curve for the specified curve name.
 
QStringList curvesGraphsNames () const
 List of graph curve names.
 
int curvesGraphsNumPoints (const QString &curveName) const
 Point count.
 
void editPointGraph (bool isX, bool isY, double x, double y, const QStringList &identifiers, const Transformation &transformation)
 Set the x and/or y coordinate values of the specified points.
 
void iterateThroughCurvePoints (const QString &curveNameWanted, const Functor2wRet< const QString &, const Point &, CallbackSearchReturn > &ftorWithCallback)
 Apply functor to Points in the specified axis or graph Curve.
 
void iterateThroughCurveSegments (const QString &curveNameWanted, const Functor2wRet< const Point &, const Point &, CallbackSearchReturn > &ftorWithCallback) const
 Apply functor to segments on the specified axis or graph Curve.
 
void iterateThroughCurvesPoints (const Functor2wRet< const QString &, const Point &, CallbackSearchReturn > &ftorWithCallback)
 Apply functor to Points on all of the Curves.
 
void iterateThroughCurvesPoints (const Functor2wRet< const QString &, const Point &, CallbackSearchReturn > &ftorWithCallback) const
 Apply functor to Points on all of the Curves.
 
void loadPreVersion6 (QDataStream &str)
 Load from serialized binary pre-version 6 file.
 
void loadXml (QXmlStreamReader &reader)
 Load from serialized xml post-version 5 file.
 
int numCurves () const
 Current number of graphs curves.
 
void printStream (QString indentation, QTextStream &str) const
 Debugging method that supports print method of this class and printStream method of some other class(es)
 
void removePoint (const QString &pointIdentifier)
 Remove the Point from its Curve.
 
void saveXml (QXmlStreamWriter &writer) const
 Serialize curves.
 
void updatePointOrdinals (const Transformation &transformation)
 Update point ordinals to be consistent with their CurveStyle and x/theta coordinate.
 

Detailed Description

Container for all graph curves. The axes point curve is external to this class.

Definition at line 24 of file CurvesGraphs.h.

Constructor & Destructor Documentation

◆ CurvesGraphs()

CurvesGraphs::CurvesGraphs ( )

Definition at line 20 of file CurvesGraphs.cpp.

21{
22}

Member Function Documentation

◆ addGraphCurveAtEnd()

void CurvesGraphs::addGraphCurveAtEnd ( const Curve & curve)

Append new graph Curve to end of Curve list.

Definition at line 24 of file CurvesGraphs.cpp.

25{
26 m_curvesGraphs.push_back (curve);
27}
const int INNER_RADIUS_MIN

◆ addPoint()

void CurvesGraphs::addPoint ( const Point & point)

Append new Point to the specified Curve.

Definition at line 29 of file CurvesGraphs.cpp.

30{
32
33 Curve *curve = curveForCurveName (curveName);
34 curve->addPoint (point);
35}
Container for one set of digitized Points.
Definition Curve.h:34
Curve * curveForCurveName(const QString &curveName)
Return the axis or graph curve for the specified curve name.
static QString curveNameFromPointIdentifier(const QString &pointIdentifier)
Parse the curve name from the specified point identifier. This does the opposite of uniqueIdentifierG...
Definition Point.cpp:227
QString identifier() const
Unique identifier for a specific Point.
Definition Point.cpp:268

◆ curveForCurveName() [1/2]

Curve * CurvesGraphs::curveForCurveName ( const QString & curveName)

Return the axis or graph curve for the specified curve name.

Definition at line 37 of file CurvesGraphs.cpp.

38{
39 // Search for curve with matching name
40 CurveList::iterator itr;
41 for (itr = m_curvesGraphs.begin (); itr != m_curvesGraphs.end (); itr++) {
42
43 Curve &curve = *itr;
44 if (curveName == curve.curveName ()) {
45 return &curve;
46 }
47 }
48
49 return nullptr;
50}

◆ curveForCurveName() [2/2]

const Curve * CurvesGraphs::curveForCurveName ( const QString & curveName) const

Return the axis or graph curve for the specified curve name.

Definition at line 52 of file CurvesGraphs.cpp.

53{
54 // Search for curve with matching name
55 CurveList::const_iterator itr;
56 for (itr = m_curvesGraphs.begin (); itr != m_curvesGraphs.end (); itr++) {
57
58 const Curve &curve = *itr;
59 if (curveName == curve.curveName ()) {
60 return &curve;
61 }
62 }
63
64 return nullptr;
65}

◆ curvesGraphsNames()

QStringList CurvesGraphs::curvesGraphsNames ( ) const

List of graph curve names.

Definition at line 67 of file CurvesGraphs.cpp.

68{
70
71 CurveList::const_iterator itr;
72 for (itr = m_curvesGraphs.begin (); itr != m_curvesGraphs.end (); itr++) {
73
74 const Curve &curve = *itr;
75 names << curve.curveName ();
76 }
77
78 return names;
79}
QString curveName() const
Name of this Curve.
Definition Curve.cpp:144

◆ curvesGraphsNumPoints()

int CurvesGraphs::curvesGraphsNumPoints ( const QString & curveName) const

Point count.

Definition at line 81 of file CurvesGraphs.cpp.

82{
83 // Search for curve with matching name
84 CurveList::const_iterator itr;
85 for (itr = m_curvesGraphs.begin (); itr != m_curvesGraphs.end (); itr++) {
86
87 const Curve &curve = *itr;
88 if (curve.curveName () == curveName) {
89 return curve.numPoints ();
90 }
91 }
92
93 return 0;
94}
int numPoints() const
Number of points.
Definition Curve.cpp:432

◆ editPointGraph()

void CurvesGraphs::editPointGraph ( bool isX,
bool isY,
double x,
double y,
const QStringList & identifiers,
const Transformation & transformation )

Set the x and/or y coordinate values of the specified points.

Definition at line 96 of file CurvesGraphs.cpp.

102{
103 CurveList::iterator itr;
104 for (itr = m_curvesGraphs.begin (); itr != m_curvesGraphs.end (); itr++) {
105
106 Curve &curve = *itr;
108 isY,
109 x,
110 y,
112 transformation);
113 }
114}
void editPointGraph(bool isX, bool isY, double x, double y, const QStringList &identifiers, const Transformation &transformation)
Edit the graph coordinates of one or more graph points. This method does not apply to an axis point.
Definition Curve.cpp:171

◆ iterateThroughCurvePoints()

void CurvesGraphs::iterateThroughCurvePoints ( const QString & curveNameWanted,
const Functor2wRet< const QString &, const Point &, CallbackSearchReturn > & ftorWithCallback )

Apply functor to Points in the specified axis or graph Curve.

Definition at line 116 of file CurvesGraphs.cpp.

118{
119 // Search for curve with matching name
120 CurveList::const_iterator itr;
121 for (itr = m_curvesGraphs.begin (); itr != m_curvesGraphs.end (); itr++) {
122
123 const Curve &curve = *itr;
124 if (curve.curveName () == curveNameWanted) {
125
127 return;
128 }
129 }
130
131 ENGAUGE_ASSERT (false);
132}
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS) define ENGAUGE...
void iterateThroughCurvePoints(const Functor2wRet< const QString &, const Point &, CallbackSearchReturn > &ftorWithCallback) const
Apply functor to Points on Curve.
Definition Curve.cpp:301

◆ iterateThroughCurveSegments()

void CurvesGraphs::iterateThroughCurveSegments ( const QString & curveNameWanted,
const Functor2wRet< const Point &, const Point &, CallbackSearchReturn > & ftorWithCallback ) const

Apply functor to segments on the specified axis or graph Curve.

Definition at line 134 of file CurvesGraphs.cpp.

136{
137 // Search for curve with matching name
138 CurveList::const_iterator itr;
139 for (itr = m_curvesGraphs.begin (); itr != m_curvesGraphs.end (); itr++) {
140
141 const Curve &curve = *itr;
142 if (curve.curveName () == curveNameWanted) {
143
145 return;
146 }
147 }
148
149 ENGAUGE_ASSERT (false);
150}
void iterateThroughCurveSegments(const Functor2wRet< const Point &, const Point &, CallbackSearchReturn > &ftorWithCallback) const
Apply functor to successive Points, as line segments, on Curve. This could be a bit slow.
Definition Curve.cpp:316

◆ iterateThroughCurvesPoints() [1/2]

void CurvesGraphs::iterateThroughCurvesPoints ( const Functor2wRet< const QString &, const Point &, CallbackSearchReturn > & ftorWithCallback)

Apply functor to Points on all of the Curves.

Definition at line 152 of file CurvesGraphs.cpp.

153{
154 CurveList::const_iterator itr;
155 for (itr = m_curvesGraphs.begin (); itr != m_curvesGraphs.end (); itr++) {
156
157 const Curve &curve = *itr;
159 }
160}

◆ iterateThroughCurvesPoints() [2/2]

void CurvesGraphs::iterateThroughCurvesPoints ( const Functor2wRet< const QString &, const Point &, CallbackSearchReturn > & ftorWithCallback) const

Apply functor to Points on all of the Curves.

Definition at line 162 of file CurvesGraphs.cpp.

163{
164 CurveList::const_iterator itr;
165 for (itr = m_curvesGraphs.begin (); itr != m_curvesGraphs.end (); itr++) {
166
167 const Curve &curve = *itr;
169 }
170}

◆ loadPreVersion6()

void CurvesGraphs::loadPreVersion6 ( QDataStream & str)

Load from serialized binary pre-version 6 file.

Definition at line 172 of file CurvesGraphs.cpp.

173{
174 LOG4CPP_INFO_S ((*mainCat)) << "CurvesGraphs::loadPreVersion6";
175
176 int i;
177
178 // Remove previous Curves. There is a DEFAULT_GRAPH_CURVE_NAME by default
179 m_curvesGraphs.clear();
180
183 for (i = 0; i < numberCurvesGraphs; i++) {
184 Curve curve (str);
185 m_curvesGraphs.append (curve);
186 }
187
190 for (i = 0; i < numberCurvesMeasures; i++) {
191 Curve curve (str);
192
193 // Measures get dropped on the floor
194 }
195}
log4cpp::Category * mainCat
Definition Logger.cpp:14
#define LOG4CPP_INFO_S(logger)
Definition convenience.h:18

◆ loadXml()

void CurvesGraphs::loadXml ( QXmlStreamReader & reader)

Load from serialized xml post-version 5 file.

Definition at line 197 of file CurvesGraphs.cpp.

198{
199 LOG4CPP_INFO_S ((*mainCat)) << "CurvesGraphs::loadXml";
200
201 bool success = true;
202
203 // Remove previous Curves. There is a DEFAULT_GRAPH_CURVE_NAME by default
204 m_curvesGraphs.clear();
205
206 // Read until end of this subtree
207 while ((reader.tokenType() != QXmlStreamReader::EndElement) ||
209
211 if (reader.atEnd()) {
212 success = false;
213 break;
214 }
215
216 if ((reader.tokenType() == QXmlStreamReader::StartElement) &&
217 (reader.name () == DOCUMENT_SERIALIZE_CURVE)) {
218
220
221 // Version 6 of Engauge let users create multiple curves with the same name. Reading a file with duplicate
222 // curve names can result in crashes and/or corruption, so we deconflict duplicate curve names here
223 QString DUPLICATE = QString ("-%1").arg (QObject::tr ("DUPLICATE"));
224 QString curveName = curve.curveName();
225 while (curvesGraphsNames().contains (curveName)) {
226 curveName += DUPLICATE;
227 }
228 curve.setCurveName (curveName); // No effect if curve name was not a duplicate
229
230 // Add the curve
231 m_curvesGraphs.push_back (curve);
232
233 }
234 }
235
236 if (!success) {
237 reader.raiseError (QObject::tr ("Cannot read graph curves data"));
238 }
239}
const QString DOCUMENT_SERIALIZE_CURVES_GRAPHS
const QString DOCUMENT_SERIALIZE_CURVE
QXmlStreamReader::TokenType loadNextFromReader(QXmlStreamReader &reader)
Load next token from xml reader.
Definition Xml.cpp:14
QStringList curvesGraphsNames() const
List of graph curve names.

◆ numCurves()

int CurvesGraphs::numCurves ( ) const

Current number of graphs curves.

Definition at line 241 of file CurvesGraphs.cpp.

242{
243 return m_curvesGraphs.count ();
244}

◆ printStream()

void CurvesGraphs::printStream ( QString indentation,
QTextStream & str ) const

Debugging method that supports print method of this class and printStream method of some other class(es)

Definition at line 246 of file CurvesGraphs.cpp.

248{
249 str << indentation << "CurvesGraphs\n";
250
252
253 CurveList::const_iterator itr;
254 for (itr = m_curvesGraphs.begin (); itr != m_curvesGraphs.end (); itr++) {
255
256 const Curve &curve = *itr;
258 str);
259 }
260}
const QString INDENTATION_DELTA
void printStream(QString indentation, QTextStream &str) const
Debugging method that supports print method of this class and printStream method of some other class(...
Definition Curve.cpp:490

◆ removePoint()

void CurvesGraphs::removePoint ( const QString & pointIdentifier)

Remove the Point from its Curve.

Definition at line 262 of file CurvesGraphs.cpp.

263{
265
266 Curve *curve = curveForCurveName (curveName);
267 curve->removePoint (pointIdentifier);
268}

◆ saveXml()

void CurvesGraphs::saveXml ( QXmlStreamWriter & writer) const

Serialize curves.

Definition at line 270 of file CurvesGraphs.cpp.

271{
272 LOG4CPP_INFO_S ((*mainCat)) << "CurvesGraphs::saveXml";
273
274 writer.writeStartElement(DOCUMENT_SERIALIZE_CURVES_GRAPHS);
275
276 CurveList::const_iterator itr;
277 for (itr = m_curvesGraphs.begin (); itr != m_curvesGraphs.end (); itr++) {
278
279 const Curve &curve = *itr;
281 }
282
283 writer.writeEndElement();
284}
void saveXml(QXmlStreamWriter &writer) const
Serialize curve.
Definition Curve.cpp:523

◆ updatePointOrdinals()

void CurvesGraphs::updatePointOrdinals ( const Transformation & transformation)

Update point ordinals to be consistent with their CurveStyle and x/theta coordinate.

Definition at line 286 of file CurvesGraphs.cpp.

287{
288 LOG4CPP_INFO_S ((*mainCat)) << "CurvesGraphs::updatePointOrdinals";
289
290 CurveList::iterator itr;
291 for (itr = m_curvesGraphs.begin (); itr != m_curvesGraphs.end (); itr++) {
292
293 Curve &curve = *itr;
294 curve.updatePointOrdinals (transformation);
295 }
296}
void updatePointOrdinals(const Transformation &transformation)
See CurveGraphs::updatePointOrdinals.
Definition Curve.cpp:568

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