Engauge Digitizer  2
 All Classes Files Functions Variables Enumerations Enumerator Friends Pages
CmdFactory.cpp
1 /******************************************************************************************************
2  * (C) 2014 markummitchell@github.com. This file is part of Engauge Digitizer, which is released *
3  * under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file *
4  * LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. *
5  ******************************************************************************************************/
6 
7 #include "CmdAbstract.h"
8 #include "CmdAddPointAxis.h"
9 #include "CmdAddPointGraph.h"
10 #include "CmdAddPointsGraph.h"
11 #include "CmdCopy.h"
12 #include "CmdCut.h"
13 #include "CmdDelete.h"
14 #include "CmdEditPointAxis.h"
15 #include "CmdEditPointGraph.h"
16 #include "CmdFactory.h"
17 #include "CmdMoveBy.h"
18 #include "CmdPaste.h"
19 #include "CmdRedoForTest.h"
20 #include "CmdSelectCoordSystem.h"
21 #include "CmdSettingsAxesChecker.h"
22 #include "CmdSettingsColorFilter.h"
23 #include "CmdSettingsCoords.h"
24 #include "CmdSettingsCurveAddRemove.h"
25 #include "CmdSettingsCurveProperties.h"
26 #include "CmdSettingsDigitizeCurve.h"
27 #include "CmdSettingsExportFormat.h"
28 #include "CmdSettingsGeneral.h"
29 #include "CmdSettingsGridRemoval.h"
30 #include "CmdSettingsPointMatch.h"
31 #include "CmdSettingsSegments.h"
32 #include "CmdUndoForTest.h"
33 #include "Document.h"
34 #include "DocumentSerialize.h"
35 #include "EngaugeAssert.h"
36 #include "MainWindow.h"
37 #include <QXmlStreamReader>
38 
40 {
41 }
42 
44  Document &document,
45  QXmlStreamReader &reader)
46 {
47  CmdAbstract *cmd = 0;
48 
49  QXmlStreamAttributes attributes = reader.attributes();
50  if (!attributes.hasAttribute(DOCUMENT_SERIALIZE_CMD_TYPE) ||
51  !attributes.hasAttribute(DOCUMENT_SERIALIZE_CMD_DESCRIPTION)) {
52 
53  // Invalid xml
54  ENGAUGE_ASSERT(false);
55 
56  }
57 
58  // Get common attributes
59  QString cmdType = attributes.value(DOCUMENT_SERIALIZE_CMD_TYPE).toString();
60  QString cmdDescription = attributes.value(DOCUMENT_SERIALIZE_CMD_DESCRIPTION).toString();
61 
62  if (cmdType == DOCUMENT_SERIALIZE_CMD_ADD_POINT_AXIS) {
63  cmd = new CmdAddPointAxis (mainWindow,
64  document,
65  cmdDescription,
66  reader);
67  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_ADD_POINT_GRAPH) {
68  cmd = new CmdAddPointGraph (mainWindow,
69  document,
70  cmdDescription,
71  reader);
72  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_ADD_POINTS_GRAPH) {
73  cmd = new CmdAddPointsGraph (mainWindow,
74  document,
75  cmdDescription,
76  reader);
77  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_COPY) {
78  cmd = new CmdCopy (mainWindow,
79  document,
80  cmdDescription,
81  reader);
82  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_CUT) {
83  cmd = new CmdCut (mainWindow,
84  document,
85  cmdDescription,
86  reader);
87  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_DELETE) {
88  cmd = new CmdDelete (mainWindow,
89  document,
90  cmdDescription,
91  reader);
92  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_EDIT_POINT_AXIS) {
93  cmd = new CmdEditPointAxis (mainWindow,
94  document,
95  cmdDescription,
96  reader);
97  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_EDIT_POINT_GRAPH) {
98  cmd = new CmdEditPointGraph (mainWindow,
99  document,
100  cmdDescription,
101  reader);
102  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_MOVE_BY) {
103  cmd = new CmdMoveBy (mainWindow,
104  document,
105  cmdDescription,
106  reader);
107  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_PASTE) {
108  cmd = new CmdPaste (mainWindow,
109  document,
110  cmdDescription,
111  reader);
112  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_REDO_FOR_TEST) {
113  cmd = new CmdRedoForTest (mainWindow,
114  document,
115  cmdDescription,
116  reader);
117  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_SELECT_COORD_SYSTEM) {
118  cmd = new CmdSelectCoordSystem (mainWindow,
119  document,
120  cmdDescription,
121  reader);
122  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_SETTINGS_AXES_CHECKER) {
123  cmd = new CmdSettingsAxesChecker (mainWindow,
124  document,
125  cmdDescription,
126  reader);
127  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_SETTINGS_COLOR_FILTER) {
128  cmd = new CmdSettingsColorFilter (mainWindow,
129  document,
130  cmdDescription,
131  reader);
132  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_SETTINGS_COORDS) {
133  cmd = new CmdSettingsCoords (mainWindow,
134  document,
135  cmdDescription,
136  reader);
137  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_SETTINGS_CURVE_ADD_REMOVE) {
138  cmd = new CmdSettingsCurveAddRemove (mainWindow,
139  document,
140  cmdDescription,
141  reader);
142  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_SETTINGS_CURVE_PROPERTIES) {
143  cmd = new CmdSettingsCurveProperties (mainWindow,
144  document,
145  cmdDescription,
146  reader);
147  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_SETTINGS_DIGITIZE_CURVE) {
148  cmd = new CmdSettingsDigitizeCurve (mainWindow,
149  document,
150  cmdDescription,
151  reader);
152  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_SETTINGS_EXPORT) {
153  cmd = new CmdSettingsExportFormat (mainWindow,
154  document,
155  cmdDescription,
156  reader);
157  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_SETTINGS_GENERAL) {
158  cmd = new CmdSettingsGeneral (mainWindow,
159  document,
160  cmdDescription,
161  reader);
162  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_SETTINGS_GRID_REMOVAL) {
163  cmd = new CmdSettingsGridRemoval (mainWindow,
164  document,
165  cmdDescription,
166  reader);
167  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_SETTINGS_POINT_MATCH) {
168  cmd = new CmdSettingsPointMatch (mainWindow,
169  document,
170  cmdDescription,
171  reader);
172  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_SETTINGS_SEGMENTS) {
173  cmd = new CmdSettingsSegments (mainWindow,
174  document,
175  cmdDescription,
176  reader);
177  } else if (cmdType == DOCUMENT_SERIALIZE_CMD_UNDO_FOR_TEST) {
178  cmd = new CmdUndoForTest (mainWindow,
179  document,
180  cmdDescription,
181  reader);
182  } else {
183 
184  // Invalid xml
185  ENGAUGE_ASSERT (false);
186 
187  }
188 
189  return cmd;
190 }
Command for cutting all selected Points.
Definition: CmdCut.h:18
Wrapper around QUndoCommand. This simplifies the more complicated feature set of QUndoCommand.
Definition: CmdAbstract.h:19
Command for performing Undo during testing.
CmdFactory()
Single constructor.
Definition: CmdFactory.cpp:39
Command for editing the graph coordinates of one or more graph points.
Command for performing Redo during testing.
Command for moving all selected Points by a specified translation.
Definition: CmdMoveBy.h:18
Command for DlgSettingsCurveProperties.
Command for DlgSettingsCurveAddRemove.
Command for DlgSettingsPointMatch.
Command for DlgSettingsGeneral.
Command for DlgSettingsCoords.
Command for DlgSettingsAxesChecker.
Command for adding one axis point.
Command for adding one or more graph points. This is for Segment Fill mode.
Command for adding one graph point.
Storage of one imported image and the data attached to that image.
Definition: Document.h:41
Command for deleting all selected Points.
Definition: CmdDelete.h:18
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:18
Command for changing the currently selected CoordSystem.
Command for moving all selected Points by a specified translation.
Definition: CmdPaste.h:18
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
Definition: MainWindow.h:83
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:43