OpenIndy-Core  0.2.0.43
oijob.h
Go to the documentation of this file.
1 #ifndef OIJOB_H
2 #define OIJOB_H
3 
4 #include <QObject>
5 #include <QPointer>
6 #include <QString>
7 #include <QList>
8 #include <QStringList>
9 #include <QMap>
10 #include <QMultiMap>
11 #include <QIODevice>
12 #include <QSet>
13 #include <QRegExp>
14 #include <QStringRef>
15 
16 #include "featurecontainer.h"
17 #include "featureattributes.h"
18 #include "function.h"
19 #include "types.h"
20 #include "util.h"
21 
22 class ProjectExchanger;
23 
24 namespace oi{
25 
30 class OI_CORE_EXPORT OiJob : public QObject
31 {
32  friend class ProjectExchanger;
33  Q_OBJECT
34 
35 public:
36  explicit OiJob(QObject *parent = 0);
37 
38  ~OiJob();
39 
40  //####################################
41  //get or set meta information of a job
42  //####################################
43 
44  const QString &getJobName() const;
45  void setJobName(const QString &jobName);
46 
47  const QPointer<QIODevice> &getJobDevice() const;
48  void setJobDevice(const QPointer<QIODevice> &jobDevice);
49 
50  int generateUniqueId();
51 
52  bool validateFeatureName(const QString &name, const FeatureTypes &type, const bool &isNominal = false,
53  const QPointer<CoordinateSystem> &nominalSystem = QPointer<CoordinateSystem>(NULL));
54 
55  //###########################################
56  //methods to access the current feature state
57  //###########################################
58 
59  //number of features
60  int getFeatureCount() const;
61  int getGeometryCount() const;
62  int getFeatureCount(const FeatureTypes &type) const;
63  int getFeatureCount(const QString &group) const;
64  int getFeatureCount(const QPair<QString, bool> &mConfig) const;
65 
66  //access a list of all feature ids and names
67  const QList<int> &getFeatureIdList() const;
68  const QStringList &getFeatureNameList() const;
69  const QStringList &getFeatureGroupList() const;
70  const QList<QPair<QString, bool> > &getUsedMeasurementConfigs() const;
71 
72  //access feature lists
73  const QList<QPointer<FeatureWrapper> > &getFeaturesList() const;
74  const QList<QPointer<CoordinateSystem> > &getCoordinateSystemsList() const;
75  QList<QPointer<CoordinateSystem> > getStationSystemsList() const;
76  const QList<QPointer<Station> > &getStationsList() const;
77  const QList<QPointer<TrafoParam> > &getTransformationParametersList() const;
78  const QList<QPointer<FeatureWrapper> > &getGeometriesList() const;
79 
80  //access specific features
81  QPointer<FeatureWrapper> getFeatureById(const int &featureId) const;
82  QList<QPointer<FeatureWrapper> > getFeaturesByName(const QString &name) const;
83  QList<QPointer<FeatureWrapper> > getFeaturesByGroup(const QString &group) const;
84  QList<QPointer<FeatureWrapper> > getFeaturesByType(const FeatureTypes &type) const;
85  QList<QPointer<Geometry> > getGeometriesByMConfig(const QPair<QString, bool> &mConfig) const;
86 
87  //access active features
88  const QPointer<FeatureWrapper> &getActiveFeature() const;
89  const QPointer<Station> &getActiveStation() const;
90  const QPointer<CoordinateSystem> &getActiveCoordinateSystem() const;
91 
92  //get or set feature groups
93  const QString &getActiveGroup() const;
94  bool setActiveGroup(const QString &group);
95 
96  //######################
97  //add or remove features
98  //######################
99 
100  bool addFeature(const QPointer<FeatureWrapper> &feature);
101  QList<QPointer<FeatureWrapper> > addFeatures(const FeatureAttributes &fAttr);
102  bool addFeatures(const QList<QPointer<FeatureWrapper> > &features);
103 
104  bool removeFeature(const int &featureId);
105  bool removeFeature(const QPointer<FeatureWrapper> &feature);
106  bool removeFeatures(const QSet<int> &featureIds);
107  bool removeFeatures(const QList<QPointer<FeatureWrapper> > &features);
108 
109  void removeAll();
110 
111  //##########################################
112  //add or remove functions and input elements
113  //##########################################
114 
115  //add or remove functions
116  void addFunction(const QPointer<Function> &function);
117  void removeFunction(const int &functionIndex);
118 
119  //add input elements to a feature's function
120  void addInputObservation(const QPointer<FeatureWrapper> &target, const int &functionPosition, const int &neededElementsIndex, const QPointer<Observation> &observation);
121  void addInputReading(const QPointer<FeatureWrapper> &target, const int &functionPosition, const int &neededElementsIndex, const QPointer<Reading> &reading);
122  void addInputFeature(const QPointer<FeatureWrapper> &target, const int &functionPosition, const int &neededElementsIndex, const QPointer<FeatureWrapper> &feature);
123 
124  //remove input elements from a feature's function
125  void removeInputElement(const QPointer<FeatureWrapper> &target, const int &functionPosition, const int &neededElementsIndex, const int &elementId);
126 
127  //##########################
128  //add or remove observations
129  //##########################
130 
131  //add new observations
132  void addMeasurementResults(const int &geomId, const QList<QPointer<Reading> > &readings);
133 
134  //remove existing observations
135  void removeObservations(const int &featureId);
136  void removeAllObservations();
137 
138  //###############################
139  //set use state of input elements
140  //###############################
141 
142  void setShouldBeUsed(const QPointer<FeatureWrapper> &target, const int &functionIndex, const int &neededElementIndex,
143  const int &elementId, const bool &use, const bool &recalc);
144 
145 signals:
146 
147  //#########################################
148  //signals to inform about job state changes
149  //#########################################
150 
151  //active feature changes
152  void activeFeatureChanged();
153  void activeStationChanged();
154  void activeCoordinateSystemChanged();
155 
156  //feature(s) added or removed
157  void featureSetChanged();
158  void coordSystemSetChanged();
159  void stationSetChanged();
160  void trafoParamSetChanged();
161  void geometrySetChanged();
162 
163  //group(s) added or removed
164  void availableGroupsChanged();
165  void activeGroupChanged();
166 
167  //general feature attributes changed
168  void featureAttributesChanged();
169 
170  //feature specific attributes changed
171  void featureNameChanged(const int &featureId, const QString &oldName);
172  void featureGroupChanged(const int &featureId, const QString &oldGroup);
173  void featureCommentChanged(const int &featureId);
174  void featureIsUpdatedChanged(const int &featureId); //currently not connected
175  void featureIsSolvedChanged(const int &featureId);
176  void featureFunctionsChanged(const int &featureId);
177  void featureUsedForChanged(const int &featureId);
178  void featurePreviouslyNeededChanged(const int &featureId);
179 
180  //geometry specific attributes changed
181  void geometryIsCommonChanged(const int &featureId);
182  void geometryNominalsChanged(const int &featureId);
183  void geometryActualChanged(const int &featureId);
184  void geometryObservationsChanged(const int &featureId);
185  void geometryNominalSystemChanged(const int &featureId);
186  void geometryStatisticChanged(const int &featureId);
187  void geometrySimulationDataChanged(const int &featureId);
188  void geometryMeasurementConfigChanged(const int &featureId, const QString &oldMConfig, bool oldIsSaved);
189 
190  //coordinate system specific attributes changed
191  void systemObservationsChanged(const int &featureId, const int &obsId);
192  void systemTrafoParamsChanged(const int &featureId);
193  void systemsNominalsChanged(const int &featureId);
194 
195  //station specific attributes changed
196  void stationSensorChanged(const int &featureId);
197 
198  //transformation parameter specific attributes changed
199  void trafoParamParametersChanged(const int &featureId);
200  void trafoParamSystemsChanged(const int &featureId);
201  void trafoParamIsUsedChanged(const int &featureId);
202  void trafoParamValidTimeChanged(const int &featureId);
203  void trafoParamIsMovementChanged(const int &featureId);
204 
205  //###################################################
206  //general signals to inform OpenIndy about job issues
207  //###################################################
208 
209  void sendMessage(const QString &msg, const MessageTypes &msgType, const MessageDestinations &msgDest = eConsoleMessage) const;
210 
211  //##############################
212  //signals to force recalculation
213  //##############################
214 
215  void recalcFeature(const QPointer<Feature> &feature);
216 
217  //#####################################
218  //signals forwarded from FeatureUpdater
219  //#####################################
220 
221  void featuresRecalculated();
222  void featureRecalculated(const int &featureId);
223  void trafoParamRecalculated(const int &featureId);
224 
225 private slots:
226 
227  //###########################################################################
228  //internal slots that are called when a feature changes (or is added/removed)
229  //###########################################################################
230 
231  //active feature changes
232  void setActiveFeature(const int &featureId);
233  void setActiveStation(const int &featureId);
234  void setActiveCoordinateSystem(const int &featureId);
235 
236  //feature specific attributes changed
237  void setFeatureName(const int &featureId, const QString &oldName);
238  void setFeatureGroup(const int &featureId, const QString &oldGroup);
239  void setFeatureComment(const int &featureId);
240  void setFeatureIsUpdated(const int &featureId); //currently not connected
241  void setFeatureIsSolved(const int &featureId);
242  void setFeatureFunctions(const int &featureId);
243  void setFeatureUsedFor(const int &featureId);
244  void setFeaturePreviouslyNeeded(const int &featureId);
245 
246  //geometry specific attributes changed
247  void setGeometryIsCommon(const int &featureId);
248  void setGeometryNominals(const int &featureId);
249  void setGeometryActual(const int &featureId);
250  void setGeometryObservations(const int &featureId);
251  void setGeometryNominalSystem(const int &featureId);
252  void setGeometryStatistic(const int &featureId);
253  void setGeometrySimulationData(const int &featureId);
254  void setGeometryMeasurementConfig(const int &featureId, const QString &oldMConfig, bool oldIsSaved);
255 
256  //coordinate system specific attributes changed
257  void setSystemObservations(const int &featureId, const int &obsId);
258  void setSystemTrafoParams(const int &featureId);
259  void setSystemsNominals(const int &featureId);
260 
261  //station specific attributes changed
262  void setStationSensor(const int &featureId);
263 
264  //transformation parameter specific attributes changed
265  void setTrafoParamParameters(const int &featureId);
266  void setTrafoParamSystems(const int &featureId);
267  void setTrafoParamIsUsed(const int &featureId);
268  void setTrafoParamValidTime(const int &featureId);
269  void setTrafoParamIsMovement(const int &featureId);
270 
271  //element deleted
272  void elementAboutToBeDeleted(const int &elementId, const QString &name, const QString &group, const FeatureTypes &type);
273 
274 private:
275 
276  //##############################
277  //connect or disconnect features
278  //##############################
279 
280  void connectFeature(const QPointer<FeatureWrapper> &feature);
281  void disconnectFeature(const QPointer<FeatureWrapper> &feature);
282 
283  //##############
284  //helper methods
285  //##############
286 
287  QStringList createFeatureNames(const QString &name, const int &count) const;
288  QPointer<FeatureWrapper> createFeatureWrapper(const FeatureTypes &type, bool isNominal = false) const;
289  bool checkAndSetUpNewFeature(const QPointer<FeatureWrapper> &feature);
290 
291  bool canRemoveFeature(const QPointer<FeatureWrapper> &feature) const;
292 
293  bool checkCircleWarning(const QPointer<Feature> &activeFeature, const QPointer<Feature> &usedForActiveFeature);
294 
295  void setUpDependencies(const InputElement &element, const QPointer<Feature> &feature);
296  void resetDependencies(const InputElement &element, const QPointer<Feature> &feature);
297 
298  //###################################################################################
299  //add features when a project has been loaded (only accessible from ProjectExchanger)
300  //###################################################################################
301 
302  void addFeaturesFromXml(const QList<QPointer<FeatureWrapper> > &features);
303 
304 private:
305 
306  //#########################
307  //meta information of a job
308  //#########################
309 
310  QString jobName; //the name under that the job is saved
311  QPointer<QIODevice> jobDevice; //the device where the job is saved
312 
313  //################################
314  //active features and active group
315  //################################
316 
317  //active features
318  QPointer<FeatureWrapper> activeFeature;
319  QPointer<Station> activeStation;
320  QPointer<CoordinateSystem> activeCoordinateSystem;
321 
322  //active group
323  QString activeGroup;
324 
325  //################################
326  //feature container and current id
327  //################################
328 
329  FeatureContainer featureContainer; //all features of this job
330 
331  int nextId; //the next free id an element of this job could get
332 
333 };
334 
335 }
336 
337 #endif // OIJOB_H
FeatureTypes
all OpenIndy feature types
Definition: types.h:95
The FeatureAttributes class Helper class that is used when creating new features to specify their att...
Definition: featureattributes.h:15
Definition: coordinatesystem.h:15
The InputElement class Save the input elements that are used to solve a function. ...
Definition: function.h:62
Definition: types.h:38
MessageDestinations
used to specify where to print a message
Definition: types.h:37
MessageTypes
all types of messages
Definition: types.h:29
The FeatureContainer class Works as a container for all features in an OiJob. The features are stored...
Definition: featurecontainer.h:26
#define OI_CORE_EXPORT
Definition: types.h:11
The OiJob class Represents an OpenIndy job (holds all features and active states) ...
Definition: oijob.h:30