4 #include <QFileSystemModel>
22 : QDockWidget(parent),
23 m_FileBrowserSettings(settings),
25 m_Experiment(experiment),
26 m_Processor(processor),
30 printf(
"QxrdFileBrowser::QxrdFileBrowser(%p)\n",
this);
33 qRegisterMetaType<QFileInfo>(
"QFileInfo");
37 setWindowTitle(
"Output " + windowTitle());
39 setWindowTitle(
"Input " + windowTitle());
46 m_Model -> setRootPath(QDir::currentPath());
48 m_FileBrowser -> setModel(
m_Model.data());
53 #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
54 m_FileBrowser->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
55 m_FileBrowser->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
57 m_FileBrowser->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
58 m_FileBrowser->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
61 m_Model -> setNameFilters(QStringList(
"*.tif"));
62 m_Model -> setNameFilterDisables(
false);
96 set->prop_BrowserFilter() -> linkTo(m_FilterChoices);
97 set->prop_BrowserSelector() -> linkTo(m_FileSelector);
100 m_PrevDirectoryButton->setEnabled(
false);
103 m_RootDirectoryCombo -> setItemText(0, set->get_RootDirectory());
110 printf(
"Deleting file browser\n");
114 printf(
"QxrdFileBrowser::~QxrdFileBrowser(%p)\n",
this);
122 m_Model -> setNameFilters(QStringList(
"*.tif"));
126 m_Model -> setNameFilters(QStringList(
"*[0-9][0-9][0-9][0-9][0-9].tif"));
130 m_Model -> setNameFilters(QStringList(
"*.raw.tif"));
134 m_Model -> setNameFilters(QStringList(
"*.dark.tif"));
138 m_Model -> setNameFilters(QStringList(
"*.avg"));
142 m_Model -> setNameFilters(QStringList(
"*.metadata"));
146 m_Model -> setNameFilters(QStringList());
153 QItemSelectionModel *sel = m_FileBrowser->selectionModel();
154 QRegExp pattern(str, Qt::CaseSensitive, QRegExp::Wildcard);
156 int rows =
m_Model -> rowCount(QModelIndex());
158 for (
int i=0; i<rows; i++) {
159 QModelIndex index =
m_Model -> index(i, 0, QModelIndex());
161 QString path =
m_Model->fileName(index);
164 if (pattern.exactMatch(path)) {
165 sel -> select(index, QItemSelectionModel::Rows | QItemSelectionModel::Select);
167 sel -> select(index, QItemSelectionModel::Rows | QItemSelectionModel::Deselect);
174 QString path = m_RootDirectoryCombo->itemText(index);
187 m_RootDirectoryCombo -> clear();
188 m_RootDirectoryCombo -> insertItem(0, str);
191 m_RootDirectoryCombo -> insertItem(0, dir.path());
199 if (set && newDir !=
"") {
202 set->set_RootDirectory(newDir);
204 m_PrevDirectoryButton->setEnabled(
true);
224 QString newRoot = QFileDialog::getExistingDirectory(
this,
"New browser directory...", set->get_RootDirectory(), 0);
237 QDir dir(set->get_RootDirectory());
261 QItemSelectionModel *sel = m_FileBrowser->selectionModel();
262 QModelIndexList rows = sel->selectedRows();
264 int ndirs = 0, nfiles = 0;
265 foreach(index, rows) {
274 foreach(index, rows) {
284 foreach(index, rows) {
287 proc->loadData(
m_Model->filePath(index));
296 QItemSelectionModel *sel = m_FileBrowser->selectionModel();
297 QModelIndexList rows = sel->selectedRows();
303 foreach(index, rows) {
306 proc->loadDark(
m_Model->filePath(index));
314 QItemSelectionModel *sel = m_FileBrowser->selectionModel();
315 QModelIndexList rows = sel->selectedRows();
321 foreach(index, rows) {
324 proc->loadMask(
m_Model->filePath(index));
332 QItemSelectionModel *sel = m_FileBrowser->selectionModel();
333 QModelIndexList rows = sel->selectedRows();
339 foreach(index, rows) {
342 proc->loadGainMap(
m_Model->filePath(index));
350 QItemSelectionModel *sel = m_FileBrowser->selectionModel();
351 QModelIndexList rows = sel->selectedRows();
357 foreach(index, rows) {
360 proc->processData(
m_Model->filePath(index));
368 QItemSelectionModel *sel = m_FileBrowser->selectionModel();
369 QModelIndexList rows = sel->selectedRows();
375 foreach(index, rows) {
378 proc->integrateData(
m_Model->filePath(index));
386 QItemSelectionModel *sel = m_FileBrowser->selectionModel();
387 QModelIndexList rows = sel->selectedRows();
391 foreach(index, rows) {
393 paths.append(
m_Model->filePath(index));
400 QMetaObject::invokeMethod(proc.data(),
"sumImages", Q_ARG(QStringList, paths));
409 QMetaObject::invokeMethod(proc.data(),
"clearAccumulator");
415 QItemSelectionModel *sel = m_FileBrowser->selectionModel();
416 QModelIndexList rows = sel->selectedRows();
420 foreach(index, rows) {
422 paths.append(
m_Model->filePath(index));
429 QMetaObject::invokeMethod(proc.data(),
"integrateAndAccumulate", Q_ARG(QStringList, paths));
455 QString selectedFilter = proc->get_AccumulateIntegratedFormat();
456 QString path = proc->get_AccumulateIntegratedDirectory() +
"/" +
457 proc->get_AccumulateIntegratedFileName();
459 QString file = QFileDialog::getSaveFileName(
this,
460 "Save accumulated data in...", path,
461 obj->fileFormatFilterString(), &selectedFilter);
463 if (file.length() > 0) {
464 proc -> saveAccumulator(file, selectedFilter);
466 proc -> set_AccumulateIntegratedFormat(selectedFilter);
468 QFileInfo finfo(file);
470 proc -> set_AccumulateIntegratedDirectory(finfo.dir().absolutePath());
471 proc -> set_AccumulateIntegratedFileName(finfo.fileName());
473 QString message = tr(
"Accumulator saved in %1, Format %2").arg(file).arg(selectedFilter);
474 expt -> statusMessage(message);
475 expt -> printMessage(message);
484 QItemSelectionModel *sel = m_FileBrowser->selectionModel();
485 QModelIndexList rows = sel->selectedRows();
489 foreach(index, rows) {
491 paths.append(
m_Model->filePath(index));
498 QMetaObject::invokeMethod(proc.data(),
"addImages", Q_ARG(QStringList, paths));
504 QItemSelectionModel *sel = m_FileBrowser->selectionModel();
505 QModelIndexList rows = sel->selectedRows();
509 foreach(index, rows) {
511 paths.append(
m_Model->filePath(index));
518 QMetaObject::invokeMethod(proc.data(),
"subtractImages", Q_ARG(QStringList, paths));
524 QItemSelectionModel *sel = m_FileBrowser->selectionModel();
525 QModelIndexList rows = sel->selectedRows();
529 foreach(index, rows) {
531 paths.append(
m_Model->filePath(index));
538 QMetaObject::invokeMethod(proc.data(),
"projectImages", Q_ARG(QStringList, paths), Q_ARG(
int, 1), Q_ARG(
int, 0), Q_ARG(
int, 0));
544 QItemSelectionModel *sel = m_FileBrowser->selectionModel();
545 QModelIndexList rows = sel->selectedRows();
549 foreach(index, rows) {
551 paths.append(
m_Model->filePath(index));
558 QMetaObject::invokeMethod(proc.data(),
"projectImages", Q_ARG(QStringList, paths), Q_ARG(
int, 0), Q_ARG(
int, 1), Q_ARG(
int, 0));
564 QItemSelectionModel *sel = m_FileBrowser->selectionModel();
565 QModelIndexList rows = sel->selectedRows();
569 foreach(index, rows) {
571 paths.append(
m_Model->filePath(index));
578 QMetaObject::invokeMethod(proc.data(),
"projectImages", Q_ARG(QStringList, paths), Q_ARG(
int, 0), Q_ARG(
int, 0), Q_ARG(
int, 1));
584 QItemSelectionModel *sel = m_FileBrowser->selectionModel();
585 QModelIndexList rows = sel->selectedRows();
589 foreach(index, rows) {
591 paths.append(
m_Model->filePath(index));
598 QMetaObject::invokeMethod(proc.data(),
"correlateImages", Q_ARG(QStringList, paths));
618 INVOKE_CHECK(QMetaObject::invokeMethod(exp.data(),
"evaluateScriptFile", Q_ARG(QString, filePath)));
629 if (QApplication::mouseButtons() & Qt::RightButton) {
632 QString filePath =
m_Model->filePath(index);
634 QMenu *actions =
new QMenu(
this);
635 QAction *title = actions->addAction(
"File operations...");
636 QAction *open = actions->addAction(
"Open");
637 QAction *openDark = actions->addAction(
"Open as Dark Image");
638 QAction *openMask = actions->addAction(
"Open as Mask");
639 QAction *openGainMap = actions->addAction(
"Open as Gain Map");
640 QAction *integrate = actions->addAction(
"Integrate");
641 QAction *clearAccum = actions->addAction(
"Clear accumulator");
642 QAction *integAccum = actions->addAction(
"Integrate and accumulate");
643 QAction *saveAccum = actions->addAction(
"Save accumulator in...");
644 QAction *process = actions->addAction(
"Process");
645 QAction *sumImages = actions->addAction(
"Sum Images to make new Current Image");
646 QAction *add = actions->addAction(
"Add Images to existing Current Image");
647 QAction *subtract = actions->addAction(
"Subtract Images from Current Image");
648 QAction *projectX = actions->addAction(
"Project Along X");
649 QAction *projectY = actions->addAction(
"Project Along Y");
650 QAction *projectZ = actions->addAction(
"Project Along Z");
651 QAction *correlate = actions->addAction(
"Correlate Images with Current Image");
652 QAction *evaluate = actions->addAction(
"Evaluate scripts");
654 title->setDisabled(
true);
656 QAction *action = actions->exec(QCursor::pos(), title);
658 if (action == open) {
660 }
else if (action == openDark) {
662 }
else if (action == openMask) {
664 }
else if (action == openGainMap) {
666 }
else if (action == sumImages) {
668 }
else if (action == integrate) {
670 }
else if (action == clearAccum) {
672 }
else if (action == integAccum) {
674 }
else if (action == saveAccum) {
676 }
else if (action == process) {
678 }
else if (action == add) {
680 }
else if (action == subtract) {
682 }
else if (action == projectX) {
684 }
else if (action == projectY) {
686 }
else if (action == projectZ) {
688 }
else if (action == correlate) {
690 }
else if (action == evaluate) {
707 tr(
"QxrdFileBrowser::onRowCountChanged(%1,%2)").arg(oldCount).arg(newCount));
725 tr(
"QxrdFileBrowser::fileUpdated(\"%1\",\"%2\")").arg(file.filePath()).arg(file.lastModified().toString()));
QSharedPointer< QxrdExperiment > QxrdExperimentPtr
QxrdFileBrowser(QxrdFileBrowserSettingsWPtr settings, int isOutput, QxrdExperimentWPtr experiment, QxrdDataProcessorWPtr processor, QWidget *parent)
QxrdFileBrowserSettingsWPtr m_FileBrowserSettings
void doAcquisitionDirectory()
QxrdExperimentWPtr m_Experiment
QWeakPointer< QxrdDataProcessor > QxrdDataProcessorWPtr
void doEvaluate(QString filePath)
qint64 qcepDebug(int cond)
void valueChanged(QString val, int index)
QSharedPointer< QxrdFileBrowserSettings > QxrdFileBrowserSettingsPtr
void onRowCountChanged(int oldCount, int newCount)
void onSelectorChanged(QString str)
void doPreviousDirectory()
void doPushDirectory(QString newDir)
QSharedPointer< QxrdDataProcessor > QxrdDataProcessorPtr
void onFilterChanged(int newfilter)
virtual ~QxrdFileBrowser()
QWeakPointer< QxrdExperiment > QxrdExperimentWPtr
void onRootDirectoryChanged(QString dir)
QWeakPointer< QxrdFileBrowserSettings > QxrdFileBrowserSettingsWPtr
void doSelectComboItem(int index)
#define INVOKE_CHECK(res)
QStringList m_DirectoryStack
void doubleClicked(QModelIndex index)
QxrdFileBrowserModelPtr m_Model
void fileUpdated(QFileInfo file)
QxrdOutputFileBrowser(QxrdFileBrowserSettingsWPtr settings, QxrdExperimentWPtr experiment, QxrdDataProcessorWPtr processor, QWidget *parent)
void onFileUpdated(QFileInfo file)
QSharedPointer< QcepDataObject > QcepDataObjectPtr
void doIntegrateAndAccumulate()
QSharedPointer< QxrdFileBrowserModel > QxrdFileBrowserModelPtr
void mousePressed(QModelIndex index)
void valueChanged(int val, int index)
void doClearAccumulator()
QSharedPointer< QcepDatasetModel > QcepDatasetModelPtr
QxrdDataProcessorWPtr m_Processor