BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
SavePlotAssistant.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/coregui/Views/IntensityDataWidgets/SavePlotAssistant.h
6 //! @brief Defines class SavePlotAssistant
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #ifndef BORNAGAIN_GUI_COREGUI_VIEWS_INTENSITYDATAWIDGETS_SAVEPLOTASSISTANT_H
16 #define BORNAGAIN_GUI_COREGUI_VIEWS_INTENSITYDATAWIDGETS_SAVEPLOTASSISTANT_H
17 
18 #include <QString>
19 #include <QVector>
20 
21 class QCustomPlot;
22 template <class T> class OutputData;
23 
24 //! Assistant class which contains all logic for saving IntensityData to various formats
25 //! from IntensityDataPlotWidget.
26 
28 public:
29  class Format {
30  public:
31  Format() {}
32  Format(const QString& file_extention, const QString& filter);
34  QString m_filter;
35  };
36 
37  void savePlot(const QString& dirname, QCustomPlot* plot, OutputData<double>* output_data);
38 
39 private:
40  void saveToFile(const QString& dirname, QCustomPlot* plot, OutputData<double>* output_data);
41  QString getFilterString() const;
42  QString composeFileName(const QString& fileName, const QString& filterName) const;
43  bool isValidExtension(const QString& fileName) const;
44  QString getExtensionFromFilterName(const QString& filterName) const;
45  bool isPngFile(const QString& fileName) const;
46  bool isJpgFile(const QString& fileName) const;
47  bool isPdfFile(const QString& fileName) const;
48  static QVector<Format> m_formats;
49 };
50 
51 #endif // BORNAGAIN_GUI_COREGUI_VIEWS_INTENSITYDATAWIDGETS_SAVEPLOTASSISTANT_H
Templated class to store data of type double or CumulativeValue in multi-dimensional space.
Definition: OutputData.h:32
Assistant class which contains all logic for saving IntensityData to various formats from IntensityDa...
QString getExtensionFromFilterName(const QString &filterName) const
bool isPdfFile(const QString &fileName) const
QString composeFileName(const QString &fileName, const QString &filterName) const
Compose file name to save plot from information provided by QFileDialog.
bool isJpgFile(const QString &fileName) const
QString getFilterString() const
Returns string contraining all defined filters in the format suitable for QFileDialog.
bool isPngFile(const QString &fileName) const
void saveToFile(const QString &dirname, QCustomPlot *plot, OutputData< double > *output_data)
static QVector< Format > m_formats
bool isValidExtension(const QString &fileName) const
void savePlot(const QString &dirname, QCustomPlot *plot, OutputData< double > *output_data)