7 inline std::string
toName(
const std::string& s) {
11 inline std::string
toKey(
const std::string& s) {
15 void ParticleProbe::onMenu(wxCommandEvent&
UNUSED(evt)) {
20 if (!wxTheClipboard->Open()) {
23 wxTheClipboard->Clear();
28 if (!data.dt.empty()) {
30 wxTheClipboard->SetData(
new wxTextDataObject(ss.str()));
34 if (!data.value.empty()) {
37 wxTheClipboard->SetData(
new wxTextDataObject(ss.str()));
41 wxTheClipboard->Flush();
42 wxTheClipboard->Close();
45 void ParticleProbe::onPaint(wxPaintEvent&
UNUSED(evt)) {
47 wxSize canvasSize = dc.GetSize();
50 Rgba backgroundColor =
Rgba(this->GetParent()->GetBackgroundColour());
52 brush.SetColour(wxColour(backgroundColor.
darken(0.3f)));
54 dc.DrawRectangle(wxPoint(0, 0), canvasSize);
61 brush.SetColour(wxColour(color));
63 wxPoint offset(config.leftSkip, config.topSkip);
64 dc.DrawRectangle(offset, wxSize(15, 15));
67 const bool isLightTheme = backgroundColor.
intensity() > 0.5_f;
69 dc.SetTextForeground(wxColour(
Rgba(0.2f, 0.2f, 0.2f)));
71 dc.SetTextForeground(wxColour(
Rgba(0.8f, 0.8f, 0.8f)));
73 dc.DrawText(
"Particle " + std::to_string(particle->getIndex()), wxPoint(24, 4));
88 const Size x = canvasSize.x / 2;
95 }
else if (accelerationValue) {
96 const Vector acceleration = accelerationValue;
97 const Size x = canvasSize.x / 2;
99 dc, L
"dv_x = " +
toPrintableString(acceleration[
X]), offset + wxSize(x, 1 * config.lineSkip));
101 dc, L
"dv_y = " +
toPrintableString(acceleration[
Y]), offset + wxSize(x, 2 * config.lineSkip));
103 dc, L
"dv_z = " +
toPrintableString(acceleration[
Z]), offset + wxSize(x, 3 * config.lineSkip));
106 offset.y += 4 * config.lineSkip;
119 const DynamicId id = data.value.getType();
126 offset.y += config.lineSkip;
130 offset.y += config.lineSkip;
133 const Vector vector = data.value;
134 this->printVector(dc, vector, label, offset);
135 offset.y += 3 * config.lineSkip;
140 this->printTensor(dc, tensor, label, offset);
141 offset.y += 6 * config.lineSkip;
146 this->printTensor(dc, tensor, label, offset);
147 offset.y += 6 * config.lineSkip;
159 const DynamicId id = data.value.getType();
163 offset.y += config.lineSkip;
171 void ParticleProbe::printVector(wxDC& dc,
173 const std::wstring& label,
174 const wxPoint offset)
const {
176 dc, label + L
"_x = " +
toPrintableString(v[
X]), offset + wxSize(0, 0 * config.lineSkip));
178 dc, label + L
"_y = " +
toPrintableString(v[
Y]), offset + wxSize(0, 1 * config.lineSkip));
180 dc, label + L
"_z = " +
toPrintableString(v[
Z]), offset + wxSize(0, 2 * config.lineSkip));
183 template <
typename Type>
184 void ParticleProbe::printTensor(wxDC& dc,
186 const std::wstring& label,
187 const wxPoint offset)
const {
188 const Size x = dc.GetSize().x / 2;
190 dc, label + L
"_xx = " +
toPrintableString(tensor(
X,
X)), offset + wxSize(0, 0 * config.lineSkip));
192 dc, label + L
"_yy = " +
toPrintableString(tensor(
Y,
Y)), offset + wxSize(0, 1 * config.lineSkip));
194 dc, label + L
"_zz = " +
toPrintableString(tensor(
Z,
Z)), offset + wxSize(0, 2 * config.lineSkip));
196 dc, label + L
"_xy = " +
toPrintableString(tensor(
X,
Y)), offset + wxSize(x, 0 * config.lineSkip));
198 dc, label + L
"_xz = " +
toPrintableString(tensor(
X,
Z)), offset + wxSize(x, 1 * config.lineSkip));
200 dc, label + L
"_yz = " +
toPrintableString(tensor(
Y,
Z)), offset + wxSize(x, 2 * config.lineSkip));
#define SPH_ASSERT(x,...)
DynamicId
Enum representing a value type stored in a Value object.
uint32_t Size
Integral type used to index arrays (by default).
double Float
Precision used withing the code. Use Float instead of float or double where precision is important.
#define NAMESPACE_SPH_END
std::string toKey(const std::string &s)
NAMESPACE_SPH_BEGIN std::string toName(const std::string &s)
Frame showing information about selected particle.
QuantityMetadata getMetadata(const QuantityId key)
Returns the quantity information using quantity ID.
@ POSITION
Positions (velocities, accelerations) of particles, always a vector quantity,.
std::string replaceAll(const std::string &source, const std::string &old, const std::string &s)
Replaces all occurences of string with a new string.
Array< std::string > split(const std::string &s, const char delimiter)
Splits a string into an array of string using given delimiter.
std::string capitalize(const std::string &input)
Capitalizes first letters of all words in the string, except for words like 'and',...
void drawTextWithSubscripts(wxDC &dc, const std::wstring &text, const wxPoint point)
std::wstring toPrintableString(const Float value, const Size precision, const Float decimalThreshold)
Converts the value to a printable string.
INLINE T & back() noexcept
Convenient object for storing a single value of different types.
INLINE Type & value()
Returns the reference to the stored value.
float intensity() const
Returns the average intensity of the color.
Rgba darken(const float amount) const
Returns a color darker by given factor.
static Optional< std::string > getEntryName(const BodySettingsId idx)
Returns the human-readable name of the entry with given index.
Symmetric tensor of 2nd order.
Symmetric traceless 2nd order tensor.
Vector position(const Float a, const Float e, const Float u)
Computes the position on the elliptic trajectory.
Vector velocity(const Float a, const Float e, const Float u, const Float n)
Computes the velocity vector on the elliptic trajectory.
Stored info about a material parameter.
Stored info about a quantity.