Exemplo n.º 1
0
void Marquee::resizeEvent(QResizeEvent * /*event*/)
{
    if( _show_temporary > 0 ) {
        _draw_text( _temporary );
    } else {
        _draw_text( _permanent );
    }
    if( _pos > _canvas->width() ) _pos = 0;
}
Exemplo n.º 2
0
static void
draw_axis_labels (BotGlScrollPlot2d *self, int x, int y, int width, int height)
{
    if (!self->show_ylim) return;

    _gl_setcolor (self->text_rgba);
    glRasterPos2f(x + 1, y + self->text_height - 1);
    char text[20];
    snprintf(text, sizeof(text), "%.2g", self->y_max);
    _draw_text (self, text);

    glRasterPos2f (x + 1, y + height - 1);
    snprintf(text, sizeof(text), "%.2g", self->y_min);
    _draw_text (self, text);
}
Exemplo n.º 3
0
void Marquee::set_temporary(QString txt) {
    _scroll_timer.stop();
    _temporary = txt;
    _show_temporary = _show_temporary_first;
    _draw_text(txt);
    _wait_timer.start();
}
Exemplo n.º 4
0
void zz_font_d3d::draw_text_prim_offset (const zz_font_text& text_item, float offsetx, float offsety)
{
	zz_assert(!text_item.to_texture);
	zz_assert(text_item.msg.get());
	zz_assert(text_item.msg.size());
	zz_assert(_d3d_font);
	
	if (!_d3d_font)
		return;

	zz_renderer_d3d * r = (zz_renderer_d3d *)(znzin->renderer);

	assert(r->is_a(ZZ_RUNTIME_TYPE(zz_renderer_d3d)));

	LPD3DXSPRITE sprite = r->get_sprite();
	zz_assert(sprite);
	HRESULT hr;

	D3DXMATRIX saved_tm;
	D3DXMATRIX new_tm;

	zz_assert(r->sprite_began());

	r->flush_sprite();
	r->get_sprite_transform((float*)&saved_tm); // save tm

	// adjust offset
	new_tm = saved_tm;

	// assert not-zero-scale
	assert(saved_tm._11 != 0);
	assert(saved_tm._22 != 0);
	assert(saved_tm._33 != 0);

	// we does not support rotation
	assert(saved_tm._12 == 0);
	assert(saved_tm._13 == 0);
	assert(saved_tm._21 == 0);
	assert(saved_tm._23 == 0);
	assert(saved_tm._31 == 0);
	assert(saved_tm._32 == 0);
	new_tm._41 += offsetx * saved_tm._11;
	new_tm._42 += offsety * saved_tm._22;

	r->set_sprite_transform((float*)&new_tm);

	RECT rect = text_item.rect;
	if (FAILED(hr = _draw_text(
		sprite,
		text_item.msg.get(), -1,
		&rect, 
		text_item.format,
		text_item.color )))
	{
		ZZ_LOG("font_d3d: DrawText() failed\n", zz_renderer_d3d::get_hresult_string(hr));
	}

	sprite->SetTransform(&saved_tm); // restore tm
}
Exemplo n.º 5
0
void Marquee::_wait_over()
{
    if( _show_temporary == 1 ) {
        _draw_text(_permanent);
        _pos = 0;
        _show_temporary = 0;
    } else if( _show_temporary > 0 ) {
        --_show_temporary;
    }
    if(_scroll == false) {
        _draw_text(_permanent);
        _pos = 0;
        _show_temporary = 0;
        return;
    } else {
        _scroll_timer.start();
    }
}
Exemplo n.º 6
0
static void
draw_title (BotGlScrollPlot2d *self, int x, int y, int width, int height)
{
    if (!self->title || !self->show_title) return;

    _gl_setcolor (self->text_rgba);
    int title_width_pixels = glutBitmapLength(self->text_font, 
            (unsigned char *) self->title);
    glRasterPos2f(x + width / 2 - title_width_pixels / 2, 
            y + self->text_height - 1);
    _draw_text (self, self->title);
}
Exemplo n.º 7
0
Marquee::Marquee(QWidget* parent) :
    QWidget(parent),
    _pos(0),
    _incr(5),
    _show_temporary(0),
    _show_temporary_first(3)
{
    _scroll_timer.setInterval(42);
    _scroll_timer.setSingleShot(false);
    _wait_timer.setInterval(1500);
    _wait_timer.setSingleShot(true);

    connect( &_scroll_timer, SIGNAL(timeout()),
             this, SLOT(_scroll_incr()) );
    connect( &_wait_timer, SIGNAL(timeout()),
             this, SLOT(_wait_over()) );

    _draw_text("");
    _scroll = false;
}
Exemplo n.º 8
0
void myWindow::paintGL()
{
    double deltaTime = t_Timer->interval()/1000.0;

    int LightPos[4] = {1,5,-1,0};
    int Light2Pos[4] = {-2,7,2,0};
    int Light3Pos[4] = {5,4,0,0};
    _fx += _speed;
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glLoadIdentity();
    glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );

    glLightiv(GL_LIGHT0,GL_POSITION,LightPos);
    glLightiv(GL_LIGHT1,GL_POSITION,Light2Pos);
    glLightiv(GL_LIGHT2,GL_POSITION,Light3Pos);
    glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, 1);
    glLightf(GL_LIGHT1, GL_LINEAR_ATTENUATION, 10);

    //zoom
    if(_zooming){
        multiplicateurovertimezoom += 0.15;
        _zoom += _zoomspeed * multiplicateurovertimezoom * deltaTime;
    }else if(_dezooming){
        multiplicateurovertimezoom += 0.15;
        _zoom -= _zoomspeed * multiplicateurovertimezoom * deltaTime;
    }else{
        multiplicateurovertimezoom = 1.0;
    }
    //rotation
    if(_turningleft){
        multiplicateurovertimerotation += 0.15;
        _fx -= _rotationspeed * multiplicateurovertimerotation * deltaTime;
    }else if(_turningright){
        multiplicateurovertimerotation += 0.15;
        _fx += _rotationspeed * multiplicateurovertimerotation * deltaTime;
    }else{
        multiplicateurovertimerotation = 1.0;
    }
    //angle
    if(_plonger){
        multiplicateurovertimeplonger += 0.15;
        _angle += _rotationspeed* multiplicateurovertimeplonger *deltaTime;
    }else if(_deplonger){
        multiplicateurovertimeplonger += 0.15;
        _angle -= _rotationspeed* multiplicateurovertimeplonger *deltaTime;
    }else{
        multiplicateurovertimeplonger = 1.0;
    }
    //hauteur camera
    if(_monter){
        multiplicateurovertimemonter += 0.15;
        _hauteurcam -= 2 * multiplicateurovertimemonter *deltaTime;
    }else if(_demonter){
        multiplicateurovertimemonter += 0.15;
        _hauteurcam += 2 * multiplicateurovertimemonter *deltaTime;
    }else{
        multiplicateurovertimemonter = 1.0;
    }

    glTranslatef(0.f, _hauteurcam, _zoom);
    glRotated(_angle,1,0,0);
    glRotated(_fx,0,0,1);

    //***************************************//
    //************* Création Mesh ***********//
    //***************************************//

    if(!meshUpToDate){
        _par.resetEtageLePlusHaut();

        qDebug()<<_mesh.nbFace();
        largeur = 40; //du terrain
        longueur = 40;

        int largeurQuartier = 10;
        int longueurQuartier = 10;
/*
        float angle = 2*3.14159265359 / 6;
        _mesh = Mesh::createHexaangle3D(Vector3D(cos(0),sin(0),0),
                                        Vector3D(cos(angle),sin(angle),0),
                                        Vector3D(cos(2*angle),sin(2*angle),0),
                                        Vector3D(cos(3*angle),sin(3*angle),0),
                                        Vector3D(cos(4*angle),sin(4*angle),0),
                                        Vector3D(cos(5*angle),sin(5*angle),0),1.0);
*/
/*
        Mesh m1;
        for(float i=-largeur/2;i<largeur/2;i+=3.1){
            for(float j=-longueur/2; j<longueur/2; j+=3.1){
        //for(float i=-largeur/2;i<largeur/2;i+=largeurQuartier+1){
            //for(float j=-longueur/2; j<longueur/2; j+=longueurQuartier+1){
                int tmp = (int)rand()%4;
                //tmp = 0;
                //qDebug()<<tmp;
                if(tmp == 0){
                    //PaterneQuad p1(Vector2D(i,j), Vector2D(i,j+longueurQuartier), Vector2D(i+largeurQuartier,j+longueurQuartier), Vector2D(i+largeurQuartier,j),&_par);
                     //m1.merge(p1.generate());
                    Batiment test(Vector3D(i+(rand()%100)*0.001,j+(rand()%100)*0.001,0),
                                  Vector3D(i+(rand()%100)*0.001,j+1+(rand()%100)*0.001,0),
                                  Vector3D(i+1+(rand()%100)*0.001,j+1+(rand()%100)*0.001,0),
                                  Vector3D(i+1+(rand()%100)*0.001,j+(rand()%100)*0.001,0),
                                  &_par);
                    m1.merge(test.generate());
                }else if(tmp == 1){
                    float offset = (rand()%21)*0.1;
                    Batiment test(Vector3D(i+(rand()%100)*0.001,j+(rand()%100)*0.001,0),
                                  Vector3D(i+(rand()%100)*0.001,j+1+(rand()%100)*0.001,0),
                                  Vector3D(i+1+offset+(rand()%100)*0.001,j+1+(rand()%100)*0.001,0),
                                  Vector3D(i+1+offset+(rand()%100)*0.001,j+(rand()%100)*0.001,0),
                                  &_par);
                    m1.merge(test.generate());
                }else if(tmp == 2){
                    float offset = (rand()%21)*0.1;
                    Batiment test(Vector3D(i+(rand()%100)*0.001,j+(rand()%100)*0.001,0),
                                  Vector3D(i+(rand()%100)*0.001,j+1+offset+(rand()%100)*0.001,0),
                                  Vector3D(i+1+(rand()%100)*0.001,j+1+offset+(rand()%100)*0.001,0),
                                  Vector3D(i+1+(rand()%100)*0.001,j+(rand()%100)*0.001,0),
                                  &_par);
                    m1.merge(test.generate());
                }else{
                    float offset = (rand()%21)*0.1;
                    Batiment test(Vector3D(i+(rand()%100)*0.001,j+(rand()%100)*0.001,0),
                                  Vector3D(i+(rand()%100)*0.001,j+1+offset+(rand()%100)*0.001,0),
                                  Vector3D(i+1+offset+(rand()%100)*0.001,j+1+offset+(rand()%100)*0.001,0),
                                  Vector3D(i+1+offset+(rand()%100)*0.001,j+(rand()%100)*0.001,0),
                                  &_par);
                    m1.merge(test.generate());
                }
            }
        }
        _mesh = m1;*/
        /*Batiment test(Vector3D(-3+(rand()%100)*0.001,-3+(rand()%100)*0.001,0),
                      Vector3D(-3+(rand()%100)*0.001,3+(rand()%100)*0.001,0),
                      Vector3D(3+(rand()%100)*0.001,3+(rand()%100)*0.001,0),
                      Vector3D(3+(rand()%100)*0.001,-3+(rand()%100)*0.001,0),
                      &_par);
        _mesh = test.generate();*/

        TerrainBase base(400,400, &_par);
        base.decoupeSimple(4000);
        base.shrink(4.f);
        base.supprPetitQuartier(400);
        _mesh = base.generate();

        //Mesh m1 = base.generate();


/*
        TerrainBase base(2000,2000, &_par);
        base.decoupeSimple();
        base.shrink(10.f);
        base.supprPetitQuartier(1000);
        Mesh m = base.generate();

        _mesh = m;

*/
        /*
        TerrainBase base(1000,1000);
        base.decoupeSimple();
        for(Quartier* q : base.quartiers){

        }*/
        meshUpToDate = true;
        frame->update_values();
    }
    glEnable(GL_LIGHTING);
    int nbfaces = _mesh.nbFace();
    for(int i=0; i<nbfaces; i+=3){
        Vector3D dir1, dir2; //pour le calcul des normals
        Vector3D normal;
        Vector3D p1 = _mesh.getVertex(_mesh.getFace(i));
        Vector3D p2 = _mesh.getVertex(_mesh.getFace(i+1));
        Vector3D p3 = _mesh.getVertex(_mesh.getFace(i+2));
        dir1 = p2-p1;
        dir2 = p3-p1;
        normal = dir1.crossProduct(dir2);
        normal.normalize();;
        glColor3f(0.0,1.0,0.0); //Y vert
        glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
        glBegin(GL_TRIANGLES);
            glNormal3f(normal.x,normal.y,normal.z);
            glVertex3f(p1.x,p1.y,p1.z);
            glVertex3f(p2.x,p2.y,p2.z);
            glVertex3f(p3.x,p3.y,p3.z);
        glEnd();
    }

    glDisable(GL_LIGHTING);
    float angle = (2*M_PI)/64;
    glColor3f(1.0,0.2,0.2);
    glLineWidth(4.0f);
    glBegin(GL_LINE_STRIP);

    for(float i = 0; i < 2*M_PI ; i+=angle){
        glVertex3f(cos(i)*200*_par.influenceCentreVille+_par._centreVille.x, sin(i)*200*_par.influenceCentreVille+_par._centreVille.y,10);
    }
    glEnd();
    _draw_text(_par.hauteurEtageLePlusHaut.x,_par.hauteurEtageLePlusHaut.y,_par.hauteurEtageLePlusHaut.z,QString(QString::number(_par.etageLePlusHaut)));
}
Exemplo n.º 9
0
void Marquee::set_permanent(QString txt) {
    _permanent = txt;
    if(_show_temporary == 0) {
        _draw_text(txt);
    }
}
Exemplo n.º 10
0
void GLWidget::drawAxes(float bigger, boolean draw_x, boolean draw_y, boolean draw_z){
	if(draw_axes){
		GLfloat materialColor[] = { 1.0, 1.0, 1.0, 0.2 };
		glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, materialColor);
	//	glLineWidth(5.0f);

		float step = bigger/2;
		float glstep = (step)/bigger;

		if(draw_z){
			glBegin(GL_LINES);
				glVertex3f( -1, -1, -1);
				glVertex3f( -1, -1, 1);
			glEnd();

			float current_glvalue = -1.0;
			float current_value = -bigger;
			while(current_glvalue < 1.0){
				glBegin(GL_LINES);
					glVertex3f( -1, -1, current_glvalue);
					glVertex3f( -0.99, -0.99, current_glvalue);
				glEnd();
				_draw_text( -0.99, -0.99, current_glvalue, QString::number(round(current_value)), Qt::white);
				current_glvalue += glstep;
				current_value += step;
			}
			_draw_text( -1.0f, -1.0f, 1.0f, "Z(nm)", Qt::red);
		}

		if(draw_y){
			glBegin(GL_LINES);
				glVertex3f( -1, -1, -1);
				glVertex3f(  1, -1, -1);
			glEnd();

			float current_glvalue = -1.0;
			float current_value = -bigger;
			while(current_glvalue < 1.0){
				glBegin(GL_LINES);
					glVertex3f( current_glvalue, -1, -1);
					glVertex3f( current_glvalue, -0.99, -0.99);
				glEnd();
				_draw_text( current_glvalue, -0.99, -0.99, QString::number(round(current_value)), Qt::white);
				current_glvalue += glstep;
				current_value += step;
			}
			_draw_text( 1.0f, -1.0f, -1.0f, "Y(nm)", Qt::red);
		}

		if(draw_x){
			glBegin(GL_LINES);
				glVertex3f( -1, -1, -1);
				glVertex3f( -1, 1, -1);
			glEnd();

			float current_glvalue = -1.0;
			float current_value = -bigger;
			while(current_glvalue < 1.0){
				glBegin(GL_LINES);
					glVertex3f( -1, current_glvalue, -1);
					glVertex3f( -0.99, current_glvalue, -0.99);
				glEnd();
				_draw_text( -0.99, current_glvalue, -0.99, QString::number(round(current_value)), Qt::white);
				current_glvalue += glstep;
				current_value += step;
			}
			_draw_text( -1.0f, 1.0f, -1.0f, "X(nm)", Qt::red);
		}


	//draw grid
		GLfloat materialColor2[] = { 0.4, 0.4, 0.4, 0.2 };
		glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, materialColor2);
	//	x0-axe
		glBegin(GL_LINES);
			glVertex3f( -1, -1, 0);
			glVertex3f(  1, -1, 0);
		glEnd();
	//	y0-axe
		glBegin(GL_LINES);
			glVertex3f( -1, -1, 0);
			glVertex3f( -1, 1, 0);
		glEnd();

		glBegin(GL_LINES);
			glVertex3f(  1,  1, 0);
			glVertex3f(  1, -1, 0);
		glEnd();
	//	y0-axe
		glBegin(GL_LINES);
			glVertex3f( -1, 1, 0);
			glVertex3f(  1, 1, 0);
		glEnd();

	}
}
Exemplo n.º 11
0
void Graphics::drawString(const std::string& str, Color fg, Color bg, bool fillbg, const gfx::Point& pt)
{
  _draw_text(m_bmp, m_currentFont, str.c_str(), m_dx+pt.x, m_dy+pt.y,
    fg, bg, fillbg, 1 * jguiscale());
}
Exemplo n.º 12
0
void bb_litehtml_document_container::draw_text( litehtml::uint_ptr hHdc,const litehtml::tchar_t *text,litehtml::uint_ptr hFont,litehtml::web_color color,const litehtml::position &pos ){

	bbObject *hdc=(bbObject*)hHdc;
	bbObject *font=(bbObject*)hFont;
	_draw_text( hdc,text,font,&color,(litehtml::position*)&pos );
}
Exemplo n.º 13
0
static void
draw_legend (BotGlScrollPlot2d *self, int x, int y, int width, int height)
{
    if (self->show_legend == BOT_GL_SCROLLPLOT2D_HIDDEN) return;

    // compute the width and height of the legend box
    int max_label_width = 0;
    GPtrArray * all_plots = __hash_table_get_vals (self->plots);
    for (int i=0; i<all_plots->len; i++) {
        _plot2d_t *plot = (_plot2d_t*) g_ptr_array_index (all_plots, i);
        int label_width = glutBitmapLength (self->text_font, 
                (unsigned char*) plot->name);
        if (label_width > max_label_width) max_label_width = label_width;
    }
    int smallbox_width = 20;
    int smallbox_height = 15;
    int sb_label_padding = 5;
    int row_height = MAX (self->text_height, smallbox_height) + 2;
    int row_width = smallbox_width + max_label_width + sb_label_padding;
    int legend_width = row_width + 2;
    int legend_height = row_height * all_plots->len;

    // now where does the legend go?
    int legend_x = 0;
    int legend_y = 0;
    switch (self->show_legend) {
        case BOT_GL_SCROLLPLOT2D_TOP_LEFT:
            legend_x = x;
            legend_y = y;
            break;
        case BOT_GL_SCROLLPLOT2D_TOP_RIGHT:
            legend_x = x + width - legend_width;
            legend_y = y;
            break;
        case BOT_GL_SCROLLPLOT2D_BOTTOM_LEFT:
            legend_x = x;
            legend_y = y + height - legend_height;
            break;
        case BOT_GL_SCROLLPLOT2D_BOTTOM_RIGHT:
            legend_x = x + width - legend_y;
            legend_y = y + height - legend_height;
            break;
        default:
            g_warning ("BotGlScrollPlot2d: invalid legend location %d\n", 
                    self->show_legend);
            goto done;
    }

    if (legend_x < x || legend_width > width) goto done;
    if (legend_y < y) legend_y = y;

    int row_x = legend_x;
    int row_y = legend_y;
    for (int i=0; i<all_plots->len; i++) {
        _plot2d_t *plot = (_plot2d_t*) g_ptr_array_index (all_plots, i);

        if (row_y + row_height > y + height) break;
        _plot2d_setup_gl_line_style (plot);

        glBegin (GL_LINES);
        glVertex2f (legend_x + 2, row_y + smallbox_height / 2);
        glVertex2f (legend_x + smallbox_width, row_y + smallbox_height / 2);
        glEnd ();

        _gl_setcolor (plot->rgba);
        glRasterPos2f (row_x + smallbox_width + sb_label_padding, 
                row_y + self->text_height - 1);
        _draw_text (self, plot->name);
        row_y += row_height;
    }

    glBegin (GL_LINE_LOOP);
    glColor3f (1, 1, 1);
    glVertex2f (legend_x, legend_y);
    glVertex2f (legend_x + legend_width, legend_y);
    glVertex2f (legend_x + legend_width, row_y);
    glVertex2f (legend_x, row_y);
    glEnd ();

done:
    g_ptr_array_free (all_plots, TRUE);
}
Exemplo n.º 14
0
// called after clear_text_texture
void zz_font_d3d::draw_text_prim (const zz_font_text& text_item)
{
	if (!text_item.msg.get()) return;

	size_t length;
	length = text_item.msg.size();

	if (length <= 0) return; // draw nothing
	
	assert(_d3d_font);
	if (!_d3d_font)
		return;
	
	zz_renderer_d3d * r = static_cast<zz_renderer_d3d*>(znzin->renderer);
	LPD3DXSPRITE sprite = r->get_sprite();
	assert(sprite);

	if (!text_item.use_sprite) { // begin sprite
		
		zz_assert(!r->sprite_began());
		r->begin_sprite(ZZ_SPRITE_ALPHABLEND, "draw_text_prim");  //조성현 2006 04 25 Text출력..
		// we assumes that identity matrix transform is the default
	   D3DXMATRIX mat, mat2;
	   D3DXMatrixIdentity(&mat2);
	   sprite->GetTransform(&mat);
	   
	   mat2._41 = mat._41;
	   mat2._42 = mat._42;
	   mat2._43 = mat._43;
	
	   sprite->SetTransform(&mat2);

	    
	}
	else {
		zz_assert(r->sprite_began());
	  
	}

	HRESULT hr;

	if (text_item.to_texture) { // render to texture stage
		r->enable_zbuffer(false);
		r->enable_zwrite(false);

		zz_rect new_rect;
		int width, height;
		width = text_item.rect.right - text_item.rect.left;
		height = text_item.rect.bottom - text_item.rect.top;
		SetRect(&new_rect, text_item.tex_rect.left, text_item.tex_rect.top,
			text_item.tex_rect.left + width, text_item.tex_rect.top + height);

		assert((text_item.tex_rect.top != 0) || (text_item.tex_rect.bottom != 0));

		//ZZ_LOG("font: draw_text_prim(%s), [%d, %d]\n", text_item.msg.get(),	text_item.tex_rect.top, text_item.tex_rect.top + height);
		//ZZ_LOG("font: draw_text_prim(%s), [%d, %d, %d, %d]\n",
		//	text_item.msg.get(),
		//	new_rect.left, new_rect.top, new_rect.right, new_rect.bottom);

		DWORD frontcolor = 0xFFFFFFFF;

		if (FAILED(hr = _draw_text(
			sprite,
			text_item.msg.get(), -1,
			&new_rect, 
			text_item.format,
			frontcolor )))
		{
			ZZ_LOG("font_d3d: DrawText() failed\n", zz_renderer_d3d::get_hresult_string(hr));
		}
		
		// restore states
		r->enable_zbuffer(true);
		r->enable_zwrite(true);
	}
	else {
		RECT rect = text_item.rect;
		if (FAILED(hr = _draw_text(
			sprite,
			text_item.msg.get(), -1,
			&rect, 
			text_item.format,
			text_item.color )))
		{
			ZZ_LOG("font_d3d: DrawText() failed\n", zz_renderer_d3d::get_hresult_string(hr));
		}
	}

	if (!text_item.use_sprite) { // end sprite
		r->end_sprite();
	}
}