-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlaufindgridbatchwidget.cpp
More file actions
92 lines (80 loc) · 4.15 KB
/
laufindgridbatchwidget.cpp
File metadata and controls
92 lines (80 loc) · 4.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include "laufindgridbatchwidget.h"
#include "laudefaultdirectorieswidget.h"
/****************************************************************************/
/****************************************************************************/
/****************************************************************************/
LAUFindGridBatchDialog::LAUFindGridBatchDialog(QStringList strings, QWidget *parent) : QDialog(parent), counter(0), abortFlag(false), filenames(strings), progress(nullptr)
{
this->setLayout(new QVBoxLayout());
this->layout()->setContentsMargins(6, 6, 6, 6);
this->setWindowTitle(QString("Thumbnail Layout Dialog"));
// SET THE SINK FILE NAME BASED ON THE DEFAULT DIRECTORIES
sinkName = QString("%1/printedThumbnail").arg(LAUDefaultDirectoriesDialog::printedThumbnailsDirectory);
// CREATE A GLWIDGET FOR DISPLAY AND PROCESSING OF MEMORY OBJECTS
widget = new LAUFindGridGLWidget(LAUMemoryObject());
widget->setMinimumSize(640, 480);
connect(this, SIGNAL(emitObject(LAUMemoryObject)), widget, SLOT(onUpdateObject(LAUMemoryObject)), Qt::QueuedConnection);
connect(widget, SIGNAL(emitObject(LAUMemoryObject)), this, SLOT(onUpdateObject(LAUMemoryObject)), Qt::QueuedConnection);
this->layout()->addWidget(widget);
buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
connect(buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT(onAbort()));
connect(buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked()), this, SLOT(onUpdateObject()));
this->layout()->addWidget(buttonBox);
}
/****************************************************************************/
/****************************************************************************/
/****************************************************************************/
void LAUFindGridBatchDialog::showEvent(QShowEvent *)
{
// CREATE A PROGRESS BAR
progress = new QProgressDialog(QString("Processing printed sheets..."), QString("Abort"), 0, filenames.count(), this, Qt::Sheet);
progress->show();
// START THE PROCESSING OF OBJECTS
emit emitObject(LAUMemoryObject());
}
/****************************************************************************/
/****************************************************************************/
/****************************************************************************/
void LAUFindGridBatchDialog::onUpdateObject(LAUMemoryObject obj)
{
if (progress->wasCanceled()) {
QDialog::reject();
} else {
// EXTRACT ALL THE IMAGES OF THE JUST PROCESSED MEMORY OBJECT
if (obj.isValid()) {
for (unsigned int row = 0; row < widget->rows(); row++) {
for (unsigned int col = 0; col < widget->cols(); col++) {
LAUMemoryObject object = widget->result(col, row);
QString filestring = sinkName;
if (counter < 10) {
filestring.append(QString("0000"));
} else if (counter < 100) {
filestring.append(QString("000"));
} else if (counter < 1000) {
filestring.append(QString("00"));
} else if (counter < 10000) {
filestring.append(QString("0"));
}
filestring.append(QString("%1").arg(counter));
filestring.append(QString(".tif"));
object.save(filestring);
counter++;
}
}
}
// LOAD THE NEXT IMAGE IN THE INPUT LIST
if (filenames.count() > 0) {
QString string = filenames.first().split("/").last();
string.chop(string.length() - string.lastIndexOf('.'));
counter = 100 * string.right(5).toInt();
LAUMemoryObject obj = LAUMemoryObject(filenames.takeFirst());
if (obj.isValid()) {
progress->setValue(progress->maximum() - filenames.count());
emit emitObject(LAUMemoryObject(obj));
return;
}
}
// IF WE MAKE IT THIS FAR, THEN WE MUST BE DONE
QDialog::accept();
}
}