Isis 3 Programmer Reference
WorkOrder.h
1#ifndef WorkOrder_H
2#define WorkOrder_H
3
10/* SPDX-License-Identifier: CC0-1.0 */
11
12
13#include <QAction>
14#include <QDateTime>
15// This is needed for the QVariant macro
16#include <QMetaType>
17#include <QPointer>
18#include <QUndoCommand>
19
20
21
22#include "CorrelationMatrix.h"
23#include "FileItem.h"
24#include "GuiCamera.h"
25#include "TargetBody.h"
26#include "XmlStackedHandler.h"
27
28template<typename T> class QFutureWatcher;
29class QMutex;
30class QXmlStreamWriter;
31
32namespace Isis {
33 class Control;
34 class ControlList;
35 class Directory;
36 class ImageList;
37 class ProgressBar;
38 class Project;
39 class ProjectItem;
40 class ShapeList;
41 class Template;
42 class XmlStackedHandlerReader;
43
311 class WorkOrder : public QAction, public QUndoCommand {
312 Q_OBJECT
313 public:
314
315
316
322 WorkOrderUnknownStatus = 0,
323 WorkOrderNotStarted,
324 WorkOrderRedoing,
325 WorkOrderRedone,
326 WorkOrderUndoing,
327 WorkOrderUndone,
332 WorkOrderLastStatus = WorkOrderFinished
333 };
334
339 enum Context {
340 NoContext,
341 ProjectContext
342 };
343
345 virtual ~WorkOrder();
346
347 virtual WorkOrder *clone() const = 0;
348
349 virtual bool isExecutable(Context);
350 virtual bool isExecutable(ImageList *images);
351 virtual bool isExecutable(ShapeList *shapes);
352 virtual bool isExecutable(ControlList *controls);
353 virtual bool isExecutable(CorrelationMatrix);
355 virtual bool isExecutable(Template *currentTemplate);
356 virtual bool isExecutable(GuiCameraQsp guiCamera);
357 virtual bool isExecutable(FileItemQsp fileItem);
358 virtual bool isExecutable(ProjectItem *item);
359
360 void read(XmlStackedHandlerReader *xmlReader);
361 void save(QXmlStreamWriter &stream) const;
362
363 virtual void setData(Context);
364 virtual void setData(QString data);
365 virtual void setData(ImageList *images);
366 virtual void setData(ShapeList *shapes);
367 virtual void setData(ControlList *controls);
368 virtual void setData(Template *currentTemplate);
369 virtual void setData(CorrelationMatrix);
370 virtual void setData(TargetBodyQsp targetBody);
371 virtual void setData(GuiCameraQsp guiCamera);
372 virtual void setData(FileItemQsp fileItem);
373 virtual void setData(ProjectItem *item);
374
375
376
377 void setNext(WorkOrder *nextWorkOrder);
378 void setPrevious(WorkOrder *previousWorkOrder);
379
380 QString bestText() const;
381 bool isUndoable() const;
382 bool isSavedToHistory() const;
383 bool isSynchronous() const;
384 bool createsCleanState() const;
385 QDateTime executionTime() const;
386 bool isFinished() const;
387 bool isRedoing() const;
388 bool isRedone() const;
389 bool isUndoing() const;
390 bool isUndone() const;
391 bool modifiesDiskState() const;
392 WorkOrder *next() const;
393 WorkOrder *previous() const;
394 QString statusText() const;
395
397
398 static WorkOrderStatus fromStatusString(QString);
399 static QString toString(WorkOrderStatus);
400
401 signals:
402 void creatingProgress(WorkOrder *);
403 // This is necessary because QTreeWidget doesn't support us just deleting the progress bar..
404 // HistoryWidget relies on this signal.
405 void deletingProgress(WorkOrder *);
406 void finished(WorkOrder *);
407 void statusChanged(WorkOrder *);
408
409 public slots:
410 void enableWorkOrder();
411 void disableWorkOrder();
412
413 virtual bool setupExecution();
414
415 virtual void execute();
416
417 virtual void redo();
418 virtual void undo();
419
420 protected:
421 WorkOrder(const WorkOrder &other);
422
424 const ImageList *imageList() const;
425
427 const ShapeList *shapeList() const;
428
430
431 QPointer<ControlList> controlList();
432
434
436
438
440
441 virtual bool dependsOn(WorkOrder *other) const;
442
443 Directory *directory() const;
444 Project *project() const;
445
447 void setModifiesDiskState(bool changesProjectOnDisk);
448 void setInternalData(QStringList data);
449
450 int progressMin() const;
451 int progressMax() const;
452 int progressValue() const;
453 void setProgressRange(int, int);
454 void setProgressValue(int);
455
457 virtual void postExecution();
458 virtual void undoExecution();
459 virtual void postUndoExecution();
460
461 protected slots:
462 void addCloneToProject();
463
464 private:
465 bool isInStableState() const;
468 void resetProgressBar();
470
471 private slots:
472 void attemptQueuedAction();
473 void executionFinished();
474 void clearImageList();
475 void clearShapeList();
476 void updateProgress();
477 void startRedo();
478
479 private:
484 NoQueuedAction,
485 RedoQueuedAction,
486 UndoQueuedAction
487 };
488
498 public:
499 XmlHandler(WorkOrder *workOrder);
500
501 virtual bool startElement(const QString &namespaceURI, const QString &localName,
502 const QString &qName, const QXmlAttributes &atts);
503
504 private:
505 Q_DISABLE_COPY(XmlHandler);
506
512 };
513
514 protected:
524
531
538
539 WorkOrderStatus m_status;
540
541 private:
542 WorkOrder &operator=(const WorkOrder &rhs);
543
550
557
558 QueuedWorkOrderAction m_queuedAction;
559
572
573 Context m_context;
574 QString m_data;
575 QPointer<ImageList> m_imageList;
576 QPointer<ShapeList> m_shapeList;
577 QPointer<ControlList> m_controlList;
578 CorrelationMatrix m_correlationMatrix;
584
585
591
592
598
599
604
605
611
617
622
626 QPointer<WorkOrder> m_nextWorkOrder;
627
631 QPointer<WorkOrder> m_previousWorkOrder;
632
636 QPointer<Project> m_project;
637
643
648
654 QPointer< QFutureWatcher<void> > m_futureWatcher;
655
656
657
661 QPointer<ProgressBar> m_progressBar;
662
666 QPointer<QTimer> m_progressBarUpdateTimer;
667
672
673
678
683 };
684}
685
687Q_DECLARE_METATYPE(Isis::WorkOrder *);
688
689#endif
Maintains a list of Controls so that control nets can easily be copied from one Project to another,...
Definition ControlList.h:44
This is a container for the correlation matrix that comes from a bundle adjust.
Internalizes a list of images and allows for operations on the entire list.
Definition ImageList.h:55
The main project for ipce.
Definition Project.h:289
Represents an item of a ProjectItemModel in Qt's model-view framework.
Internalizes a list of shapes and allows for operations on the entire list.
Definition ShapeList.h:33
This class is used for processing an XML file containing information about a WorkOrder.
Definition WorkOrder.h:497
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.
XmlHandler(WorkOrder *workOrder)
Passes a pointer to a WorkOrder to the WorkOrder::XmlHandler class.
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:511
Provide Undo/redo abilities, serialization, and history for an operation.
Definition WorkOrder.h:311
QTime * m_elapsedTimer
A QTime object holding the excecution time of the WorkOrder.
Definition WorkOrder.h:677
void enableWorkOrder()
Enables the work order.
QPointer< QTimer > m_progressBarUpdateTimer
A pointer to the QTimer which updates the ProgressBar.
Definition WorkOrder.h:666
QStringList m_imageIds
A QStringList of unique image identifiers for all of the images this WorkOrder is dealing with.
Definition WorkOrder.h:610
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.
Definition WorkOrder.h:537
QueuedWorkOrderAction
This enum describes the current state of a Queued WorkOrder.
Definition WorkOrder.h:483
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.
Definition WorkOrder.h:616
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.
void read(XmlStackedHandlerReader *xmlReader)
Read this work order's data from disk.
bool m_isSynchronous
This is defaulted to true.
Definition WorkOrder.h:530
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.
Definition WorkOrder.h:590
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.
Definition WorkOrder.h:321
@ WorkOrderFinished
This is used for work orders that will not undo or redo (See createsCleanState())
Definition WorkOrder.h:331
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...
Definition WorkOrder.h:523
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.
Definition WorkOrder.h:647
bool m_createsCleanState
This is defaulted to false.
Definition WorkOrder.h:549
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.
Definition WorkOrder.h:583
QPointer< WorkOrder > m_previousWorkOrder
A pointer to the previous WorkOrder in the queue.
Definition WorkOrder.h:631
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.
Definition WorkOrder.h:567
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.
Definition WorkOrder.h:571
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.
Definition WorkOrder.h:661
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.
Definition WorkOrder.h:682
void setInternalData(QStringList data)
Sets the internal data for this WorkOrder.
int m_progressRangeMinValue
The miniumum value of the Progess Bar.
Definition WorkOrder.h:563
virtual bool dependsOn(WorkOrder *other) const
Indicate workorder dependency This is a virtual function whose role in child classes is to determine ...
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.
Definition WorkOrder.h:636
virtual ~WorkOrder()
The Destructor.
ProgressBar * progressBar()
Returns the ProgressBar.
QStringList m_internalData
A QStringList of internal properties for this WorkOrder.
Definition WorkOrder.h:621
bool m_modifiesDiskState
This is defaulted to false.
Definition WorkOrder.h:556
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:642
QPointer< WorkOrder > m_nextWorkOrder
A pointer to the next WorkOrder in the queue.
Definition WorkOrder.h:626
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.
Definition WorkOrder.h:603
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...
Definition WorkOrder.h:339
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.
Definition WorkOrder.h:654
CorrelationMatrix correlationMatrix()
Returns the CorrleationMatrix for this WorkOrder.
QPointer< QTimer > m_progressBarDeletionTimer
A pointer to the ProgressBar deletion timer.
Definition WorkOrder.h:671
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.
Definition WorkOrder.cpp:39
TargetBodyQsp m_targetBody
A QSharedPointer to the TargetBody (A Target object but encapsulated within a Gui framework.
Definition WorkOrder.h:597
XML Handler that parses XMLs in a stack-oriented way.
Manage a stack of content handlers for reading XML files.
This is free and unencumbered software released into the public domain.
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16