22 : wxPanel(parent, wxID_ANY) {
23 this->Connect(wxEVT_PAINT, wxPaintEventHandler(ProgressPanel::onPaint));
26 void onRunStart(
const std::string& className,
const std::string& instanceName) {
28 name = instanceName +
" (" + className +
")";
47 if (stat.progress > 0.05_f) {
48 stat.eta =
"Estimated remaining: " +
60 stat.simulationTime =
"";
61 stat.finished =
false;
64 void onPaint(wxPaintEvent&
UNUSED(evt)) {
66 wxSize size = dc.GetSize();
67 constexpr
int padding = 25;
68 wxRect rect(wxPoint(padding, 0), wxSize(size.x - 2 * padding, size.y));
70 wxBrush brush = *wxBLACK_BRUSH;
71 const bool isLightTheme =
Rgba(dc.GetBackground().GetColour()).
intensity() > 0.5f;
73 brush.SetColour(wxColour(40, 150, 40));
75 brush.SetColour(isLightTheme ? wxColour(160, 160, 200) : wxColour(100, 100, 120));
78 dc.DrawRectangle(wxPoint(0, 0), wxSize(
int(stat.progress * size.x), size.y));
80 wxFont font = dc.GetFont();
81 dc.SetFont(font.Bold());
82 dc.DrawLabel(name, rect, wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL);
85 dc.DrawLabel(stat.eta, rect, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
86 dc.DrawLabel(stat.simulationTime, rect, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
Helper functions to check the internal consistency of the code.
@ NO_THROW
Function cannot throw exceptions.
@ MAIN_THREAD
Function can only be executed from main thread.
#define CHECK_FUNCTION(flags)
double Float
Precision used withing the code. Use Float instead of float or double where precision is important.
#define NAMESPACE_SPH_END
Statistics gathered and periodically displayed during the run.
@ WALLCLOCK_TIME
Current wallclock duration of the simulation.
String getFormattedTime(const String &format)
Utility functions.
std::string simulationTime
void update(const Statistics &stats)
ProgressPanel(wxWindow *parent)
void onRunStart(const std::string &className, const std::string &instanceName)
float intensity() const
Returns the average intensity of the color.
Object holding various statistics about current run.
TValue get(const StatisticsId idx) const
Returns value of a statistic.
TValue getOr(const StatisticsId idx, const TValue &other) const
Returns value of a statistic, or a given value if the statistic is not stored.
bool has(const StatisticsId idx) const
Checks if the object contains a statistic with given ID.