Isis 3.0 Programmer Reference
Back | Home
WorkOrder.cpp
Go to the documentation of this file.
1 
23 #include "IsisDebug.h"
24 
25 #include "WorkOrder.h"
26 
27 #include <QDebug>
28 #include <QFutureWatcher>
29 #include <QMutex>
30 #include <QtConcurrentRun>
31 #include <QTimer>
32 #include <QXmlStreamWriter>
33 
34 #include "ControlList.h"
35 #include "CorrelationMatrix.h"
36 #include "IException.h"
37 #include "ImageList.h"
38 #include "IString.h"
39 #include "ProgressBar.h"
40 #include "Project.h"
41 #include "ProjectItem.h"
42 #include "ShapeList.h"
43 #include "TargetBody.h"
44 #include "XmlStackedHandlerReader.h"
45 
46 
47 namespace Isis {
55  WorkOrder::WorkOrder(Project *project) : QAction(project) {
57 
58  m_context = NoContext;
59  m_imageList = new ImageList;
60  m_shapeList = new ShapeList;
61  m_controlList = NULL;
62  m_correlationMatrix = CorrelationMatrix();
65 
66  m_createsCleanState = false;
67  m_modifiesDiskState = false;
68  m_status = WorkOrderNotStarted;
69  m_queuedAction = NoQueuedAction;
71  m_elapsedTimer = NULL;
72 
74  m_transparentConstMutex = new QMutex;
75 
78  m_progressValue = 0;
79 
80  m_secondsElapsed = 0.0;
81 
82  if (!m_project) {
84  tr("Work orders cannot be created without a project."), _FILEINFO_);
85  }
86 
87  connect(this, SIGNAL(triggered()),
88  this, SLOT(addCloneToProject()));
89  connect(m_futureWatcher, SIGNAL(finished()),
90  this, SLOT(asyncFinished()));
91  }
92 
93 
98  delete m_imageList;
99  delete m_shapeList;
100  delete m_futureWatcher;
101  delete m_progressBar;
105 
106  m_nextWorkOrder = NULL;
107  m_previousWorkOrder = NULL;
108  m_project = NULL;
110  }
111 
112 
120  QAction(other.icon(), ((QAction &)other).text(), other.parentWidget()),
121  QUndoCommand(((QUndoCommand &)other).text()) {
123  m_elapsedTimer = NULL;
124  m_project = other.project();
125  m_context = other.m_context;
126  m_imageIds = other.m_imageIds;
127  m_imageList = new ImageList(*other.m_imageList);
128  m_shapeIds = other.m_shapeIds;
129  m_shapeList = new ShapeList(*other.m_shapeList);
130  m_correlationMatrix = other.m_correlationMatrix;
131  m_controlList = other.m_controlList;
132  m_guiCamera = other.m_guiCamera;
133  m_targetBody = other.m_targetBody;
135 
138 
140 
141  m_status = other.m_status;
142  m_queuedAction = other.m_queuedAction;
143 
145 
149 
151  m_transparentConstMutex = new QMutex;
152 
153  if (!other.isInStableState()) {
155  tr("Can not copy work order [%1] because it is currently running")
156  .arg(((QUndoCommand &)other).text()),
157  _FILEINFO_);
158  }
159 
160  connect(this, SIGNAL(triggered()),
161  this, SLOT(addCloneToProject()));
162  connect(m_futureWatcher, SIGNAL(finished()),
163  this, SLOT(asyncFinished()));
164 
167  }
168 
169 
180  return false;
181  }
182 
183 
194  return false;
195  }
196 
197 
208  return false;
209  }
210 
211 
219 //bool WorkOrder::isExecutable(Control *control) {
220 // return false;
221 //}
222 
223 
232  return false;
233  }
234 
235 
236  bool WorkOrder::isExecutable(CorrelationMatrix correlationMatrix) {
237  return false;
238  }
239 
240 
245  void WorkOrder::setData(Context context) {
246  m_context = context;
247  }
248 
249 
255  m_imageIds.clear();
256  delete m_imageList;
257 
258  m_imageList = new ImageList(*images);
260  }
261 
262 
268  m_shapeIds.clear();
269  delete m_shapeList;
270 
271  m_shapeList = new ShapeList(*shapes);
273  }
274 
275 
280 //void WorkOrder::setData(Control *control) {
281 // m_control = control;
282 //}
283 
284 
290  void WorkOrder::setData(ControlList *controls) {
291  m_controlList = controls;
292  }
293 
294 
299  void WorkOrder::setData(CorrelationMatrix correlationMatrix) {
300  m_correlationMatrix = correlationMatrix;
301  }
302 
303 
310  }
311 
312 
319  }
320 
321 
327  if ( item->isProject() ) {
328  setData( ProjectContext );
329  }
330  else if ( item->isImageList() ) {
331  setData( item->imageList() );
332  }
333  else if ( item->isImage() ) {
334  ImageList *imageList = new ImageList(this);
335  imageList->append( item->image() );
336  setData(imageList);
337  }
338  else if ( item->isShapeList() ) {
339  setData( item->shapeList() );
340  }
341  else if ( item->isShape() ) {
342  ShapeList *shapeList = new ShapeList(this);
343  shapeList->append( item->shape() );
344  setData(shapeList);
345  }
346  else if (item->isControlList()) {
347  setData( item->controlList() );
348  }
349  else if ( item->isControl() ) {
350  ControlList *controlList = new ControlList(this);
351  controlList->append( item->control() );
352  setData(controlList);
353 // //setData(*controlList);
354  }
355  else if ( item->isCorrelationMatrix() ) {
356  setData( item->correlationMatrix() );
357  }
358  else if ( item->isTargetBody() ) {
359  setData( item->targetBody() );
360  }
361  else if ( item->isGuiCamera() ) {
362  setData( item->guiCamera() );
363  }
364  }
365 
366 
375  return false;
376  }
377 
378 
387  return false;
388  }
389 
390 
399  if ( !item ) {
400  return false;
401  }
402  else if ( item->isProject() ) {
403  return isExecutable( ProjectContext );
404  }
405  else if ( item->isImageList() ) {
406  return isExecutable( item->imageList() );
407  }
408  else if ( item->isImage() ) {
409  ImageList *imageList = new ImageList();
410  imageList->append( item->image() );
411  bool ret = isExecutable(imageList);
412  imageList->deleteLater();
413  return ret;
414  }
415  else if ( item->isShapeList() ) {
416  return isExecutable( item->shapeList() );
417  }
418  else if ( item->isShape() ) {
419  ShapeList *shapeList = new ShapeList();
420  shapeList->append( item->shape() );
421  bool ret = isExecutable(shapeList);
422  shapeList->deleteLater();
423  return ret;
424  }
425  else if ( item->isControlList() ) {
426  return isExecutable (item -> controlList() );
427  }
428  else if ( item->isControl() ) {
430  controlList->append( item->control() );
431  bool ret = isExecutable(controlList);
432  controlList->deleteLater();
433  return ret;
434  }
435  else if ( item->isCorrelationMatrix() ) {
436  return isExecutable( item->correlationMatrix() );
437  }
438  else if ( item->isTargetBody() ) {
439  //return isExecutable( item->targetBody() ) || isExecutable( item->targetBody().data() );
440  return isExecutable(item->targetBody());
441  }
442  else if ( item->isGuiCamera() ) {
443  //return isExecutable( item->guiCamera() ) || isExecutable( item->guiCamera().data() );
444  return isExecutable( item->guiCamera() );
445  }
446 
447  return false;
448  }
449 
450 
455  xmlReader->pushContentHandler(new XmlHandler(this));
456  }
457 
458 
478  void WorkOrder::save(QXmlStreamWriter &stream) const {
479  if (!isInStableState()) {
481  tr("Can not store an unstable work order. The work order [%1] is currently "
482  "working").arg(bestText()),
483  _FILEINFO_);
484  }
485 
486  stream.writeStartElement("workOrder");
487 
488  stream.writeAttribute("actionText", QAction::text());
489  stream.writeAttribute("undoText", QUndoCommand::text());
490  stream.writeAttribute("executionTime", m_executionTime.toString());
491  stream.writeAttribute("type", metaObject()->className());
492  stream.writeAttribute("status", toString(m_status));
493 
494  if (m_imageIds.count()) {
495  stream.writeStartElement("images");
496 
497  foreach (QString imageId, m_imageIds) {
498  stream.writeStartElement("image");
499  stream.writeAttribute("id", imageId);
500  stream.writeEndElement();
501  }
502 
503  stream.writeEndElement();
504  }
505 
506  if (m_shapeIds.count()) {
507  stream.writeStartElement("shapes");
508 
509  foreach (QString shapeId, m_shapeIds) {
510  stream.writeStartElement("shape");
511  stream.writeAttribute("id", shapeId);
512  stream.writeEndElement();
513  }
514 
515  stream.writeEndElement();
516  }
517 
518  if (m_internalData.count()) {
519  stream.writeStartElement("internalDataValues");
520 
521  foreach (QString str, m_internalData) {
522  stream.writeStartElement("dataValue");
523  stream.writeAttribute("value", str);
524  stream.writeEndElement();
525  }
526 
527  stream.writeEndElement();
528  }
529 
530  if (m_context != NoContext) {
531  stream.writeStartElement("context");
532 
533  QString contextStr = "ProjectContext";
534  stream.writeAttribute("value", contextStr);
535 
536  stream.writeEndElement();
537  }
538 
539  stream.writeEndElement();
540  }
541 
542 
547  void WorkOrder::setNext(WorkOrder *nextWorkOrder) {
548  m_nextWorkOrder = nextWorkOrder;
549  }
550 
551 
556  void WorkOrder::setPrevious(WorkOrder *previousWorkOrder) {
557  m_previousWorkOrder = previousWorkOrder;
558  }
559 
560 
566  if (!m_imageList) {
567  bool anyImagesAreNull = false;
568 
569  m_imageList = new ImageList;
570 
571  foreach (QString id, m_imageIds) {
572  Image *image = project()->image(id);
573  m_imageList->append(image);
574 
575  if (!image) {
576  anyImagesAreNull = true;
577  }
578  }
579 
580  if (anyImagesAreNull) {
581  delete m_imageList;
582  }
583  else {
585  }
586  }
587 
588  return m_imageList;
589  }
590 
591 
597  if (!m_shapeList) {
598  bool anyShapesAreNull = false;
599 
600  m_shapeList = new ShapeList;
601 
602  foreach (QString id, m_shapeIds) {
603  Shape *shape = project()->shape(id);
604  m_shapeList->append(shape);
605 
606  if (!shape) {
607  anyShapesAreNull = true;
608  }
609  }
610 
611  if (anyShapesAreNull) {
612  delete m_shapeList;
613  }
614  else {
616  }
617  }
618 
619  return
620  m_shapeList;
621  }
622 
623 
629  return m_correlationMatrix;
630  }
631 
632 
637  QPointer<ControlList> WorkOrder::controlList() {
638  return m_controlList;
639  }
640 
641 
647  QMutexLocker lock(m_transparentConstMutex);
648  return const_cast<WorkOrder *>(this)->imageList();
649  }
650 
651 
657  QMutexLocker lock(m_transparentConstMutex);
658  return const_cast<WorkOrder *>(this)->shapeList();
659  }
660 
661 
667  return m_targetBody;
668  }
669 
670 
676  return m_guiCamera;
677  }
678 
679 
689  return true;
690  }
691 
692 
701  QString WorkOrder::bestText() const {
702  QString result = QUndoCommand::text().remove("&").remove("...");
703 
704  // if the QUndoCommand has no text, create a warning
705  if (result.isEmpty()) {
706  // get the name of the work order
707  result = QString(metaObject()->className()).remove("Isis::").remove("WorkOrder")
708  .replace(QRegExp("([a-z0-9])([A-Z])"), "\\1 \\2");
709  qWarning() << QString("WorkOrder::bestText(): Work order [%1] has no QUndoCommand text")
710  .arg(result);
711  }
712 
713  return result;
714  }
715 
716 
722  return m_createsCleanState;
723  }
724 
725 
730  QDateTime WorkOrder::executionTime() const {
731  return m_executionTime;
732  }
733 
734 
739  bool WorkOrder::isFinished() const {
740  return m_status == WorkOrderFinished;
741  }
742 
743 
748  bool WorkOrder::isRedoing() const {
749  return m_status == WorkOrderRedoing;
750  }
751 
752 
757  bool WorkOrder::isRedone() const {
758  return m_status == WorkOrderRedone;
759  }
760 
761 
766  bool WorkOrder::isUndoing() const {
767  return m_status == WorkOrderUndoing;
768  }
769 
770 
775  bool WorkOrder::isUndone() const {
776  return m_status == WorkOrderUndone;
777  }
778 
779 
786  return m_modifiesDiskState;
787  }
788 
789 
795  return m_nextWorkOrder;
796  }
797 
798 
804  return m_previousWorkOrder;
805  }
806 
807 
812  QString WorkOrder::statusText() const {
813  QString result = toString(m_status);
814 
815  if (m_secondsElapsed) {
816  // QTime can't format in the way that I want (0-n minutes, 00-59 seconds, no hours
817  // displayed)... so do it manually.
818  // Expected output format examples: 0:01, 0:55, 1:30, 55:55, 90:00, 100:12
819  int seconds = qRound(m_secondsElapsed) % 60;
820  int minutes = qRound(m_secondsElapsed) / 60;
821  result += tr(" (elapsed: %1:%2)").arg(minutes).arg(seconds, 2, 10, QChar('0'));
822  }
823 
824  return result;
825  }
826 
827 
833  return m_progressBar;
834  }
835 
836 
845  statusString = statusString.toUpper();
846  WorkOrderStatus result = WorkOrderUnknownStatus;
847 
848  for (WorkOrderStatus possibleResult = WorkOrderUnknownStatus;
849  possibleResult <= WorkOrderLastStatus;
850  possibleResult = (WorkOrderStatus)(possibleResult + 1)) {
851  if (statusString == toString(possibleResult).toUpper()) {
852  result = possibleResult;
853  }
854  }
855 
856  return result;
857  }
858 
859 
866  QString result;
867 
868  switch (status) {
869  case WorkOrderUnknownStatus:
870  result = tr("Unknown");
871  break;
872  case WorkOrderNotStarted:
873  result = tr("Not Started");
874  break;
875  case WorkOrderRedoing:
876  result = tr("In Progress");
877  break;
878  case WorkOrderRedone:
879  result = tr("Completed");
880  break;
881  case WorkOrderUndoing:
882  result = tr("Undoing");
883  break;
884  case WorkOrderUndone:
885  result = tr("Undone");
886  break;
887  case WorkOrderFinished:
888  result = tr("Finished");
889  break;
890  }
891 
892  return result;
893  }
894 
895 
901  if (!isInStableState()) {
902  m_queuedAction = RedoQueuedAction;
903  }
904 
905  if (!isRedone()) {
906  bool mustQueueThisRedo = false;
907 
908  WorkOrder *dependency = NULL;
909  WorkOrder *current = this;
910  while (current->previous() && !dependency) {
911  if (!current->previous()->isRedone() && !current->previous()->isFinished()) {
912  WorkOrder *possibleDependency = current->previous();
913 
914  if (dependsOn(possibleDependency)) {
915  connect(possibleDependency, SIGNAL(finished(WorkOrder *)),
916  this, SLOT(attemptQueuedAction()));
917  dependency = possibleDependency;
918  mustQueueThisRedo = true;
919  }
920  }
921 
922  current = current->previous();
923  }
924 
925  if (!imageList()) {
926  connect(project(), SIGNAL(imagesAdded(ImageList *)),
927  this, SLOT(attemptQueuedAction()));
928  mustQueueThisRedo = true;
929  }
930 
931  if (!shapeList()) {
932  connect(project(), SIGNAL(shapesAdded(ShapeList *)),
933  this, SLOT(attemptQueuedAction()));
934  mustQueueThisRedo = true;
935  }
936 
937  if (mustQueueThisRedo && !isUndoing() && !isRedoing()) {
938  m_queuedAction = RedoQueuedAction;
939 
940  QString queueStatusText;
941 
942  if (dependency) {
943  QString dependencyText = dependency->bestText();
944 
945  if (dependencyText.count() > 5) {
946  dependencyText = dependencyText.mid(0, 5) + "...";
947  }
948 
949  queueStatusText = tr("Wait for [%1]").arg(dependencyText);
950  }
951  else if (!imageList()) {
952  queueStatusText = tr("Wait for images");
953  }
954  else if (!shapeList()) {
955  queueStatusText = tr("Wait for shapes");
956  }
957 
959  m_progressBar->setValue(m_progressBar->minimum());
960  m_progressBar->setText(queueStatusText);
961  m_progressBar->update();
962  }
963 
964  if (m_queuedAction == NoQueuedAction) {
965  m_status = WorkOrderRedoing;
966  emit statusChanged(this);
967 
969  m_progressBar->setText("Starting...");
970  m_progressBar->update();
971 
972  delete m_elapsedTimer;
973  m_elapsedTimer = new QTime;
974  m_elapsedTimer->start();
975 
976  syncRedo();
977 
978  m_progressBar->setText("Running...");
979  m_progressBar->update();
980  QFuture<void> future = QtConcurrent::run(this, &WorkOrder::asyncRedo);
981  m_futureWatcher->setFuture(future);
982  }
983  }
984  else {
986  }
987  }
988 
989 
995  if (!isInStableState()) {
996  m_queuedAction = UndoQueuedAction;
997  }
998 
999  if (!isUndone() && m_status != WorkOrderNotStarted) {
1000  WorkOrder *dependency = NULL;
1001  WorkOrder *current = this;
1002  while (current->next() && !dependency) {
1003  if (!current->next()->isUndone() && !current->next()->isFinished() &&
1004  current->next()->m_status != WorkOrderNotStarted) {
1005  connect(current->next(), SIGNAL(finished(WorkOrder *)),
1006  this, SLOT(attemptQueuedAction()));
1007  m_queuedAction = UndoQueuedAction;
1008  dependency = current->next();
1009  }
1010 
1011  current = current->next();
1012  }
1013 
1014  if (dependency && !isUndoing() && !isRedoing()) {
1015  QString prevText = dependency->bestText();
1016 
1017  if (prevText.count() > 5) {
1018  prevText = prevText.mid(0, 5) + "...";
1019  }
1020 
1021  resetProgressBar();
1022  m_progressBar->setValue(m_progressBar->minimum());
1023  m_progressBar->setText(tr("Undo after [%1]").arg(prevText));
1024  m_progressBar->update();
1025  }
1026 
1027  if (m_queuedAction == NoQueuedAction) {
1028  m_status = WorkOrderUndoing;
1029  emit statusChanged(this);
1030 
1031  resetProgressBar();
1032  m_progressBar->setText("Starting Undo...");
1033  m_progressBar->update();
1034 
1035  delete m_elapsedTimer;
1036  m_elapsedTimer = new QTime;
1037  m_elapsedTimer->start();
1038 
1039  syncUndo();
1040 
1041  m_progressBar->setText("Undoing...");
1042  m_progressBar->update();
1043  QFuture<void> future = QtConcurrent::run(this, &WorkOrder::asyncUndo);
1044  m_futureWatcher->setFuture(future);
1045  }
1046  }
1047  else {
1049  }
1050  }
1051 
1052 
1079  // We're finished at this point if we save/open a project, we're not finished if we need to do
1080  // redo()
1081  if (createsCleanState()) {
1082  m_status = WorkOrderFinished;
1083 
1084  emit statusChanged(this);
1085  }
1086 
1087  m_executionTime = QDateTime::currentDateTime();
1088 
1089  resetProgressBar();
1090 
1091  if (createsCleanState()) {
1093  }
1094  else {
1095  m_progressBar->setText("Initializing...");
1096  }
1097 
1098  return true;
1099  }
1100 
1101 
1107  return project()->directory();
1108  }
1109 
1110 
1117  if (!m_project) {
1119  "This work order no longer has a project.", _FILEINFO_);
1120  }
1121 
1122  return m_project;
1123  }
1124 
1125 
1131  m_internalData = data;
1132  }
1133 
1134 
1140  return m_progressRangeMinValue;
1141  }
1142 
1143 
1149  return m_progressRangeMaxValue;
1150  }
1151 
1152 
1158  return m_progressValue;
1159  }
1160 
1161 
1167  void WorkOrder::setProgressRange(int minValue, int maxValue) {
1168  m_progressRangeMinValue = minValue;
1169  m_progressRangeMaxValue = maxValue;
1170  }
1171 
1172 
1178  m_progressValue = value;
1179  }
1180 
1181 
1187  return m_internalData;
1188  }
1189 
1190 
1204  }
1205 
1206 
1223  }
1224 
1225 
1239  }
1240 
1241 
1255  }
1256 
1257 
1272  }
1273 
1274 
1288  }
1289 
1290 
1295  if (project()) {
1296  project()->addToProject(clone());
1297  }
1298  }
1299 
1300 
1306  bool result = true;
1307 
1308  if (isRedoing() || isUndoing() || m_queuedAction != NoQueuedAction) {
1309  result = false;
1310  }
1311 
1312  return result;
1313  }
1314 
1315 
1322  m_imageIds.clear();
1323  foreach (Image *image, *m_imageList) {
1324  if (image) {
1325  m_imageIds.append(image->id());
1326 
1327  // If we lose any images, destroy the entire list. This will let us know that we need to
1328  // rebuild it, if needed, when requested.
1329  connect(image, SIGNAL(destroyed(QObject *)),
1330  this, SLOT(clearImageList()));
1331  }
1332  }
1333  }
1334 
1335 
1345  m_shapeIds.clear();
1346  foreach (Shape *shape, *m_shapeList) {
1347  if (shape) {
1348  m_shapeIds.append(shape->id());
1349 
1350  // If we lose any shapes, destroy the entire list. This will let us know that we need to
1351  // rebuild it, if needed, when requested.
1352  connect(shape, SIGNAL(destroyed(QObject *)),
1353  this, SLOT(clearShapeList()));
1354  }
1355  }
1356  }
1357 
1358 
1364 
1365  if (!m_progressBar) {
1366  m_progressBar = new ProgressBar;
1367  emit creatingProgress(this);
1368  }
1369 
1370  if (!m_progressBarUpdateTimer) {
1371  m_progressBarUpdateTimer = new QTimer;
1372  connect(m_progressBarUpdateTimer, SIGNAL(timeout()),
1373  this, SLOT(updateProgress()));
1374  m_progressBarUpdateTimer->start(100);
1375  }
1376 
1379  m_progressValue = 0;
1380  }
1381 
1382 
1387  if (m_progressBar) {
1388  if (isRedone()) {
1389  m_progressBar->setText(tr("Finished"));
1390  }
1391  else if (isUndone() || m_status == WorkOrderNotStarted) {
1392  m_progressBar->setText(tr("Undone"));
1393  }
1394 
1395  if (m_progressBar->minimum() != 0 || m_progressBar->maximum() != 0) {
1396  m_progressBar->setValue(m_progressBar->maximum());
1397  }
1398  else {
1399  m_progressBar->setRange(0, 100);
1400  m_progressBar->setValue(100);
1401  }
1402 
1404  m_progressBarDeletionTimer = new QTimer;
1405  m_progressBarDeletionTimer->setSingleShot(true);
1406  connect(m_progressBarDeletionTimer, SIGNAL(timeout()),
1407  this, SLOT(deleteProgress()));
1408 
1409  m_progressBarDeletionTimer->start(5 * 1000); // 5 seconds
1410 
1411  m_progressBar->update();
1412  }
1413  }
1414 
1415 
1420  QueuedWorkOrderAction queued = m_queuedAction;
1421  m_queuedAction = NoQueuedAction;
1422 
1423  if (queued == RedoQueuedAction && m_status != WorkOrderRedone) {
1424  redo();
1425  }
1426  else if (queued == UndoQueuedAction && m_status != WorkOrderUndone) {
1427  undo();
1428  }
1429  }
1430 
1431 
1437  delete m_progressBarUpdateTimer;
1438 
1439  WorkOrderStatus finishedStatus = WorkOrderRedone;
1440  void (WorkOrder::*postSyncMethod)() = &WorkOrder::postSyncRedo;
1441 
1442  if (isUndoing()) {
1443  finishedStatus = WorkOrderUndone;
1444  postSyncMethod = &WorkOrder::postSyncUndo;
1445  }
1446 
1447  (this->*postSyncMethod)();
1448 
1449  m_status = finishedStatus;
1450 
1451  m_secondsElapsed = m_elapsedTimer->elapsed() / 1000.0;
1452 
1453  delete m_elapsedTimer;
1454  m_elapsedTimer = NULL;
1455 
1456  emit statusChanged(this);
1458  emit finished(this);
1459 
1461  }
1462 
1463 
1468  delete m_imageList;
1469  }
1470 
1471 
1476  delete m_shapeList;
1477  }
1478 
1479 
1484  ProgressBar *progress = m_progressBar;
1485 
1486  if (m_progressBar) {
1487  m_progressBar = NULL;
1488  emit deletingProgress(this);
1489  delete progress;
1490  }
1491  }
1492 
1493 
1498  if (m_progressBar && (isRedoing() || isUndoing())) {
1500  m_progressBar->setValue(m_progressValue);
1501  }
1502  }
1503 
1504 
1509  }
1510 
1511 
1520  void WorkOrder::setCreatesCleanState(bool createsCleanState) {
1522  }
1523 
1524 
1531  void WorkOrder::setModifiesDiskState(bool changesProjectOnDisk) {
1532  m_modifiesDiskState = changesProjectOnDisk;
1533  }
1534 
1535 
1541  m_workOrder = workOrder;
1542  }
1543 
1544 
1559  bool WorkOrder::XmlHandler::startElement(const QString &namespaceURI, const QString &localName,
1560  const QString &qName, const QXmlAttributes &atts) {
1561  if (XmlStackedHandler::startElement(namespaceURI, localName, qName, atts)) {
1562  if (localName == "workOrder") {
1563  QString actionText = atts.value("actionText");
1564  QString undoText = atts.value("undoText");
1565  QString executionTime = atts.value("executionTime");
1566  QString statusStr = atts.value("status");
1567 
1568  if (!actionText.isEmpty()) {
1569  ((QAction *)m_workOrder)->setText(actionText);
1570  }
1571 
1572  if (!undoText.isEmpty()) {
1573  ((QUndoCommand *)m_workOrder)->setText(undoText);
1574  }
1575 
1576  if (!executionTime.isEmpty()) {
1577  m_workOrder->m_executionTime = QDateTime::fromString(executionTime);
1578  }
1579 
1580  if (!statusStr.isEmpty()) {
1581  m_workOrder->m_status = fromStatusString(statusStr);
1582  }
1583  else {
1584  if (m_workOrder->createsCleanState()) {
1585  m_workOrder->m_status = WorkOrderFinished;
1586  }
1587  else {
1588  m_workOrder->m_status = WorkOrderRedone;
1589  }
1590  }
1591  }
1592  else if (localName == "dataValue") {
1593  m_workOrder->m_internalData.append(atts.value("value"));
1594  }
1595  else if (localName == "context") {
1596  if (atts.value("value") == "ProjectContext") {
1597  m_workOrder->m_context = ProjectContext;
1598  }
1599  }
1600  }
1601 
1602  return true;
1603  }
1604 }
Internalizes a list of shapes and allows for operations on the entire list.
Definition: ShapeList.h:33
void setProgressValue(int)
Sets the current progress value for the WorkOrder.
Definition: WorkOrder.cpp:1177
Internalizes a list of images and allows for operations on the entire list.
Definition: ImageList.h:44
bool m_modifiesDiskState
This is defaulted to false.
Definition: WorkOrder.h:332
The main project for cnetsuite.
Definition: Project.h:105
QString id() const
Get a unique, identifying string associated with this image.
Definition: Image.cpp:394
void deleteProgress()
Deletes the progress bar.
Definition: WorkOrder.cpp:1483
XmlHandler(WorkOrder *workOrder)
Passes a pointer to a WorkOrder to the WorkOrder::XmlHandler class.
Definition: WorkOrder.cpp:1540
This is a container for the correlation matrix that comes from a bundle adjust.
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.
void attemptQueuedAction()
Attempts to execute an action on the action action queue.
Definition: WorkOrder.cpp:1419
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:1559
void updateProgress()
Updates the progress bar.
Definition: WorkOrder.cpp:1497
virtual void syncUndo()
This method is designed to be implemented by children work orders.
Definition: WorkOrder.cpp:1254
QPointer< QTimer > m_progressBarUpdateTimer
A pointer to the QTimer which updates the ProgressBar.
Definition: WorkOrder.h:429
Maintains a list of Controls so that control nets can easily be copied from one Project to another...
Definition: ControlList.h:34
bool isControl() const
Returns true if a Control is stored in the data of the item.
Project * project() const
Returns the Project this WorkOrder is attached to.
Definition: WorkOrder.cpp:1116
void read(XmlStackedHandlerReader *xmlReader)
Read this work order&#39;s data from disk.
Definition: WorkOrder.cpp:454
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 createsCleanState() const
Returns the CleanState status (whether the Project has been saved to disk or not).
Definition: WorkOrder.cpp:721
WorkOrder * previous() const
Gets the previous WorkOrder.
Definition: WorkOrder.cpp:803
bool isImage() const
Returns true if an Image 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.
int m_progressRangeMinValue
The miniumum value of the Progess Bar.
Definition: WorkOrder.h:340
int progressMin() const
Gets the minimum value of the progress range of the WorkOrder.
Definition: WorkOrder.cpp:1139
QPointer< WorkOrder > m_previousWorkOrder
A pointer to the previous WorkOrder in the queue.
Definition: WorkOrder.h:394
QStringList internalData() const
Gets the internal data for this WorkOrder.
Definition: WorkOrder.cpp:1186
This error is for when a programmer made an API call that was illegal.
Definition: IException.h:154
void asyncFinished()
Signals the Project that the WorkOrder is finished, deletes the update time for the Progress bar...
Definition: WorkOrder.cpp:1436
int progressMax() const
Gets the maximum value of the progress range of the WorkOrder.
Definition: WorkOrder.cpp:1148
bool isRedone() const
Returns the WorkOrder redone status.
Definition: WorkOrder.cpp:757
TargetBodyQsp targetBody()
WorkOrder::targetBody.
Definition: WorkOrder.cpp:666
bool isTargetBody() const
Returns true if a TargetBodyQsp is stored in the data of the item.
ShapeList * shapeList()
a pointer to the ShapeList for this WorkOrder.
Definition: WorkOrder.cpp:596
virtual void redo()
Starts (or enqueues) a redo.
Definition: WorkOrder.cpp:900
QPointer< ProgressBar > m_progressBar
A pointer to the ProgressBar.
Definition: WorkOrder.h:424
virtual bool isExecutable(Context)
Re-implement this method if your work order utilizes controls for data in order to operate...
Definition: WorkOrder.cpp:179
QTime * m_elapsedTimer
A QTime object holding the excecution time of the WorkOrder.
Definition: WorkOrder.h:440
QDateTime m_executionTime
This is the date/time that execute() was called.
Definition: WorkOrder.h:410
virtual void postSyncRedo()
This method is designed to be implemented by children work orders.
Definition: WorkOrder.cpp:1238
WorkOrder(Project *project)
Create a work order that will work with the given project.
Definition: WorkOrder.cpp:55
virtual void undo()
Starts (or enqueues) an undo.
Definition: WorkOrder.cpp:994
void listenForShapeDestruction()
Checks to see if we have lost any shapes in the ShapeList.
Definition: WorkOrder.cpp:1344
static QString toString(WorkOrderStatus)
Gets the current status of the WorkOrder.
Definition: WorkOrder.cpp:865
QPointer< QTimer > m_progressBarDeletionTimer
A pointer to the ProgressBar deletion timer.
Definition: WorkOrder.h:434
void addToProject(WorkOrder *)
Run the work order and stores it in the project.
Definition: Project.cpp:1546
Image * image() const
Returns the Image stored in the data of the item.
Parent class for anything that performs an action in Project.
Definition: WorkOrder.h:104
ControlList * controlList() const
Returns the ControlList stored in the data of the item.
int m_progressValue
The current value of the Progress Bar.
Definition: WorkOrder.h:348
int progressValue() const
Gets the current progress value of the WorkOrder.
Definition: WorkOrder.cpp:1157
QSharedPointer< TargetBody > TargetBodyQsp
Defines A smart pointer to a TargetBody obj.
Definition: TargetBody.h:224
bool isCorrelationMatrix() const
Returns true if a CorrelationMatrix is stored in the data of the item.
virtual void postSyncUndo()
This method is designed to be implemented by children work orders.
Definition: WorkOrder.cpp:1287
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:38
bool isFinished() const
Returns the finished state of this WorkOrder.
Definition: WorkOrder.cpp:739
void append(Shape *const &value)
Appends an shape to the shape list.
Definition: ShapeList.cpp:147
WorkOrderStatus
This enumeration is used by other functions to set and retrieve the current state of the WorkOrder...
Definition: WorkOrder.h:114
GuiCameraQsp guiCamera() const
Returns the GuiCameraQsp stored in the data of the item.
Control * control() const
Returns the Control stored in the data of the item.
QStringList m_internalData
A QStringList of internal properties for this WorkOrder.
Definition: WorkOrder.h:384
bool isGuiCamera() const
Returns true if a GuiCameraQsp is stored in the data of the item.
A type of error that cannot be classified as any of the other error types.
Definition: IException.h:126
virtual void asyncUndo()
This method is designed to be implemented by children work orders.
Definition: WorkOrder.cpp:1271
void setPrevious(WorkOrder *previousWorkOrder)
Sets the previous WorkOrder in the sequence.
Definition: WorkOrder.cpp:556
QPointer< WorkOrder > m_nextWorkOrder
A pointer to the next WorkOrder in the queue.
Definition: WorkOrder.h:389
This represents a cube in a project-based GUI interface.
Definition: Image.h:91
QString id() const
Get a unique, identifying string associated with this shape.
Definition: Shape.cpp:417
bool m_createsCleanState
This is defaulted to false.
Definition: WorkOrder.h:325
Directory * directory() const
Returns the directory associated with this Project.
Definition: Project.cpp:824
virtual void setData(Context)
Sets the context data for this WorkOrder.
Definition: WorkOrder.cpp:245
void clearShapeList()
Clears the list of shapes.
Definition: WorkOrder.cpp:1475
void append(Image *const &value)
Appends an image to the image list.
Definition: ImageList.cpp:150
int m_progressRangeMaxValue
The maximum value of the Progess Bar.
Definition: WorkOrder.h:344
void resetProgressBar()
Resets the ProgressBar.
Definition: WorkOrder.cpp:1362
void setProgressRange(int, int)
Sets the progress range of the WorkOrder.
Definition: WorkOrder.cpp:1167
bool modifiesDiskState() const
Returns the modified disk state.
Definition: WorkOrder.cpp:785
virtual ~WorkOrder()
The Destructor.
Definition: WorkOrder.cpp:97
bool isShapeList() const
Returns true if an ShapeList is stored in the data of the item.
TargetBodyQsp m_targetBody
A QSharedPointer to the TargetBody (A Target object but encapsulated within a Gui framework...
Definition: WorkOrder.h:366
void append(Control *const &value)
Appends a control pointer to the control list.
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:445
void setModifiesDiskState(bool changesProjectOnDisk)
.
Definition: WorkOrder.cpp:1531
bool isInStableState() const
Determines if the WorkOrder is in a stable state, or if it&#39;s busy doing something.
Definition: WorkOrder.cpp:1305
QString statusText() const
WorkOrder::statusText.
Definition: WorkOrder.cpp:812
QPointer< QFutureWatcher< void > > m_futureWatcher
A pointer to a QFutureWatcher object which monitors a QFuture object using signals and slots...
Definition: WorkOrder.h:417
QSharedPointer< GuiCamera > GuiCameraQsp
GuiCameraQsp Represents a smart pointer to a GuiCamera object.
Definition: GuiCamera.h:188
QueuedWorkOrderAction
This enum describes the current state of a Queued WorkOrder.
Definition: WorkOrder.h:285
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:405
$Date$ $Revision$
This represents a shape in a project-based GUI interface.
Definition: Shape.h:70
bool isUndone() const
Returns the WorkOrder undo status.
Definition: WorkOrder.cpp:775
ShapeList * shapeList() const
Returns the ShapeList stored in the data of the item.
void listenForImageDestruction()
Checks to see if we have lost any images in the ImageList.
Definition: WorkOrder.cpp:1321
bool isRedoing() const
Returns the redoing status of this WorkOrder.
Definition: WorkOrder.cpp:748
void setProgressToFinalText()
Sets the ProgressBar to display the final status of the operation.
Definition: WorkOrder.cpp:1386
bool isControlList() const
Returns true if a ControlList is stored in the data of the item.
QString bestText() const
We don&#39;t use action text anymore because Directory likes to rename our actions.
Definition: WorkOrder.cpp:701
WorkOrder * next() const
Gets the next WorkOrder.
Definition: WorkOrder.cpp:794
Context
This enumeration is for recording the context of the current Workorder (whether it is part of a proje...
Definition: WorkOrder.h:132
static WorkOrderStatus fromStatusString(QString)
Attempts to query the current status of the WorkOrder.
Definition: WorkOrder.cpp:844
Represents an item of a ProjectItemModel in Qt&#39;s model-view framework.
Definition: ProjectItem.h:113
Directory * directory() const
Returns the Directory object of the Project this WorkOrder is attached to.
Definition: WorkOrder.cpp:1106
QDateTime executionTime() const
Gets the execution time of this WorkOrder.
Definition: WorkOrder.cpp:730
Isis exception class.
Definition: IException.h:99
bool isUndoing() const
Returns the WorkOrderUndoing state.
Definition: WorkOrder.cpp:766
CorrelationMatrix correlationMatrix()
Returns the CorrleationMatrix for this WorkOrder.
Definition: WorkOrder.cpp:628
void setNext(WorkOrder *nextWorkOrder)
Sets the next WorkOrder in the sequence.
Definition: WorkOrder.cpp:547
This is used for work orders that will not undo or redo (See createsCleanState()) ...
Definition: WorkOrder.h:124
QProgressBar with customizable text.
Definition: ProgressBar.h:15
This class is used for processing an XML file containing information about a WorkOrder.
Definition: WorkOrder.h:299
void save(QXmlStreamWriter &stream) const
: Saves a WorkOrder to a data stream.
Definition: WorkOrder.cpp:478
GuiCameraQsp m_guiCamera
A QSharedPointer to the GuiCamera (the Camera object but encapsulated within a Gui framework...
Definition: WorkOrder.h:359
GuiCameraQsp guiCamera()
WorkOrder::guiCamera.
Definition: WorkOrder.cpp:675
virtual bool execute()
The (child) implementation of this method should prompt the user/gather state by any means necessary...
Definition: WorkOrder.cpp:1078
QPointer< ControlList > controlList()
Returns the Control List for this WorkOrder (a list of control networks).
Definition: WorkOrder.cpp:637
ProgressBar * progressBar()
Returns the ProgressBar.
Definition: WorkOrder.cpp:832
ImageList * imageList()
a pointer to the ImageList for this WorkOrder.
Definition: WorkOrder.cpp:565
virtual void asyncRedo()
This method is designed to be implemented by children work orders.
Definition: WorkOrder.cpp:1222
his enables stack-based XML parsing of XML files.
void addCloneToProject()
Runs a copy of the current WorkOrder and stores it in the project.
Definition: WorkOrder.cpp:1294
QStringList m_shapeIds
A QStringList of unique shape identifiers for all of the shapes this WorkOrder is dealing with...
Definition: WorkOrder.h:379
void clearImageList()
Clears the list of images.
Definition: WorkOrder.cpp:1467
void setInternalData(QStringList data)
Sets the internal data for this WorkOrder.
Definition: WorkOrder.cpp:1130
void startRedo()
WorkOrder::startRedo This function is currently empty.
Definition: WorkOrder.cpp:1508
void setCreatesCleanState(bool createsCleanState)
Declare that this work order is saving the project.
Definition: WorkOrder.cpp:1520
QPointer< Project > m_project
A pointer to the Project this WorkOrder is attached to.
Definition: WorkOrder.h:399
QStringList m_imageIds
A QStringList of unique image identifiers for all of the images this WorkOrder is dealing with...
Definition: WorkOrder.h:373
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:313
virtual bool dependsOn(WorkOrder *other) const
This is a virtual function whose role in child classes is to determine if this WorkOrder deppends on ...
Definition: WorkOrder.cpp:688
bool isProject() const
Returns true if a Project is stored in the data of the item.
virtual void syncRedo()
This method is designed to be implemented by children work orders.
Definition: WorkOrder.cpp:1203

U.S. Department of the Interior | U.S. Geological Survey
ISIS | Privacy & Disclaimers | Astrogeology Research Program
To contact us, please post comments and questions on the ISIS Support Center
File Modified: 07/12/2023 23:31:46