Isis 3 Programmer Reference
Footprint2DViewWorkOrder.cpp
Go to the documentation of this file.
1 
22 
23 #include <QtDebug>
24 
25 #include <QFileDialog>
26 #include <QInputDialog>
27 #include <QMessageBox>
28 
29 #include "Directory.h"
30 #include "Footprint2DView.h"
31 #include "ImageList.h"
32 #include "MosaicSceneItem.h"
33 #include "MosaicSceneWidget.h"
34 #include "Project.h"
35 #include "ProjectItem.h"
36 #include "ProjectItemModel.h"
37 
38 namespace Isis {
39 
47  WorkOrder(project) {
48  QAction::setText(tr("View &Footprints..."));
49  m_isUndoable = false;
50  m_isSavedToHistory = false;
51  }
52 
53 
62  WorkOrder(other) {
63  m_isUndoable = other.m_isUndoable;
64  }
65 
66 
73  }
74 
75 
82 
83  return new Footprint2DViewWorkOrder(*this);
84  }
85 
86 
98  bool result = false;
99 
100  foreach (Image *image, *images) {
101  result = result || image->isFootprintable();
102  }
103 
104  return result;
105  }
106 
107 
119  bool result = false;
120 
121  if (shapes) {
122  foreach (Shape *shape, *shapes) {
123  result = result || shape->isFootprintable();
124  }
125  return result;
126  }
127  return result;
128  }
129 
130 
140  bool success = WorkOrder::setupExecution();
141 
142  int maxRecommendedFootprints = 50000;
143  if (success && imageList()->count() > maxRecommendedFootprints) {
144  QMessageBox::StandardButton selectedOpt = QMessageBox::warning(NULL,
145  tr("Potentially Slow Operation"),
146  tr("You are asking to open %L1 images in a 2D footprint view at once. This is possible, "
147  "but will take a significant amount of time and cause overall slowness. Working with "
148  "more than %L2 footprints is not recommended. Are you sure you want to view these "
149  "%L1 footprints?").arg(imageList()->count()).arg(maxRecommendedFootprints),
150  QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
151 
152  if (selectedOpt == QMessageBox::No) {
153  success = false;
154  }
155  }
156 
157  int viewToUse = -1;
158  if (success) {
159  QStringList viewOptions;
160 
162  if (existingViews.count()) {
163  for (int i = 0; i < existingViews.count(); i++) {
164  viewOptions.append(existingViews[i]->windowTitle());
165  }
166  }
167 
168  viewOptions.append(tr("New Footprint View"));
169 
170  if (viewOptions.count() > 1) {
171  QString selected = QInputDialog::getItem(NULL, tr("View to see footprints in"),
172  tr("Which view would you like your\nimage's footprints to be put into?"),
173  viewOptions, viewOptions.count() - 1, false, &success);
174 
175  viewToUse = viewOptions.indexOf(selected);
176  }
177  else {
178  viewToUse = viewOptions.count() - 1;
179  }
180 
181  if (viewToUse == viewOptions.count() - 1) {
182  QUndoCommand::setText(tr("View footprints in new 2D footprint view"));
183  }
184  else if (viewToUse != -1) {
185  QUndoCommand::setText(tr("View footprints in footprint view [%1]")
186  .arg(existingViews[viewToUse]->windowTitle()));
187  }
188 
190  internalData.append(QString::number(viewToUse));
192  }
193  return success;
194  }
195 
196 
203 
204  QList<ProjectItem *> selectedItems = project()->directory()->model()->selectedItems();
205 
206  int viewToUse = internalData().first().toInt();
207 
208  Footprint2DView *view = NULL;
209  if (viewToUse == project()->directory()->footprint2DViews().count()) {
210  view = project()->directory()->addFootprint2DView();
211  }
212  else {
213  view = project()->directory()->footprint2DViews()[viewToUse];
214  }
215 
216  view->addItems( selectedItems );
217  project()->setClean(false);
218  }
219 }
virtual Footprint2DViewWorkOrder * clone() const
This method clones the current Footprint2DViewWorkOrder and returns it.
Internalizes a list of shapes and allows for operations on the entire list.
Definition: ShapeList.h:33
$Date$ $Revision$
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
virtual void addItems(QList< ProjectItem *> items)
Adds several items to the view.
virtual bool isExecutable(ImageList *images)
This method returns true if one of an image in ImageList images isFootprintable, False if none of the...
View for displaying footprints of images in a QMos like way.
virtual bool setupExecution()
This sets up the state for the work order.
Definition: WorkOrder.cpp:1275
$Date$ $Revision$
View an image list&#39;s footprints in a footprint view.
virtual bool setupExecution()
Setup this WorkOrder for execution.
QList< Footprint2DView * > footprint2DViews()
Accessor for the list of Footprint2DViews currently available.
Definition: Directory.cpp:1424
Directory * directory() const
Returns the directory associated with this Project.
Definition: Project.cpp:1229
ProjectItemModel * model()
Gets the ProjectItemModel for this directory.
Definition: Directory.cpp:1105
Provide Undo/redo abilities, serialization, and history for an operation.
Definition: WorkOrder.h:322
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
Footprint2DView * addFootprint2DView(QString objectName="")
Add the qmos view widget to the window.
Definition: Directory.cpp:771
This represents a cube in a project-based GUI interface.
Definition: Image.h:107
bool m_isUndoable
Set the workorder to be undoable/redoable This is defaulted to true - his will allow the workorder to...
Definition: WorkOrder.h:534
bool isFootprintable() const
Test to see if it&#39;s possible to create a footprint from this image.
Definition: Image.cpp:253
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
This represents a shape in a project-based GUI interface.
Definition: Shape.h:78
QList< ProjectItem * > selectedItems()
Returns a list of the selected items of the internal selection model.
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
virtual void execute()
This either adds a new Footprint2DView containing the selected images or adds the image&#39;s footprints ...
Project * project() const
Returns the Project this WorkOrder is attached to.
Definition: WorkOrder.cpp:1314
ImageList * imageList()
Returns a pointer to the ImageList for this WorkOrder.
Definition: WorkOrder.cpp:645
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
void setInternalData(QStringList data)
Sets the internal data for this WorkOrder.
Definition: WorkOrder.cpp:1332
bool isFootprintable() const
Test to see if it&#39;s possible to create a footprint from this shape.
Definition: Shape.cpp:294
Directory * directory() const
return the workorder project directory Returns the Directory object of the Project this WorkOrder is ...
Definition: WorkOrder.cpp:1304
void setClean(bool value)
Function to change the clean state of the project.
Definition: Project.cpp:1595
Footprint2DViewWorkOrder(Project *project)
Creates a work order to view image footprints.