Isis 3 Programmer Reference
MatrixViewWorkOrder.cpp
Go to the documentation of this file.
1 
21 #include "MatrixViewWorkOrder.h"
22 
23 #include <QDebug>
24 #include <QFileDialog>
25 #include <QInputDialog>
26 #include <QMessageBox>
27 
28 #include "CorrelationMatrix.h"
29 #include "Directory.h"
30 #include "IException.h"
31 #include "MatrixSceneWidget.h"
32 #include "Project.h"
33 
34 namespace Isis {
35 
43  WorkOrder(project) {
44  QAction::setText( tr("View Correlation &Matrix...") );
45  m_isSavedToHistory = false;
46  }
47 
54  WorkOrder(other) {
55  qDebug() << "matrix good?";
56  }
57 
62  }
63 
70  return new MatrixViewWorkOrder(*this);
71  }
72 
73 
83  return matrix.isValid();
84  }
85 
86 
93  bool success = WorkOrder::setupExecution();
94 
95  if (success) {
96  QStringList viewOptions;
97 
99  int viewToUse = -1;
100 
101  if ( existingViews.count() ) {
102  for (int i = 0; i < existingViews.count(); i++) {
103  viewOptions.append( existingViews[i]->windowTitle() );
104  }
105  }
106 
107  viewOptions.append( tr("New Matrix View") );
108 
109  if (viewOptions.count() > 1) {
110  QString selected = QInputDialog::getItem(NULL, tr("View to see matrix in"),
111  tr("Which view would you like your\nmatrix to be put into?"),
112  viewOptions, viewOptions.count() - 1, false, &success);
113 
114  viewToUse = viewOptions.indexOf(selected);
115  }
116  else {
117  viewToUse = viewOptions.count() - 1;
118  }
119 
120  bool newView = false;
121  if (viewToUse == viewOptions.count() - 1) {
122  newView = true;
123 
124  QUndoCommand::setText( tr("View matrix in new matrix view") );
125 
126  }
127  else if (viewToUse != -1) {
128  MatrixSceneWidget *matrixView = existingViews[viewToUse];
129 
130  // Do we need this? If the view already exists has this already been done?
132  corrMat.computeCorrelationMatrix();
133  matrixView->setUpOptions(corrMat);
134  matrixView->drawElements(corrMat);
135  matrixView->drawGrid(corrMat);
136  }
137 
139  internalData.append( QString::number(viewToUse) );
140  internalData.append(newView? "new view" : "existing view");
142  }
143 
144  return success;
145  }
146 
147 
157  // depend on types of ourselves.
158  return dynamic_cast<MatrixViewWorkOrder *>(other);
159  }
160 
161 
166  try {
167  MatrixSceneWidget *matrixViewToUse = project()->directory()->addMatrixView();
169  /*
170  * Since computing the correlation matrix is potentially time consuming we only want to
171  * do it if the user wants to see it.
172  */
173  corrMat.computeCorrelationMatrix();
174  matrixViewToUse->setUpOptions(corrMat);
175  matrixViewToUse->drawElements(corrMat);
176  matrixViewToUse->drawGrid(corrMat);
177  if (matrixViewToUse == NULL) {
178  QString msg = "The Correlation Matrix for this bundle could not be displayed";
180  }
181  project()->setClean(false);
182  }
183  catch (IException &e) {
184  m_status = WorkOrderFinished;
185  QMessageBox::critical(NULL, tr("Error"), tr(e.what()));
186  }
187  }
188 
189 
194  if (internalData()[1] == "new view") {
195  delete project()->directory()->matrixViews().last();
196  }
197  }
198 }
QList< MatrixSceneWidget * > matrixViews()
Accessor for the list of MatrixSceneWidgets currently available.
Definition: Directory.cpp:1364
const char * what() const
Returns a string representation of this exception in its current state.
Definition: IException.cpp:391
void drawElements(CorrelationMatrix corrMatrix)
Refit scene and items when the widget size changes.
The main project for ipce.
Definition: Project.h:289
This is a container for the correlation matrix that comes from a bundle adjust.
void undoExecution()
This method deletes the last matrix viewed.
virtual bool isExecutable(CorrelationMatrix matrix)
This check is used by Directory::supportedActions(DataType data).
virtual bool setupExecution()
This sets up the state for the work order.
Definition: WorkOrder.cpp:1275
MatrixSceneWidget * addMatrixView()
Add the matrix view widget to the window.
Definition: Directory.cpp:938
void computeCorrelationMatrix()
Read covariance matrix and compute correlation values This method reads the covariance matrix in from...
void execute()
This method computes and displays the correlation matrix.
This widget encompasses the entire matrixDisplay scene.
This error is for when a programmer made an API call that was illegal.
Definition: IException.h:162
This work order will open a MatrixSceneWidget and display the correlation matrix. ...
void drawGrid(CorrelationMatrix corrMatrix)
Draw the lines that will show the columns and blocks for each image.
Directory * directory() const
Returns the directory associated with this Project.
Definition: Project.cpp:1229
Provide Undo/redo abilities, serialization, and history for an operation.
Definition: WorkOrder.h:322
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:40
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
void setUpOptions(CorrelationMatrix corrMat)
Change item colors when options are changed.
virtual MatrixViewWorkOrder * clone() const
This method clones the MatrixViewWorkOrder.
bool setupExecution()
If WorkOrder::execute() returns true, a new matrix view is created.
bool isValid()
This is the public accessor for the list of elements that should be displayed in the current view...
Isis exception class.
Definition: IException.h:107
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
CorrelationMatrix correlationMatrix()
Returns the CorrleationMatrix for this WorkOrder.
Definition: WorkOrder.cpp:710
This is used for work orders that will not undo or redo (See createsCleanState()) ...
Definition: WorkOrder.h:342
Project * project() const
Returns the Project this WorkOrder is attached to.
Definition: WorkOrder.cpp:1314
MatrixViewWorkOrder(Project *project)
This method sets the text of the work order.
bool m_isSavedToHistory
Set the work order to be shown in the HistoryTreeWidget.
Definition: WorkOrder.h:548
QStringList internalData() const
Gets the internal data for this WorkOrder.
Definition: WorkOrder.cpp:1391
bool dependsOn(WorkOrder *other) const
This method returns true if other depends on a MatrixViewWorkOrder.
void setInternalData(QStringList data)
Sets the internal data for this WorkOrder.
Definition: WorkOrder.cpp:1332
void setClean(bool value)
Function to change the clean state of the project.
Definition: Project.cpp:1595