]> granicus.if.org Git - graphviz/commitdiff
Topview.c is cleaned up, drawing function splitted to 4 small function,
authorarif <devnull@localhost>
Tue, 29 Apr 2008 15:54:13 +0000 (15:54 +0000)
committerarif <devnull@localhost>
Tue, 29 Apr 2008 15:54:13 +0000 (15:54 +0000)
drawnodes drawedges drawlabels attributes are added.

cmd/smyrna/gui/topviewsettings.c
cmd/smyrna/smyrnadefs.h
cmd/smyrna/topview.c
cmd/smyrna/topview.h
cmd/smyrna/viewport.c
lib/cgraph/write.c
share/gui/smyrna.glade

index 75ec9afcd4fffe2f4754b500c82a7b2830d1640b..53e0bf346c63c1a123ce6d83793d762856d9aeeb 100644 (file)
@@ -167,7 +167,12 @@ int load_settings_from_graph(Agraph_t * g)
     set_checkbox_widget("gridvisible", "settingsChkBox3");
     set_checkbox_widget("randomizenodecolors", "settingsChkBox4");
     set_checkbox_widget("randomizeedgecolors", "settingsChkBox5");
-    set_checkbox_widget("usermode", "settingsChkBox10");
+
+       set_checkbox_widget("drawnodes", "settingsChkBox5-1");
+       set_checkbox_widget("drawedges", "settingsChkBox5-2");
+       set_checkbox_widget("drawlabels", "settingsChkBox5-3");
+
+       set_checkbox_widget("usermode", "settingsChkBox10");
     set_checkbox_widget("nodesizewithdegree", "settingsChkBox11");
     set_checkbox_widget("antialiasing", "settingsChkBox12");
 
@@ -254,27 +259,6 @@ int update_graph_from_settings(Agraph_t * g)
     get_color_button_widget_to_attribute("selectededgecolor",
                                         "settingsColorBtn9", g);
 
-    /*
-       defaultmagnifierwidth="300",
-       defaultmagnifierheight="200",
-       defaultmagnifierkts="5",
-       defaultfisheyemagnifierradius="250"
-       defaultfisheyemagnifierdistort="5",
-
-       topologicalfisheyefinenodes="50",
-       topologicalfisheyecoarseningfactor="2.5",
-       topologicalfisheyedistortionfactor="1",
-
-       topologicalfisheyedist2limit="1",
-       topologicalfisheyeanimate="1",
-       topologicalfisheyelabelfinenodes="1",
-       topologicalfisheyecolornodes="1",
-       topologicalfisheyecoloredges="1",
-       topologicalfisheyelabelfocus="1",
-
-       topologicalfisheyefinestcolor="red",
-       topologicalfisheyecoarsestcolor="green" */
-
     get_color_button_widget_to_attribute("topologicalfisheyefinestcolor",
                                         "settingsColorBtn10", g);
     get_color_button_widget_to_attribute("topologicalfisheyecoarsestcolor",
@@ -287,7 +271,16 @@ int update_graph_from_settings(Agraph_t * g)
                                     "settingsChkBox4", g);
     get_checkbox_widget_to_attribute("randomizeedgecolors",
                                     "settingsChkBox5", g);
-    get_checkbox_widget_to_attribute("usermode", "settingsChkBox10", g);
+
+    get_checkbox_widget_to_attribute("drawnodes",
+                                    "settingsChkBox5-1", g);
+    get_checkbox_widget_to_attribute("drawedges",
+                                    "settingsChkBox5-2", g);
+    get_checkbox_widget_to_attribute("drawlabels",
+                                    "settingsChkBox5-3", g);
+       
+       
+       get_checkbox_widget_to_attribute("usermode", "settingsChkBox10", g);
     get_checkbox_widget_to_attribute("nodesizewithdegree",
                                     "settingsChkBox11", g);
     get_checkbox_widget_to_attribute("antialiasing", "settingsChkBox12",
index de96ffbcaea20584e7173e7c023fc376ea3b90fc..be42569ef96344bbe5251796aedfd35ce8e4fd23 100644 (file)
@@ -446,6 +446,10 @@ typedef struct _ViewInfo
        int active_frame;
        int total_frames;
        int frame_length;
+       /*lately added*/
+       int drawnodes;
+       int drawedges;
+       int drawlabels;
 
 }ViewInfo;
 
