]> granicus.if.org Git - graphviz/commitdiff
smyrna mouse inter. changes
authorarif <devnull@localhost>
Thu, 5 Nov 2009 14:50:42 +0000 (14:50 +0000)
committerarif <devnull@localhost>
Thu, 5 Nov 2009 14:50:42 +0000 (14:50 +0000)
16 files changed:
cmd/smyrna/draw.c
cmd/smyrna/glexpose.c
cmd/smyrna/glmotion.c
cmd/smyrna/gltemplate.c
cmd/smyrna/gui/appmouse.c
cmd/smyrna/gui/appmouse.h
cmd/smyrna/gui/glcompui.c
cmd/smyrna/gui/menucallbacks.c
cmd/smyrna/gui/toolboxcallbacks.c
cmd/smyrna/selection.c
cmd/smyrna/selection.h
cmd/smyrna/smyrna.vcproj
cmd/smyrna/smyrnadefs.h
cmd/smyrna/topview.c
cmd/smyrna/viewport.c
lib/glcomp/glcompdefs.h

index 139d9f60e5b5e362d2e0cdc38b7f3aafeecc7932..f437f7eb2ab129011b5384c97c7c38c217b6f9d0 100755 (executable)
@@ -28,6 +28,7 @@ XDOT DRAWING FUNCTIONS, maybe need to move them somewhere else
 #include "xdot.h"
 #include "viewport.h"
 #include "topfisheyeview.h"
+#include "appmouse.h"
 
 //delta values
 static float dx = 0.0;
