Isis 3 Programmer Reference
WorkOrder.h
Go to the documentation of this file.
1 #ifndef WorkOrder_H
2 #define WorkOrder_H
3 
24 #include <QAction>
25 #include <QDateTime>
26 // This is needed for the QVariant macro
27 #include <QMetaType>
28 #include <QPointer>
29 #include <QUndoCommand>
30 
31 
32 
33 #include "CorrelationMatrix.h"
34 #include "FileItem.h"
35 #include "GuiCamera.h"
36 #include "TargetBody.h"
37 #include "XmlStackedHandler.h"
38 
39 template<typename T> class QFutureWatcher;
40 class QMutex;
41 class QXmlStreamWriter;
42 
43 namespace Isis {
44  class Control;
45  class ControlList;
46  class Directory;
47  class ImageList;
48  class ProgressBar;
49  class Project;
50  class ProjectItem;
51  class ShapeList;
52  class Template;
53  class XmlStackedHandlerReader;
54 
322  class WorkOrder : public QAction, public QUndoCommand {
323  Q_OBJECT
324  public:
325 
326 
327 
333  WorkOrderUnknownStatus = 0,
334  WorkOrderNotStarted,
335  WorkOrderRedoing,
336  WorkOrderRedone,
337  WorkOrderUndoing,
338  WorkOrderUndone,
343  WorkOrderLastStatus = WorkOrderFinished
344  };
345 
350  enum Context {
351  NoContext,
352  ProjectContext
353  };
354 
356  virtual ~WorkOrder();
357 
358  virtual WorkOrder *clone() const = 0;
359 
360  virtual bool isExecutable(Context);
361  virtual bool isExecutable(ImageList *images);
362  virtual bool isExecutable(ShapeList *shapes);
363  virtual bool isExecutable(ControlList *controls);
364  virtual bool isExecutable(CorrelationMatrix);
365  virtual bool isExecutable(TargetBodyQsp targetBody);
366  virtual bool isExecutable(Template *currentTemplate);
367  virtual bool isExecutable(GuiCameraQsp guiCamera);
368  virtual bool isExecutable(FileItemQsp fileItem);
369  virtual bool isExecutable(ProjectItem *item);
370 
371  void read(XmlStackedHandlerReader *xmlReader);
372  void save(QXmlStreamWriter &stream) const;
373 
374  virtual void setData(Context);
375  virtual void setData(QString data);
376  virtual void setData(ImageList *images);
377  virtual void setData(ShapeList *shapes);
378  virtual void setData(ControlList *controls);
379  virtual void setData(Template *currentTemplate);
380  virtual void setData(CorrelationMatrix);
381  virtual void setData(TargetBodyQsp targetBody);
382  virtual void setData(GuiCameraQsp guiCamera);
383  virtual void setData(FileItemQsp fileItem);
384  virtual void setData(ProjectItem *item);
385 
386 
387 
388  void setNext(WorkOrder *nextWorkOrder);
389  void setPrevious(WorkOrder *previousWorkOrder);
390 
391  QString bestText() const;
392  bool isUndoable() const;
393  bool isSavedToHistory() const;
394  bool isSynchronous() const;
395  bool createsCleanState() const;
396  QDateTime executionTime() const;
397  bool isFinished() const;
398  bool isRedoing() const;
399  bool isRedone() const;
400  bool isUndoing() const;
401  bool isUndone() const;
402  bool modifiesDiskState() const;
403  WorkOrder *next() const;
404  WorkOrder *previous() const;
405  QString statusText() const;
406 
408 
409  static WorkOrderStatus fromStatusString(QString);
410  static QString toString(WorkOrderStatus);
411 
412  signals:
413  void creatingProgress(WorkOrder *);
414  // This is necessary because QTreeWidget doesn't support us just deleting the progress bar..
415  // HistoryWidget relies on this signal.
416  void deletingProgress(WorkOrder *);
417  void finished(WorkOrder *);
418  void statusChanged(WorkOrder *);
419 
420  public slots:
421  void enableWorkOrder();
422  void disableWorkOrder();
423 
424  virtual bool setupExecution();
425 
426  virtual void execute();
427 
428  virtual void redo();
429  virtual void undo();
430 
431  protected:
432  WorkOrder(const WorkOrder &other);
433 
434  ImageList *imageList();
435  const ImageList *imageList() const;
436 
437  ShapeList *shapeList();
438  const ShapeList *shapeList() const;
439 
441 
442  QPointer<ControlList> controlList();
443 
445 
447 
449 
451 
452  virtual bool dependsOn(WorkOrder *other) const;
453 
454  Directory *directory() const;
455  Project *project() const;
456 
458  void setModifiesDiskState(bool changesProjectOnDisk);
459  void setInternalData(QStringList data);
460 
461  int progressMin() const;
462  int progressMax() const;
463  int progressValue() const;
464  void setProgressRange(int, int);
465  void setProgressValue(int);
466 
467  QStringList internalData() const;
468  virtual void postExecution();
469  virtual void undoExecution();
470  virtual void postUndoExecution();
471 
472  protected slots:
473  void addCloneToProject();
474 
475  private:
476  bool isInStableState() const;
479  void resetProgressBar();
480  void setProgressToFinalText();
481 
482  private slots:
483  void attemptQueuedAction();
484  void executionFinished();
485  void clearImageList();
486  void clearShapeList();
487  void updateProgress();
488  void startRedo();
489 
490  private:
495  NoQueuedAction,
496  RedoQueuedAction,
497  UndoQueuedAction
498  };
499 
508  class XmlHandler : public XmlStackedHandler {
509  public:
510  XmlHandler(WorkOrder *workOrder);
511 
512  virtual bool startElement(const QString &namespaceURI, const QString &localName,
513  const QString &qName, const QXmlAttributes &atts);
514 
515  private:
516  Q_DISABLE_COPY(XmlHandler);
517 
523  };
524 
525  protected:
535 
542 
549 
550  WorkOrderStatus m_status;
551 
552  private:
553  WorkOrder &operator=(const WorkOrder &rhs);
554 
561 
568 
569  QueuedWorkOrderAction m_queuedAction;
570 
583 
584  Context m_context;
585  QString m_data;
586  QPointer<ImageList> m_imageList;
587  QPointer<ShapeList> m_shapeList;
588  QPointer<ControlList> m_controlList;
589  CorrelationMatrix m_correlationMatrix;
595 
596 
602 
603 
609 
610 
615 
616 
622 
628 
633 
637  QPointer<WorkOrder> m_nextWorkOrder;
638 
642  QPointer<WorkOrder> m_previousWorkOrder;
643 
647  QPointer<Project> m_project;
648 
654 
658  QDateTime m_executionTime;
659 
665  QPointer< QFutureWatcher<void> > m_futureWatcher;
666 
667 
668 
672  QPointer<ProgressBar> m_progressBar;
673 
677  QPointer<QTimer> m_progressBarUpdateTimer;
678 
682  QPointer<QTimer> m_progressBarDeletionTimer;
683 
684 
689 
694  };
695 }
696 
699 
700 #endif
Internalizes a list of shapes and allows for operations on the entire list.
Definition: ShapeList.h:33
QString bestText() const
Generate unique action names We don&#39;t use action text anymore because Directory likes to rename our a...
Definition: WorkOrder.cpp:809
bool isSynchronous() const
Returns true if this work order is run synchronously, otherwise false.
Definition: WorkOrder.cpp:855
bool isInStableState() const
Determines if the WorkOrder is in a stable state, or if it&#39;s busy doing something.
Definition: WorkOrder.cpp:1477
void setProgressValue(int)
Sets the current progress value for the WorkOrder.
Definition: WorkOrder.cpp:1382
Internalizes a list of images and allows for operations on the entire list.
Definition: ImageList.h:55
bool m_modifiesDiskState
This is defaulted to false.
Definition: WorkOrder.h:567
The main project for ipce.
Definition: Project.h:289
virtual void postExecution()
Perform any necessary actions after execution of a workorder.
Definition: WorkOrder.cpp:1428
XmlHandler(WorkOrder *workOrder)
Passes a pointer to a WorkOrder to the WorkOrder::XmlHandler class.
Definition: WorkOrder.cpp:1697
This is a container for the correlation matrix that comes from a bundle adjust.
void attemptQueuedAction()
Attempts to execute an action on the action queue.
Definition: WorkOrder.cpp:1589
bool modifiesDiskState() const
Returns the modified disk state.
Definition: WorkOrder.cpp:938
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:1716
void updateProgress()
Updates the progress bar.
Definition: WorkOrder.cpp:1653
QPointer< QTimer > m_progressBarUpdateTimer
A pointer to the QTimer which updates the ProgressBar.
Definition: WorkOrder.h:677
int progressMax() const
Gets the maximum value of the progress range of the WorkOrder.
Definition: WorkOrder.cpp:1351
bool isRedoing() const
Returns the redoing status of this WorkOrder.
Definition: WorkOrder.cpp:897
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
Maintains a list of Controls so that control nets can easily be copied from one Project to another...
Definition: ControlList.h:36
virtual bool setupExecution()
This sets up the state for the work order.
Definition: WorkOrder.cpp:1275
void read(XmlStackedHandlerReader *xmlReader)
Read this work order&#39;s data from disk.
Definition: WorkOrder.cpp:534
int m_progressRangeMinValue
The miniumum value of the Progess Bar.
Definition: WorkOrder.h:574
WorkOrder * next() const
Gets the next WorkOrder.
Definition: WorkOrder.cpp:948
QPointer< WorkOrder > m_previousWorkOrder
A pointer to the previous WorkOrder in the queue.
Definition: WorkOrder.h:642
bool isRedone() const
Returns the WorkOrder redone status.
Definition: WorkOrder.cpp:907
TargetBodyQsp targetBody()
WorkOrder::targetBody.
Definition: WorkOrder.cpp:760
ShapeList * shapeList()
a pointer to the ShapeList for this WorkOrder.
Definition: WorkOrder.cpp:677
virtual void redo()
Starts (or enqueues) a redo.
Definition: WorkOrder.cpp:1057
QPointer< ProgressBar > m_progressBar
A pointer to the ProgressBar.
Definition: WorkOrder.h:672
virtual bool isExecutable(Context)
Re-implement this method if your work order utilizes controls for data in order to operate...
Definition: WorkOrder.cpp:196
QTime * m_elapsedTimer
A QTime object holding the excecution time of the WorkOrder.
Definition: WorkOrder.h:688
QDateTime m_executionTime
This is the date/time that setupExecution() was called.
Definition: WorkOrder.h:658
WorkOrder(Project *project)
Create a work order that will work with the given project.
Definition: WorkOrder.cpp:55
void disableWorkOrder()
Disables the work order.
Definition: WorkOrder.cpp:1244
virtual void undo()
Starts (or enqueues) an undo.
Definition: WorkOrder.cpp:1160
void listenForShapeDestruction()
Checks to see if we have lost any shapes in the ShapeList.
Definition: WorkOrder.cpp:1516
int progressMin() const
Gets the minimum value of the progress range of the WorkOrder.
Definition: WorkOrder.cpp:1341
static QString toString(WorkOrderStatus)
Gets the current status of the WorkOrder.
Definition: WorkOrder.cpp:1023
QPointer< QTimer > m_progressBarDeletionTimer
A pointer to the ProgressBar deletion timer.
Definition: WorkOrder.h:682
Provide Undo/redo abilities, serialization, and history for an operation.
Definition: WorkOrder.h:322
bool isSavedToHistory() const
Returns true if this work order is to be shown in History, otherwise false.
Definition: WorkOrder.cpp:844
int m_progressValue
The current value of the Progress Bar.
Definition: WorkOrder.h:582
Q_DECLARE_METATYPE(Isis::WorkOrder *)
This allows WorkOrder *&#39;s to be stored in a QVariant.
bool createsCleanState() const
Returns the CleanState status (whether the Project has been saved to disk or not).
Definition: WorkOrder.cpp:868
WorkOrderStatus
This enumeration is used by other functions to set and retrieve the current state of the WorkOrder...
Definition: WorkOrder.h:332
QStringList m_internalData
A QStringList of internal properties for this WorkOrder.
Definition: WorkOrder.h:632
XML Handler that parses XMLs in a stack-oriented way.
virtual void execute()
Execute the workorder.
Definition: WorkOrder.cpp:1417
void setPrevious(WorkOrder *previousWorkOrder)
Sets the previous WorkOrder in the sequence.
Definition: WorkOrder.cpp:636
Template * getTemplate()
WorkOrder::getTemplate.
Definition: WorkOrder.cpp:750
QPointer< WorkOrder > m_nextWorkOrder
A pointer to the next WorkOrder in the queue.
Definition: WorkOrder.h:637
bool m_isSynchronous
This is defaulted to true.
Definition: WorkOrder.h:541
int progressValue() const
Gets the current progress value of the WorkOrder.
Definition: WorkOrder.cpp:1361
WorkOrder * previous() const
Gets the previous WorkOrder.
Definition: WorkOrder.cpp:958
bool m_isUndoable
Set the workorder to be undoable/redoable This is defaulted to true - his will allow the workorder to...
Definition: WorkOrder.h:534
bool m_createsCleanState
This is defaulted to false.
Definition: WorkOrder.h:560
virtual void setData(Context)
Sets the context data for this WorkOrder.
Definition: WorkOrder.cpp:262
void clearShapeList()
Clears the list of shapes.
Definition: WorkOrder.cpp:1645
Template * m_template
A QSharedPointer to the Template (A Template object but encapsulated within a Gui framework...
Definition: WorkOrder.h:601
int m_progressRangeMaxValue
The maximum value of the Progess Bar.
Definition: WorkOrder.h:578
void resetProgressBar()
Resets the ProgressBar.
Definition: WorkOrder.cpp:1534
bool isFinished() const
Returns the finished state of this WorkOrder.
Definition: WorkOrder.cpp:888
void executionFinished()
Signals the Project that the WorkOrder is finished, deletes the update time for the Progress bar...
Definition: WorkOrder.cpp:1606
void setProgressRange(int, int)
Sets the progress range of the WorkOrder.
Definition: WorkOrder.cpp:1372
virtual ~WorkOrder()
The Destructor.
Definition: WorkOrder.cpp:171
bool isUndoing() const
Returns the WorkOrderUndoing state.
Definition: WorkOrder.cpp:917
TargetBodyQsp m_targetBody
A QSharedPointer to the TargetBody (A Target object but encapsulated within a Gui framework...
Definition: WorkOrder.h:608
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:693
void setModifiesDiskState(bool changesProjectOnDisk)
Definition: WorkOrder.cpp:1688
QPointer< QFutureWatcher< void > > m_futureWatcher
A pointer to a QFutureWatcher object which monitors a QFuture object using signals and slots...
Definition: WorkOrder.h:665
QueuedWorkOrderAction
This enum describes the current state of a Queued WorkOrder.
Definition: WorkOrder.h:494
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:653
void listenForImageDestruction()
Checks to see if we have lost any images in the ImageList.
Definition: WorkOrder.cpp:1493
void setProgressToFinalText()
Sets the ProgressBar to display the final status of the operation.
Definition: WorkOrder.cpp:1558
Context
This enumeration is for recording the context of the current Workorder (whether it is part of a proje...
Definition: WorkOrder.h:350
static WorkOrderStatus fromStatusString(QString)
Attempts to query the current status of the WorkOrder.
Definition: WorkOrder.cpp:1002
QString statusText() const
WorkOrder::statusText.
Definition: WorkOrder.cpp:968
Represents an item of a ProjectItemModel in Qt&#39;s model-view framework.
Definition: ProjectItem.h:146
FileItemQsp fileItem()
WorkOrder::fileItem.
Definition: WorkOrder.cpp:780
bool isUndone() const
Returns the WorkOrder undo status.
Definition: WorkOrder.cpp:927
QDateTime executionTime() const
Gets the execution time of this WorkOrder.
Definition: WorkOrder.cpp:878
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
virtual void postUndoExecution()
Perform any steps necessary after an undo of a workorder.
Definition: WorkOrder.cpp:1459
CorrelationMatrix correlationMatrix()
Returns the CorrleationMatrix for this WorkOrder.
Definition: WorkOrder.cpp:710
void setNext(WorkOrder *nextWorkOrder)
Sets the next WorkOrder in the sequence.
Definition: WorkOrder.cpp:627
void enableWorkOrder()
Enables the work order.
Definition: WorkOrder.cpp:1232
This is used for work orders that will not undo or redo (See createsCleanState()) ...
Definition: WorkOrder.h:342
This class is used for processing an XML file containing information about a WorkOrder.
Definition: WorkOrder.h:508
Project * project() const
Returns the Project this WorkOrder is attached to.
Definition: WorkOrder.cpp:1314
virtual void undoExecution()
Execute the steps necessary to undo this workorder.
Definition: WorkOrder.cpp:1448
GuiCameraQsp m_guiCamera
A QSharedPointer to the GuiCamera (the Camera object but encapsulated within a Gui framework...
Definition: WorkOrder.h:594
GuiCameraQsp guiCamera()
WorkOrder::guiCamera.
Definition: WorkOrder.cpp:770
QPointer< ControlList > controlList()
Returns the Control List for this WorkOrder (a list of control networks).
Definition: WorkOrder.cpp:720
ProgressBar * progressBar()
Returns the ProgressBar.
Definition: WorkOrder.cpp:989
ImageList * imageList()
Returns a pointer to the ImageList for this WorkOrder.
Definition: WorkOrder.cpp:645
Manage a stack of content handlers for reading XML files.
void addCloneToProject()
Runs a copy of the current WorkOrder and stores it in the project.
Definition: WorkOrder.cpp:1466
bool m_isSavedToHistory
Set the work order to be shown in the HistoryTreeWidget.
Definition: WorkOrder.h:548
QStringList m_shapeIds
A QStringList of unique shape identifiers for all of the shapes this WorkOrder is dealing with...
Definition: WorkOrder.h:627
QStringList internalData() const
Gets the internal data for this WorkOrder.
Definition: WorkOrder.cpp:1391
bool isUndoable() const
Returns true if this work order is undoable, otherwise false.
Definition: WorkOrder.cpp:833
virtual bool dependsOn(WorkOrder *other) const
Indicate workorder dependency This is a virtual function whose role in child classes is to determine ...
Definition: WorkOrder.cpp:795
FileItemQsp m_fileItem
A QSharedPointer to the FileItem.
Definition: WorkOrder.h:614
void clearImageList()
Clears the list of images.
Definition: WorkOrder.cpp:1637
void setInternalData(QStringList data)
Sets the internal data for this WorkOrder.
Definition: WorkOrder.cpp:1332
void startRedo()
WorkOrder::startRedo This function is currently empty.
Definition: WorkOrder.cpp:1664
void setCreatesCleanState(bool createsCleanState)
Declare that this work order is saving the project.
Definition: WorkOrder.cpp:1677
QPointer< Project > m_project
A pointer to the Project this WorkOrder is attached to.
Definition: WorkOrder.h:647
void save(QXmlStreamWriter &stream) const
: Saves a WorkOrder to a data stream.
Definition: WorkOrder.cpp:558
Directory * directory() const
return the workorder project directory Returns the Directory object of the Project this WorkOrder is ...
Definition: WorkOrder.cpp:1304
QStringList m_imageIds
A QStringList of unique image identifiers for all of the images this WorkOrder is dealing with...
Definition: WorkOrder.h:621
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:522