SPH
ParticleProbe.h
Go to the documentation of this file.
1 #pragma once
2 
7 
8 #include "gui/Utils.h"
9 #include "gui/objects/Color.h"
10 #include "quantities/Particle.h"
11 #include <wx/clipbrd.h>
12 #include <wx/dcclient.h>
13 #include <wx/menu.h>
14 #include <wx/panel.h>
15 #include <wx/textctrl.h>
16 
18 
19 class ParticleProbe : public wxPanel {
20 private:
22  Optional<Particle> particle;
23 
25  Rgba color;
26 
27  struct {
28 
31 
34 
36  Size lineSkip = 19;
37 
38  } config;
39 
40 public:
41  ParticleProbe(wxWindow* parent, const wxSize size)
42  : wxPanel(parent, wxID_ANY, wxDefaultPosition, size) {
43  this->SetMinSize(size);
44 
45  // Connect handlers
46  Connect(wxEVT_PAINT, wxPaintEventHandler(ParticleProbe::onPaint));
47  Connect(wxEVT_RIGHT_UP, wxMouseEventHandler(ParticleProbe::onRightUp));
48  }
49 
50  void update(const Particle& selectedParticle, const Rgba colorizerColor) {
51  particle = selectedParticle;
52  color = colorizerColor;
53  this->Refresh();
54  }
55 
56  void clear() {
57  particle = NOTHING;
58  this->Refresh();
59  }
60 
61 private:
62  void onRightUp(wxMouseEvent& UNUSED(evt)) {
63  wxMenu menu;
64  menu.Append(0, "Copy to clipboard");
65  menu.Connect(
66  wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(ParticleProbe::onMenu), nullptr, this);
67  this->PopupMenu(&menu);
68  }
69 
70  void onMenu(wxCommandEvent& evt);
71 
72  void onPaint(wxPaintEvent& evt);
73 
74  void printVector(wxDC& dc, const Vector& v, const std::wstring& label, const wxPoint offset) const;
75 
76  template <typename Type>
77  void printTensor(wxDC& dc, const Type& tensor, const std::wstring& label, const wxPoint offset) const;
78 };
79 
NAMESPACE_SPH_BEGIN
Definition: BarnesHut.cpp:13
uint32_t Size
Integral type used to index arrays (by default).
Definition: Globals.h:16
#define UNUSED(x)
Definition: Object.h:37
#define NAMESPACE_SPH_END
Definition: Object.h:12
const NothingType NOTHING
Definition: Optional.h:16
Random utility functions for drawing stuff to DC.
ParticleProbe(wxWindow *parent, const wxSize size)
Definition: ParticleProbe.h:41
Size topSkip
Padding on top.
Definition: ParticleProbe.h:30
Size leftSkip
Padding on left end.
Definition: ParticleProbe.h:33
void update(const Particle &selectedParticle, const Rgba colorizerColor)
Definition: ParticleProbe.h:50
Size lineSkip
Height of a line of text.
Definition: ParticleProbe.h:36
Object holding information about single particle.
Definition: Particle.h:17
Definition: Color.h:8