Isis 3.0
Home
WorkOrder.h
Go to the documentation of this file.
1 #ifndef WorkOrder_H
2 #define WorkOrder_H
3 
26 #include <QAction>
27 #include <QDateTime>
28 // This is needed for the QVariant macro
29 #include <QMetaType>
30 #include <QPointer>
31 #include <QUndoCommand>
32 
33 
34 
35 #include "CorrelationMatrix.h"
36 #include "GuiCamera.h"
37 #include "TargetBody.h"
38 #include "XmlStackedHandler.h"
39 
40 template<typename T> class QFutureWatcher;
41 class QMutex;
42 class QXmlStreamWriter;
43 
44 namespace Isis {
45  class Control;
46  class ControlList;
47  class Directory;
48  class ImageList;
49  class ProgressBar;
50  class Project;
51  class ProjectItem;
52  class ShapeList;
53  class XmlStackedHandlerReader;
54 
104  class WorkOrder : public QAction, public QUndoCommand {
105  Q_OBJECT
106  public:
107 
108 
109 
126  };
127 
132  enum Context {
135  };
136 
138  virtual ~WorkOrder();
139 
140  virtual WorkOrder *clone() const = 0;
141 
142  virtual bool isExecutable(Context);
143  virtual bool isExecutable(ImageList *images);
144  virtual bool isExecutable(ShapeList *shapes);
145  virtual bool isExecutable(ControlList *controls);
146  virtual bool isExecutable(CorrelationMatrix);
147  virtual bool isExecutable(TargetBodyQsp targetBody);
148  virtual bool isExecutable(GuiCameraQsp guiCamera);
149  virtual bool isExecutable(ProjectItem *item);
150 
151  void read(XmlStackedHandlerReader *xmlReader);
152  void save(QXmlStreamWriter &stream) const;
153 
154  virtual void setData(Context);
155  virtual void setData(ImageList *images);
156  virtual void setData(ShapeList *shapes);
157  virtual void setData(ControlList *controls);
158  virtual void setData(CorrelationMatrix);
159  virtual void setData(TargetBodyQsp targetBody);
160  virtual void setData(GuiCameraQsp guiCamera);
161  virtual void setData(ProjectItem *item);
162 
163 
164  void setNext(WorkOrder *nextWorkOrder);
165  void setPrevious(WorkOrder *previousWorkOrder);
166 
167  QString bestText() const;
168  bool createsCleanState() const;
169  QDateTime executionTime() const;
170  bool isFinished() const;
171  bool isRedoing() const;
172  bool isRedone() const;
173  bool isUndoing() const;
174  bool isUndone() const;
175  bool modifiesDiskState() const;
176  WorkOrder *next() const;
177  WorkOrder *previous() const;
178  QString statusText() const;
179 
181 
182  static WorkOrderStatus fromStatusString(QString);
183  static QString toString(WorkOrderStatus);
184 
185  signals:
186  void creatingProgress(WorkOrder *);
187  // This is necessary because QTreeWidget doesn't support us just deleting the progress bar..
188  // HistoryWidget relies on this signal.
189  void deletingProgress(WorkOrder *);
190  void finished(WorkOrder *);
191  void statusChanged(WorkOrder *);
192 
193  public slots:
217  virtual bool execute();
218 
219  virtual void redo();
220  virtual void undo();
221 
222  protected:
223  WorkOrder(const WorkOrder &other);
224 
225  ImageList *imageList();
226  const ImageList *imageList() const;
227 
228  ShapeList *shapeList();
229  const ShapeList *shapeList() const;
230 
232 
233  QPointer<ControlList> controlList();
234 
236 
238 
239  virtual bool dependsOn(WorkOrder *other) const;
240 
241  Directory *directory() const;
242  Project *project() const;
243 
245  void setModifiesDiskState(bool changesProjectOnDisk);
246  void setInternalData(QStringList data);
247 
248  int progressMin() const;
249  int progressMax() const;
250  int progressValue() const;
251  void setProgressRange(int, int);
252  void setProgressValue(int);
253 
254  QStringList internalData() const;
255  virtual void syncRedo();
256  virtual void asyncRedo();
257  virtual void postSyncRedo();
258  virtual void syncUndo();
259  virtual void asyncUndo();
260  virtual void postSyncUndo();
261 
262  protected slots:
263  void addCloneToProject();
264 
265  private:
266  bool isInStableState() const;
267  void listenForImageDestruction();
268  void listenForShapeDestruction();
269  void resetProgressBar();
270  void setProgressToFinalText();
271 
272  private slots:
273  void attemptQueuedAction();
274  void asyncFinished();
275  void clearImageList();
276  void clearShapeList();
277  void deleteProgress();
278  void updateProgress();
279  void startRedo();
280 
281  private:
285  enum QueuedWorkOrderAction {
286  NoQueuedAction,
287  RedoQueuedAction,
288  UndoQueuedAction
289  };
290 
299  class XmlHandler : public XmlStackedHandler {
300  public:
301  XmlHandler(WorkOrder *workOrder);
302 
303  virtual bool startElement(const QString &namespaceURI, const QString &localName,
304  const QString &qName, const QXmlAttributes &atts);
305 
306  private:
307  Q_DISABLE_COPY(XmlHandler);
308 
313  WorkOrder *m_workOrder;
314  };
315 
316 
317  private:
318  WorkOrder &operator=(const WorkOrder &rhs);
319 
325  bool m_createsCleanState;
326 
332  bool m_modifiesDiskState;
333 
334  WorkOrderStatus m_status;
335  QueuedWorkOrderAction m_queuedAction;
336 
340  int m_progressRangeMinValue;
344  int m_progressRangeMaxValue;
348  int m_progressValue;
349 
350  Context m_context;
351  QPointer<ImageList> m_imageList;
352  QPointer<ShapeList> m_shapeList;
353  QPointer<ControlList> m_controlList;
354  CorrelationMatrix m_correlationMatrix;
359  GuiCameraQsp m_guiCamera;
360 
361 
366  TargetBodyQsp m_targetBody;
367 
368 
373  QStringList m_imageIds;
374 
379  QStringList m_shapeIds;
380 
384  QStringList m_internalData;
385 
389  QPointer<WorkOrder> m_nextWorkOrder;
390 
394  QPointer<WorkOrder> m_previousWorkOrder;
395 
399  QPointer<Project> m_project;
400 
405  QMutex *m_transparentConstMutex;
406 
410  QDateTime m_executionTime;
411 
417  QPointer< QFutureWatcher<void> > m_futureWatcher;
418 
419 
420 
424  QPointer<ProgressBar> m_progressBar;
425 
429  QPointer<QTimer> m_progressBarUpdateTimer;
430 
434  QPointer<QTimer> m_progressBarDeletionTimer;
435 
436 
440  QTime *m_elapsedTimer;
441 
445  double m_secondsElapsed;
446  };
447 }
448 
451 
452 #endif
void finished(WorkOrder *)
Definition: moc_WorkOrder.cpp:259
Internalizes a list of shapes and allows for operations on the entire list.
Definition: ShapeList.h:33
void setProgressValue(int)
Sets the current progress value for the WorkOrder.
Definition: WorkOrder.cpp:1177
Internalizes a list of images and allows for operations on the entire list.
Definition: ImageList.h:44
The main project for cnetsuite.
Definition: Project.h:105
Definition: WorkOrder.h:116
This is a container for the correlation matrix that comes from a bundle adjust.
Definition: CorrelationMatrix.h:72
Definition: WorkOrder.h:125
Definition: WorkOrder.h:134
Definition: WorkOrder.h:118
virtual void syncUndo()
This method is designed to be implemented by children work orders.
Definition: WorkOrder.cpp:1254
Maintains a list of Controls so that control nets can easily be copied from one Project to another...
Definition: ControlList.h:34
Project * project() const
Returns the Project this WorkOrder is attached to.
Definition: WorkOrder.cpp:1116
void read(XmlStackedHandlerReader *xmlReader)
Read this work order&#39;s data from disk.
Definition: WorkOrder.cpp:454
bool createsCleanState() const
Returns the CleanState status (whether the Project has been saved to disk or not).
Definition: WorkOrder.cpp:721
WorkOrder * previous() const
Gets the previous WorkOrder.
Definition: WorkOrder.cpp:803
Q_DECLARE_METATYPE(Isis::Cube *)
This allows Cube *&#39;s to be stored in a QVariant.
int progressMin() const
Gets the minimum value of the progress range of the WorkOrder.
Definition: WorkOrder.cpp:1139
QStringList internalData() const
Gets the internal data for this WorkOrder.
Definition: WorkOrder.cpp:1186
int progressMax() const
Gets the maximum value of the progress range of the WorkOrder.
Definition: WorkOrder.cpp:1148
bool isRedone() const
Returns the WorkOrder redone status.
Definition: WorkOrder.cpp:757
TargetBodyQsp targetBody()
WorkOrder::targetBody.
Definition: WorkOrder.cpp:666
ShapeList * shapeList()
a pointer to the ShapeList for this WorkOrder.
Definition: WorkOrder.cpp:596
Definition: WorkOrder.h:115
virtual void redo()
Starts (or enqueues) a redo.
Definition: WorkOrder.cpp:900
virtual bool isExecutable(Context)
Re-implement this method if your work order utilizes controls for data in order to operate...
Definition: WorkOrder.cpp:179
void deletingProgress(WorkOrder *)
Definition: moc_WorkOrder.cpp:252
virtual void postSyncRedo()
This method is designed to be implemented by children work orders.
Definition: WorkOrder.cpp:1238
WorkOrder(Project *project)
Create a work order that will work with the given project.
Definition: WorkOrder.cpp:55
virtual void undo()
Starts (or enqueues) an undo.
Definition: WorkOrder.cpp:994
static QString toString(WorkOrderStatus)
Gets the current status of the WorkOrder.
Definition: WorkOrder.cpp:865
Parent class for anything that performs an action in Project.
Definition: WorkOrder.h:104
void creatingProgress(WorkOrder *)
Definition: moc_WorkOrder.cpp:245
int progressValue() const
Gets the current progress value of the WorkOrder.
Definition: WorkOrder.cpp:1157
Definition: AbstractTableModel.h:16
QSharedPointer< TargetBody > TargetBodyQsp
Defines A smart pointer to a TargetBody obj.
Definition: TargetBody.h:224
virtual void postSyncUndo()
This method is designed to be implemented by children work orders.
Definition: WorkOrder.cpp:1287
bool isFinished() const
Returns the finished state of this WorkOrder.
Definition: WorkOrder.cpp:739
WorkOrderStatus
This enumeration is used by other functions to set and retrieve the current state of the WorkOrder...
Definition: WorkOrder.h:114
virtual void asyncUndo()
This method is designed to be implemented by children work orders.
Definition: WorkOrder.cpp:1271
void setPrevious(WorkOrder *previousWorkOrder)
Sets the previous WorkOrder in the sequence.
Definition: WorkOrder.cpp:556
Definition: WorkOrder.h:133
virtual void setData(Context)
Sets the context data for this WorkOrder.
Definition: WorkOrder.cpp:245
void setProgressRange(int, int)
Sets the progress range of the WorkOrder.
Definition: WorkOrder.cpp:1167
bool modifiesDiskState() const
Returns the modified disk state.
Definition: WorkOrder.cpp:785
virtual ~WorkOrder()
The Destructor.
Definition: WorkOrder.cpp:97
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
void setModifiesDiskState(bool changesProjectOnDisk)
.
Definition: WorkOrder.cpp:1531
QString statusText() const
WorkOrder::statusText.
Definition: WorkOrder.cpp:812
QSharedPointer< GuiCamera > GuiCameraQsp
GuiCameraQsp Represents a smart pointer to a GuiCamera object.
Definition: GuiCamera.h:188
void statusChanged(WorkOrder *)
Definition: moc_WorkOrder.cpp:266
bool isUndone() const
Returns the WorkOrder undo status.
Definition: WorkOrder.cpp:775
virtual WorkOrder * clone() const =0
bool isRedoing() const
Returns the redoing status of this WorkOrder.
Definition: WorkOrder.cpp:748
QString bestText() const
We don&#39;t use action text anymore because Directory likes to rename our actions.
Definition: WorkOrder.cpp:701
WorkOrder * next() const
Gets the next WorkOrder.
Definition: WorkOrder.cpp:794
Context
This enumeration is for recording the context of the current Workorder (whether it is part of a proje...
Definition: WorkOrder.h:132
static WorkOrderStatus fromStatusString(QString)
Attempts to query the current status of the WorkOrder.
Definition: WorkOrder.cpp:844
Definition: WorkOrder.h:119
Represents an item of a ProjectItemModel in Qt&#39;s model-view framework.
Definition: ProjectItem.h:113
Directory * directory() const
Returns the Directory object of the Project this WorkOrder is attached to.
Definition: WorkOrder.cpp:1106
QDateTime executionTime() const
Gets the execution time of this WorkOrder.
Definition: WorkOrder.cpp:730
bool isUndoing() const
Returns the WorkOrderUndoing state.
Definition: WorkOrder.cpp:766
CorrelationMatrix correlationMatrix()
Returns the CorrleationMatrix for this WorkOrder.
Definition: WorkOrder.cpp:628
void setNext(WorkOrder *nextWorkOrder)
Sets the next WorkOrder in the sequence.
Definition: WorkOrder.cpp:547
This is used for work orders that will not undo or redo (See createsCleanState()) ...
Definition: WorkOrder.h:124
Definition: WorkOrder.h:117
QProgressBar with customizable text.
Definition: ProgressBar.h:15
void save(QXmlStreamWriter &stream) const
: Saves a WorkOrder to a data stream.
Definition: WorkOrder.cpp:478
GuiCameraQsp guiCamera()
WorkOrder::guiCamera.
Definition: WorkOrder.cpp:675
virtual bool execute()
The (child) implementation of this method should prompt the user/gather state by any means necessary...
Definition: WorkOrder.cpp:1078
QPointer< ControlList > controlList()
Returns the Control List for this WorkOrder (a list of control networks).
Definition: WorkOrder.cpp:637
ProgressBar * progressBar()
Returns the ProgressBar.
Definition: WorkOrder.cpp:832
ImageList * imageList()
a pointer to the ImageList for this WorkOrder.
Definition: WorkOrder.cpp:565
virtual void asyncRedo()
This method is designed to be implemented by children work orders.
Definition: WorkOrder.cpp:1222
Definition: Directory.h:106
his enables stack-based XML parsing of XML files.
Definition: XmlStackedHandlerReader.h:26
void addCloneToProject()
Runs a copy of the current WorkOrder and stores it in the project.
Definition: WorkOrder.cpp:1294
void setInternalData(QStringList data)
Sets the internal data for this WorkOrder.
Definition: WorkOrder.cpp:1130
void setCreatesCleanState(bool createsCleanState)
Declare that this work order is saving the project.
Definition: WorkOrder.cpp:1520
virtual bool dependsOn(WorkOrder *other) const
This is a virtual function whose role in child classes is to determine if this WorkOrder deppends on ...
Definition: WorkOrder.cpp:688
Definition: WorkOrder.h:120
virtual void syncRedo()
This method is designed to be implemented by children work orders.
Definition: WorkOrder.cpp:1203