]> granicus.if.org Git - graphviz/commitdiff
nodes and edges can be selected seperately
authorarif <devnull@localhost>
Wed, 3 Mar 2010 23:35:19 +0000 (23:35 +0000)
committerarif <devnull@localhost>
Wed, 3 Mar 2010 23:35:19 +0000 (23:35 +0000)
cmd/smyrna/glexpose.c
cmd/smyrna/gltemplate.c
cmd/smyrna/gui/appmouse.c
cmd/smyrna/gui/glcompui.c
cmd/smyrna/selectionfuncs.c
cmd/smyrna/smyrnadefs.h
cmd/smyrna/topviewfuncs.c
lib/glcomp/glcompbutton.c
lib/glcomp/glcompdefs.h
lib/glcomp/glcompfont.c

index e35fa208207d4ef21d7c126430cec0e972b1d53d..b715db208b12c72f98a7882814444efcde8cf8ab 100644 (file)
@@ -181,7 +181,7 @@ int glexpose_main(ViewInfo * view)
 //      drawRotatingTools();
 //      draw_cube();
     drawRotatingAxis();
-    draw_selpoly(&view->Topview->selPoly);
+    draw_selpoly(&view->Topview->sel.selPoly);
 //              draw_stuff();
 //      test_color_pallete();
 //      drawtestpoly();
index 33ecc7943bdd54bc5371aca9f57a35657e903c05..c3e9d4c01d1210545042f63584d62a5d2879b53d 100755 (executable)
@@ -397,7 +397,7 @@ static gboolean motion_notify_event(GtkWidget * widget,
        appmouse_middle_drag(view,(int)event->x,(int)event->y);
        redraw = TRUE;
     }
-    if(view->Topview->selPoly.cnt > 0)
+    if(view->Topview->sel.selPoly.cnt > 0)
        redraw=TRUE;
 
 
index 6d12a14b1a8ed3addd07cf29ca2289b231d147be..4e686449c2dc2fdb19a6dc5b89d1861be9cca818 100644 (file)
@@ -65,7 +65,7 @@ static void apply_actions(ViewInfo* v,int x,int y)
 
     if(a==MM_POLYGON_SELECT)
     {
-       add_selpoly(view->g[view->activeGraph],&view->Topview->selPoly,view->mouse.GLfinalPos);
+       add_selpoly(view->g[view->activeGraph],&view->Topview->sel.selPoly,view->mouse.GLfinalPos);
     }
 
 
@@ -231,7 +231,7 @@ void appmouse_key_release(ViewInfo* v,int key)
     int action=get_key_action(v,key);
     if(lastAction==MM_POLYGON_SELECT)
     {
-       clear_selpoly(&view->Topview->selPoly); 
+       clear_selpoly(&view->Topview->sel.selPoly);     
        glexpose();
     }
     v->keymap.down=0;
index 5e795621bd84ddfaf496851fe9e7b76e48afa61f..e6fc26236a411f47bcc7d94f7ba8b4856ecaed8d 100644 (file)
@@ -183,6 +183,22 @@ void glCompMouseMove(glCompObj *obj, GLfloat x, GLfloat y)
        glexpose();
     }
 }
+void selectedges(glCompObj *obj, GLfloat x, GLfloat y)
+{
+    if(view->Topview->sel.selectEdges==0)
+       view->Topview->sel.selectEdges=1;
+    else
+       view->Topview->sel.selectEdges=0;
+
+}
+void selectnodes(glCompObj *obj, GLfloat x, GLfloat y)
+{
+    if(view->Topview->sel.selectNodes==0)
+       view->Topview->sel.selectNodes=1;
+    else
+       view->Topview->sel.selectNodes=0;
+
+}
 
 
 glCompSet *glcreate_gl_topview_menu(void)
@@ -239,6 +255,16 @@ glCompSet *glcreate_gl_topview_menu(void)
     glCompButtonHide(b);
     to2DBtn = b;
 
