Isis Developer Reference
WorkOrder.h
Go to the documentation of this file.
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#include <QXmlStreamReader>
20
21#include <QElapsedTimer>
22
23
24#include "CorrelationMatrix.h"
25#include "FileItem.h"
26#include "GuiCamera.h"
27#include "TargetBody.h"
28
29template<typename T> class QFutureWatcher;
30class QMutex;
31class QXmlStreamWriter;
32
33namespace Isis {
34 class Control;
35 class ControlList;
36 class Directory;
37 class ImageList;
38 class ProgressBar;
39 class Project;
40 class ProjectItem;
41 class ShapeList;
42 class Template;
43
311 class WorkOrder : public QAction, public QUndoCommand {
312 Q_OBJECT
313 public:
314
315
316
334
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 save(QXmlStreamWriter &stream) const;
361
362 virtual void setData(Context);
363 virtual void setData(QString data);
364 virtual void setData(ImageList *images);
365 virtual void setData(ShapeList *shapes);
366 virtual void setData(ControlList *controls);
367 virtual void setData(Template *currentTemplate);
368 virtual void setData(CorrelationMatrix);
369 virtual void setData(TargetBodyQsp targetBody);
370 virtual void setData(GuiCameraQsp guiCamera);
371 virtual void setData(FileItemQsp fileItem);
372 virtual void setData(ProjectItem *item);
373
374
375
376 void setNext(WorkOrder *nextWorkOrder);
377 void setPrevious(WorkOrder *previousWorkOrder);
378
379 QString bestText() const;
380 bool isUndoable() const;
381 bool isSavedToHistory() const;
382 bool isSynchronous() const;
383 bool createsCleanState() const;
384 QDateTime executionTime() const;
385 bool isFinished() const;
386 bool isRedoing() const;
387 bool isRedone() const;
388 bool isUndoing() const;
389 bool isUndone() const;
390 bool modifiesDiskState() const;
391 WorkOrder *next() const;
392 WorkOrder *previous() const;
393 QString statusText() const;
394
396
397 static WorkOrderStatus fromStatusString(QString);
398 static QString toString(WorkOrderStatus);
399
400 signals:
402 // This is necessary because QTreeWidget doesn't support us just deleting the progress bar..
403 // HistoryWidget relies on this signal.
407
408 public slots:
409 void enableWorkOrder();
410 void disableWorkOrder();
411
412 virtual bool setupExecution();
413
414 virtual void execute();
415
416 virtual void redo();
417 virtual void undo();
418
419 protected:
420 WorkOrder(const WorkOrder &other);
421
423 const ImageList *imageList() const;
424
426 const ShapeList *shapeList() const;
427
429
430 QPointer<ControlList> controlList();
431
433
435
437
439
440 virtual bool dependsOn(WorkOrder *other) const;
441
442 Directory *directory() const;
443 Project *project() const;
444
446 void setModifiesDiskState(bool changesProjectOnDisk);
447 void setInternalData(QStringList data);
448
449 int progressMin() const;
450 int progressMax() const;
451 int progressValue() const;
452 void setProgressRange(int, int);
453 void setProgressValue(int);
454
456 virtual void postExecution();
457 virtual void undoExecution();
458 virtual void postUndoExecution();
459
460 protected slots:
461 void addCloneToProject();
462
463 private:
464 bool isInStableState() const;
465 void listenForImageDestruction();
466 void listenForShapeDestruction();
467 void resetProgressBar();
468 void setProgressToFinalText();
469
470 private slots:
471 void attemptQueuedAction();
472 void executionFinished();
473 void clearImageList();
474 void clearShapeList();
475 void updateProgress();
476 void startRedo();
477
478 private:
482 enum QueuedWorkOrderAction {
483 NoQueuedAction,
484 RedoQueuedAction,
485 UndoQueuedAction
486 };
487
488 protected:
498
505
512
514
515 private:
516 WorkOrder &operator=(const WorkOrder &rhs);
517
523 bool m_createsCleanState;
524
530 bool m_modifiesDiskState;
531
532 QueuedWorkOrderAction m_queuedAction;
533
537 int m_progressRangeMinValue;
541 int m_progressRangeMaxValue;
545 int m_progressValue;
546
547 Context m_context;
548 QString m_data;
549 QPointer<ImageList> m_imageList;
550 QPointer<ShapeList> m_shapeList;
551 QPointer<ControlList> m_controlList;
552 CorrelationMatrix m_correlationMatrix;
557 GuiCameraQsp m_guiCamera;
558
559
564 Template *m_template;
565
566
571 TargetBodyQsp m_targetBody;
572
573
577 FileItemQsp m_fileItem;
578
579
584 QStringList m_imageIds;
585
590 QStringList m_shapeIds;
591
595 QStringList m_internalData;
596
600 QPointer<WorkOrder> m_nextWorkOrder;
601
605 QPointer<WorkOrder> m_previousWorkOrder;
606
610 QPointer<Project> m_project;
611
616 QMutex *m_transparentConstMutex;
617
621 QDateTime m_executionTime;
622
628 QPointer< QFutureWatcher<void> > m_futureWatcher;
629
630
631
635 QPointer<ProgressBar> m_progressBar;
636
640 QPointer<QTimer> m_progressBarUpdateTimer;
641
645 QPointer<QTimer> m_progressBarDeletionTimer;
646
647
651 QElapsedTimer *m_elapsedTimer;
652
656 double m_secondsElapsed;
657 };
658}
659
662
663#endif
Q_DECLARE_METATYPE(Isis::WorkOrder *)
This allows WorkOrder *'s to be stored in a QVariant.
Maintains a list of Controls so that control nets can easily be copied from one Project to another,...
Definition ControlList.h:42
This is a container for the correlation matrix that comes from a bundle adjust.
Definition CorrelationMatrix.h:61
Definition Directory.h:271
Internalizes a list of images and allows for operations on the entire list.
Definition ImageList.h:53
Definition ProgressBar.h:15
The main project for ipce.
Definition Project.h:287
Represents an item of a ProjectItemModel in Qt's model-view framework.
Definition ProjectItem.h:134
Internalizes a list of shapes and allows for operations on the entire list.
Definition ShapeList.h:31
Definition Template.h:30
Provide Undo/redo abilities, serialization, and history for an operation.
Definition WorkOrder.h:311
void creatingProgress(WorkOrder *)
void enableWorkOrder()
Enables the work order.
Definition WorkOrder.cpp:1206
void setNext(WorkOrder *nextWorkOrder)
Sets the next WorkOrder in the sequence.
Definition WorkOrder.cpp:601
void finished(WorkOrder *)
ShapeList * shapeList()
@briefReturns a pointer to the ShapeList for this WorkOrder.
Definition WorkOrder.cpp:651
bool m_isSavedToHistory
Set the work order to be shown in the HistoryTreeWidget.
Definition WorkOrder.h:511
void setProgressRange(int, int)
Sets the progress range of the WorkOrder.
Definition WorkOrder.cpp:1346
int progressMax() const
Gets the maximum value of the progress range of the WorkOrder.
Definition WorkOrder.cpp:1325
virtual void setData(Context)
Sets the context data for this WorkOrder.
Definition WorkOrder.cpp:245
WorkOrder * next() const
Gets the next WorkOrder.
Definition WorkOrder.cpp:922
bool modifiesDiskState() const
Returns the modified disk state.
Definition WorkOrder.cpp:912
bool m_isSynchronous
This is defaulted to true.
Definition WorkOrder.h:504
bool isUndoing() const
Returns the WorkOrderUndoing state.
Definition WorkOrder.cpp:891
virtual void undoExecution()
Execute the steps necessary to undo this workorder.
Definition WorkOrder.cpp:1422
virtual void postUndoExecution()
Perform any steps necessary after an undo of a workorder.
Definition WorkOrder.cpp:1433
Template * getTemplate()
WorkOrder::getTemplate.
Definition WorkOrder.cpp:724
void save(QXmlStreamWriter &stream) const
: Saves a WorkOrder to a data stream.
Definition WorkOrder.cpp:532
bool isRedone() const
Returns the WorkOrder redone status.
Definition WorkOrder.cpp:881
virtual void redo()
Starts (or enqueues) a redo.
Definition WorkOrder.cpp:1031
WorkOrderStatus
This enumeration is used by other functions to set and retrieve the current state of the WorkOrder.
Definition WorkOrder.h:321
@ WorkOrderUnknownStatus
Definition WorkOrder.h:322
@ WorkOrderNotStarted
Definition WorkOrder.h:323
@ WorkOrderUndone
Definition WorkOrder.h:327
@ WorkOrderRedoing
Definition WorkOrder.h:324
@ WorkOrderUndoing
Definition WorkOrder.h:326
@ WorkOrderFinished
This is used for work orders that will not undo or redo (See createsCleanState())
Definition WorkOrder.h:331
@ WorkOrderLastStatus
Definition WorkOrder.h:332
@ WorkOrderRedone
Definition WorkOrder.h:325
WorkOrderStatus m_status
Definition WorkOrder.h:513
virtual void undo()
Starts (or enqueues) an undo.
Definition WorkOrder.cpp:1134
int progressMin() const
Gets the minimum value of the progress range of the WorkOrder.
Definition WorkOrder.cpp:1315
bool isUndoable() const
Returns true if this work order is undoable, otherwise false.
Definition WorkOrder.cpp:807
WorkOrder * previous() const
Gets the previous WorkOrder.
Definition WorkOrder.cpp:932
bool m_isUndoable
Set the workorder to be undoable/redoable This is defaulted to true - his will allow the workorder to...
Definition WorkOrder.h:497
void setProgressValue(int)
Sets the current progress value for the WorkOrder.
Definition WorkOrder.cpp:1356
static QString toString(WorkOrderStatus)
Gets the current status of the WorkOrder.
Definition WorkOrder.cpp:997
bool isUndone() const
Returns the WorkOrder undo status.
Definition WorkOrder.cpp:901
virtual bool setupExecution()
This sets up the state for the work order.
Definition WorkOrder.cpp:1249
void statusChanged(WorkOrder *)
bool isSavedToHistory() const
Returns true if this work order is to be shown in History, otherwise false.
Definition WorkOrder.cpp:818
static WorkOrderStatus fromStatusString(QString)
Attempts to query the current status of the WorkOrder.
Definition WorkOrder.cpp:976
bool isRedoing() const
Returns the redoing status of this WorkOrder.
Definition WorkOrder.cpp:871
QStringList internalData() const
Gets the internal data for this WorkOrder.
Definition WorkOrder.cpp:1365
QPointer< ControlList > controlList()
Returns the Control List for this WorkOrder (a list of control networks).
Definition WorkOrder.cpp:694
Directory * directory() const
return the workorder project directory Returns the Directory object of the Project this WorkOrder is ...
Definition WorkOrder.cpp:1278
virtual WorkOrder * clone() const =0
GuiCameraQsp guiCamera()
WorkOrder::guiCamera.
Definition WorkOrder.cpp:744
void setCreatesCleanState(bool createsCleanState)
Declare that this work order is saving the project.
Definition WorkOrder.cpp:1651
QString statusText() const
WorkOrder::statusText.
Definition WorkOrder.cpp:942
QDateTime executionTime() const
Gets the execution time of this WorkOrder.
Definition WorkOrder.cpp:852
virtual void execute()
Execute the workorder.
Definition WorkOrder.cpp:1391
void setModifiesDiskState(bool changesProjectOnDisk)
Definition WorkOrder.cpp:1662
void setPrevious(WorkOrder *previousWorkOrder)
Sets the previous WorkOrder in the sequence.
Definition WorkOrder.cpp:610
virtual bool isExecutable(Context)
Re-implement this method if your work order utilizes controls for data in order to operate.
Definition WorkOrder.cpp:179
void disableWorkOrder()
Disables the work order.
Definition WorkOrder.cpp:1218
bool createsCleanState() const
Returns the CleanState status (whether the Project has been saved to disk or not).
Definition WorkOrder.cpp:842
TargetBodyQsp targetBody()
WorkOrder::targetBody.
Definition WorkOrder.cpp:734
void setInternalData(QStringList data)
Sets the internal data for this WorkOrder.
Definition WorkOrder.cpp:1306
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:769
Project * project() const
Returns the Project this WorkOrder is attached to.
Definition WorkOrder.cpp:1288
virtual ~WorkOrder()
The Destructor.
Definition WorkOrder.cpp:154
ProgressBar * progressBar()
Returns the ProgressBar.
Definition WorkOrder.cpp:963
void addCloneToProject()
Runs a copy of the current WorkOrder and stores it in the project.
Definition WorkOrder.cpp:1440
ImageList * imageList()
Returns a pointer to the ImageList for this WorkOrder.
Definition WorkOrder.cpp:619
bool isSynchronous() const
Returns true if this work order is run synchronously, otherwise false.
Definition WorkOrder.cpp:829
Context
This enumeration is for recording the context of the current Workorder (whether it is part of a proje...
Definition WorkOrder.h:339
@ NoContext
Definition WorkOrder.h:340
@ ProjectContext
Definition WorkOrder.h:341
QString bestText() const
Generate unique action names We don't use action text anymore because Directory likes to rename our a...
Definition WorkOrder.cpp:783
int progressValue() const
Gets the current progress value of the WorkOrder.
Definition WorkOrder.cpp:1335
bool isFinished() const
Returns the finished state of this WorkOrder.
Definition WorkOrder.cpp:862
void deletingProgress(WorkOrder *)
virtual void postExecution()
Perform any necessary actions after execution of a workorder.
Definition WorkOrder.cpp:1402
CorrelationMatrix correlationMatrix()
Returns the CorrleationMatrix for this WorkOrder.
Definition WorkOrder.cpp:684
FileItemQsp fileItem()
WorkOrder::fileItem.
Definition WorkOrder.cpp:754
WorkOrder(Project *project)
Create a work order that will work with the given project.
Definition WorkOrder.cpp:38
This is free and unencumbered software released into the public domain.
Definition AbstractTableModel.h:24
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16