18 : event_vis(2.0 *
std::max(fabs(ceil(mod->GetWorld()->GetExtent().x.max)),
19 fabs(floor(mod->GetWorld()->GetExtent().x.min))),
20 2.0 *
std::max(fabs(ceil(mod->GetWorld()->GetExtent().y.max)),
21 fabs(floor(mod->GetWorld()->GetExtent().y.min))),
23 output_vis(0, 100, 200, 40, 1200,
Color(1, 0, 0),
Color(0, 0, 0, 0.5),
"energy output",
25 stored_vis(0, 142, 200, 40, 1200,
Color(0, 1, 0),
Color(0, 0, 0, 0.5),
"energy stored",
27 mod(mod), stored(0.0), capacity(0.0), charging(false), dissipated(0.0), last_time(0),
28 last_joules(0.0), last_watts(0.0)
51 const double height = 0.5;
52 const double width = 0.2;
56 const double alpha = 0.5;
59 glColor4f(0, 1, 0, alpha);
60 else if (percent > 25)
61 glColor4f(1, 0, 1, alpha);
63 glColor4f(1, 0, 0, alpha);
67 glTranslatef(-width, 0.0, 0.0);
69 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
71 GLfloat fullness = height * (percent * 0.01);
72 glRectf(0, 0, width, fullness);
75 glTranslatef(0, 0, 0.1);
76 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
78 glColor4f(0, 0, 0, 0.7);
80 glRectf(0, 0, width, height);
83 glVertex2f(0, fullness);
84 glVertex2f(width, fullness);
91 glVertex2f(width / 3.0, height / 3.0);
92 glVertex2f(2.0 * width / 3, height / 3.0);
94 glVertex2f(width / 3.0, height / 3.0);
95 glVertex2f(width / 3.0, height - height / 5.0);
97 glVertex2f(width / 3.0, height - height / 5.0);
98 glVertex2f(0, height - height / 5.0);
100 glVertex2f(0, height - height / 5.0);
101 glVertex2f(width / 2.0, height);
103 glVertex2f(width / 2.0, height);
104 glVertex2f(width, height - height / 5.0);
106 glVertex2f(width, height - height / 5.0);
107 glVertex2f(2.0 * width / 3.0, height - height / 5.0);
109 glVertex2f(2.0 * width / 3.0, height - height / 5.0);
110 glVertex2f(2.0 * width / 3, height / 3.0);
117 glColor4f(1, 0, 0, 0.7);
119 glRectf(0, 0, width, height);
132 watts_t watts = (-1e6 * delta_j) / (
double)delta_t;
135 last_time = time_now;
139 if (fabs(watts) > 1e-5)
141 glColor4f(1, 0, 0, 0.8);
143 snprintf(buf, 32,
"%.1fW", watts);
185 amount = std::min(
stored, amount);
258 :
Visualizer(
"energy dissipation",
"energy_dissipation"), columns(width / cellsize),
259 rows(height / cellsize), width(width), height(height), cells(columns * rows), peak_value(0),
281 for (
unsigned int y = 0; y <
rows; y++)
282 for (
unsigned int x = 0; x <
columns; x++) {
289 glRectf(x, y, x + 1, y + 1);
304 if (ix < 0 || ix >=
int(
columns) || iy < 0 || iy >= int(
rows))
static joules_t global_input
Pose GetGlobalPose() const
The Stage library uses its own namespace.
joules_t GetCapacity() const
void Accumulate(meters_t x, meters_t y, joules_t amount)
void RemovePowerPack(PowerPack *pp)
static joules_t global_capacity
static joules_t global_stored
void Visualize(Camera *cam)
void Dissipate(joules_t j)
void RemoveVisualizer(Visualizer *custom_visual)
joules_t GetDissipated() const
void pose_inverse_shift(const Pose &pose)
std::vector< joules_t > cells
void Subtract(joules_t j)
usec_t SimTimeNow(void) const
virtual void Visualize(Model *mod, Camera *cam)
void AddVisualizer(Visualizer *custom_visual, bool on_by_default)
void draw_string(float x, float y, float z, const char *string)
void TransferTo(PowerPack *dest, joules_t amount)
virtual ~DissipationVis()
static joules_t global_peak_value
World * world
Pointer to the world in which this model exists.
void SetCapacity(joules_t j)
void SetStored(joules_t j)
DissipationVis(meters_t width, meters_t height, meters_t cellsize)
void AppendValue(float value)
joules_t RemainingCapacity() const
static joules_t global_dissipated
joules_t GetStored() const
Stg::PowerPack::DissipationVis event_vis
void AddPowerPack(PowerPack *pp)