wxMathPlot - Plot Library for wxWidgets Applications
MathPlotConfig.h
1/***************************************************************
2 * Name: MathPlotConfig.h (included from mathplot.h when MP_ENABLE_CONFIG defined)
3 * Purpose: Defines Application Frame
4 * Author: Lionel ()
5 * Created: 2021-01-24
6 * Last edit: 2026-07-01
7 * Copyright: Lionel ()
8 * License:
9 **************************************************************/
10
11#ifndef MATHPLOTCONFIG_H_INCLUDED
12#define MATHPLOTCONFIG_H_INCLUDED
13
14//(*Headers(MathPlotConfigDialog)
15#include <wx/button.h>
16#include <wx/checkbox.h>
17#include <wx/choice.h>
18#include <wx/dialog.h>
19#include <wx/notebook.h>
20#include <wx/panel.h>
21#include <wx/radiobut.h>
22#include <wx/sizer.h>
23#include <wx/spinctrl.h>
24#include <wx/statbox.h>
25#include <wx/stattext.h>
26#include <wx/textctrl.h>
27//*)
28
29#include <wx/colordlg.h>
30#include <wx/fontdlg.h>
31#include <wx/valnum.h>
32#include <wx/fileconf.h>
33
34#if defined(MP_ENABLE_NAMESPACE) || defined(ENABLE_MP_NAMESPACE)
35 namespace MathPlot {
36#endif // MP_ENABLE_NAMESPACE
37
46
50class MathPlotConfigSettings : public wxFileConfig
51{
52 public:
57 MathPlotConfigSettings(const wxString& localFilename) :
58 wxFileConfig(wxEmptyString, wxEmptyString, localFilename) {}
59 virtual ~MathPlotConfigSettings() {}
60
65 void SetSettings(wxWindow* win);
66
71 void GetSettings(wxWindow* win);
72
73 protected:
79 void DoPosition(bool set, wxWindow *win);
80
88 void DoRecursiveSearch(bool set, wxWindow *win, const wxString &path = wxEmptyString, int level = 0);
89};
90
95class wxMultiTextCtrlDialog: public wxDialog
96{
97 public:
108 wxMultiTextCtrlDialog(wxWindow* parent, const wxString& title,
109 const wxString& message, long size, const wxString prompt[], double *values,
110 const wxPoint& pos = wxDefaultPosition)
111 {
112 Create(parent, title, message, size, prompt, values, pos);
113 }
114
119 bool Create(wxWindow* parent, const wxString& title,
120 const wxString& message, long size, const wxString prompt[], double *values,
121 const wxPoint& pos = wxDefaultPosition);
122
123 protected:
124 void OnOK(wxCommandEvent& event);
125 void OnCancel(wxCommandEvent& event);
126
127 private:
128 std::vector<wxTextCtrl *> m_ctrls;
129 wxDECLARE_EVENT_TABLE();
130};
131
132
136typedef enum __ConfigPageIndex
137{
138 mpcpiNone = -1,
139 mpcpiGeneral = 0,
140 mpcpiLegend,
141 mpcpiAxis,
142 mpcpiSeries,
143 mpcpiLines
144} mpConfigPageId;
145
155class MathPlotConfigDialog: public wxDialog
156{
157 public:
158
164 MathPlotConfigDialog(wxWindow *parent, wxWindowID id = -1);
165 virtual ~MathPlotConfigDialog();
166
171 void Initialize(mpConfigPageId id = mpcpiNone);
172
177 void SelectChoiceSerie(unsigned int serie);
178
183 void SelectChoiceYAxis(int yAxisID);
184
185
192 void CreateSettingsFile(const wxString& filename, const wxString& path = wxEmptyString, bool apply = false);
193
197 void ApplySettings(void);
198
203 {
204 return m_settings;
205 }
206
207 private:
208
209 mpWindow* m_plot;
210 MathPlotConfigSettings* m_settings;
211 wxButton* colourButton;
212 mpText* CurrentTitle;
213 mpInfoLegend* CurrentLegend;
214 mpInfoCoords* CurrentCoords;
215 mpScale* CurrentScale;
216 mpFunction* CurrentSerie;
217 mpLine* CurrentLine;
218 wxChoice* CurrentChoice;
219 bool fontTitleChanged;
220 bool fontLegendChanged;
221 bool fontAxisChanged;
222 // Margin validator
223 unsigned int int_top, int_bottom, int_left, int_right, int_extra;
224 int scale_offset;
225 // Scale validator
226 double scale_min, scale_max;
227 // Line position validator
228 double line_value;
229 bool CheckBar;
230 bool SerieVisibleChange;
231
232 //(*Handlers(MathPlotConfigDialog)
233 void OnQuit(wxCommandEvent& event);
234 void OnnbConfigPageChanged(wxNotebookEvent& event);
235 void OnbColorClick(wxCommandEvent& event);
236 void OnChoiceSeries(wxCommandEvent& event);
237 void OnAxisSelect(wxCommandEvent& event);
238 void OncbFormatSelect(wxCommandEvent& event);
239 void OncbAutoScaleClick(wxCommandEvent& event);
240 void OnbApplyClick(wxCommandEvent& event);
241 void OnbFontClick(wxCommandEvent& event);
242 void OnbDelSeriesClick(wxCommandEvent& event);
243 void OnbAddAxisClick(wxCommandEvent& event);
244 void OnChoiceLinesSelect(wxCommandEvent& event);
245 void OnbAddLinesClick(wxCommandEvent& event);
246 void OnbDelLinesClick(wxCommandEvent& event);
247 void OnbDelAxisClick(wxCommandEvent& event);
248 void OncbSeriesShowNameClick(wxCommandEvent& event);
249 void OnbApplyAndFitClick(wxCommandEvent& event);
250 void OncbAutoStepClick(wxCommandEvent& event);
251 //*)
252
253 //(*Identifiers(MathPlotConfigDialog)
254 //*)
255
256 //(*Declarations(MathPlotConfigDialog)
257 wxBoxSizer* sizerAxis;
258 wxBoxSizer* sizerLines;
259 wxBoxSizer* sizerMain;
260 wxButton* bAddLines;
261 wxButton* bAddXAxis;
262 wxButton* bAddYAxis;
263 wxButton* bApply;
264 wxButton* bApplyAndFit;
265 wxButton* bAxisPenColor;
266 wxButton* bBGColor;
267 wxButton* bClose;
268 wxButton* bCoordBrushColor;
269 wxButton* bDelAxis;
270 wxButton* bDelLines;
271 wxButton* bDelSeries;
272 wxButton* bFontAxis;
273 wxButton* bFontLegend;
274 wxButton* bFontTitle;
275 wxButton* bGridPenColor;
276 wxButton* bLegendBrushColor;
277 wxButton* bLinesPenColor;
278 wxButton* bSeriesBrushColor;
279 wxButton* bSeriesPenColor;
280 wxCheckBox* cbAutoScale;
281 wxCheckBox* cbAutoStep;
282 wxCheckBox* cbAxisOutside;
283 wxCheckBox* cbAxisVisible;
284 wxCheckBox* cbBar;
285 wxCheckBox* cbCoordDefaultVisibility;
286 wxCheckBox* cbCoordOutside;
287 wxCheckBox* cbCoordVisible;
288 wxCheckBox* cbCoordinates;
289 wxCheckBox* cbDrawBox;
290 wxCheckBox* cbGridVisible;
291 wxCheckBox* cbLegendDefaultVisibility;
292 wxCheckBox* cbLegendVisible;
293 wxCheckBox* cbLinesOutside;
294 wxCheckBox* cbLinesShowName;
295 wxCheckBox* cbLinesVisible;
296 wxCheckBox* cbLogAxis;
297 wxCheckBox* cbMagnetize;
298 wxCheckBox* cbMouseCoordVisible;
299 wxCheckBox* cbSeriesContinuity;
300 wxCheckBox* cbSeriesLegend;
301 wxCheckBox* cbSeriesOutside;
302 wxCheckBox* cbSeriesShowName;
303 wxCheckBox* cbSeriesVisible;
304 wxCheckBox* cbShowSeriesValues;
305 wxCheckBox* cbTitleVisible;
306 wxCheckBox* cbTractable;
307 wxChoice* ChoiceAxis;
308 wxChoice* ChoiceLeftMouseAction;
309 wxChoice* ChoiceLines;
310 wxChoice* ChoiceLinesYAxis;
311 wxChoice* ChoiceSeries;
312 wxChoice* ChoiceSeriesYAxis;
313 wxChoice* cbAxisPenStyle;
314 wxChoice* cbAxisPenWidth;
315 wxChoice* cbAxisPosition;
316 wxChoice* cbCoord;
317 wxChoice* cbCoordBrushStyle;
318 wxChoice* cbFormat;
319 wxChoice* cbGridPenStyle;
320 wxChoice* cbGridPenWidth;
321 wxChoice* cbInfoCoordType;
322 wxChoice* cbLegendBrushStyle;
323 wxChoice* cbLegendDirection;
324 wxChoice* cbLegendPosition;
325 wxChoice* cbLegendStyle;
326 wxChoice* cbLinesPenStyle;
327 wxChoice* cbLinesPenWidth;
328 wxChoice* cbSeriesBrushStyle;
329 wxChoice* cbSeriesNamePosition;
330 wxChoice* cbSeriesPenStyle;
331 wxChoice* cbSeriesPenWidth;
332 wxChoice* cbSeriesSymbolType;
333 wxFlexGridSizer* sizerSeriesStep;
334 wxNotebook* nbConfig;
335 wxNotebook* nbPenAxisGrid;
336 wxPanel* Panel1;
337 wxPanel* Panel2;
338 wxPanel* Panel3;
339 wxPanel* Panel4;
340 wxPanel* Panel5;
341 wxPanel* Panel6;
342 wxPanel* Panel7;
343 wxPanel* pLines;
344 wxRadioButton* rbLinesDirection;
345 wxSpinCtrl* cbSeriesSymbolSize;
346 wxSpinCtrl* spinSeriesStep;
347 wxStaticText* StaticText10;
348 wxStaticText* StaticText11;
349 wxStaticText* StaticText12;
350 wxStaticText* StaticText13;
351 wxStaticText* StaticText14;
352 wxStaticText* StaticText15;
353 wxStaticText* StaticText16;
354 wxStaticText* StaticText17;
355 wxStaticText* StaticText19;
356 wxStaticText* StaticText1;
357 wxStaticText* StaticText20;
358 wxStaticText* StaticText21;
359 wxStaticText* StaticText22;
360 wxStaticText* StaticText23;
361 wxStaticText* StaticText24;
362 wxStaticText* StaticText25;
363 wxStaticText* StaticText26;
364 wxStaticText* StaticText27;
365 wxStaticText* StaticText28;
366 wxStaticText* StaticText29;
367 wxStaticText* StaticText2;
368 wxStaticText* StaticText30;
369 wxStaticText* StaticText31;
370 wxStaticText* StaticText32;
371 wxStaticText* StaticText33;
372 wxStaticText* StaticText34;
373 wxStaticText* StaticText35;
374 wxStaticText* StaticText36;
375 wxStaticText* StaticText37;
376 wxStaticText* StaticText38;
377 wxStaticText* StaticText39;
378 wxStaticText* StaticText3;
379 wxStaticText* StaticText40;
380 wxStaticText* StaticText41;
381 wxStaticText* StaticText42;
382 wxStaticText* StaticText43;
383 wxStaticText* StaticText44;
384 wxStaticText* StaticText45;
385 wxStaticText* StaticText4;
386 wxStaticText* StaticText5;
387 wxStaticText* StaticText6;
388 wxStaticText* StaticText7;
389 wxStaticText* StaticText8;
390 wxStaticText* StaticText9;
391 wxStaticText* stLinesYIndexLabel;
392 wxStaticText* stStepChoice;
393 wxTextCtrl* edAxisName;
394 wxTextCtrl* edExtraMargin;
395 wxTextCtrl* edFormat;
396 wxTextCtrl* edLinesName;
397 wxTextCtrl* edLinesValue;
398 wxTextCtrl* edMarginBottom;
399 wxTextCtrl* edMarginLeft;
400 wxTextCtrl* edMarginRight;
401 wxTextCtrl* edMarginTop;
402 wxTextCtrl* edScaleMax;
403 wxTextCtrl* edScaleMin;
404 wxTextCtrl* edSeriesName;
405 wxTextCtrl* edTitle;
406 //*)
407
408 void Apply(int pageIndex, bool updateFont = false);
409 void UpdateSelectedSerie(void);
410 void UpdateSelectedLine(void);
411 void UpdateAxis(void);
412 void FillYAxisList(wxChoice* yChoice, bool clearChoice = true);
413 void UpdateSeriesStep(void);
414
415 void DoButtonColour(wxButton* button, const wxColour& colour);
416 void DoApplyColour(const wxColour& colour);
417 void UpdateFont(mpLayer* layer, wxButton* button, bool get_set);
418 void SetFontChildren(wxButton* p, const wxFontData& fontdata);
419
420 wxBrushStyle IdToBrushStyle(int id);
421 int BrushStyleToId(wxBrushStyle style);
422
423 DECLARE_EVENT_TABLE()
424};
425
426#if defined(MP_ENABLE_NAMESPACE) || defined(ENABLE_MP_NAMESPACE)
427 } // namespace MathPlot
428#endif // MP_ENABLE_NAMESPACE
429
430#endif // MATHPLOTCONFIG_H_INCLUDED
Dialog box for configuring the plot's layer objects In this dialog, you can configure:
Definition MathPlotConfig.h:156
MathPlotConfigDialog(wxWindow *parent, wxWindowID id=-1)
Create a dialog window to configure the plot's layer objects.
void SelectChoiceYAxis(int yAxisID)
Select the Y axis having the given axis ID in the axis page.
void Initialize(mpConfigPageId id=mpcpiNone)
Initialize the dialog box by retrieving the layer properties.
void ApplySettings(void)
Apply the settings loaded in the configuration file.
void CreateSettingsFile(const wxString &filename, const wxString &path=wxEmptyString, bool apply=false)
Create a file to store the properties of mpTitle, mpInfoCoords and mpInfoLegend layers.
MathPlotConfigSettings * GetSettingsHandle(void)
Give access to m_settings if we want to save some others parameters.
Definition MathPlotConfig.h:202
void SelectChoiceSerie(unsigned int serie)
Select the series by number.
Helper class to save/restore configuration.
Definition MathPlotConfig.h:51
void DoRecursiveSearch(bool set, wxWindow *win, const wxString &path=wxEmptyString, int level=0)
Search recursively all the widgets then get/set parameters.
MathPlotConfigSettings(const wxString &localFilename)
Manages the backup of configuration window data.
Definition MathPlotConfig.h:57
void GetSettings(wxWindow *win)
Get the settings from the plot window.
void DoPosition(bool set, wxWindow *win)
Get/set the position of the config window in the screen.
void SetSettings(wxWindow *win)
Set the settings to the plot window.
Plot layer implementing an abstract function plot class.
Definition mathplot.h:1743
Implements an overlay box which shows the mouse coordinates in plot units.
Definition mathplot.h:1347
Implement the legend to be added to the plot This layer allows you to add a legend to describe the pl...
Definition mathplot.h:1479
Plot layer, abstract base class.
Definition mathplot.h:844
Abstract class providing a line.
Definition mathplot.h:1900
Plot layer implementing an abstract scale ruler.
Definition mathplot.h:2853
Plot layer implementing a text string.
Definition mathplot.h:4855
Canvas for plotting mpLayer implementations.
Definition mathplot.h:3504
wxMultiTextCtrlDialog class A simple text control dialog window that support several text control
Definition MathPlotConfig.h:96
void OnCancel(wxCommandEvent &event)
Cancel handler.
void OnOK(wxCommandEvent &event)
Ok handler. Data are transfered to values array.
wxMultiTextCtrlDialog(wxWindow *parent, const wxString &title, const wxString &message, long size, const wxString prompt[], double *values, const wxPoint &pos=wxDefaultPosition)
Constructor.
Definition MathPlotConfig.h:108
bool Create(wxWindow *parent, const wxString &title, const wxString &message, long size, const wxString prompt[], double *values, const wxPoint &pos=wxDefaultPosition)
Create the dialog window.
#define WXDLLIMPEXP_MATHPLOT
Definition uses windows dll to export function.
Definition mathplot.h:90