Engauge Digitizer  2
 All Classes Files Functions Variables Enumerations Enumerator Friends Pages
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 "CmdSettingsMainWindow.h"
20 #include "CmdSettingsPointMatch.h"
21 #include "CmdSettingsSegments.h"
22 #include "Document.h"
23 #include "DocumentSerialize.h"
24 #include "EngaugeAssert.h"
25 #include "MainWindow.h"
26 #include <QXmlStreamReader>
27 
29 {
30 }
31 
33  Document &document,
34  QXmlStreamReader &reader)
35 {
36  CmdAbstract *cmd = 0;
37 
38  QXmlStreamAttributes attributes = reader.attributes();
39  if (!attributes.hasAttribute(DOCUMENT_SERIALIZE_CMD_TYPE) ||
40  !attributes.hasAttribute(DOCUMENT_SERIALIZE_CMD_DESCRIPTION)) {
41 
42  // Invalid xml
43  ENGAUGE_ASSERT(false);
44 
45  }
46 
47  // Get common attributes
48  QString cmdType = attributes.value(DOCUMENT_SERIALIZE_CMD_TYPE).toString();
49  QString cmdDescription = attributes.value(DOCUMENT_SERIALIZE_CMD_DESCRIPTION).toString();
50 
51  if (cmdType == DOCUMENT_SERIALIZE_CMD_ADD_POINT_AXIS) {
52  cmd = new CmdAddPointAxis (mainWindow,
53  document,
54  cmdDescription,
55  reader);
56  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_ADD_POINT_GRAPH) {
57  cmd = new CmdAddPointGraph (mainWindow,
58  document,
59  cmdDescription,
60  reader);
61  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_COPY) {
62  cmd = new CmdCopy (mainWindow,
63  document,
64  cmdDescription,
65  reader);
66  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_CUT) {
67  cmd = new CmdCut (mainWindow,
68  document,
69  cmdDescription,
70  reader);
71  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_DELETE) {
72  cmd = new CmdDelete (mainWindow,
73  document,
74  cmdDescription,
75  reader);
76  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_EDIT_POINT_AXIS) {
77  cmd = new CmdEditPointAxis (mainWindow,
78  document,
79  cmdDescription,
80  reader);
81  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_MOVE_BY) {
82  cmd = new CmdMoveBy (mainWindow,
83  document,
84  cmdDescription,
85  reader);
86  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_PASTE) {
87  cmd = new CmdPaste (mainWindow,
88  document,
89  cmdDescription,
90  reader);
91  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_SETTINGS_AXES_CHECKER) {
92  cmd = new CmdSettingsAxesChecker (mainWindow,
93  document,
94  cmdDescription,
95  reader);
96  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_SETTINGS_COLOR_FILTER) {
97  cmd = new CmdSettingsColorFilter (mainWindow,
98  document,
99  cmdDescription,
100  reader);
101  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_SETTINGS_COORDS) {
102  cmd = new CmdSettingsCoords (mainWindow,
103  document,
104  cmdDescription,
105  reader);
106  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_SETTINGS_CURVE_ADD_REMOVE) {
107  cmd = new CmdSettingsCurveAddRemove (mainWindow,
108  document,
109  cmdDescription,
110  reader);
111  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_SETTINGS_CURVE_PROPERTIES) {
112  cmd = new CmdSettingsCurveProperties (mainWindow,
113  document,
114  cmdDescription,
115  reader);
116  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_SETTINGS_DIGITIZE_CURVE) {
117  cmd = new CmdSettingsDigitizeCurve (mainWindow,
118  document,
119  cmdDescription,
120  reader);
121  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_SETTINGS_EXPORT) {
122  cmd = new CmdSettingsExportFormat (mainWindow,
123  document,
124  cmdDescription,
125  reader);
126  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_SETTINGS_GRID_REMOVAL) {
127  cmd = new CmdSettingsGridRemoval (mainWindow,
128  document,
129  cmdDescription,
130  reader);
131  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_SETTINGS_MAIN_WINDOW) {
132  cmd = new CmdSettingsMainWindow (mainWindow,
133  document,
134  cmdDescription,
135  reader);
136  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_SETTINGS_POINT_MATCH) {
137  cmd = new CmdSettingsPointMatch (mainWindow,
138  document,
139  cmdDescription,
140  reader);
141  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_SETTINGS_SEGMENTS) {
142  cmd = new CmdSettingsSegments (mainWindow,
143  document,
144  cmdDescription,
145  reader);
146  } else {
147 
148  // Invalid xml
149  ENGAUGE_ASSERT (false);
150 
151  }
152 
153  return cmd;
154 }
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:28
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:29
Command for deleting all selected Points.
Definition: CmdDelete.h:12
Command for DlgSettingsMainWindow.
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:66
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:32