@@ -111,7 +112,8 @@ void DrawBezier(GLfloat * xp, GLfloat * yp, GLfloat * zp, int filled,
 static void set_options(sdot_op * op, int param)
 {
 
-    if ((param == 1) && (view->mouse.mouse_mode == 10) && (view->mouse.down == 1))     //selected, if there is move, move it
+    int a=get_mode(view);
+    if ((param == 1) && (a == 10) && (view->mouse.down == 1))  //selected, if there is move, move it
     {
        dx = view->mouse.GLinitPos.x-view->mouse.GLfinalPos.x;
        dy = view->mouse.GLinitPos.y-view->mouse.GLfinalPos.y;
@@ -444,7 +446,7 @@ void EmbedText(sdot_op* o, int param)
 
 void draw_selection_box(ViewInfo * view)
 {
-    if (((view->mouse.mouse_mode == 4) || (view->mouse.mouse_mode == 5))
+/*    if (((view->mouse.mouse_mode == 4) || (view->mouse.mouse_mode == 5))
        && view->mouse.down) {
        glColor4f(view->Selection.SelectionColor.R,
                  view->Selection.SelectionColor.G,
@@ -469,13 +471,13 @@ void draw_selection_box(ViewInfo * view)
        if (view->mouse.mouse_mode == 5)
            glDisable(GL_LINE_STIPPLE);
 
-    }
+    }*/
 }
 
 void draw_magnifier(ViewInfo * view)
 {
 
-    if ((view->mouse.mouse_mode == MM_MAGNIFIER)
+    if ((get_mode(view) == MM_MAGNIFIER)
        && (view->mouse.down)) {
 
        GLfloat mg_x, mg_y, mg_z;
@@ -544,7 +546,9 @@ void draw_circle(float originX, float originY, float radius)
 GLUquadric *fisheyesphere;
 void draw_fisheye_magnifier(ViewInfo * view)
 {
-    if ((view->mouse.mouse_mode == 21) && (view->mouse.down)) {
+    if (get_mode(view)==MM_FISHEYE_MAGNIFIER)
+
+    {
        float a;
        GLfloat mg_x, mg_y, mg_z;
        a = GetOGLDistance((int) view->fmg.constantR);
@@ -587,11 +591,11 @@ void drawBorders(ViewInfo * view)
                  view->borderColor.G, view->borderColor.A);
        glLineWidth(2);
        glBegin(GL_LINE_STRIP);
-       glVertex2d(view->bdxLeft, view->bdyBottom);
-       glVertex2d(view->bdxRight, view->bdyBottom);
-       glVertex2d(view->bdxRight, view->bdyTop);
-       glVertex2d(view->bdxLeft, view->bdyTop);
-       glVertex2d(view->bdxLeft, view->bdyBottom);
+       glVertex3d(view->bdxLeft, view->bdyBottom,0);
+       glVertex3d(view->bdxRight, view->bdyBottom,0);
+       glVertex3d(view->bdxRight, view->bdyTop,0);
+       glVertex3d(view->bdxLeft, view->bdyTop,0);
+       glVertex3d(view->bdxLeft, view->bdyBottom,0);
        glEnd();
        glLineWidth(1);
     }
index c4a716205324580c35a6c32bf5ece23c94558cfa..7add58af7cea27224bda69f754d90fd3923d0c8c 100644 (file)
@@ -65,13 +65,12 @@ void draw_cube()
 
 void drawRotatingAxis(void)
 {
-#ifdef UNUSED
-    float x, y;
-    float x1, y1, z1;
-    float x2, y2, z2;
-    float R1, R2;
-#endif
     static GLUquadricObj *quadratic = (GLUquadricObj *) 0;
+       float AL = 45;
+
+    if (get_mode(view) != MM_ROTATE)
+           return;
+
     if (!quadratic) {
        quadratic = gluNewQuadric();    // Create A Pointer To The Quadric Object
        gluQuadricNormals(quadratic, GLU_SMOOTH);       // Create Smooth Normals
@@ -81,9 +80,6 @@ void drawRotatingAxis(void)
 
     }
 
-    if ((view->mouse.mouse_mode == MM_ROTATE)
-       && (view->active_camera >= 0)) {
-       float AL = 45;
        glPushMatrix();
        glLoadIdentity();
        glMultMatrixf(view->arcball->Transform.M);      /*arcball transformations , experimental */
@@ -106,7 +102,6 @@ void drawRotatingAxis(void)
        glLineWidth(1);
        glPopMatrix();
 
-    }
 
 }
 
@@ -173,7 +168,6 @@ int glexpose_main(ViewInfo * view)
     draw_fisheye_magnifier(view);
     draw_magnifier(view);
     glexpose_drawgraph(view);
-    draw_selection_box(view);
     drawBorders(view);
 //      drawRotatingTools();
 //      draw_cube();
index badb9a44405048ac5540a4290d322ea5c56d3a1d..6436cf8881bdaf66da3415cd3256445fffad40b5 100644 (file)
@@ -30,44 +30,31 @@ void glmotion_main(ViewInfo * v, GdkEventMotion * event,
                   GtkWidget * widget)
 {
 
+    int a=get_mode(v);
     redraw = FALSE;
-    view->FontSizeConst = GetOGLDistance(14);
     /*panning */
-    if ((event->state & GDK_BUTTON1_MASK)
-       && (v->mouse.mouse_mode == MM_PAN))
+    if (a == MM_PAN)
        glmotion_pan(v);
-
     /*rotating, only in 3d v */
-    if ((v->active_camera >= 0) && (v->mouse.mouse_mode == MM_ROTATE))
+    if (a == MM_ROTATE)
        glmotion_rotate(v);
 
     /*zooming */
-    if ((event->state & GDK_BUTTON1_MASK)
-       && (v->mouse.mouse_mode == MM_ZOOM))
+    if (a == 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))) {
+    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 ((event->state & GDK_BUTTON1_MASK)
-       && (v->mouse.mouse_mode == MM_MOVE)) {
+    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 ((event->state & GDK_BUTTON1_MASK)
-       && ((v->mouse.mouse_mode == MM_MAGNIFIER)
-           || (v->mouse.mouse_mode == MM_FISHEYE_MAGNIFIER))) {
-       v->mouse.pos.x = (float) event->x;
-       v->mouse.pos.y = (float) event->y;
-       redraw = TRUE;
-    }
-
     if (redraw)
        gdk_window_invalidate_rect(widget->window, &widget->allocation,
                                   FALSE);
index 1417781ff66852742a921cd02d032e373a37473b..79bd5117d598e899ef6ec9d315766be8c950f19f 100755 (executable)
@@ -307,6 +307,19 @@ static gboolean button_release_event(GtkWidget * widget,
     dy = 0.0;
     return FALSE;
 }
+static gboolean key_press_event(GtkWidget * widget, GdkEventKey * event, gpointer data)
+{
+    view->keymap.down=1;
+    view->keymap.keyVal=event->keyval;
+//    printf ("key is pressed:%d\n",event->keyval);
+
+}
+static gboolean key_release_event(GtkWidget * widget, GdkEventKey * event, gpointer data)
+{
+ //   printf ("key is released:%d\n",event->keyval);
+    view->keymap.down=0;
+}
+
 
 static gboolean
 scroll_event(GtkWidget * widget, GdkEventScroll * event, gpointer data)
@@ -345,12 +358,9 @@ static gboolean motion_notify_event(GtkWidget * widget,
 
     dx = x - begin_x;
     dy = y - begin_y;
-
     view->mouse.dragX = dx;
     view->mouse.dragY = dy;
-
-
-    if((view->mouse.t==glMouseLeftButton) && (view->mouse.down))
+    if((view->mouse.t==glMouseLeftButton) && (view->mouse.down)  )
     {
        appmouse_left_drag(view,(int)event->x,(int)event->y);
        redraw = TRUE;
@@ -394,45 +404,6 @@ static gboolean key_press_event(GtkWidget * widget, GdkEventKey * event,
 }
 #endif
 
-/*
-       call back for mouse mode changes,
-       params:GtkMenuItem is not used, mouse_mode is the new mouse_mode
-       return value:none
-*/
-void switch_Mouse(GtkMenuItem * menuitem, int mouse_mode)
-{
-    switch (mouse_mode) {
-
-    case -1:
-       change_cursor(GDK_TOP_LEFT_ARROW);
-       break;
-    case 0:
-       change_cursor(GDK_HAND2);
-       break;
-    case 1:
-       change_cursor(GDK_SIZING);
-       break;
-    case 3:
-       change_cursor(GDK_CROSS);
-       break;
-    case 4:
-       change_cursor(GDK_TCROSS);
-       break;
-    case 5:
-       change_cursor(GDK_CROSSHAIR);
-       break;
-    case 10:
-       change_cursor(GDK_FLEUR);
-       break;
-    case MM_ROTATE:
-       change_cursor(GDK_EXCHANGE);
-       break;
-    default:
-       break;
-    };
-    view->mouse.mouse_mode = mouse_mode;
-}
-
 
 /*
        call back for mouse right click, this function activates the gtk right click pop up menu
@@ -516,7 +487,7 @@ void create_window(GdkGLConfig * glconfig, GtkWidget * vbox)
                          GDK_POINTER_MOTION_MASK |
                          GDK_BUTTON_PRESS_MASK | GDK_KEY_PRESS |
                          GDK_BUTTON_RELEASE_MASK |
-                         GDK_SCROLL | GDK_VISIBILITY_NOTIFY_MASK);
+                         GDK_SCROLL | GDK_VISIBILITY_NOTIFY_MASK |  GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK  );
 
     g_signal_connect_after(G_OBJECT(view->drawing_area), "realize",
                           G_CALLBACK(realize), NULL);
@@ -530,12 +501,9 @@ void create_window(GdkGLConfig * glconfig, GtkWidget * vbox)
 /*    g_signal_connect(G_OBJECT(view->drawing_area), "2button_press_event",
                     G_CALLBACK(button_press_event), NULL);*/
 
-    g_signal_connect(G_OBJECT(view->drawing_area), "button_release_event",
-                    G_CALLBACK(button_release_event), NULL);
-    g_signal_connect(G_OBJECT(view->drawing_area), "key_release_event",
-                    G_CALLBACK(button_release_event), NULL);
-    g_signal_connect(G_OBJECT(view->drawing_area), "key_press_event",
-                    G_CALLBACK(button_release_event), NULL);
+    g_signal_connect(G_OBJECT(view->drawing_area), "button_release_event",G_CALLBACK(button_release_event), NULL);
+    g_signal_connect(G_OBJECT(view->drawing_area), "key_release_event", G_CALLBACK(key_release_event), NULL);
+    g_signal_connect(G_OBJECT(view->drawing_area), "key_press_event", G_CALLBACK(key_press_event), NULL);
     g_signal_connect(G_OBJECT(view->drawing_area), "scroll_event",
                     G_CALLBACK(scroll_event), NULL);
 
@@ -543,12 +511,27 @@ void create_window(GdkGLConfig * glconfig, GtkWidget * vbox)
                     G_CALLBACK(motion_notify_event), NULL);
 
 
+//gtk_accel_group_connect (GTK_ACCEL_GROUP (mainw->accel_group), GDK_Page_Up, GDK_CONTROL_MASK, 0, g_cclosure_new (G_CALLBACK (prevclip_callback),NULL,NULL));
 
 
     gtk_box_pack_start(GTK_BOX(vbox), view->drawing_area, TRUE, TRUE, 0);
 
     gtk_widget_show(view->drawing_area);
 
+
+
+    gtk_widget_add_events(glade_xml_get_widget(xml, "frmMain"),
+                         GDK_BUTTON_MOTION_MASK |
+                         GDK_POINTER_MOTION_MASK |
+                         GDK_BUTTON_PRESS_MASK | GDK_KEY_PRESS |
+                         GDK_BUTTON_RELEASE_MASK |
+                         GDK_SCROLL | GDK_VISIBILITY_NOTIFY_MASK |  GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK  );
+
+
+    g_signal_connect(G_OBJECT(glade_xml_get_widget(xml, "frmMain")), "key_release_event", G_CALLBACK(key_release_event), NULL);
+    g_signal_connect(G_OBJECT(glade_xml_get_widget(xml, "frmMain")), "key_press_event", G_CALLBACK(key_press_event), NULL);
+
+
     /* Popup menu. */
 
 #ifdef UNUSED
index b654b6460cb426239a18e0725c4d0bbb9627671c..cd28f460fac6e2f19ee6d7ee9c50cc37d1749786 100644 (file)
@@ -33,12 +33,6 @@ static int singleclick(ViewInfo* v)
 }
 static void appmouse_left_click(ViewInfo* v,int x,int y)
 {
-       if (v->mouse.mouse_mode == MM_SINGLE_SELECT)    //single select
-       {
-           v->Selection.Active = 1;
-           v->Selection.Type = 0;
-           v->Selection.AlreadySelected = 0;
-       }
 
 }
 static void appmouse_right_click(ViewInfo* v,int x,int y)
@@ -50,6 +44,8 @@ static void appmouse_right_click(ViewInfo* v,int x,int y)
 
 static void appmouse_down(ViewInfo* v,int x,int y)
 {
+        view->mouse.dragX = 0;
+       view->mouse.dragY = 0;
     v->mouse.down=1;
     v->mouse.initPos.x=x;
     v->mouse.initPos.y=y;
@@ -70,6 +66,9 @@ static void appmouse_up(ViewInfo* v,int x,int y)
        v->mouse.down=0;
        v->mouse.finalPos.x=x;
        v->mouse.finalPos.y=y;
+        view->mouse.dragX = 0;
+       view->mouse.dragY = 0;
+
        GetFixedOGLPos((float) x,y,v->GLDepth, &v->mouse.GLfinalPos.x,&v->mouse.GLfinalPos.y,&v->mouse.GLfinalPos.z);
        if(singleclick(v))
        {
@@ -90,7 +89,6 @@ static void appmouse_drag(ViewInfo* v,int x,int y)
     y2=v->mouse.GLpos.y;
 //    v->mouse.dragX=x2-prevX;
 //    v->mouse.dragY=y2-prevY;
-    //printf ("(%f,%f)->(%f,%f) : %f  %f \n",prevX,prevY,v->mouse.GLpos.x,v->mouse.GLpos.y,v->mouse.dragX,v->mouse.dragY);
 
     prevX=x2;
     prevY=y2;
@@ -105,38 +103,65 @@ void appmouse_left_click_down(ViewInfo* v,int x,int y)
 
 
 }
-void appmouse_left_click_up(ViewInfo* v,int x,int y)
+int get_mode(ViewInfo* v)
 {
-       appmouse_up(v,x,y);
-       if (v->mouse.mouse_mode == MM_MOVE)
-           move_TVnodes();
+/*#define MM_PAN                                       0
+#define MM_ZOOM                                        1
+#define MM_ROTATE                              2
+#define MM_SINGLE_SELECT               3
+#define MM_RECTANGULAR_SELECT  4
+#define MM_RECTANGULAR_X_SELECT        5
+#define MM_MOVE                                        10
+#define MM_MAGNIFIER                   20
+#define MM_FISHEYE_MAGNIFIER   21*/
 
-       if ((v->mouse.mouse_mode == MM_FISHEYE_MAGNIFIER) || (v->mouse.mouse_mode == MM_MAGNIFIER))     //fisheye mag mouse release, stop distortion
-       {
+
+    if ((view->mouse.t==glMouseLeftButton)&&(view->keymap.down) && (view->keymap.keyVal == B_LSHIFT/*left shift*/) && (view->active_camera==-1))
+       return MM_FISHEYE_MAGNIFIER;
+    if ((view->mouse.t==glMouseLeftButton)&&(view->keymap.down) && (view->keymap.keyVal == B_LSHIFT/*left shift*/) && (view->active_camera>-1))
+       return MM_ROTATE;
+    if ((view->mouse.t==glMouseLeftButton)&&(view->keymap.down) && (view->keymap.keyVal == B_LCTRL/*left CTRL*/)) 
+       return MM_MOVE;
+    if ((view->mouse.t==glMouseLeftButton)&&(view->mouse.down) ) 
+       return MM_PAN;
+
+
+
+
+}
+void appmouse_left_click_up(ViewInfo* v,int x,int y)
+{
+       int a=get_mode(v);
+    appmouse_up(v,x,y);
+/*     if (v->mouse.mouse_mode == MM_MOVE)
+           move_TVnodes();*/
+       if ((a== MM_FISHEYE_MAGNIFIER) || (a == MM_MAGNIFIER))  //fisheye mag mouse release, stop distortion
            originate_distorded_coordinates(v->Topview);
-       }
 
 
 }
 void appmouse_left_drag(ViewInfo* v,int x,int y)
 {
+    int a=get_mode(v);
     appmouse_drag(v,x,y);
-    switch (view->mouse.mouse_mode)
+
+    if (a==MM_ROTATE)
+
     {
-       case MM_PAN:
-               glmotion_pan(v);
-               break;
-       case  MM_ROTATE:
-               view->arcball->MousePt.s.X = (GLfloat) x;
-               view->arcball->MousePt.s.Y = (GLfloat) y;
-               if (!view->arcball->isDragging) {
-                   arcmouseClick(view);
-                   view->arcball->isDragging = 1;
-
-               } else 
+       view->arcball->MousePt.s.X = (GLfloat) x;
+       view->arcball->MousePt.s.Y = (GLfloat) y;
+       if (!view->arcball->isDragging) {
+           arcmouseClick(view);
+        view->arcball->isDragging = 1;
+       } else 
                    arcmouseDrag(view);
-               break;
+       return;
     }
+    if (a==MM_PAN)
+       glmotion_pan(v);
+    if (a==MM_MOVE)
+        move_TVnodes();
+
 
 }
 void appmouse_right_click_down(ViewInfo* v,int x,int y)
@@ -168,28 +193,7 @@ void appmouse_right_click_up(ViewInfo* v,int x,int y)
 
     }
     else    /*update selection values*/
-    {
-       if (v->mouse.GLinitPos.x <= v->mouse.GLfinalPos.x)
-           v->Selection.X = v->mouse.GLinitPos.x;
-       else
-           v->Selection.X = v->mouse.GLfinalPos.x;
-       if (v->mouse.GLinitPos.y <= v->mouse.GLfinalPos.y)
-           v->Selection.Y = v->mouse.GLinitPos.y;
-       else
-           v->Selection.Y = v->mouse.GLfinalPos.y;
-       v->Selection.W = ABS(v->mouse.GLfinalPos.x - v->mouse.GLinitPos.x);
-       v->Selection.H = ABS(v->mouse.GLfinalPos.y - v->mouse.GLinitPos.y);
-       if (v->Selection.H < 0)
-           v->Selection.H = v->Selection.H * -1;
-       if (v->mouse.mouse_mode == 4)
-               v->Selection.Type = 1;
-       else
-           v->Selection.Type = 2;
-       v->Selection.Active = 1;
-    }
-
-
-
+       rectangle_select(v);
 }
 void appmouse_right_drag(ViewInfo* v,int x,int y)
 {
@@ -197,3 +201,6 @@ void appmouse_right_drag(ViewInfo* v,int x,int y)
     appmouse_drag(v,x,y);
 
 }
+
+
+
index 75cd1da4bae7f1212d6035c6f1613dc2093e2e91..acfda104f53eabc924d4ada49551d617b36f0425 100644 (file)
@@ -24,5 +24,6 @@ extern void appmouse_left_drag(ViewInfo* v,int x,int y);
 extern void appmouse_right_click_down(ViewInfo* v,int x,int y);
 extern void appmouse_right_click_up(ViewInfo* v,int x,int y);
 extern void appmouse_right_drag(ViewInfo* v,int x,int y);
+extern int get_mode(ViewInfo* v);
 
 #endif
index 6f9b4641fde4c775f0fa33cc51f2830718a5a799..6f48591468f0dff59805aec29ab56f0b19825c37 100644 (file)
@@ -31,6 +31,7 @@
 /* static glCompPanel *controlPanel; */
 /* static glCompButton *rotatebutton; */
 static glCompPanel *sel = NULL;
+static  glCompLabel *selLabel=NULL;
 static glCompButton *to3DBtn;
 static glCompButton *to2DBtn;
 static glCompButton *rotateBtn;
@@ -44,7 +45,6 @@ static glCompButton *panBtn;
 static void menu_click_pan(void *obj, GLfloat x, GLfloat y,
                           glMouseButtonType t)
 {
-    switch_Mouse(NULL, MM_PAN);
 
 }
 
@@ -56,11 +56,6 @@ static void menu_click_zoom(void *obj, GLfloat x, GLfloat y,
 }
 #endif
 
-static void menu_click_fisheye_magnifier(void *obj, GLfloat x, GLfloat y,
-                                        glMouseButtonType t)
-{
-    view->mouse.mouse_mode = MM_FISHEYE_MAGNIFIER;
-}
 
 static void menu_click_zoom_minus(void *obj, GLfloat x, GLfloat y,
                                  glMouseButtonType t)
@@ -99,12 +94,6 @@ static void menu_switch_to_fisheye(void *obj, GLfloat x, GLfloat y,
     }
 }
 
-static void menu_click_rotate(void *obj, GLfloat x, GLfloat y,
-                             glMouseButtonType t)
-{
-    switch_Mouse(NULL, MM_ROTATE);
-    view->mouse.mouse_mode = MM_ROTATE;
-}
 
 
 static void menu_click_center(void *obj, GLfloat x, GLfloat y,
@@ -134,14 +123,12 @@ static void switch2D3D(void *obj, GLfloat x, GLfloat y,
            }
            glCompButtonShow(to2DBtn);
            glCompButtonHide(to3DBtn);
-           glCompButtonShow(rotateBtn);
            img3D->common.visible = 1;
        } else {                /*switch to 2d */
 
            view->active_camera = -1;   /*set to camera */
            glCompButtonShow(to3DBtn);
            glCompButtonHide(to2DBtn);
-           glCompButtonHide(rotateBtn);
            panBtn->common.callbacks.click(panBtn, (GLfloat) 0,
                                           (GLfloat) 0,
                                           (glMouseButtonType) 0);
@@ -224,19 +211,9 @@ glCompSet *glcreate_gl_topview_menu(void)
     b->groupid = 1;
     y = y + off;
 
-    b = glCompButtonNew((glCompObj *) p, 1, y, 42, 42, "");
-    glCompButtonAddPngGlyph(b, smyrnaPath("magnifier.png"));
-    b->common.callbacks.click = menu_click_fisheye_magnifier;
-    b->groupid = 1;
 
     y = y + off;
 
-    b = glCompButtonNew((glCompObj *) p, 1, y, 42, 42, "");
-    glCompButtonAddPngGlyph(b, smyrnaPath("rotate.png"));
-    b->groupid = 1;
-    b->common.callbacks.click = menu_click_rotate;
-    glCompButtonHide(b);
-    rotateBtn = b;
 
 
     p = glCompPanelNew((glCompObj *) p, 1, 25, 80, 255);
@@ -323,7 +300,6 @@ glCompSet *glcreate_gl_topview_menu(void)
     p->common.color.A = 0.2;
     p->common.visible = 0;
     sel = p;
-
     s->common.callbacks.mouseover = glCompMouseMove;
     s->common.callbacks.mouseup = CBglCompMouseUp;
 
index 4538ccc6921d152c72353b6ea0350fe4051147d9..1ee4cab7e93bdd1214513d3926b7e1f85dd9f0e4 100755 (executable)
@@ -169,17 +169,6 @@ void mShowHostSelectionSlot(GtkWidget * widget, gpointer user_data)
 
 }
 
-void mMenuPan(GtkWidget * widget, gpointer user_data)
-{
-    view->mouse.mouse_mode = MM_PAN;
-
-}
-
-void mMenuZoom(GtkWidget * widget, gpointer user_data)
-{
-    view->mouse.mouse_mode = MM_ZOOM;
-
-}
 
 void mShowConsoleSlot(GtkWidget * widget, gpointer user_data)
 {
@@ -384,20 +373,6 @@ void mUnselectAllClustersSlot(GtkWidget * widget, gpointer user_data)
 //    deselect_all_graphs(view->g[view->activeGraph]);
 }
 
-void mSingleSelectSlot(GtkWidget * widget, gpointer user_data)
-{
-    view->mouse.mouse_mode = MM_SINGLE_SELECT;
-}
-
-void mSelectAreaSlot(GtkWidget * widget, gpointer user_data)
-{
-    view->mouse.mouse_mode = MM_RECTANGULAR_SELECT;
-}
-
-void mSelectAreaXSlot(GtkWidget * widget, gpointer user_data)
-{
-    view->mouse.mouse_mode = MM_RECTANGULAR_X_SELECT;
-}
 
 //help
 void mAbout(GtkWidget * widget, gpointer user_data)
index d36ef5ba291fd5827996aaf9e9e33fe762a3cf9a..deeded5a759b0c84e366b03f051f970a2f166530 100755 (executable)
@@ -27,35 +27,29 @@ void btnToolSingleSelect_clicked(GtkWidget * widget, gpointer user_data)
 {
     deselect_all(view->g[view->activeGraph]);
     //gtk_toggle_tool_button_set_active   ((GtkToggleToolButton*)widget,1);
-    switch_Mouse(NULL, 3);
 }
 
 void btnToolRectSelect_clicked(GtkWidget * widget, gpointer user_data)
 {
 
     deselect_all(view->g[view->activeGraph]);
-    view->Selection.Anti = 0;
-    switch_Mouse(NULL, 4);
 }
 
 void btnToolRectXSelect_clicked(GtkWidget * widget, gpointer user_data)
 {
     deselect_all(view->g[view->activeGraph]);
     view->Selection.Anti = 0;
-    switch_Mouse(NULL, 5);
 }
 
 void btnToolAntiRectSelect_clicked(GtkWidget * widget, gpointer user_data)
 {
     view->Selection.Anti = 1;
-    switch_Mouse(NULL, 4);
 
 }
 
 void btnToolAntiRectXSelect_clicked(GtkWidget * widget, gpointer user_data)
 {
     view->Selection.Anti = 1;
-    switch_Mouse(NULL, 5);
 
 }
 
@@ -64,13 +58,11 @@ void btnToolPan_clicked(GtkWidget * widget, gpointer user_data)
 {
 
 
-    switch_Mouse(NULL, 0);
 
 }
 
 void btnToolZoom_clicked(GtkWidget * widget, gpointer user_data)
 {
-    switch_Mouse(NULL, 1);
 }
 
 void btnToolZoomIn_clicked(GtkWidget * widget, gpointer user_data)
@@ -157,7 +149,6 @@ void btnToolFit_clicked(GtkWidget * widget, gpointer user_data)
 
 void btnToolMove_clicked(GtkWidget * widget, gpointer user_data)
 {
-    switch_Mouse(NULL, 10);
 }
 
 void btnToolAddNode_clicked(GtkWidget * widget, gpointer user_data)
@@ -180,7 +171,6 @@ void btnToolFindEdge_clicked(GtkWidget * widget, gpointer user_data)
 }
 void btnToolCursor_clicked(GtkWidget * widget, gpointer user_data)
 {
-    switch_Mouse(NULL, -1);
 }
 void write_to_console(char *text)
 {
index fbf61f99d049c43d17378e42b61e12042611dd05..288acab10bc1722b283dd93380f0503b07e40bc1 100755 (executable)
@@ -523,11 +523,6 @@ int lineintersects(float X1, float X2, float Y1, float Y2)
     float x, y, m, iter;
     float RX, RY, RW, RH;
     int intersects, in;
-    if (view->mouse.mouse_mode == MM_SINGLE_SELECT) {
-       RW = 10;
-       RH = 10;
-    }
-
     RX = view->Selection.X;
     RY = view->Selection.Y;
     if ((is_point_in_rectangle(X1, Y1, RX, RY, RW, RH))
@@ -579,6 +574,128 @@ int is_point_in_rectangle(float X, float Y, float RX, float RY, float RW,
 }
 
 
+
+static int select_topview_node(topview_node * n)
+{
+    static float x1,y1,x2,y2,x,y;
+    static int sel_type=0;  /*0:select all , 1:only nodes 2:only edges*/
+    x=n->distorted_x;
+    y=n->distorted_y;
+    if(view->mouse.GLfinalPos.x > view->mouse.GLinitPos.x)
+    {
+        x1=view->mouse.GLinitPos.x;
+       x2=view->mouse.GLfinalPos.x;
+    }
+    else
+    {
+        x2=view->mouse.GLinitPos.x;
+       x1=view->mouse.GLfinalPos.x;
+
+    }
+    if(view->mouse.GLfinalPos.y > view->mouse.GLinitPos.y)
+    {
+        y1=view->mouse.GLinitPos.y;
+       y2=view->mouse.GLfinalPos.y;
+    }
+    else
+    {
+        y2=view->mouse.GLinitPos.y;
+       y1=view->mouse.GLfinalPos.y;
+    }
+    if(is_point_in_rectangle(x,y,x1,y1,x2-x1,y2-y1))
+    {
+        agset(n->Node,"selected","1");
+       n->data.Selected=1;
+    }
+}
+
+static int select_topview_edge(topview_edge* e)
+{
+    static float x1,y1,x2,y2,n1x,n1y,n2x,n2y;
+    static int sel_type=0;  /*0:select all , 1:only nodes 2:only edges*/
+    n1x=e->Node1->distorted_x;
+    n1y=e->Node1->distorted_y;
+    n2x=e->Node2->distorted_x;
+    n2y=e->Node2->distorted_y;
+    if(view->mouse.GLfinalPos.x > view->mouse.GLinitPos.x)
+    {
+        x1=view->mouse.GLinitPos.x;
+       x2=view->mouse.GLfinalPos.x;
+    }
+    else
+    {
+        x2=view->mouse.GLinitPos.x;
+       x1=view->mouse.GLfinalPos.x;
+
+    }
+    if(view->mouse.GLfinalPos.y > view->mouse.GLinitPos.y)
+    {
+        y1=view->mouse.GLinitPos.y;
+       y2=view->mouse.GLfinalPos.y;
+    }
+    else
+    {
+        y2=view->mouse.GLinitPos.y;
+       y1=view->mouse.GLfinalPos.y;
+    }
+    if((is_point_in_rectangle(n1x,n1y,x1,y1,x2-x1,y2-y1))
+       &&
+       (is_point_in_rectangle(n2x,n2y,x1,y1,x2-x1,y2-y1)) )
+    {
+       agset(e->Edge,"selected","1");
+       e->data.Selected=1;
+    }
+}
+
+static void node_rectangle_select(ViewInfo* v)
+{
+    int ind;
+    topview_node* n;
+   
+    for (ind = 0; ind < v->Topview->Nodecount; ind++) 
+    {
+       n = v->Topview->Nodes + ind;
+       select_topview_node(n);
+    }
+
+}
+static void edge_rectangle_select(ViewInfo* v)
+{
+    int ind;
+    topview_edge* e;
+   
+    for (ind = 0; ind < v->Topview->Edgecount; ind++) 
+    {
+       e = v->Topview->Edges + ind;
+       select_topview_edge(e);
+    }
+
+}
+void rectangle_select(ViewInfo* v)
+{
+    node_rectangle_select(v);
+    edge_rectangle_select(v);
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
 #ifdef UNUSED
 static int line_intersects(float *x, float *y, float *X, float *Y)
 {
index 28f90c2423aeb8cccb97fbce96abb336261da08f..ebc399397ab511e6c7c79eb329aad4e6d00c413d 100644 (file)
@@ -62,6 +62,8 @@ extern "C" {
     float distance_to_line(float ax, float ay, float bx, float by,
                           float cx, float cy);
 
+    extern void rectangle_select(ViewInfo* v);
+
 #ifdef __cplusplus
 }                              /* end extern "C" */
 #endif
index 697d7f89007afe8756de3f3bc60db3b2d28c1654..5f436ac1fabf7165de8f082f3a65ddb03b3396a6 100644 (file)
                                RelativePath=".\glexpose.h"
                                >
                        </File>
-                       <File
-                               RelativePath=".\gui\glmenu.h"
-                               >
-                       </File>
                        <File
                                RelativePath=".\glmotion.h"
                                >
                                RelativePath=".\glexpose.c"
                                >
                        </File>
-                       <File
-                               RelativePath=".\gui\glmenu.c"
-                               >
-                       </File>
                        <File
                                RelativePath=".\glmotion.c"
                                >
index 8b474a8436ff7f90867b7db1902747f05dafddfa..75d8c6844554129cb7706d2d461ade9c0c91c438 100644 (file)
@@ -69,6 +69,13 @@ typedef struct _ArcBall_t ArcBall_t;
 #define MM_MOVE                                        10
 #define MM_MAGNIFIER                   20
 #define MM_FISHEYE_MAGNIFIER   21
+
+#define B_LSHIFT           65505
+#define B_RSHIFT           65506
+#define B_LCTRL                    65507
+#define B_RCTRL                    65508
+
+
 #define GLOBAL_Z_OFFSET                        0.001
 
 #define MAX_ZOOM       500
@@ -101,6 +108,14 @@ typedef struct _ArcBall_t ArcBall_t;
 
 typedef enum {attr_alpha,attr_float,attr_int,attr_bool,attr_drowdown,attr_color} attr_data_type;
 
+
+typedef struct{
+    int keyVal;
+    int down;
+}keymap_t;
+
+
+
 typedef struct {
        int index;
        char* name;
@@ -636,6 +651,7 @@ typedef struct
        int script_count;       /*# of scripts */
        GtkComboBox *graphComboBox;     /*pointer to graph combo box at top right */
        ArcBall_t *arcball;
+       keymap_t keymap;
 
     } ViewInfo;
 /*rotation steps*/
index b3236b2548635169ea8e44f29a0f2db681a9480c..a4155cea6b1ffe6e7ad770db3d8e32ffa07d41e9 100755 (executable)
@@ -642,7 +642,6 @@ static int drawtopviewnodes(Agraph_t * g)
                continue;
 
            /*check for each node if it needs to be selected or picked */
-           select_topview_node(v);
            //UPDATE view->Topview data from cgraph
            /* if (v->update_required) */
            /* update_topview_node_from_cgraph(v); */
@@ -864,77 +863,6 @@ void drawTopViewGraph(Agraph_t * g)
 
 
 
-static int select_topview_node(topview_node * n)
-{
-    if (!view->Selection.Active) {
-       //implement hint box here
-/*             if (view->mouse.button== rightmousebutton)
-               {
-                       if (pick_node(n))
-                               view->mouse.button = -1;
-               }
-               return 0;*/
-    }
-    if (((view->Selection.Type == 0) && (view->Selection.Active))
-       || (view->mouse.t == rightmousebutton)) //single selection or right click (picking)
-    {
-       float dist =
-           (float) DIST2(view->Selection.X - n->distorted_x,
-                         view->Selection.Y - n->distorted_y);
-
-       if ((view->Selection.node_distance == -1)
-           || (dist < view->Selection.node_distance)) {
-           view->Selection.node_distance = dist;
-           view->Selection.single_selected_node = n;
-       }
-
-       return 0;
-
-/*             if (OD_Selected(n->Node) == 0)
-               {
-                       OD_Selected(n->Node) = 1;
-                       select_object(view->g[view->activeGraph], n->Node);
-           } else {
-                       OD_Selected(n->Node) = 1;
-                       deselect_object(view->g[view->activeGraph], n->Node);
-           }
-           break;*/
-
-    }
-    if (view->Selection.Active == 0)
-       return 0;
-    if (is_point_in_rectangle
-       (n->x, n->y, view->Selection.X, view->Selection.Y,
-        view->Selection.W, view->Selection.H)) {
-
-       switch (view->Selection.Type) {
-
-/*
-       int Active;                     //0 there is no selection need to be applied
-    char Type;                 //0     single selection , 1 rectangle , 2 rectangleX 
-    float X, Y, W, H;          //selection boundries
-    int Anti;                  //subtract selections if 1
-    int AlreadySelected;       //for single selections to avoid selecting more than one object
-    glCompColor SelectionColor;
-*/
-
-
-       case 1:
-       case 2:
-           if (view->Selection.Anti == 0) {
-               select_node(n);
-               view->Selection.AlreadySelected = 1;
-           } else {
-
-               deselect_node(n);
-               view->Selection.AlreadySelected = 1;
-           }
-           break;
-
-       }
-    }
-    return 1;
-}
 
 
 #ifdef UNUSED
@@ -1059,7 +987,8 @@ static int draw_topview_edge_label(topview_edge * e, float zdepth)
 static void set_topview_options(void)
 {
 
-    if ((view->mouse.mouse_mode == 10) && (view->mouse.down == 1))     //selected, if there is move move it, experimental
+    int a=get_mode(view);
+    if ((a == 10) && (view->mouse.down == 1))  //selected, if there is move move it, experimental
     {
        dx = view->mouse.GLinitPos.x - view->mouse.GLfinalPos.x;
        dy = view->mouse.GLinitPos.y - view->mouse.GLfinalPos.y;
@@ -1127,15 +1056,6 @@ static int get_color_from_edge(topview_edge * e)
                  view->selectedEdgeColor.B, view->selectedEdgeColor.A);
        return return_value;
     }
-    /*if both head and tail nodes are highlighted use edge highlight color */
-    if ((e->Node1->data.Highlighted)
-       && (e->Node2->data.Highlighted)) {
-       glColor4f(view->highlightedEdgeColor.R,
-                 view->highlightedEdgeColor.G,
-                 view->highlightedEdgeColor.B,
-                 view->highlightedEdgeColor.A);
-       return return_value;
-    }
     /*edge maybe in a group and group may be selected, then use groups's color example:ATT hosts */
     if ((e->Node1->GroupIndex >= 0) || (e->Node2->GroupIndex >= 0)) {
        if (view->Topview->TopviewData->hostactive[e->Node1->GroupIndex] ==
@@ -1181,13 +1101,24 @@ static int node_visible(topview_node * n)
 
 int move_TVnodes(void)
 {
+    float delX,delY;
     topview_node *v;
+    static flag=0;
     int ind = 0;
+    if (!flag)
+    {
+//     printf ("dragx:%f dragy:%f\n",view->mouse.dragX,view->mouse.dragY);
+       flag=1;
+       return;
+    }
+
+    delX = GetOGLDistance((int) view->mouse.dragX);
+    delY = GetOGLDistance((int) view->mouse.dragY);
     for (ind = 0; ind < view->Topview->Nodecount; ind++) {
        v = &view->Topview->Nodes[ind];
        if (v->data.Selected) {
-           v->distorted_x = v->distorted_x - dx;
-           v->distorted_y = v->distorted_y - dy;
+           v->distorted_x = v->distorted_x + delX;
+           v->distorted_y = v->distorted_y - delY;
        }
     }
     return 1;
index 13a66c70b9ed432d70f1ebf1af58bf95749ba1b7..20b9d3fbd1cfa3f394a29ee3b9573a08479d542d 100755 (executable)
@@ -386,7 +386,6 @@ void init_viewport(ViewInfo * view)
     view->gridVisible = 0;     //show grids in light gray
 
     //mouse mode=pan
-    view->mouse.mouse_mode = 0;
     //pen color
     view->penColor.R = 0;
     view->penColor.G = 0;
@@ -481,6 +480,7 @@ void init_viewport(ViewInfo * view)
     view->colschms = NULL;
     view->flush = 1;
     view->arcball = NEW(ArcBall_t);
+    view->keymap.down=0;
     /*add default camera */
     //create fontset
 }
index aea44b84d8b5f3bbd637e3143d49985c4fc27d8e..86f6145b007fcb4312930e7adad1f33258026b96 100644 (file)
@@ -364,7 +364,6 @@ extern "C" {
        glCompCallBacks callbacks;
        glCompCallBacks functions;
        int down;
-       int mouse_mode; /*some data value to store custom defined mouse modes*/
 
 
     } glCompMouse;