index fed61bf59518e51e3f6bcdc099fb0b493d6624e7..fbfd0592360135a733eec886c112317c82f15dac 100755 (executable)
@@ -199,93 +199,85 @@ void preparetopview(Agraph_t * g, topview * t)
        t->picked_nodes='\0';
 }
 
-void drawTopViewGraph(Agraph_t * g)
+int drawtopviewnodes(Agraph_t * g)
 {
-//      DWORD t1,t2;
     topview_node *v;
-    topview_edge *e;
     float ddx, ddy,ddz;
-    float dddx, dddy,dddz;
     int ind = 0;
-       if (view->zoom > NODE_ZOOM_LIMIT) {
-       glPointSize(3);
-               //draw nodes
-       set_topview_options();
-       
-       
-//     if (view->zoom < NODE_CIRCLE_LIMIT)
-           glBegin(GL_POINTS);
-
-       //drawing labels
-       for (ind = 0; ind < view->Topview->Nodecount; ind++) {
-
-           v = &view->Topview->Nodes[ind];
-           if (!node_visible(v->Node))
-               break;
-
-           draw_topview_label(v, 1);
-
-       }
-       for (ind = 0; ind < view->Topview->Nodecount; ind++)
+       float dotsize=0;
+       if (view->zoom > NODE_ZOOM_LIMIT)
        {
-           if (((-view->Topview->Nodes[ind].x/view->zoom > view->clipX1)
-               && (-view->Topview->Nodes[ind].x/view->zoom < view->clipX2)
-               && (-view->Topview->Nodes[ind].y/view->zoom > view->clipY1)
-               && (-view->Topview->Nodes[ind].y/view->zoom < view->clipY2)) 
-               || (view->active_camera>=0)) {
-                       float zdepth;
-                       v = &view->Topview->Nodes[ind];
-                   if (!node_visible(v->Node))
-                       break;
-
-                   select_topview_node(v);
-                   //UPDATE view->Topview data from cgraph
-                   if (v->update_required)
-                       update_topview_node_from_cgraph(v);
-                   if (OD_Selected(v->Node) == 1) {
-                               glColor4f(view->selectedNodeColor.R,
-                                         view->selectedNodeColor.G,
-                                         view->selectedNodeColor.B,
-                                         view->selectedNodeColor.A);
-                               ddx = dx;       
-                               ddy = dy;
-                               ddz= dz;
-                       } 
-                       else    //get the color from node
-                   {
-                               glColor4f(v->Color.R, v->Color.G, v->Color.B,
-                                 v->node_alpha);
-                               ddx = 0;
-                               ddy = 0;
-                               ddz=0;
-                       }
+               dotsize=5/view->zoom*-1;
+               if(dotsize > 1)
+                       glPointSize(dotsize);
+               else
+                       glPointSize(1);
+
 
-                   if (v->distorted_x != v->x)
-                       zdepth = (float) Z_FORWARD_PLANE;
-                   else
-                       zdepth = (float) Z_BACK_PLANE;
-//                 if (view->zoom < NODE_CIRCLE_LIMIT)
+               //draw nodes
+               set_topview_options();
+           glBegin(GL_POINTS);
+               for (ind = 0; ((ind < view->Topview->Nodecount) && (view->drawnodes)); ind++)
+               {
+                       if (((-view->Topview->Nodes[ind].x/view->zoom > view->clipX1)
+                       && (-view->Topview->Nodes[ind].x/view->zoom < view->clipX2)
+                       && (-view->Topview->Nodes[ind].y/view->zoom > view->clipY1)
+                       && (-view->Topview->Nodes[ind].y/view->zoom < view->clipY2)) 
+                       || (view->active_camera>=0))
+                       {
+                               float zdepth;
+                               v = &view->Topview->Nodes[ind];
+                               if (!node_visible(v->Node))
+                                       break;
+
+                           select_topview_node(v);
+                           //UPDATE view->Topview data from cgraph
+                           if (v->update_required)
+                                       update_topview_node_from_cgraph(v);
+                               if (OD_Selected(v->Node) == 1)
+                               {
+                                       glColor4f(view->selectedNodeColor.R,
+                                                 view->selectedNodeColor.G,
+                                               view->selectedNodeColor.B,
+                                               view->selectedNodeColor.A);
+                                       ddx = dx;       
+                                       ddy = dy;
+                                       ddz= dz;
+                               } 
+                               else    //get the color from node
+                           {
+                                       glColor4f(v->Color.R, v->Color.G, v->Color.B,
+                                         v->node_alpha);
+                                       ddx = 0;
+                                       ddy = 0;
+                                       ddz=0;
+                               }
+
+                               if (v->distorted_x != v->x)
+                                       zdepth = (float) Z_FORWARD_PLANE;
+                               else
+                                       zdepth = (float) Z_BACK_PLANE;
                                glVertex3f(v->distorted_x - ddx,
-                               v->distorted_y - ddy, v->distorted_z-ddz);
-/*                 else
-                       drawCircle(v->distorted_x - ddx,
-                                  v->distorted_y - ddy,
-                                  v->node_alpha * v->zoom_factor, v->distorted_z);*/
+                                               v->distorted_y - ddy, v->distorted_z-ddz);
+                       }
                }
-       }
-//     if (view->zoom < NODE_CIRCLE_LIMIT)
            glEnd();
+       }
+       return 1;
 
+}
+int drawtopviewedges(Agraph_t * g)
+{
+    topview_edge *e;
+    float ddx, ddy,ddz;
+    float dddx, dddy,dddz;
+    int ind = 0;
 
-    }
-       //draw picked node names;
-       draw_node_hint_boxes();
-    //draw edges
-//      glLineWidth(5/view->zoom*-1);
-    glBegin(GL_LINES);
+       glBegin(GL_LINES);
     set_topview_options();
