wxMathPlot - Plot Library for wxWidgets Applications
mathplot.h
Go to the documentation of this file.
1
2// Name: mathplot.h
3// Purpose: Framework for plotting in wxWindows
4// Original Author: David Schalig
5// Maintainer: Davide Rondini
6// Contributors: Jose Luis Blanco, Val Greene, Lionel Reynaud, Dave Nadler, MortenMacFly,
7// Oskar Waldemarsson (for multi Y axis and corrections)
8// Created: 21/07/2003
9// Last edit: 11/07/2026
10// Copyright: (c) David Schalig, Davide Rondini
11// Licence: wxWindows licence
13
14#ifndef MATHPLOT_H_INCLUDED
15#define MATHPLOT_H_INCLUDED
16
81// mathplot_EXPORTS definition uses windows dll to export function.
82// mathplot_EXPORTS will be defined by cmake
83#ifdef mathplot_EXPORTS
85 #define WXDLLIMPEXP_MATHPLOT WXEXPORT
87 #define WXDLLIMPEXP_DATA_MATHPLOT(type) WXEXPORT type
88#else // not making DLL
90 #define WXDLLIMPEXP_MATHPLOT
92 #define WXDLLIMPEXP_DATA_MATHPLOT(type) type
93#endif
94
95#if defined(__GNUG__) && !defined(__APPLE__) && !defined(__INTEL_CLANG_COMPILER)
96 #pragma interface "mathplot.h"
97#endif
98
99#include <cassert> // For assert debug message (assert is disabled if NDEBUG is defined)
100#include <vector>
101#include <map>
102#include <unordered_map>
103
104#include <optional>
106typedef std::optional<unsigned int> mpOptional_uint;
108typedef std::optional<int> mpOptional_int;
109
110// #include <wx/wx.h>
111#include <wx/defs.h>
112#include <wx/menu.h>
113#include <wx/scrolwin.h>
114#include <wx/event.h>
115#include <wx/dynarray.h>
116#include <wx/pen.h>
117#include <wx/dcmemory.h>
118#include <wx/string.h>
119#include <wx/print.h>
120#include <wx/image.h>
121#include <wx/intl.h>
122
123#include <cmath>
124#include <deque>
125#include <algorithm>
126
127#if defined(MP_USER_INCLUDE)
129 #define xstr(x) #x
131 #define str(x) xstr(x)
132 #define header MP_USER_INCLUDE.h
133 #include str(header)
134 #undef header
135#endif
136
137#if defined(MP_ENABLE_CONFIG) || defined(ENABLE_MP_CONFIG)
138 #include "MathPlotConfig.h"
139#endif // MP_ENABLE_CONFIG
140
145#if defined(MP_ENABLE_NAMESPACE) || defined(ENABLE_MP_NAMESPACE)
146 namespace MathPlot {
147#endif // MP_ENABLE_NAMESPACE
148
149#ifdef MP_ENABLE_DEBUG
150 // For memory leak debug
151 #ifdef _WIN32
152 #ifdef _DEBUG
153 #include <crtdbg.h>
154 #define DEBUG_NEW new(_NORMAL_BLOCK ,__FILE__, __LINE__)
155 #else
156 #define DEBUG_NEW new
157 #endif // _DEBUG
158 #endif // _WINDOWS
159#endif // MP_ENABLE_DEBUG
160
162#define MP_X_BORDER_SEPARATION 40
164#define MP_Y_BORDER_SEPARATION 60
165
167#define MP_X_LOCALTIME 0x10
169#define MP_X_UTCTIME 0x20
171#define MP_X_RAWTIME MP_X_UTCTIME
172
174#define MP_EPSILON 1e-30
176#define MP_ISNOTNULL(x) (std::fpclassify(x) != FP_ZERO)
177
179#define MP_EXTRA_MARGIN 8
180
182#define MP_ZOOM_AROUND_CENTER -1
183
184//-----------------------------------------------------------------------------
185// classes
186//-----------------------------------------------------------------------------
187
189#define DECLARE_DYNAMIC_CLASS_MATHPLOT(mp_class) wxDECLARE_DYNAMIC_CLASS(mp_class)
190
220
221#if defined(MP_ENABLE_CONFIG) || defined(ENABLE_MP_CONFIG)
223#endif // MP_ENABLE_CONFIG
224
226struct mpRect
227{
228 union {
229 struct
230 {
231 wxCoord startPx;
232 wxCoord startPy;
233 wxCoord endPx;
234 wxCoord endPy;
235 };
236 struct
237 {
238 wxCoord left;
239 wxCoord top;
240 wxCoord right;
241 wxCoord bottom;
242 };
243 struct
244 {
245 wxCoord x1;
246 wxCoord y1;
247 wxCoord x2;
248 wxCoord y2;
249 };
250 wxCoord tab[4];
251 };
256 wxRect GetRect(void) const
257 {
258 return wxRect(startPx, startPy, endPx - startPx, endPy - startPy);
259 }
260};
261static_assert(sizeof(mpRect) == 4 * sizeof(wxCoord));
262
268template<typename T>
270{
271 T min = 0;
272 T max = 0;
273
276 {
277 min = 0;
278 max = 0;
279 }
280
282 mpRange(T value1, T value2)
283 {
284 if (value1 < value2)
285 {
286 min = value1;
287 max = value2;
288 }
289 else
290 {
291 min = value2;
292 max = value1;
293 }
294 }
295
297 void Set(T value_)
298 {
299 min = value_;
300 max = value_;
301 }
302
304 void Set(T min_, T max_)
305 {
306 min = min_;
307 max = max_;
308 }
309
311 void SetMin(T min_)
312 {
313 min = min_;
314 if (max < min)
315 max = min;
316 }
317
319 void SetMax(T max_)
320 {
321 max = max_;
322 if (min > max)
323 min = max;
324 }
325
327 void Assign(T value1, T value2)
328 {
329 if (value1 < value2)
330 {
331 min = value1;
332 max = value2;
333 }
334 else
335 {
336 min = value2;
337 max = value1;
338 }
339 }
340
342 bool IsSet() const
343 {
344 return ((min != 0) || (max != 0));
345 }
346
351 void Update(T value)
352 {
353 if (value < min)
354 min = value;
355 else if (value > max)
356 max = value;
357 }
358
362 void Update(T min_, T max_)
363 {
364 if (min_ < min)
365 min = min_;
366 if (max_ > max)
367 max = max_;
368 }
369
372 void Update(mpRange range)
373 {
374 if (range.min < min)
375 min = range.min;
376 if (range.max > max)
377 max = range.max;
378 }
379
381 void Check(void)
382 {
383 if (min == max)
384 {
385 if (max > 0)
386 min = 0;
387 else
388 max = 0;
389 }
390 }
391
393 T Length(void) const
394 {
395 return max - min;
396 }
397
399 T GetCenter(void) const
400 {
401 return (min + max) / 2;
402 }
403
405 T GetMaxAbs(void) const
406 {
407 return std::max(fabs(min), fabs(max));
408 }
409
411 void ToLog(void)
412 {
413 min = (min > 0) ? log10(min) : 0;
414 max = (max > 0) ? log10(max) : 0;
415 }
416
418 bool PointIsInside(T point) const
419 {
420 return ((point >= min) && (point <= max));
421 }
422
423 #if (defined(__cplusplus) && (__cplusplus > 201703L)) // C++20 or newer
424 bool operator==(const mpRange&) const = default;
425 #else
427 bool operator==(const mpRange &other) const
428 {
429 return (min == other.min) && (max == other.max);
430 }
432 bool operator!=(const mpRange& other) const
433 {
434 return !(*this == other);
435 }
436 #endif
437};
438
444struct [[deprecated("Deprecated! No longer used as X and Y are now separated")]] mpFloatRect
445{
447 std::vector<mpRange<double>> y;
448
456
458 mpFloatRect() = delete;
459
466 bool PointIsInside(const double px, const double py, const size_t yAxisID = 0) const {
467 if (yAxisID < y.size())
468 {
469 if( (px < x.min || px > x.max) ||
470 (py < y[yAxisID].min || py > y[yAxisID].max))
471 {
472 return false;
473 }
474 }
475 else
476 {
477 return false;
478 }
479
480 return true;
481 }
482
489 void UpdateBoundingBoxToInclude(const double px, const double py, const size_t yAxisID = 0) {
490 assert(yAxisID < y.size());
491 if (yAxisID < y.size())
492 {
493 if (px < x.min ) x.min = px;
494 else if (px > x.max ) x.max = px;
495 if (py < y[yAxisID].min ) y[yAxisID].min = py;
496 else if (py > y[yAxisID].max ) y[yAxisID].max = py;
497 }
498 }
499
506 void InitializeBoundingBox(const double px, const double py, const size_t yAxisID = 0) {
507 assert(yAxisID < y.size());
508 if (yAxisID < y.size())
509 {
510 x.min = x.max = px;
511 y[yAxisID].min = y[yAxisID].max = py;
512 }
513 }
515 bool IsNotSet(mpWindow& w) const { const mpFloatRect def(w); return *this==def; }
517#if (defined(__cplusplus) && (__cplusplus > 201703L)) // C++ > C++17 (MSVC requires <AdditionalOptions>/Zc:__cplusplus</AdditionalOptions>
518 bool operator==(const mpFloatRect&) const = default;
519#else
520 // We compare with an epsilon precision
521 // NOTE: should be unnecessary as we are looking for any changes; normally this will be an exact match or a real change...
522 bool operator==(const mpFloatRect& rect) const
523 {
524 auto Same = [](const double a, const double b) {
525 return std::fabs(a - b) < MP_EPSILON;
526 };
527
528 // Compare scalar members
529 if (!Same(x.min, rect.x.min) || !Same(x.max, rect.x.max))
530 {
531 return false;
532 }
533
534 // Compare vector sizes
535 if (y.size() != rect.y.size())
536 {
537 return false;
538 }
539
540 // Compare each Y boundary
541 for (size_t i = 0; i < y.size(); ++i)
542 {
543 if (!Same(y[i].min, rect.y[i].min) ||
544 !Same(y[i].max, rect.y[i].max) )
545 {
546 return false;
547 }
548 }
549
550 return true;
551 }
552#endif
553};
554
561{
564
570 mpFloatRectSimple(const mpRange<double> x_, const mpRange<double> y_) : x(x_), y(y_) { };
571
577 bool PointIsInside(const double px, const double py) const {
578 return x.PointIsInside(px) && y.PointIsInside(py);
579 }
580
586 void UpdateBoundingBoxToInclude(const double px, const double py)
587 {
588 x.Update(px);
589 y.Update(py);
590 }
591
596 void InitializeBoundingBox(const double px, const double py)
597 {
598 x.Set(px, px);
599 y.Set(py, py);
600 }
601};
602
606{
607 wxColour colour;
608 wxRealPoint coords;
609};
610
614enum
615{
616 mpID_FIT = 2000,
624#if defined(MP_ENABLE_CONFIG) || defined(ENABLE_MP_CONFIG)
625 mpID_CONFIG,
626#endif // MP_ENABLE_CONFIG
631
646
656
666
675
683
690
702
703//-----------------------------------------------------------------------------
704// mpLayer sub_type values
705//-----------------------------------------------------------------------------
706
715
723
736
745
754
761
785
786//-----------------------------------------------------------------------------
787// mpLayer
788//-----------------------------------------------------------------------------
789
802
819
832
843class WXDLLIMPEXP_MATHPLOT mpLayer: public wxObject
844{
845 public:
851
852 ~mpLayer() override
853 {
854 ;
855 }
856
860 {
861 m_win = &w;
862 }
863
871 virtual bool HasBBox()
872 {
873 return true;
874 }
875
880 {
881 return m_type;
882 }
883
887 int GetLayerSubType() const
888 {
889 return m_subtype;
890 }
891
897 virtual bool IsLayerType(const mpLayerType typeOfInterest, int *subtype)
898 {
899 *subtype = m_subtype;
900 return (m_type == typeOfInterest);
901 }
902
906 virtual double GetMinX()
907 {
908 return -1.0;
909 }
910
914 virtual double GetMaxX()
915 {
916 return 1.0;
917 }
918
922 virtual double GetMinY()
923 {
924 return -1.0;
925 }
926
930 virtual double GetMaxY()
931 {
932 return 1.0;
933 }
934
976 void Plot(wxDC &dc, mpWindow &w);
977
981 void SetName(const wxString &name)
982 {
983 m_name = name;
984 }
985
989 const wxString& GetName() const
990 {
991 return m_name;
992 }
993
997 void SetFont(const wxFont &font)
998 {
999 m_font = font;
1000 }
1001
1005 const wxFont& GetFont() const
1006 {
1007 return m_font;
1008 }
1009
1013 void SetFontColour(const wxColour &colour)
1014 {
1015 m_fontcolour = colour;
1016 }
1017
1021 const wxColour& GetFontColour() const
1022 {
1023 return m_fontcolour;
1024 }
1025
1029 void SetPen(const wxPen &pen)
1030 {
1031 m_pen = pen;
1032 }
1033
1037 const wxPen& GetPen() const
1038 {
1039 return m_pen;
1040 }
1041
1044 void SetBrush(const wxBrush &brush)
1045 {
1046 if (brush == wxNullBrush)
1047 m_brush = *wxTRANSPARENT_BRUSH;
1048 else
1049 m_brush = brush;
1050 }
1051
1055 void SetBrush(const wxColour &colour, enum wxBrushStyle style = wxBRUSHSTYLE_SOLID)
1056 {
1057 m_brush.SetColour(colour);
1058 m_brush.SetStyle(style);
1059 }
1060
1063 const wxBrush& GetBrush() const
1064 {
1065 return m_brush;
1066 }
1067
1070 void SetShowName(const bool show)
1071 {
1072 m_showName = show;
1073 }
1074
1077 bool GetShowName() const
1078 {
1079 return m_showName;
1080 }
1081
1084 void SetDrawOutsideMargins(const bool drawModeOutside)
1085 {
1086 m_drawOutsideMargins = drawModeOutside;
1087 }
1088
1092 {
1093 return m_drawOutsideMargins;
1094 }
1095
1100 wxBitmap GetColourSquare(int side = 16);
1101
1104 bool IsVisible() const
1105 {
1106 return m_visible;
1107 }
1108
1111 virtual void SetVisible(const bool show)
1112 {
1113 m_visible = show;
1114 }
1115
1118 bool IsTractable() const
1119 {
1120 return m_tractable;
1121 }
1122
1125 virtual void SetTractable(const bool track)
1126 {
1127 m_tractable = track;
1128 }
1129
1132 void SetAlign(const int align)
1133 {
1134 m_flags = align;
1135 }
1136
1139 int GetAlign() const
1140 {
1141 return m_flags;
1142 }
1143
1146 void SetCanDelete(const bool canDelete)
1147 {
1148 m_CanDelete = canDelete;
1149 }
1150
1153 bool GetCanDelete(void) const
1154 {
1155 return m_CanDelete;
1156 }
1157
1161 {
1162 return m_ZIndex;
1163 }
1164
1165 protected:
1169 wxFont m_font;
1170 wxColour m_fontcolour;
1171 wxPen m_pen;
1172 wxBrush m_brush;
1173 wxString m_name;
1182
1185 void UpdateContext(wxDC &dc) const;
1186
1191 virtual void DoPlot(wxDC &dc, mpWindow &w) = 0;
1192
1197 virtual bool DoBeforePlot()
1198 {
1199 return true;
1200 }
1201
1208 void CheckLog(double *x, double *y, int yAxisID);
1209
1210 private:
1211 bool m_busy;
1212 mpLayer() = delete; // default ctor not implemented/permitted
1213
1215};
1216
1217//-----------------------------------------------------------------------------
1218// mpInfoLayer
1219//-----------------------------------------------------------------------------
1220
1227{
1228 public:
1231
1236 mpInfoLayer(wxPoint pos, const wxBrush &brush = *wxTRANSPARENT_BRUSH, mpLocation location = mpMarginUser);
1237
1239 ~mpInfoLayer() override;
1240
1243 void SetVisible(bool show) override;
1244
1249 virtual void UpdateInfo(mpWindow &w, wxEvent &event);
1250
1253 bool HasBBox() override
1254 {
1255 return false;
1256 }
1257
1260 [[deprecated("Use Show() instead")]]
1261 virtual void ErasePlot(wxDC&, mpWindow&) {};
1262
1266 virtual bool Inside(const wxPoint &point);
1267
1271 virtual void Move(wxPoint delta, mpWindow &w);
1272
1274 virtual void UpdateReference();
1275
1278 wxPoint GetPosition() const
1279 {
1280 return m_dim.GetPosition();
1281 }
1282
1285 void SetInitialPosition(const wxPoint pos)
1286 {
1287 m_relX = pos.x / 100.0;
1288 m_relY = pos.y / 100.0;
1289 }
1290
1293 wxSize GetSize() const
1294 {
1295 return m_dim.GetSize();
1296 }
1297
1300 const wxRect& GetRectangle() const
1301 {
1302 return m_dim;
1303 }
1304
1307 void SetLocation(const mpLocation location)
1308 {
1309 m_location = location;
1310 }
1311
1315 {
1316 return m_location;
1317 }
1318
1319 protected:
1320 wxRect m_dim;
1321 wxBitmap* m_info_bmp;
1322 wxPoint m_reference;
1323 double m_relX;
1324 double m_relY;
1326
1331 void DoPlot(wxDC &dc, mpWindow &w) override;
1332
1335 void SetInfoRectangle(mpWindow &w, int width = 0, int height = 0);
1336
1337 private:
1338
1340};
1341
1347{
1348 public:
1351
1354
1359 mpInfoCoords(wxPoint pos, const wxBrush &brush = *wxTRANSPARENT_BRUSH, mpLocation location = mpMarginUser);
1360
1362 ~mpInfoCoords() override
1363 {
1364 ;
1365 }
1366
1374
1378 void UpdateInfo(mpWindow &w, wxEvent &event) override;
1379
1382 [[deprecated("Use Show() instead")]]
1383 void ErasePlot(wxDC&, mpWindow&) override {};
1384
1387 void Show(const bool show)
1388 {
1389 m_show = show;
1390 }
1391
1394 bool IsShown() const
1395 {
1396 return m_show;
1397 }
1398
1403 bool ShouldBeShown(const wxRect plotArea, const wxPoint mousePos) const
1404 {
1405 return IsVisible() && (GetDrawOutsideMargins() || plotArea.Contains(mousePos));
1406 }
1407
1411 void SetLabelMode(const mpLabelType mode, const unsigned int time_conv = MP_X_RAWTIME)
1412 {
1413 m_labelType = mode;
1414 m_timeConv = time_conv;
1415 }
1416
1419 [[deprecated("Deprecated, use SetInfoCoordType instead")]]
1420 void SetSeriesCoord(const bool show)
1421 {
1422 m_infoCoordType = show ? infoCoord_closestSeries : infoCoord_axis;
1423 }
1424
1429 {
1430 m_infoCoordType = type;
1431 }
1432
1437 {
1438 return m_infoCoordType;
1439 }
1440
1446 virtual wxString GetInfoCoordsText(mpWindow &w, double xVal, std::unordered_map<int, double> yValList);
1447
1451 void DrawContent(wxDC &dc, mpWindow &w);
1452
1453 protected:
1454 bool m_show;
1455 wxString m_content;
1457 unsigned int m_timeConv;
1458 wxCoord m_mouseX;
1459 wxCoord m_mouseY;
1461 std::vector<wxColor> m_seriesColors;
1462
1467 void DoPlot(wxDC &dc, mpWindow &w) override;
1468
1469 private:
1470
1472};
1473
1479{
1480 public:
1483
1489 mpInfoLegend(wxPoint pos, const wxBrush &brush = *wxWHITE_BRUSH, mpLocation location = mpMarginUser);
1490
1492 ~mpInfoLegend() override {}
1493
1497 {
1498 m_item_mode = mode;
1499 m_needs_update = true;
1500 }
1501
1504 {
1505 return m_item_mode;
1506 }
1507
1511 {
1512 m_item_direction = mode;
1513 m_needs_update = true;
1514 }
1515
1518 {
1519 return m_item_direction;
1520 }
1521
1524 {
1525 m_needs_update = true;
1526 }
1527
1530 void ShowDraggedSeries(const bool active)
1531 {
1532 m_showDraggedSeries = active;
1533 }
1534
1538 {
1539 return m_showDraggedSeries;
1540 }
1541
1544 void EnableSeriesValues(const bool enable)
1545 {
1546 m_enableSeriesValues = enable;
1547 m_maxSeriesValueWidth = 0;
1548 }
1549
1553 {
1554 return m_enableSeriesValues;
1555 }
1556
1560 bool SeriesValuesShouldBeShown(const wxRect plotArea, const wxPoint mousePos) const
1561 {
1562 return m_enableSeriesValues && plotArea.Contains(mousePos);
1563 }
1564
1567 void ShowSeriesValues(const bool show)
1568 {
1569 m_showSeriesValues = show;
1570 }
1571
1575 {
1576 return m_showSeriesValues && IsVisible();
1577 }
1578
1581 void IndicateSeriesIntersection(const bool enable)
1582 {
1583 m_indicateSeriesIntersection = enable;
1584 }
1585
1589
1592 void SetVerticalCursorFixed(double posX);
1593
1596 {
1598 CursorMode_fixed
1600
1604 {
1605 return m_verticalCursorMode;
1606 }
1607
1611 wxCoord GetVerticalCursorX() const;
1612
1618 int GetLegendHitRegion(wxPoint mousePos);
1619
1626 void DrawDraggedSeries(wxDC& dc, mpWindow &w) const;
1627
1631 void DrawContent(wxDC &dc, mpWindow &w);
1632
1636
1638 enum HitCode : int
1639 {
1640 HitNone = -1,
1641 HitHeader = -2
1642 };
1643
1644 mpFunction* m_selectedSeries = nullptr;
1645 mpOptional_int m_lastHoveredAxisID = std::nullopt;
1646
1647 protected:
1651 wxString m_headerString = wxString::FromUTF8("≡");
1652
1657 void DoPlot(wxDC &dc, mpWindow &w) override;
1658
1659 private:
1661 struct LegendDetail
1662 {
1663 unsigned int layerIdx;
1664 wxCoord legendEnd;
1666 };
1667 std::vector<LegendDetail> m_LegendDetailList;
1668 wxCoord m_headerEnd;
1669 bool m_needs_update;
1670 int m_maxSeriesValueWidth;
1671 bool m_enableSeriesValues;
1672 bool m_showSeriesValues;
1673 bool m_indicateSeriesIntersection;
1674 VerticalCursorMode m_verticalCursorMode;
1675 double m_verticalCursorPosX;
1676
1687 void UpdateBitmap(wxDC &dc, mpWindow &w);
1688
1697 int GetMaxLabelWidth(wxDC &dc, mpWindow &w) const;
1698
1719 int DrawSeriesValue(wxDC& dc, mpWindow& w, mpFunction& function, int posX, int posY, int labelHeight, int labelWidth, int maxLabelWidth);
1720
1725 void DrawVerticalCursor(wxDC &dc, mpWindow &w);
1726
1727 private:
1729};
1730
1731//-----------------------------------------------------------------------------
1732// mpLayer implementations - functions
1733//-----------------------------------------------------------------------------
1734
1735
1743{
1744 public:
1750 mpFunction(mpLayerType layerType = mpLAYER_PLOT, const wxString &name = wxEmptyString, unsigned int yAxisID = 0);
1751
1755 void SetContinuity(const bool continuity)
1756 {
1757 m_continuous = continuity;
1758 }
1759
1763 bool GetContinuity() const
1764 {
1765 return m_continuous;
1766 }
1767
1770 void SetStep(const unsigned int step)
1771 {
1772 m_step = step;
1773 }
1774
1777 unsigned int GetStep() const
1778 {
1779 return m_step;
1780 }
1781
1784 void SetSymbol(const mpSymbol symbol)
1785 {
1786 m_symbol = symbol;
1787 }
1788
1792 {
1793 return m_symbol;
1794 }
1795
1798 void SetSymbolSize(const int size)
1799 {
1800 m_symbolSize = size;
1801 }
1802
1805 int GetSymbolSize() const
1806 {
1807 return m_symbolSize;
1808 }
1809
1813 virtual bool DrawSymbol(wxDC &dc, wxCoord x, wxCoord y);
1814
1818 std::optional<double> GetSeriesValue(double xValue);
1819
1823 int GetYAxisID() const
1824 {
1825 return m_yAxisID;
1826 }
1827
1832 void SetYAxisID(const unsigned int yAxisID)
1833 {
1834 m_yAxisID = yAxisID;
1835 }
1836
1840 void SetLegendIsAlwaysVisible(const bool alwaysVisible)
1841 {
1842 m_LegendIsAlwaysVisible = alwaysVisible;
1843 }
1844
1849 {
1850 return m_LegendIsAlwaysVisible;
1851 }
1852
1856 void SetAutoStep(const bool enable)
1857 {
1858 m_autoStep = enable;
1859 }
1860
1863 bool GetAutoStep() const
1864 {
1865 return m_autoStep;
1866 }
1867
1871 void SetMaxNOfPoints(const size_t nOfPoints)
1872 {
1873 m_maxNOfPoints = nOfPoints;
1874 }
1875
1878 size_t GetMaxNOfPoints() const
1879 {
1880 return m_maxNOfPoints;
1881 }
1882
1883 protected:
1887 unsigned int m_step;
1892
1893 private:
1895};
1896
1900{
1901 public:
1908 mpLine(double value, const wxPen &pen = *wxGREEN_PEN);
1909
1910 // We don't want to include line (horizontal or vertical) in BBox computation
1911 bool HasBBox() override
1912 {
1913 return false;
1914 }
1915
1919 double GetValue() const
1920 {
1921 return m_value;
1922 }
1923
1927 void SetValue(const double value)
1928 {
1929 m_value = value;
1930 }
1931
1935 bool IsHorizontal(void) const
1936 {
1937 return m_IsHorizontal;
1938 }
1939
1940 protected:
1941 double m_value;
1943
1944 private:
1946};
1947
1951{
1952 public:
1959 mpHorizontalLine(double yvalue, const wxPen &pen = *wxGREEN_PEN, unsigned int yAxisID = 0);
1960
1964 void SetYValue(const double yvalue)
1965 {
1966 SetValue(yvalue);
1967 }
1968
1969 protected:
1970
1971 void DoPlot(wxDC &dc, mpWindow &w) override;
1972
1973 private:
1975};
1976
1980{
1981 public:
1987 mpVerticalLine(double xvalue, const wxPen &pen = *wxGREEN_PEN);
1988
1992 void SetXValue(const double xvalue)
1993 {
1994 SetValue(xvalue);
1995 }
1996
1997 protected:
1998
1999 void DoPlot(wxDC &dc, mpWindow &w) override;
2000
2005 bool DoBeforePlot() override
2006 {
2007 return true;
2008 }
2009
2010 private:
2012};
2013
2021{
2022 public:
2027 mpFX(const wxString &name = wxEmptyString, int flags = mpALIGN_RIGHT, unsigned int yAxisID = 0);
2028
2034 virtual double GetY(double x) = 0;
2035
2042 double DoGetY(double x);
2043
2048 void DefineDoGetY(void);
2049
2050 protected:
2051
2052 double (mpFX::*pDoGetY)(double x);
2053
2058 void DoPlot(wxDC &dc, mpWindow &w) override;
2059
2064 double NormalDoGetY(double x);
2065
2070 double LogDoGetY(double x);
2071
2072 private:
2074};
2075
2083{
2084 public:
2089 mpFY(const wxString &name = wxEmptyString, int flags = mpALIGN_TOP, unsigned int yAxisID = 0);
2090
2096 virtual double GetX(double y) = 0;
2097
2104 double DoGetX(double y);
2105
2110 void DefineDoGetX(void);
2111
2112 protected:
2113
2114 double (mpFY::*pDoGetX)(double y);
2115
2120 void DoPlot(wxDC &dc, mpWindow &w) override;
2121
2126 double NormalDoGetX(double y);
2127
2132 double LogDoGetX(double y);
2133
2134 private:
2136};
2137
2148{
2149 public:
2155 mpFXY(const wxString &name = wxEmptyString, int flags = mpALIGN_SW, bool viewAsBar = false, unsigned int yAxisID = 0);
2156
2160 virtual void Rewind() = 0;
2161
2165 virtual void Clear()
2166 {
2167 ;
2168 }
2169
2173 virtual size_t GetSize()
2174 {
2175 return 0;
2176 }
2177
2184 virtual bool GetNextXY(double *x, double *y) = 0;
2185
2192 bool DoGetNextXY(double *x, double *y);
2193
2198 void SetViewMode(bool asBar);
2199
2204 int GetBarWidth(void) const
2205 {
2206 return m_BarWidth;
2207 }
2208
2213 bool ViewAsBar(void) const
2214 {
2215 return m_ViewAsBar;
2216 }
2217
2218 protected:
2219
2220 // Data to calculate label positioning
2223
2224 // Min delta between 2 x coordinate (used for view as bar)
2225 double m_deltaX;
2226 double m_deltaY;
2227
2229
2230 bool m_ViewAsBar = false;
2231
2238 void DoPlot(wxDC &dc, mpWindow &w) override;
2239
2244 void UpdateViewBoundary(wxCoord xnew, wxCoord ynew);
2245
2246 private:
2248};
2249
2250//-----------------------------------------------------------------------------
2251// mpFXYVector - provided by Jose Luis Blanco
2252//-----------------------------------------------------------------------------
2253
2274{
2275 public:
2281 mpFXYVector(const wxString &name = wxEmptyString, int flags = mpALIGN_SW, bool viewAsBar = false, unsigned int yAxisID = 0);
2282
2285 ~mpFXYVector() override
2286 {
2287 Clear();
2288 }
2289
2294 void SetData(const std::vector<double> &xs, const std::vector<double> &ys);
2295
2299 void Clear() override;
2300
2305 size_t GetSize() override
2306 {
2307 return m_xs.size();
2308 }
2309
2311 const std::vector<double>& GetXData() const
2312 {
2313 return m_xs;
2314 }
2315
2317 const std::vector<double>& GetYData() const
2318 {
2319 return m_ys;
2320 }
2321
2329 bool AddData(double x, double y, bool updatePlot);
2330
2337 void SetReserve(const int reserve)
2338 {
2339 m_reserveXY = reserve;
2340 m_xs.reserve(m_reserveXY);
2341 m_ys.reserve(m_reserveXY);
2342 }
2343
2347 int GetReserve() const
2348 {
2349 return m_reserveXY;
2350 }
2351
2352 protected:
2353 std::vector<double> m_xs;
2354 std::vector<double> m_ys;
2357 size_t m_index;
2358 size_t m_endIndex;
2360 double m_lastX;
2362 double m_lastY;
2363
2368 void Rewind() override;
2369
2376 bool GetNextXY(double *x, double *y) override;
2377
2382 void DrawAddedPoint(double x, double y);
2383
2386 double GetMinX()override
2387 {
2388 if (m_ViewAsBar)
2389 {
2390 // Make extra space for outer bars
2391 return m_rangeX.min - (m_deltaX / 2);
2392 }
2393 else
2394 {
2395 return m_rangeX.min;
2396 }
2397 }
2398
2401 double GetMinY() override
2402 {
2403 return m_rangeY.min;
2404 }
2405
2408 double GetMaxX() override
2409 {
2410 if(m_ViewAsBar)
2411 {
2412 // Make extra space for outer bars
2413 return m_rangeX.max + (m_deltaX / 2);
2414 }
2415 else
2416 {
2417 return m_rangeX.max;
2418 }
2419 }
2420
2423 double GetMaxY() override
2424 {
2425 return m_rangeY.max;
2426 }
2427
2428 private:
2431 void First_Point(double x, double y);
2432
2435 static void Check_Limit(double val, mpRange<double> *range, double *last, double *delta);
2436
2438};
2439
2449{
2450 public:
2454 mpProfile(const wxString &name = wxEmptyString, int flags = mpALIGN_TOP);
2455
2461 virtual double GetY(double x) = 0;
2462
2463 protected:
2464
2469 void DoPlot(wxDC &dc, mpWindow &w) override;
2470
2471 private:
2473};
2474
2479class mpFXGeneric: public mpFX
2480{
2481 public:
2486 mpFXGeneric(const wxString &name = wxT("Generic FX function"), const int flags = mpALIGN_LEFT, const unsigned int yAxisID = 0) :
2487 mpFX(name, flags, yAxisID)
2488 {
2489 const wxPen FXpen(*wxBLUE, 1, wxPENSTYLE_SOLID);
2490 SetDrawOutsideMargins(false);
2491 SetContinuity(true);
2492 SetPen(FXpen);
2493 SetStep(8); // Draw one point over eight
2494 }
2495
2500 double GetY(const double x) override
2501 {
2502 double y;
2503 try
2504 {
2505 y = ComputeY(x);
2506 }
2507 catch (...)
2508 {
2509 y = 0;
2510 }
2511 m_rangeY.Update(y);
2512 return y;
2513 }
2514
2519 double GetMinY() override
2520 {
2521 return m_rangeY.min;
2522 }
2523
2528 double GetMaxY() override
2529 {
2530 return m_rangeY.max;
2531 }
2532
2533 protected:
2535
2541 virtual double ComputeY(double x) = 0;
2542
2543 private:
2545};
2546
2552{
2553 public:
2559 mpGaussian(const double mu, const double sigma) :
2560 mpFXGeneric(wxT("Gaussian"), mpALIGN_LEFT)
2561 {
2562 m_mu = mu;
2563 m_sigma = sigma;
2564 m_variance = sigma * sigma;
2565 m_const = 1.0 / sqrt(2.0 * M_PI * m_variance);
2566 }
2567
2568 protected:
2569 double m_mu;
2570 double m_sigma;
2571 double m_variance;
2572 double m_const;
2573
2574 double ComputeY(const double x) override
2575 {
2576 return m_const * exp(-(x - m_mu) * (x - m_mu) / (2.0 * m_variance));
2577 }
2578
2579 private:
2581};
2582
2588{
2589 public:
2595 mpNormal(const double mu, const double sigma) :
2596 mpFXGeneric(wxT("Normal"), mpALIGN_LEFT)
2597 {
2598 m_mu = mu;
2599 m_sigma = sigma;
2600 m_variance = sigma * sigma;
2601 m_const = 1.0 / (m_variance * sqrt(2.0 * M_PI));
2602 }
2603
2604 protected:
2605 double m_mu;
2606 double m_sigma;
2607 double m_variance;
2608 double m_const;
2609
2610 double ComputeY(const double x) override
2611 {
2612 if (x < 0)
2613 return 0.0;
2614 else
2615 {
2616 const double tmp = log(x) - m_mu;
2617 return m_const * exp(-tmp * tmp / (2.0 * m_variance)) / x;
2618 }
2619 }
2620
2621 private:
2623};
2624
2625//-----------------------------------------------------------------------------
2626// mpChart
2627//-----------------------------------------------------------------------------
2631{
2632 public:
2634 mpChart(const wxString &name = wxEmptyString);
2635
2637 ~mpChart() override
2638 {
2639 Clear();
2640 }
2641
2644 void SetChartValues(const std::vector<double> &data);
2645
2648 void SetChartLabels(const std::vector<std::string> &labelArray);
2649
2654 void AddData(const double &data, const std::string &label);
2655
2659 virtual void Clear();
2660
2661 bool HasBBox() override
2662 {
2663 return (values.size() > 0);
2664 }
2665
2666 protected:
2667 std::vector<double> values;
2668 std::vector<std::string> labels;
2669
2672
2673 private:
2675};
2676
2677//-----------------------------------------------------------------------------
2678// mpBarChart - provided by Jose Davide Rondini
2679//-----------------------------------------------------------------------------
2680/* Defines for bar charts label positioning. */
2681#define mpBAR_NONE 0
2682#define mpBAR_AXIS_H 1
2683#define mpBAR_AXIS_V 2
2684#define mpBAR_INSIDE 3
2685#define mpBAR_TOP 4
2686
2690{
2691 public:
2693 mpBarChart(const wxString &name = wxEmptyString, double width = 0.5);
2694
2696 ~mpBarChart() override
2697 {
2698 Clear();
2699 }
2700
2702 void SetBarColour(const wxColour &colour);
2703
2705 void SetColumnWidth(const double colWidth)
2706 {
2707 m_width = colWidth;
2708 }
2709
2711 void SetBarLabelPosition(int position);
2712
2716 double GetMinX() override;
2717
2721 double GetMaxX() override;
2722
2726 double GetMinY() override;
2727
2731 double GetMaxY() override;
2732
2733 protected:
2734
2735 double m_width;
2736 wxColour m_barColour;
2739
2744 void DoPlot(wxDC &dc, mpWindow &w) override;
2745
2746 private:
2748};
2749
2754{
2755 public:
2759 mpPieChart(const wxString &name = wxEmptyString, double radius = 20);
2760
2762 ~mpPieChart() override
2763 {
2764 Clear();
2765 colours.clear();
2766 }
2767
2771 void SetCenter(const wxPoint center)
2772 {
2773 m_center = center;
2774 }
2775
2779 wxPoint GetCenter(void) const
2780 {
2781 return m_center;
2782 }
2783
2787 void SetPieColours(const std::vector<wxColour> &colourArray);
2788
2792 double GetMinX() override
2793 {
2794 return m_center.x - m_radius;
2795 }
2796
2800 double GetMaxX() override
2801 {
2802 return m_center.x + m_radius;
2803 }
2804
2808 double GetMinY() override
2809 {
2810 return m_center.y - m_radius;
2811 }
2812
2816 double GetMaxY() override
2817 {
2818 return m_center.y + m_radius;
2819 }
2820
2821 protected:
2822
2823 double m_radius;
2824 wxPoint m_center;
2825 std::vector<wxColour> colours;
2826
2831 void DoPlot(wxDC &dc, mpWindow &w) override;
2832
2834 const wxColour& GetColour(unsigned int id);
2835
2836 private:
2838};
2839
2842//-----------------------------------------------------------------------------
2843// mpLayer implementations - furniture (scales, ...)
2844//-----------------------------------------------------------------------------
2853{
2854 public:
2861 {
2862 double step = 0.0;
2863 double maxAxisValue = 0.0;
2864 bool UseScientific = false;
2865 int SignificantDigits = 0;
2866 int DecimalDigits = 0;
2867 double EpsilonScale = 0.0;
2868 };
2869
2877 mpScale(const wxString &name, int flags, bool grids, mpLabelType labelType = mpLabel_AUTO, mpOptional_uint axisID = std::nullopt);
2878
2882 bool HasBBox() override
2883 {
2884 return false;
2885 }
2886
2890 int GetAxisID(void) const
2891 {
2892 return m_axisID;
2893 }
2894
2899 void SetAxisID(const unsigned int yAxisID)
2900 {
2901 m_axisID = yAxisID;
2902 }
2903
2906 void ShowTicks(const bool ticks)
2907 {
2908 m_ticks = ticks;
2909 }
2910
2913 bool GetShowTicks() const
2914 {
2915 return m_ticks;
2916 }
2917
2920 void ShowGrids(const bool grids)
2921 {
2922 m_grids = grids;
2923 }
2924
2927 bool GetShowGrids() const
2928 {
2929 return m_grids;
2930 }
2931
2936 void SetLabelFormat(const wxString &format, const bool updateLabelMode = false)
2937 {
2938 m_labelFormat = format;
2939 if (updateLabelMode)
2940 m_labelType = mpLabel_USER;
2941 }
2942
2946 {
2947 return m_labelType;
2948 }
2949
2953 void SetLabelMode(const mpLabelType mode, const unsigned int time_conv = MP_X_RAWTIME)
2954 {
2955 m_labelType = mode;
2956 m_timeConv = time_conv;
2957 }
2958
2961 const wxString& GetLabelFormat() const
2962 {
2963 return m_labelFormat;
2964 }
2965
2969 void SetGridPen(const wxPen &pen)
2970 {
2971 m_gridpen = pen;
2972 }
2973
2977 const wxPen& GetGridPen() const
2978 {
2979 return m_gridpen;
2980 }
2981
2985 void SetAuto(const bool automaticScalingIsEnabled)
2986 {
2987 m_auto = automaticScalingIsEnabled;
2988 }
2989
2993 bool GetAuto() const
2994 {
2995 return m_auto;
2996 }
2997
3001 void SetMinScale(const double min)
3002 {
3003 m_axisRange.SetMin(min);
3004 }
3005
3009 double GetMinScale() const
3010 {
3011 return m_axisRange.min;
3012 }
3013
3017 void SetMaxScale(const double max)
3018 {
3019 m_axisRange.SetMax(max);
3020 }
3021
3025 double GetMaxScale() const
3026 {
3027 return m_axisRange.max;
3028 }
3029
3034 void SetScale(const double min, const double max)
3035 {
3036 m_axisRange.Set(min, max);
3037 }
3038
3043 void GetScale(double *min, double *max) const
3044 {
3045 *min = m_axisRange.min;
3046 *max = m_axisRange.max;
3047 }
3048
3052 void SetScale(const mpRange<double> range)
3053 {
3054 m_axisRange = range;
3055 }
3056
3061 {
3062 return mpRange<double>(m_axisRange);
3063 }
3064
3068 void SetHovering(const bool hover)
3069 {
3070 m_hover = hover;
3071 }
3072
3076 virtual bool IsLogAxis()
3077 {
3078 return m_isLog;
3079 }
3080
3084 virtual void SetLogAxis(const bool log)
3085 {
3086 m_isLog = log;
3087 }
3088
3092 void SetCoordIsAlwaysVisible(const bool alwaysVisible)
3093 {
3094 m_CoordIsAlwaysVisible = alwaysVisible;
3095 }
3096
3101 {
3102 return m_CoordIsAlwaysVisible;
3103 }
3104
3111 static mpScaleConstraints ComputeScaleConstraints(double step, double maxAxisValue);
3112
3119 wxString FormatLabelValue(double value, const mpScaleConstraints &constraints);
3120
3121 protected:
3122 static constexpr wxCoord kTickSize = 4;
3123 static constexpr wxCoord kYAxisExtraSpace = 6;
3124 static constexpr wxCoord kYAxisTitleSpace = 2;
3125 static constexpr wxCoord kYAxisLabelSpace = 2;
3126 static constexpr wxCoord kXAxisTitleSpace = 3;
3127
3130 bool m_ticks;
3131 bool m_grids;
3132 bool m_auto;
3135 unsigned int m_timeConv;
3136 wxString m_labelFormat;
3137 bool m_isLog;
3138 bool m_hover = false;
3140
3143 virtual int GetOrigin(mpWindow &w) = 0;
3144
3151 static double GetStep(double scale, int minLabelSpacing);
3152
3160 virtual void DrawScaleName(wxDC &dc, mpWindow &w, int origin, int labelSize) = 0;
3161
3166 static wxString FormatLogValue(double n);
3167
3174 int GetLabelWidth(double value, wxDC &dc, const mpScaleConstraints &constraints);
3175
3180 static bool UseScientific(double maxAxisValue);
3181
3187 static int GetSignificantDigits(double step, double maxAxisValue);
3188
3193 static int GetDecimalDigits(double step);
3194
3195 private:
3197};
3198
3199
3206{
3207 public:
3213 mpScaleX(const wxString &name = _T("X"), const int flags = mpALIGN_CENTERX, const bool grids = false, const mpLabelType type = mpLabel_AUTO) :
3214 mpScale(name, flags, grids, type)
3215 {
3216 m_subtype = mpsScaleX;
3217 }
3218
3220 bool IsTopAxis() const
3221 {
3222 return ((GetAlign() == mpALIGN_BORDER_TOP) || (GetAlign() == mpALIGN_TOP));
3223 }
3224
3226 bool IsBottomAxis() const
3227 {
3228 return ((GetAlign() == mpALIGN_BORDER_BOTTOM) || (GetAlign() == mpALIGN_BOTTOM));
3229 }
3230
3231 protected:
3236 static int m_orgy;
3237
3240 void DoPlot(wxDC &dc, mpWindow &w) override;
3241
3242 int GetOrigin(mpWindow &w) override;
3243 void DrawScaleName(wxDC &dc, mpWindow &w, int origin, int labelSize) override;
3244
3245 private:
3247
3251 friend mpScaleY;
3252};
3253
3261{
3262 public:
3270 mpScaleY(const wxString &name = _T("Y"), const int flags = mpALIGN_CENTERY, const bool grids = false, const mpOptional_uint yAxisID = std::nullopt, const mpLabelType labelType = mpLabel_AUTO) :
3271 mpScale(name, flags, grids, labelType, yAxisID)
3272 {
3273 m_subtype = mpsScaleY;
3274 m_axisWidth = MP_Y_BORDER_SEPARATION;
3275 m_xPos = 0;
3276 m_autoHideAxis = false;
3277 }
3278
3282
3284 int GetAxisWidth() const
3285 {
3286 return m_axisWidth;
3287 }
3288
3292 void SetAutoHideAxis(const bool autoHide)
3293 {
3294 m_autoHideAxis = autoHide;
3295 }
3296
3298 bool GetAutoHideAxis() const
3299 {
3300 return m_autoHideAxis;
3301 }
3302
3304 bool IsLeftAxis() const
3305 {
3306 return ((GetAlign() == mpALIGN_BORDER_LEFT) || (GetAlign() == mpALIGN_LEFT));
3307 }
3308
3310 bool IsRightAxis() const
3311 {
3312 return ((GetAlign() == mpALIGN_BORDER_RIGHT) || (GetAlign() == mpALIGN_RIGHT));
3313 }
3314
3316 bool IsInside(const wxCoord xPixel) const
3317 {
3318 if ( (IsLeftAxis() || IsRightAxis()) && (xPixel >= m_xPos) && (xPixel <= (m_xPos + m_axisWidth)) )
3319 {
3320 return true;
3321 }
3322 return false;
3323 }
3324
3325 protected:
3329
3332 void DoPlot(wxDC &dc, mpWindow &w) override;
3333
3334 int GetOrigin(mpWindow &w) override;
3335 void DrawScaleName(wxDC &dc, mpWindow &w, int origin, int maxLabelWidth) override;
3336
3337 private:
3339};
3340
3341//-----------------------------------------------------------------------------
3342// mpWindow
3343//-----------------------------------------------------------------------------
3344
3350#define mpMOUSEMODE_DRAG 0
3352#define mpMOUSEMODE_ZOOMBOX 1
3353
3356//WX_DECLARE_HASH_MAP( int, mpLayer*, wxIntegerHash, wxIntegerEqual, mpLayerList );
3357typedef std::deque<mpLayer*> mpLayerList;
3358
3369{
3370 mpScale* axis = nullptr;
3371 double scale = 1.0;
3372 double pos = 0;
3376
3377 // Note: we don't use the default operator since we don't want to compare axis pointers
3379 bool operator==(const mpAxisData& other) const
3380 {
3381 return /*(axis == other.axis) && */ (scale == other.scale) && (pos == other.pos) &&
3382 (bound == other.bound) && (desired == other.desired);
3383 }
3384};
3385
3387typedef std::map<int, mpAxisData> mpAxisList;
3388
3395typedef enum {
3396 uXAxis = 1,
3397 uYAxis = 2,
3398 uXYAxis = 3
3399} mpAxisUpdate;
3400
3410typedef std::function<void(void *Sender, const wxString &classname, bool &cancel)> mpOnDeleteLayer;
3411
3418typedef std::function<void(void *Sender, wxMouseEvent &event, bool &cancel)> mpOnUserMouseAction;
3419
3425{
3426 public:
3427 mpMagnet()
3428 {
3429 m_enable = false;
3430 m_show = false;
3431 }
3432 ~mpMagnet()
3433 {
3434 ;
3435 }
3436
3438 void UpdateBox(const wxRect &plotArea)
3439 {
3440 m_domain = plotArea;
3441 }
3442
3444 void Enable(const bool enable)
3445 {
3446 m_enable = enable;
3447 }
3448
3450 bool IsEnabled() const
3451 {
3452 return m_enable;
3453 }
3454
3456 void DrawCross(wxDC &dc, mpWindow &w);
3457
3459 bool ShouldBeShown(const wxPoint mousePos) const
3460 {
3461 return m_enable && m_domain.Contains(mousePos);
3462 }
3463
3465 void Show(const bool show)
3466 {
3467 m_show = show;
3468 }
3469
3471 bool IsShown() const
3472 {
3473 return m_show;
3474 }
3475
3476 private:
3477 bool m_enable;
3478 bool m_show;
3479 wxRect m_domain;
3480};
3481
3503class WXDLLIMPEXP_MATHPLOT mpWindow: public wxWindow
3504{
3505 public:
3506 mpWindow()
3507 {
3508 InitParameters();
3509 }
3510
3518 mpWindow(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
3519 long flags = 0);
3520
3521 ~mpWindow() override;
3522
3527 {
3528 return &m_popmenu;
3529 }
3530
3539 bool AddLayer(mpLayer *layer, bool fit = true, bool refreshConfig = true);
3540
3553 bool DelLayer(mpLayer *layer, mpDeleteAction alsoDeleteObject, bool refreshDisplay = true, bool refreshConfig = true);
3554
3560 void DelAllLayers(mpDeleteAction alsoDeleteObject, bool refreshDisplay = true);
3561
3569 void DelAllPlot(mpDeleteAction alsoDeleteObject, mpFunctionType func = mpfAllType, bool refreshDisplay = true, bool refreshConfig = true);
3570
3577 void DelAllYAxisAfterID(mpDeleteAction alsoDeleteObject, int yAxisID = 0, bool refreshDisplay = true);
3578
3584 mpLayer* GetLayer(int position);
3585
3591
3598 mpLayer* GetLayersType(int position, mpLayerType type);
3599
3607
3614
3623 mpFXYVector* GetXYSeries(unsigned int n, const wxString &name = _T("Serie "), bool create = true);
3624
3632 std::optional<mpPlotHit> GetClosestPlot(wxCoord ix, wxCoord iy);
3633
3638 mpLayer* GetLayerByName(const wxString &name);
3639
3644 mpLayer* GetLayerByClassName(const wxString &name);
3645
3649 void RefreshLegend(void);
3650
3656 bool IsYAxisUsedByFunction(int yAxisID);
3657
3663 bool ShouldDrawYAxis(const mpScaleY &yAxis);
3664
3665
3670
3675
3679 void SetScaleX(const double scaleX)
3680 {
3681 if (MP_ISNOTNULL(scaleX))
3682 {
3683 m_AxisDataX.scale = scaleX;
3684 UpdateDesiredBoundingBox(uXAxis);
3685 }
3686 UpdateAll();
3687 }
3688
3693 double GetScaleX(void) const
3694 {
3695 return m_AxisDataX.scale;
3696 }
3697
3702 void SetScaleY(const double scaleY, const int yAxisID)
3703 {
3704 assert(m_AxisDataYList.count(yAxisID) != 0);
3705 if (MP_ISNOTNULL(scaleY))
3706 {
3707 m_AxisDataYList[yAxisID].scale = scaleY;
3708 UpdateDesiredBoundingBox(uYAxis);
3709 }
3710 UpdateAll();
3711 }
3712
3718 double GetScaleY(const int yAxisID)
3719 {
3720 assert(m_AxisDataYList.count(yAxisID) != 0);
3721 return m_AxisDataYList[yAxisID].scale;
3722 } // Schaling's method: maybe another method exists with the same name
3723
3724 [[deprecated("Incomplete, use UpdateBBox instead")]]
3727 void SetBound();
3728
3731 {
3732 return m_AxisDataX.bound;
3733 }
3734
3737 {
3738 return m_AxisDataX.desired;
3739 }
3740
3744 mpRange<double> GetBoundY(const int yAxisID)
3745 {
3746 assert(m_AxisDataYList.count(yAxisID) != 0);
3747 return m_AxisDataYList[yAxisID].bound;
3748 }
3749
3754 {
3755 assert(m_AxisDataYList.count(yAxisID) != 0);
3756 return m_AxisDataYList[yAxisID].desired;
3757 }
3758
3763 {
3764 return mpRange<double>(m_AxisDataX.pos + (m_margin.left / m_AxisDataX.scale), m_AxisDataX.pos + ((m_margin.left + m_plotWidth) / m_AxisDataX.scale));
3765 }
3766
3771 mpRange<double> GetVisibleRangeY(const unsigned int yAxisID = 0)
3772 {
3773 assert(m_AxisDataYList.count(yAxisID) != 0);
3774 mpAxisData& yData = m_AxisDataYList[yAxisID];
3775 return mpRange<double>(yData.pos - ((m_margin.top + m_plotHeight) / yData.scale), yData.pos - (m_margin.top / yData.scale));
3776 }
3777
3782 std::unordered_map<int, mpRange<double>> GetAllBoundY()
3783 {
3784 std::unordered_map<int, mpRange<double>> yRange;
3785 for (const auto& [m_yID, m_yData] : m_AxisDataYList)
3786 {
3787 yRange[m_yID] = m_yData.bound;
3788 }
3789 return yRange;
3790 }
3791
3796 std::unordered_map<int, mpRange<double>> GetAllDesiredY()
3797 {
3798 std::unordered_map<int, mpRange<double>> yRange;
3799 for (const auto& [m_yID, m_yData] : m_AxisDataYList)
3800 {
3801 yRange[m_yID] = m_yData.desired;
3802 }
3803 return yRange;
3804 }
3805
3809 void SetPosX(const double posX)
3810 {
3811 m_AxisDataX.pos = posX;
3812 UpdateDesiredBoundingBox(uXAxis);
3813 UpdateAll();
3814 }
3815
3820 double GetPosX(void) const
3821 {
3822 return m_AxisDataX.pos;
3823 }
3824
3829 void SetPosY(std::unordered_map<int, double>& posYList)
3830 {
3831 for (auto& [m_yID, m_yData] : m_AxisDataYList)
3832 {
3833 m_yData.pos = posYList[m_yID];
3834 }
3835 UpdateDesiredBoundingBox(uYAxis);
3836 UpdateAll();
3837 }
3838
3844 double GetPosY(const int yAxisID)
3845 {
3846 assert(m_AxisDataYList.count(yAxisID) != 0);
3847 return m_AxisDataYList[yAxisID].pos;
3848 }
3849
3853 int GetNOfYAxis(void) const
3854 {
3855 return (int)m_AxisDataYList.size();
3856 }
3857
3862 {
3863 return m_AxisDataYList;
3864 }
3865
3871 void SetScreen(const int scrX, const int scrY)
3872 {
3873 m_scrX = scrX;
3874 m_scrY = scrY;
3875 m_plotWidth = m_scrX - (m_margin.left + m_margin.right);
3876 m_plotHeight = m_scrY - (m_margin.top + m_margin.bottom);
3877
3878 m_plotBoundaries.endPx = m_scrX;
3879 m_plotBoundariesMargin.endPx = m_scrX - m_margin.right;
3880 m_plotBoundaries.endPy = m_scrY;
3881 m_plotBoundariesMargin.endPy = m_scrY - m_margin.bottom;
3882
3883 m_PlotArea = wxRect(m_margin.left - m_extraMargin, m_margin.top - m_extraMargin,
3884 m_plotWidth + 2*m_extraMargin, m_plotHeight + 2*m_extraMargin);
3885
3886 m_magnet.UpdateBox(m_PlotArea);
3887 }
3888
3895 int GetScreenX(void) const
3896 {
3897 return m_scrX;
3898 }
3899
3906 int GetScreenY(void) const
3907 {
3908 return m_scrY;
3909 }
3910
3916 void SetPos(const double posX, std::unordered_map<int, double>& posYList)
3917 {
3918 m_AxisDataX.pos = posX;
3919 SetPosY(posYList);
3920 }
3921
3925 double p2x(const wxCoord pixelCoordX) const
3926 {
3927 return m_AxisDataX.pos + (pixelCoordX / m_AxisDataX.scale);
3928 }
3929
3933 double p2y(const wxCoord pixelCoordY, const int yAxisID = 0)
3934 {
3935 assert(m_AxisDataYList.count(yAxisID) != 0);
3936 if (m_AxisDataYList.count(yAxisID) == 0)
3937 return 0.0;
3938 return m_AxisDataYList[yAxisID].pos - (pixelCoordY / m_AxisDataYList[yAxisID].scale);
3939 }
3940
3944 wxCoord x2p(const double x) const
3945 {
3946 return (wxCoord)((x - m_AxisDataX.pos) * m_AxisDataX.scale);
3947 }
3948
3952 wxCoord y2p(const double y, const int yAxisID = 0)
3953 {
3954 assert(m_AxisDataYList.count(yAxisID) != 0);
3955 if (m_AxisDataYList.count(yAxisID) == 0)
3956 return 0;
3957 return (wxCoord)((m_AxisDataYList[yAxisID].pos - y) * m_AxisDataYList[yAxisID].scale);
3958 }
3959
3961 [[deprecated("Deprecated - use EnableBufferedPaintDC??")]]
3962 void EnableDoubleBuffer(const bool enabled)
3963 {
3964 EnableBufferedPaintDC(enabled);
3965 }
3966
3970 void EnableBufferedPaintDC(const bool enabled)
3971 {
3972 m_enableBufferedPaintDC = enabled;
3973 }
3974
3977 void EnableMousePanZoom(const bool enabled)
3978 {
3979 m_enableMouseNavigation = enabled;
3980 }
3981
3987 void LockAspect(bool enable = true);
3988
3993 bool IsAspectLocked() const
3994 {
3995 return m_lockaspect;
3996 }
3997
4002 void Fit() override;
4003
4010 void Fit(const mpRange<double> &rangeX, std::unordered_map<int, mpRange<double>> rangeY, bool updateDesired = true, wxCoord *printSizeX = NULL, wxCoord *printSizeY = NULL);
4011
4015 void FitX(void);
4016
4021 void FitY(int yAxisID);
4022
4027 void ZoomIn(const wxPoint &centerPoint = wxDefaultPosition);
4028
4033 void ZoomOut(const wxPoint &centerPoint = wxDefaultPosition);
4034
4036 void ZoomInX();
4037
4039 void ZoomOutX();
4040
4043 void ZoomInY(mpOptional_int yAxisID = std::nullopt);
4044
4047 void ZoomOutY(mpOptional_int yAxisID = std::nullopt);
4048
4053 void ZoomRect(wxPoint p0, wxPoint p1);
4054
4057
4058 // Added methods by Davide Rondini
4059
4063 unsigned int CountLayers();
4064
4067 unsigned int CountAllLayers() const
4068 {
4069 return (unsigned int)m_layers.size();
4070 }
4071
4075 unsigned int CountLayersType(mpLayerType type);
4076
4080 unsigned int CountLayersFXYPlot();
4081
4089 {
4090 // Change on X axis
4091 if (update & uXAxis)
4092 {
4093 m_AxisDataX.desired = GetVisibleRangeX();
4094 }
4095
4096 // Change on Y axis
4097 if (update & uYAxis)
4098 {
4099 for (auto& [yID, yData] : m_AxisDataYList)
4100 {
4101 yData.desired = GetVisibleRangeY(yID);
4102 }
4103 }
4104 }
4105
4111 mpFloatRectSimple GetBoundingBox(const bool desired, const unsigned int yAxisID = 0)
4112 {
4113 assert(m_AxisDataYList.count(yAxisID) != 0);
4114 if (desired)
4115 return mpFloatRectSimple(m_AxisDataX.desired, m_AxisDataYList[yAxisID].desired);
4116 else
4117 return mpFloatRectSimple(m_AxisDataX.bound, m_AxisDataYList[yAxisID].bound);
4118 }
4119
4125 bool PointIsInsideBound(const double px, const double py, const int yAxisID)
4126 {
4127 if (m_AxisDataYList.count(yAxisID) == 0)
4128 return false;
4129
4130 return m_AxisDataX.bound.PointIsInside(px) && GetBoundY(yAxisID).PointIsInside(py);
4131 }
4132
4138 void UpdateBoundingBoxToInclude(const double px, const double py, const int yAxisID)
4139 {
4140 if (m_AxisDataYList.count(yAxisID) == 0)
4141 return ;
4142
4143 m_AxisDataX.bound.Update(px);
4144 m_AxisDataYList[yAxisID].bound.Update(py);
4145 }
4146
4147 /* Initialize bounding box with an initial point
4148 * @param px point on x-axis
4149 * @param py point on y-axis
4150 * @param yAxisID the y-axis ID
4151 */
4153 void InitializeBoundingBox(const double px, const double py, const int yAxisID)
4154 {
4155 if (m_AxisDataYList.count(yAxisID) == 0)
4156 return ;
4157
4158 m_AxisDataX.bound.Set(px, px);
4159 m_AxisDataYList[yAxisID].bound.Set(py, py);
4160 }
4161
4164 void SetMPScrollbars(bool status);
4165
4168 bool GetMPScrollbars() const
4169 {
4170 return m_enableScrollBars;
4171 }
4172
4178 bool SaveScreenshot(const wxString &filename, int type = wxBITMAP_TYPE_BMP, wxSize imageSize = wxDefaultSize, bool fit = false);
4179
4183 wxBitmap* BitmapScreenshot(wxSize imageSize = wxDefaultSize, bool fit = false);
4184
4188 void ClipboardScreenshot(wxSize imageSize = wxDefaultSize, bool fit = false);
4189
4193 void SetWildcard(const wxString &wildcard)
4194 {
4195 m_wildcard = wildcard;
4196 }
4197
4201 const wxString& GetWildcard(void) const
4202 {
4203 return m_wildcard;
4204 }
4205
4213 bool LoadFile(const wxString &filename = wxEmptyString);
4214
4219 void SetDefaultDir(const wxString &dirname)
4220 {
4221 m_DefaultDir = dirname;
4222 }
4223
4227
4232
4238 static void SetDefaultLegendIsAlwaysVisible(const bool visible)
4239 {
4240 m_DefaultLegendIsAlwaysVisible = visible;
4241 }
4242
4247
4248
4253 void SetAutoFit(const bool autoFit)
4254 {
4255 m_autoFit = autoFit;
4256 }
4257
4264 void SetMargins(int top, int right, int bottom, int left);
4265
4268 {
4269 SetMargins(m_marginOuter.top, m_marginOuter.right, m_marginOuter.bottom, m_marginOuter.left);
4270 }
4271
4273 void SetMarginTop(const int top)
4274 {
4275 SetMargins(top, m_marginOuter.right, m_marginOuter.bottom, m_marginOuter.left);
4276 }
4277
4281 int GetMarginTop(const bool minusExtra = false) const
4282 {
4283 if (minusExtra)
4284 return m_margin.top - m_extraMargin;
4285 else
4286 return m_margin.top;
4287 }
4288
4290 void SetMarginRight(const int right)
4291 {
4292 SetMargins(m_marginOuter.top, right, m_marginOuter.bottom, m_marginOuter.left);
4293 }
4294
4298 int GetMarginRight(const bool minusExtra = false) const
4299 {
4300 if (minusExtra)
4301 return m_margin.right - m_extraMargin;
4302 else
4303 return m_margin.right;
4304 }
4305
4308 {
4309 return m_marginOuter.right;
4310 }
4311
4313 void SetMarginBottom(const int bottom)
4314 {
4315 SetMargins(m_marginOuter.top, m_marginOuter.right, bottom, m_marginOuter.left);
4316 }
4317
4321 int GetMarginBottom(const bool minusExtra = false) const
4322 {
4323 if (minusExtra)
4324 return m_margin.bottom - m_extraMargin;
4325 else
4326 return m_margin.bottom;
4327 }
4328
4330 void SetMarginLeft(const int left)
4331 {
4332 SetMargins(m_marginOuter.top, m_marginOuter.right, m_marginOuter.bottom, left);
4333 }
4334
4338 int GetMarginLeft(const bool minusExtra = false) const
4339 {
4340 if (minusExtra)
4341 return m_margin.left - m_extraMargin;
4342 else
4343 return m_margin.left;
4344 }
4345
4347 void SetExtraMargin(const int extra)
4348 {
4349 m_extraMargin = extra;
4350 SetMargins(m_marginOuter.top, m_marginOuter.right, m_marginOuter.bottom, m_marginOuter.left);
4351 }
4352
4354 int GetExtraMargin() const
4355 {
4356 return m_extraMargin;
4357 }
4358
4361 {
4362 return m_marginOuter.left;
4363 }
4364
4366 int GetPlotWidth() const
4367 {
4368 return m_plotWidth;
4369 }
4370
4372 int GetPlotHeight() const
4373 {
4374 return m_plotHeight;
4375 }
4376
4381 mpRect GetPlotBoundaries(const bool with_margin) const
4382 {
4383 mpRect bond;
4384 if (with_margin)
4385 bond = m_plotBoundariesMargin;
4386 else
4387 bond = m_plotBoundaries;
4388 bond.startPx -= m_extraMargin;
4389 bond.endPx += m_extraMargin;
4390 bond.startPy -= m_extraMargin;
4391 bond.endPy += m_extraMargin;
4392 return bond;
4393 }
4394
4398 int GetLeftYAxesWidth(mpOptional_int yAxisID = std::nullopt);
4399
4403 int GetRightYAxesWidth(mpOptional_int yAxisID = std::nullopt);
4404
4406 void SetDrawBox(const bool drawbox)
4407 {
4408 m_drawBox = drawbox;
4409 }
4410
4412 bool GetDrawBox() const
4413 {
4414 return m_drawBox;
4415 }
4416
4420 mpOptional_int IsInsideYAxis(const wxPoint &point);
4421
4425 mpInfoLayer* IsInsideInfoLayer(const wxPoint &point);
4426
4430 void SetLayerVisible(const wxString &name, bool viewable);
4431
4435 bool IsLayerVisible(const wxString &name);
4436
4440 bool IsLayerVisible(const unsigned int position);
4441
4445 void SetLayerVisible(const unsigned int position, bool viewable);
4446
4451 void SetColourTheme(const wxColour &bgColour, const wxColour &drawColour, const wxColour &axesColour);
4452
4455 const wxColour& GetAxesColour() const
4456 {
4457 return m_axColour;
4458 }
4459
4461 const wxColour& GetbgColour() const
4462 {
4463 return m_bgColour;
4464 }
4465
4467 void SetbgColour(const wxColour &colour)
4468 {
4469 m_bgColour = colour;
4470 }
4471
4478 {
4479 m_OnDeleteLayer = event;
4480 }
4481
4484 {
4485 m_OnDeleteLayer = NULL;
4486 }
4487
4492 void SetOnUserMouseAction(const mpOnUserMouseAction &userMouseEventHandler)
4493 {
4494 m_OnUserMouseAction = userMouseEventHandler;
4495 }
4496
4499 {
4500 m_OnUserMouseAction = NULL;
4501 }
4502
4508 bool IsLogXaxis() const
4509 {
4510 if (m_AxisDataX.axis)
4511 return ((mpScaleX *)m_AxisDataX.axis)->IsLogAxis();
4512 else
4513 return false;
4514 }
4515
4520 bool IsLogYaxis(const int yAxisID)
4521 {
4522 assert(m_AxisDataYList.count(yAxisID) != 0);
4523 mpScaleY* yAxis = GetLayerYAxis(yAxisID);
4524 if (yAxis)
4525 return yAxis->IsLogAxis();
4526 else
4527 return false;
4528 }
4529
4534 void SetLogXaxis(const bool log)
4535 {
4536 if (m_AxisDataX.axis)
4537 ((mpScaleX *)m_AxisDataX.axis)->SetLogAxis(log);
4538 }
4539
4545 void SetLogYaxis(const int yAxisID, const bool log)
4546 {
4547 mpScaleY* yAxis = GetLayerYAxis(yAxisID);
4548 if (yAxis)
4549 yAxis->SetLogAxis(log);
4550 }
4551
4556 bool GetMagnetize() const
4557 {
4558 return m_magnet.IsEnabled();
4559 }
4560
4562 void SetMagnetize(const bool mag)
4563 {
4564 m_magnet.Enable(mag);
4565 }
4566
4572 {
4573 m_mouseLeftDownAction = action;
4574 }
4575
4581 {
4582 return m_mouseLeftDownAction;
4583 }
4584
4589 wxPoint GetMousePosition() const
4590 {
4591 return m_mousePos;
4592 }
4593
4599 {
4600 return m_movingInfoLayer;
4601 }
4602
4603#if defined(MP_ENABLE_CONFIG) || defined(ENABLE_MP_CONFIG)
4608 MathPlotConfigDialog* GetConfigWindow(bool Create = false);
4609#endif // MP_ENABLE_CONFIG
4610
4618 void RefreshConfigWindow(mpLayerType layerType = mpLAYER_UNDEF, int param = -1);
4619
4627 void OpenConfigWindow(mpLayerType layerType = mpLAYER_UNDEF, int param = -1);
4628
4633
4638 void Paint(wxDC& dc);
4639
4644 void RenderOverlays(wxDC& dc);
4645
4651 wxMemoryDC *GetMemoryDC(void)
4652 {
4653 m_buff_dc.SelectObject(m_buff_bmp);
4654 return &m_buff_dc;
4655 }
4656
4657 protected:
4658 virtual void BindEvents(void);
4659 virtual void OnPaint(wxPaintEvent &event);
4660 virtual void OnSize(wxSizeEvent &event);
4661 virtual void OnShowPopupMenu(wxMouseEvent &event);
4662 virtual void OnCenter(wxCommandEvent &event);
4663 virtual void OnFit(wxCommandEvent &event);
4664 virtual void OnToggleGrids(wxCommandEvent &event);
4665 virtual void OnToggleCoords(wxCommandEvent &event);
4666 virtual void OnScreenShot(wxCommandEvent &event);
4667 virtual void OnFullScreen(wxCommandEvent &event);
4668#if defined(MP_ENABLE_CONFIG) || defined(ENABLE_MP_CONFIG)
4669 virtual void OnConfiguration(wxCommandEvent &event);
4670#endif // MP_ENABLE_CONFIG
4671 virtual void OnLoadFile(wxCommandEvent &event);
4672 virtual void OnZoomIn(wxCommandEvent &event);
4673 virtual void OnZoomOut(wxCommandEvent &event);
4674 virtual void OnLockAspect(wxCommandEvent &event);
4675 virtual void OnMouseHelp(wxCommandEvent &event);
4676 virtual void OnMouseLeftDown(wxMouseEvent &event);
4677 virtual void OnMouseLeftDoubleClick(wxMouseEvent &event);
4678 virtual void OnMouseRightDown(wxMouseEvent &event);
4679 virtual void OnMouseMove(wxMouseEvent &event);
4680 virtual void OnMouseLeftRelease(wxMouseEvent &event);
4681 virtual void OnMouseWheel(wxMouseEvent &event);
4682 virtual void OnMouseLeave(wxMouseEvent &event);
4683 bool CheckUserMouseAction(wxMouseEvent &event);
4684 virtual void OnScrollThumbTrack(wxScrollWinEvent &event);
4685 virtual void OnScrollPageUp(wxScrollWinEvent &event);
4686 virtual void OnScrollPageDown(wxScrollWinEvent &event);
4687 virtual void OnScrollLineUp(wxScrollWinEvent &event);
4688 virtual void OnScrollLineDown(wxScrollWinEvent &event);
4689 virtual void OnScrollTop(wxScrollWinEvent &event);
4690 virtual void OnScrollBottom(wxScrollWinEvent &event);
4691
4693 void DoScrollCalc(const int position, const int orientation);
4694
4699 void DoZoomXCalc(bool zoomIn, wxCoord staticXpixel = MP_ZOOM_AROUND_CENTER);
4700
4707 void DoZoomYCalc(bool zoomIn, wxCoord staticYpixel = MP_ZOOM_AROUND_CENTER, mpOptional_int yAxisID = std::nullopt);
4708
4713 void SetScaleXAndCenter(double scaleX);
4714
4720 void SetScaleYAndCenter(double scaleY, int yAxisID);
4721
4726 void Zoom(bool zoomIn, const wxPoint &centerPoint);
4727
4730 virtual bool UpdateBBox();
4731
4735 void DrawBoxZoom(wxDC& dc);
4736
4741
4742 wxTopLevelWindow* m_parent;
4744
4748
4749 wxMenu m_popmenu;
4751 wxColour m_bgColour;
4752 wxColour m_fgColour;
4753 wxColour m_axColour;
4755
4760
4764 wxCoord m_plotWidth;
4766
4769 wxRect m_PlotArea;
4770
4773 wxBitmap m_buff_bmp;
4774 wxMemoryDC m_buff_dc;
4780 wxPoint m_mousePos;
4784 std::unordered_map<int, double> m_mouseScaleYList;
4791
4793
4795
4797
4798 wxString m_wildcard;
4799 wxString m_DefaultDir;
4800
4801#if defined(MP_ENABLE_CONFIG) || defined(ENABLE_MP_CONFIG)
4802 MathPlotConfigDialog* m_configWindow = NULL;
4803#endif // MP_ENABLE_CONFIG
4804 bool m_openConfigWindowPending = false;
4806
4807 mpOnDeleteLayer m_OnDeleteLayer = NULL;
4808 mpOnUserMouseAction m_OnUserMouseAction = NULL;
4809
4813 virtual void DesiredBoundsHaveChanged() {};
4814
4815 private:
4817 void CheckAndReportDesiredBoundsChanges();
4818
4823 unsigned int GetNewAxisDataID(void)
4824 {
4825 int newID = 0;
4826 for (const auto& [m_yID, m_yData] : m_AxisDataYList)
4827 {
4828 if(m_yData.axis)
4829 {
4830 // This ID is used by an axis. Make sure the new ID is larger
4831 newID = std::max(newID, m_yID + 1);
4832 }
4833 }
4834 return newID;
4835 }
4836
4838
4839 // To have direct access to m_Screenshot_dc
4840 friend mpPrintout;
4841};
4842
4843//-----------------------------------------------------------------------------
4844// mpText - provided by Val Greene
4845//-----------------------------------------------------------------------------
4846
4855{
4856 public:
4859 mpText(const wxString &name = wxEmptyString) : mpLayer(mpLAYER_TEXT)
4860 {
4861 m_subtype = mptText;
4862 SetName(name);
4863 m_offsetx = 5;
4864 m_offsety = 50;
4865 m_location = mpMarginUser;
4866 m_ZIndex = mpZIndex_TEXT;
4867 }
4868
4872 mpText(const wxString &name, int offsetx, int offsety);
4873
4877 mpText(const wxString &name, mpLocation marginLocation);
4878
4881 bool HasBBox() override
4882 {
4883 return false;
4884 }
4885
4888 void SetLocation(const mpLocation location)
4889 {
4890 m_location = location;
4891 }
4892
4896 {
4897 return m_location;
4898 }
4899
4902 void SetOffset(const int offX, const int offY)
4903 {
4904 m_offsetx = offX;
4905 m_offsety = offY;
4906 }
4907
4909 void GetOffset(int *offX, int *offY) const
4910 {
4911 *offX = m_offsetx;
4912 *offY = m_offsety;
4913 }
4914
4915 protected:
4919
4922 void DoPlot(wxDC &dc, mpWindow &w) override;
4923
4924 private:
4926};
4927
4932{
4933 public:
4937
4940 mpTitle(const wxString &name) :
4942 {
4943 m_subtype = mptTitle;
4944 SetPen(*wxWHITE_PEN);
4945 SetBrush(*wxWHITE_BRUSH);
4946 }
4947
4948 private:
4950};
4951
4952//-----------------------------------------------------------------------------
4953// mpPrintout - provided by Davide Rondini
4954//-----------------------------------------------------------------------------
4955
4960class WXDLLIMPEXP_MATHPLOT mpPrintout: public wxPrintout
4961{
4962 public:
4963 mpPrintout()
4964 {
4965 plotWindow = NULL;
4966 drawn = false;
4967 stretch_factor = 2;
4968 }
4969
4975 mpPrintout(mpWindow *drawWindow, const wxString &title = _T("wxMathPlot print output"), int factor = 2);
4976 ~mpPrintout() override
4977 {
4978 ;
4979 }
4980
4984 void SetDrawState(const bool drawState)
4985 {
4986 drawn = drawState;
4987 }
4988
4990 bool OnPrintPage(int page) override;
4992 bool HasPage(int page) override;
4993
4996 void SetFactor(const int factor)
4997 {
4998 stretch_factor = factor;
4999 }
5000
5001 private:
5002 bool drawn;
5003 mpWindow* plotWindow;
5004 int stretch_factor; // To reduce the size of plot
5005
5007};
5008
5009//-----------------------------------------------------------------------------
5010// mpMovableObject - provided by Jose Luis Blanco
5011//-----------------------------------------------------------------------------
5020{
5021 public:
5025 m_reference_x(0), m_reference_y(0), m_reference_phi(0), m_shape_xs(0), m_shape_ys(0)
5026 {
5027 assert(m_type == mpLAYER_PLOT); // m_type is already set to mpLAYER_PLOT in default-arg mpFunction ctor: m_type = mpLAYER_PLOT;
5028 m_subtype = mpfMovable;
5029 }
5030
5031 ~mpMovableObject() override {}
5032
5035 void GetCoordinateBase(double &x, double &y, double &phi) const
5036 {
5037 x = m_reference_x;
5038 y = m_reference_y;
5039 phi = m_reference_phi;
5040 }
5041
5044 void SetCoordinateBase(const double x, const double y, const double phi = 0)
5045 {
5046 m_reference_x = x;
5047 m_reference_y = y;
5048 m_reference_phi = phi;
5049 m_flags = mpALIGN_SW;
5050 ShapeUpdated();
5051 }
5052
5053 bool HasBBox() override
5054 {
5055 return m_trans_shape_xs.size() != 0;
5056 }
5057
5060 double GetMinX() override
5061 {
5062 return m_bbox_x.min;
5063 }
5064
5067 double GetMaxX() override
5068 {
5069 return m_bbox_x.max;
5070 }
5071
5074 double GetMinY() override
5075 {
5076 return m_bbox_y.min;
5077 }
5078
5081 double GetMaxY() override
5082 {
5083 return m_bbox_y.max;
5084 }
5085
5086 protected:
5087
5093
5094 void DoPlot(wxDC &dc, mpWindow &w) override;
5095
5098 void TranslatePoint(double x, double y, double &out_x, double &out_y) const;
5099
5100 // the object points, in local coordinates (to be transformed by the current transformation).
5101 std::vector<double> m_shape_xs;
5102 std::vector<double> m_shape_ys;
5103
5104 // The buffer for the translated & rotated points (to avoid recomputing them with each mpWindow refresh).
5105 std::vector<double> m_trans_shape_xs;
5106 std::vector<double> m_trans_shape_ys;
5107
5113
5118
5119 private:
5121};
5122
5123//-----------------------------------------------------------------------------
5124// mpCovarianceEllipse - provided by Jose Luis Blanco
5125//-----------------------------------------------------------------------------
5138{
5139 public:
5143 mpCovarianceEllipse(const double cov_00 = 1, const double cov_11 = 1, const double cov_01 = 0, const double quantiles = 2, const int segments = 32,
5144 const wxString &layerName = _T("")) : mpMovableObject(),
5145 m_cov_00(cov_00), m_cov_11(cov_11), m_cov_01(cov_01), m_quantiles(quantiles), m_segments(segments)
5146 {
5147 m_continuous = true;
5148 m_name = layerName;
5149 RecalculateShape();
5150 }
5151
5152 ~mpCovarianceEllipse() override
5153 {
5154 ;
5155 }
5156
5159 double GetQuantiles() const
5160 {
5161 return m_quantiles;
5162 }
5163
5166 void SetQuantiles(const double q)
5167 {
5168 m_quantiles = q;
5169 RecalculateShape();
5170 }
5171
5173 void SetSegments(const int segments)
5174 {
5175 m_segments = segments;
5176 }
5177
5179 int GetSegments() const
5180 {
5181 return m_segments;
5182 }
5183
5186 void GetCovarianceMatrix(double &cov_00, double &cov_01, double &cov_11) const
5187 {
5188 cov_00 = m_cov_00;
5189 cov_01 = m_cov_01;
5190 cov_11 = m_cov_11;
5191 }
5192
5195 void SetCovarianceMatrix(const double cov_00, const double cov_01, const double cov_11)
5196 {
5197 m_cov_00 = cov_00;
5198 m_cov_01 = cov_01;
5199 m_cov_11 = cov_11;
5200 RecalculateShape();
5201 }
5202
5203 protected:
5206 double m_cov_00;
5207 double m_cov_11;
5208 double m_cov_01;
5210
5214
5218
5219 private:
5221};
5222
5223//-----------------------------------------------------------------------------
5224// mpPolygon - provided by Jose Luis Blanco
5225//-----------------------------------------------------------------------------
5231{
5232 public:
5235 mpPolygon(const wxString &layerName = _T("")) : mpMovableObject()
5236 {
5237 m_continuous = true;
5238 m_name = layerName;
5239 }
5240
5241 ~mpPolygon() override
5242 {
5243 ;
5244 }
5245
5251 void setPoints(const std::vector<double> &points_xs, const std::vector<double> &points_ys, bool closedShape = true);
5252
5253 private:
5255};
5256
5257//-----------------------------------------------------------------------------
5258// mpBitmapLayer - provided by Jose Luis Blanco
5259//-----------------------------------------------------------------------------
5265{
5266 public:
5270 {
5271 m_validImg = false;
5272 m_bitmapChanged = false;
5273 m_scaledBitmap_offset_x = m_scaledBitmap_offset_y = 0;
5274 }
5275
5276 ~mpBitmapLayer() override
5277 {
5278 ;
5279 }
5280
5283 void GetBitmapCopy(wxImage &outBmp) const;
5284
5292 void SetBitmap(const wxImage &inBmp, double x, double y, double lx, double ly);
5293
5296 double GetMinX() override
5297 {
5298 return m_bitmapX.min;
5299 }
5300
5303 double GetMaxX() override
5304 {
5305 return m_bitmapX.max;
5306 }
5307
5310 double GetMinY() override
5311 {
5312 return m_bitmapY.min;
5313 }
5314
5317 double GetMaxY() override
5318 {
5319 return m_bitmapY.max;
5320 }
5321
5322 protected:
5323
5326 wxImage m_bitmap;
5332
5337
5338 void DoPlot(wxDC &dc, mpWindow &w) override;
5339
5340 private:
5342};
5343
5344// utility class
5345
5347typedef enum __mp_Colour
5348{
5349 mpBlue,
5350 mpRed,
5351 mpGreen,
5352 mpPurple,
5353 mpYellow,
5354 mpFuchsia,
5355 mpLime,
5356 mpAqua,
5357 mpOlive
5359
5365{
5366 public:
5371 wxIndexColour(const unsigned int id)
5372 {
5373#ifdef _WIN32
5374 auto GetRandomColor = []() {
5375 return (rand() * 255) / RAND_MAX;
5376 };
5377#else
5378 auto GetRandomColor = []() {
5379 return (random() * 255) / RAND_MAX;
5380 };
5381#endif
5382 switch (id)
5383 {
5384 case 0:
5385 this->Set(0, 0, 255);
5386 break; // Blue
5387 case 1:
5388 this->Set(255, 0, 0);
5389 break; // Red
5390 case 2:
5391 this->Set(0, 128, 0);
5392 break; // Green
5393 case 3:
5394 this->Set(128, 0, 128);
5395 break; // Purple
5396 case 4:
5397 this->Set(255, 255, 0);
5398 break; // Yellow
5399 case 5:
5400 this->Set(255, 0, 255);
5401 break; // Fuchsia
5402 case 6:
5403 this->Set(0, 255, 0);
5404 break; // Lime
5405 case 7:
5406 this->Set(0, 255, 255);
5407 break; // Aqua/Cyan
5408 case 8:
5409 this->Set(128, 128, 0);
5410 break; // Olive
5411 default:
5412 this->Set((ChannelType) (GetRandomColor()), (ChannelType) (GetRandomColor()), (ChannelType) (GetRandomColor()));
5413 }
5414 }
5415};
5416
5419// ---------------------------------------------------------------------
5420#if defined(MP_ENABLE_NAMESPACE) || defined(ENABLE_MP_NAMESPACE)
5421 }// namespace MathPlot
5422#endif // MP_ENABLE_NAMESPACE
5423
5424#endif // MATHPLOT_H_INCLUDED
Dialog box for configuring the plot's layer objects In this dialog, you can configure:
Definition MathPlotConfig.h:156
Layer for bar chart.
Definition mathplot.h:2690
~mpBarChart() override
Destructor.
Definition mathplot.h:2696
double GetMaxX() override
Get inclusive right border of bounding box.
double GetMaxY() override
Get inclusive top border of bounding box.
void SetBarColour(const wxColour &colour)
Set the colour used to fill the bars.
void DoPlot(wxDC &dc, mpWindow &w) override
Layer plot handler.
double m_width
Width of each bar/column in plot units.
Definition mathplot.h:2735
double GetMinY() override
Get inclusive bottom border of bounding box.
double GetMinX() override
Get inclusive left border of bounding box.
void SetBarLabelPosition(int position)
Set bar labels positioning.
wxColour m_barColour
Fill colour used for the bars.
Definition mathplot.h:2736
void SetColumnWidth(const double colWidth)
Set the bar width in plot units.
Definition mathplot.h:2705
int m_labelPos
Bar-label placement mode.
Definition mathplot.h:2737
double m_labelAngle
Rotation angle used for bar labels, in degrees.
Definition mathplot.h:2738
mpBarChart(const wxString &name=wxEmptyString, double width=0.5)
Debault constructor.
A layer that allows you to have a bitmap image printed in the mpWindow.
Definition mathplot.h:5265
void SetBitmap(const wxImage &inBmp, double x, double y, double lx, double ly)
Change the bitmap associated with the layer (to update the screen, refresh the mpWindow).
double GetMinY() override
Get inclusive bottom border of bounding box.
Definition mathplot.h:5310
bool m_validImg
True when the source image is valid and ready to draw.
Definition mathplot.h:5330
double GetMinX() override
Get inclusive left border of bounding box.
Definition mathplot.h:5296
void GetBitmapCopy(wxImage &outBmp) const
Returns a copy of the current bitmap assigned to the layer.
wxBitmap m_scaledBitmap
Cached scaled bitmap used for drawing.
Definition mathplot.h:5327
double GetMaxY() override
Get inclusive top border of bounding box.
Definition mathplot.h:5317
wxImage m_bitmap
The internal copy of the Bitmap:
Definition mathplot.h:5326
mpRange< double > m_bitmapX
The shape of the bitmap:
Definition mathplot.h:5335
double GetMaxX() override
Get inclusive right border of bounding box.
Definition mathplot.h:5303
mpBitmapLayer()
Default constructor.
Definition mathplot.h:5269
wxCoord m_scaledBitmap_offset_x
Cached X pixel offset used when drawing the scaled bitmap.
Definition mathplot.h:5328
bool m_bitmapChanged
True when the cached scaled bitmap must be regenerated.
Definition mathplot.h:5331
void DoPlot(wxDC &dc, mpWindow &w) override
Pure virtual method to plot the layer.
mpRange< double > m_bitmapY
Range of the bitmap on y direction.
Definition mathplot.h:5336
wxCoord m_scaledBitmap_offset_y
Cached Y pixel offset used when drawing the scaled bitmap.
Definition mathplot.h:5329
abstract Layer for chart (bar and pie).
Definition mathplot.h:2631
void AddData(const double &data, const std::string &label)
Add data and label.
mpChart(const wxString &name=wxEmptyString)
Default constructor.
void SetChartLabels(const std::vector< std::string > &labelArray)
Set bar label values.
double m_total_value
Total of the values vector.
Definition mathplot.h:2671
void SetChartValues(const std::vector< double > &data)
Set bar values.
std::vector< std::string > labels
Labels of the Values.
Definition mathplot.h:2668
bool HasBBox() override
Check whether this layer has a bounding box.
Definition mathplot.h:2661
double m_max_value
Max value of the values vector.
Definition mathplot.h:2670
std::vector< double > values
Values of the chart.
Definition mathplot.h:2667
virtual void Clear()
Clears all the data, leaving the layer empty.
~mpChart() override
Destructor.
Definition mathplot.h:2637
A 2D ellipse, described by a 2x2 covariance matrix.
Definition mathplot.h:5138
int GetSegments() const
Get the number of line segments used to approximate the ellipse. *‍/.
Definition mathplot.h:5179
double m_cov_11
Covariance matrix element (1,1).
Definition mathplot.h:5207
void SetCovarianceMatrix(const double cov_00, const double cov_01, const double cov_11)
Changes the covariance matrix:
Definition mathplot.h:5195
void SetQuantiles(const double q)
Set how many "quantiles" to draw, that is, the confidence interval of the ellipse (see GetQuantiles a...
Definition mathplot.h:5166
double m_cov_00
The elements of the matrix (only 3 since cov(0,1)=cov(1,0) in any positive definite matrix).
Definition mathplot.h:5206
void SetSegments(const int segments)
Set the number of line segments used to approximate the ellipse.
Definition mathplot.h:5173
double m_quantiles
Confidence-interval multiplier used when drawing the ellipse.
Definition mathplot.h:5209
mpCovarianceEllipse(const double cov_00=1, const double cov_11=1, const double cov_01=0, const double quantiles=2, const int segments=32, const wxString &layerName=_T(""))
Default constructor.
Definition mathplot.h:5143
void RecalculateShape()
Called to update the m_shape_xs, m_shape_ys vectors, whenever a parameter changes.
double GetQuantiles() const
Get the confidence-interval multiplier used for the ellipse.
Definition mathplot.h:5159
int m_segments
The number of line segments that build up the ellipse.
Definition mathplot.h:5213
void GetCovarianceMatrix(double &cov_00, double &cov_01, double &cov_11) const
Returns the elements of the current covariance matrix:
Definition mathplot.h:5186
double m_cov_01
Covariance matrix element (0,1), equal to element (1,0).
Definition mathplot.h:5208
Create a generic FX function Override the ComputeY() function with your function.
Definition mathplot.h:2480
mpFXGeneric(const wxString &name=wxT("Generic FX function"), const int flags=mpALIGN_LEFT, const unsigned int yAxisID=0)
Definition mathplot.h:2486
double GetMinY() override
Get min Y of the function.
Definition mathplot.h:2519
virtual double ComputeY(double x)=0
The main computation of the FX function.
double GetY(const double x) override
Get function value for argument.
Definition mathplot.h:2500
double GetMaxY() override
Get max Y of the function.
Definition mathplot.h:2528
mpRange< double > m_rangeY
Y range.
Definition mathplot.h:2534
Abstract base class providing plot and labeling functionality for functions F:X->Y.
Definition mathplot.h:2021
virtual double GetY(double x)=0
Get function value for argument.
double DoGetY(double x)
Get function value with log if necessary Call DefineDoGetY() function if pDoGetY pointer is not defin...
void DoPlot(wxDC &dc, mpWindow &w) override
Layer plot handler.
double NormalDoGetY(double x)
Definition of the DoGetY function without log.
double LogDoGetY(double x)
Definition of the DoGetY function with log.
mpFX(const wxString &name=wxEmptyString, int flags=mpALIGN_RIGHT, unsigned int yAxisID=0)
void DefineDoGetY(void)
Define the good DoGetY function (with ou without log).
Abstract base class providing plot and labeling functionality for a locus plot F:N->X,...
Definition mathplot.h:2148
void SetViewMode(bool asBar)
Switch series plot like a bar mode.
int m_BarWidth
Bar width in pixels when the XY series is drawn in bar mode.
Definition mathplot.h:2228
virtual void Rewind()=0
Rewind value enumeration with mpFXY::GetNextXY.
double m_deltaX
Min delta between 2 consecutive coordinate on x direction.
Definition mathplot.h:2225
int GetBarWidth(void) const
Get the width of the bar when we plot in bar mode.
Definition mathplot.h:2204
bool DoGetNextXY(double *x, double *y)
Get function value with log test.
double m_deltaY
Min delta between 2 consecutive coordinate on y direction.
Definition mathplot.h:2226
void UpdateViewBoundary(wxCoord xnew, wxCoord ynew)
Update label positioning data.
mpRange< int > m_drawX
Range min and max on x axis.
Definition mathplot.h:2221
mpFXY(const wxString &name=wxEmptyString, int flags=mpALIGN_SW, bool viewAsBar=false, unsigned int yAxisID=0)
mpRange< int > m_drawY
Range min and max on y axis.
Definition mathplot.h:2222
virtual bool GetNextXY(double *x, double *y)=0
Get locus value for next N.
bool ViewAsBar(void) const
Get if we are in bar mode.
Definition mathplot.h:2213
virtual size_t GetSize()
Return the number of points in the series.
Definition mathplot.h:2173
virtual void Clear()
Clears all the data, leaving the layer empty.
Definition mathplot.h:2165
void DoPlot(wxDC &dc, mpWindow &w) override
Layer plot handler.
A class providing graphs functionality for a 2D plot (either continuous or a set of points),...
Definition mathplot.h:2274
const std::vector< double > & GetXData() const
Get read-only access to the internal X data vector.
Definition mathplot.h:2311
double GetMaxX() override
Returns the actual maximum X data (loaded in SetData).
Definition mathplot.h:2408
bool AddData(double x, double y, bool updatePlot)
Add data to the internal vector.
int GetReserve() const
Get memory reserved for m_xs and m_ys.
Definition mathplot.h:2347
size_t GetSize() override
Return the number of points in the series We assume that size of m_xs equals size of m_ys.
Definition mathplot.h:2305
mpRange< double > m_rangeY
Range min and max on y axis.
Definition mathplot.h:2361
~mpFXYVector() override
destrutor
Definition mathplot.h:2285
void Clear() override
Clears all the data, leaving the layer empty.
std::vector< double > m_ys
internal copy of the set of data on y direction
Definition mathplot.h:2354
void DrawAddedPoint(double x, double y)
Draw the point added if there is in bound.
std::vector< double > m_xs
internal copy of the set of data on x direction
Definition mathplot.h:2353
mpFXYVector(const wxString &name=wxEmptyString, int flags=mpALIGN_SW, bool viewAsBar=false, unsigned int yAxisID=0)
double GetMinX() override
Returns the actual minimum X data (loaded in SetData).
Definition mathplot.h:2386
void SetData(const std::vector< double > &xs, const std::vector< double > &ys)
Changes the internal data: the set of points to draw.
void SetReserve(const int reserve)
Set memory reserved for m_xs and m_ys Note : this does not modify the size of m_xs and m_ys,...
Definition mathplot.h:2337
int m_reserveXY
Memory reserved for m_xs and m_ys. Default 1000.
Definition mathplot.h:2356
double GetMaxY() override
Returns the actual maximum Y data (loaded in SetData).
Definition mathplot.h:2423
double m_lastX
Last x-coordinate point added.
Definition mathplot.h:2360
size_t m_endIndex
The end index indicating the last point inside plot area.
Definition mathplot.h:2358
bool m_isMonotonicX
Indicates if all all X values are monotonic, i.e increasing, which enables binary search.
Definition mathplot.h:2355
double GetMinY() override
Returns the actual minimum Y data (loaded in SetData).
Definition mathplot.h:2401
bool GetNextXY(double *x, double *y) override
Get locus value for next N.
void Rewind() override
Calculates the start and end index which shall be used when iterating the data.
double m_lastY
Last y-coordinate point added.
Definition mathplot.h:2362
const std::vector< double > & GetYData() const
Get read-only access to the internal Y data vector.
Definition mathplot.h:2317
mpRange< double > m_rangeX
Range min and max on x axis.
Definition mathplot.h:2359
size_t m_index
The internal counter for the "GetNextXY" interface.
Definition mathplot.h:2357
Abstract base class providing plot and labeling functionality for functions F:Y->X.
Definition mathplot.h:2083
double LogDoGetX(double y)
Definition of the DoGetX function with log.
void DefineDoGetX(void)
Define the good DoGetX function (with ou without log).
void DoPlot(wxDC &dc, mpWindow &w) override
Layer plot handler.
double DoGetX(double y)
Get function value with log if necessary Call DefineDoGetX() function if pDoGetX pointer is not defin...
virtual double GetX(double y)=0
Get function value for argument.
double NormalDoGetX(double y)
Definition of the DoGetX function without log.
mpFY(const wxString &name=wxEmptyString, int flags=mpALIGN_TOP, unsigned int yAxisID=0)
Plot layer implementing an abstract function plot class.
Definition mathplot.h:1743
unsigned int GetStep() const
Get step for plot.
Definition mathplot.h:1777
mpSymbol m_symbol
A symbol for the plot in place of point. Default mpNone.
Definition mathplot.h:1885
bool GetContinuity() const
Gets the 'continuity' property of the layer.
Definition mathplot.h:1763
int GetYAxisID() const
Get the ID of the Y axis used by the function.
Definition mathplot.h:1823
void SetAutoStep(const bool enable)
Enables auto step which is used to plot a maximum nuber of points at a time to the plot no matter zoo...
Definition mathplot.h:1856
virtual bool DrawSymbol(wxDC &dc, wxCoord x, wxCoord y)
Draw a symbol in place of point.
std::optional< double > GetSeriesValue(double xValue)
Get Y value of series at specified X.
size_t GetMaxNOfPoints() const
Get maximum number of points to plot.
Definition mathplot.h:1878
void SetSymbolSize(const int size)
Set symbol size.
Definition mathplot.h:1798
bool m_autoStep
Calculates m_step automatically based on how many points you want to draw.
Definition mathplot.h:1890
void SetLegendIsAlwaysVisible(const bool alwaysVisible)
Set the visibility of the name of the function in the legend despite the visibility of the function i...
Definition mathplot.h:1840
bool m_continuous
Specify if the layer will be plotted as a continuous line or a set of points. Default false.
Definition mathplot.h:1884
size_t m_maxNOfPoints
Maximum number of points to draw to screen.
Definition mathplot.h:1891
bool GetLegendIsAlwaysVisible() const
Get the visibility of the legend.
Definition mathplot.h:1848
bool GetAutoStep() const
Get if auto stop is enabled.
Definition mathplot.h:1863
void SetSymbol(const mpSymbol symbol)
Set symbol.
Definition mathplot.h:1784
int m_yAxisID
The ID of the Y axis used by the function. Equal 0 if no axis.
Definition mathplot.h:1888
void SetContinuity(const bool continuity)
Set the 'continuity' property of the layer.
Definition mathplot.h:1755
void SetStep(const unsigned int step)
Set step for plot.
Definition mathplot.h:1770
mpSymbol GetSymbol() const
Get symbol.
Definition mathplot.h:1791
bool m_LegendIsAlwaysVisible
If true, the name is visible in the legend despite the visibility of the function....
Definition mathplot.h:1889
void SetYAxisID(const unsigned int yAxisID)
Set the ID of the Y axis used by the function.
Definition mathplot.h:1832
mpFunction(mpLayerType layerType=mpLAYER_PLOT, const wxString &name=wxEmptyString, unsigned int yAxisID=0)
Full constructor.
int m_symbolSize
Size of the symbol. Default 6.
Definition mathplot.h:1886
void SetMaxNOfPoints(const size_t nOfPoints)
Set how many points that is allowed to be drawn at a time.
Definition mathplot.h:1871
int GetSymbolSize() const
Get symbol size.
Definition mathplot.h:1805
unsigned int m_step
Step to get point to be draw. Default : 1.
Definition mathplot.h:1887
Classic Gaussian distribution f(x) = exp(-(x-μ)²/2σ²)/sqrt(2πσ²)
Definition mathplot.h:2552
mpGaussian(const double mu, const double sigma)
Classic Gaussian distribution.
Definition mathplot.h:2559
double m_sigma
Sigma value.
Definition mathplot.h:2570
double ComputeY(const double x) override
The main computation of the FX function.
Definition mathplot.h:2574
double m_variance
Sigma² is the variance.
Definition mathplot.h:2571
double m_mu
Mean value.
Definition mathplot.h:2569
double m_const
Const factor.
Definition mathplot.h:2572
Abstract class providing an horizontal line.
Definition mathplot.h:1951
mpHorizontalLine(double yvalue, const wxPen &pen= *wxGREEN_PEN, unsigned int yAxisID=0)
Draw a horizontal line.
void SetYValue(const double yvalue)
Set y.
Definition mathplot.h:1964
void DoPlot(wxDC &dc, mpWindow &w) override
Pure virtual method to plot the layer.
Implements an overlay box which shows the mouse coordinates in plot units.
Definition mathplot.h:1347
bool ShouldBeShown(const wxRect plotArea, const wxPoint mousePos) const
Check conditions if info coords shall be shown or not.
Definition mathplot.h:1403
wxCoord m_mouseX
Last mouse X position in window pixel coordinates.
Definition mathplot.h:1458
bool IsShown() const
Get shown status.
Definition mathplot.h:1394
infoCoordType GetInfoCoordType() const
Get the type of info coordinates to be displayed (axis, closest series, or all series)
Definition mathplot.h:1436
infoCoordType
Type of info coordinates to be displayed (axis, closest series, or all series)
Definition mathplot.h:1369
@ infoCoord_closestSeries
Show the X and Y value of the closest series.
Definition mathplot.h:1371
@ infoCoord_axis
Show axis coordinates at mouse position.
Definition mathplot.h:1370
~mpInfoCoords() override
Default destructor.
Definition mathplot.h:1362
mpLabelType m_labelType
Label formatting mode used for the X coordinate display.
Definition mathplot.h:1456
std::vector< wxColor > m_seriesColors
Colors of the series in the order they were added to the mpWindow.
Definition mathplot.h:1461
void UpdateInfo(mpWindow &w, wxEvent &event) override
Update the content of the info box.
void DoPlot(wxDC &dc, mpWindow &w) override
Plot method.
void DrawContent(wxDC &dc, mpWindow &w)
Draw the content of info coords to plot.
void SetSeriesCoord(const bool show)
Set the series coordinates of the mouse position (if tractable set)
Definition mathplot.h:1420
mpInfoCoords(wxPoint pos, const wxBrush &brush= *wxTRANSPARENT_BRUSH, mpLocation location=mpMarginUser)
Complete constructor, setting initial rectangle and background brush.
wxString m_content
string holding the coordinates to be drawn.
Definition mathplot.h:1455
unsigned int m_timeConv
Time conversion mode used when formatting date/time X values.
Definition mathplot.h:1457
mpInfoCoords(mpLocation location)
Limited constructor.
void SetInfoCoordType(const infoCoordType type)
Set the type of info coordinates to be displayed (axis, closest series, or all series)
Definition mathplot.h:1428
virtual wxString GetInfoCoordsText(mpWindow &w, double xVal, std::unordered_map< int, double > yValList)
Get string describing mouse position.
wxCoord m_mouseY
Last mouse Y position in window pixel coordinates.
Definition mathplot.h:1459
bool m_show
Indicates if magnet shall be shown in plot.
Definition mathplot.h:1454
infoCoordType m_infoCoordType
Type of info coordinates to be displayed (axis, closest series, or all series).
Definition mathplot.h:1460
void ErasePlot(wxDC &, mpWindow &) override
Just delete the bitmap of the info.
Definition mathplot.h:1383
void Show(const bool show)
Set if info coords shall be shown or hidden.
Definition mathplot.h:1387
mpInfoCoords()
Default constructor.
void SetLabelMode(const mpLabelType mode, const unsigned int time_conv=0x20)
Set X axis label view mode.
Definition mathplot.h:1411
Base class to create small rectangular info boxes mpInfoLayer is the base class to create a small rec...
Definition mathplot.h:1227
const wxRect & GetRectangle() const
Get the current rectangle coordinates.
Definition mathplot.h:1300
virtual void ErasePlot(wxDC &, mpWindow &)
Just delete the bitmap of the info.
Definition mathplot.h:1261
double m_relX
Box X position relative window, used to rescale the info box position when the window is resized.
Definition mathplot.h:1323
wxBitmap * m_info_bmp
The bitmap that contain the info.
Definition mathplot.h:1321
void SetVisible(bool show) override
Sets layer visibility.
wxPoint m_reference
Holds the reference point for movements.
Definition mathplot.h:1322
virtual void UpdateInfo(mpWindow &w, wxEvent &event)
Update the content of the info box.
wxRect m_dim
The bounding rectangle of the mpInfoLayer box (may be resized dynamically by the Plot method).
Definition mathplot.h:1320
mpInfoLayer()
Default constructor.
~mpInfoLayer() override
Destructor.
wxPoint GetPosition() const
Get the position of the upper left corner of the box (in pixels)
Definition mathplot.h:1278
void SetInfoRectangle(mpWindow &w, int width=0, int height=0)
Compute the dimensions and position of the mpInfoLayer rectangle.
void SetLocation(const mpLocation location)
Set the location of the mpInfoLayer box.
Definition mathplot.h:1307
void SetInitialPosition(const wxPoint pos)
Set the position in percent of the upper left corner of the box.
Definition mathplot.h:1285
mpLocation GetLocation() const
Return the location of the mpInfoLayer box.
Definition mathplot.h:1314
bool HasBBox() override
mpInfoLayer has not bounding box.
Definition mathplot.h:1253
virtual bool Inside(const wxPoint &point)
Is given point inside the info box rectangle?
virtual void UpdateReference()
Update the rectangle reference point.
double m_relY
Box Y position relative window, used to rescale the info box position when the window is resized.
Definition mathplot.h:1324
mpInfoLayer(wxPoint pos, const wxBrush &brush= *wxTRANSPARENT_BRUSH, mpLocation location=mpMarginUser)
Complete constructor.
void DoPlot(wxDC &dc, mpWindow &w) override
Plot method.
virtual void Move(wxPoint delta, mpWindow &w)
Move the layer rectangle by given pixel deltas.
mpLocation m_location
Location of the box in the margin. Default mpMarginNone = use coordinates.
Definition mathplot.h:1325
wxSize GetSize() const
Get the size of the box (in pixels)
Definition mathplot.h:1293
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
~mpInfoLegend() override
Default destructor.
Definition mathplot.h:1492
int GetLegendHitRegion(wxPoint mousePos)
Checks if mouse is inside legend and if it hovers the header or any of the series If a series is hove...
mpInfoLegend()
Default constructor.
bool m_showDraggedSeries
Indicate if series that has been gripped with mouse shall be drawn.
Definition mathplot.h:1650
void SetNeedUpdate()
Mark the legend bitmap as needing regeneration.
Definition mathplot.h:1523
mpInfoLegend(wxPoint pos, const wxBrush &brush= *wxWHITE_BRUSH, mpLocation location=mpMarginUser)
Complete constructor, setting initial rectangle and background brush.
void ShowSeriesValues(const bool show)
Set if the series values shall be drawn to the plot.
Definition mathplot.h:1567
void DrawDraggedSeries(wxDC &dc, mpWindow &w) const
When a series is being dragged, draw a rectangle with its name at the mouse cursor.
void DrawContent(wxDC &dc, mpWindow &w)
Draw the content of info legend to plot.
void SetVerticalCursorFixed(double posX)
Place the vertical cursor at a fixed position and show the series values.
void SetItemDirection(const mpLegendDirection mode)
Set item direction (may be vertical or horizontal)
Definition mathplot.h:1510
void EnableSeriesValues(const bool enable)
Enables to show series values in the legend.
Definition mathplot.h:1544
void IndicateSeriesIntersection(const bool enable)
Set if the intersection of the series with the vertical cursor shall be indicated.
Definition mathplot.h:1581
void ShowDraggedSeries(const bool active)
Set if dragged series shall be shown or hidden.
Definition mathplot.h:1530
mpLegendStyle m_item_mode
Visual style used for each legend entry.
Definition mathplot.h:1648
mpLegendStyle GetItemMode() const
Get the current legend item drawing mode.
Definition mathplot.h:1503
mpLegendDirection m_item_direction
Layout direction used when arranging legend entries.
Definition mathplot.h:1649
VerticalCursorMode GetVerticalCursorMode() const
Get the current vertical cursor mode.
Definition mathplot.h:1603
void SetVerticalCursorFollowMouse()
Make the vertical cursor follow the mouse position.
bool IsSeriesValuesEnabled() const
Check if series values is enabled in legend.
Definition mathplot.h:1552
VerticalCursorMode
Enumeration for vertical cursor mode, which determines how the vertical cursor is positioned for seri...
Definition mathplot.h:1596
@ CursorMode_mouse
Vertical cursor is at mouse position.
Definition mathplot.h:1597
wxCoord GetVerticalCursorX() const
Get the current x position (in pixels) of the vertical cursor.
static void RestoreAxisHighlighting(mpWindow &w)
Clear the dragged series rectangle from the plot and restores axis hovering indication.
HitCode
Return codes for GetLegendHitRegion() if no series was hit.
Definition mathplot.h:1639
void DoPlot(wxDC &dc, mpWindow &w) override
Plot method.
mpLegendDirection GetItemDirection() const
Get the current legend item layout direction.
Definition mathplot.h:1517
bool IsSeriesValuesShown() const
Indicates if series values shall be shown.
Definition mathplot.h:1574
void SetItemMode(const mpLegendStyle mode)
Set item mode (the element on the left of text representing the plot line may be line,...
Definition mathplot.h:1496
bool IsDraggedSeriesShown() const
Get shown status of dragged series.
Definition mathplot.h:1537
bool SeriesValuesShouldBeShown(const wxRect plotArea, const wxPoint mousePos) const
Check if series values should be shown in plot, depending on where mouse is.
Definition mathplot.h:1560
Plot layer, abstract base class.
Definition mathplot.h:844
void UpdateContext(wxDC &dc) const
Initialize the context.
void Plot(wxDC &dc, mpWindow &w)
Plot given view of layer to the given device context.
mpLayerZOrder m_ZIndex
The index in Z-Order to draw the layer.
Definition mathplot.h:1181
mpLayerType GetLayerType() const
Get layer type: a Layer can be of different types: plot, lines, axis, info boxes, etc.
Definition mathplot.h:879
bool GetDrawOutsideMargins() const
Get Draw mode: inside or outside margins.
Definition mathplot.h:1091
wxFont m_font
Layer's font.
Definition mathplot.h:1169
bool m_drawOutsideMargins
Select if the layer should draw only inside margins or over all DC. Default : false.
Definition mathplot.h:1175
void SetFontColour(const wxColour &colour)
Set layer font foreground colour.
Definition mathplot.h:1013
void SetFont(const wxFont &font)
Set layer font.
Definition mathplot.h:997
bool GetCanDelete(void) const
Retreive what we do with the object associated with the layer when we delete the layer.
Definition mathplot.h:1153
bool IsVisible() const
Is this layer visible?
Definition mathplot.h:1104
const wxString & GetName() const
Get layer name.
Definition mathplot.h:989
mpLayerZOrder GetZIndex(void) const
Get the ZIndex of the plot.
Definition mathplot.h:1160
wxBitmap GetColourSquare(int side=16)
Get a small square bitmap filled with the colour of the pen used in the layer.
wxColour m_fontcolour
Layer's font foreground colour.
Definition mathplot.h:1170
mpWindow * m_win
The wxWindow handle.
Definition mathplot.h:1167
bool m_CanDelete
Is the layer can be deleted.
Definition mathplot.h:1180
bool m_showName
States whether the name of the layer must be shown. Default : false.
Definition mathplot.h:1174
bool m_visible
Toggles layer visibility. Default : true.
Definition mathplot.h:1176
mpRect m_plotBoundaries
The boundaries for plotting curve calculated by mpWindow.
Definition mathplot.h:1179
void SetCanDelete(const bool canDelete)
Set what we do with the object associated with the layer when we delete the layer.
Definition mathplot.h:1146
bool GetShowName() const
Get Name visibility.
Definition mathplot.h:1077
void SetBrush(const wxColour &colour, enum wxBrushStyle style=wxBRUSHSTYLE_SOLID)
Set layer brush.
Definition mathplot.h:1055
virtual void SetTractable(const bool track)
Sets layer tractability.
Definition mathplot.h:1125
void SetAlign(const int align)
Set X/Y alignment.
Definition mathplot.h:1132
const mpLayerType m_type
Layer type mpLAYER_*.
Definition mathplot.h:1166
virtual bool IsLayerType(const mpLayerType typeOfInterest, int *subtype)
Set the layer's subtype in caller variable, and return true if the layer is of type "typeOfInterest".
Definition mathplot.h:897
int m_subtype
Layer sub type, set in constructors.
Definition mathplot.h:1168
const wxFont & GetFont() const
Get font set for this layer.
Definition mathplot.h:1005
int GetLayerSubType() const
Get layer subtype: each layer type can have several flavors.
Definition mathplot.h:887
mpLayer(mpLayerType layerType)
The base class of all layer objects.
const wxColour & GetFontColour() const
Get font foreground colour set for this layer.
Definition mathplot.h:1021
virtual void DoPlot(wxDC &dc, mpWindow &w)=0
Pure virtual method to plot the layer.
bool m_tractable
Is the layer tractable.
Definition mathplot.h:1177
const wxPen & GetPen() const
Get pen set for this layer.
Definition mathplot.h:1037
void SetShowName(const bool show)
Set Name visibility.
Definition mathplot.h:1070
void SetName(const wxString &name)
Set layer name.
Definition mathplot.h:981
bool IsTractable() const
Checks whether the layer is tractable or not.
Definition mathplot.h:1118
int m_flags
Holds label alignment. Default : mpALIGN_SW for series and mpALIGN_CENTER for scale.
Definition mathplot.h:1178
void SetDrawOutsideMargins(const bool drawModeOutside)
Set Draw mode: inside or outside margins.
Definition mathplot.h:1084
virtual void SetVisible(const bool show)
Sets layer visibility.
Definition mathplot.h:1111
wxString m_name
Layer's name.
Definition mathplot.h:1173
wxBrush m_brush
Layer's brush. Default wxTRANSPARENT_BRUSH.
Definition mathplot.h:1172
virtual bool DoBeforePlot()
If we need to do something before plot like reinitialize some parameters ... Return true by default t...
Definition mathplot.h:1197
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition mathplot.h:871
void SetPen(const wxPen &pen)
Set layer pen.
Definition mathplot.h:1029
wxPen m_pen
Layer's pen. Default Colour = Black, width = 1, style = wxPENSTYLE_SOLID.
Definition mathplot.h:1171
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition mathplot.h:914
void SetBrush(const wxBrush &brush)
Set layer brush.
Definition mathplot.h:1044
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition mathplot.h:906
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition mathplot.h:930
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition mathplot.h:922
void SetWindow(mpWindow &w)
Set the wxWindow handle.
Definition mathplot.h:859
void CheckLog(double *x, double *y, int yAxisID)
Test if we are in log axis and if true return the log of the values.
const wxBrush & GetBrush() const
Get brush set for this layer.
Definition mathplot.h:1063
int GetAlign() const
Get X/Y alignment.
Definition mathplot.h:1139
Abstract class providing a line.
Definition mathplot.h:1900
void SetValue(const double value)
Set x or y value.
Definition mathplot.h:1927
bool IsHorizontal(void) const
Is it a horizontal line?
Definition mathplot.h:1935
bool m_IsHorizontal
Is the line horizontal? Default false.
Definition mathplot.h:1942
bool HasBBox() override
Check whether this layer has a bounding box.
Definition mathplot.h:1911
mpLine(double value, const wxPen &pen= *wxGREEN_PEN)
Implement a line.
double GetValue() const
Get the x or y coordinates of the line.
Definition mathplot.h:1919
double m_value
The x or y coordinates of the line.
Definition mathplot.h:1941
Class for drawing mouse magnetization Draw an horizontal and a vertical line at the mouse position.
Definition mathplot.h:3425
void Show(const bool show)
Set if magnet shall be shown or hidden.
Definition mathplot.h:3465
void UpdateBox(const wxRect &plotArea)
Update the drawable magnet area from a wxRect.
Definition mathplot.h:3438
void DrawCross(wxDC &dc, mpWindow &w)
Update the magnet cross to a new mouse position.
void Enable(const bool enable)
Enables the magnet.
Definition mathplot.h:3444
bool IsEnabled() const
Check if magnet is enabled.
Definition mathplot.h:3450
bool ShouldBeShown(const wxPoint mousePos) const
Check conditions if magnet shall be shown.
Definition mathplot.h:3459
bool IsShown() const
Get shown status.
Definition mathplot.h:3471
This virtual class represents objects that can be moved to an arbitrary 2D location+rotation.
Definition mathplot.h:5020
void GetCoordinateBase(double &x, double &y, double &phi) const
Get the current coordinate transformation.
Definition mathplot.h:5035
bool HasBBox() override
Check whether this layer has a bounding box.
Definition mathplot.h:5053
std::vector< double > m_trans_shape_xs
Transformed shape vertices in X coordinates.
Definition mathplot.h:5105
mpRange< double > m_bbox_y
Range of bounding box on y direction.
Definition mathplot.h:5112
mpMovableObject()
Default constructor (sets mpMovableObject location and rotation to (0,0,0))
Definition mathplot.h:5024
double m_reference_phi
Current object rotation angle in radians.
Definition mathplot.h:5092
std::vector< double > m_shape_xs
Shape vertices in object-local X coordinates.
Definition mathplot.h:5101
double GetMinY() override
Get inclusive bottom border of bounding box.
Definition mathplot.h:5074
mpRange< double > m_bbox_x
The precomputed bounding box:
Definition mathplot.h:5111
double m_reference_y
Current object Y position in plot coordinates.
Definition mathplot.h:5091
double GetMinX() override
Get inclusive left border of bounding box.
Definition mathplot.h:5060
double GetMaxX() override
Get inclusive right border of bounding box.
Definition mathplot.h:5067
void DoPlot(wxDC &dc, mpWindow &w) override
Pure virtual method to plot the layer.
void ShapeUpdated()
Must be called by the descendent class after updating the shape (m_shape_xs/ys), or when the transfor...
double GetMaxY() override
Get inclusive top border of bounding box.
Definition mathplot.h:5081
void TranslatePoint(double x, double y, double &out_x, double &out_y) const
A method for 2D translation and rotation, using the current transformation stored in m_reference_x,...
double m_reference_x
The coordinates of the object (orientation "phi" is in radians).
Definition mathplot.h:5090
std::vector< double > m_shape_ys
Shape vertices in object-local Y coordinates.
Definition mathplot.h:5102
std::vector< double > m_trans_shape_ys
Transformed shape vertices in Y coordinates.
Definition mathplot.h:5106
void SetCoordinateBase(const double x, const double y, const double phi=0)
Set the coordinate transformation (phi in radians, 0 means no rotation).
Definition mathplot.h:5044
Classic Normal distribution f(x) = exp(-(ln(x)-μ)²/2σ²)/(xσ.sqrt(2π))
Definition mathplot.h:2588
double ComputeY(const double x) override
The main computation of the FX function.
Definition mathplot.h:2610
double m_const
Const factor.
Definition mathplot.h:2608
double m_variance
Sigma² is the variance.
Definition mathplot.h:2607
double m_mu
Mean value.
Definition mathplot.h:2605
mpNormal(const double mu, const double sigma)
Classic Normal distribution.
Definition mathplot.h:2595
double m_sigma
Sigma value.
Definition mathplot.h:2606
Layer for pie chart.
Definition mathplot.h:2754
void SetCenter(const wxPoint center)
Set the center of the pie chart.
Definition mathplot.h:2771
double GetMaxY() override
Get inclusive top border of bounding box.
Definition mathplot.h:2816
wxPoint m_center
Center of the pie chart in device coordinates.
Definition mathplot.h:2824
double GetMaxX() override
Get inclusive right border of bounding box.
Definition mathplot.h:2800
std::vector< wxColour > colours
Per-slice colours used when drawing the chart.
Definition mathplot.h:2825
~mpPieChart() override
Destructor.
Definition mathplot.h:2762
void SetPieColours(const std::vector< wxColour > &colourArray)
Set colours for the pie.
double m_radius
Radius of the pie chart in pixels.
Definition mathplot.h:2823
mpPieChart(const wxString &name=wxEmptyString, double radius=20)
Default constructor.
void DoPlot(wxDC &dc, mpWindow &w) override
Layer plot handler.
wxPoint GetCenter(void) const
Get the center of the pie chart.
Definition mathplot.h:2779
double GetMinY() override
Get inclusive bottom border of bounding box.
Definition mathplot.h:2808
double GetMinX() override
Get inclusive left border of bounding box.
Definition mathplot.h:2792
const wxColour & GetColour(unsigned int id)
Get the colour used for the slice with the given index.
An arbitrary polygon, descendant of mpMovableObject.
Definition mathplot.h:5231
void setPoints(const std::vector< double > &points_xs, const std::vector< double > &points_ys, bool closedShape=true)
Set the points in the polygon.
mpPolygon(const wxString &layerName=_T(""))
Default constructor.
Definition mathplot.h:5235
Printout class used by mpWindow to draw in the objects to be printed.
Definition mathplot.h:4961
bool OnPrintPage(int page) override
Render the requested print page.
bool HasPage(int page) override
Does this page exist?
mpPrintout(mpWindow *drawWindow, const wxString &title=_T("wxMathPlot print output"), int factor=2)
Construct a printout helper for a plot window.
void SetFactor(const int factor)
Definition mathplot.h:4996
void SetDrawState(const bool drawState)
Set whether the plot has already been drawn on the current printout.
Definition mathplot.h:4984
Abstract base class providing plot and labeling functionality for functions F:Y->X.
Definition mathplot.h:2449
mpProfile(const wxString &name=wxEmptyString, int flags=mpALIGN_TOP)
virtual double GetY(double x)=0
Get function value for argument.
void DoPlot(wxDC &dc, mpWindow &w) override
Layer plot handler.
Plot layer implementing an abstract scale ruler.
Definition mathplot.h:2853
static int GetSignificantDigits(double step, double maxAxisValue)
Get number of significant digits to be used in scientific notation.
mpLabelType GetLabelMode() const
Get axis label view mode.
Definition mathplot.h:2945
void GetScale(double *min, double *max) const
Get the minimum and maximum of the scale range when we are in automatic mode.
Definition mathplot.h:3043
void ShowTicks(const bool ticks)
Set axis ticks.
Definition mathplot.h:2906
mpLabelType m_labelType
Select labels mode: mpLabel_AUTO for normal labels, mpLabel_TIME for time axis in hours,...
Definition mathplot.h:3134
bool m_isLog
Is the axis a log axis ?
Definition mathplot.h:3137
bool m_grids
Flag to show grids. Default false.
Definition mathplot.h:3131
void SetLabelFormat(const wxString &format, const bool updateLabelMode=false)
Set axis Label format (used for mpLabel_AUTO draw mode).
Definition mathplot.h:2936
void SetAxisID(const unsigned int yAxisID)
Set an ID to the axis.
Definition mathplot.h:2899
virtual bool IsLogAxis()
Get if we are in Logarithmic mode.
Definition mathplot.h:3076
const wxString & GetLabelFormat() const
Get axis Label format (used for mpLabel_AUTO draw mode).
Definition mathplot.h:2961
void SetCoordIsAlwaysVisible(const bool alwaysVisible)
Set the visibility of the mouse coordinates in the info coordinates despite the visibility of the axi...
Definition mathplot.h:3092
void SetScale(const mpRange< double > range)
Set the minimum and maximum of the scale range when we are in automatic mode.
Definition mathplot.h:3052
virtual int GetOrigin(mpWindow &w)=0
virtual function to compute origin of the axis
bool GetCoordIsAlwaysVisible() const
Get the visibility of the mouse coordinates in the info coordinates.
Definition mathplot.h:3100
static bool UseScientific(double maxAxisValue)
Checks if scientific notation shall be used on the labels.
static int GetDecimalDigits(double step)
Get number of decimal digits to be used in decimal notation.
bool GetShowTicks() const
Get axis ticks.
Definition mathplot.h:2913
int m_axisID
Unique ID that identify this axis. Default -1 mean that axis is not used.
Definition mathplot.h:3128
bool m_CoordIsAlwaysVisible
If true, the mouse coordinates is visible in the info coordinates despite the visibility of the axis....
Definition mathplot.h:3139
virtual void SetLogAxis(const bool log)
Set Logarithmic mode.
Definition mathplot.h:3084
void ShowGrids(const bool grids)
Set axis grids.
Definition mathplot.h:2920
bool m_ticks
Flag to show ticks. Default true.
Definition mathplot.h:3130
unsigned int m_timeConv
Selects if time has to be converted to local time or not.
Definition mathplot.h:3135
bool HasBBox() override
Check whether this layer has a bounding box.
Definition mathplot.h:2882
mpRange< double > m_axisRange
Range axis values when autosize is false.
Definition mathplot.h:3133
void SetAuto(const bool automaticScalingIsEnabled)
Enable/Disable automatic scaling for this axis.
Definition mathplot.h:2985
int GetLabelWidth(double value, wxDC &dc, const mpScaleConstraints &constraints)
Get label text width for a given value.
void SetHovering(const bool hover)
Set if axis shall be highlighted when a series is dragged over it.
Definition mathplot.h:3068
int GetAxisID(void) const
Return the ID of the Axis.
Definition mathplot.h:2890
wxString m_labelFormat
Format string used to print labels.
Definition mathplot.h:3136
double GetMaxScale() const
Get the maximum of the scale range when we are in automatic mode.
Definition mathplot.h:3025
void SetMaxScale(const double max)
Set the maximum of the scale range when we are in automatic mode.
Definition mathplot.h:3017
virtual void DrawScaleName(wxDC &dc, mpWindow &w, int origin, int labelSize)=0
Draw the name of the scale This function is virtual and need to be overloaded in child class.
bool GetAuto() const
Is automatic scaling enabled for this axis?
Definition mathplot.h:2993
const wxPen & GetGridPen() const
Get pen set for this axis.
Definition mathplot.h:2977
static mpScaleConstraints ComputeScaleConstraints(double step, double maxAxisValue)
Compute the scale constraints for the given step size and axis range.
void SetScale(const double min, const double max)
Set the minimum and maximum of the scale range when we are in automatic mode.
Definition mathplot.h:3034
bool m_auto
Flag to autosize grids. Default true.
Definition mathplot.h:3132
mpScale(const wxString &name, int flags, bool grids, mpLabelType labelType=mpLabel_AUTO, mpOptional_uint axisID=std::nullopt)
Full constructor.
wxPen m_gridpen
Grid's pen. Default Colour = LIGHT_GREY, width = 1, style = wxPENSTYLE_DOT.
Definition mathplot.h:3129
bool GetShowGrids() const
Get axis grids.
Definition mathplot.h:2927
void SetLabelMode(const mpLabelType mode, const unsigned int time_conv=0x20)
Set axis label view mode.
Definition mathplot.h:2953
void SetMinScale(const double min)
Set the minimum of the scale range when we are in automatic mode.
Definition mathplot.h:3001
static wxString FormatLogValue(double n)
Formats a value to a string used on a log axis.
mpRange< double > GetScale() const
Get the minimum and maximum of the scale range when we are in automatic mode.
Definition mathplot.h:3060
void SetGridPen(const wxPen &pen)
Set grid pen.
Definition mathplot.h:2969
static double GetStep(double scale, int minLabelSpacing)
Calculate a 'nice' label step size for the given dataset and desired pixel spacing.
wxString FormatLabelValue(double value, const mpScaleConstraints &constraints)
Formats a label value to a string Use m_ScaleConstraints, so this structure must be up to date.
double GetMinScale() const
Get the minimum of the scale range when we are in automatic mode.
Definition mathplot.h:3009
Plot layer implementing a x-scale ruler.
Definition mathplot.h:3206
bool IsTopAxis() const
Return true when this X axis is aligned at the top edge or top border.
Definition mathplot.h:3220
mpScaleX(const wxString &name=_T("X"), const int flags=mpALIGN_CENTERX, const bool grids=false, const mpLabelType type=mpLabel_AUTO)
Full constructor.
Definition mathplot.h:3213
void DoPlot(wxDC &dc, mpWindow &w) override
Layer plot handler.
static int m_orgy
The y origin coordinate of the X axis We declare it static so we can access to it in mpScaleY.
Definition mathplot.h:3236
void DrawScaleName(wxDC &dc, mpWindow &w, int origin, int labelSize) override
Draw the name of the scale This function is virtual and need to be overloaded in child class.
int GetOrigin(mpWindow &w) override
virtual function to compute origin of the axis
bool IsBottomAxis() const
Return true when this X axis is aligned at the bottom edge or bottom border.
Definition mathplot.h:3226
Plot layer implementing a y-scale ruler.
Definition mathplot.h:3261
void DoPlot(wxDC &dc, mpWindow &w) override
Layer plot handler.
bool IsInside(const wxCoord xPixel) const
Return true if the given X pixel lies within this Y-axis drawing area.
Definition mathplot.h:3316
int m_axisWidth
Reserved width for this Y axis including labels, in pixels.
Definition mathplot.h:3326
void UpdateAxisWidth(mpWindow &w)
Recalculate the axis width based on the label and name text sizes.
bool GetAutoHideAxis() const
Return true if this axis is automatically hidden when not used by any series.
Definition mathplot.h:3298
int m_xPos
Leftmost X pixel occupied by this axis (starting point).
Definition mathplot.h:3327
void SetAutoHideAxis(const bool autoHide)
Enable or disable automatic hiding of this axis when no series uses it.
Definition mathplot.h:3292
int GetAxisWidth() const
Get the reserved width of the Y axis in pixels.
Definition mathplot.h:3284
void DrawScaleName(wxDC &dc, mpWindow &w, int origin, int maxLabelWidth) override
Draw the name of the scale This function is virtual and need to be overloaded in child class.
int GetOrigin(mpWindow &w) override
virtual function to compute origin of the axis
bool IsLeftAxis() const
Return true if this Y axis is aligned to the left side.
Definition mathplot.h:3304
bool m_autoHideAxis
Hide axis automatically if no series uses it. Default: false.
Definition mathplot.h:3328
mpScaleY(const wxString &name=_T("Y"), const int flags=mpALIGN_CENTERY, const bool grids=false, const mpOptional_uint yAxisID=std::nullopt, const mpLabelType labelType=mpLabel_AUTO)
Full constructor.
Definition mathplot.h:3270
bool IsRightAxis() const
Return true if this Y axis is aligned to the right side.
Definition mathplot.h:3310
Plot layer implementing a text string.
Definition mathplot.h:4855
mpLocation m_location
The location of the text.
Definition mathplot.h:4918
void SetLocation(const mpLocation location)
Set the location of the box.
Definition mathplot.h:4888
mpText(const wxString &name=wxEmptyString)
Default constructor.
Definition mathplot.h:4859
int m_offsetx
Holds offset for X in percentage.
Definition mathplot.h:4916
void GetOffset(int *offX, int *offY) const
Get the offset.
Definition mathplot.h:4909
bool HasBBox() override
Text Layer has not bounding box.
Definition mathplot.h:4881
mpLocation GetLocation() const
Returns the location of the box.
Definition mathplot.h:4895
void DoPlot(wxDC &dc, mpWindow &w) override
Text Layer plot handler.
mpText(const wxString &name, mpLocation marginLocation)
void SetOffset(const int offX, const int offY)
Set offset.
Definition mathplot.h:4902
int m_offsety
Holds offset for Y in percentage.
Definition mathplot.h:4917
mpText(const wxString &name, int offsetx, int offsety)
Plot layer implementing a simple title.
Definition mathplot.h:4932
mpTitle(const wxString &name)
Definition mathplot.h:4940
mpTitle()
Default constructor.
Abstract class providing an vertical line.
Definition mathplot.h:1980
bool DoBeforePlot() override
This is the only case where we don't need and Y axis So no need to test m_yAxisID.
Definition mathplot.h:2005
mpVerticalLine(double xvalue, const wxPen &pen= *wxGREEN_PEN)
Draw a vertical line.
void SetXValue(const double xvalue)
Set x.
Definition mathplot.h:1992
void DoPlot(wxDC &dc, mpWindow &w) override
Pure virtual method to plot the layer.
Canvas for plotting mpLayer implementations.
Definition mathplot.h:3504
mpRange< double > GetVisibleRangeY(const unsigned int yAxisID=0)
Get the visible range for Y axis of ID yAxisID, i.e.
Definition mathplot.h:3771
const wxString & GetWildcard(void) const
Get wildcard.
Definition mathplot.h:4201
double GetPosY(const int yAxisID)
Get current view's Y position.
Definition mathplot.h:3844
mpInfoLayer * m_movingInfoLayer
For moving info layers over the window area.
Definition mathplot.h:4788
mpRange< double > GetDesiredBoundX(void) const
Get desired bounding box for X axis.
Definition mathplot.h:3736
int GetScreenY(void) const
Get current view's Y dimension in device context units.
Definition mathplot.h:3906
int GetNOfYAxis(void) const
Get the number of Y axis.
Definition mathplot.h:3853
virtual void OnMouseLeftRelease(wxMouseEvent &event)
Mouse left click (for rect zoom)
void SetColourTheme(const wxColour &bgColour, const wxColour &drawColour, const wxColour &axesColour)
Set Color theme.
void UnSetOnUserMouseAction()
Remove the 'user mouse action event' callback.
Definition mathplot.h:4498
void ZoomRect(wxPoint p0, wxPoint p1)
Zoom view fitting given coordinates to the window (p0 and p1 do not need to be in any specific order)
double m_mouseScaleX
Store current X-scale, used as reference during drag zooming.
Definition mathplot.h:4783
bool GetDrawBox() const
Get the draw of the box around the plot.
Definition mathplot.h:4412
int m_infoLegendSelectedSeries
Only used with config window: the selected series in info legend.
Definition mathplot.h:4805
void OpenConfigWindow(mpLayerType layerType=mpLAYER_UNDEF, int param=-1)
Opens the configuration window, creating it lazily on first use.
virtual void OnToggleCoords(wxCommandEvent &event)
Toggle Coords handler.
mpRange< double > GetDesiredBoundY(const int yAxisID)
Get desired bounding box for Y axis of ID yAxisID.
Definition mathplot.h:3753
bool m_mouseMovedAfterRightClick
If the mouse does not move after a right click, then the context menu is displayed.
Definition mathplot.h:4779
mpInfoLayer * GetMovingInfoLayer() const
Returns moving info layer.
Definition mathplot.h:4598
bool PointIsInsideBound(const double px, const double py, const int yAxisID)
Is the given point inside the current bounding box for the selected Y axis?
Definition mathplot.h:4125
bool m_enableMouseNavigation
For pan/zoom with the mouse.
Definition mathplot.h:4777
const wxColour & GetAxesColour() const
Get axes draw colour.
Definition mathplot.h:4455
void SetOnDeleteLayer(const mpOnDeleteLayer &event)
On delete layer event Allows the user to perform certain actions before deleting the layer.
Definition mathplot.h:4477
virtual void OnMouseWheel(wxMouseEvent &event)
Mouse handler for the wheel.
int GetExtraMargin() const
Get the extra margin.
Definition mathplot.h:4354
bool IsLayerVisible(const wxString &name)
Check whether a layer with given name is visible.
bool SaveScreenshot(const wxString &filename, int type=wxBITMAP_TYPE_BMP, wxSize imageSize=wxDefaultSize, bool fit=false)
Draw the window on a wxBitmap, then save it to a file.
unsigned int CountLayersFXYPlot()
Counts the number of XY plot layers.
unsigned int CountLayersType(mpLayerType type)
Counts the number of plot layers: this is to count only the layers which have a plot.
void ZoomInX()
Zoom in current view along X around center and refresh display.
std::unordered_map< int, double > m_mouseScaleYList
Store current Y-scales, used as reference during drag zooming.
Definition mathplot.h:4784
bool m_boxZoomActive
Indicate if box zoom is active.
Definition mathplot.h:4792
void SetPosY(std::unordered_map< int, double > &posYList)
Set current view's Y position and refresh display.
Definition mathplot.h:3829
bool GetMagnetize() const
Is mouse magnetization enabled? Useful to read the position on the axes.
Definition mathplot.h:4556
virtual void OnMouseHelp(wxCommandEvent &event)
Help handler.
virtual void OnSize(wxSizeEvent &event)
Size handler, will update scroll bar sizes.
void SetMouseLeftDownAction(const mpMouseButtonAction action)
Set the type of action for the left mouse button.
Definition mathplot.h:4571
virtual void OnScrollPageDown(wxScrollWinEvent &event)
Scroll page down.
int m_last_lx
Last logical X origin, used for double buffering.
Definition mathplot.h:4771
void SetLayerVisible(const unsigned int position, bool viewable)
Sets the visibility of a layer by its position in layer list.
bool m_autoFit
Automatically fit plot when hiding / showing axis and series.
Definition mathplot.h:4787
virtual void OnToggleGrids(wxCommandEvent &event)
Toggle Grids handler.
virtual void OnMouseMove(wxMouseEvent &event)
Mouse handler for mouse motion (for pan)
void Zoom(bool zoomIn, const wxPoint &centerPoint)
zoom action
bool IsLogYaxis(const int yAxisID)
Get the log property (true or false) Y layer (Y axis) with a specific Y ID or false if not found.
Definition mathplot.h:4520
wxMemoryDC * GetMemoryDC(void)
Give a direct access to the memory DC to draw in the buffered bitmap You need release the bitmap afte...
Definition mathplot.h:4651
mpMagnet m_magnet
For mouse magnetization.
Definition mathplot.h:4794
virtual void OnLoadFile(wxCommandEvent &event)
Load File handler.
void SetAutoFit(const bool autoFit)
Set if plot shall be auto fitted when hiding or showing axis and series via mouse.
Definition mathplot.h:4253
void SetMargins(int top, int right, int bottom, int left)
Set window margins, creating a blank area where some kinds of layers cannot draw.
int GetScreenX(void) const
Get current view's X dimension in device context units.
Definition mathplot.h:3895
virtual void OnShowPopupMenu(wxMouseEvent &event)
Mouse handler, will show context menu.
bool m_enableBufferedPaintDC
For auto DC double buffering.
Definition mathplot.h:4776
mpOptional_int IsInsideYAxis(const wxPoint &point)
Check if a given point is inside the area of a visible Y-axis and returns its ID if so.
mpMouseButtonAction GetMouseLeftDownAction() const
Returns the type of action for the left mouse button.
Definition mathplot.h:4580
void SetScaleX(const double scaleX)
Set current view's X scale and refresh display.
Definition mathplot.h:3679
void SetDefaultDir(const wxString &dirname)
Set the default directory for wxFileDialog.
Definition mathplot.h:4219
virtual void OnScrollBottom(wxScrollWinEvent &event)
Scroll to bottom.
unsigned int CountLayers()
Counts the number of plot layers, including axes: this is to count only the layers which have a bound...
mpLayer * GetLayerByClassName(const wxString &name)
void SetLogXaxis(const bool log)
Enable or disable logarithmic scaling on the X axis.
Definition mathplot.h:4534
int GetRightYAxesWidth(mpOptional_int yAxisID=std::nullopt)
Calculate width of all axes to the right of this axis.
void SetBound()
Update bound for mpFX and mpFY when axis is scaled.
mpRect GetPlotBoundaries(const bool with_margin) const
Get the boundaries of the plot.
Definition mathplot.h:4381
void EnableBufferedPaintDC(const bool enabled)
Enable/disable the auto buffering of PaintDC.
Definition mathplot.h:3970
wxBitmap m_buff_bmp
Bmp for double buffering.
Definition mathplot.h:4773
mpMouseButtonAction m_mouseLeftDownAction
Type of action for left mouse button.
Definition mathplot.h:4778
mpLayer * GetLayersType(int position, mpLayerType type)
wxMemoryDC m_buff_dc
DC for double buffering.
Definition mathplot.h:4774
wxCoord x2p(const double x) const
Converts graph (floating point) coordinates into mpWindow (screen) pixel coordinates,...
Definition mathplot.h:3944
void Paint(wxDC &dc)
Paint handler which plot all attached layers, with possibility to chose type of DC.
mpScale * GetLayerAxis(int position, mpScaleType scale=mpsAllType)
wxTopLevelWindow * m_parent
Pointer to the top-level window containing the plot (used for fullscreen)
Definition mathplot.h:4742
wxRect m_PlotArea
The full size of the plot with m_extraMargin.
Definition mathplot.h:4769
virtual void OnZoomIn(wxCommandEvent &event)
Zoom In handler.
int m_clickedY
Last mouse click Y position, for centering and zooming the view.
Definition mathplot.h:4759
wxColour m_bgColour
Background Colour.
Definition mathplot.h:4751
void RefreshLegend(void)
virtual void OnScrollLineDown(wxScrollWinEvent &event)
Scroll line down.
wxCoord m_plotHeight
Height of the plot = m_scrY - (m_margin.top + m_margin.bottom)
Definition mathplot.h:4765
mpRange< double > GetBoundY(const int yAxisID)
Get bounding box for Y axis of ID yAxisID.
Definition mathplot.h:3744
void SetLogYaxis(const int yAxisID, const bool log)
Set the log property (true or false) for a Y layer (Y axis) given by is ID.
Definition mathplot.h:4545
void SetWildcard(const wxString &wildcard)
Set wildcard for LoadFile() function when we use wxFileDialog.
Definition mathplot.h:4193
wxCoord m_plotWidth
Width of the plot = m_scrX - (m_margin.left + m_margin.right)
Definition mathplot.h:4764
wxPoint m_mouseLClick
Starting coords for rectangular zoom selection.
Definition mathplot.h:4782
mpScaleY * GetLayerYAxis(int yAxisID)
void DrawBoxZoom(wxDC &dc)
Draws the box zoom selection rectangle.
virtual void OnFit(wxCommandEvent &event)
Fit handler.
const wxColour & GetbgColour() const
Get the plot background colour.
Definition mathplot.h:4461
bool m_lockaspect
Scale aspect is locked or not.
Definition mathplot.h:4750
void SetScaleYAndCenter(double scaleY, int yAxisID)
Set the m_scaleY directly to fixed zoom level, but also adjust m_posY to to make the zoom around cent...
bool m_enableScrollBars
Enable scrollbar in plot window (default false)
Definition mathplot.h:4786
mpLayer * GetLayerPlot(int position, mpFunctionType func=mpfAllType)
void UpdateBoundingBoxToInclude(const double px, const double py, const int yAxisID)
Ensure the bounding box includes the given point for the selected Y axis.
Definition mathplot.h:4138
void SetLayerVisible(const wxString &name, bool viewable)
Sets the visibility of a layer by its name.
bool m_drawBox
Draw box of the plot bound. Default true.
Definition mathplot.h:4754
void SetScreen(const int scrX, const int scrY)
Set current view's dimensions in device context units.
Definition mathplot.h:3871
mpWindow(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long flags=0)
Construct a plotting window.
void RefreshConfigWindow(mpLayerType layerType=mpLAYER_UNDEF, int param=-1)
Refresh the config window if present.
void DoZoomXCalc(bool zoomIn, wxCoord staticXpixel=-1)
Zoom in or out X around a X position.
virtual void OnLockAspect(wxCommandEvent &event)
Lock Aspect handler.
bool IsLogXaxis() const
Is this an X axis to be displayed with log scale? It is really an axis property but as we need to con...
Definition mathplot.h:4508
int GetMarginTop(const bool minusExtra=false) const
Get the top margin.
Definition mathplot.h:4281
static void SetDefaultLegendIsAlwaysVisible(const bool visible)
Set if legend is always visible even if series is not plotted.
Definition mathplot.h:4238
void RenderOverlays(wxDC &dc)
Draw fast moving objects as a overlay on top of the buffered DC, without having to re-draw all layers...
virtual void OnScrollPageUp(wxScrollWinEvent &event)
Scroll page up.
virtual void OnPaint(wxPaintEvent &event)
Paint handler, will plot all attached layers.
bool IsLayerVisible(const unsigned int position)
Check whether the layer at given position is visible.
wxPoint m_mousePos
Current mouse position in window.
Definition mathplot.h:4780
mpRect m_plotBoundaries
The full size of the plot. Calculated.
Definition mathplot.h:4767
bool LoadFile(const wxString &filename=wxEmptyString)
Load a data file like a csv file Data must be formatted in 2 or more columns.
double GetScaleX(void) const
Get current view's X scale.
Definition mathplot.h:3693
std::optional< mpPlotHit > GetClosestPlot(wxCoord ix, wxCoord iy)
bool AddLayer(mpLayer *layer, bool fit=true, bool refreshConfig=true)
Add a plot layer to the canvas.
int GetPlotWidth() const
Get the width of the plot.
Definition mathplot.h:4366
void SetScaleXAndCenter(double scaleX)
Set the m_scaleX directly to fixed zoom level, but also adjust m_posX to to make the zoom around cent...
bool DelLayer(mpLayer *layer, mpDeleteAction alsoDeleteObject, bool refreshDisplay=true, bool refreshConfig=true)
Remove a plot layer from the canvas.
wxPoint m_mouseRClick
For the right button "drag" feature.
Definition mathplot.h:4781
virtual void OnMouseLeftDown(wxMouseEvent &event)
Mouse left click (for rect zoom)
std::unordered_map< int, mpRange< double > > GetAllDesiredY()
Returns the desired bounds for all Y-axes.
Definition mathplot.h:3796
int GetLayerPosition(mpLayer *layer)
bool IsYAxisUsedByFunction(int yAxisID)
void ZoomInY(mpOptional_int yAxisID=std::nullopt)
Zoom in current view along Y around center and refresh display.
void EnableMousePanZoom(const bool enabled)
Enable/disable the feature of pan/zoom with the mouse (default=enabled)
Definition mathplot.h:3977
mpAxisList GetAxisDataYList(void) const
Get the Y-axis data map.
Definition mathplot.h:3861
void UpdateDesiredBoundingBox(const mpAxisUpdate update)
Update m_desired bounds.
Definition mathplot.h:4088
void ZoomIn(const wxPoint &centerPoint=wxDefaultPosition)
Zoom into current view and refresh display.
void DoZoomYCalc(bool zoomIn, wxCoord staticYpixel=-1, mpOptional_int yAxisID=std::nullopt)
Zoom in or out Y around a Y position.
wxColour m_fgColour
Foreground Colour.
Definition mathplot.h:4752
void ZoomOut(const wxPoint &centerPoint=wxDefaultPosition)
Zoom out current view and refresh display.
void SetMarginBottom(const int bottom)
Set the bottom margin.
Definition mathplot.h:4313
int GetMarginLeft(const bool minusExtra=false) const
Get the left margin.
Definition mathplot.h:4338
bool IsAspectLocked() const
Checks whether the X/Y scale aspect is locked.
Definition mathplot.h:3993
mpRange< double > GetBoundX(void) const
Get bounding box for X axis.
Definition mathplot.h:3730
mpAxisList m_AxisDataYList
List of axis data for the Y direction.
Definition mathplot.h:4747
double p2x(const wxCoord pixelCoordX) const
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
Definition mathplot.h:3925
void SetDrawBox(const bool drawbox)
Set the draw of the box around the plot.
Definition mathplot.h:4406
mpInfoLayer * IsInsideInfoLayer(const wxPoint &point)
Check if a given point is inside the area of a mpInfoLayer and eventually returns its pointer.
void DelAllLayers(mpDeleteAction alsoDeleteObject, bool refreshDisplay=true)
Remove all layers from the plot.
void LockAspect(bool enable=true)
Enable or disable X/Y scale aspect locking for the view.
void SetOnUserMouseAction(const mpOnUserMouseAction &userMouseEventHandler)
On user mouse action event Allows the user to perform certain actions before normal event processing.
Definition mathplot.h:4492
void UpdateAll()
Refresh display.
wxString m_DefaultDir
The default directory for wxFileDialog.
Definition mathplot.h:4799
wxMenu m_popmenu
Canvas' context menu.
Definition mathplot.h:4749
virtual void OnScrollThumbTrack(wxScrollWinEvent &event)
Scroll thumb on scroll bar moving.
bool CheckUserMouseAction(wxMouseEvent &event)
Check if a user mouse action is required.
virtual void OnMouseLeave(wxMouseEvent &event)
Mouse handler for mouse motion (for pan)
double GetScaleY(const int yAxisID)
Get current view's Y scale.
Definition mathplot.h:3718
int m_clickedX
Last mouse click X position, for centering and zooming the view.
Definition mathplot.h:4758
virtual void OnCenter(wxCommandEvent &event)
Center handler.
void SetMarginRight(const int right)
Set the right margin.
Definition mathplot.h:4290
void InitializeBoundingBox(const double px, const double py, const int yAxisID)
Initialize the bounding box from a first point for the selected Y axis.
Definition mathplot.h:4153
wxMenu * GetPopupMenu()
Get reference to context menu of the plot canvas.
Definition mathplot.h:3526
void SetPos(const double posX, std::unordered_map< int, double > &posYList)
Set current view's X and Y position and refresh display.
Definition mathplot.h:3916
static bool m_DefaultCoordIsAlwaysVisible
This value sets the default behaviour when an axis is not visible for the mouse info coordinates disp...
Definition mathplot.h:4246
void DelAllYAxisAfterID(mpDeleteAction alsoDeleteObject, int yAxisID=0, bool refreshDisplay=true)
Remove all extra y axis after the selected y axis.
static bool m_DefaultLegendIsAlwaysVisible
This value sets the default behaviour when a series is not visible for the legend display.
Definition mathplot.h:4231
wxBitmap * BitmapScreenshot(wxSize imageSize=wxDefaultSize, bool fit=false)
Get a screen shot of the window plot.
void DeleteConfigWindow(void)
Deletes configuration window.
void EnableDoubleBuffer(const bool enabled)
Deprecated: Enable/disable the double-buffering of the window, eliminating the flicker (default=enabl...
Definition mathplot.h:3962
virtual void OnFullScreen(wxCommandEvent &event)
FullScreen handler.
void SetMPScrollbars(bool status)
Enable/disable scrollbars.
wxBitmap * m_Screenshot_bmp
For clipboard, save and print.
Definition mathplot.h:4796
void DelAllPlot(mpDeleteAction alsoDeleteObject, mpFunctionType func=mpfAllType, bool refreshDisplay=true, bool refreshConfig=true)
Remove all plot layers.
void ClipboardScreenshot(wxSize imageSize=wxDefaultSize, bool fit=false)
Send the screen shot to the Clipboard.
virtual void BindEvents(void)
Connect all events.
virtual void OnScreenShot(wxCommandEvent &event)
ScreenShot handler.
virtual void OnScrollLineUp(wxScrollWinEvent &event)
Scroll line up.
void Fit(const mpRange< double > &rangeX, std::unordered_map< int, mpRange< double > > rangeY, bool updateDesired=true, wxCoord *printSizeX=NULL, wxCoord *printSizeY=NULL)
Set view to fit a given bounding box and refresh display with UpdateAll().
mpLayerList m_layers
List of attached plot layers.
Definition mathplot.h:4745
void SetbgColour(const wxColour &colour)
Set the plot background colour.
Definition mathplot.h:4467
static double m_zoomIncrementalFactor
This value sets the zoom steps whenever the user clicks "Zoom in/out" or performs zoom with the mouse...
Definition mathplot.h:4226
virtual void OnZoomOut(wxCommandEvent &event)
Zoom Out handler.
int GetMarginBottom(const bool minusExtra=false) const
Get the bottom margin.
Definition mathplot.h:4321
mpFloatRectSimple GetBoundingBox(const bool desired, const unsigned int yAxisID=0)
Return a bounding box for an y-axis ID.
Definition mathplot.h:4111
void SetScaleY(const double scaleY, const int yAxisID)
Set current view's Y scale and refresh display.
Definition mathplot.h:3702
wxColour m_axColour
Axes Colour.
Definition mathplot.h:4753
mpLayer * GetLayerByName(const wxString &name)
virtual void OnMouseLeftDoubleClick(wxMouseEvent &event)
Mouse left double click (opens the configuration window of a Y-axis)
mpAxisData m_AxisDataX
Axis data for the X direction.
Definition mathplot.h:4746
void SetPosX(const double posX)
Set current view's X position and refresh display.
Definition mathplot.h:3809
mpRect m_marginOuter
Margin around the plot exluding Y-axis. Default 50.
Definition mathplot.h:4762
mpLayer * GetLayer(int position)
mpRect m_margin
Margin around the plot including Y-axis.
Definition mathplot.h:4761
void ZoomOutX()
Zoom out current view along X around center and refresh display.
void InitParameters()
Function to initialize all variables to their default values This function is called in mpWindow cons...
virtual void OnMouseRightDown(wxMouseEvent &event)
Mouse handler, for detecting when the user drags with the right button or just "clicks" for the menu.
int GetPlotHeight() const
Get the height of the plot.
Definition mathplot.h:4372
int GetLeftYAxesWidth(mpOptional_int yAxisID=std::nullopt)
Calculate width of all axes to the left of this axis.
void SetMarginTop(const int top)
Set the top margin.
Definition mathplot.h:4273
std::unordered_map< int, mpRange< double > > GetAllBoundY()
Returns the bounds for all Y-axes.
Definition mathplot.h:3782
mpRange< double > GetVisibleRangeX()
Get the visible range for X axis, i.e.
Definition mathplot.h:3762
void ZoomOutY(mpOptional_int yAxisID=std::nullopt)
Zoom out current view along Y around center and refresh display.
virtual void DesiredBoundsHaveChanged()
To be notified of displayed bounds changes (after user zoom etc), override this callback in your deri...
Definition mathplot.h:4813
unsigned int CountAllLayers() const
Counts the number of plot layers, whether or not they have a bounding box.
Definition mathplot.h:4067
double GetPosX(void) const
Get current view's X position.
Definition mathplot.h:3820
int m_scrY
Current view's Y dimension.
Definition mathplot.h:4757
void SetExtraMargin(const int extra)
Set the extra margin.
Definition mathplot.h:4347
bool m_cacheDirty
Indicate that the cached buffer m_buff_bmp need to be re-created.
Definition mathplot.h:4775
int GetMarginRight(const bool minusExtra=false) const
Get the right margin.
Definition mathplot.h:4298
void FitX(void)
Similar to Fit() but only fit in X.
mpOptional_int m_mouseYAxisID
Indicate which ID of Y-axis the mouse was on during zoom/pan.
Definition mathplot.h:4785
bool m_fullscreen
Boolean value indicating that we are in fullscreen mode (default false)
Definition mathplot.h:4743
wxPoint GetMousePosition() const
Returns current mouse position in window.
Definition mathplot.h:4589
bool GetMPScrollbars() const
Get scrollbars status.
Definition mathplot.h:4168
void SetMagnetize(const bool mag)
Enable or disable mouse-position magnet lines (cross-hairs) in the plot area.
Definition mathplot.h:4562
void Fit() override
Set view to fit global bounding box of all plot layers and refresh display with UpdateAll().
wxCoord y2p(const double y, const int yAxisID=0)
Converts graph (floating point) coordinates into mpWindow (screen) pixel coordinates,...
Definition mathplot.h:3952
mpRect m_plotBoundariesMargin
The size of the plot with the margins. Calculated.
Definition mathplot.h:4768
int m_extraMargin
Extra margin around the plot. Default 8.
Definition mathplot.h:4763
int GetMarginRightOuter() const
Get the right outer margin, exluding Y-axis.
Definition mathplot.h:4307
bool ShouldDrawYAxis(const mpScaleY &yAxis)
void UpdateMargins()
Update margins if e.g.
Definition mathplot.h:4267
void UnSetOnDeleteLayer()
Remove the 'delete layer event' callback.
Definition mathplot.h:4483
int GetMarginLeftOuter() const
Get the left outer margin, exluding Y-axis.
Definition mathplot.h:4360
void FitY(int yAxisID)
Similar to Fit() but only fit in Y and only one Y-axis, specified by ID.
mpInfoLegend * m_InfoLegend
Pointer to the optional info legend layer.
Definition mathplot.h:4790
void DoScrollCalc(const int position, const int orientation)
Update scrolling state from a scrollbar position/orientation pair.
virtual bool UpdateBBox()
Set bounding box 'm_bound' to contain all visible plots of this mpWindow.
mpInfoCoords * m_InfoCoords
Pointer to the optional info coords layer.
Definition mathplot.h:4789
mpFXYVector * GetXYSeries(unsigned int n, const wxString &name=_T("Serie "), bool create=true)
virtual void OnScrollTop(wxScrollWinEvent &event)
Scroll to top.
wxString m_wildcard
For loadfile() function when we use wxFileDialog.
Definition mathplot.h:4798
int m_scrX
Current view's X dimension in DC units, including all scales, margins.
Definition mathplot.h:4756
void SetMarginLeft(const int left)
Set the left margin.
Definition mathplot.h:4330
double p2y(const wxCoord pixelCoordY, const int yAxisID=0)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
Definition mathplot.h:3933
int m_last_ly
Last logical Y origin, used for double buffering.
Definition mathplot.h:4772
mpScaleX * GetLayerXAxis() const
Create a wxColour id is the number of the colour : blue, red, green, ...
Definition mathplot.h:5365
wxIndexColour(const unsigned int id)
Constructor.
Definition mathplot.h:5371
@ mpID_LOAD_FILE
Load a file.
Definition mathplot.h:627
@ mpID_FIT
Fit view to match bounding box of all layers.
Definition mathplot.h:616
@ mpID_LOCKASPECT
Lock x/y scaling aspect.
Definition mathplot.h:620
@ mpID_FULLSCREEN
Toggle fullscreen only if parent is a frame windows.
Definition mathplot.h:629
@ mpID_ZOOM_IN
Zoom into view at clickposition / window center.
Definition mathplot.h:617
@ mpID_TOGGLE_GRID
Show/Hide grids.
Definition mathplot.h:621
@ mpID_CENTER
Center view on click position.
Definition mathplot.h:619
@ mpID_SCREENSHOT
Copy a screen shot to the clipboard.
Definition mathplot.h:623
@ mpID_TOGGLE_COORD
Show/Hide info coord.
Definition mathplot.h:622
@ mpID_HELP_MOUSE
Shows information about the mouse commands.
Definition mathplot.h:628
@ mpID_ZOOM_OUT
Zoom out.
Definition mathplot.h:618
std::map< int, mpAxisData > mpAxisList
Define the type for the list of axis.
Definition mathplot.h:3387
enum __XAxis_Align_Type mpXAxis_Align
Alignment for X axis.
__mp_Style_Type
Style for the Legend layer.
Definition mathplot.h:678
@ mpLegendSquare
Show legend items with small square with the same color of referred mpLayer.
Definition mathplot.h:680
@ mpLegendSymbol
Show legend items with symbol used with the referred mpLayer.
Definition mathplot.h:681
@ mpLegendLine
Show legend items with line with the same pen of referred mpLayer.
Definition mathplot.h:679
enum __Chart_Type mpChartType
sub_type values for mpLAYER_CHART
__Chart_Type
sub_type values for mpLAYER_CHART
Definition mathplot.h:748
@ mpcAllType
sub type for all layers who are chart.
Definition mathplot.h:752
@ mpcBarChart
sub type for mpBarChart
Definition mathplot.h:750
@ mpcPieChart
sub type for mpPieChart
Definition mathplot.h:751
@ mpcChartNone
sub type not defined (should be never used)
Definition mathplot.h:749
__mp_Location_Type
Location for the Info layer.
Definition mathplot.h:634
@ mpMarginBottomCenter
Align the info in margin center-bottom.
Definition mathplot.h:641
@ mpMarginTopLeft
Align the info in margin top-left.
Definition mathplot.h:636
@ mpMarginBottomLeft
Align the info in margin bottom-left.
Definition mathplot.h:640
@ mpMarginTopCenter
Align the info in margin center-top.
Definition mathplot.h:637
@ mpMarginBottomRight
Align the info in margin bottom-right.
Definition mathplot.h:642
@ mpMarginRightCenter
Align the info in margin center-right.
Definition mathplot.h:639
@ mpMarginTopRight
Align the info in margin top-right.
Definition mathplot.h:638
@ mpMarginLeftCenter
Align the info in margin center-left.
Definition mathplot.h:635
@ mpCursor
only for mpInfoCoords
Definition mathplot.h:644
@ mpMarginUser
User defined position. Can be change by mouse drag.
Definition mathplot.h:643
enum __mp_Colour mpColour
Enumeration of classic colour.
std::optional< unsigned int > mpOptional_uint
Shortcut to optional unsigned integer type.
Definition mathplot.h:106
enum __Symbol_Type mpSymbol
Displaying a symbol instead of a point in the plot function.
__mp_Layer_Type
Major type of an mpLayer (detail is in subtype)
Definition mathplot.h:792
@ mpLAYER_TEXT
Text box type layer.
Definition mathplot.h:797
@ mpLAYER_CHART
Chart type layer (bar chart)
Definition mathplot.h:800
@ mpLAYER_INFO
Info box type layer.
Definition mathplot.h:796
@ mpLAYER_BITMAP
Bitmap type layer.
Definition mathplot.h:798
@ mpLAYER_LINE
Line (horizontal or vertical) type layer.
Definition mathplot.h:799
@ mpLAYER_UNDEF
Layer type undefined; SHOULD NOT BE USED.
Definition mathplot.h:793
@ mpLAYER_AXIS
Axis type layer.
Definition mathplot.h:794
@ mpLAYER_PLOT
Plot type layer.
Definition mathplot.h:795
__Info_Type
sub_type values for mpLAYER_INFO
Definition mathplot.h:709
@ mpiLegend
sub type for mpInfoLegend layer
Definition mathplot.h:713
@ mpiInfo
sub type for mpInfoLayer layer
Definition mathplot.h:711
@ mpiNone
sub type not defined (should be never used)
Definition mathplot.h:710
@ mpiCoords
sub type for mpInfoCoords layer
Definition mathplot.h:712
__YAxis_Align_Type
Alignment for Y axis.
Definition mathplot.h:659
@ mpALIGN_LEFT
Align the y-axis towards left plot.
Definition mathplot.h:661
@ mpALIGN_BORDER_LEFT
Align the y-axis towards left border.
Definition mathplot.h:660
@ mpALIGN_RIGHT
Align the y-axis towards right plot.
Definition mathplot.h:663
@ mpALIGN_BORDER_RIGHT
Align the y-axis towards right border.
Definition mathplot.h:664
@ mpALIGN_CENTERY
Align the y-axis center plot.
Definition mathplot.h:662
__Text_Type
sub_type values for mpLAYER_TEXT
Definition mathplot.h:718
@ mptText
sub type for mpText layer
Definition mathplot.h:720
@ mptTitle
sub type for mpTitle layer
Definition mathplot.h:721
@ mptNone
sub type not defined (should be never used)
Definition mathplot.h:719
std::function< void(void *Sender, const wxString &classname, bool &cancel)> mpOnDeleteLayer
Define an event for when we delete a layer.
Definition mathplot.h:3410
__mp_Delete_Action
Action to do with the object associated to the layer when we delete it.
Definition mathplot.h:827
@ mpYesDelete
Delete the object if CanDelete is true and remove it from the layer list.
Definition mathplot.h:829
@ mpForceDelete
Delete the object regardless of the CanDelete value and remove it from the layer list.
Definition mathplot.h:830
@ mpNoDelete
Keep the object, just remove the layer from the layer list.
Definition mathplot.h:828
enum __mp_Layer_Type mpLayerType
Major type of an mpLayer (detail is in subtype)
#define DECLARE_DYNAMIC_CLASS_MATHPLOT(mp_class)
Definition for RTTI.
Definition mathplot.h:189
#define MP_Y_BORDER_SEPARATION
Default minimum separation in pixels between Y axes and the plot border.
Definition mathplot.h:164
mpAxisUpdate
Define the axis we want to update.
Definition mathplot.h:3395
__mp_Direction_Type
Direction for the Legend layer.
Definition mathplot.h:686
@ mpVertical
each visible plot is described on its own line, one above the other
Definition mathplot.h:687
@ mpHorizontal
legend components follow each other horizontally on a single line
Definition mathplot.h:688
enum __mp_Layer_ZOrder mpLayerZOrder
Z order for drawing layer Background is the deeper (bitmap layer) Then draw axis, custom layer,...
enum __mp_Style_Type mpLegendStyle
Style for the Legend layer.
#define MP_EPSILON
An epsilon for float comparison to 0.
Definition mathplot.h:174
enum __mp_Direction_Type mpLegendDirection
Direction for the Legend layer.
mpMouseButtonAction
enum for left button mouse action: box zoom or drag
Definition mathplot.h:757
@ mpMouseBoxZoom
Mouse action draw a box to zoom inside.
Definition mathplot.h:758
@ mpMouseDragZoom
Mouse action drag the plot.
Definition mathplot.h:759
std::deque< mpLayer * > mpLayerList
Define the type for the list of layers inside mpWindow.
Definition mathplot.h:3357
#define WXDLLIMPEXP_MATHPLOT
Definition uses windows dll to export function.
Definition mathplot.h:90
enum __Text_Type mpTextType
sub_type values for mpLAYER_TEXT
std::function< void(void *Sender, wxMouseEvent &event, bool &cancel)> mpOnUserMouseAction
Define an event for when we have a mouse click Use like this : your_plot->SetOnUserMouseAction([this]...
Definition mathplot.h:3418
enum __YAxis_Align_Type mpYAxis_Align
Alignment for Y axis.
#define MP_X_RAWTIME
Shortcut for MP_X_UTCTIME.
Definition mathplot.h:171
#define MP_ZOOM_AROUND_CENTER
Default value for zoom around a point (default -1 is no zoom)
Definition mathplot.h:182
enum __mp_Location_Type mpLocation
Location for the Info layer.
enum __Plot_Align_Name_Type mpPlot_Align
Plot alignment (which corner should plot be placed)
__XAxis_Align_Type
Alignment for X axis.
Definition mathplot.h:649
@ mpALIGN_BORDER_BOTTOM
Align the x-axis towards bottom border.
Definition mathplot.h:650
@ mpALIGN_TOP
Align the x-axis towards top plot.
Definition mathplot.h:653
@ mpALIGN_BORDER_TOP
Align the x-axis towards top border.
Definition mathplot.h:654
@ mpALIGN_CENTERX
Align the x-axis center plot.
Definition mathplot.h:652
@ mpALIGN_BOTTOM
Align the x-axis towards bottom plot.
Definition mathplot.h:651
mpLabelType
enum for label for grid
Definition mathplot.h:764
@ mpLabel_AUTO
Set label for axis in auto mode, automatically switch between decimal and scientific notation.
Definition mathplot.h:766
@ mpLabel_SCIENTIFIC
Set label for axis in scientific notation.
Definition mathplot.h:770
@ mpLabel_USER
Set label user defined.
Definition mathplot.h:781
@ mpLabel_DATETIME
Set label for axis in datetime mode: the value is always represented as yyyy-mm-ddThh:mm:ss.
Definition mathplot.h:779
@ mpLabel_DATE
Set label for axis in date mode: the value is always represented as yyyy-mm-dd.
Definition mathplot.h:777
@ mpLabel_HOURS
Set label for axis in hours mode: the value is always represented as hours:minutes:seconds.
Definition mathplot.h:775
@ mpLabel_TIME
Set label for axis in time mode: the value is represented as minutes:seconds.milliseconds if time is ...
Definition mathplot.h:773
@ mpLabel_DECIMAL
Set label for axis in decimal notation, with number of decimals automatically calculated based on zoo...
Definition mathplot.h:768
@ mpLabel_NONE
Set no label for axis (useful for bar)
Definition mathplot.h:783
enum __Scale_Type mpScaleType
sub_type values for mpLAYER_AXIS
__Scale_Type
sub_type values for mpLAYER_AXIS
Definition mathplot.h:739
@ mpsAllType
sub type for all layers who are scale.
Definition mathplot.h:743
@ mpsScaleY
sub type for mpScaleY
Definition mathplot.h:742
@ mpsScaleX
sub type for mpScaleX
Definition mathplot.h:741
@ mpsScaleNone
sub type not defined (should be never used)
Definition mathplot.h:740
__mp_Layer_ZOrder
Z order for drawing layer Background is the deeper (bitmap layer) Then draw axis, custom layer,...
Definition mathplot.h:809
@ mpZIndex_BACKGROUND
Bitmap type layer.
Definition mathplot.h:810
@ mpZIndex_TEXT
Text box type layer.
Definition mathplot.h:816
@ mpZIndex_END
Just the end of ZOrder.
Definition mathplot.h:817
@ mpZIndex_AXIS
Axis type layer.
Definition mathplot.h:811
@ mpZIndex_PLOT
Plot (function) type layer.
Definition mathplot.h:813
@ mpZIndex_INFO
Info box type layer.
Definition mathplot.h:815
@ mpZIndex_LINE
Line (horizontal or vertical) type layer.
Definition mathplot.h:812
@ mpZIndex_CHART
Chart type layer.
Definition mathplot.h:814
__mp_Colour
Enumeration of classic colour.
Definition mathplot.h:5348
#define MP_ISNOTNULL(x)
Nullity test. Old solution is to test according small epsilon: (fabs(x) > MP_EPSILON)
Definition mathplot.h:176
enum __Info_Type mpInfoType
sub_type values for mpLAYER_INFO
enum __mp_Delete_Action mpDeleteAction
Action to do with the object associated to the layer when we delete it.
__Plot_Align_Name_Type
Plot alignment (which corner should plot be placed)
Definition mathplot.h:669
@ mpALIGN_NW
Align the plot label towards the northwest.
Definition mathplot.h:670
@ mpALIGN_SE
Align the plot label towards the southeast.
Definition mathplot.h:672
@ mpALIGN_SW
Align the plot label towards the southwest.
Definition mathplot.h:673
@ mpALIGN_NE
Align the plot label towards the northeast.
Definition mathplot.h:671
__Symbol_Type
Displaying a symbol instead of a point in the plot function.
Definition mathplot.h:693
@ mpsDownTriangle
Draw a triangle down oriented.
Definition mathplot.h:698
@ mpsSquare
Draw a square.
Definition mathplot.h:696
@ mpsCircle
Draw a circle.
Definition mathplot.h:695
@ mpsUpTriangle
Draw a triangle up oriented.
Definition mathplot.h:697
@ mpsPlus
Draw a plus +.
Definition mathplot.h:700
@ mpsNone
No symbol is drawing.
Definition mathplot.h:694
@ mpsCross
Draw a cross X.
Definition mathplot.h:699
enum __Function_Type mpFunctionType
sub_type values for mpLAYER_PLOT and mpLAYER_LINE
std::optional< int > mpOptional_int
Shortcut to optional integer type..
Definition mathplot.h:108
__Function_Type
sub_type values for mpLAYER_PLOT and mpLAYER_LINE
Definition mathplot.h:726
@ mpfAllType
sub type for all layers who are function.
Definition mathplot.h:734
@ mpfFX
sub type for mpFX function
Definition mathplot.h:728
@ mpfLine
sub type for mpLine function
Definition mathplot.h:733
@ mpfMovable
sub type for mpMovableObject function
Definition mathplot.h:732
@ mpfFY
sub type for mpFY function
Definition mathplot.h:729
@ mpfFXYVector
sub type for mpFXYVector function
Definition mathplot.h:731
@ mpfNone
sub type not defined (should be never used)
Definition mathplot.h:727
@ mpfFXY
sub type for mpFXY function
Definition mathplot.h:730
Represents all the informations needed for plotting a layer in one direction (X or Y) This struct hol...
Definition mathplot.h:3369
double pos
Position.
Definition mathplot.h:3372
mpRange< double > desired
Desired range min and max.
Definition mathplot.h:3374
mpRange< double > lastDesired
Last desired ranged, used for check if desired has changed.
Definition mathplot.h:3375
double scale
Scale.
Definition mathplot.h:3371
mpRange< double > bound
Range min and max.
Definition mathplot.h:3373
bool operator==(const mpAxisData &other) const
Compare axis data while ignoring the axis pointer itself.
Definition mathplot.h:3379
A structure for computation of bounds in real units (not in screen pixel) X refer to X axis Y refer t...
Definition mathplot.h:445
mpFloatRect(mpWindow &w)
Construct a new mpFloatRect using it's parent mpWindow to obtain the number of Y-scales to use.
mpRange< double > x
range over x direction
Definition mathplot.h:446
mpFloatRect()=delete
Only allow constructor with mpWindow supplied.
bool IsNotSet(mpWindow &w) const
Is mpFloatRect set ?
Definition mathplot.h:515
void UpdateBoundingBoxToInclude(const double px, const double py, const size_t yAxisID=0)
Update bounding box to include this point.
Definition mathplot.h:489
std::vector< mpRange< double > > y
array of range over all y directions
Definition mathplot.h:447
bool operator==(const mpFloatRect &rect) const
Equal operator.
Definition mathplot.h:522
bool PointIsInside(const double px, const double py, const size_t yAxisID=0) const
Is point inside this bounding box?
Definition mathplot.h:466
void InitializeBoundingBox(const double px, const double py, const size_t yAxisID=0)
Initialize bounding box with an initial point.
Definition mathplot.h:506
Define a simple rectangular box X refer to X axis Y refer to Y axis.
Definition mathplot.h:561
mpFloatRectSimple(const mpRange< double > x_, const mpRange< double > y_)
Construct a simple rectangular box.
Definition mathplot.h:570
void InitializeBoundingBox(const double px, const double py)
Initialize bounding box with an initial point.
Definition mathplot.h:596
mpRange< double > y
range over y direction
Definition mathplot.h:563
bool PointIsInside(const double px, const double py) const
Is point inside this bounding box?
Definition mathplot.h:577
mpRange< double > x
range over x direction
Definition mathplot.h:562
void UpdateBoundingBoxToInclude(const double px, const double py)
Update bounding box (X and Y axis) to include this point.
Definition mathplot.h:586
Result of mpWindow::GetClosestPlot: the colour and data-space coordinates of the plot point closest t...
Definition mathplot.h:606
wxRealPoint coords
data-space (x, y) of the closest point
Definition mathplot.h:608
wxColour colour
pen colour of the matched plot layer
Definition mathplot.h:607
Represents a numeric range with minimum and maximum values.
Definition mathplot.h:270
void Update(T min_, T max_)
Update range with new min and max values if this expand the range If min_ < min then min = min_ and i...
Definition mathplot.h:362
mpRange(T value1, T value2)
Create range with the 2 values.
Definition mathplot.h:282
bool PointIsInside(T point) const
Return true if the point is inside the range (min and max included)
Definition mathplot.h:418
void Update(mpRange range)
Update range with new range values if this expand the range.
Definition mathplot.h:372
T Length(void) const
Length of the range.
Definition mathplot.h:393
bool IsSet() const
Check if this mpRange has been assigned any values.
Definition mathplot.h:342
void Update(T value)
Update range according new value: Expand the range to include the value.
Definition mathplot.h:351
mpRange()
Default constructor.
Definition mathplot.h:275
void Set(T min_, T max_)
Set min, max function.
Definition mathplot.h:304
bool operator!=(const mpRange &other) const
Compare two ranges for inequality.
Definition mathplot.h:432
bool operator==(const mpRange &other) const
Compare two ranges for equality.
Definition mathplot.h:427
T GetCenter(void) const
Center of the range.
Definition mathplot.h:399
T max
The max value of the range.
Definition mathplot.h:272
void Check(void)
Check to always have a range. If min = max then introduce the 0 to make a range.
Definition mathplot.h:381
T min
The min value of the range.
Definition mathplot.h:271
T GetMaxAbs(void) const
Max absolute value of the range.
Definition mathplot.h:405
void SetMin(T min_)
Set min function, correct max.
Definition mathplot.h:311
void ToLog(void)
Convert to log range.
Definition mathplot.h:411
void Assign(T value1, T value2)
Assign values to min and max.
Definition mathplot.h:327
void SetMax(T max_)
Set max function, correct min.
Definition mathplot.h:319
void Set(T value_)
Initialize min and max.
Definition mathplot.h:297
A rectangle structure in several (integer) flavors.
Definition mathplot.h:227
wxRect GetRect(void) const
Create standard wxWidgets rectangle defined by this object's start and end points.
Definition mathplot.h:256
Group of properties, derived from the axis step size and range, that control how scale labels are for...
Definition mathplot.h:2861