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
26namespace Isis {
27
35 WorkOrder(project) {
36 m_isUndoable = false;
37 QAction::setText(tr("Display &Images..."));
38 m_isSavedToHistory = false;
39 }
40
47
53
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}
View that displays cubes in a QView-like way.
Definition CubeDnView.h:97
This work order is designed to bring up a qview-like view for a small number of cubes.
virtual CubeDnViewWorkOrder * clone() const
This method clones the CubeDnViewWorkOrder.
CubeDnViewWorkOrder(Project *project)
This method sets the text of the work order.
bool setupExecution()
This method asks the user what view they want to see their cube list in.
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's directory and then adds currentItem() to that.
virtual bool isExecutable(ImageList *images)
This check is used by Directory::supportedActions(DataType data).
CubeDnView * addCubeDnView(QString objectName="")
Add the qview workspace to the window.
QList< CubeDnView * > cubeDnViews()
Accessor for the list of CubeDnViews currently available.
ProjectItemModel * model()
Gets the ProjectItemModel for this directory.
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
Directory * directory() const
Returns the directory associated with this Project.
Definition Project.cpp:1228
void setClean(bool value)
Function to change the clean state of the project.
Definition Project.cpp:1594
QList< ProjectItem * > selectedItems()
Returns a list of the selected items of the internal selection model.
Internalizes a list of shapes and allows for operations on the entire list.
Definition ShapeList.h:33
Provide Undo/redo abilities, serialization, and history for an operation.
Definition WorkOrder.h:311
bool m_isSavedToHistory
Set the work order to be shown in the HistoryTreeWidget.
Definition WorkOrder.h:537
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
virtual bool setupExecution()
This sets up the state for the work order.
QStringList internalData() const
Gets the internal data for this WorkOrder.
Directory * directory() const
return the workorder project directory Returns the Directory object of the Project this WorkOrder is ...
void setInternalData(QStringList data)
Sets the internal data for this WorkOrder.
Project * project() const
Returns the Project this WorkOrder is attached to.
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16