QString AMExporterGeneralAscii::exportScan(const AMScan *scan, const QString &destinationFolderPath, const AMExporterOption *option, int autoIndex) { setCurrentAutoIndex(autoIndex); setCurrentFilename(option->fileName()); setDestinationFolderPath(destinationFolderPath); // prepare scan and option setCurrentScan(scan); option_ = qobject_cast<const AMExporterOptionGeneralAscii*>(option); if(!option_) { AMErrorMon::report(AMErrorReport(this, AMErrorReport::Alert, -2, "Invalid options specified for the General Ascii Exporter. Please report this bug to the Acquaman developers.")); return QString(); } // prepare data sources if(!prepareDataSources()) return QString(); // prepare export file mainFileName_ = parseKeywordString( destinationFolderPath % "/" % option->fileName() ); qDebug() << "Wants to save as " << mainFileName_; if(!openFile(mainFileName_)) { AMErrorMon::report(AMErrorReport(this, AMErrorReport::Alert, -3, "Export failed: Could not open the file '" % mainFileName_ % "' for writing. Check that you have permission to save files there, and that a file with that name doesn't already exists.")); return QString(); } writeHeader(); writeMainTable(); writeSeparateSections(); if(option_->includeHigherDimensionSources() && !writeSeparateFiles(destinationFolderPath)) { file_->close(); return QString(); } file_->close(); return mainFileName_; }
BioXASSSRLMonochromatorEnergyCalibrationView::BioXASSSRLMonochromatorEnergyCalibrationView(BioXASSSRLMonochromator *mono, AMScan *scan, QWidget *parent) : QWidget(parent) { // Initialize local variables. monoEnergy_ = 0; desiredEnergy_ = 0; mono_ = 0; currentScan_ = 0; scanViewModel_ = 0; // Create UI elements. loadDataButton_ = new QPushButton("Load data"); loadDataButton_->setToolTip("Use previously acquired data for calibration."); newDataButton_ = new QPushButton("New data"); newDataButton_->setToolTip("Configure a new scan for calibration."); scanView_ = new AMScanView(); scanViewModel_ = scanView_->model(); scanSourcesEditor_ = new AMDataSourcesEditor(scanViewModel_); QLabel *monoEnergyPrompt = new QLabel("Mono energy: "); monoEnergySpinBox_ = new QDoubleSpinBox(this); monoEnergySpinBox_->setValue(0); QLabel *desiredEnergyPrompt = new QLabel("Desired energy: "); desiredEnergySpinBox_ = new QDoubleSpinBox(this); desiredEnergySpinBox_->setValue(0); calibrateButton_ = new QPushButton("Calibrate"); chooseScanDialog_ = 0; // Create and set layouts. QVBoxLayout *dataButtonsLayout = new QVBoxLayout(); dataButtonsLayout->addWidget(loadDataButton_); dataButtonsLayout->addWidget(newDataButton_); QGridLayout *energyLayout = new QGridLayout(); energyLayout->addWidget(monoEnergyPrompt, 0, 0, 1, 1, Qt::AlignRight); energyLayout->addWidget(monoEnergySpinBox_, 0, 1); energyLayout->addWidget(desiredEnergyPrompt, 1, 0, 1, 1, Qt::AlignRight); energyLayout->addWidget(desiredEnergySpinBox_, 1, 1); energyLayout->addWidget(calibrateButton_, 1, 2); QHBoxLayout *calibrationViewLayout = new QHBoxLayout(); calibrationViewLayout->addLayout(dataButtonsLayout); calibrationViewLayout->addLayout(energyLayout); QGroupBox *calibrationView = new QGroupBox(); calibrationView->setLayout(calibrationViewLayout); QVBoxLayout *leftLayout = new QVBoxLayout(); leftLayout->addWidget(scanView_); leftLayout->addWidget(calibrationView); QVBoxLayout *rightLayout = new QVBoxLayout(); rightLayout->addWidget(scanSourcesEditor_); QHBoxLayout *layout = new QHBoxLayout(); layout->addLayout(leftLayout); layout->addLayout(rightLayout); setLayout(layout); // Make connections. connect( loadDataButton_, SIGNAL(clicked()), this, SLOT(onLoadDataButtonClicked()) ); connect( newDataButton_, SIGNAL(clicked()), this, SIGNAL(energyCalibrationScanRequested()) ); connect( scanView_, SIGNAL(dataPositionChanged(QPointF)), this, SLOT(onScanViewDataPositionChanged(QPointF)) ); connect( monoEnergySpinBox_, SIGNAL(valueChanged(double)), this, SLOT(setMonoEnergy(double)) ); connect( desiredEnergySpinBox_, SIGNAL(valueChanged(double)), this, SLOT(setDesiredEnergy(double)) ); connect( calibrateButton_, SIGNAL(clicked()), this, SLOT(onCalibrateButtonClicked()) ); // Initial settings. update(); // Current settings. setMono(mono); setCurrentScan(scan); }
void AMDataSourcesEditor::setCurrentScan(AMScan *scan) { if(!scan) setCurrentScan(-1); else setCurrentScan(model_->indexOf(scan)); }