Isis 3.0 Programmer Reference
Back | Home
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 
37 namespace Isis {
38 
39  ExportControlNetWorkOrder::ExportControlNetWorkOrder(Project *project) :
40  WorkOrder(project) {
41  QAction::setText(tr("&Export Control Network..."));
42  }
43 
44 
45  ExportControlNetWorkOrder::ExportControlNetWorkOrder(const ExportControlNetWorkOrder &other) :
46  WorkOrder(other) {
47  }
48 
49 
50  ExportControlNetWorkOrder::~ExportControlNetWorkOrder() {
51 
52  }
53 
54 
55  ExportControlNetWorkOrder *ExportControlNetWorkOrder::clone() const {
56  return new ExportControlNetWorkOrder(*this);
57  }
58 
59 
69  return (controls->count() == 1);
70  }
71 
72 
81  bool success = WorkOrder::execute();
82 
83  if (success) {
85 
86  Control *control = NULL;
87  if (controlList()->isEmpty()) {
88  QMap<Control *, QString> cnetChoices;
89  foreach (ControlList *list, project()->controls()) {
90  foreach (Control *control, *list) {
91  cnetChoices[control] = tr("%1/%2").arg(list->name())
92  .arg(control->displayProperties()->displayName());
93  }
94  }
95 
96  QStringList cnetNames = cnetChoices.values();
97  qSort(cnetNames);
98 
99  QString choice = QInputDialog::getItem(NULL, tr("Select Control"),
100  tr("Please choose a control to export."), cnetNames, 0, false, &success);
101 
102  control = cnetChoices.key(choice);
103  internalData.append(control->id());
104  }
105  else {
106  control = controlList()->first();
107  }
108 
109  QString destination =
110  QFileDialog::getSaveFileName(NULL, QString("Export Control Network"),
111  "./" + FileName(control->fileName()).name());
112 
113  if (destination.isEmpty()) {
114  success = false;
115  }
116  internalData.append(destination);
117 
118  setInternalData(internalData);
119  }
120 
121  return success;
122  }
123 
124 
130  QString destination;
131  Control *control = NULL;
132 
133  if (controlList()->isEmpty()) {
134  destination = internalData()[1];
135 
136  QString controlId = internalData()[0];
137  control = project()->control(controlId);
138  }
139  else {
140  destination = internalData()[0];
141  control = controlList()->first();
142  }
143 
144  try {
145  control->controlNet()->Write(destination);
146  }
147  catch (IException &e) {
148  m_warning = e.toString();
149  }
150  }
151 
152 
157  if (!m_warning.isEmpty()) {
158  project()->warn(m_warning);
159  m_warning.clear();
160  }
161  }
162 }
This represents an ISIS control net in a project-based GUI interface.
Definition: Control.h:57
bool isExecutable(ControlList *controls)
Currently, this work order only works with either no data (file menu) or with a single control networ...
File name manipulation and expansion.
Definition: FileName.h:111
void asyncRedo()
Use internalData() and write the control network into the output file.
Maintains a list of Controls so that control nets can easily be copied from one Project to another...
Definition: ControlList.h:34
Project * project() const
Returns the Project this WorkOrder is attached to.
Definition: WorkOrder.cpp:1116
QString id() const
Access the unique ID associated with this Control.
Definition: Control.cpp:181
QStringList internalData() const
Gets the internal data for this WorkOrder.
Definition: WorkOrder.cpp:1186
void postSyncRedo()
Display any warnings that occurred during the asynchronous computations.
QString displayName() const
Returns the display name.
QString name() const
Get the human-readable name of this control list.
QString fileName() const
Access the name of the control network file associated with this Control.
Definition: Control.cpp:171
ControlNet * controlNet()
Open and return a pointer to the ControlNet for this Control.
Definition: Control.cpp:106
ControlDisplayProperties * displayProperties()
Access a pointer to the display properties for the control network.
Definition: Control.cpp:151
QString toString() const
Returns a string representation of this exception.
Definition: IException.cpp:553
Isis exception class.
Definition: IException.h:99
bool execute()
Prompts the user for input.
virtual bool execute()
The (child) implementation of this method should prompt the user/gather state by any means necessary...
Definition: WorkOrder.cpp:1078
QPointer< ControlList > controlList()
Returns the Control List for this WorkOrder (a list of control networks).
Definition: WorkOrder.cpp:637
void setInternalData(QStringList data)
Sets the internal data for this WorkOrder.
Definition: WorkOrder.cpp:1130
void Write(const QString &filename, bool pvl=false)
Writes out the control network.
Definition: ControlNet.cpp:302

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:56