]> granicus.if.org Git - graphviz/commitdiff
z axis is added to rotate
authorarif <devnull@localhost>
Thu, 17 Apr 2008 21:01:39 +0000 (21:01 +0000)
committerarif <devnull@localhost>
Thu, 17 Apr 2008 21:01:39 +0000 (21:01 +0000)
a new image file (rotate.raw) has been al so added to share/icons

cmd/smyrna/draw.c
cmd/smyrna/draw.h
cmd/smyrna/glexpose.c
cmd/smyrna/topview.c

index ea499ed5bf75e63bff672f4eba33603e33d4b25f..ba9d93688efe1c34f9214674b7c1d7446c4e5cbe 100755 (executable)
@@ -766,3 +766,17 @@ RGBColor GetRGBColor(char *color)
     }
     return c;
 }
+void drawEllipse(float xradius, float yradius,int angle1,int angle2)
+{
+       int i;
+       glBegin(GL_LINE_STRIP);
+
+   for (i=angle1; i<=angle2; i++)
+   {
+      //convert degrees into radians
+      float degInRad = i*DEG2RAD;
+      glVertex2f(cos(degInRad)*xradius,sin(degInRad)*yradius);
+   }
+   glEnd();
+}
index 9410a7b76779bea97c1f21d8a1b216ba54613234..489d327382d01097286eaa66084900b5055c36d5 100755 (executable)
@@ -42,5 +42,6 @@ extern int randomize_color(RGBColor * c, int brightness);
 extern void drawCircle(float x, float y, float radius, float zdepth);
 extern RGBColor GetRGBColor(char *color);
 extern void drawBorders(ViewInfo * view);
+void drawEllipse(float xradius, float yradius,int angle1,int angle2);
 
 #endif
index d41e22d745815960f5064df5cc4586796efc9ac1..9a4f3e880dcfa0b1c3c956cc7cf9d95b0fa164d4 100644 (file)
@@ -18,6 +18,7 @@
 #include "topview.h"
 #include "glutils.h"
 #include "topview.h"
