Engauge Digitizer  2
Public Member Functions | List of all members
CmdFactory Class Reference

Factory for CmdAbstractBase objects. More...

#include <CmdFactory.h>

Collaboration diagram for CmdFactory:
Collaboration graph

Public Member Functions

 CmdFactory ()
 Single constructor. More...
 
CmdAbstract * createCmd (MainWindow &mainWindow, Document &document, QXmlStreamReader &reader)
 Factory method. Input is the xml node from an error report file. More...
 

Detailed Description

Factory for CmdAbstractBase objects.

Definition at line 16 of file CmdFactory.h.

Constructor & Destructor Documentation

◆ CmdFactory()

CmdFactory::CmdFactory ( )

Single constructor.

Definition at line 38 of file CmdFactory.cpp.

39 {
40 }

Member Function Documentation

◆ createCmd()

CmdAbstract * CmdFactory::createCmd ( MainWindow &  mainWindow,
Document &  document,
QXmlStreamReader &  reader 
)

Factory method. Input is the xml node from an error report file.

Definition at line 42 of file CmdFactory.cpp.

45 {
46  CmdAbstract *cmd = nullptr;
47 
48  QXmlStreamAttributes attributes = reader.attributes();
49  if (!attributes.hasAttribute(DOCUMENT_SERIALIZE_CMD_TYPE) ||
50  !attributes.hasAttribute(DOCUMENT_SERIALIZE_CMD_DESCRIPTION)) {
51 
52  // Invalid xml
53  ENGAUGE_ASSERT(false);
54 
55  }
56 
57  // Get common attributes
58  QString cmdType = attributes.value(DOCUMENT_SERIALIZE_CMD_TYPE).toString();
59  QString cmdDescription = attributes.value(DOCUMENT_SERIALIZE_CMD_DESCRIPTION).toString();
60 
62  cmd = new CmdAddPointAxis (mainWindow,
63  document,
64  cmdDescription,
65  reader);
66  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_ADD_POINT_GRAPH) {
67  cmd = new CmdAddPointGraph (mainWindow,
68  document,
69  cmdDescription,
70  reader);
71  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_ADD_POINTS_GRAPH) {
72  cmd = new CmdAddPointsGraph (mainWindow,
73  document,
74  cmdDescription,
75  reader);
76  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_COPY) {
77  cmd = new CmdCopy (mainWindow,
78  document,
79  cmdDescription,
80  reader);
81  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_CUT) {
82  cmd = new CmdCut (mainWindow,
83  document,
84  cmdDescription,
85  reader);
86  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_DELETE) {
87  cmd = new CmdDelete (mainWindow,
88  document,
89  cmdDescription,
90  reader);
91  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_EDIT_POINT_AXIS) {
92  cmd = new CmdEditPointAxis (mainWindow,
93  document,
94  cmdDescription,
95  reader);
96  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_EDIT_POINT_GRAPH) {
97  cmd = new CmdEditPointGraph (mainWindow,
98  document,
99  cmdDescription,
100  reader);
101  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_MOVE_BY) {
102  cmd = new CmdMoveBy (mainWindow,
103  document,
104  cmdDescription,
105  reader);
106  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_REDO_FOR_TEST) {
107  cmd = new CmdRedoForTest (mainWindow,
108  document,
109  cmdDescription,
110  reader);
111  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_SELECT_COORD_SYSTEM) {
112  cmd = new CmdSelectCoordSystem (mainWindow,
113  document,
114  cmdDescription,
115  reader);
116  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_SETTINGS_AXES_CHECKER) {
117  cmd = new CmdSettingsAxesChecker (mainWindow,
118  document,
119  cmdDescription,
120  reader);
121  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_SETTINGS_COLOR_FILTER) {
122  cmd = new CmdSettingsColorFilter (mainWindow,
123  document,
124  cmdDescription,
125  reader);
126  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_SETTINGS_COORDS) {
127  cmd = new CmdSettingsCoords (mainWindow,
128  document,
129  cmdDescription,
130  reader);
131  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_SETTINGS_CURVE_LIST) {
132  cmd = new CmdSettingsCurveList (mainWindow,
133  document,
134  cmdDescription,
135  reader);
136  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_SETTINGS_CURVE_PROPERTIES) {
137  cmd = new CmdSettingsCurveProperties (mainWindow,
138  document,
139  cmdDescription,
140  reader);
141  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_SETTINGS_DIGITIZE_CURVE) {
142  cmd = new CmdSettingsDigitizeCurve (mainWindow,
143  document,
144  cmdDescription,
145  reader);
146  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_SETTINGS_EXPORT) {
147  cmd = new CmdSettingsExportFormat (mainWindow,
148  document,
149  cmdDescription,
150  reader);
151  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_SETTINGS_GENERAL) {
152  cmd = new CmdSettingsGeneral (mainWindow,
153  document,
154  cmdDescription,
155  reader);
156  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_SETTINGS_GRID_REMOVAL) {
157  cmd = new CmdSettingsGridRemoval (mainWindow,
158  document,
159  cmdDescription,
160  reader);
161  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_SETTINGS_POINT_MATCH) {
162  cmd = new CmdSettingsPointMatch (mainWindow,
163  document,
164  cmdDescription,
165  reader);
166  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_SETTINGS_SEGMENTS) {
167  cmd = new CmdSettingsSegments (mainWindow,
168  document,
169  cmdDescription,
170  reader);
171  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_UNDO_FOR_TEST) {
172  cmd = new CmdUndoForTest (mainWindow,
173  document,
174  cmdDescription,
175  reader);
176  } else {
177 
178  // Invalid xml
179  ENGAUGE_ASSERT (false);
180 
181  }
182 
183  return cmd;
184 }
const QString DOCUMENT_SERIALIZE_CMD_ADD_POINT_AXIS
const QString DOCUMENT_SERIALIZE_CMD_MOVE_BY
const QString DOCUMENT_SERIALIZE_CMD_REDO_FOR_TEST
const QString DOCUMENT_SERIALIZE_CMD_SETTINGS_CURVE_LIST
const QString DOCUMENT_SERIALIZE_CMD_SETTINGS_CURVE_PROPERTIES
const QString DOCUMENT_SERIALIZE_CMD_SETTINGS_GRID_REMOVAL
const QString DOCUMENT_SERIALIZE_CMD_ADD_POINTS_GRAPH
const QString DOCUMENT_SERIALIZE_CMD_ADD_POINT_GRAPH
const QString DOCUMENT_SERIALIZE_CMD_SETTINGS_SEGMENTS
const QString DOCUMENT_SERIALIZE_CMD_SETTINGS_POINT_MATCH
const QString DOCUMENT_SERIALIZE_CMD_SETTINGS_COLOR_FILTER
const QString DOCUMENT_SERIALIZE_CMD_UNDO_FOR_TEST
const QString DOCUMENT_SERIALIZE_CMD_TYPE
const QString DOCUMENT_SERIALIZE_CMD_SETTINGS_GENERAL
const QString DOCUMENT_SERIALIZE_CMD_CUT
const QString DOCUMENT_SERIALIZE_CMD_SETTINGS_DIGITIZE_CURVE
const QString DOCUMENT_SERIALIZE_CMD_DELETE
const QString DOCUMENT_SERIALIZE_CMD_EDIT_POINT_AXIS
const QString DOCUMENT_SERIALIZE_CMD_EDIT_POINT_GRAPH
const QString DOCUMENT_SERIALIZE_CMD_SETTINGS_COORDS
const QString DOCUMENT_SERIALIZE_CMD_SETTINGS_AXES_CHECKER
const QString DOCUMENT_SERIALIZE_CMD_DESCRIPTION
const QString DOCUMENT_SERIALIZE_CMD_SETTINGS_EXPORT
const QString DOCUMENT_SERIALIZE_CMD_COPY
const QString DOCUMENT_SERIALIZE_CMD_SELECT_COORD_SYSTEM
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS) define ENGAUGE...
Definition: EngaugeAssert.h:20
Wrapper around QUndoCommand. This simplifies the more complicated feature set of QUndoCommand.
Definition: CmdAbstract.h:20
Command for adding one axis point.
Command for adding one graph point.
Command for adding one or more graph points. This is for Segment Fill mode.
Command for moving all selected Points by a specified translation.
Definition: CmdCopy.h:19
Command for cutting all selected Points.
Definition: CmdCut.h:19
Command for deleting all selected Points.
Definition: CmdDelete.h:19
Command for editing the graph coordinates one axis point.
Command for editing the graph coordinates of one or more graph points.
Command for moving all selected Points by a specified translation.
Definition: CmdMoveBy.h:19
Command for performing Redo during testing.
Command for changing the currently selected CoordSystem.
Command for DlgSettingsAxesChecker.
Command for DlgSettingsColorFilter.
Command for DlgSettingsCoords.
Command for DlgSettingsCurveList.
Command for DlgSettingsCurveProperties.
Command for DlgSettingsDigitizeCurve.
Command for DlgSettingsExportFormat.
Command for DlgSettingsGeneral.
Command for DlgSettingsGridRemoval.
Command for DlgSettingsPointMatch.
Command for DlgSettingsSegments.
Command for performing Undo during testing.

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