Example #1
0
/*
	refreshes camera settings using view parameters such as pan zoom etc
	if a camera is selected viewport is switched to 3D
	params:ViewInfo	, global view variable defined in viewport.c
	return value:always 1
*/
static int glupdatecamera(ViewInfo * view)
{
    if (view->active_camera == -1)
        glTranslatef(-view->panx, -view->pany, view->panz);


    /*toggle to active camera */
    else {
        glMultMatrixf(view->arcball->Transform.M);	/*arcball transformations , experimental */
        glTranslatef(-view->cameras[view->active_camera]->targetx,
                     -view->cameras[view->active_camera]->targety, 0);
    }
    view->clipX1=0;
    view->clipX2=0;
    view->clipY1=0;
    view->clipY2=0;
    view->clipZ1=0;
    view->clipZ2=0;
    GetOGLPosRef(1, view->h - 5, &(view->clipX1), &(view->clipY1),
                 &(view->clipZ1));
    GetOGLPosRef(view->w - 1, 1, &(view->clipX2), &(view->clipY2),
                 &(view->clipZ2));

    if (view->active_camera == -1) {
        glScalef(1 / view->zoom * -1, 1 / view->zoom * -1,
                 1 / view->zoom * -1);
    } else {
        glScalef(1 / view->cameras[view->active_camera]->r,
                 1 / view->cameras[view->active_camera]->r,
                 1 / view->cameras[view->active_camera]->r);
    }


    return 1;
}
Example #2
0
void draw_fisheye_magnifier(ViewInfo * view)
{
    if (get_mode(view)==MM_FISHEYE_MAGNIFIER) {
	float a;
	GLfloat mg_x, mg_y, mg_z;
	a = GetOGLDistance((int) view->fmg.constantR);
	view->fmg.R = (int) a;
	GetOGLPosRef((int) view->mouse.pos.x, (int) view->mouse.pos.y,
		     &mg_x, &mg_y, &mg_z);
	glColor4f((GLfloat) 0.3, (GLfloat) 0.1, (GLfloat) 0.8,
		  (GLfloat) 1);
	if ((view->fmg.x != mg_x) || (view->fmg.y != mg_y)) {
	    if (view->active_camera == -1) {
		/* fisheye_polar(mg_x, mg_y, view->Topview); */
		draw_circle(mg_x, mg_y, a);
	    }
	    else {
		/* fisheye_spherical(mg_x, mg_y, 0.00, view->Topview); */
		if (!fisheyesphere)
		    fisheyesphere = gluNewQuadric();
		gluQuadricDrawStyle(fisheyesphere, GLU_LINE);
		glColor4f((GLfloat) 0.3, (GLfloat) 0.1, (GLfloat) 0.8, (GLfloat) 0.05);
		glTranslatef(mg_x, mg_y, 0);
		gluSphere(fisheyesphere, a, 30, 30);
		glTranslatef(-mg_x, -mg_y, 0);
	    }
	    view->fmg.x = mg_x;
	    view->fmg.y = mg_y;
	}
    }
}
Example #3
0
void draw_magnifier(ViewInfo * view)
{

    if ((get_mode(view) == MM_MAGNIFIER)
	&& (view->mouse.down)) {

	GLfloat mg_x, mg_y, mg_z;
	//converting screen pixel distaances to GL distances
	view->mg.GLwidth = GetOGLDistance(view->mg.width) / (float) 2.0;
	view->mg.GLheight = GetOGLDistance(view->mg.height) / (float) 2.0;
	GetOGLPosRef((int) view->mouse.pos.x, (int) view->mouse.pos.y, &mg_x, &mg_y, &mg_z);	//retrieving mouse coords as GL coordinates
	view->mg.x = mg_x;
	view->mg.y = mg_y;
	glLineWidth(4);
//	local_zoom(view->Topview);
	//drawing the magnifier borders
	glBegin(GL_LINE_STRIP);
	glColor4f((GLfloat) 0.3, (GLfloat) 0.1, (GLfloat) 0.8,
		  (GLfloat) 1);
	glVertex3f(view->mg.x - view->mg.GLwidth,
		   view->mg.y - view->mg.GLheight, Z_MIDDLE_PLANE);
	glVertex3f(view->mg.x + view->mg.GLwidth,
		   view->mg.y - view->mg.GLheight, Z_MIDDLE_PLANE);
	glVertex3f(view->mg.x + view->mg.GLwidth,
		   view->mg.y + view->mg.GLheight, Z_MIDDLE_PLANE);
	glVertex3f(view->mg.x - view->mg.GLwidth,
		   view->mg.y + view->mg.GLheight, Z_MIDDLE_PLANE);
	glVertex3f(view->mg.x - view->mg.GLwidth,
		   view->mg.y - view->mg.GLheight, Z_MIDDLE_PLANE);
	glEnd();
	glBegin(GL_TRIANGLE_FAN);
	glColor4f(1, 1, 1, 1);
	glVertex3f(view->mg.x - view->mg.GLwidth + 1,
		   view->mg.y - view->mg.GLheight + 1, Z_MIDDLE_PLANE);
	glVertex3f(view->mg.x + view->mg.GLwidth - 1,
		   view->mg.y - view->mg.GLheight + 1, Z_MIDDLE_PLANE);
	glVertex3f(view->mg.x + view->mg.GLwidth - 1,
		   view->mg.y + view->mg.GLheight - 1, Z_MIDDLE_PLANE);
	glVertex3f(view->mg.x - view->mg.GLwidth + 1,
		   view->mg.y + view->mg.GLheight - 1, Z_MIDDLE_PLANE);
	glVertex3f(view->mg.x - view->mg.GLwidth + 1,
		   view->mg.y - view->mg.GLheight + 1, Z_MIDDLE_PLANE);
	glEnd();
	glLineWidth(1);
    }

}
Example #4
0
/*
	when a mouse button is clicked this function is called
	params:gtk opgn gl canvas , GdkEventButton object and custom data
	return value:true or false, fails (false) if cannot init gl
*/
static gboolean button_press_event(GtkWidget * widget,
				   GdkEventButton * event, gpointer data)
{
    if (view->graphCount) {
	if (glCompSetClick
	    (view->Topview->topviewmenu, (int) event->x, (int) event->y))
	    expose_event(view->drawing_area, NULL, NULL);
    }

    begin_x = (float) event->x;
    begin_y = (float) event->y;

    if (event->button == 3)	//right click
	view->mouse.button = rightmousebutton;


    if (event->button == 1)	//left click
    {
	view->prevpanx = view->panx;
	view->prevpany = view->pany;
	view->mouse.mouse_down = 1;
	view->mouse.button = leftmousebutton;
	if (GetOGLPosRef
	    ((int) begin_x, (int) begin_y, &(view->GLx), &(view->GLy),
	     &(view->GLz))) {
	    if (view->mouse.mouse_mode == MM_SINGLE_SELECT)	//single select
	    {
		view->Selection.Active = 1;
		view->Selection.Type = 0;
		view->Selection.AlreadySelected = 0;
		view->Selection.X = view->GLx - SINGLE_SELECTION_WIDTH / 2;
		view->Selection.Y = view->GLy - SINGLE_SELECTION_WIDTH / 2;
		view->Selection.W = SINGLE_SELECTION_WIDTH;
		view->Selection.H = SINGLE_SELECTION_WIDTH;
		expose_event(view->drawing_area, NULL, NULL);
	    }
	}
    }
    return FALSE;
}