19 event_vis( 2.0 *
std::max( fabs(ceil(mod->GetWorld()->GetExtent().x.max)),
20 fabs(floor(mod->GetWorld()->GetExtent().x.min))),
21 2.0 *
std::max( fabs(ceil(mod->GetWorld()->GetExtent().y.max)),
22 fabs(floor(mod->GetWorld()->GetExtent().y.min))),
24 output_vis( 0,100,200,40, 1200,
Color(1,0,0),
Color(0,0,0,0.5),
"energy output",
"energy_input" ),
25 stored_vis( 0,142,200,40, 1200,
Color(0,1,0),
Color(0,0,0,0.5),
"energy stored",
"energy_stored" ),
56 const double height = 0.5;
57 const double width = 0.2;
61 const double alpha = 0.5;
64 glColor4f( 0,1,0, alpha );
65 else if( percent > 25 )
66 glColor4f( 1,0,1, alpha );
68 glColor4f( 1,0,0, alpha );
72 glTranslatef( -width, 0.0, 0.0 );
74 glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
76 GLfloat fullness = height * (percent * 0.01);
77 glRectf( 0,0,width, fullness);
80 glTranslatef( 0,0,0.1 );
81 glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
83 glColor4f( 0,0,0,0.7 );
85 glRectf( 0,0,width, height );
88 glVertex2f( 0, fullness );
89 glVertex2f( width, fullness );
96 glVertex2f( width/3.0, height/3.0 );
97 glVertex2f( 2.0 * width/3, height/3.0 );
99 glVertex2f( width/3.0, height/3.0 );
100 glVertex2f( width/3.0, height - height/5.0 );
102 glVertex2f( width/3.0, height - height/5.0 );
103 glVertex2f( 0, height - height/5.0 );
105 glVertex2f( 0, height - height/5.0 );
106 glVertex2f( width/2.0, height );
108 glVertex2f( width/2.0, height );
109 glVertex2f( width, height - height/5.0 );
111 glVertex2f( width, height - height/5.0 );
112 glVertex2f( 2.0 * width/3.0, height - height/5.0 );
114 glVertex2f( 2.0 * width/3.0, height - height/5.0 );
115 glVertex2f( 2.0 * width/3, height/3.0 );
124 glColor4f( 1,0,0,0.7 );
126 glRectf( 0,0,width, height );
140 watts_t watts = (-1e6 * delta_j) / (
double)delta_t;
143 last_time = time_now;
147 if( fabs(watts) > 1e-5 )
149 glColor4f( 1,0,0,0.8 );
151 snprintf( buf, 32,
"%.1fW", watts );
193 amount = std::min(
stored, amount );
270 :
Visualizer(
"energy dissipation",
"energy_dissipation" ),
271 columns(width/cellsize),
272 rows(height/cellsize),
275 cells( columns*rows ),
297 for(
unsigned int y=0; y<
rows; y++ )
298 for(
unsigned int x=0; x<
columns; x++ )
307 glRectf( x,y,x+1,y+1 );
326 if( ix < 0 || ix >=
int(
columns) || iy < 0 || iy >= int(
rows) )
static joules_t global_input
usec_t SimTimeNow(void) const
The Stage library uses its own namespace.
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)
void pose_inverse_shift(const Pose &pose)
std::vector< joules_t > cells
joules_t GetCapacity() const
void Subtract(joules_t j)
Pose GetGlobalPose() 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)
joules_t GetStored() const
virtual ~DissipationVis()
static joules_t global_peak_value
void SetCapacity(joules_t j)
joules_t RemainingCapacity() const
void SetStored(joules_t j)
DissipationVis(meters_t width, meters_t height, meters_t cellsize)
void AppendValue(float value)
static joules_t global_dissipated
joules_t GetDissipated() const
Stg::PowerPack::DissipationVis event_vis
void AddPowerPack(PowerPack *pp)