12#include <QFutureWatcher> 
   14#include <QMutexLocker> 
   15#include <QtConcurrentRun> 
   17#include <QXmlStreamWriter> 
   19#include "ControlList.h" 
   20#include "IException.h" 
   23#include "ProgressBar.h" 
   25#include "ProjectItem.h" 
   41    m_context = NoContext;
 
   58    m_status = WorkOrderNotStarted;
 
   59    m_queuedAction = NoQueuedAction;
 
   74            tr(
"Work orders cannot be created without a project."), _FILEINFO_);
 
   77    connect(
this, SIGNAL(triggered()),
 
 
   91      QAction(other.icon(), ((
QAction &)other).text(), other.parentWidget()),
 
   94    QAction::setWhatsThis(other.whatsThis());
 
   95    QAction::setToolTip(other.toolTip());
 
  100    m_context = other.m_context;
 
  102    m_imageList = 
new ImageList(*other.m_imageList);
 
  104    m_shapeList = 
new ShapeList(*other.m_shapeList);
 
  105    m_correlationMatrix = other.m_correlationMatrix;
 
  106    m_controlList = other.m_controlList;
 
  122    m_status = other.m_status;
 
  123    m_queuedAction = other.m_queuedAction;
 
  134    if (!other.isInStableState()) {
 
  136          tr(
"Can not copy work order [%1] because it is currently running")
 
  141    connect(
this, SIGNAL(triggered()),
 
 
  295    m_controlList = controls;
 
 
  391    else if ( item->isTemplate() ) {
 
 
  506    else if ( item->isTemplate() ) {
 
 
  535                       tr(
"Can not store an unstable work order. The work order [%1] is currently " 
  540    stream.writeStartElement(
"workOrder");
 
  542    stream.writeAttribute(
"actionText", QAction::text());
 
  543    stream.writeAttribute(
"undoText", QUndoCommand::text());
 
  545    stream.writeAttribute(
"type", metaObject()->className());
 
  546    stream.writeAttribute(
"status", 
toString(m_status));
 
  549      stream.writeStartElement(
"images");
 
  552        stream.writeStartElement(
"image");
 
  553        stream.writeAttribute(
"id", imageId);
 
  554        stream.writeEndElement();
 
  557      stream.writeEndElement();
 
  561      stream.writeStartElement(
"shapes");
 
  564        stream.writeStartElement(
"shape");
 
  565        stream.writeAttribute(
"id", shapeId);
 
  566        stream.writeEndElement();
 
  569      stream.writeEndElement();
 
  573      stream.writeStartElement(
"internalDataValues");
 
  576        stream.writeStartElement(
"dataValue");
 
  577        stream.writeAttribute(
"value", str);
 
  578        stream.writeEndElement();
 
  581      stream.writeEndElement();
 
  584    if (m_context != NoContext) {
 
  585      stream.writeStartElement(
"context");
 
  587      QString contextStr = 
"ProjectContext";
 
  588      stream.writeAttribute(
"value", contextStr);
 
  590      stream.writeEndElement();
 
  593    stream.writeEndElement();
 
 
  620    QMutexLocker locker(
project()->workOrderMutex());
 
  622      bool anyImagesAreNull = 
false;
 
  628        m_imageList->append(image);
 
  631          anyImagesAreNull = 
true;
 
  635      if (anyImagesAreNull) {
 
 
  652    QMutexLocker locker(
project()->workOrderMutex());
 
  654      bool anyShapesAreNull = 
false;
 
  660        m_shapeList->append(shape);
 
  663          anyShapesAreNull = 
true;
 
  667      if (anyShapesAreNull) {
 
 
  685    QMutexLocker locker(
project()->workOrderMutex());
 
  686    return m_correlationMatrix;
 
 
  695    QMutexLocker locker(
project()->workOrderMutex());
 
  696    return m_controlList;
 
 
  725    QMutexLocker locker(
project()->workOrderMutex());
 
 
  735    QMutexLocker locker(
project()->workOrderMutex());
 
 
  745    QMutexLocker locker(
project()->workOrderMutex());
 
 
  755    QMutexLocker locker(
project()->workOrderMutex());
 
 
  784    QString result = QUndoCommand::text().remove(
"&").remove(
"...");
 
  787    if (result.isEmpty()) {
 
  789      result = QString(metaObject()->className()).remove(
"Isis::").remove(
"WorkOrder")
 
  790                   .replace(QRegExp(
"([a-z0-9])([A-Z])"), 
"\\1 \\2");
 
  791      qWarning() << QString(
"WorkOrder::bestText(): Work order [%1] has no QUndoCommand text")
 
 
  808    QMutexLocker locker(
project()->workOrderMutex());
 
 
  819     QMutexLocker locker(
project()->workOrderMutex());
 
 
  830    QMutexLocker locker(
project()->workOrderMutex());
 
 
  843    QMutexLocker locker(
project()->workOrderMutex());
 
 
  853    QMutexLocker locker(
project()->workOrderMutex());
 
 
  872    QMutexLocker locker(
project()->workOrderMutex());
 
  873    return m_status == WorkOrderRedoing;
 
 
  882    QMutexLocker locker(
project()->workOrderMutex());
 
  883    return m_status == WorkOrderRedone;
 
 
  892    QMutexLocker locker(
project()->workOrderMutex());
 
  893    return m_status == WorkOrderUndoing;
 
 
  902    QMutexLocker locker(
project()->workOrderMutex());
 
  903    return m_status == WorkOrderUndone;
 
 
  913    QMutexLocker locker(
project()->workOrderMutex());
 
 
  923    QMutexLocker locker(
project()->workOrderMutex());
 
 
  933    QMutexLocker locker(
project()->workOrderMutex());
 
 
  943    QMutexLocker locker(
project()->workOrderMutex());
 
  944    QString result = 
toString(m_status);
 
  952      result += tr(
" (elapsed: %1:%2)").arg(minutes).arg(seconds, 2, 10, QChar(
'0'));
 
 
  964    QMutexLocker locker(
project()->workOrderMutex());
 
 
  977    statusString = statusString.toUpper();
 
  981         possibleResult <= WorkOrderLastStatus;
 
  983      if (statusString == 
toString(possibleResult).toUpper()) {
 
  984        result = possibleResult;
 
 
 1001      case WorkOrderUnknownStatus:
 
 1002        result = tr(
"Unknown");
 
 1004      case WorkOrderNotStarted:
 
 1005        result = tr(
"Not Started");
 
 1007      case WorkOrderRedoing:
 
 1008        result = tr(
"In Progress");
 
 1010      case WorkOrderRedone:
 
 1011        result = tr(
"Completed");
 
 1013      case WorkOrderUndoing:
 
 1014        result = tr(
"Undoing");
 
 1016      case WorkOrderUndone:
 
 1017        result = tr(
"Undone");
 
 1020        result = tr(
"Finished");
 
 
 1033      m_queuedAction = RedoQueuedAction;
 
 1037      bool mustQueueThisRedo = 
false;
 
 1041      while (current->previous() && !dependency) {
 
 1042        if (!current->previous()->isRedone() && !current->previous()->isFinished()) {
 
 1046            connect(possibleDependency, SIGNAL(finished(
WorkOrder *)),
 
 1048            dependency = possibleDependency;
 
 1049            mustQueueThisRedo = 
true;
 
 1053        current = current->previous();
 
 1059        mustQueueThisRedo = 
true;
 
 1065        mustQueueThisRedo = 
true;
 
 1070        m_queuedAction = RedoQueuedAction;
 
 1072        QString queueStatusText;
 
 1075          QString dependencyText = dependency->bestText();
 
 1077          if (dependencyText.count() > 5) {
 
 1078            dependencyText = dependencyText.mid(0, 5) + 
"...";
 
 1081          queueStatusText = tr(
"Wait for [%1]").arg(dependencyText);
 
 1084          queueStatusText = tr(
"Wait for images");
 
 1087          queueStatusText = tr(
"Wait for shapes");
 
 1096      if (m_queuedAction == NoQueuedAction) {
 
 1097        m_status = WorkOrderRedoing;
 
 1098        emit statusChanged(
this);
 
 
 1136      m_queuedAction = UndoQueuedAction;
 
 1139    if (!
isUndone() && m_status != WorkOrderNotStarted) {
 
 1142      while (current->next() && !dependency) {
 
 1143        if (!current->next()->isUndone() && !current->next()->isFinished() &&
 
 1144            current->next()->m_status != WorkOrderNotStarted) {
 
 1145          connect(current->next(), SIGNAL(finished(
WorkOrder *)),
 
 1147          m_queuedAction = UndoQueuedAction;
 
 1148          dependency = current->next();
 
 1151        current = current->next();
 
 1155        QString prevText = dependency->bestText();
 
 1157        if (prevText.count() > 5) {
 
 1158          prevText = prevText.mid(0, 5) + 
"...";
 
 1163        m_progressBar->setText(tr(
"Undo after [%1]").arg(prevText));
 
 1167      if (m_queuedAction == NoQueuedAction) {
 
 1168        m_status = WorkOrderUndoing;
 
 1169        emit statusChanged(
this);
 
 
 1255      emit statusChanged(
this);
 
 
 1291          "This work order no longer has a project.", _FILEINFO_);
 
 
 1316    QMutexLocker locker(
project()->workOrderMutex());
 
 
 1326    QMutexLocker locker(
project()->workOrderMutex());
 
 
 1336    QMutexLocker locker(
project()->workOrderMutex());
 
 
 1366    QMutexLocker locker(
project()->workOrderMutex());
 
 
 1469    foreach (
Image *image, *m_imageList) {
 
 1475        connect(image, SIGNAL(destroyed(
QObject *)),
 
 
 1492    foreach (
Shape *shape, *m_shapeList) {
 
 1498        connect(shape, SIGNAL(destroyed(
QObject *)),
 
 
 1513      emit creatingProgress(
this);
 
 
 1537      else if (
isUndone() || m_status == WorkOrderNotStarted) {
 
 
 1565    m_queuedAction = NoQueuedAction;
 
 1567    if (queued == RedoQueuedAction && m_status != WorkOrderRedone) {
 
 1570    else if (queued == UndoQueuedAction && m_status != WorkOrderUndone) {
 
 
 1587      finishedStatus = WorkOrderUndone;
 
 1591    (this->*postMethod)();
 
 1593    m_status = finishedStatus;
 
 1600    emit statusChanged(
this);
 
 1602    emit finished(
this);
 
 
Maintains a list of Controls so that control nets can easily be copied from one Project to another,...
 
This is a container for the correlation matrix that comes from a bundle adjust.
 
@ Unknown
A type of error that cannot be classified as any of the other error types.
 
@ Programmer
This error is for when a programmer made an API call that was illegal.
 
This represents a cube in a project-based GUI interface.
 
QString id() const
Get a unique, identifying string associated with this image.
 
Internalizes a list of images and allows for operations on the entire list.
 
void append(Image *const &value)
Appends an image to the image list.
 
The main project for ipce.
 
Shape * shape(QString id)
Return a shape given its id.
 
void addToProject(WorkOrder *)
This executes the WorkOrder and stores it in the project.
 
Directory * directory() const
Returns the directory associated with this Project.
 
Image * image(QString id)
Return an image given its id.
 
Represents an item of a ProjectItemModel in Qt's model-view framework.
 
TargetBodyQsp targetBody() const
Returns the TargetBodyQsp stored in the data of the item.
 
bool isShape() const
Returns true if an Shape is stored in the data of the item.
 
Template * getTemplate() const
Returns the Template stored in the data of the item.
 
bool isProject() const
Returns true if a Project is stored in the data of the item.
 
FileItemQsp fileItem() const
Returns the FileItemQsp stored in the data of the item.
 
ShapeList * shapeList() const
Returns the ShapeList stored in the data of the item.
 
bool isControl() const
Returns true if a Control is stored in the data of the item.
 
bool isControlList() const
Returns true if a ControlList is stored in the data of the item.
 
bool isShapeList() const
Returns true if an ShapeList is stored in the data of the item.
 
CorrelationMatrix correlationMatrix() const
Returns the CorrelationMatrix stored the item.
 
Shape * shape() const
Returns the Shape stored in the data of the item.
 
bool isImageList() const
Returns true if an ImageList is stored in the data of the item.
 
ImageList * imageList() const
Returns the ImageList stored in the data of the item.
 
bool isFileItem() const
Returns true if a FileItemQsp is stored in the data of the item.
 
Control * control() const
Returns the Control stored in the data of the item.
 
Image * image() const
Returns the Image stored in the data of the item.
 
ControlList * controlList() const
Returns the ControlList stored in the data of the item.
 
bool isImage() const
Returns true if an Image is stored in the data of the item.
 
GuiCameraQsp guiCamera() const
Returns the GuiCameraQsp stored in the data of the item.
 
bool isGuiCamera() const
Returns true if a GuiCameraQsp is stored in the data of the item.
 
bool isCorrelationMatrix() const
Returns true if a CorrelationMatrix is stored in the data of the item.
 
bool isTargetBody() const
Returns true if a TargetBodyQsp is stored in the data of the item.
 
This represents a shape in a project-based GUI interface.
 
QString id() const
Get a unique, identifying string associated with this shape.
 
Internalizes a list of shapes and allows for operations on the entire list.
 
void append(Shape *const &value)
Appends an shape to the shape list.
 
Provide Undo/redo abilities, serialization, and history for an operation.
 
void enableWorkOrder()
Enables the work order.
 
QPointer< QTimer > m_progressBarUpdateTimer
A pointer to the QTimer which updates the ProgressBar.
 
QStringList m_imageIds
A QStringList of unique image identifiers for all of the images this WorkOrder is dealing with.
 
void setNext(WorkOrder *nextWorkOrder)
Sets the next WorkOrder in the sequence.
 
void updateProgress()
Updates the progress bar.
 
ShapeList * shapeList()
@briefReturns a pointer to the ShapeList for this WorkOrder.
 
bool m_isSavedToHistory
Set the work order to be shown in the HistoryTreeWidget.
 
QueuedWorkOrderAction
This enum describes the current state of a Queued WorkOrder.
 
void setProgressRange(int, int)
Sets the progress range of the WorkOrder.
 
int progressMax() const
Gets the maximum value of the progress range of the WorkOrder.
 
QStringList m_shapeIds
A QStringList of unique shape identifiers for all of the shapes this WorkOrder is dealing with.
 
virtual void setData(Context)
Sets the context data for this WorkOrder.
 
WorkOrder * next() const
Gets the next WorkOrder.
 
bool modifiesDiskState() const
Returns the modified disk state.
 
bool m_isSynchronous
This is defaulted to true.
 
bool isUndoing() const
Returns the WorkOrderUndoing state.
 
void attemptQueuedAction()
Attempts to execute an action on the action queue.
 
virtual void undoExecution()
Execute the steps necessary to undo this workorder.
 
virtual void postUndoExecution()
Perform any steps necessary after an undo of a workorder.
 
Template * getTemplate()
WorkOrder::getTemplate.
 
Template * m_template
A QSharedPointer to the Template (A Template object but encapsulated within a Gui framework.
 
void save(QXmlStreamWriter &stream) const
: Saves a WorkOrder to a data stream.
 
void clearShapeList()
Clears the list of shapes.
 
bool isRedone() const
Returns the WorkOrder redone status.
 
void executionFinished()
Signals the Project that the WorkOrder is finished, deletes the update time for the Progress bar,...
 
virtual void redo()
Starts (or enqueues) a redo.
 
WorkOrderStatus
This enumeration is used by other functions to set and retrieve the current state of the WorkOrder.
 
@ WorkOrderFinished
This is used for work orders that will not undo or redo (See createsCleanState())
 
virtual void undo()
Starts (or enqueues) an undo.
 
int progressMin() const
Gets the minimum value of the progress range of the WorkOrder.
 
bool isUndoable() const
Returns true if this work order is undoable, otherwise false.
 
WorkOrder * previous() const
Gets the previous WorkOrder.
 
bool m_isUndoable
Set the workorder to be undoable/redoable This is defaulted to true - his will allow the workorder to...
 
void setProgressValue(int)
Sets the current progress value for the WorkOrder.
 
static QString toString(WorkOrderStatus)
Gets the current status of the WorkOrder.
 
bool isUndone() const
Returns the WorkOrder undo status.
 
virtual bool setupExecution()
This sets up the state for the work order.
 
void setProgressToFinalText()
Sets the ProgressBar to display the final status of the operation.
 
QDateTime m_executionTime
This is the date/time that setupExecution() was called.
 
bool m_createsCleanState
This is defaulted to false.
 
bool isSavedToHistory() const
Returns true if this work order is to be shown in History, otherwise false.
 
bool isInStableState() const
Determines if the WorkOrder is in a stable state, or if it's busy doing something.
 
GuiCameraQsp m_guiCamera
A QSharedPointer to the GuiCamera (the Camera object but encapsulated within a Gui framework.
 
QPointer< WorkOrder > m_previousWorkOrder
A pointer to the previous WorkOrder in the queue.
 
static WorkOrderStatus fromStatusString(QString)
Attempts to query the current status of the WorkOrder.
 
bool isRedoing() const
Returns the redoing status of this WorkOrder.
 
int m_progressRangeMaxValue
The maximum value of the Progess Bar.
 
QStringList internalData() const
Gets the internal data for this WorkOrder.
 
QPointer< ControlList > controlList()
Returns the Control List for this WorkOrder (a list of control networks).
 
Directory * directory() const
return the workorder project directory Returns the Directory object of the Project this WorkOrder is ...
 
int m_progressValue
The current value of the Progress Bar.
 
GuiCameraQsp guiCamera()
WorkOrder::guiCamera.
 
void setCreatesCleanState(bool createsCleanState)
Declare that this work order is saving the project.
 
QString statusText() const
WorkOrder::statusText.
 
QDateTime executionTime() const
Gets the execution time of this WorkOrder.
 
virtual void execute()
Execute the workorder.
 
void setModifiesDiskState(bool changesProjectOnDisk)
 
QPointer< ProgressBar > m_progressBar
A pointer to the ProgressBar.
 
void setPrevious(WorkOrder *previousWorkOrder)
Sets the previous WorkOrder in the sequence.
 
void listenForShapeDestruction()
Checks to see if we have lost any shapes in the ShapeList.
 
virtual bool isExecutable(Context)
Re-implement this method if your work order utilizes controls for data in order to operate.
 
void disableWorkOrder()
Disables the work order.
 
bool createsCleanState() const
Returns the CleanState status (whether the Project has been saved to disk or not).
 
TargetBodyQsp targetBody()
WorkOrder::targetBody.
 
double m_secondsElapsed
The seconds that have elapsed since the WorkOrder started executing.
 
void setInternalData(QStringList data)
Sets the internal data for this WorkOrder.
 
int m_progressRangeMinValue
The miniumum value of the Progess Bar.
 
virtual bool dependsOn(WorkOrder *other) const
Indicate workorder dependency This is a virtual function whose role in child classes is to determine ...
 
QElapsedTimer * m_elapsedTimer
A QElapsedTimer object holding the excecution time of the WorkOrder.
 
Project * project() const
Returns the Project this WorkOrder is attached to.
 
void clearImageList()
Clears the list of images.
 
QPointer< Project > m_project
A pointer to the Project this WorkOrder is attached to.
 
virtual ~WorkOrder()
The Destructor.
 
ProgressBar * progressBar()
Returns the ProgressBar.
 
QStringList m_internalData
A QStringList of internal properties for this WorkOrder.
 
bool m_modifiesDiskState
This is defaulted to false.
 
QMutex * m_transparentConstMutex
This is used to protect the integrity of data the WorkOrder is working on so that only one thread at ...
 
QPointer< WorkOrder > m_nextWorkOrder
A pointer to the next WorkOrder in the queue.
 
void addCloneToProject()
Runs a copy of the current WorkOrder and stores it in the project.
 
void startRedo()
WorkOrder::startRedo This function is currently empty.
 
void resetProgressBar()
Resets the ProgressBar.
 
FileItemQsp m_fileItem
A QSharedPointer to the FileItem.
 
ImageList * imageList()
Returns a pointer to the ImageList for this WorkOrder.
 
bool isSynchronous() const
Returns true if this work order is run synchronously, otherwise false.
 
Context
This enumeration is for recording the context of the current Workorder (whether it is part of a proje...
 
QString bestText() const
Generate unique action names We don't use action text anymore because Directory likes to rename our a...
 
int progressValue() const
Gets the current progress value of the WorkOrder.
 
bool isFinished() const
Returns the finished state of this WorkOrder.
 
virtual void postExecution()
Perform any necessary actions after execution of a workorder.
 
QPointer< QFutureWatcher< void > > m_futureWatcher
A pointer to a QFutureWatcher object which monitors a QFuture object using signals and slots.
 
CorrelationMatrix correlationMatrix()
Returns the CorrleationMatrix for this WorkOrder.
 
QPointer< QTimer > m_progressBarDeletionTimer
A pointer to the ProgressBar deletion timer.
 
void listenForImageDestruction()
Checks to see if we have lost any images in the ImageList.
 
FileItemQsp fileItem()
WorkOrder::fileItem.
 
WorkOrder(Project *project)
Create a work order that will work with the given project.
 
TargetBodyQsp m_targetBody
A QSharedPointer to the TargetBody (A Target object but encapsulated within a Gui framework.
 
This is free and unencumbered software released into the public domain.
 
QSharedPointer< GuiCamera > GuiCameraQsp
GuiCameraQsp Represents a smart pointer to a GuiCamera object.
 
QSharedPointer< TargetBody > TargetBodyQsp
Defines A smart pointer to a TargetBody obj.
 
QSharedPointer< FileItem > FileItemQsp
A FileItem smart pointer.