Isis 3.0 Programmer Reference
Back | Home
Footprint2DViewWorkOrder.cpp
Go to the documentation of this file.
1 
24 
25 #include <QtDebug>
26 
27 #include <QFileDialog>
28 #include <QInputDialog>
29 #include <QMessageBox>
30 
31 #include "Directory.h"
32 #include "Footprint2DView.h"
33 #include "ImageList.h"
34 #include "MosaicSceneItem.h"
35 #include "MosaicSceneWidget.h"
36 #include "Project.h"
37 #include "ProjectItem.h"
38 #include "ProjectItemModel.h"
39 
40 namespace Isis {
41 
48  WorkOrder(project) {
49  QAction::setText(tr("View &Footprints..."));
50  QUndoCommand::setText(tr("View &Footprints..."));
51  }
52 
57  WorkOrder(other) {
58  }
59 
64  }
65 
72 
73  return new Footprint2DViewWorkOrder(*this);
74  }
75 
84  bool result = false;
85 
86  foreach (Image *image, *images) {
87  result = result || image->isFootprintable();
88  }
89 
90  return result;
91  }
92 
93 
102  bool result = false;
103 
104  foreach (Shape *shape, *shapes) {
105  result = result || shape->isFootprintable();
106  }
107 
108  return result;
109  }
110 
111 
118  bool success = WorkOrder::execute();
119 
120  int maxRecommendedFootprints = 50000;
121  if (success && imageList()->count() > maxRecommendedFootprints) {
122  QMessageBox::StandardButton selectedOpt = QMessageBox::warning(NULL,
123  tr("Potentially Slow Operation"),
124  tr("You are asking to open %L1 images in a 2D footprint view at once. This is possible, "
125  "but will take a significant amount of time and cause overall slowness. Working with "
126  "more than %L2 footprints is not recommended. Are you sure you want to view these "
127  "%L1 footprints?").arg(imageList()->count()).arg(maxRecommendedFootprints),
128  QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
129 
130  if (selectedOpt == QMessageBox::No) {
131  success = false;
132  }
133  }
134 
135  if (success) {
136  QStringList viewOptions;
137 
139  int viewToUse = -1;
140 
141  if (existingViews.count()) {
142  for (int i = 0; i < existingViews.count(); i++) {
143  viewOptions.append(existingViews[i]->windowTitle());
144  }
145  }
146 
147  viewOptions.append(tr("New Footprint View"));
148 
149  if (viewOptions.count() > 1) {
150  QString selected = QInputDialog::getItem(NULL, tr("View to see footprints in"),
151  tr("Which view would you like your\nimage's footprints to be put into?"),
152  viewOptions, viewOptions.count() - 1, false, &success);
153 
154  viewToUse = viewOptions.indexOf(selected);
155  }
156  else {
157  viewToUse = viewOptions.count() - 1;
158  }
159 
160  bool newView = false;
161  if (viewToUse == viewOptions.count() - 1) {
162  newView = true;
163  QUndoCommand::setText(tr("View footprints in new 2D footprint view"));
164  }
165  else if (viewToUse != -1) {
166  QUndoCommand::setText(tr("View footprints in footprint view [%1]")
167  .arg(existingViews[viewToUse]->windowTitle()));
168  }
169 
171  internalData.append(QString::number(viewToUse));
172  internalData.append(newView? "new view" : "existing view");
173  setInternalData(internalData);
174  }
175 
176  return success;
177  }
178 
187  // depend on types of ourselves.
188  return dynamic_cast<Footprint2DViewWorkOrder *>(other);
189  }
190 
196  QList<ProjectItem *> selectedItems = project()->directory()->model()->selectedItems();
197 
198  int viewToUse = internalData().first().toInt();
199 
200  Footprint2DView *view = NULL;
201  if (viewToUse == project()->directory()->footprint2DViews().count()) {
202  view = project()->directory()->addFootprint2DView();
203  }
204  else {
205  view = project()->directory()->footprint2DViews()[viewToUse];
206  }
207 
208  view->addItems( selectedItems );
209 
210  // qDebug()<<"Footprint2DViewWorkOrder::syncRedo source model: "<<project()->directory()->model()<<" rows = "<<project()->directory()->model()->rowCount();
211 // qDebug()<<"Footprint2DViewWorkOrder::syncRedo proxy model: "<<view->internalModel()<<" rows = "<<view->internalModel()->rowCount();
212  }
213 
215  delete project()->directory()->footprint2DViews().last();
216  }
217 }
218 
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:44
The main project for cnetsuite.
Definition: Project.h:105
virtual bool isExecutable(ImageList *images)
This method returns true if one of an image in ImageList images isFootprintable.
virtual void addItems(QList< ProjectItem * > items)
Adds several items to the view.
View for displaying footprints of images in a QMos like way.
bool isFootprintable() const
Test to see if it&#39;s possible to create a footprint from this image.
Definition: Image.cpp:221
Project * project() const
Returns the Project this WorkOrder is attached to.
Definition: WorkOrder.cpp:1116
void syncUndo()
This method is designed to be implemented by children work orders.
$Date$ $Revision$
void syncRedo()
This methods adds the current item to Footprint2DView.
QStringList internalData() const
Gets the internal data for this WorkOrder.
Definition: WorkOrder.cpp:1186
bool execute()
This method calls WorkOrder&#39;s execute.
View an image list&#39;s footprints in a footprint view.
QList< Footprint2DView * > footprint2DViews()
Accessor for the list of Footprint2DViews currently available.
Definition: Directory.cpp:1007
ProjectItemModel * model()
Gets the ProjectItemModel for this directory.
Definition: Directory.cpp:828
Parent class for anything that performs an action in Project.
Definition: WorkOrder.h:104
bool dependsOn(WorkOrder *other) const
This method returns whether or not other depends on a Footprint2DViewWorkOrder.
virtual Footprint2DViewWorkOrder * clone() const
This method clones the current Footprint2DViewWorkOrder and returns it.
This represents a cube in a project-based GUI interface.
Definition: Image.h:91
Directory * directory() const
Returns the directory associated with this Project.
Definition: Project.cpp:824
bool isFootprintable() const
Test to see if it&#39;s possible to create a footprint from this shape.
Definition: Shape.cpp:251
$Date$ $Revision$
This represents a shape in a project-based GUI interface.
Definition: Shape.h:70
QList< ProjectItem * > selectedItems()
Returns a list of the selected items of the internal selection model.
Footprint2DView * addFootprint2DView()
Add the qmos view widget to the window.
Definition: Directory.cpp:599
Directory * directory() const
Returns the Directory object of the Project this WorkOrder is attached to.
Definition: WorkOrder.cpp:1106
virtual bool execute()
The (child) implementation of this method should prompt the user/gather state by any means necessary...
Definition: WorkOrder.cpp:1078
ImageList * imageList()
a pointer to the ImageList for this WorkOrder.
Definition: WorkOrder.cpp:565
void setInternalData(QStringList data)
Sets the internal data for this WorkOrder.
Definition: WorkOrder.cpp:1130
Footprint2DViewWorkOrder(Project *project)
Constructor.

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:18:21