+
 /*
        refreshes camera settings using view parameters such as pan zoom etc
        if a camera is selected viewport is switched to 3D
@@ -48,6 +49,8 @@ int glupdatecamera(ViewInfo * view)
 //                     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);
+                       glRotatef(view->cameras[view->active_camera]->anglez,0,0,1);
+
        }
        GetOGLPosRef(1, view->h - 5, &(view->clipX1), &(view->clipY1),
                 &(view->clipZ1));
@@ -83,6 +86,7 @@ int glexpose_main(ViewInfo * view)
     glexpose_drawgraph(view);
     draw_selection_box(view);
     drawBorders(view);
+       drawRotatingTools();
        /*DEBUG*/
 /*     if (view->mouse.mouse_mode == MM_PAN)
        {
@@ -150,3 +154,59 @@ int glexpose_drawgraph(ViewInfo * view)
     }
     return 0;
 }
+
+void drawRotatingTools()
+{
+       float x,y,z;
+       float x1,y1,z1;
+       float x2,y2,z2;
+       float R1,R2;
+       if ((view->mouse.mouse_mode == MM_ROTATE) && (view->active_camera >=0))
+       {
+               R1=25;
+               R2=200;
+               glCompDrawBegin();
+               GetOGLPosRef(1, view->h - 5, &x1, &y1,&z1);
+               GetOGLPosRef(view->w - 1, 1, &x2,&y2,&z2);
+               x=(x2-x1)/2.0;
+               y=(y2-y1)/2.0;
+               glTranslatef(x,y,0);
+               if ((view->mouse.rotate_axis==MOUSE_ROTATE_X) || (view->mouse.rotate_axis==MOUSE_ROTATE_XY))
+               {
+                       glLineWidth(2);
+                       glColor4f(0,1,0,0.5);
+               }
+               else
+               {
+                       glLineWidth(1);
+                       glColor4f(1,0,0,0.5);
+               }
+               drawEllipse(R1,R2,90,270);
+               if ((view->mouse.rotate_axis==MOUSE_ROTATE_Y) || (view->mouse.rotate_axis==MOUSE_ROTATE_XY))
+               {
+                       glLineWidth(2);
+                       glColor4f(0,1,0,0.5);
+               }
+               else
+               {
+                       glLineWidth(1);
+                       glColor4f(1,0,0,0.5);
+               }
+               drawEllipse(R2, R1,0,180);
+               if (view->mouse.rotate_axis==MOUSE_ROTATE_Z)
+               {
+                       glLineWidth(2);
+                       glColor4f(0,1,0,0.5);
+               }
+               else
+               {
+                       glLineWidth(1);
+                       glColor4f(1,0,0,0.5);
+               }
+
+               drawEllipse(R2, R2,0,360);
+               glCompDrawEnd();
+       }
+
+}
+
index 4c05e6ed37c6af00c90dff14c9d383760f994081..7bf4c9bc63c83f0a685404b23935df2780a3be4b 100755 (executable)
@@ -1033,6 +1033,26 @@ void menu_switch_to_fisheye(void* p)
        }
        view->Topview->is_top_fisheye=1;
 }
+void menu_click_rotate(void* p)
+{
+    view->mouse.mouse_mode = MM_ROTATE;
+}
+void menu_click_rotate_x(void* p)
+{
+       view->mouse.rotate_axis=MOUSE_ROTATE_X;
+}
+void menu_click_rotate_y(void* p)
+{
+       view->mouse.rotate_axis=MOUSE_ROTATE_Y;
+}
+void menu_click_rotate_xy(void* p)
+{
+       view->mouse.rotate_axis=MOUSE_ROTATE_XY;
+}
+void menu_click_rotate_z(void* p)
+{
+       view->mouse.rotate_axis=MOUSE_ROTATE_Z;
+}
 
 
 #ifdef _WIN32
@@ -1041,6 +1061,7 @@ void menu_switch_to_fisheye(void* p)
 #define SMYRNA_ICON_ZOOMPLUS "c:/zoomplus.raw"
 #define SMYRNA_ICON_ZOOMMINUS "c:/zoomminus.raw"
 #define SMYRNA_ICON_FISHEYE "c:/fisheye.raw"
+#define SMYRNA_ICON_ROTATE "c:/rotate.raw"
 #endif
 
 static char* smyrna_icon_pan;
@@ -1119,7 +1140,7 @@ glCompSet *glcreate_gl_topview_menu()
 
 
     //control panel
-    p = glCompPanelNew(25, 75, 165, 200);
+    p = glCompPanelNew(25, 75, 165, 277);
     p->data = 1;               //control panel
     glCompSetAddPanel(s, p);
 
@@ -1144,7 +1165,43 @@ glCompSet *glcreate_gl_topview_menu()
     b->groupid = 2;
     b->callbackfunc = menu_switch_to_fisheye;
     glCompSetAddButton(s, b);
-    //pan button
+
+    //rotate
+    b = glCompButtonNew(5, 197, 72, 72, "", SMYRNA_ICON_ROTATE,
+                       72, 72);
+    b->groupid = 3;
+    b->customptr = view;
+    b->panel = p;
+    b->callbackfunc = menu_click_rotate;
+    glCompSetAddButton(s, b);
+       
+    b = glCompButtonNew(80, 251, 40, 20, "X", '\0', 0, 0);
+    b->customptr = view;
+    b->panel = p;
+    b->groupid = 1;
+    b->callbackfunc = menu_click_rotate_x;
+    glCompSetAddButton(s, b);
+    b = glCompButtonNew(125, 251, 40, 20, "Y", '\0', 0, 0);
+    b->customptr = view;
+    b->panel = p;
+    b->groupid = 1;
+    b->callbackfunc = menu_click_rotate_y;
+    glCompSetAddButton(s, b);
+    b = glCompButtonNew(80, 231, 40, 20, "XY", '\0', 0, 0);
+    b->customptr = view;
+    b->panel = p;
+    b->groupid = 1;
+    b->callbackfunc = menu_click_rotate_xy;
+    glCompSetAddButton(s, b);
+    b = glCompButtonNew(125, 231, 40, 20, "Z", '\0', 0, 0);
+    b->customptr = view;
+    b->panel = p;
+    b->groupid = 1;
+    b->callbackfunc = menu_click_rotate_z;
+    glCompSetAddButton(s, b);
+
+
+       //pan button
     b = glCompButtonNew(5, 120, 72, 72, "adasasds", SMYRNA_ICON_PAN, 72,
                        72);
     b->groupid = 3;