+    y=y+off;
+    b = glCompButtonNew((glCompObj *) p, 1, y, 42, 42, "N");
+    b->common.callbacks.click = selectnodes;
+    b->groupid=-1;
+    b->status=1;
+
+    y=y+off;
+    b = glCompButtonNew((glCompObj *) p, 1, y, 42, 42, "E");
+    b->common.callbacks.click = selectedges;
+    b->groupid=-1;
 
 
 
@@ -317,7 +343,7 @@ glCompSet *glcreate_gl_topview_menu(void)
 
 
        
-       p = glCompPanelNew((glCompObj *) p, 25, 0, 52, 110);
+    p = glCompPanelNew((glCompObj *) p, 25, 0, 52, 110);
     p->common.align = glAlignTop;
     p->common.data = 0;
     p->common.color.A = 0;
index 75e751083ab84dacdf1dfc430f0f17e92d866030..eab6e4b35adc8b3d7b6cd46ba5219bb5f0f37b46 100644 (file)
@@ -88,17 +88,21 @@ static void pick_objects_in_rect(Agraph_t* g,GLfloat x1,GLfloat y1,GLfloat x2,GL
      
      for (v = agfstnode(g); v; v = agnxtnode(g, v)) 
     {
-       posN=((nodeRec*)(aggetrec(v,"nodeRec",0)))->A;
-       if(is_point_in_rectangle(posN.x,posN.y,x1,y1,x2-x1,y2-y1))
-           select_node(g,v,0);
-       for (e = agfstout(g, v); e; e = agnxtout(g, e)) 
+       if(view->Topview->sel.selectNodes==1)
        {
-           posT=((edgeRec*)(aggetrec(e,"edgeRec",0)))->posTail;
-           posH=((edgeRec*)(aggetrec(e,"edgeRec",0)))->posHead;
-           if(is_point_in_rectangle(posT.x,posT.y,x1,y1,x2-x1,y2-y1))
-               if(is_point_in_rectangle(posH.x,posH.y,x1,y1,x2-x1,y2-y1))
-                   select_edge(g,e,0);
+           posN=((nodeRec*)(aggetrec(v,"nodeRec",0)))->A;
+           if(is_point_in_rectangle(posN.x,posN.y,x1,y1,x2-x1,y2-y1))
+               select_node(g,v,0);
        }
+       if(view->Topview->sel.selectEdges==1)
+               for (e = agfstout(g, v); e; e = agnxtout(g, e)) 
+           {
+               posT=((edgeRec*)(aggetrec(e,"edgeRec",0)))->posTail;
+               posH=((edgeRec*)(aggetrec(e,"edgeRec",0)))->posHead;
+               if(is_point_in_rectangle(posT.x,posT.y,x1,y1,x2-x1,y2-y1))
+                   if(is_point_in_rectangle(posH.x,posH.y,x1,y1,x2-x1,y2-y1))
+                       select_edge(g,e,0);
+           }
     }
 }
 
index 32547d32b4ee05be3e93006b03b51557be745a3a..6f9f058166032a0744fcdf14c0ddbeab43717089 100644 (file)
@@ -295,22 +295,6 @@ typedef struct
        int TVref;              //topview data structure reference
     } temp_node_record;
 
