Exemple #1
0
void    
Button::render()
{
#ifdef DEBUG_BUTTON
    cout << "Button::render()" << endl;
#endif    
    ViewRect r = getScreenQuad();

    float cx = r.x + r.w/2.0;
    float cy = r.y + r.h/2.0;

    //
    RenderSystem *renderSystem = Global::instance()->getRenderSystem();
    renderSystem->startViewport(screen_window);

    renderSystem->setColor(bg_color);
    renderSystem->drawQuad(r.x,r.y,r.w,r.h);
 
#ifdef DEBUG_BUTTON
    cout << "   state: " << state << endl;
    cout << "   toggle: " << toggle << endl;
    cout << "   toggle: " << text_color_1.str() << endl;
#endif    

    renderSystem->setColor(text_color_0);
    if (state == 1 && toggle)
	renderSystem->setColor(text_color_1);
    renderSystem->drawCenteredText(text.c_str(), 
				   font_size, 
				   r.x, r.y,
				   r.w, r.h);

    renderSystem->endViewport();
}
Exemple #2
0
void 
MapSelectionsRenderer::process()
{
#ifdef DEBUG_MAPSELECTIONSRENDERER
    cout << "MapSelectionsRenderer::process()" << endl;
#endif
    // cout << "MapSelectionsRenderer::process()" << endl;
    typedef data::Single<Selection *> SingleSelectionPtr;


    ViewRect screen_window;
    if (!data::SingleViewRect::getInputValue(this,"screen_window",screen_window))
	return;

#ifdef DEBUG_MAPSELECTIONSRENDERER
    cout << "   screen window.....OK" << endl;
#endif

    ViewRect world_window;
    if (!data::SingleViewRect::getInputValue(this,"world_window",world_window))
	return;

#ifdef DEBUG_MAPSELECTIONSRENDERER
    cout << "   world window.....OK" << endl;
#endif

    vector<Selection *> selections;
    vector<Data *> vec_data = this->getInputPort("selections")->getAllData();
    for (int i=0;i<vec_data.size();i++)
    {
	SingleSelectionPtr* data = dynamic_cast<SingleSelectionPtr*>(vec_data.at(i));  
	if (data != NULL)
	    selections.push_back(data->value);
    }
    
#ifdef DEBUG_MAPSELECTIONSRENDERER
    cout << "   number of selections " << selections.size() << endl;
#endif

    Global *global = Global::instance();

    if (global->usa_states == NULL)
    {
	cout << "   usa states not loaded... returning without rendering" << endl;
    }

    ScreenWorldTransform swt(screen_window, world_window);
    ViewRect adj_screen_window = swt.getAdjustedScreenWindow();

    RenderSystem *renderSystem = global->getRenderSystem();
    renderSystem->startViewport(adj_screen_window, 
				world_window,
				screen_window);


    for (int i=0;i<selections.size();i++)
    {
	Selection *sel = selections[i];
	ViewRect sw = sel->getSelectionWindow();

	Color c = sel->getColor();
	renderSystem->setColor(c.r,c.g,c.b, ColorConstants::SEL_TRANSPARENCY);
	renderSystem->drawQuad(sw.x,sw.y,sw.w,sw.h);

	renderSystem->setColor(sel->getColor());
	renderSystem->drawQuad(sw.x,sw.y,sw.w,sw.h,GL_LINE_LOOP);
    }

    renderSystem->endViewport();

}