23 #include "ExportImagesWorkOrder.h" 26 #include <QFileDialog> 28 #include <QInputDialog> 29 #include <QtConcurrentMap> 34 #include "ImageList.h" 42 ExportImagesWorkOrder::ExportImagesWorkOrder(Project *project) :
49 QAction::setText(tr(
"Export I&mages..."));
53 ExportImagesWorkOrder::ExportImagesWorkOrder(
const ExportImagesWorkOrder &other) :
58 ExportImagesWorkOrder::~ExportImagesWorkOrder() {
63 ExportImagesWorkOrder *ExportImagesWorkOrder::clone()
const {
64 return new ExportImagesWorkOrder(*
this);
78 return (!images->isEmpty());
100 imageListNames.append(list->
name());
103 qSort(imageListNames);
105 QString choice = QInputDialog::getItem(NULL, tr(
"Select Image List"),
106 tr(
"Please choose a list of images to export."), imageListNames, 0,
false, &success);
110 QUndoCommand::setText(tr(
"Export image list [%1]").arg(choice));
113 QUndoCommand::setText(tr(
"Export [%1] images").arg(
imageList()->count()));
116 QString destination = QFileDialog::getExistingDirectory(NULL, tr(
"Export Images"),
".");
118 if (destination.isEmpty()) {
137 if (list->isEmpty()) {
145 QFuture<void *> future = QtConcurrent::mapped(*list, functor);
149 QThreadPool::globalInstance()->releaseThread();
150 for (
int i = 0; i < list->count(); i++) {
157 QThreadPool::globalInstance()->reserveThread();
168 if (!m_warning.isEmpty()) {
182 QString destination) : m_errors(new
IException()), m_numErrors(new int(0)) {
184 m_destination = destination;
196 m_numErrors(other.m_numErrors) {
198 m_destination = other.m_destination;
227 QMutexLocker locker(&m_errorsLock);
247 if (*m_numErrors != 0) {
250 tr(
"Failed to export [%1] images").arg(*m_numErrors),
QString name() const
Get the human-readable name of this image list.
void setProgressValue(int)
Sets the current progress value for the WorkOrder.
Internalizes a list of images and allows for operations on the entire list.
File name manipulation and expansion.
virtual bool setupExecution()
This sets up the state for the work order.
void append(const IException &exceptionSource)
Appends the given exception (and its list of previous exceptions) to this exception's causational exc...
bool setupExecution()
Prompts the user for input.
void postExecution()
Display any warnings that occurred during the asynchronous computations.
#define _FILEINFO_
Macro for the filename and line number.
void execute()
Use internalData() and write the images into the output directory.
Manipulate and parse attributes of output cube filenames.
A type of error that cannot be classified as any of the other error types.
This represents a cube in a project-based GUI interface.
bool m_isSynchronous
This is defaulted to true.
Cube * copy(FileName newFile, const CubeAttributeOutput &newFileAttributes)
Copies the cube to the new fileName.
bool m_isUndoable
Set the workorder to be undoable/redoable This is defaulted to true - his will allow the workorder to...
ProjectImageExportFunctor(QString destination)
Create an image export functor that will copy the image's cubes into the given destination directory...
void setProgressRange(int, int)
Sets the progress range of the WorkOrder.
bool isExecutable(ImageList *images)
Currently, this work order only works with either no data (file menu) or with any number of images...
QString toString() const
Returns a string representation of this exception.
This functor is meant for QtConcurrentMap.
Namespace for ISIS/Bullet specific routines.
Cube * cube()
Get the Cube pointer associated with this display property.
Project * project() const
Returns the Project this WorkOrder is attached to.
~ProjectImageExportFunctor()
Destroys the functor.
ImageList * imageList()
Returns a pointer to the ImageList for this WorkOrder.
IException errors() const
Get the accumulated error list from this functor's run.
QStringList internalData() const
Gets the internal data for this WorkOrder.
void setInternalData(QStringList data)
Sets the internal data for this WorkOrder.
void closeCube()
Cleans up the Cube pointer.
QString fileName() const
Get the file name of the cube that this image represents.
void * operator()(Image *const &imageToExport)
Write the given image's cube into the destination folder (preserves the base name).
ImageList * imageList(QString name)
Return an imagelist given its name.