예제 #1
0
void glmotion_main(ViewInfo * v, GdkEventMotion * event,
		   GtkWidget * widget)
{

    int a=get_mode(v);
    redraw = FALSE;
    /*panning */
    if (a == MM_PAN)
	glmotion_pan(v);
    /*rotating, only in 3d v */
    if (a == MM_ROTATE)
	glmotion_rotate(v);

    /*zooming */
    if (a == MM_ZOOM)
	glmotion_zoom(v);
    /*selection rect */
    if ((a == MM_RECTANGULAR_SELECT) || (a == 5)) 
    {
	GetFixedOGLPos((int) event->x, (int) event->y, v->GLDepth,
		       &(v->mouse.GLfinalPos.x), &(v->mouse.GLfinalPos.y), &(v->mouse.GLfinalPos.z));
	redraw = TRUE;
    }
    if (a == MM_MOVE) 
    {
	GetFixedOGLPos((int) event->x, (int) event->y, v->GLDepth,
		       &(v->mouse.GLfinalPos.x), &(v->mouse.GLfinalPos.y), &(v->mouse.GLfinalPos.z));
	redraw = TRUE;
    }
    if (redraw)
	gdk_window_invalidate_rect(widget->window, &widget->allocation,
				   FALSE);

}
예제 #2
0
/*
	when  mouse is moved over glcanvas this function is called
	params:gtk opgn gl canvas , GdkEventMotion object and custom data
	return value:always TRUE !!!
*/
static gboolean motion_notify_event(GtkWidget * widget,
				    GdkEventMotion * event, gpointer data)
{
    /* float w = (float)widget->allocation.width; */
    /* float h = (float)widget->allocation.height; */
    float x = (float) event->x;
    float y = (float) event->y;


    gboolean redraw = FALSE;
    dx = x - begin_x;
    dy = y - begin_y;

    view->mouse.dx = dx;
    view->mouse.dy = dy;

	view->mouse.mouse_X = x;
	view->mouse.mouse_Y = y;

	/*panning */
    if ((event->state & GDK_BUTTON1_MASK)
	&& (view->mouse.mouse_mode == MM_PAN)) {
	if (glmotion_main(view, event, widget))
	    redraw = TRUE;
    }
    /*rotating, only in 3d view */
    if ((view->active_camera >= 0) && (view->mouse.mouse_mode == MM_ROTATE)
	&& (event->state & GDK_BUTTON1_MASK)) {
	if (glmotion_main(view, event, widget))
	    redraw = TRUE;
    }
    /*zooming */
    if ((event->state & GDK_BUTTON1_MASK)
	&& (view->mouse.mouse_mode == MM_ZOOM))
	{
		if (glmotion_main(view, event, widget))
		    redraw = TRUE;
	}

    /*selection rect */
    if ((event->state & GDK_BUTTON1_MASK)
	&& ((view->mouse.mouse_mode == MM_RECTANGULAR_SELECT)
	    || (view->mouse.mouse_mode == 5))) {
	GetFixedOGLPos((int) x, (int) y, view->GLDepth, &(view->GLx2),
		       &(view->GLy2), &(view->GLz2));
	redraw = TRUE;
    }
    if ((event->state & GDK_BUTTON1_MASK)
	&& (view->mouse.mouse_mode == MM_MOVE)) {
	GetFixedOGLPos((int) x, (int) y, view->GLDepth, &(view->GLx2),
		       &(view->GLy2), &(view->GLz2));
	redraw = TRUE;
    }
    if ((event->state & GDK_BUTTON1_MASK)
	&& ((view->mouse.mouse_mode == MM_MAGNIFIER)
	    || (view->mouse.mouse_mode == MM_FISHEYE_MAGNIFIER))) {
	view->mouse.mouse_X = x;
	view->mouse.mouse_Y = y;
	redraw = TRUE;
    }


    begin_x = x;
    begin_y = y;


    if (redraw)
	gdk_window_invalidate_rect(widget->window, &widget->allocation,
				   FALSE);
    return TRUE;
}