view->cameras[view->active_camera]->camera_vectorx,
view->cameras[view->active_camera]->camera_vectory,
view->cameras[view->active_camera]->camera_vectorz);*/
- gluLookAt(view->panx, view->pany, view->zoom * -1, view->panx,
- view->pany, 0.0, 0.0, 1.0, 0.0);
+ gluLookAt(view->cameras[view->active_camera]->targetx, view->cameras[view->active_camera]->targety, view->cameras[view->active_camera]->r, view->cameras[view->active_camera]->targetx,
+ view->cameras[view->active_camera]->targety, 0.0, 0.0, 1.0, 0.0);
+// glTranslatef(view->cameras[view->active_camera]->targetx/pow(view->cameras[view->active_camera]->r,0.125),view->cameras[view->active_camera]->targety/pow(view->cameras[view->active_camera]->r,0.125),0);
glRotatef(view->cameras[view->active_camera]->angley,1,0,0);
glRotatef(view->cameras[view->active_camera]->anglex,0,1,0);
-
-
}
GetOGLPosRef(1, view->h - 5, &(view->clipX1), &(view->clipY1),
&(view->clipZ1));
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;
}
--- /dev/null
+#include "glmotion.h"
+#include <gtk/gtk.h>
+#include <gdk/gdkkeysyms.h>
+#include <gtk/gtkgl.h>
+#include <gdk/gdkcursor.h>
+#include "draw.h"
+#include "topview.h"
+#include "glutils.h"
+
+gboolean redraw = FALSE;
+
+int glmotion_main(ViewInfo * v,GdkEventMotion * event,GtkWidget * widget)
+{
+
+ redraw = FALSE;
+ /*panning */
+ if ((event->state & GDK_BUTTON1_MASK)&& (v->mouse.mouse_mode == MM_PAN))
+ glmotion_pan(v);
+
+ return 1;
+ /*rotating, only in 3d v */
+ if ((v->active_camera >=0)&&(v->mouse.button==rightmousebutton))
+ glmotion_rotate(v);
+
+ /*zooming */
+ if ((event->state & GDK_BUTTON1_MASK)&& (v->mouse.mouse_mode == MM_ZOOM))
+ glmotion_zoom(v);
+
+
+ /*selection rect */
+ if ((event->state & GDK_BUTTON1_MASK)
+ && ((v->mouse.mouse_mode == MM_RECTANGULAR_SELECT)
+ || (v->mouse.mouse_mode == 5)))
+ {
+ GetFixedOGLPos((int) v->mouse.mouse_X, (int) v->mouse.mouse_Y, v->GLDepth, &(v->GLx2),
+ &(v->GLy2), &(v->GLz2));
+ redraw = TRUE;
+ }
+ if ((event->state & GDK_BUTTON1_MASK)
+ && (v->mouse.mouse_mode == MM_MOVE)) {
+ GetFixedOGLPos((int) v->mouse.mouse_X, (int) v->mouse.mouse_Y, v->GLDepth, &(v->GLx2),
+ &(v->GLy2), &(v->GLz2));
+ redraw = TRUE;
+ }
+/* if ((event->state & GDK_BUTTON1_MASK)
+ && ((v->mouse.mouse_mode == MM_MAGNIFIER)
+ || (v->mouse.mouse_mode == MM_FISHEYE_MAGNIFIER))) {
+ v->mouse.mouse_X = (int) x;
+ v->mouse.mouse_Y = (int) y;
+ redraw = TRUE;
+ }*/
+
+ if (redraw)
+ gdk_window_invalidate_rect(widget->window, &widget->allocation,
+ FALSE);
+
+ return 1;
+}
+int glmotion_zoom(ViewInfo * v)
+{
+ char buf[256];
+
+ float real_zoom,xx;
+ if(v->active_camera==-1)
+ real_zoom=v->zoom + v->mouse.dx / 10 * (v->zoom * -1 / 20);
+ else
+ real_zoom=(v->cameras[v->active_camera]->r + v->mouse.dx / 10 * (v->cameras[v->active_camera]->r / 20))*-1;
+
+ if (real_zoom > MAX_ZOOM)
+ real_zoom = (float) MAX_ZOOM;
+ if (real_zoom < MIN_ZOOM)
+ real_zoom = (float) MIN_ZOOM;
+ if(v->active_camera==-1)
+ v->zoom = real_zoom;
+ else
+ v->cameras[v->active_camera]->r=real_zoom*-1;
+ /*set label to new zoom value */
+ xx = ((float) 100.0 - (float) 1.0) * (v->zoom -
+ (float) MIN_ZOOM) / ((float) MAX_ZOOM - (float) MIN_ZOOM) + (float) 1.0;
+ sprintf(buf, "%i", (int) xx);
+ glCompLabelSetText((glCompLabel *) v->Topview->customptr, buf);
+ return 1;
+}
+int glmotion_pan(ViewInfo * v)
+{
+ float gldx,gldy;
+ if(v->active_camera ==-1)
+ {
+ gldx=GetOGLDistance(v->mouse.dx)/v->zoom*-1;
+ gldy=GetOGLDistance(v->mouse.dy)/v->zoom*-1;
+ v->panx=v->panx-gldx;
+ v->pany=v->pany+gldy;
+ }
+ else
+ {
+ gldx=GetOGLDistance(v->mouse.dx)/v->cameras[v->active_camera]->r;
+ gldy=GetOGLDistance(v->mouse.dy)/v->cameras[v->active_camera]->r;
+ v->cameras[v->active_camera]->x-=gldx;
+ v->cameras[v->active_camera]->y-=gldy;
+ v->cameras[v->active_camera]->targetx-=gldx;
+ v->cameras[v->active_camera]->targety+=gldy;
+ }
+
+ redraw = TRUE;
+}
+int glmotion_rotate(ViewInfo * v)
+{
+ v->cameras[v->active_camera]->angley-=v->mouse.dy/5;
+ v->cameras[v->active_camera]->anglex-=v->mouse.dx/5;
+ return 1;
+}
--- /dev/null
+#ifndef GLMOTION_H
+#define GLMOTION_H
+#include "viewport.h"
+int glmotion_main(ViewInfo * v,GdkEventMotion * event,GtkWidget * widget);
+int glmotion_zoom(ViewInfo * v);
+int glmotion_pan(ViewInfo * v);
+int glmotion_rotate(ViewInfo * v);
+#endif
\ No newline at end of file
#include "gltemplate.h"
#include "glutils.h"
#include "glexpose.h"
+#include "glmotion.h"
#include "glmenu.h"
#include "selection.h"
#include "glcompset.h"
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))) {
gboolean redraw = FALSE;
dx = x - begin_x;
dy = y - begin_y;
- /*panning */
+
+ view->mouse.dx=dx;
+ view->mouse.dy=dy;
+
+ /*panning */
if ((event->state & GDK_BUTTON1_MASK)
&& (view->mouse.mouse_mode == MM_PAN))
{
- gldx=GetOGLDistance(dx)/view->zoom*-1;
- gldy=GetOGLDistance(dy)/view->zoom*-1;
- if(view->active_camera ==-1)
- {
- view->panx=view->panx-gldx;
- view->pany=view->pany+gldy;
- }
- else
- {
+ if(glmotion_main(view,event,widget))
+ redraw = TRUE;
+ }
+ /*rotating, only in 3d view */
+ if ((view->active_camera >=0)&&(view->mouse.button==rightmousebutton) )
+ {
view->cameras[view->active_camera]->angley-=dy/5;
view->cameras[view->active_camera]->anglex-=dx/5;
-// set_camera_x_y(view->cameras[view->active_camera]);
- }
- redraw = TRUE;
+ redraw = TRUE;
}
/*zooming */
if ((event->state & GDK_BUTTON1_MASK)
glconfig, NULL, TRUE, GDK_GL_RGBA_TYPE);
gtk_widget_add_events(view->drawing_area,
- GDK_BUTTON1_MOTION_MASK |
+// GDK_BUTTON_MOTION_MASK = 1 << 4,
+ GDK_BUTTON_MOTION_MASK |
+ GDK_BUTTON1_MOTION_MASK |
GDK_BUTTON2_MOTION_MASK |
+ GDK_BUTTON3_MOTION_MASK |
GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK |
GDK_VISIBILITY_NOTIFY_MASK);
/* Popup menu. */
- menu = create_popup_menu(view->drawing_area);
+ /* menu = create_popup_menu(view->drawing_area);
/* Signal handler */
- g_signal_connect_swapped(G_OBJECT(view->drawing_area),
+ /* g_signal_connect_swapped(G_OBJECT(view->drawing_area),
"button_press_event",
G_CALLBACK(button_press_event_popup_menu),
- menu);
+ menu);*/
}
#define NODE_CIRCLE_LIMIT -7.3
typedef enum { nodshapedot,nodeshapecircle} node_shape;
+typedef enum { leftmousebutton,rightmousebutton,thirdmousebutton} clicked_mouse_button;
+
typedef struct {
float R;
typedef struct _mouse_attr {
int mouse_down;
int mouse_mode;
- int mouse_X;
- int mouse_Y;
+ float mouse_X;
+ float mouse_Y;
+ float begin_x;
+ float begin_y;
+ float dx;
+ float dy;
+ clicked_mouse_button button;
} mouse_attr;
GLdouble projection[16];
GLfloat winX, winY;
float kts = 1;
- //glTranslatef (0.0,0.0,0.0);
+
+
+
glGetDoublev(GL_MODELVIEW_MATRIX, modelview);
glGetDoublev(GL_PROJECTION_MATRIX, projection);