23 #include "IsisDebug.h" 28 #include <QFutureWatcher> 30 #include <QMutexLocker> 31 #include <QtConcurrentRun> 33 #include <QXmlStreamWriter> 35 #include "ControlList.h" 37 #include "ImageList.h" 39 #include "ProgressBar.h" 42 #include "ShapeList.h" 44 #include "XmlStackedHandlerReader.h" 58 m_context = NoContext;
75 m_status = WorkOrderNotStarted;
76 m_queuedAction = NoQueuedAction;
91 tr(
"Work orders cannot be created without a project."),
_FILEINFO_);
94 connect(
this, SIGNAL(triggered()),
108 QAction(other.icon(), ((
QAction &)other).text(), other.parentWidget()),
111 QAction::setWhatsThis(other.whatsThis());
112 QAction::setToolTip(other.toolTip());
117 m_context = other.m_context;
119 m_imageList =
new ImageList(*other.m_imageList);
121 m_shapeList =
new ShapeList(*other.m_shapeList);
122 m_correlationMatrix = other.m_correlationMatrix;
123 m_controlList = other.m_controlList;
139 m_status = other.m_status;
140 m_queuedAction = other.m_queuedAction;
153 tr(
"Can not copy work order [%1] because it is currently running")
158 connect(
this, SIGNAL(triggered()),
312 m_controlList = controls;
408 else if ( item->isTemplate() ) {
523 else if ( item->isTemplate() ) {
561 tr(
"Can not store an unstable work order. The work order [%1] is currently " 566 stream.writeStartElement(
"workOrder");
568 stream.writeAttribute(
"actionText", QAction::text());
569 stream.writeAttribute(
"undoText", QUndoCommand::text());
571 stream.writeAttribute(
"type", metaObject()->className());
572 stream.writeAttribute(
"status",
toString(m_status));
575 stream.writeStartElement(
"images");
578 stream.writeStartElement(
"image");
579 stream.writeAttribute(
"id", imageId);
580 stream.writeEndElement();
583 stream.writeEndElement();
587 stream.writeStartElement(
"shapes");
590 stream.writeStartElement(
"shape");
591 stream.writeAttribute(
"id", shapeId);
592 stream.writeEndElement();
595 stream.writeEndElement();
599 stream.writeStartElement(
"internalDataValues");
602 stream.writeStartElement(
"dataValue");
603 stream.writeAttribute(
"value", str);
604 stream.writeEndElement();
607 stream.writeEndElement();
610 if (m_context != NoContext) {
611 stream.writeStartElement(
"context");
613 QString contextStr =
"ProjectContext";
614 stream.writeAttribute(
"value", contextStr);
616 stream.writeEndElement();
619 stream.writeEndElement();
646 QMutexLocker locker(
project()->workOrderMutex());
648 bool anyImagesAreNull =
false;
654 m_imageList->append(image);
657 anyImagesAreNull =
true;
661 if (anyImagesAreNull) {
678 QMutexLocker locker(
project()->workOrderMutex());
680 bool anyShapesAreNull =
false;
686 m_shapeList->append(shape);
689 anyShapesAreNull =
true;
693 if (anyShapesAreNull) {
711 QMutexLocker locker(
project()->workOrderMutex());
712 return m_correlationMatrix;
721 QMutexLocker locker(
project()->workOrderMutex());
722 return m_controlList;
751 QMutexLocker locker(
project()->workOrderMutex());
761 QMutexLocker locker(
project()->workOrderMutex());
771 QMutexLocker locker(
project()->workOrderMutex());
781 QMutexLocker locker(
project()->workOrderMutex());
810 QString result = QUndoCommand::text().remove(
"&").remove(
"...");
813 if (result.isEmpty()) {
815 result = QString(metaObject()->className()).remove(
"Isis::").remove(
"WorkOrder")
816 .replace(QRegExp(
"([a-z0-9])([A-Z])"),
"\\1 \\2");
817 qWarning() << QString(
"WorkOrder::bestText(): Work order [%1] has no QUndoCommand text")
834 QMutexLocker locker(
project()->workOrderMutex());
845 QMutexLocker locker(
project()->workOrderMutex());
856 QMutexLocker locker(
project()->workOrderMutex());
869 QMutexLocker locker(
project()->workOrderMutex());
879 QMutexLocker locker(
project()->workOrderMutex());
898 QMutexLocker locker(
project()->workOrderMutex());
899 return m_status == WorkOrderRedoing;
908 QMutexLocker locker(
project()->workOrderMutex());
909 return m_status == WorkOrderRedone;
918 QMutexLocker locker(
project()->workOrderMutex());
919 return m_status == WorkOrderUndoing;
928 QMutexLocker locker(
project()->workOrderMutex());
929 return m_status == WorkOrderUndone;
939 QMutexLocker locker(
project()->workOrderMutex());
949 QMutexLocker locker(
project()->workOrderMutex());
959 QMutexLocker locker(
project()->workOrderMutex());
969 QMutexLocker locker(
project()->workOrderMutex());
970 QString result =
toString(m_status);
978 result += tr(
" (elapsed: %1:%2)").arg(minutes).arg(seconds, 2, 10, QChar(
'0'));
990 QMutexLocker locker(
project()->workOrderMutex());
1003 statusString = statusString.toUpper();
1007 possibleResult <= WorkOrderLastStatus;
1009 if (statusString ==
toString(possibleResult).toUpper()) {
1010 result = possibleResult;
1027 case WorkOrderUnknownStatus:
1028 result = tr(
"Unknown");
1030 case WorkOrderNotStarted:
1031 result = tr(
"Not Started");
1033 case WorkOrderRedoing:
1034 result = tr(
"In Progress");
1036 case WorkOrderRedone:
1037 result = tr(
"Completed");
1039 case WorkOrderUndoing:
1040 result = tr(
"Undoing");
1042 case WorkOrderUndone:
1043 result = tr(
"Undone");
1046 result = tr(
"Finished");
1059 m_queuedAction = RedoQueuedAction;
1063 bool mustQueueThisRedo =
false;
1067 while (current->
previous() && !dependency) {
1072 connect(possibleDependency, SIGNAL(finished(
WorkOrder *)),
1074 dependency = possibleDependency;
1075 mustQueueThisRedo =
true;
1085 mustQueueThisRedo =
true;
1091 mustQueueThisRedo =
true;
1096 m_queuedAction = RedoQueuedAction;
1098 QString queueStatusText;
1101 QString dependencyText = dependency->
bestText();
1103 if (dependencyText.count() > 5) {
1104 dependencyText = dependencyText.mid(0, 5) +
"...";
1107 queueStatusText = tr(
"Wait for [%1]").arg(dependencyText);
1110 queueStatusText = tr(
"Wait for images");
1113 queueStatusText = tr(
"Wait for shapes");
1122 if (m_queuedAction == NoQueuedAction) {
1123 m_status = WorkOrderRedoing;
1124 emit statusChanged(
this);
1162 m_queuedAction = UndoQueuedAction;
1165 if (!
isUndone() && m_status != WorkOrderNotStarted) {
1168 while (current->
next() && !dependency) {
1170 current->
next()->m_status != WorkOrderNotStarted) {
1173 m_queuedAction = UndoQueuedAction;
1174 dependency = current->
next();
1177 current = current->
next();
1181 QString prevText = dependency->
bestText();
1183 if (prevText.count() > 5) {
1184 prevText = prevText.mid(0, 5) +
"...";
1189 m_progressBar->setText(tr(
"Undo after [%1]").arg(prevText));
1193 if (m_queuedAction == NoQueuedAction) {
1194 m_status = WorkOrderUndoing;
1195 emit statusChanged(
this);
1281 emit statusChanged(
this);
1317 "This work order no longer has a project.",
_FILEINFO_);
1342 QMutexLocker locker(
project()->workOrderMutex());
1352 QMutexLocker locker(
project()->workOrderMutex());
1362 QMutexLocker locker(
project()->workOrderMutex());
1392 QMutexLocker locker(
project()->workOrderMutex());
1495 foreach (
Image *image, *m_imageList) {
1501 connect(image, SIGNAL(destroyed(
QObject *)),
1518 foreach (
Shape *shape, *m_shapeList) {
1524 connect(shape, SIGNAL(destroyed(
QObject *)),
1539 emit creatingProgress(
this);
1563 else if (
isUndone() || m_status == WorkOrderNotStarted) {
1591 m_queuedAction = NoQueuedAction;
1593 if (queued == RedoQueuedAction && m_status != WorkOrderRedone) {
1596 else if (queued == UndoQueuedAction && m_status != WorkOrderUndone) {
1613 finishedStatus = WorkOrderUndone;
1617 (this->*postMethod)();
1619 m_status = finishedStatus;
1626 emit statusChanged(
this);
1628 emit finished(
this);
1717 const QString &qName,
const QXmlAttributes &atts) {
1718 if (XmlStackedHandler::startElement(namespaceURI, localName, qName, atts)) {
1719 if (localName ==
"workOrder") {
1720 QString actionText = atts.value(
"actionText");
1721 QString undoText = atts.value(
"undoText");
1723 QString statusStr = atts.value(
"status");
1725 if (!actionText.isEmpty()) {
1726 ((
QAction *)m_workOrder)->setText(actionText);
1729 if (!undoText.isEmpty()) {
1734 m_workOrder->m_executionTime = QDateTime::fromString(
executionTime);
1737 if (!statusStr.isEmpty()) {
1741 if (m_workOrder->createsCleanState()) {
1745 m_workOrder->m_status = WorkOrderRedone;
1749 else if (localName ==
"dataValue") {
1750 m_workOrder->m_internalData.append(atts.value(
"value"));
1752 else if (localName ==
"context") {
1753 if (atts.value(
"value") ==
"ProjectContext") {
1754 m_workOrder->m_context = ProjectContext;
Internalizes a list of shapes and allows for operations on the entire list.
bool isFileItem() const
Returns true if a FileItemQsp is stored in the data of the item.
QString bestText() const
Generate unique action names We don't use action text anymore because Directory likes to rename our a...
bool isImageList() const
Returns true if an ImageList is stored in the data of the item.
bool isSynchronous() const
Returns true if this work order is run synchronously, otherwise false.
bool isInStableState() const
Determines if the WorkOrder is in a stable state, or if it's busy doing something.
void setProgressValue(int)
Sets the current progress value for the WorkOrder.
bool isShapeList() const
Returns true if an ShapeList is stored in the data of the item.
Internalizes a list of images and allows for operations on the entire list.
bool m_modifiesDiskState
This is defaulted to false.
GuiCameraQsp guiCamera() const
Returns the GuiCameraQsp stored in the data of the item.
The main project for ipce.
bool isImage() const
Returns true if an Image is stored in the data of the item.
virtual void postExecution()
Perform any necessary actions after execution of a workorder.
XmlHandler(WorkOrder *workOrder)
Passes a pointer to a WorkOrder to the WorkOrder::XmlHandler class.
This is a container for the correlation matrix that comes from a bundle adjust.
QSharedPointer< FileItem > FileItemQsp
A FileItem smart pointer.
void attemptQueuedAction()
Attempts to execute an action on the action queue.
ControlList * controlList() const
Returns the ControlList stored in the data of the item.
bool modifiesDiskState() const
Returns the modified disk state.
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.
FileItemQsp fileItem() const
Returns the FileItemQsp stored in the data of the item.
void updateProgress()
Updates the progress bar.
QPointer< QTimer > m_progressBarUpdateTimer
A pointer to the QTimer which updates the ProgressBar.
int progressMax() const
Gets the maximum value of the progress range of the WorkOrder.
bool isRedoing() const
Returns the redoing status of this WorkOrder.
Shape * shape(QString id)
Return a shape given its id.
Maintains a list of Controls so that control nets can easily be copied from one Project to another...
virtual bool setupExecution()
This sets up the state for the work order.
void read(XmlStackedHandlerReader *xmlReader)
Read this work order's data from disk.
bool isProject() const
Returns true if a Project is stored in the data of the item.
int m_progressRangeMinValue
The miniumum value of the Progess Bar.
WorkOrder * next() const
Gets the next WorkOrder.
QPointer< WorkOrder > m_previousWorkOrder
A pointer to the previous WorkOrder in the queue.
This error is for when a programmer made an API call that was illegal.
bool isRedone() const
Returns the WorkOrder redone status.
ImageList * imageList() const
Returns the ImageList stored in the data of the item.
TargetBodyQsp targetBody()
WorkOrder::targetBody.
ShapeList * shapeList()
a pointer to the ShapeList for this WorkOrder.
virtual void redo()
Starts (or enqueues) a redo.
QPointer< ProgressBar > m_progressBar
A pointer to the ProgressBar.
virtual bool isExecutable(Context)
Re-implement this method if your work order utilizes controls for data in order to operate...
QTime * m_elapsedTimer
A QTime object holding the excecution time of the WorkOrder.
QDateTime m_executionTime
This is the date/time that setupExecution() was called.
WorkOrder(Project *project)
Create a work order that will work with the given project.
Template * getTemplate() const
Returns the Template stored in the data of the item.
void disableWorkOrder()
Disables the work order.
Directory * directory() const
Returns the directory associated with this Project.
virtual void undo()
Starts (or enqueues) an undo.
void listenForShapeDestruction()
Checks to see if we have lost any shapes in the ShapeList.
int progressMin() const
Gets the minimum value of the progress range of the WorkOrder.
static QString toString(WorkOrderStatus)
Gets the current status of the WorkOrder.
QPointer< QTimer > m_progressBarDeletionTimer
A pointer to the ProgressBar deletion timer.
void addToProject(WorkOrder *)
This executes the WorkOrder and stores it in the project.
Provide Undo/redo abilities, serialization, and history for an operation.
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
bool isSavedToHistory() const
Returns true if this work order is to be shown in History, otherwise false.
int m_progressValue
The current value of the Progress Bar.
QSharedPointer< TargetBody > TargetBodyQsp
Defines A smart pointer to a TargetBody obj.
TargetBodyQsp targetBody() const
Returns the TargetBodyQsp stored in the data of the item.
bool createsCleanState() const
Returns the CleanState status (whether the Project has been saved to disk or not).
#define _FILEINFO_
Macro for the filename and line number.
void append(Shape *const &value)
Appends an shape to the shape list.
WorkOrderStatus
This enumeration is used by other functions to set and retrieve the current state of the WorkOrder...
QStringList m_internalData
A QStringList of internal properties for this WorkOrder.
virtual void pushContentHandler(XmlStackedHandler *newHandler)
Push a contentHandler and maybe continue parsing...
A type of error that cannot be classified as any of the other error types.
virtual void execute()
Execute the workorder.
void setPrevious(WorkOrder *previousWorkOrder)
Sets the previous WorkOrder in the sequence.
Template * getTemplate()
WorkOrder::getTemplate.
QPointer< WorkOrder > m_nextWorkOrder
A pointer to the next WorkOrder in the queue.
This represents a cube in a project-based GUI interface.
bool m_isSynchronous
This is defaulted to true.
int progressValue() const
Gets the current progress value of the WorkOrder.
WorkOrder * previous() const
Gets the previous WorkOrder.
Image * image() const
Returns the Image stored in the data of the item.
bool m_isUndoable
Set the workorder to be undoable/redoable This is defaulted to true - his will allow the workorder to...
bool m_createsCleanState
This is defaulted to false.
QString id() const
Get a unique, identifying string associated with this shape.
virtual void setData(Context)
Sets the context data for this WorkOrder.
void clearShapeList()
Clears the list of shapes.
void append(Image *const &value)
Appends an image to the image list.
bool isGuiCamera() const
Returns true if a GuiCameraQsp is stored in the data of the item.
Template * m_template
A QSharedPointer to the Template (A Template object but encapsulated within a Gui framework...
Image * image(QString id)
Return an image given its id.
int m_progressRangeMaxValue
The maximum value of the Progess Bar.
void resetProgressBar()
Resets the ProgressBar.
bool isFinished() const
Returns the finished state of this WorkOrder.
bool isTargetBody() const
Returns true if a TargetBodyQsp is stored in the data of the item.
void executionFinished()
Signals the Project that the WorkOrder is finished, deletes the update time for the Progress bar...
void setProgressRange(int, int)
Sets the progress range of the WorkOrder.
virtual ~WorkOrder()
The Destructor.
bool isUndoing() const
Returns the WorkOrderUndoing state.
TargetBodyQsp m_targetBody
A QSharedPointer to the TargetBody (A Target object but encapsulated within a Gui framework...
bool isControl() const
Returns true if a Control is stored in the data of the item.
double m_secondsElapsed
The seconds that have elapsed since the WorkOrder started executing.
void setModifiesDiskState(bool changesProjectOnDisk)
CorrelationMatrix correlationMatrix() const
Returns the CorrelationMatrix stored the item.
QPointer< QFutureWatcher< void > > m_futureWatcher
A pointer to a QFutureWatcher object which monitors a QFuture object using signals and slots...
QSharedPointer< GuiCamera > GuiCameraQsp
GuiCameraQsp Represents a smart pointer to a GuiCamera object.
QueuedWorkOrderAction
This enum describes the current state of a Queued WorkOrder.
QMutex * m_transparentConstMutex
This is used to protect the integrity of data the WorkOrder is working on so that only one thread at ...
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
This represents a shape in a project-based GUI interface.
Shape * shape() const
Returns the Shape stored in the data of the item.
Control * control() const
Returns the Control stored in the data of the item.
void listenForImageDestruction()
Checks to see if we have lost any images in the ImageList.
void setProgressToFinalText()
Sets the ProgressBar to display the final status of the operation.
bool isControlList() const
Returns true if a ControlList is stored in the data of the item.
Context
This enumeration is for recording the context of the current Workorder (whether it is part of a proje...
static WorkOrderStatus fromStatusString(QString)
Attempts to query the current status of the WorkOrder.
QString id() const
Get a unique, identifying string associated with this image.
QString statusText() const
WorkOrder::statusText.
Represents an item of a ProjectItemModel in Qt's model-view framework.
FileItemQsp fileItem()
WorkOrder::fileItem.
bool isUndone() const
Returns the WorkOrder undo status.
QDateTime executionTime() const
Gets the execution time of this WorkOrder.
Namespace for ISIS/Bullet specific routines.
virtual void postUndoExecution()
Perform any steps necessary after an undo of a workorder.
bool isCorrelationMatrix() const
Returns true if a CorrelationMatrix is stored in the data of the item.
CorrelationMatrix correlationMatrix()
Returns the CorrleationMatrix for this WorkOrder.
bool isShape() const
Returns true if an Shape is stored in the data of the item.
void setNext(WorkOrder *nextWorkOrder)
Sets the next WorkOrder in the sequence.
void enableWorkOrder()
Enables the work order.
This is used for work orders that will not undo or redo (See createsCleanState()) ...
This class is used for processing an XML file containing information about a WorkOrder.
Project * project() const
Returns the Project this WorkOrder is attached to.
virtual void undoExecution()
Execute the steps necessary to undo this workorder.
GuiCameraQsp m_guiCamera
A QSharedPointer to the GuiCamera (the Camera object but encapsulated within a Gui framework...
GuiCameraQsp guiCamera()
WorkOrder::guiCamera.
QPointer< ControlList > controlList()
Returns the Control List for this WorkOrder (a list of control networks).
ProgressBar * progressBar()
Returns the ProgressBar.
ImageList * imageList()
Returns a pointer to the ImageList for this WorkOrder.
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.
bool m_isSavedToHistory
Set the work order to be shown in the HistoryTreeWidget.
QStringList m_shapeIds
A QStringList of unique shape identifiers for all of the shapes this WorkOrder is dealing with...
QStringList internalData() const
Gets the internal data for this WorkOrder.
bool isUndoable() const
Returns true if this work order is undoable, otherwise false.
virtual bool dependsOn(WorkOrder *other) const
Indicate workorder dependency This is a virtual function whose role in child classes is to determine ...
FileItemQsp m_fileItem
A QSharedPointer to the FileItem.
void clearImageList()
Clears the list of images.
void setInternalData(QStringList data)
Sets the internal data for this WorkOrder.
void startRedo()
WorkOrder::startRedo This function is currently empty.
void setCreatesCleanState(bool createsCleanState)
Declare that this work order is saving the project.
QPointer< Project > m_project
A pointer to the Project this WorkOrder is attached to.
void save(QXmlStreamWriter &stream) const
: Saves a WorkOrder to a data stream.
Directory * directory() const
return the workorder project directory Returns the Directory object of the Project this WorkOrder is ...
QStringList m_imageIds
A QStringList of unique image identifiers for all of the images this WorkOrder is dealing with...
WorkOrder * m_workOrder
This is a pointer to the WorkOrder the XmlHandler is filling with information it parses from an XML f...
ShapeList * shapeList() const
Returns the ShapeList stored in the data of the item.