SPH
PlotView.h
Go to the documentation of this file.
1 #pragma once
2 
7 
9 #include "gui/objects/Plots.h"
10 #include "gui/objects/Point.h"
11 #include "physics/Integrals.h"
12 #include "thread/CheckFunction.h"
13 #include <wx/frame.h>
14 #include <wx/panel.h>
15 
16 class wxBoxSizer;
17 
19 
20 class PlotPage;
21 
22 struct TicsParams {
23  Size minCnt = 6;
24  Size digits = 3;
25 };
26 
27 class PlotView : public wxPanel {
28 private:
29  wxSize padding;
31 
32  struct {
35  } cached;
36 
37  Optional<TicsParams> ticsParams;
38 
39 public:
41  bool addZeroX = false;
42 
44  bool addZeroY = false;
45 
46  PlotView(wxWindow* parent,
47  const wxSize size,
48  const wxSize padding,
49  const SharedPtr<Array<PlotData>>& list,
50  const Size defaultSelectedIdx,
51  Optional<TicsParams> ticsParams);
52 
53  void resize(const Pixel size);
54 
56  AffineMatrix2 getPlotTransformMatrix(const Interval& rangeX, const Interval& rangeY) const;
57 
58  void drawAxes(wxDC& dc, const Interval rangeX, const Interval rangeY);
59 
60 private:
61  void updatePlot(const Size index);
62 
64 
65  void onRightUp(wxMouseEvent& evt);
66 
67  void onDoubleClick(wxMouseEvent& evt);
68 
69  void onMenu(wxCommandEvent& evt);
70 
71  void onPaint(wxPaintEvent& evt);
72 
74 
75  void drawPlot(wxPaintDC& dc, IPlot& lockedPlot, const Interval rangeX, const Interval rangeY);
76 
77  void drawCaption(wxDC& dc, IPlot& lockedPlot);
78 };
79 
80 
81 class PlotPage : public wxPanel {
82 private:
83  LockingPtr<IPlot> plot;
84  wxSize padding;
85 
86  PlotView* plotView;
87 
88 public:
89  PlotPage(wxWindow* parent, const wxSize size, const wxSize padding, const LockingPtr<IPlot>& plot);
90 
91 private:
92  wxBoxSizer* createToolbar(const Size toolbarHeight);
93 
94  void saveImage(const Path& path);
95 
96  void saveData(const Path& path);
97 };
98 
99 
NAMESPACE_SPH_BEGIN
Definition: BarnesHut.cpp:13
Helper functions to check the internal consistency of the code.
uint32_t Size
Integral type used to index arrays (by default).
Definition: Globals.h:16
Implementation of IDrawingContext using wxGraphicsContext.
Integrals of motion and other integral quantities.
#define NAMESPACE_SPH_END
Definition: Object.h:12
2D affine matrix
Definition: Point.h:50
Generic dynamically allocated resizable storage.
Definition: Array.h:43
Interface for constructing generic plots from quantities stored in storage.
Definition: Plot.h:75
Object representing a 1D interval of real numbers.
Definition: Interval.h:17
Object representing a path on a filesystem.
Definition: Path.h:17
PlotPage(wxWindow *parent, const wxSize size, const wxSize padding, const LockingPtr< IPlot > &plot)
Definition: PlotView.cpp:221
LockingPtr< IPlot > plot
Definition: PlotView.h:33
bool addZeroY
Include zero in y-range.
Definition: PlotView.h:44
bool addZeroX
Include zero in x-range.
Definition: PlotView.h:41
AffineMatrix2 getPlotTransformMatrix(const Interval &rangeX, const Interval &rangeY) const
Returns the transformation matrix for managed plot.
Definition: PlotView.cpp:50
PlotView(wxWindow *parent, const wxSize size, const wxSize padding, const SharedPtr< Array< PlotData >> &list, const Size defaultSelectedIdx, Optional< TicsParams > ticsParams)
Definition: PlotView.cpp:17
Rgba color
Definition: PlotView.h:34
void resize(const Pixel size)
Definition: PlotView.cpp:35
void drawAxes(wxDC &dc, const Interval rangeX, const Interval rangeY)
Definition: PlotView.cpp:161
Definition: Color.h:8
Simple 2D vector with integer coordinates. Provides conversion from and to wxPoint.
Definition: Point.h:101
Size digits
Definition: PlotView.h:24
Size minCnt
Definition: PlotView.h:23