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