BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
GUI::Plot Namespace Reference

Functions

void savePlot (const QString &dirname, QCustomPlot *plot, Datafield *output_data)
 

Function Documentation

◆ savePlot()

void GUI::Plot::savePlot ( const QString &  dirname,
QCustomPlot *  plot,
Datafield *  output_data 
)

Definition at line 132 of file SavePlotAssistant.cpp.

134 {
135  QString selectedFilter("*.png");
136  QString defaultName = dirname + "/untitled";
137  QString fileName = QFileDialog::getSaveFileName(
138  nullptr, "Save Plot", defaultName, getFilterString(), &selectedFilter,
139  appSettings->useNativeFileDialog() ? QFileDialog::Options()
140  : QFileDialog::DontUseNativeDialog);
141 
142  QString nameToSave = composeFileName(fileName, selectedFilter);
143 
144  if (!nameToSave.isEmpty()) {
145  try {
146  saveToFile(nameToSave, plot, output_data);
147  } catch (const std::exception& ex) {
148  QString message = "Attempt to save file with the name '";
149  message.append(nameToSave);
150  message.append("' has failed with following error message\n\n");
151  message.append(QString::fromStdString(ex.what()));
152  QMessageBox::warning(nullptr, "Houston, we have a problem.", message);
153  }
154  }
155 }
ApplicationSettings * appSettings
global pointer to the instance
bool useNativeFileDialog() const
void warning(QWidget *parent, const QString &title, const QString &text, const QString &detailedText)
Definition: MessageBox.cpp:37

References appSettings, ApplicationSettings::useNativeFileDialog(), and GUI::View::Helpers::warning().

Referenced by IntensityDataCanvas::onSavePlotAction(), SpecularDataCanvas::onSavePlotAction(), and MaskEditorCanvas::onSavePlotRequest().

Here is the call graph for this function: