26 #include <QFileDialog> 28 #include <QMessageBox> 29 #include <QtConcurrentMap> 32 #include "ControlList.h" 56 QAction::setText(tr(
"Import &Control Networks..."));
110 return (item->text() ==
"Control Networks");
127 QUndoCommand::setText(tr(
"Import Control Networks"));
131 QStringList cnetFileNames = QFileDialog::getOpenFileNames(
132 qobject_cast<QWidget *>(parent()),
133 tr(
"Import Control Networks"),
"",
134 tr(
"Isis control nets (*.net);;All Files (*)"));
136 if (!cnetFileNames.isEmpty()) {
137 QUndoCommand::setText(tr(
"Import %1 Control Networks").arg(cnetFileNames.count()));
157 foreach (
FileName fileName, cnetFileNames) {
159 cnetFileNamesAndProgress.append(qMakePair(fileName, readProgress));
165 m_watcher->setFuture(QtConcurrent::mapped(cnetFileNamesAndProgress,
170 int totalProgress = 0;
175 if (
m_watcher->future().isResultReadyAt(i)) {
176 totalProgress += 100;
181 totalProgress += qRound(progressPercent * 90);
189 QThread::yieldCurrentThread();
260 QString cnetFileName = cnetFileNameAndProgress.first.original();
263 cnet->
ReadControl(cnetFileName, cnetFileNameAndProgress.second);
266 QString destination = m_destinationFolder.canonicalPath() +
"/" + baseFilename;
268 cnet->
Write(destination);
290 QMutexLocker locker(
project()->workOrderMutex());
This represents an ISIS control net in a project-based GUI interface.
virtual ImportControlNetWorkOrder * clone() const
This method clones the current ImportControlNetWorkOrder and returns it.
void setProgressValue(int)
Sets the current progress value for the WorkOrder.
QFutureWatcher< Control * > * m_watcher
QFutureWatcher, allows for asynchronous import.
void ReadControl(const QString &filename, Progress *progress=0)
Reads in the control points from the given file.
The main project for ipce.
CreateControlsFunctor(Project *project, QDir destinationFolder)
CreateControlsFunctor constructor.
void SetMutex(QMutex *mutex)
Set mutex to lock for making Naif calls.
File name manipulation and expansion.
void DisableAutomaticDisplay()
Turns off updating the Isis Gui when CheckStatus() is called.
~ImportControlNetWorkOrder()
Destructor.
virtual bool isExecutable(ProjectItem *item)
This method returns true if the user clicked on a project tree node with the text "Control Networks"...
ControlList * m_list
List of controls added to project.
virtual bool setupExecution()
This sets up the state for the work order.
QList< Progress * > m_readProgresses
Keeps track of import progress.
void append(const IException &exceptionSource)
Appends the given exception (and its list of previous exceptions) to this exception's causational exc...
Control * operator()(const QPair< FileName, Progress *> &cnetFilename)
Reads and writes the control network(s) asynchronously.
void addControl(Control *control)
Add the given Control's to the current project.
QString name() const
Returns the name of the file excluding the path and the attributes in the file name.
Control * activeControl()
Return the Active Control (control network)
void closeControlNet()
Cleans up the ControlNet pointer.
Program progress reporter.
QDir m_destinationFolder
The directory to copy the control net too.
Provide Undo/redo abilities, serialization, and history for an operation.
Add control networks to a project c Asks the user for a list of control nets and copies them into the...
void cnetReady(int ready)
Adds the control net to the project.
void postExecution()
Clears progress.
bool m_isSynchronous
This is defaulted to true.
bool m_isUndoable
Set the workorder to be undoable/redoable This is defaulted to true - his will allow the workorder to...
bool setupExecution()
Sets up the work order for execution.
ImportControlNetWorkOrder(Project *project)
Creates a work order to import a control network.
int MaximumSteps() const
Returns the maximum number of steps of the progress.
QList< ControlList * > controls()
Return controls in project.
void setProgressRange(int, int)
Sets the progress range of the WorkOrder.
void execute()
Imports the control network asynchronously.
void setModifiesDiskState(bool changesProjectOnDisk)
QString toString() const
Returns a string representation of this exception.
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
QString m_warning
String of any errors/warnings that occurred during import.
Project * m_project
The project to import to.
IException errors() const
Indicates if any errors occurred during the import.
Represents an item of a ProjectItemModel in Qt's model-view framework.
int CurrentStep() const
Returns the current step of the progress.
Namespace for ISIS/Bullet specific routines.
This is used for work orders that will not undo or redo (See createsCleanState()) ...
Project * project() const
Returns the Project this WorkOrder is attached to.
QDir addCnetFolder(QString prefix)
Create and return the name of a folder for placing control networks.
QStringList internalData() const
Gets the internal data for this WorkOrder.
void setInternalData(QStringList data)
Sets the internal data for this WorkOrder.
QPointer< Project > m_project
A pointer to the Project this WorkOrder is attached to.
void Write(const QString &filename, bool pvl=false)
Writes out the control network.
void setClean(bool value)
Function to change the clean state of the project.