File failed to load: https://isis.astrogeology.usgs.gov/9.0.0/Object/assets/jax/output/NativeMML/config.js
Isis 3 Programmer Reference
ExportControlNetWorkOrder.cpp
Go to the documentation of this file.
1
23#include "ExportControlNetWorkOrder.h"
24
25#include <QDebug>
26#include <QFileDialog>
27#include <QInputDialog>
28
29#include "Control.h"
30#include "ControlList.h"
31#include "ControlNet.h"
32#include "FileName.h"
33#include "IException.h"
34#include "IString.h"
35#include "Project.h"
36
37namespace Isis {
38
48 m_isSynchronous = false;
49 m_isUndoable = false;
50 QAction::setText(tr("&Export Control Network..."));
51 QUndoCommand::setText(tr("Export Control Network..."));
52 }
53
54
65
66
75
76
87
88
101
102 if (controls) {
103 return (controls->count() == 1);
104 }
105 return false;
106 }
107
108
120 bool success = WorkOrder::setupExecution();
121
122 if (success) {
124
125 Control *control = NULL;
126
127 // See if there are any other control lists in the project and give these to the user as
128 // choices for control nets they can export.
129 if (project()) {
130
131 Project *proj = project();
132
133 QList<ControlList *> controls = proj->controls();
134 if (controls.count() > 0) {
135 ControlList *l = controls.first();
137 control = controlList()->first();
138 }
139 else {
140
141 QMap<Control *, QString> cnetChoices;
142 foreach (ControlList *list, project()->controls()) {
143 foreach (Control *control, *list) {
144 cnetChoices[control] = tr("%1/%2").arg(list->name())
145 .arg(control->displayProperties()->displayName());
146 }
147 }
148
149 QStringList cnetNames = cnetChoices.values();
150 cnetNames.sort();
151
152 QString choice = QInputDialog::getItem(NULL, tr("Select Control"),
153 tr("Please choose a control to export."), cnetNames, 0, false, &success);
154
155 control = cnetChoices.key(choice);
156 internalData.append(control->id());
157 }
158 }
159
160
161 QString destination =
162 QFileDialog::getSaveFileName(NULL, QString("Export Control Network"),
163 "./" + FileName(control->fileName()).name());
164
165 if (destination.isEmpty()) {
166 success = false;
167 }
168 internalData.append(destination);
169
171 }
172
173 return success;
174 }
175
176
186 QString destination;
187 Control *control = NULL;
188
189 if (controlList()->isEmpty()) {
190 destination = internalData()[1];
191
192 QString controlId = internalData()[0];
193 control = project()->control(controlId);
194 }
195 else {
196 destination = internalData()[0];
197 control = controlList()->first();
198 }
199
200 QString currentLocation = control->fileName();
201 if (!QFile::copy(currentLocation, destination) ) {
202 m_warning = "Error saving control net.";
203 }
204 }
205
206
215 if (!m_warning.isEmpty()) {
216 project()->warn(m_warning);
217 m_warning.clear();
218 }
219 }
220}
This represents an ISIS control net in a project-based GUI interface.
Definition Control.h:65
QString id() const
Access the unique ID associated with this Control.
Definition Control.cpp:262
ControlDisplayProperties * displayProperties()
Access a pointer to the display properties for the control network.
Definition Control.cpp:232
QString fileName() const
Access the name of the control network file associated with this Control.
Definition Control.cpp:252
Maintains a list of Controls so that control nets can easily be copied from one Project to another,...
Definition ControlList.h:42
QString name() const
Get the human-readable name of this control list.
QString displayName() const
Returns the display name.
virtual ExportControlNetWorkOrder * clone() const
Clones this work order.
virtual bool setupExecution()
Prepares for exporting a control net by soliciting information from the user.
virtual void execute()
Executes the work order.
bool isExecutable(ControlList *controls)
Determines if we can export a control net.
ExportControlNetWorkOrder(Project *project)
Creates a work order for exporting a control network from the project.
virtual void postExecution()
Display any warnings that occurred during the asynchronous computations.
QString m_warning
Stores any errors that may have occurred during export.
File name manipulation and expansion.
Definition FileName.h:100
QString name() const
Returns the name of the file excluding the path and the attributes in the file name.
Definition FileName.cpp:162
The main project for ipce.
Definition Project.h:287
Control * control(QString id)
Accessor for if the project is clearing or not.
Definition Project.cpp:1160
QList< ControlList * > controls()
Return controls in project.
Definition Project.cpp:2099
virtual void setData(Context)
Sets the context data for this WorkOrder.
bool m_isSynchronous
This is defaulted to true.
Definition WorkOrder.h:504
bool m_isUndoable
Set the workorder to be undoable/redoable This is defaulted to true - his will allow the workorder to...
Definition WorkOrder.h:497
virtual bool setupExecution()
This sets up the state for the work order.
QStringList internalData() const
Gets the internal data for this WorkOrder.
QPointer< ControlList > controlList()
Returns the Control List for this WorkOrder (a list of control networks).
void setInternalData(QStringList data)
Sets the internal data for this WorkOrder.
Project * project() const
Returns the Project this WorkOrder is attached to.
WorkOrder(Project *project)
Create a work order that will work with the given project.
Definition WorkOrder.cpp:38
This is free and unencumbered software released into the public domain.
This is free and unencumbered software released into the public domain.
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16