-/*#define OD_ID(p) (((custom_object_data*)AGDATA(p))->ID)
-#define OD_ObjName(p) (((custom_object_data*)AGDATA(p))->ObjName)
-#define OD_ObjType(p) (((custom_object_data*)AGDATA(p))->ObjType)
-#define OD_Layer(p) (((custom_object_data*)AGDATA(p))->Layer)
-#define OD_Visible(p) (p->data.Visible)
-#define OD_Locked(p) (((custom_object_data*)AGDATA(p))->Locked)
-#define OD_Highlighted(p) (((custom_object_data*)AGDATA(p))->Highlighted)
-#define OD_NumDataCount(p) (((custom_object_data*)AGDATA(p))->NumDataCount)
-#define OD_NumData(p) (((custom_object_data*)AGDATA(p))->NumData)
-#define OD_StrDataCount(p) (((custom_object_data*)AGDATA(p))->StrDataCount)
-#define OD_StrData(p) (((custom_object_data*)AGDATA(p))->StrData)
-#define OD_Selected(p) (((custom_object_data*)AGDATA(p))->Selected)
-#define OD_Preselected(p) (((custom_object_data*)AGDATA(p))->Preselected)
-#define OD_SelFlag(p) (((custom_object_data*)AGDATA(p))->selectionflag)
-#define OD_TVRef(p) (((custom_object_data*)AGDATA(p))->TVRef)*/
-
 #define OD_Visible(p) (p.data.Visible)
 #define OD_Locked(p) (p.data.Locked)
 #define OD_Highlighted(p) (p.data.Highlighted)
@@ -417,6 +401,11 @@ typedef struct
        int printLabel;
     }edgeRec;
 
+    typedef struct _selection {
+       glCompPoly selPoly;
+       int selectNodes;
+       int selectEdges;
+    } selection;
 
     typedef struct {
        topview_node *Nodes;
@@ -457,10 +446,8 @@ typedef struct
 
        topviewcache cache;
        int xdotId;
-       glCompPoly selPoly;
-
-
-
+       selection sel;
+       
     } topview;
 
 
@@ -503,20 +490,6 @@ typedef struct
 
     } attribute;
 
