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

This class consolidates utility routines that deal with graphics items that are getting extracted from the scene. More...

#include <GraphicsItemsExtractor.h>

Collaboration diagram for GraphicsItemsExtractor:
Collaboration graph

Public Member Functions

 GraphicsItemsExtractor ()
 Single constructor.
 
 ~GraphicsItemsExtractor ()
 
bool allSelectedItemsAreEitherAxisOrGraph (const QList< QGraphicsItem * > &items, AxisOrGraph axisOrGraph) const
 Return true if all selected points are of the specified axis or graph type.
 
QStringList selectedPointIdentifiers (const QList< QGraphicsItem * > &items) const
 Return list of selected point identifiers.
 

Detailed Description

This class consolidates utility routines that deal with graphics items that are getting extracted from the scene.

Definition at line 20 of file GraphicsItemsExtractor.h.

Constructor & Destructor Documentation

◆ GraphicsItemsExtractor()

GraphicsItemsExtractor::GraphicsItemsExtractor ( )

Single constructor.

Definition at line 15 of file GraphicsItemsExtractor.cpp.

16{
17}

◆ ~GraphicsItemsExtractor()

GraphicsItemsExtractor::~GraphicsItemsExtractor ( )

Definition at line 19 of file GraphicsItemsExtractor.cpp.

20{
21}

Member Function Documentation

◆ allSelectedItemsAreEitherAxisOrGraph()

bool GraphicsItemsExtractor::allSelectedItemsAreEitherAxisOrGraph ( const QList< QGraphicsItem * > &  items,
AxisOrGraph  axisOrGraph 
) const

Return true if all selected points are of the specified axis or graph type.

Definition at line 23 of file GraphicsItemsExtractor.cpp.

25{
26 bool allAreEitherAxisOrGraph = true;
27
28 QList<QGraphicsItem*>::const_iterator itr;
29 for (itr = items.begin(); itr != items.end(); itr++) {
30
31 QGraphicsItem *item = *itr;
32 GraphicsItemType type = static_cast<GraphicsItemType> (item->data (DATA_KEY_GRAPHICS_ITEM_TYPE).toInt ());
33
34 if (type == GRAPHICS_ITEM_TYPE_POINT) {
35
36 QString pointIdentifier = item->data (DATA_KEY_IDENTIFIER).toString ();
37 QString curveName = Point::curveNameFromPointIdentifier (pointIdentifier);
38
39 bool unwantedAxisPoint = ((curveName == AXIS_CURVE_NAME) && (axisOrGraph == GRAPH_POINTS));
40 bool unwantedCurvePoint = ((curveName != AXIS_CURVE_NAME) && (axisOrGraph == AXIS_POINTS));
41
42 if (unwantedAxisPoint || unwantedCurvePoint) {
43
44 allAreEitherAxisOrGraph = false;
45 break;
46
47 }
48 } else {
49
50 allAreEitherAxisOrGraph = false;
51 break;
52
53 }
54 }
55
56 return allAreEitherAxisOrGraph;
57}
const QString AXIS_CURVE_NAME
@ DATA_KEY_GRAPHICS_ITEM_TYPE
‍Unique identifier for QGraphicsItem object
Definition: DataKey.h:15
@ DATA_KEY_IDENTIFIER
Definition: DataKey.h:14
GraphicsItemType
Runtime type identification (RTTI) for QGraphicsItem objects.
@ GRAPHICS_ITEM_TYPE_POINT
@ GRAPH_POINTS
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

◆ selectedPointIdentifiers()

QStringList GraphicsItemsExtractor::selectedPointIdentifiers ( const QList< QGraphicsItem * > &  items) const

Return list of selected point identifiers.

Definition at line 59 of file GraphicsItemsExtractor.cpp.

60{
61 LOG4CPP_INFO_S ((*mainCat)) << "GraphicsScene::selectedPointIdentifiers"
62 << " selectedItems=" << items.count();
63
64 QStringList selectedIds;
65 QList<QGraphicsItem*>::const_iterator itr;
66 for (itr = items.begin(); itr != items.end(); itr++) {
67
68 const QGraphicsItem* item = *itr;
69
70 // Skip the image and only keep the Points
71 bool isPoint = (item->data (DATA_KEY_GRAPHICS_ITEM_TYPE).toInt () == GRAPHICS_ITEM_TYPE_POINT);
72 if (isPoint) {
73
74 // Add Point to the list
75 selectedIds << item->data(DATA_KEY_IDENTIFIER).toString ();
76
77 }
78 }
79
80 return selectedIds;
81}
log4cpp::Category * mainCat
Definition: Logger.cpp:14
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18

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