Isis 3 Programmer Reference
CubeDnViewWorkOrder.cpp
1 
7 /* SPDX-License-Identifier: CC0-1.0 */
8 
9 #include "CubeDnViewWorkOrder.h"
10 
11 #include <QtDebug>
12 
13 #include <QFileDialog>
14 #include <QInputDialog>
15 #include <QMessageBox>
16 
17 #include "CubeDnView.h"
18 #include "Directory.h"
19 #include "ImageList.h"
20 #include "MdiCubeViewport.h"
21 #include "Project.h"
22 #include "ProjectItem.h"
23 #include "ProjectItemModel.h"
24 #include "Workspace.h"
25 
26 namespace Isis {
27 
35  WorkOrder(project) {
36  m_isUndoable = false;
37  QAction::setText(tr("Display &Images..."));
38  m_isSavedToHistory = false;
39  }
40 
45  WorkOrder(other) {
46  }
47 
52  }
53 
60  return new CubeDnViewWorkOrder(*this);
61  }
62 
71  if (!images)
72  return false;
73  return (images->count() > 0 && images->count() < 50);
74  }
75 
84  if (!shapes)
85  return false;
86  return (shapes->count() > 0 && shapes->count() < 20);
87  }
88 
89 
90 
101  bool success = WorkOrder::setupExecution();
102 
103 
104  if (success) {
105  QStringList viewOptions;
106 
107  QList<CubeDnView *> existingViews = project()->directory()->cubeDnViews();
108  int viewToUse = -1;
109 
110  if (existingViews.count()) {
111  for (int i = 0; i < existingViews.count(); i++) {
112  viewOptions.append(existingViews[i]->windowTitle());
113  }
114  }
115 
116  viewOptions.append(tr("New Cube DN View"));
117 
118  if (viewOptions.count() > 1) {
119  QString selected = QInputDialog::getItem(NULL, tr("View to see cubes in"),
120  tr("Which view would you like your\nimage's DN data to be put into?"),
121  viewOptions, viewOptions.count() - 1, false, &success);
122 
123  viewToUse = viewOptions.indexOf(selected);
124  }
125  else {
126  viewToUse = viewOptions.count() - 1;
127  }
128 
129  bool newView = false;
130  if (viewToUse == viewOptions.count() - 1) {
131  newView = true;
132  QUndoCommand::setText(tr("View image DN data of list in new cube DN view"));
133  }
134  else if (viewToUse != -1) {
135  QUndoCommand::setText(tr("View image DN data in cube DN view [%1]")
136  .arg(existingViews[viewToUse]->windowTitle()));
137  }
138 
140  internalData.append(QString::number(viewToUse));
141  internalData.append(newView? "new view" : "existing view");
143  }
144 
145  return success;
146  }
147 
148 
154  QList<ProjectItem *> selectedItems = project()->directory()->model()->selectedItems();
155 
156  int viewToUse = internalData().first().toInt();
157 
158  CubeDnView *view = NULL;
159  if (viewToUse == project()->directory()->cubeDnViews().count()) {
160  view = project()->directory()->addCubeDnView();
161  }
162  else {
163  view = project()->directory()->cubeDnViews()[viewToUse];
164  }
165 
166  view->addItems(selectedItems);
167  project()->setClean(false);
168  }
169 
170 
180  // depend on types of ourselves.
181  return dynamic_cast<CubeDnViewWorkOrder *>(other);
182  }
183 }
Isis::CubeDnViewWorkOrder
This work order is designed to bring up a qview-like view for a small number of cubes.
Definition: CubeDnViewWorkOrder.h:44
Isis::WorkOrder::setupExecution
virtual bool setupExecution()
This sets up the state for the work order.
Definition: WorkOrder.cpp:1261
Isis::Directory::cubeDnViews
QList< CubeDnView * > cubeDnViews()
Accessor for the list of CubeDnViews currently available.
Definition: Directory.cpp:1335
Isis::CubeDnView
View that displays cubes in a QView-like way.
Definition: CubeDnView.h:97
QList
This is free and unencumbered software released into the public domain.
Definition: BoxcarCachingAlgorithm.h:13
Isis::WorkOrder
Provide Undo/redo abilities, serialization, and history for an operation.
Definition: WorkOrder.h:311
Project.h
Isis::CubeDnViewWorkOrder::setupExecution
bool setupExecution()
This method asks the user what view they want to see their cube list in.
Definition: CubeDnViewWorkOrder.cpp:100
Isis::Directory::model
ProjectItemModel * model()
Gets the ProjectItemModel for this directory.
Definition: Directory.cpp:1091
Isis::WorkOrder::m_isSavedToHistory
bool m_isSavedToHistory
Set the work order to be shown in the HistoryTreeWidget.
Definition: WorkOrder.h:537
Isis::WorkOrder::setInternalData
void setInternalData(QStringList data)
Sets the internal data for this WorkOrder.
Definition: WorkOrder.cpp:1318
Isis::Directory::addCubeDnView
CubeDnView * addCubeDnView(QString objectName="")
Add the qview workspace to the window.
Definition: Directory.cpp:706
Isis::CubeDnViewWorkOrder::CubeDnViewWorkOrder
CubeDnViewWorkOrder(Project *project)
This method sets the text of the work order.
Definition: CubeDnViewWorkOrder.cpp:34
Isis::WorkOrder::directory
Directory * directory() const
return the workorder project directory Returns the Directory object of the Project this WorkOrder is ...
Definition: WorkOrder.cpp:1290
Isis::AbstractProjectItemView::addItems
virtual void addItems(QList< ProjectItem * > items)
Adds several items to the view.
Definition: AbstractProjectItemView.cpp:264
QStringList
Isis::Project
The main project for ipce.
Definition: Project.h:289
Isis::Project::directory
Directory * directory() const
Returns the directory associated with this Project.
Definition: Project.cpp:1229
Isis::ImageList
Internalizes a list of images and allows for operations on the entire list.
Definition: ImageList.h:55
Isis::CubeDnViewWorkOrder::~CubeDnViewWorkOrder
~CubeDnViewWorkOrder()
Destructor.
Definition: CubeDnViewWorkOrder.cpp:51
Isis::WorkOrder::m_isUndoable
bool m_isUndoable
Set the workorder to be undoable/redoable This is defaulted to true - his will allow the workorder to...
Definition: WorkOrder.h:523
Isis::CubeDnViewWorkOrder::isExecutable
virtual bool isExecutable(ImageList *images)
This check is used by Directory::supportedActions(DataType data).
Definition: CubeDnViewWorkOrder.cpp:70
Isis::ProjectItemModel::selectedItems
QList< ProjectItem * > selectedItems()
Returns a list of the selected items of the internal selection model.
Definition: ProjectItemModel.cpp:158
Isis::CubeDnViewWorkOrder::execute
void execute()
This method adds a new CubeDnView to the project's directory and then adds currentItem() to that.
Definition: CubeDnViewWorkOrder.cpp:153
Isis::WorkOrder::project
Project * project() const
Returns the Project this WorkOrder is attached to.
Definition: WorkOrder.cpp:1300
Isis::ShapeList
Internalizes a list of shapes and allows for operations on the entire list.
Definition: ShapeList.h:33
Isis::CubeDnViewWorkOrder::dependsOn
bool dependsOn(WorkOrder *other) const
This method returns true if other depends on a CubeDnViewWorkOrder.
Definition: CubeDnViewWorkOrder.cpp:179
Isis::WorkOrder::internalData
QStringList internalData() const
Gets the internal data for this WorkOrder.
Definition: WorkOrder.cpp:1377
Isis::CubeDnViewWorkOrder::clone
virtual CubeDnViewWorkOrder * clone() const
This method clones the CubeDnViewWorkOrder.
Definition: CubeDnViewWorkOrder.cpp:59
Isis::Project::setClean
void setClean(bool value)
Function to change the clean state of the project.
Definition: Project.cpp:1595
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16