1 /******************************************************************************************************
2  * (C) 2014 markummitchell@github.com. This file is part of Engauge Digitizer, which is released      *
3  * under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file *
4  * LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission.     *
5  ******************************************************************************************************/
6 
7 #ifndef DLG_SETTINGS_EXPORT_FORMAT_H
8 #define DLG_SETTINGS_EXPORT_FORMAT_H
9 
10 #include "DlgSettingsAbstractBase.h"
11 
12 class DocumentModelExportFormat;
13 class QCheckBox;
14 class QComboBox;
15 class QDoubleValidator;
16 class QGridLayout;
17 class QHBoxLayout;
18 class QLineEdit;
19 class QLabel;
20 class QListWidget;
21 class QPushButton;
22 class QRadioButton;
23 class QTabWidget;
24 class QTextEdit;
25 class QVBoxLayout;
26 
27 /// Dialog for editing exporting settings.
28 class DlgSettingsExportFormat : public DlgSettingsAbstractBase
29 {
30   Q_OBJECT;
31 
32 public:
33   /// Single constructor.
34   DlgSettingsExportFormat(MainWindow &mainWindow);
35   virtual ~DlgSettingsExportFormat();
36 
37   virtual void createOptionalSaveDefault (QHBoxLayout *layout);
38   virtual QWidget *createSubPanel ();
39   virtual void load (CmdMediator &cmdMediator);
40   virtual void setSmallDialogs (bool smallDialogs);
41 
42 private slots:
43   void slotDelimitersCommas();
44   void slotDelimitersSemicolons();
45   void slotDelimitersSpaces();
46   void slotDelimitersTabs();
47   void slotExclude();
48   void slotFileExtension(const QString &);
49   void slotFunctionsExtrapolateOutsideEndpoints(int);
50   void slotFunctionsLayoutAllCurves();
51   void slotFunctionsLayoutOneCurve();
52   void slotFunctionsPointsAllCurves();
53   void slotFunctionsPointsEvenlySpaced();
54   void slotFunctionsPointsEvenlySpacedInterval(const QString  &);
55   void slotFunctionsPointsEvenlySpacedIntervalUnits(const QString &);
56   void slotFunctionsPointsFirstCurve();
57   void slotFunctionsPointsGridLines();
58   void slotFunctionsPointsRaw();
59   void slotHeaderGnuplot();
60   void slotHeaderNone();
61   void slotHeaderSimple();
62   void slotInclude();
63   void slotListExcluded();
64   void slotListIncluded();
65   void slotLoadDefault();
66   void slotOverrideCsvTsv(int);
67   void slotRelationsPointsEvenlySpaced();
68   void slotRelationsPointsEvenlySpacedInterval(const QString &);
69   void slotRelationsPointsEvenlySpacedIntervalUnits(const QString &);
70   void slotRelationsPointsRaw();
71   void slotSaveDefault();
72   void slotTabChanged (int);
73   void slotXLabel (const QString &);
74 
75 protected:
76   virtual void handleOk ();
77 
78 private:
79 
80   void createCurveSelection (QGridLayout *layout, int &row);
81   void createDelimiters (QHBoxLayout *layoutMisc);
82   void createFileLayout (QHBoxLayout *layoutMisc);
83   void createFunctionsPointsSelection (QHBoxLayout *layout);
84   void createHeader (QHBoxLayout *layoutMisc);
85   void createPreview (QGridLayout *layout, int &row);
86   void createRelationsPointsSelection (QHBoxLayout *layout);
87   void createTabWidget (QGridLayout *layout,
88                         int &row);
89   void createXLabel (QGridLayout *layoutHeader,
90                      int colLabel);
91   QString exportedTextToExportedHtml (const QString &text,
92                                       const QString &color) const;
93   bool goodIntervalFunctions() const;
94   bool goodIntervalRelations() const;
95   void initializeIntervalConstraints ();
96   void updateControls();
97   void updateControlsUponLoad();
98   void updateIntervalConstraints(); // Update constraints on intervals to prevent overflows downstream (especially when value is temporarily 0)
99   void updatePreview();
100 
101   QTabWidget *m_tabWidget;
102 
103   QListWidget *m_listIncluded;
104   QListWidget *m_listExcluded;
105 
106   QPushButton *m_btnInclude;
107   QPushButton *m_btnExclude;
108 
109   QRadioButton *m_btnFunctionsPointsAllCurves;
110   QRadioButton *m_btnFunctionsPointsFirstCurve;
111   QRadioButton *m_btnFunctionsPointsEvenlySpaced;
112   QLineEdit *m_editFunctionsPointsEvenlySpacing;
113   QDoubleValidator *m_validatorFunctionsPointsEvenlySpacing;
114   QComboBox *m_cmbFunctionsPointsEvenlySpacingUnits;
115   QLabel *m_lblOverflowFunctions;
116   QRadioButton *m_btnFunctionsPointsGridLines;
117   QRadioButton *m_btnFunctionsPointsRaw;
118   QCheckBox *m_chkExtrapolateOutsideEndpoints;
119 
120   QRadioButton *m_btnCurvesLayoutAllCurves;
121   QRadioButton *m_btnCurvesLayoutOneCurve;
122 
123   QRadioButton *m_btnRelationsPointsEvenlySpaced;
124   QLineEdit *m_editRelationsPointsEvenlySpacing;
125   QDoubleValidator *m_validatorRelationsPointsEvenlySpacing;
126   QComboBox *m_cmbRelationsPointsEvenlySpacingUnits;
127   QLabel *m_lblOverflowRelations;
128   QRadioButton *m_btnRelationsPointsRaw;
129 
130   QRadioButton *m_btnDelimitersCommas;
131   QRadioButton *m_btnDelimitersSemicolons;
132   QRadioButton *m_btnDelimitersSpaces;
133   QRadioButton *m_btnDelimitersTabs;
134   QCheckBox *m_chkOverrideCsvTsv;
135 
136   QRadioButton *m_btnHeaderNone;
137   QRadioButton *m_btnHeaderSimple;
138   QRadioButton *m_btnHeaderGnuplot;
139 
140   QLineEdit *m_editXLabel;
141 
142   QTextEdit *m_editPreview;
143 
144   QComboBox *m_cmbFileExtension;
145 
146   QPushButton *m_btnSaveDefault;
147   QPushButton *m_btnLoadDefault;
148 
149   DocumentModelExportFormat *m_modelExportBefore;
150   DocumentModelExportFormat *m_modelExportAfter;
151 
152   // Safe values are computed for intervals and then applied according to the current settings. This prevents
153   // accidentally generating exports with thousands of points. That causes delays and can even overflow resources
154   // with a resulting crash
155   double m_minIntervalGraph;
156   double m_minIntervalScreen;
157 
158   bool m_haveFunction;
159   bool m_haveRelation;
160 };
161 
162 #endif // DLG_SETTINGS_EXPORT_FORMAT_H
163