-    for (ind = 0; ind < view->Topview->Edgecount; ind++) {
-       if (((view->Topview->Edges[ind].x1/view->zoom*-1  > view->clipX1)
+       for (ind = 0; ((ind < view->Topview->Edgecount)&& view->drawedges); ind++)
+       {
+               if (((view->Topview->Edges[ind].x1/view->zoom*-1  > view->clipX1)
             && (view->Topview->Edges[ind].x1/view->zoom*-1  < view->clipX2)
             && (view->Topview->Edges[ind].y1/view->zoom*-1  > view->clipY1)
             && (view->Topview->Edges[ind].y1/view->zoom*-1  < view->clipY2))
@@ -293,48 +285,81 @@ void drawTopViewGraph(Agraph_t * g)
                && (view->Topview->Edges[ind].x2/view->zoom*-1  < view->clipX2)
                && (view->Topview->Edges[ind].y2/view->zoom*-1  > view->clipY1)
                && (view->Topview->Edges[ind].y2/view->zoom*-1  < view->clipY2))
-               ||   (view->active_camera>=0)
-           )
-               if(1)
+               ||   (view->active_camera>=0)       )
+               {
+                   e = &view->Topview->Edges[ind];
+                   select_topview_edge(e);
+                   if (OD_Selected(e->Node1->Node) == 1)
+                       { //tail is selected
+                               ddx = dx;
+                               ddy = dy;
+                               ddz=0;
+                       }
+                       else 
+                       {
+                               ddx = 0;
+                               ddy = 0;
+                               ddz=0;
+                       }
+                       if (OD_Selected(e->Node2->Node) == 1) 
+                       { //head
+                               dddx = dx;
+                               dddy = dy;
+                               dddz=0;
+                       } 
+                       else 
+                       {
+                               dddx = 0;
+                               dddy = 0;
+                               dddz=0;
+                       }
+                       if (get_color_from_edge(e))
+                       {
+                               glVertex3f(e->Node1->distorted_x - ddx,
+                                       e->Node1->distorted_y - ddy, e->Node1->distorted_z-ddz);
+                               glVertex3f(e->Node2->distorted_x - dddx,
+                                       e->Node2->distorted_y - dddy, e->Node2->distorted_z-ddz);
+                       }
+               }
+    }
+    glEnd();
 
+
+}
+int drawtopviewlabels(Agraph_t * g)
+{
+               //drawing labels
+    int ind = 0;
+       if(view->drawlabels)
        {
-           e = &view->Topview->Edges[ind];
-           select_topview_edge(e);
-           if (OD_Selected(e->Node1->Node) == 1) { //tail is selected
-               ddx = dx;
-               ddy = dy;
-               ddz=0;
-           } else {
-               ddx = 0;
-               ddy = 0;
-               ddz=0;
-           }
-           if (OD_Selected(e->Node2->Node) == 1) { //head
-               dddx = dx;
-               dddy = dy;
-               dddz=0;
-           } else {
-               dddx = 0;
-               dddy = 0;
-               dddz=0;
-           }
+           topview_node *v;
+               for (ind = 0; ind < view->Topview->Nodecount; ind++)
+               {
+                               v = &view->Topview->Nodes[ind];
+                               if (!node_visible(v->Node))
+                               break;
+                               draw_topview_label(v, 1);
+               }
+               return 1;
+       }
+               return 0;
 
-           if (get_color_from_edge(e)) {
+}
 
-               glVertex3f(e->Node1->distorted_x - ddx,
-                       e->Node1->distorted_y - ddy, e->Node1->distorted_z-ddz);
-               glVertex3f(e->Node2->distorted_x - dddx,
-                       e->Node2->distorted_y - dddy, e->Node2->distorted_z-ddz);
-           }
-       }
-    }
-    glEnd();
-    if ((view->Selection.Active > 0) && (!view->SignalBlock)) {
-       view->Selection.Active = 0;
-       drawTopViewGraph(g);
-       view->SignalBlock = 1;
-       glexpose();
-       view->SignalBlock = 0;
+
+void drawTopViewGraph(Agraph_t * g)
+{
+       drawtopviewnodes(g);
+       drawtopviewlabels(g);
+       draw_node_hint_boxes();
+       drawtopviewedges(g);
+       if ((view->Selection.Active > 0) && (!view->SignalBlock))
+       {
+               view->Selection.Active = 0;
+               drawTopViewGraph(g);
+               view->SignalBlock = 1;
+               glexpose();
+               view->SignalBlock = 0;
     }
 }
 int is_node_picked(topview_node* n)
@@ -385,7 +410,7 @@ int pick_node(topview_node* n)
        float a,b;
        a=ABS(n->distorted_x-view->GLx);
        b=ABS(n->distorted_y-view->GLy);
-       a=pow((a*a+b*b),0.5);
+       a=(float)pow((a*a+b*b),(float)0.5);
        if( a < closest_dif)
        {
                if(!is_node_picked(n))
@@ -416,12 +441,13 @@ int draw_node_hint_boxes()
        int fs=12;
        for (ind=0;ind < view->Topview->picked_node_count;ind++)
        {
-               draw_node_hintbox(view->Topview->picked_nodes[ind]->distorted_x,view->Topview->picked_nodes[ind]->distorted_y,fs,1,1,(int)(strlen(agnameof(view->Topview->picked_nodes[ind]->Node))/2),ind);
+               draw_node_hintbox(view->Topview->picked_nodes[ind]->distorted_x,view->Topview->picked_nodes[ind]->distorted_y,(GLfloat)fs,(GLfloat)1,(GLfloat)1,(GLfloat)(strlen(agnameof(view->Topview->picked_nodes[ind]->Node))/2),(GLfloat)ind);
                fontSize(fs);
                fontColorA(0,0,1,1);
-               fontDrawString(view->Topview->picked_nodes[ind]->distorted_x-fs/3+1-fs,view->Topview->picked_nodes[ind]->distorted_y+fs+1,
+               fontDrawString((int)(view->Topview->picked_nodes[ind]->distorted_x-fs/3+1-fs),(int)(view->Topview->picked_nodes[ind]->distorted_y+fs+1),
                        agnameof(view->Topview->picked_nodes[ind]->Node),fs*strlen(agnameof(view->Topview->picked_nodes[ind]->Node))/2);
        }
+       return 1;
 }
 
 
index a9ed09315785c37dc9d6650c2413581345001e2b..592060cefe990650e8f36ab4f37522df583d942e 100755 (executable)
@@ -26,6 +26,9 @@
 
 void cleartopview(topview * t);
 void preparetopview(Agraph_t * g, topview * t);
+int drawtopviewnodes(Agraph_t * g);
+int drawtopviewedges(Agraph_t * g);
+int drawtopviewlabels(Agraph_t * g);
 void drawTopViewGraph(Agraph_t * g);
 int select_topview_node(topview_node * n);
 int select_topview_edge(topview_edge * e);
index eea01afd64a5cc8e96cce91b1bffc939e3498cc7..977bfca78f5bcefa746d9b1b336a04c6a66968fe 100755 (executable)
@@ -111,7 +111,13 @@ set_viewport_settings_from_template(ViewInfo * view, Agraph_t * g)
          topologicalfisheyecoloredges = "1",
          topologicalfisheyelabelfocus = "1",
          topologicalfisheyefinestcolor = "red",
-         topologicalfisheyecoarsestcolor = "green"];
+         topologicalfisheyecoarsestcolor = "green",
+         drawnodes="1",
+         drawedges="1"]
+       ;
+
+         
+
 
     border color
 #endif
