-
Notifications
You must be signed in to change notification settings - Fork 7
/
SC_projectobject.h
197 lines (157 loc) · 6.05 KB
/
SC_projectobject.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
#ifndef PROJECTOBJECT_H
#define PROJECTOBJECT_H
#include <QObject>
#include "globalHeader.h"
#include "SC_versioncontrol.h"
// A marker for code that is associated with loading the old-style
// metaData.xml. In the new style, the metaData annotations are
// recorded inside the model.xml file in <LL:Annotation> tags.
#define KEEP_OLD_STYLE_METADATA_XML_FILE_LOADING_FOR_COMPATIBILITY 1
// Limit the precision of floating point numbers in metaData.xml to
// avoid the metaData.xml file changing arbitrarily.
#define METADATA_FLOAT_PRECISION 6
/*!
* \brief The projectObject class stores the data for a project that is not currently selected.
*
* When projects
* are selected the data for the deselected project is stored into the project object and the data from the
* selected project object is loaded into the network rootdata class. Data is also stored for save events.
*/
class projectObject : public QObject
{
Q_OBJECT
public:
explicit projectObject(QObject *parent = 0);
~projectObject();
// menu item
QAction * menuAction;
// save and load
bool open_project(QString);
bool save_project(QString, nl_rootdata *);
bool import_network(QString, cursorType);
void import_component(QString);
void import_layout(QString);
bool load_project_file(QString fileName);
bool save_project_file(QString fileName);
void copy_back_data(nl_rootdata *);
void copy_out_data(nl_rootdata *);
void deselect_project(nl_rootdata *);
void select_project(nl_rootdata *);
/*!
* Find the extent of the network - positions of a set of
* populations. Returns a pair of QPointFs - the first is the top
* left extent, the second is the bottom right extent. So, the
* left most extent is given by rtn.first.x() and the top most
* extent by rtn.first.y(). The right extent is rtn.second.x() and
* the bottom extent is rtn.second.y().
*/
std::pair<QPointF, QPointF> getNetworkExtent (QVector < QSharedPointer <population> >& pops);
// To finish the job of allowing an imported network to be
// auto-located, we would need a translateNetwork() method, which
// updates all the positions of the populations and connections in
// the network.
// errors
void printIssues(QString);
// general helpers
bool isChanged(nl_rootdata *);
bool isValidPointer(QSharedPointer<systemObject>);
bool isValidPointer(QSharedPointer <ComponentInstance>);
bool isValidPointer(QSharedPointer<Component>);
QAction * action(int);
/*!
* \brief getComponentDataFromName
* \param name
* \return
* Look up a ComponentData by its name - this is used to reconnect pointers after a project is loaded in
*/
QSharedPointer<ComponentInstance> getComponentDataFromName(QString name);
// info
QString name;
/*!
* Return a filename-friendly version of @see name. This is used
* as the sub-directory in the working directory where the model
* is simulated. It means that we don't get a pollution of the
* "Loaded Logs" when working in the graph interface.
*/
QString getFilenameFriendlyName (void);
/*!
* Does the given experiment pointer match one stored for this
* project?
*/
bool doesExperimentExist (experiment* e);
QString filePath;
QString networkFile;
#ifdef KEEP_OLD_STYLE_METADATA_XML_FILE_LOADING_FOR_COMPATIBILITY
/*!
* The name of hte old-style standalone metadata file (was
* usually/always metaData.xml).
*
* This now defaults to being empty. If a metaFile is specified in
* the SpineCreator project file, then that value is filled in here.
*/
QString metaFile;
#endif
QStringList components;
QStringList experiments;
QStringList layouts;
// A list of additional files that should be copied/saved with the
// model. Specified in the proj file in <AdditionalFiles>. Should
// be expanded here at runtime into absolute paths so that these
// can be copied into the new directory with save_project.
QStringList additionalFiles;
// storage for objects
QVector < QSharedPointer <population> > network;
QVector < QSharedPointer<Component> > catalogNB;
QVector < QSharedPointer<Component> > catalogWU;
QVector < QSharedPointer<Component> > catalogPS;
QVector < QSharedPointer<Component> > catalogGC;
QVector < QSharedPointer<NineMLLayout> > catalogLAY;
QVector < experiment * > experimentList;
// features
versionControl version;
QUndoStack * undoStack;
// state of the visualizer QTreeWidget
QStringList treeWidgetState;
// Getter for currentCursorPos
cursorType getCursorPos (void);
// A string annotation for the modeller to write something useful
// about this object.
QString annotation;
private:
cursorType currentCursorPos;
// load helpers
bool isComponent(QString);
bool isLayout(QString);
void loadComponent(QString, QDir);
void saveComponent(QString, QDir, QSharedPointer<Component>);
void loadLayout(QString, QDir);
void saveLayout(QString, QDir, QSharedPointer<NineMLLayout>);
void loadNetwork(QString, QDir, bool isProject = true);
void saveNetwork(QString, QDir);
void loadExperiment(QString, QDir, bool skipFileError = false);
void saveExperiment(QString, QDir, experiment *);
// error handling
bool printWarnings(QString);
bool printErrors(QString);
void addError(QString);
void addWarning(QString);
// other helper
QString getUniquePopName(QString);
/*!
* Looks in modelXml and finds all the explicitDataBinaryFile
* file_names. It then checks these are all present and removes
* any stale ones from the model file directory.
*/
void cleanUpStaleExplicitData(QString& fileName, QDir& projectDir);
QDomDocument doc;
#ifdef KEEP_OLD_STYLE_METADATA_XML_FILE_LOADING_FOR_COMPATIBILITY
/*!
* A QDomDocument into the metaData.xml file. Required only for
* loading old-style projects.
*/
QDomDocument meta;
#endif
signals:
public slots:
};
#endif // PROJECTOBJECT_H