Engauge Digitizer  2
CmdFactory.cpp
1 #include "CmdAbstract.h"
2 #include "CmdAddPointAxis.h"
3 #include "CmdAddPointGraph.h"
4 #include "CmdCopy.h"
5 #include "CmdCut.h"
6 #include "CmdDelete.h"
7 #include "CmdEditPointAxis.h"
8 #include "CmdFactory.h"
9 #include "CmdMoveBy.h"
10 #include "CmdPaste.h"
11 #include "CmdSettingsAxesChecker.h"
12 #include "CmdSettingsColorFilter.h"
13 #include "CmdSettingsCoords.h"
14 #include "CmdSettingsCurveAddRemove.h"
15 #include "CmdSettingsCurveProperties.h"
16 #include "CmdSettingsDigitizeCurve.h"
17 #include "CmdSettingsExportFormat.h"
18 #include "CmdSettingsGridRemoval.h"
19 #include "CmdSettingsPointMatch.h"
20 #include "CmdSettingsSegments.h"
21 #include "Document.h"
22 #include "DocumentSerialize.h"
23 #include "EngaugeAssert.h"
24 #include "MainWindow.h"
25 #include <QXmlStreamReader>
26 
28 {
29 }
30 
32  Document &document,
33  QXmlStreamReader &reader)
34 {
35  CmdAbstract *cmd = 0;
36 
37  QXmlStreamAttributes attributes = reader.attributes();
38  if (!attributes.hasAttribute(DOCUMENT_SERIALIZE_CMD_TYPE) ||
39  !attributes.hasAttribute(DOCUMENT_SERIALIZE_CMD_DESCRIPTION)) {
40 
41  // Invalid xml
42  ENGAUGE_ASSERT(false);
43 
44  }
45 
46  // Get common attributes
47  QString cmdType = attributes.value(DOCUMENT_SERIALIZE_CMD_TYPE).toString();
48  QString cmdDescription = attributes.value(DOCUMENT_SERIALIZE_CMD_DESCRIPTION).toString();
49 
50  if (cmdType == DOCUMENT_SERIALIZE_CMD_ADD_POINT_AXIS) {
51  cmd = new CmdAddPointAxis (mainWindow,
52  document,
53  cmdDescription,
54  reader);
55  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_ADD_POINT_GRAPH) {
56  cmd = new CmdAddPointGraph (mainWindow,
57  document,
58  cmdDescription,
59  reader);
60  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_COPY) {
61  cmd = new CmdCopy (mainWindow,
62  document,
63  cmdDescription,
64  reader);
65  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_CUT) {
66  cmd = new CmdCut (mainWindow,
67  document,
68  cmdDescription,
69  reader);
70  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_DELETE) {
71  cmd = new CmdDelete (mainWindow,
72  document,
73  cmdDescription,
74  reader);
75  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_EDIT_POINT_AXIS) {
76  cmd = new CmdEditPointAxis (mainWindow,
77  document,
78  cmdDescription,
79  reader);
80  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_MOVE_BY) {
81  cmd = new CmdMoveBy (mainWindow,
82  document,
83  cmdDescription,
84  reader);
85  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_PASTE) {
86  cmd = new CmdPaste (mainWindow,
87  document,
88  cmdDescription,
89  reader);
90  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_SETTINGS_AXES_CHECKER) {
91  cmd = new CmdSettingsAxesChecker (mainWindow,
92  document,
93  cmdDescription,
94  reader);
95  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_SETTINGS_COLOR_FILTER) {
96  cmd = new CmdSettingsColorFilter (mainWindow,
97  document,
98  cmdDescription,
99  reader);
100  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_SETTINGS_COORDS) {
101  cmd = new CmdSettingsCoords (mainWindow,
102  document,
103  cmdDescription,
104  reader);
105  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_SETTINGS_CURVE_ADD_REMOVE) {
106  cmd = new CmdSettingsCurveAddRemove (mainWindow,
107  document,
108  cmdDescription,
109  reader);
110  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_SETTINGS_CURVE_PROPERTIES) {
111  cmd = new CmdSettingsCurveProperties (mainWindow,
112  document,
113  cmdDescription,
114  reader);
115  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_SETTINGS_DIGITIZE_CURVE) {
116  cmd = new CmdSettingsDigitizeCurve (mainWindow,
117  document,
118  cmdDescription,
119  reader);
120  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_SETTINGS_EXPORT) {
121  cmd = new CmdSettingsExportFormat (mainWindow,
122  document,
123  cmdDescription,
124  reader);
125  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_SETTINGS_GRID_REMOVAL) {
126  cmd = new CmdSettingsGridRemoval (mainWindow,
127  document,
128  cmdDescription,
129  reader);
130  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_SETTINGS_POINT_MATCH) {
131  cmd = new CmdSettingsPointMatch (mainWindow,
132  document,
133  cmdDescription,
134  reader);
135  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_SETTINGS_SEGMENTS) {
136  cmd = new CmdSettingsSegments (mainWindow,
137  document,
138  cmdDescription,
139  reader);
140  } else {
141 
142  // Invalid xml
143  ENGAUGE_ASSERT (false);
144 
145  }
146 
147  return cmd;
148 }
Command for cutting all selected Points.
Definition: CmdCut.h:12
Wrapper around QUndoCommand. This simplifies the more complicated feature set of QUndoCommand.
Definition: CmdAbstract.h:11
CmdFactory()
Single constructor.
Definition: CmdFactory.cpp:27
Command for moving all selected Points by a specified translation.
Definition: CmdMoveBy.h:12
Command for DlgSettingsCurveProperties.
Command for DlgSettingsCurveAddRemove.
Command for DlgSettingsPointMatch.
Command for DlgSettingsCoords.
Command for DlgSettingsAxesChecker.
Command for adding one axis point.
Command for adding one graph point.
Storage of one imported image and the data attached to that image.
Definition: Document.h:28
Command for deleting all selected Points.
Definition: CmdDelete.h:12
Command for DlgSettingsGridRemoval.
Command for DlgSettingsColorFilter.
Command for DlgSettingsSegments.
Command for DlgSettingsDigitizeCurve.
Command for editing the graph coordinates one axis point.
Command for moving all selected Points by a specified translation.
Definition: CmdCopy.h:12
Command for moving all selected Points by a specified translation.
Definition: CmdPaste.h:12
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
Definition: MainWindow.h:60
Command for DlgSettingsExportFormat.
CmdAbstract * createCmd(MainWindow &mainWindow, Document &document, QXmlStreamReader &reader)
Factory method. Input is the xml node from an error report file.
Definition: CmdFactory.cpp:31