@@ -221,6 +227,16 @@ there i go, turn the page
     view->fmg.fisheye_distortion_fac =
        atoi(get_attribute_value
             ("defaultfisheyemagnifierdistort", view, g));
+       view->drawnodes=
+               atoi(get_attribute_value
+                    ("drawnodes", view, g));
+       view->drawedges=
+               atoi(get_attribute_value
+                    ("drawedges", view, g));
+       view->drawlabels=
+               atoi(get_attribute_value
+                    ("drawlabels", view, g));
+
 
 //FIXME: I don't think an openGL function can be called before it
   //     is initialized.
index ebf6bd881f1384207a5143d49017e61c6027c5e5..1c007d1f308672c942ae21b3e731104c70c50492 100644 (file)
@@ -46,6 +46,7 @@ static void indent(Agraph_t * g, iochan_t * ofile)
        ioput(g, ofile, "\t");
 }
 
+#ifndef WIN32
 #ifndef HAVE_STRCASECMP
 
 #include <string.h>
@@ -62,7 +63,7 @@ int strcasecmp(const char *s1, const char *s2)
     return tolower(*(unsigned char *) s1) - tolower(*(unsigned char *) s2);
 }
 #endif
-
+#endif
 /* _agstrcanon:
  * Canonicalize ordinary strings. 
  * Assumes buf is large enough to hold output.
index 1c1ca12963fec43b351ce3cca0823a8ff413076a..43fa4d7f253243bfc9e7446debdc9451484767bb 100755 (executable)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
 <!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
-<!--Generated with glade3 3.0.2 on Wed Apr 23 13:53:27 2008 by arif@DT-ARIF-->
+<!--Generated with glade3 3.0.2 on Tue Apr 29 10:36:37 2008 by arif@DT-ARIF-->
 <glade-interface>
   <widget class="GtkWindow" id="frmObject">
     <property name="width_request">470</property>
@@ -2778,7 +2778,7 @@ topview</property>
                     <property name="width_request">340</property>
                     <property name="height_request">336</property>
                     <property name="visible">True</property>
-                    <property name="n_rows">9</property>
+                    <property name="n_rows">11</property>
                     <property name="n_columns">3</property>
                     <child>
                       <placeholder/>
@@ -2801,6 +2801,12 @@ topview</property>
                     <child>
                       <placeholder/>
                     </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
                     <child>
                       <widget class="GtkColorButton" id="settingsColorBtn9">
                         <property name="visible">True</property>
@@ -3039,6 +3045,56 @@ topview</property>
                         <property name="label" translatable="yes">Background Color</property>
                       </widget>
                     </child>
+                    <child>
+                      <widget class="GtkLabel" id="label81">
+                        <property name="visible">True</property>
+                        <property name="xalign">0</property>
+                        <property name="xpad">5</property>
+                        <property name="label" translatable="yes">Draw Nodes</property>
+                      </widget>
+                      <packing>
+                        <property name="top_attach">9</property>
+                        <property name="bottom_attach">10</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <widget class="GtkLabel" id="label82">
+                        <property name="visible">True</property>
+                        <property name="xalign">0</property>
+                        <property name="xpad">5</property>
+                        <property name="label" translatable="yes">Draw Edges</property>
+                      </widget>
+                      <packing>
+                        <property name="top_attach">10</property>
+                        <property name="bottom_attach">11</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <widget class="GtkCheckButton" id="settingsChkBox5-1">
+                        <property name="visible">True</property>
+                        <property name="draw_indicator">True</property>
+                      </widget>
+                      <packing>
+                        <property name="left_attach">2</property>
+                        <property name="right_attach">3</property>
+                        <property name="top_attach">9</property>
+                        <property name="bottom_attach">10</property>
+                        <property name="x_options">GTK_EXPAND</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <widget class="GtkCheckButton" id="settingsChkBox5-2">
+                        <property name="visible">True</property>
+                        <property name="draw_indicator">True</property>
+                      </widget>
+                      <packing>
+                        <property name="left_attach">2</property>
+                        <property name="right_attach">3</property>
+                        <property name="top_attach">10</property>
+                        <property name="bottom_attach">11</property>
+                        <property name="x_options">GTK_EXPAND</property>
+                      </packing>
+                    </child>
                   </widget>
                   <packing>
                     <property name="x">6</property>