Isis 3.0 Programmer Reference
Back | Home
CubeDnViewWorkOrder.cpp
Go to the documentation of this file.
1 
23 #include "CubeDnViewWorkOrder.h"
24 
25 #include <QtDebug>
26 
27 #include <QFileDialog>
28 #include <QInputDialog>
29 #include <QMessageBox>
30 
31 #include "CubeDnView.h"
32 #include "Directory.h"
33 #include "ImageList.h"
34 #include "MdiCubeViewport.h"
35 #include "Project.h"
36 #include "ProjectItem.h"
37 #include "ProjectItemModel.h"
38 #include "Workspace.h"
39 
40 namespace Isis {
41 
49  WorkOrder(project) {
50  QAction::setText(tr("Display &Images..."));
51  }
52 
57  WorkOrder(other) {
58  }
59 
64  }
65 
72  return new CubeDnViewWorkOrder(*this);
73  }
74 
83  return (images->count() > 0 && images->count() < 50);
84  }
85 
94  return (shapes->count() > 0 && shapes->count() < 20);
95  }
96 
103  bool success = WorkOrder::execute();
104 
105 
106 
107 
108  if (success) {
109  QStringList viewOptions;
110 
111  QList<CubeDnView *> existingViews = project()->directory()->cubeDnViews();
112  int viewToUse = -1;
113 
114  if (existingViews.count()) {
115  for (int i = 0; i < existingViews.count(); i++) {
116  viewOptions.append(existingViews[i]->windowTitle());
117  }
118  }
119 
120  viewOptions.append(tr("New Cube DN View"));
121 
122  if (viewOptions.count() > 1) {
123  QString selected = QInputDialog::getItem(NULL, tr("View to see cubes in"),
124  tr("Which view would you like your\nimage's DN data to be put into?"),
125  viewOptions, viewOptions.count() - 1, false, &success);
126 
127  viewToUse = viewOptions.indexOf(selected);
128  }
129  else {
130  viewToUse = viewOptions.count() - 1;
131  }
132 
133  bool newView = false;
134  if (viewToUse == viewOptions.count() - 1) {
135  newView = true;
136  QUndoCommand::setText(tr("View image DN data of list in new cube DN view"));
137  }
138  else if (viewToUse != -1) {
139  QUndoCommand::setText(tr("View image DN data in cube DN view [%1]")
140  .arg(existingViews[viewToUse]->windowTitle()));
141  }
142 
144  internalData.append(QString::number(viewToUse));
145  internalData.append(newView? "new view" : "existing view");
146  setInternalData(internalData);
147  }
148 
149 
150 
151  return success;
152  }
153 
163  // depend on types of ourselves.
164  return dynamic_cast<CubeDnViewWorkOrder *>(other);
165  }
166 
172  QList<ProjectItem *> selectedItems = project()->directory()->model()->selectedItems();
173 
174  int viewToUse = internalData().first().toInt();
175 
176  CubeDnView *view = NULL;
177  if (viewToUse == project()->directory()->cubeDnViews().count()) {
178  view = project()->directory()->addCubeDnView();
179  }
180  else {
181  view = project()->directory()->cubeDnViews()[viewToUse];
182  }
183 
184  view->addItems(selectedItems);
185  }
186 }
187 
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
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.
Project * project() const
Returns the Project this WorkOrder is attached to.
Definition: WorkOrder.cpp:1116
CubeDnViewWorkOrder(Project *project)
This method sets the text of the work order.
QStringList internalData() const
Gets the internal data for this WorkOrder.
Definition: WorkOrder.cpp:1186
CubeDnView * addCubeDnView()
Add the qview workspace to the window.
Definition: Directory.cpp:562
void syncRedo()
This method adds a new CubeDnView to the project&#39;s directory and then adds currentItem() to that...
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 execute()
If WorkOrder::execute() returns true, then this method returns true.
virtual CubeDnViewWorkOrder * clone() const
This method clones the CubeDnViewWorkOrder.
QList< CubeDnView * > cubeDnViews()
Accessor for the list of CubeDnViews currently available.
Definition: Directory.cpp:947
Directory * directory() const
Returns the directory associated with this Project.
Definition: Project.cpp:824
$Date$ $Revision$
View that displays cubes in a QView-like way.
Definition: CubeDnView.h:74
QList< ProjectItem * > selectedItems()
Returns a list of the selected items of the internal selection model.
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
bool dependsOn(WorkOrder *other) const
This method returns true if other depends on a CubeDnViewWorkOrder.
virtual bool isExecutable(ImageList *images)
This check is used by Directory::supportedActions(DataType data).
void setInternalData(QStringList data)
Sets the internal data for this WorkOrder.
Definition: WorkOrder.cpp:1130

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:17:07