Isis 3 Programmer Reference
CubeDnViewWorkOrder.cpp
Go to the documentation of this file.
1 
21 #include "CubeDnViewWorkOrder.h"
22 
23 #include <QtDebug>
24 
25 #include <QFileDialog>
26 #include <QInputDialog>
27 #include <QMessageBox>
28 
29 #include "CubeDnView.h"
30 #include "Directory.h"
31 #include "ImageList.h"
32 #include "MdiCubeViewport.h"
33 #include "Project.h"
34 #include "ProjectItem.h"
35 #include "ProjectItemModel.h"
36 #include "Workspace.h"
37 
38 namespace Isis {
39 
47  WorkOrder(project) {
48  m_isUndoable = false;
49  QAction::setText(tr("Display &Images..."));
50  m_isSavedToHistory = false;
51  }
52 
57  WorkOrder(other) {
58  }
59 
64  }
65 
72  return new CubeDnViewWorkOrder(*this);
73  }
74 
83  if (!images)
84  return false;
85  return (images->count() > 0 && images->count() < 50);
86  }
87 
96  if (!shapes)
97  return false;
98  return (shapes->count() > 0 && shapes->count() < 20);
99  }
100 
101 
102 
113  bool success = WorkOrder::setupExecution();
114 
115 
116  if (success) {
117  QStringList viewOptions;
118 
119  QList<CubeDnView *> existingViews = project()->directory()->cubeDnViews();
120  int viewToUse = -1;
121 
122  if (existingViews.count()) {
123  for (int i = 0; i < existingViews.count(); i++) {
124  viewOptions.append(existingViews[i]->windowTitle());
125  }
126  }
127 
128  viewOptions.append(tr("New Cube DN View"));
129 
130  if (viewOptions.count() > 1) {
131  QString selected = QInputDialog::getItem(NULL, tr("View to see cubes in"),
132  tr("Which view would you like your\nimage's DN data to be put into?"),
133  viewOptions, viewOptions.count() - 1, false, &success);
134 
135  viewToUse = viewOptions.indexOf(selected);
136  }
137  else {
138  viewToUse = viewOptions.count() - 1;
139  }
140 
141  bool newView = false;
142  if (viewToUse == viewOptions.count() - 1) {
143  newView = true;
144  QUndoCommand::setText(tr("View image DN data of list in new cube DN view"));
145  }
146  else if (viewToUse != -1) {
147  QUndoCommand::setText(tr("View image DN data in cube DN view [%1]")
148  .arg(existingViews[viewToUse]->windowTitle()));
149  }
150 
152  internalData.append(QString::number(viewToUse));
153  internalData.append(newView? "new view" : "existing view");
155  }
156 
157  return success;
158  }
159 
160 
166  QList<ProjectItem *> selectedItems = project()->directory()->model()->selectedItems();
167 
168  int viewToUse = internalData().first().toInt();
169 
170  CubeDnView *view = NULL;
171  if (viewToUse == project()->directory()->cubeDnViews().count()) {
172  view = project()->directory()->addCubeDnView();
173  }
174  else {
175  view = project()->directory()->cubeDnViews()[viewToUse];
176  }
177 
178  view->addItems(selectedItems);
179  project()->setClean(false);
180  }
181 
182 
192  // depend on types of ourselves.
193  return dynamic_cast<CubeDnViewWorkOrder *>(other);
194  }
195 }
Internalizes a list of shapes and allows for operations on the entire list.
Definition: ShapeList.h:33
bool setupExecution()
This method asks the user what view they want to see their cube list in.
$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
This work order is designed to bring up a qview-like view for a small number of cubes.
$Date$ $Revision$
virtual void addItems(QList< ProjectItem *> items)
Adds several items to the view.
virtual bool setupExecution()
This sets up the state for the work order.
Definition: WorkOrder.cpp:1275
CubeDnViewWorkOrder(Project *project)
This method sets the text of the work order.
bool dependsOn(WorkOrder *other) const
This method returns true if other depends on a CubeDnViewWorkOrder
void execute()
This method adds a new CubeDnView to the project&#39;s directory and then adds currentItem() to that...
virtual CubeDnViewWorkOrder * clone() const
This method clones the CubeDnViewWorkOrder.
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
QList< CubeDnView * > cubeDnViews()
Accessor for the list of CubeDnViews currently available.
Definition: Directory.cpp:1349
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
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
View that displays cubes in a QView-like way.
Definition: CubeDnView.h:111
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
Project * project() const
Returns the Project this WorkOrder is attached to.
Definition: WorkOrder.cpp:1314
virtual bool isExecutable(ImageList *images)
This check is used by Directory::supportedActions(DataType data).
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
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
CubeDnView * addCubeDnView(QString objectName="")
Add the qview workspace to the window.
Definition: Directory.cpp:720