-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathConvolutionDialog.cpp
101 lines (78 loc) · 2.36 KB
/
ConvolutionDialog.cpp
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
93
94
95
96
97
98
99
100
101
#include "ConvolutionDialog.h"
ConvolutionDialog::ConvolutionDialog(QWidget *parent) : QDialog(parent)
{
m_final = NULL;
itemIndex = -1;
setWindowTitle(tr("Please select mask"));
targetMaskSize = "";
vLayoutWindow = new QVBoxLayout(this);
groupBox1 = new QGroupBox(tr("Masks"));
groupBox2 = new QGroupBox();
label1 = new QLabel(targetMaskSize);
label2 = new QLabel(tr("Opened images that can be used as masks:"));
comboBox = new QComboBox();
buttonOK = new QPushButton(tr("OK"));
buttonCancel = new QPushButton(tr("Cancel"));
vLayout2 = new QVBoxLayout(groupBox1);
vLayout2->addWidget(label1);
vLayout2->addWidget(label2);
vLayout2->addWidget(comboBox);
hLayout = new QHBoxLayout(groupBox2);
hLayout->addWidget(buttonCancel);
hLayout->addWidget(buttonOK);
vLayoutWindow->addWidget(groupBox1);
vLayoutWindow->addWidget(groupBox2);
connect(buttonOK, SIGNAL(clicked()), this, SLOT(ok()));
connect(buttonCancel, SIGNAL(clicked()), this, SLOT(cancel()));
connect(comboBox, SIGNAL(currentIndexChanged(int)),
this, SLOT(setItemIndex(int)));
}
void ConvolutionDialog::addSelectCandidate(ImageDisplay* candidate)
{
candidates << candidate;
}
void ConvolutionDialog::defineTargetMaskSize(int height, int width)
{
targetMaskSize = tr("Required mask dimensions: %1 x %2").arg(width).arg(height);
}
void ConvolutionDialog::refreshComboBox()
{
comboBox->clear();
QList<ImageDisplay*>::const_iterator stlIter;
for ( stlIter = candidates.begin(); stlIter != candidates.end(); ++stlIter )
{
comboBox->addItem(strippedName((*stlIter)->getCurFile()) ,"");
}
label1->setText(targetMaskSize);
}
void ConvolutionDialog::ok()
{
if (itemIndex == -1)
{
QMessageBox::critical ( this, tr("No mask selected!"), "No mask selected!", QMessageBox::Ok, QMessageBox::NoButton );
reject();
return;
}
ImageDisplay *imageDisplay = candidates.at(itemIndex);
setFinal(imageDisplay);
accept();
}
void ConvolutionDialog::cancel()
{
reject();
}
void ConvolutionDialog::setFinal(ImageDisplay *final)
{
if ( m_final == final )
return;
m_final = final;
emit finalSelected( m_final );
}
void ConvolutionDialog::setItemIndex(int index)
{
itemIndex = index;
}
QString ConvolutionDialog::strippedName(const QString &fullFileName)
{
return QFileInfo(fullFileName).fileName();
}