Isis 3.0 Programmer Reference
Back | 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 
115  WorkOrderUnknownStatus = 0,
116  WorkOrderNotStarted,
117  WorkOrderRedoing,
118  WorkOrderRedone,
119  WorkOrderUndoing,
120  WorkOrderUndone,
125  WorkOrderLastStatus = WorkOrderFinished
126  };
127 
132  enum Context {
133  NoContext,
134  ProjectContext
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;
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:
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 
314  };
315 
316 
317  private:
318  WorkOrder &operator=(const WorkOrder &rhs);
319 
326 
333 
334  WorkOrderStatus m_status;
335  QueuedWorkOrderAction m_queuedAction;
336 
349 
350  Context m_context;
351  QPointer<ImageList> m_imageList;
352  QPointer<ShapeList> m_shapeList;
353  QPointer<ControlList> m_controlList;
354  CorrelationMatrix m_correlationMatrix;
360 
361 
367 
368 
374 
380 
385 
389  QPointer<WorkOrder> m_nextWorkOrder;
390 
394  QPointer<WorkOrder> m_previousWorkOrder;
395 
399  QPointer<Project> m_project;
400 
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 
441 
446  };
447 }
448 
451 
452 #endif
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
bool m_modifiesDiskState
This is defaulted to false.
Definition: WorkOrder.h:332
The main project for cnetsuite.
Definition: Project.h:105
void deleteProgress()
Deletes the progress bar.
Definition: WorkOrder.cpp:1483
XmlHandler(WorkOrder *workOrder)
Passes a pointer to a WorkOrder to the WorkOrder::XmlHandler class.
Definition: WorkOrder.cpp:1540
This is a container for the correlation matrix that comes from a bundle adjust.
void attemptQueuedAction()
Attempts to execute an action on the action action queue.
Definition: WorkOrder.cpp:1419
virtual bool startElement(const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &atts)
The XML reader invokes this method at the start of every element in the XML document.
Definition: WorkOrder.cpp:1559
void updateProgress()
Updates the progress bar.
Definition: WorkOrder.cpp:1497
virtual void syncUndo()
This method is designed to be implemented by children work orders.
Definition: WorkOrder.cpp:1254
QPointer< QTimer > m_progressBarUpdateTimer
A pointer to the QTimer which updates the ProgressBar.
Definition: WorkOrder.h:429
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
int m_progressRangeMinValue
The miniumum value of the Progess Bar.
Definition: WorkOrder.h:340
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
QPointer< WorkOrder > m_previousWorkOrder
A pointer to the previous WorkOrder in the queue.
Definition: WorkOrder.h:394
QStringList internalData() const
Gets the internal data for this WorkOrder.
Definition: WorkOrder.cpp:1186
void asyncFinished()
Signals the Project that the WorkOrder is finished, deletes the update time for the Progress bar...
Definition: WorkOrder.cpp:1436
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
virtual void redo()
Starts (or enqueues) a redo.
Definition: WorkOrder.cpp:900
QPointer< ProgressBar > m_progressBar
A pointer to the ProgressBar.
Definition: WorkOrder.h:424
virtual bool isExecutable(Context)
Re-implement this method if your work order utilizes controls for data in order to operate...
Definition: WorkOrder.cpp:179
QTime * m_elapsedTimer
A QTime object holding the excecution time of the WorkOrder.
Definition: WorkOrder.h:440
QDateTime m_executionTime
This is the date/time that execute() was called.
Definition: WorkOrder.h:410
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
void listenForShapeDestruction()
Checks to see if we have lost any shapes in the ShapeList.
Definition: WorkOrder.cpp:1344
static QString toString(WorkOrderStatus)
Gets the current status of the WorkOrder.
Definition: WorkOrder.cpp:865
QPointer< QTimer > m_progressBarDeletionTimer
A pointer to the ProgressBar deletion timer.
Definition: WorkOrder.h:434
Parent class for anything that performs an action in Project.
Definition: WorkOrder.h:104
int m_progressValue
The current value of the Progress Bar.
Definition: WorkOrder.h:348
int progressValue() const
Gets the current progress value of the WorkOrder.
Definition: WorkOrder.cpp:1157
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
QStringList m_internalData
A QStringList of internal properties for this WorkOrder.
Definition: WorkOrder.h:384
XML Handler that parses XMLs in a stack-oriented way.
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
QPointer< WorkOrder > m_nextWorkOrder
A pointer to the next WorkOrder in the queue.
Definition: WorkOrder.h:389
bool m_createsCleanState
This is defaulted to false.
Definition: WorkOrder.h:325
virtual void setData(Context)
Sets the context data for this WorkOrder.
Definition: WorkOrder.cpp:245
void clearShapeList()
Clears the list of shapes.
Definition: WorkOrder.cpp:1475
int m_progressRangeMaxValue
The maximum value of the Progess Bar.
Definition: WorkOrder.h:344
void resetProgressBar()
Resets the ProgressBar.
Definition: WorkOrder.cpp:1362
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
TargetBodyQsp m_targetBody
A QSharedPointer to the TargetBody (A Target object but encapsulated within a Gui framework...
Definition: WorkOrder.h:366
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
double m_secondsElapsed
The seconds that have elapsed since the WorkOrder started executing.
Definition: WorkOrder.h:445
void setModifiesDiskState(bool changesProjectOnDisk)
.
Definition: WorkOrder.cpp:1531
bool isInStableState() const
Determines if the WorkOrder is in a stable state, or if it&#39;s busy doing something.
Definition: WorkOrder.cpp:1305
QString statusText() const
WorkOrder::statusText.
Definition: WorkOrder.cpp:812
QPointer< QFutureWatcher< void > > m_futureWatcher
A pointer to a QFutureWatcher object which monitors a QFuture object using signals and slots...
Definition: WorkOrder.h:417
QSharedPointer< GuiCamera > GuiCameraQsp
GuiCameraQsp Represents a smart pointer to a GuiCamera object.
Definition: GuiCamera.h:188
QueuedWorkOrderAction
This enum describes the current state of a Queued WorkOrder.
Definition: WorkOrder.h:285
QMutex * m_transparentConstMutex
This is used to protect the integrity of data the WorkOrder is working on so that only one thread at ...
Definition: WorkOrder.h:405
bool isUndone() const
Returns the WorkOrder undo status.
Definition: WorkOrder.cpp:775
void listenForImageDestruction()
Checks to see if we have lost any images in the ImageList.
Definition: WorkOrder.cpp:1321
bool isRedoing() const
Returns the redoing status of this WorkOrder.
Definition: WorkOrder.cpp:748
void setProgressToFinalText()
Sets the ProgressBar to display the final status of the operation.
Definition: WorkOrder.cpp:1386
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
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
QProgressBar with customizable text.
Definition: ProgressBar.h:15
This class is used for processing an XML file containing information about a WorkOrder.
Definition: WorkOrder.h:299
void save(QXmlStreamWriter &stream) const
: Saves a WorkOrder to a data stream.
Definition: WorkOrder.cpp:478
GuiCameraQsp m_guiCamera
A QSharedPointer to the GuiCamera (the Camera object but encapsulated within a Gui framework...
Definition: WorkOrder.h:359
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
his enables stack-based XML parsing of XML files.
void addCloneToProject()
Runs a copy of the current WorkOrder and stores it in the project.
Definition: WorkOrder.cpp:1294
QStringList m_shapeIds
A QStringList of unique shape identifiers for all of the shapes this WorkOrder is dealing with...
Definition: WorkOrder.h:379
void clearImageList()
Clears the list of images.
Definition: WorkOrder.cpp:1467
void setInternalData(QStringList data)
Sets the internal data for this WorkOrder.
Definition: WorkOrder.cpp:1130
void startRedo()
WorkOrder::startRedo This function is currently empty.
Definition: WorkOrder.cpp:1508
void setCreatesCleanState(bool createsCleanState)
Declare that this work order is saving the project.
Definition: WorkOrder.cpp:1520
QPointer< Project > m_project
A pointer to the Project this WorkOrder is attached to.
Definition: WorkOrder.h:399
QStringList m_imageIds
A QStringList of unique image identifiers for all of the images this WorkOrder is dealing with...
Definition: WorkOrder.h:373
WorkOrder * m_workOrder
This is a pointer to the WorkOrder the XmlHandler is filling with information it parses from an XML f...
Definition: WorkOrder.h:313
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
virtual void syncRedo()
This method is designed to be implemented by children work orders.
Definition: WorkOrder.cpp:1203

U.S. Department of the Interior | U.S. Geological Survey
ISIS | Privacy & Disclaimers | Astrogeology Research Program
To contact us, please post comments and questions on the ISIS Support Center
File Modified: 07/12/2023 23:31:48