t_CKUINT AudicleFaceTnT::render_shred( Shred_Stat * stat) { int j; static UIButton nameButton; //plug this into time, potentially Shred_Time * time = stat->time; check_active_stat( time ); Color4D scol( 1,1,1,1 ); if ( stat->data ) scol = stat->data->color; if ( !time->active || !m_drawing_active_set ) scol = scol.interp (Color4D ( 1.0, 1.0, 1.0, 0.2), 0.50); else scol = scol.interp ( Color4D ( 1.0, 1.0, 1.0, 1.0 ) , 0.25 ); static char buf[512]; sprintf(buf, " (%03d):", stat->xid ); double sleading = 1.0; double ssize = 1.0; if ( time->switching ) { double anim_d = ( m_now - time->switch_time ) / time->switch_span ; if (anim_d > 1.0 ) { time->switching = false; anim_d = 1.0; } if ( time->active ) { sleading = anim_d ; ssize = anim_d ; } else { sleading = 1.0 - anim_d ; ssize = 1.0 - anim_d ; } } else if ( !time->active ) { ssize = 0.0; sleading = 0.0; return 0; } glTranslated ( 0, -m_item_spacing * sleading , 0.0 ); if ( m_drawing_active_set ) m_active_accum += m_item_spacing * sleading ; else m_done_accum += m_item_spacing * sleading; glPushMatrix(); glTranslated ( -m_aspt + 0.475 , 0, 0 ); nameButton.resize( ssize * m_item_height, ssize * m_item_height ); nameButton.setLabel( stat->name + buf ); nameButton.fitLabel(); nameButton.setw ( nameButton.w() * 0.65 ); nameButton.fillCol( scol ); nameButton.lineCol( Color4D ( 0.3, 0.3, 0.3, 1.0 ) ); glLineWidth( 2.0 ); glPushMatrix(); if ( m_drawing_scale > 1.0 ) glScaled ( 1.0, 1.0 / m_drawing_scale , 1.0 ); if ( nameButton.w() > 0.45 ) glScaled ( 0.45 / nameButton.w(), 1.0, 1.0 ); nameButton.moveto ( -nameButton.w(), nameButton.h() ); nameButton.drawRounded( 0.80f ); glPopMatrix(); glPopMatrix(); //view for the shred histories... glPushMatrix(); glTranslated ( -m_aspt + 0.5 , 0, 0 ); glScaled ( ( m_aspt * 2.0 - 0.5 ) / m_window , ssize * m_item_height * m_mheight , 1.0 ); glLineWidth ( 1.0 ); glBegin( GL_LINES); Color4D linebase ( 0.0, 0.8, 0.0 , ( !time->active || !m_drawing_active_set ) ? 0.20 : 1.0 ); glColor4dv ( linebase.data() ); glVertex2d ( 0.0, 0.0 ); glVertex2d ( m_window, 0.0 ); glEnd(); linebase = linebase.interp ( scol, 0.5 ); double x, y, dt, emph; t_CKDUR emph_window = min ( 0.5 * m_srate , 0.125 * m_window ) ; Color4D emph_col = Color4D ( 1.0, 1.0, 1.0, 1.0); glLineWidth(5.0 ); glBegin(GL_LINES); for ( j = time->history.size() -1 ; j > 0 && time->history[j].when > m_now - emph_window ; j-- ) { dt = m_now - time->history[j].when; if ( dt < 0 ) fprintf(stderr, "dt < 0 : %f\n", dt ); x = ( m_wrapmode == 0 ) ? dt : fmod ( time->history[j].when, m_window ) ; y = ( m_log_scale ) ? log ( (double) time->history[j].cycles ) : time->history[j].cycles; emph = ( dt < emph_window ) ? 1.0 - ( dt / emph_window ) : 0.0 ; glColor4dv ( linebase.interp( emph_col, emph * 0.75).alpha(emph).data() ); glVertex2d( x , y ); glVertex2d( x , 0 ); } glEnd(); glLineWidth (1.0 ); glColor4dv ( linebase.data() ); glBegin(GL_LINES); for ( j = time->history.size() -1 ; j > 0 && time->history[j].when > m_earliest ; j-- ) { x = ( m_wrapmode == 0 ) ? m_now - time->history[j].when : fmod ( time->history[j].when, m_window ) ; y = ( m_log_scale ) ? log ( (double) time->history[j].cycles ) : time->history[j].cycles; glVertex2d( x , y ); glVertex2d( x , 0 ); } glEnd(); /* if ( time->history.size() > 0 && stat->wake_time != 0 ) { glPushMatrix(); glScaled( 1.0, \ ( m_log_scale ) ? log ( (double)time->history.back().cycles ) : time->history.back().cycles , \ ( m_log_scale ) ? log ( (double)time->history.back().cycles ) : time->history.back().cycles ); double sleeping = ( stat->wake_time - time->history.back().when ); //comment this out - old code if ( sleeping > 0 ) { glPushMatrix(); glTranslated ( (m_wrapmode == 0) ? 0 : fmod ( m_now, m_window ) , 0 , 0 ); double rev = 90.0 * ( m_now - time->history.back().when ) / sleeping; glRotated( rev, 1.0, 0.0, 0.0 ); glColor4d( 1,0.7,0.7,0.8); glLineWidth(2); glBegin(GL_LINES); glVertex3d(0,0.0,0.0 ); glVertex3d(0,1.0,0.0 ); glEnd(); glPopMatrix(); } //end old if ( sleeping > 0 ) { double f_to_time = ( m_now - time->history.back().when ) / sleeping; double xn = (m_wrapmode == 0) ? 0 : fmod ( m_now, m_window ); double xw = (m_wrapmode == 0) ? stat->wake_time : fmod ( stat->wake_time , m_window ); glBegin( GL_LINES ); glColor4d ( 0.25 + 0.75 * f_to_time, 1.0 , f_to_time, 0.4 ); if ( m_wrapmode != 0 && xw < xn ) { //we're over the page wrap... glVertex3d( xn , -0.1, 0 ); glVertex3d( m_window, -0.1 , 0 ); glVertex3d( 0 , -0.1, 0 ); glVertex3d( xw, -0.1, 0 ); } else { glVertex3d( xn , -0.1, 0 ); glVertex3d( xw , -0.1, 0 ); } glEnd(); } glPointSize(8); glBegin(GL_POINTS); glVertex3d( (m_wrapmode == 0 )? stat->wake_time : fmod ( stat->wake_time , m_window ) ,-0.1,0.0 ); glEnd(); glPopMatrix(); } */ glPopMatrix(); return 0; }
void ShredInstance::draw() { UIButton shredbutton; char name[32]; shredbutton.lineCol(Color4D(0,0,0,1.0) ); switch ( stat->state ) { case 0: shredbutton.fillCol(stat->data->color.interp( Color4D (1.0,0.8,0.8,1.0) , 0.25) ); break; case 1: shredbutton.fillCol(stat->data->color.interp( Color4D (0.8,1.0,0.8,1.0) , 0.25) ); break; case 2: shredbutton.fillCol(stat->data->color.interp( Color4D (1.0,1.0,0.8,1.0) , 0.25) ); break; case 3: shredbutton.fillCol(stat->data->color.interp( Color4D (0.5,0.5,0.5,1.0) , 0.7) ); break; } shredbutton.moveto(0,0); shredbutton.seth(1.0); if ( stat->children.size() ) sprintf(name, "%d (%ld)", procID, stat->children.size() ); else sprintf(name, "%d", procID, stat->children.size() ); shredbutton.setLabel( (char*)name ); shredbutton.fitLabel(); glPushName(pickID); shredbutton.draw(0.75); if ( selected ) { _killButton->moveto( 0.5 * ( shredbutton.w() - _killButton->w() ) , \ shredbutton.top() - 0.5 * ( shredbutton.h() - _killButton->h() ) ); _killButton->drawNamed(); } if ( selected ) { glPushMatrix(); glTranslated ( shredbutton.w(), 0, 0); shredbutton.resize(1.0,1.0); int ndead= 0; for ( int i = 0; i < stat->children.size(); i++ ) { if ( stat->children[i]->state == 3 ) ndead++; else { sprintf(name, "%ld", stat->children[i]->xid ); shredbutton.setLabel(name); shredbutton.fitLabel(); switch ( stat->children[i]->state ) { case 0: shredbutton.fillCol(Color4D (1.0,0.4,0.4,1.0) ); break; case 1: case 2: shredbutton.fillCol(Color4D (0.4,1.0,0.4,1.0) ); break; } shredbutton.draw(0.75); glTranslated( shredbutton.w(), 0, 0); } } if ( ndead ) { shredbutton.fillCol( Color4D ( 0.5,0.5,0.5, 0.6 ) ); sprintf ( name, "%d dead", ndead ); shredbutton.setLabel(name); shredbutton.fitLabel(); shredbutton.draw(0.75); } glPopMatrix(); } glPopName(); }