MathPlot
MathPlotConfig.h
Go to the documentation of this file.
1 #ifndef __MathPlotConfig__
2 #define __MathPlotConfig__
3 
9 #include "MathPlotConfigBuilder.h"
10 
12 
13 #include <wx/colordlg.h>
14 #include <wx/fontdlg.h>
15 #include <wx/fileconf.h>
16 #include "mathplot.h"
17 #include <wx/valnum.h>
18 
19 #ifdef ENABLE_MP_NAMESPACE
20  namespace MathPlot {
21 #endif // ENABLE_MP_NAMESPACE
22 
31 
35 class MathPlotConfigSettings : public wxFileConfig
36 {
37  public:
42  MathPlotConfigSettings(const wxString& localFilename) :
43  wxFileConfig(wxEmptyString, wxEmptyString, localFilename) {}
44  virtual ~MathPlotConfigSettings() {}
45 
50  void SetSettings(wxWindow* win);
51 
56  void GetSettings(wxWindow* win);
57 
58  protected:
64  void DoPosition(bool set, wxWindow *win);
65 
73  void DoRecursiveSearch(bool set, wxWindow *win, const wxString &path = wxEmptyString, int level = 0);
74 };
75 
80 class wxMultiTextCtrlDialog: public wxDialog
81 {
82  public:
93  wxMultiTextCtrlDialog(wxWindow* parent, const wxString& title,
94  const wxString& message, long size, const wxString prompt[], double *values,
95  const wxPoint& pos = wxDefaultPosition)
96  {
97  Create(parent, title, message, size, prompt, values, pos);
98  }
99 
104  bool Create(wxWindow* parent, const wxString& title,
105  const wxString& message, long size, const wxString prompt[], double *values,
106  const wxPoint& pos = wxDefaultPosition);
107 
108  protected:
109  void OnOK(wxCommandEvent& event);
110  void OnCancel(wxCommandEvent& event);
111 
112  private:
113  std::vector<wxTextCtrl *> m_ctrls;
114  wxDECLARE_EVENT_TABLE();
115 };
116 
117 
121 typedef enum __ConfigPageIndex
122 {
123  mpcpiNone = -1,
124  mpcpiGeneral = 0,
125  mpcpiLegend,
126  mpcpiAxis,
127  mpcpiSeries,
128  mpcpiLines
130 
142 {
143  public:
150  MathPlotConfigDialog( wxWindow* parent );
152 
153  virtual ~MathPlotConfigDialog();
154 
159  void Initialize(mpConfigPageId id = mpcpiNone);
160 
165  void SelectChoiceSerie(unsigned int serie);
166 
173  void CreateSettingsFile(const wxString& filename, const wxString& path = wxEmptyString, bool apply = false);
174 
178  void ApplySettings(void);
179 
184  {
185  return m_settings;
186  }
187 
188  protected:
189  // Handlers for MathPlotConfigDialogBuilder events.
190  void OnnbConfigPageChanged( wxNotebookEvent& event );
191  void OnbFontClick( wxCommandEvent& event );
192  void OnbColorClick( wxCommandEvent& event );
193  void OnAxisSelect( wxCommandEvent& event );
194  void OnbAddAxisClick( wxCommandEvent& event );
195  void OnbDelAxisClick( wxCommandEvent& event );
196  void OncbAutoScaleClick( wxCommandEvent& event );
197  void OncbFormatSelect( wxCommandEvent& event );
198  void OnChoiceSeries( wxCommandEvent& event );
199  void OnbDelSeriesClick( wxCommandEvent& event );
200  void OncbSeriesShowNameClick( wxCommandEvent& event );
201  void OncbAutoStepClick( wxCommandEvent& event );
202  void OnChoiceLinesSelect( wxCommandEvent& event );
203  void OnbAddLinesClick( wxCommandEvent& event );
204  void OnbDelLinesClick( wxCommandEvent& event );
205  void OnbApplyClick( wxCommandEvent& event );
206  void OnbApplyAndFitClick( wxCommandEvent& event );
207  void OnQuit( wxCommandEvent& event );
208 
209  // Best place for this should be in MathPlotConfigBuilder but not possible with wxFormBuilder
210  // Margin validator
211  unsigned int int_top, int_bottom, int_left, int_right, int_extra;
212  // Scale validator
213  double scale_min, scale_max;
214  // Line position validator
215  double line_value;
216 
218  void CompleteInitialization(void);
219 
220  private:
221  mpWindow* m_plot;
222  MathPlotConfigSettings* m_settings;
223  wxButton* colourButton;
224  mpText* CurrentTitle;
225  mpInfoLegend* CurrentLegend;
226  mpInfoCoords* CurrentCoords;
227  mpScale* CurrentScale;
228  mpFunction* CurrentSerie;
229  mpLine* CurrentLine;
230  wxChoice* CurrentChoice;
231  bool fontTitleChanged;
232  bool fontLegendChanged;
233  bool fontAxisChanged;
234  int scale_offset;
235  bool CheckBar;
236  bool SerieVisibleChange;
237 
238  void Apply(int pageIndex, bool updateFont = false);
239  void UpdateSelectedSerie(void);
240  void UpdateSelectedLine(void);
241  void UpdateAxis(void);
242  void FillYAxisList(wxChoice* yChoice, bool clearChoice = true);
243  void UpdateSeriesStep(void);
244 
245  void DoButtonColour(wxButton* button, const wxColour& colour);
246  void DoApplyColour(const wxColour& colour);
247  void UpdateFont(mpLayer* layer, wxButton* button, bool get_set);
248  void SetFontChildren(wxButton* p, const wxFontData& fontdata);
249 
250  wxBrushStyle IdToBrushStyle(int id);
251  int BrushStyleToId(wxBrushStyle style);
252 };
253 
254 #ifdef ENABLE_MP_NAMESPACE
255  } // namespace MathPlot
256 #endif // ENABLE_MP_NAMESPACE
257 
258 #endif // __MathPlotConfig__
MathPlotConfigSettings * GetSettingsHandle(void)
Give access to m_settings if we want to save some others parameters.
Definition: MathPlotConfig.h:183
Class MathPlotConfigDialogBuilder.
Definition: MathPlotConfigBuilder.h:39
Abstract class providing a line.
Definition: mathplot.h:1795
Canvas for plotting mpLayer implementations.
Definition: mathplot.h:3361
Implement the legend to be added to the plot This layer allows you to add a legend to describe the pl...
Definition: mathplot.h:1493
Dialog box for configuring the plot&#39;s layer objects In this dialog, you can configure: ...
Definition: MathPlotConfig.h:154
MathPlotConfigSettings(const wxString &localFilename)
Manages the backup of configuration window data.
Definition: MathPlotConfig.h:42
#define WXDLLIMPEXP_MATHPLOT
Definition uses windows dll to export function.
Definition: mathplot.h:77
Helper class to save/restore configuration.
Definition: MathPlotConfig.h:49
wxMultiTextCtrlDialog(wxWindow *parent, const wxString &title, const wxString &message, long size, const wxString prompt[], double *values, const wxPoint &pos=wxDefaultPosition)
Constructor.
Definition: MathPlotConfig.h:93
Implements an overlay box which shows the mouse coordinates in plot units.
Definition: mathplot.h:1371
Plot layer implementing an abstract function plot class.
Definition: mathplot.h:1641
wxMultiTextCtrlDialog class A simple text control dialog window that support several text control ...
Definition: MathPlotConfig.h:94
enum __ConfigPageIndex mpConfigPageId
The list of index of the page of the config window.
Plot layer implementing an abstract scale ruler.
Definition: mathplot.h:2736
Plot layer implementing a text string.
Definition: mathplot.h:4738
Plot layer, abstract base class.
Definition: mathplot.h:867