cctw  0.2.1
cctwqtsetupimportdialog.cpp
Go to the documentation of this file.
2 #include "ui_cctwqtsetupimportdialog.h"
3 #include "cctwqtmainwindow.h"
4 #include <QFileDialog>
5 #include "cctwimporter.h"
6 
8  QDialog(parent),
10  m_Window(parent),
11  m_Data(data)
12 {
13  ui->setupUi(this);
14 
15  setAttribute(Qt::WA_DeleteOnClose);
16 
17  connect(ui->m_AppendImages, SIGNAL(clicked()), this, SLOT(doAppendImages()));
18  connect(ui->m_ClearImages, SIGNAL(clicked()), this, SLOT(doClearImages()));
19  connect(ui->m_DataDirectoryBrowse, SIGNAL(clicked()), this, SLOT(doBrowseDirectory()));
20  connect(ui->m_MatchImages, SIGNAL(clicked()), this, SLOT(doMatchImages()));
21  connect(ui->m_DarkImageBrowse, SIGNAL(clicked()), this, SLOT(doBrowseDark()));
22  connect(ui->m_ClearDark, SIGNAL(clicked()), this, SLOT(doClearDark()));
23  connect(ui->m_OutputFileBrowse, SIGNAL(clicked()), this, SLOT(doBrowseOutput()));
24 
25  if (m_Data) {
26  ui->m_DarkImagePath->setText(m_Data->get_DarkImagePath());
27  setCurrentDirectory(m_Data->get_ImageDirectory());
28  ui->m_DataImages->addItems(m_Data->get_ImagePaths());
29  ui->m_DataPattern->setText(m_Data->get_ImagePattern());
30  ui->m_OutputPath->setText(m_Data->get_OutputPath());
31  ui->m_OutputDataset->setText(m_Data->get_OutputDataset());
32 
33  ui->m_InputImageBuffering->setValue(m_Data->get_InputDataBuffering());
34  ui->m_OutputChunkX->setValue(m_Data->get_ChunkSize().x());
35  ui->m_OutputChunkY->setValue(m_Data->get_ChunkSize().y());
36  ui->m_OutputChunkZ->setValue(m_Data->get_ChunkSize().z());
37  ui->m_OutputCompression->setValue(m_Data->get_Compression());
38  }
39 }
40 
42 {
43  delete ui;
44 }
45 
47 {
48  if (m_Data) {
49  m_Data->set_DarkImagePath(ui->m_DarkImagePath->text());
50  m_Data->set_ImageDirectory(currentDirectory());
51 
52  QStringList res;
53 
54  int ct = ui->m_DataImages->count();
55 
56  for (int i=0; i<ct; i++) {
57  QListWidgetItem *item = ui->m_DataImages->item(i);
58 
59  if (item) {
60  res.append(item->text());
61  }
62  }
63 
64  m_Data->set_ImagePaths(res);
65  m_Data->set_ImagePattern(ui->m_DataPattern->text());
66  m_Data->set_OutputPath(ui->m_OutputPath->text());
67  m_Data->set_OutputDataset(ui->m_OutputDataset->text());
68 
69  m_Data->set_InputDataBuffering(ui->m_InputImageBuffering->value());
70  m_Data->set_ChunkSize(CctwIntVector3D(ui->m_OutputChunkX->value(),
71  ui->m_OutputChunkY->value(),
72  ui->m_OutputChunkZ->value()));
73 
74  m_Data->set_Compression(ui->m_OutputCompression->value());
75  }
76 
77  QDialog::accept();
78 }
79 
81 {
82  QStringList paths = QFileDialog::getOpenFileNames(this, "Additional images...",
84 
85  ui->m_DataImages->addItems(paths);
86 }
87 
89 {
90  ui->m_DataImages->clear();
91 }
92 
94 {
95  QString path = QFileDialog::getExistingDirectory(this, "Image Directory",
97 
98  if (path.length() > 0) {
99  setCurrentDirectory(path);
100  }
101 }
102 
104 {
105  QString path = QFileDialog::getOpenFileName(this, "Dark Image",
106  ui->m_DarkImagePath->text());
107 
108  if (path.length() > 0) {
109  ui->m_DarkImagePath->setText(path);
110  }
111 }
112 
114 {
115  ui->m_DarkImagePath->setText("");
116 }
117 
119 {
120  QString path = QFileDialog::getSaveFileName(this, "Output File",
121  ui->m_OutputPath->text());
122 
123  if (path.length() > 0) {
124  ui->m_OutputPath->setText(path);
125  }
126 }
127 
129 {
130  QString patt = ui->m_DataPattern->text();
131 
132  QDir d(currentDirectory());
133  d.setFilter(QDir::Files);
134 
135  QStringList patts(patt);
136  d.setNameFilters(patts);
137 
138  QStringList newFiles = d.entryList();
139 
140  ui->m_DataImages->addItems(newFiles);
141 }
142 
144 {
145  return ui->m_DataDirectory->currentText();
146 }
147 
149 {
150 // printf("Append directory path %s\n", qPrintable(dir));
151 
152  if (dir.length() > 0) {
153  QDir d(dir);
154  QString p1 = d.absolutePath();
155 
156  if (d.cd("..")) {
157  QString p = d.absolutePath();
158 
159  if ((p.length() > 0) && (p != p1)) {
161  }
162  }
163 
164  ui->m_DataDirectory->addItem(p1);
165  }
166 }
167 
169 {
170 // disconnect(ui->m_DataDirectory, SIGNAL(currentIndexChanged(int)), this, SLOT(doBrowseDirectoryChanged(int)));
171 // bool t = ui->m_DataDirectory->blockSignals(true);
172 
173  ui->m_DataDirectory->clear();
174 
176 
177 // ui->m_DataDirectory->blockSignals(t);
178 
179 // connect(ui->m_DataDirectory, SIGNAL(currentIndexChanged(int)), this, SLOT(doBrowseDirectoryChanged(int)));
180  ui->m_DataDirectory->setCurrentIndex(ui->m_DataDirectory->count()-1);
181 }
182 
184 {
185  setCurrentDirectory(ui->m_DataDirectory->itemText(n));
186 }
Ui::CctwqtSetupImportDialog * ui
CctwVector3D< int > CctwIntVector3D
Definition: cctwvector3d.h:70
CctwqtSetupImportDialog(CctwqtMainWindow *parent, CctwImporter *data)