2 #include "ui_cctwqtmainwindow.h"
8 #include "qwt_plot_curve.h"
9 #include "qwt_legend.h"
10 #include "qwt_plot_panner.h"
11 #include "qwt_plot_magnifier.h"
12 #include "qwt_plot_zoomer.h"
13 #include "qwt_symbol.h"
14 #include "QtConcurrentRun"
21 m_TransformTester(NULL),
22 m_SetupOutputDialog(NULL),
23 m_SetupTransformDialog(NULL),
33 #ifdef WANT_IMPORT_COMMANDS
34 connect(
ui->m_ActionSetupDataImport, SIGNAL(triggered()),
this, SLOT(doSetupImport()));
35 connect(
ui->m_SetupImportButton, SIGNAL(clicked()),
this, SLOT(doSetupImport()));
37 connect(
ui->m_ActionImportData, SIGNAL(triggered()),
this, SLOT(doImport()));
38 connect(
ui->m_ImportButton, SIGNAL(clicked()),
this, SLOT(doImport()));
42 connect(
ui->m_ActionSetupOutputData, SIGNAL(triggered()),
this, SLOT(
doSetupOutput()));
43 connect(
ui->m_SetupOutputButton, SIGNAL(clicked()),
this, SLOT(
doSetupOutput()));
45 connect(
ui->m_ActionSetupTransform, SIGNAL(triggered()),
this, SLOT(
doSetupTransform()));
46 connect(
ui->m_SetupTransformButton, SIGNAL(clicked()),
this, SLOT(
doSetupTransform()));
48 connect(
ui->m_ActionPerformTransform, SIGNAL(triggered()),
this, SLOT(
doTransform()));
49 connect(
ui->m_TransformButton, SIGNAL(clicked()),
this, SLOT(
doTransform()));
51 connect(
ui->m_ActionCheckTransform, SIGNAL(triggered()),
this, SLOT(
doCheckTransform()));
52 connect(
ui->m_CheckTransformButton, SIGNAL(clicked()),
this, SLOT(
doCheckTransform()));
54 connect(
ui->m_HaltButton, SIGNAL(clicked()),
this, SLOT(
doHalt()));
56 connect(
ui->m_ActionDependencies, SIGNAL(triggered()),
m_Application, SLOT(calculateDependencies()));
57 connect(
ui->m_DependenciesButton, SIGNAL(clicked()),
m_Application, SLOT(calculateDependencies()));
72 #ifdef WANT_IMPORT_COMMANDS
73 connect(
ui->m_ActionCheckImportedData, SIGNAL(triggered()),
this, SLOT(doCheckImportedData()));
76 connect(
ui->m_ActionLoadSettings, SIGNAL(triggered()),
this, SLOT(
doLoadSettings()));
77 connect(
ui->m_ActionSaveSettings, SIGNAL(triggered()),
this, SLOT(
doSaveSettings()));
78 connect(
ui->m_ActionSaveCurrentSettings, SIGNAL(triggered()),
m_Application, SLOT(writeSettings()));
80 connect(
ui->m_ActionQuit, SIGNAL(triggered()),
this, SLOT(
possiblyClose()));
82 app->prop_Halting()->linkTo(
ui->m_Halting);
84 #ifdef WANT_ANALYSIS_COMMANDS
91 connect(
ui->m_ActionCompareTwoHDF5, SIGNAL(triggered()),
this, SLOT(
doCompareHDF5()));
93 ui->m_ParametersTabs->removeTab(5);
94 ui->m_Menubar->removeAction(
ui->m_AnalysisMenu->menuAction());
97 #ifdef WANT_IMPORT_COMMANDS
101 import->prop_DarkImagePath()->linkTo(
ui->m_ImportDarkImagePath);
102 import->prop_ImageDirectory()->linkTo(
ui->m_ImportDataDirectory);
103 import->prop_OutputPath()->linkTo(
ui->m_ImportOutputPath);
104 import->prop_OutputDataset()->linkTo(
ui->m_ImportOutputDataset);
105 import->prop_Compression()->linkTo(
ui->m_ImportOutputCompression);
107 connect(import->prop_ImagePaths(), SIGNAL(valueChanged(QStringList,
int)),
this, SLOT(updateImportImagePaths(QStringList)));
109 import->prop_ChunkSize()->linkTo(
ui->m_ImportOutputChunkX,
110 ui->m_ImportOutputChunkY,
111 ui->m_ImportOutputChunkZ);
113 updateImportImagePaths(import->get_ImagePaths());
116 ui->m_ParametersTabs->removeTab(0);
117 ui->m_FileMenu->removeAction(
ui->m_ActionSetupDataImport);
118 ui->m_FileMenu->removeAction(
ui->m_ActionImportData);
124 inputData->prop_DataFileName()->linkTo(
ui->m_InputDataFileName);
125 inputData->prop_DataSetName()->linkTo(
ui->m_InputDataSetName);
126 inputData->prop_ChunksRead()->linkTo(
ui->m_ChunksRead);
128 inputData->prop_Compression()->linkTo(
ui->m_InputCompression);
129 inputData->prop_ChunksRead()->linkTo(
ui->m_ChunksRead);
131 inputData->prop_Dimensions()->linkTo(
ui->m_InputDimensionsX,
132 ui->m_InputDimensionsY,
133 ui->m_InputDimensionsZ);
135 inputData->prop_ChunkSize()->linkTo(
ui->m_InputChunkX,
139 inputData->prop_ChunkCount()->linkTo(
ui->m_InputCountX,
143 inputData->prop_HDFChunkSize()->linkTo(
ui->m_InputHDFChunkX,
144 ui->m_InputHDFChunkY,
145 ui->m_InputHDFChunkZ);
149 connect(
ui->m_InputDataFileName, SIGNAL(textChanged(QString)),
this, SLOT(
doCheckDataFile(QString)));
150 connect(
ui->m_BrowseInputDataset, SIGNAL(currentIndexChanged(QString)),
this, SLOT(
doBrowseInputDataset(QString)));
151 connect(
ui->m_InputDataSetName, SIGNAL(textChanged(QString)),
this, SLOT(
doCheckDataset(QString)));
156 outputData->prop_DataFileName()->linkTo(
ui->m_OutputDataFileName);
157 outputData->prop_DataSetName()->linkTo(
ui->m_OutputDataSetName);
158 outputData->prop_ChunksWritten()->linkTo(
ui->m_ChunksWritten);
159 outputData->prop_ChunksHeld()->linkTo(
ui->m_ChunksHeld);
160 outputData->prop_ChunksHeldMax()->linkTo(
ui->m_ChunksHeldMax);
162 outputData->prop_Compression()->linkTo(
ui->m_OutputCompression);
163 outputData->prop_ChunksWritten()->linkTo(
ui->m_ChunksWritten);
165 outputData->prop_Dimensions()->linkTo(
ui->m_OutputDimensionsX,
166 ui->m_OutputDimensionsY,
167 ui->m_OutputDimensionsZ);
169 outputData->prop_ChunkSize()->linkTo(
ui->m_OutputChunkX,
173 outputData->prop_ChunkCount()->linkTo(
ui->m_OutputCountX,
177 outputData->prop_HDFChunkSize()->linkTo(
ui->m_OutputHDFChunkX,
178 ui->m_OutputHDFChunkY,
179 ui->m_OutputHDFChunkZ);
185 xform->prop_ProjectX()->linkTo(
ui->m_ProjectX);
186 xform->prop_ProjectY()->linkTo(
ui->m_ProjectY);
187 xform->prop_ProjectZ()->linkTo(
ui->m_ProjectZ);
188 xform->prop_ProjectDestination()->linkTo(
ui->m_ProjectDestination);
189 xform->prop_OversampleX()->linkTo(
ui->m_OversampleX);
190 xform->prop_OversampleY()->linkTo(
ui->m_OversampleY);
191 xform->prop_OversampleZ()->linkTo(
ui->m_OversampleZ);
197 parms->prop_ExtraFlip()->linkTo(
ui->m_ExtraFlip);
200 connect(
ui->m_ActionProjectBrowse, SIGNAL(triggered()),
this, SLOT(
doBrowseProject()));
201 connect(
ui->m_ProjectBrowseButton, SIGNAL(clicked()),
this, SLOT(
doBrowseProject()));
203 connect(
ui->m_ActionProjectInput, SIGNAL(triggered()),
this, SLOT(
doProjectInput()));
204 connect(
ui->m_ProjectInputButton, SIGNAL(clicked()),
this, SLOT(
doProjectInput()));
206 connect(
ui->m_ActionProjectOutput, SIGNAL(triggered()),
this, SLOT(
doProjectOutput()));
207 connect(
ui->m_ProjectOutputButton, SIGNAL(clicked()),
this, SLOT(
doProjectOutput()));
209 connect(app->prop_Progress(), SIGNAL(valueChanged(
int,
int)),
this, SLOT(
onProgressUpdate()));
210 connect(app->prop_ProgressLimit(), SIGNAL(valueChanged(
int,
int)),
this, SLOT(
onProgressUpdate()));
212 qRegisterMetaType<QwtPlotCurve*>(
"QwtPlotCurve*");
214 m_Panner =
new QwtPlotPanner(
ui->m_CctwGraph->canvas());
215 m_Panner -> setMouseButton(Qt::MidButton);
216 m_Panner -> setEnabled(
true);
218 m_Zoomer =
new QwtPlotZoomer(QwtPlot::xBottom, QwtPlot::yLeft,
ui->m_CctwGraph->canvas());
219 m_Zoomer -> setTrackerMode(QwtPicker::AlwaysOn);
220 m_Zoomer -> setMousePattern(QwtEventPattern::MouseSelect2,
221 Qt::LeftButton, Qt::ControlModifier | Qt::ShiftModifier);
222 m_Zoomer -> setMousePattern(QwtEventPattern::MouseSelect3,
223 Qt::LeftButton, Qt::ControlModifier);
226 m_Magnifier =
new QwtPlotMagnifier(
ui->m_CctwGraph->canvas());
230 m_Legend -> setFrameStyle(QFrame::Box|QFrame::Sunken);
233 ui->m_CctwGraph -> insertLegend(
m_Legend, QwtPlot::BottomLegend);
266 return QMessageBox::question(
this, tr(
"Really Close?"),
267 tr(
"Do you really want to close the window?"),
268 QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok;
273 if (QThread::currentThread() != thread()) {
274 QMetaObject::invokeMethod(
this,
"printLine", Q_ARG(QString, line));
276 ui->m_OutputMessages->append(line);
282 if (QThread::currentThread() != thread()) {
283 QMetaObject::invokeMethod(
this,
"printMessage", Q_ARG(QString, msg), Q_ARG(QDateTime, dt));
285 ui->m_OutputMessages->append(dt.toString(
"yyyy MMM dd hh:mm:ss.zzz: ")+msg);
291 QString cmd =
ui->m_CommandInput->text();
293 QMetaObject::invokeMethod(
m_Application,
"evaluateCommand", Q_ARG(QString, cmd));
296 #ifdef WANT_IMPORT_COMMANDS
297 void CctwqtMainWindow::updateImportImagePaths(QStringList p)
299 ui->m_ImportDataImages->clear();
300 ui->m_ImportDataImages->addItems(p);
303 void CctwqtMainWindow::doSetupImport()
305 if (m_SetupImportDialog == NULL) {
307 m_SetupImportDialog -> show();
310 m_SetupImportDialog->raise();
311 m_SetupImportDialog->activateWindow();
314 void CctwqtMainWindow::doImport()
325 QString path = QFileDialog::getOpenFileName(
this,
"Input File",
326 inputData->get_DataFileName());
328 if (path.length() > 0) {
329 inputData->set_DataFileName(path);
336 const H5O_info_t *object_info,
342 switch (object_info->type) {
343 case H5O_TYPE_DATASET:
345 QStringList *sl = (QStringList*)(op_data);
348 sl->append(QString(
"/%1").arg(name));
360 H5E_auto2_t old_func;
361 void *old_client_data;
363 H5Eget_auto(H5E_DEFAULT, &old_func, &old_client_data);
366 H5Eset_auto(H5E_DEFAULT, NULL, NULL);
370 hid_t file = H5Fopen(qPrintable(path), H5F_ACC_RDONLY, H5P_DEFAULT);
379 herr_t ret = H5Fclose(file);
382 H5Eset_auto(H5E_DEFAULT, old_func, old_client_data);
395 ui->m_BrowseInputDataset->clear();
396 ui->m_BrowseInputDataset->addItem(
"");
397 ui->m_BrowseInputDataset->addItems(paths);
406 ui->m_InputDataSetName->setText(entry);
455 QString path = QFileDialog::getOpenFileName(
this,
"Execute Script from...",
466 QString path = QFileDialog::getSaveFileName(
this,
"Save Settings in...",
477 QString path = QFileDialog::getOpenFileName(
this,
"Load Settings from...",
488 QString path = QFileDialog::getSaveFileName(
this,
"Save Dependencies in...",
499 QString path = QFileDialog::getOpenFileName(
this,
"Load Dependencies from...",
516 for (
int i=0; i < nchnk; i++) {
534 ui->m_DependenciesTable->clear();
535 ui->m_DependenciesTable->setRowCount(ndeps + 3);
536 ui->m_DependenciesTable->setColumnCount((maxdeps+1)>4 ? (maxdeps+1):4);
538 ui->m_DependenciesTable->setItem(0, 0,
new QTableWidgetItem(title));
539 ui->m_DependenciesTable->setItem(1, 0,
new QTableWidgetItem(tr(
"%1 Deps").arg(ndeps)));
540 ui->m_DependenciesTable->setItem(1, 1,
new QTableWidgetItem(tr(
"%1 Max").arg(maxdeps)));
541 ui->m_DependenciesTable->setItem(1, 2,
new QTableWidgetItem(tr(
"%1 Sum").arg(sumdeps)));
542 ui->m_DependenciesTable->setItem(1, 3,
new QTableWidgetItem(tr(
"%1 Avg").arg(
double(sumdeps)/
double(nchnk))));
543 ui->m_DependenciesTable->setItem(1, 4,
new QTableWidgetItem(tr(
"%1 Avg-NZ").arg(
double(sumdeps)/
double(ndeps))));
547 for (
int i=0; i < nchnk; i++) {
554 ui->m_DependenciesTable->setItem(r+3, 0,
new QTableWidgetItem(tr(
"%1->[%2]").arg(i).arg(ct)));
556 for (
int i=0; i<ct; i++) {
557 ui->m_DependenciesTable->setItem(r+3, 1+i,
new QTableWidgetItem(tr(
"%1").arg(chunk->
dependency(i))));
579 QString path = QFileDialog::getOpenFileName(
this,
"Spec Data File for PE rotscan runs...",
589 QString path = QFileDialog::getOpenFileName(
this,
"Spec Data File for PE rotscan runs...",
602 ui->m_ProgressBar->setMaximum(lim);
603 ui->m_ProgressBar->setValue(prog);
608 if (QThread::currentThread() != thread()) {
609 QMetaObject::invokeMethod(
this,
611 Q_ARG(QwtPlotCurve*, c1),
612 Q_ARG(QwtPlotCurve*, c2),
613 Q_ARG(QwtPlotCurve*, c3),
614 Q_ARG(QwtPlotCurve*, c4));
616 c1->setBrush(QBrush(Qt::red));
617 c1->setStyle(QwtPlotCurve::NoCurve);
618 c1->setSymbol(
new QwtSymbol(QwtSymbol::Rect,QBrush(Qt::red),QPen(Qt::red),QSize(3,3)));
620 c2->setBrush(QBrush(Qt::blue));
621 c2->setStyle(QwtPlotCurve::NoCurve);
622 c2->setSymbol(
new QwtSymbol(QwtSymbol::Rect,QBrush(Qt::blue),QPen(Qt::blue),QSize(3,3)));
624 c3->setBrush(QBrush(Qt::green));
625 c3->setStyle(QwtPlotCurve::NoCurve);
626 c3->setSymbol(
new QwtSymbol(QwtSymbol::Rect,QBrush(Qt::green),QPen(Qt::green),QSize(3,3)));
628 c4->setBrush(QBrush(Qt::black));
629 c4->setStyle(QwtPlotCurve::NoCurve);
630 c4->setSymbol(
new QwtSymbol(QwtSymbol::Rect,QBrush(Qt::black),QPen(Qt::black),QSize(3,3)));
632 c1 -> attach(
ui->m_CctwGraph);
633 c2 -> attach(
ui->m_CctwGraph);
634 c3 -> attach(
ui->m_CctwGraph);
635 c4 -> attach(
ui->m_CctwGraph);
637 ui->m_CctwGraph -> setAxisAutoScale(QwtPlot::xBottom);
638 ui->m_CctwGraph -> setAxisAutoScale(QwtPlot::yLeft);
639 ui->m_CctwGraph -> setAxisAutoScale(QwtPlot::yRight);
656 #ifdef WANT_IMPORT_COMMANDS
657 void CctwqtMainWindow::doCheckImportedData()
674 QString s = QFileDialog::getExistingDirectory(
this,
"Destination", xform->get_ProjectDestination());
677 xform->set_ProjectDestination(s);
687 int flags = (xform->get_ProjectX() ? 1 : 0) +
688 (xform->get_ProjectY() ? 2 : 0) +
689 (xform->get_ProjectZ() ? 4 : 0);
693 QFileInfo info(inputPath);
695 QString dst = xform->get_ProjectDestination() +
"/" + info.completeBaseName();
696 QString cmd = tr(
"transformer.inputProject(\"%1\", %2)").arg(dst).arg(flags);
707 int flags = (xform->get_ProjectX() ? 1 : 0) +
708 (xform->get_ProjectY() ? 2 : 0) +
709 (xform->get_ProjectZ() ? 4 : 0);
713 QFileInfo info(outputPath);
715 QString dst = xform->get_ProjectDestination() +
"/" + info.completeBaseName();
716 QString cmd = tr(
"transformer.outputProject(\"%1\", %2)").arg(dst).arg(flags);
CctwChunkedData * m_OutputData
int dependencyCount() const
void reportOutputDependencies()
CctwChunkedData * m_InputData
static herr_t iterate_objects(hid_t o_id, const char *name, const H5O_info_t *object_info, void *op_data)
CctwCrystalCoordinateParameters * m_Parameters
void doExecuteScriptFile()
CctwDataChunk * chunk(int n)
void reportInputDependencies()
QPointer< CctwqtSetupTransformDialog > m_SetupTransformDialog
static QStringList iterateHDF5datasets(QString path)
void executeScriptFile(QString path)
void printLine(QString line)
void doAnalyzeSpecDataFile()
void analyzeSpecDataFile(QString path)
CctwIntVector3D chunkCount
Ui::CctwqtMainWindow * ui
CctwTransformer * m_Transformer
void doCheckDataFile(QString path)
int dependency(int n) const
void closeEvent(QCloseEvent *event)
void doSaveDependencies()
CctwApplication * cctwApplication()
CctwqtMainWindow(CctwApplication *app, QWidget *parent=0)
CctwqtTransformTester * m_TransformTester
QPointer< CctwqtSetupCompareDialog > m_SetupCompareDialog
void plotCurves(QwtPlotCurve *c1, QwtPlotCurve *c2, QwtPlotCurve *c3, QwtPlotCurve *c4)
void analyzePEMetaData(QString path)
CctwComparer * m_CompareData
QPointer< CctwqtSetupCheckImportDialog > m_SetupCheckImportDialog
void reportDependencies(CctwChunkedData *data, QString title)
QwtPlotMagnifier * m_Magnifier
void saveDependencies(QString path)
void loadDependencies(QString path)
void printMessage(QString msg, QDateTime dt=QDateTime::currentDateTime())
QPointer< CctwqtSetupOutputDialog > m_SetupOutputDialog
void doAnalyzePEMetaData()
void doLoadDependencies()
CctwApplication * m_Application
void evaluateCommand(QString cmd)
CctwCrystalCoordinateParameters * parameters() const
void doBrowseInputDataset(QString entry)
void doCheckDataset(QString name)