23#include "ExportImagesWorkOrder.h"
28#include <QInputDialog>
29#include <QtConcurrentMap>
32#include "CubeAttribute.h"
36#include "IException.h"
42 ExportImagesWorkOrder::ExportImagesWorkOrder(
Project *project) :
46 m_isSynchronous =
false;
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 imageListNames.sort();
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),
Manipulate and parse attributes of output cube filenames.
Cube * copy(FileName newFile, const CubeAttributeOutput &newFileAttributes)
Copies the cube to the new fileName.
This functor is meant for QtConcurrentMap.
IException errors() const
Get the accumulated error list from this functor's run.
~ProjectImageExportFunctor()
Destroys the functor.
void * operator()(Image *const &imageToExport)
Write the given image's cube into the destination folder (preserves the base name).
ProjectImageExportFunctor(QString destination)
Create an image export functor that will copy the image's cubes into the given destination directory.
void postExecution()
Display any warnings that occurred during the asynchronous computations.
bool setupExecution()
Prompts the user for input.
bool isExecutable(ImageList *images)
Currently, this work order only works with either no data (file menu) or with any number of images.
void execute()
Use internalData() and write the images into the output directory.
File name manipulation and expansion.
QString baseName() const
Returns the name of the file without the path and without extensions.
@ Unknown
A type of error that cannot be classified as any of the other error types.
QString toString() const
Returns a string representation of this exception.
void append(const IException &exceptionSource)
Appends the given exception (and its list of previous exceptions) to this exception's causational exc...
This represents a cube in a project-based GUI interface.
Cube * cube()
Get the Cube pointer associated with this display property.
void closeCube()
Cleans up the Cube pointer.
QString fileName() const
Get the file name of the cube that this image represents.
Internalizes a list of images and allows for operations on the entire list.
QString name() const
Get the human-readable name of this image list.
The main project for ipce.
Provide Undo/redo abilities, serialization, and history for an operation.
void setProgressRange(int, int)
Sets the progress range of the WorkOrder.
void setProgressValue(int)
Sets the current progress value for the WorkOrder.
virtual bool setupExecution()
This sets up the state for the work order.
QStringList internalData() const
Gets the internal data for this WorkOrder.
void setInternalData(QStringList data)
Sets the internal data for this WorkOrder.
Project * project() const
Returns the Project this WorkOrder is attached to.
ImageList * imageList()
Returns a pointer to the ImageList for this WorkOrder.
This is free and unencumbered software released into the public domain.