-/*    typedef struct _selection {
-       int Active;             //0 there is no selection need to be applied
-       char Type;              //0     single selection , 1 rectangle , 2 rectangleX 
-       int PickingType;        //0 normal, union,2 subtract 3 intersection
-       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;
-       float node_distance;    //to get the closest node , this value is updated for each node, distance between selection coords and node coords, smallest gets to be selected
-       topview_node *single_selected_node;     //pointer to selected node in a single node/edge selection cycle,after each node loop this value is checked and if it is in the limits that node is selected or deselected
-       //before the node/edge loop this value is nulled
-       topview_edge *single_selected_edge;     //pointer to selected/picked edge
-
-    } selection;*/
     typedef struct _magnifier {
        float x, y;
        float kts;              //zoom X
index 3fccd7d530fd9eb2429b119ad9b663453bf34776..1c9bfdcebb1ec4c09633ce2a12acf4dfd0e6ad21 100644 (file)
@@ -646,8 +646,8 @@ void updateSmGraph(Agraph_t * g,topview* t)
     t->picked_edge_count = 0;
     t->picked_edges = '\0';
     t->global_z=0;
-    t->selPoly.cnt=0;
-    t->selPoly.pts=NULL;
+    t->sel.selPoly.cnt=0;
+    t->sel.selPoly.pts=NULL;
 
     if(!t)
        return ;
@@ -684,6 +684,7 @@ topview* initSmGraph(Agraph_t * g)
 {
     topview* rv=(topview*)malloc(sizeof(topview));
     rv->maxnodedegree = 1;
+
         
     /*create glcomp menu system */
     view->widgets = glcreate_gl_topview_menu();
@@ -703,6 +704,9 @@ topview* initSmGraph(Agraph_t * g)
     rv->cache.selnode_id=-1;
     rv->cache.edge_id=-1;
     rv->cache.seledge_id=-1;
+    rv->sel.selectEdges=0;
+    rv->sel.selectNodes=1;
+
     updateSmGraph(g,rv);
     return rv;
 }
index 3a58d6ce947112a1f0edf2ce432aef055ae840e9..f523ea1ea97f8a57a4344318aa0c883616d3c7a4 100644 (file)
@@ -154,16 +154,19 @@ void glCompButtonClick(glCompObj * o, GLfloat x, GLfloat y,
     glCompObj *obj;
     glCompSet *s = o->common.compset;
     int ind = 0;
-    if (p->groupid > 0) {
+    ((glCompButton *) o)->status=((glCompButton *) o)->refStatus ;
+    if (p->groupid > 0) 
+    {
        for (; ind < s->objcnt; ind++) {
            obj = s->obj[ind];
-           if (obj->objType == glButtonObj) {
+           if ((obj->objType == glButtonObj)&&(obj!=o)) {
                if (((glCompButton *) obj)->groupid == p->groupid)
                    ((glCompButton *) obj)->status = 0;
            }
        }
        p->status = 1;
-    } else {
+    }
+    else {
        if (p->groupid == -1) {
            if (p->status == 0)
                p->status = 1;
@@ -189,6 +192,8 @@ void glCompButtonMouseDown(glCompObj * obj, GLfloat x, GLfloat y,
 {
     /*Put your internal code here */
 
+    
+    ((glCompButton *) obj)->refStatus = ((glCompButton *) obj)->status;
     ((glCompButton *) obj)->status = 1;
     if (((glCompButton *) obj)->common.callbacks.mousedown)
        ((glCompButton *) obj)->common.callbacks.mousedown(obj, x, y, t);
@@ -219,6 +224,7 @@ void glCompButtonMouseUp(glCompObj * obj, GLfloat x, GLfloat y,
                         glMouseButtonType t)
 {
     /*Put your internal code here */
+
     if (((glCompButton *) obj)->common.callbacks.mouseup)
        ((glCompButton *) obj)->common.callbacks.mouseup(obj, x, y, t);
 }
index 16c145452da1c6cb5e42068200c64c00f6c97eb1..ce171b4d45011d1dd4e80668a36d7591af1ab7cb 100644 (file)
@@ -307,6 +307,7 @@ extern "C" {
        GLfloat width, height;
        glCompLabel *label;
        int status;             //0 not pressed 1 pressed;
+       int refStatus;          //0 not pressed 1 pressed;
        int groupid;
        glCompImage *image;     /*glyph */
        glCompButtonGlyph glyphPos;
index 46d4fbb3d1f169d00ca06feaaed84380c2d44d07..17433cbdba4bb22ef66b61d91b867b2eec60b2b4 100644 (file)
@@ -399,11 +399,28 @@ void glCompDrawText3D(glCompFont * f,GLfloat x,GLfloat y,GLfloat z,GLfloat w,GLf
 
 }
 /*bitmap base 2D text rendering */
+static void change_fontC(unsigned char* d,int w,int h,glCompColor* c)
+{
+    int size=w*h*4;
+    int ind=0;
+    for (ind;ind <=size; ind=ind+4)
+    {
+       if(d[ind+3] != 0)
+       {
+           d[ind]=c->R*255;
+           d[ind+1]=c->G*255;
+           d[ind+2]=c->B*255;
+           d[ind+3]=c->A*255;
+       }
+    }
+}
+
+
 void glCompDrawText(glCompFont * f,GLfloat x,GLfloat y)
 {
+    change_fontC(f->tex->data,f->tex->width,f->tex->height,&f->color);
     glRasterPos2f(x, y);
-    glDrawPixels(f->tex->width, f->tex->height, GL_RGBA, GL_UNSIGNED_BYTE,
-                f->tex->data);
+    glDrawPixels(f->tex->width, f->tex->height, GL_RGBA, GL_UNSIGNED_BYTE,  f->tex->data);
 }
 
 /*text rendering functions, depends on a globject to retrieve stats*/
@@ -419,7 +436,8 @@ void glCompRenderText(glCompFont * f, glCompObj * parentObj)
     h = f->tex->height;
     ref = parentObj->common;
     z = ref.pos.z;
-    switch (f->justify.HJustify) {
+    switch (f->justify.HJustify) 
+    {
     case glFontHJustifyNone:
     case glFontHJustifyLeft:
        x = ref.refPos.x;