]> granicus.if.org Git - graphviz/commitdiff
*** empty log message ***
authorarif <devnull@localhost>
Mon, 7 Apr 2008 21:36:43 +0000 (21:36 +0000)
committerarif <devnull@localhost>
Mon, 7 Apr 2008 21:36:43 +0000 (21:36 +0000)
cmd/smyrna/smyrnadefs.h
cmd/smyrna/viewportcamera.c
cmd/smyrna/viewportcamera.h

index 518f735777a21761d443e90af3d6c7bccdb11c87..d4f6d2b9dc26b90c1839168d7bb5dbb0203366ad 100644 (file)
@@ -140,6 +140,7 @@ typedef struct _viewport_camera{
        float targetx;
        float targety;
        float targetz;
+       int index;
 
        cam_t type; //
 } viewport_camera;
@@ -362,6 +363,7 @@ typedef struct _ViewInfo
        viewport_camera** cameras;
        int camera_count; //number of cameras
        int active_camera;
+       viewport_camera* selected_camera;       //selected camera does not have to nec. be active one 
 
        /*data attributes are read from graph's attributes DataAttribute1 and DataAttribute2*/
        char* node_data_attribute1;     /*for topview graphs this is the node data attribute to put as label*/
index f445f0e8a92aa0ca32d8a2d402a72b18fd013821..59a7dd74ba609fbe2836f4df0dbc9ad97243ee2e 100644 (file)
@@ -1,26 +1,38 @@
 #include "viewportcamera.h"
+#include "gui.h"
+
 static viewport_camera* new_viewport_camera(ViewInfo * view)
 {
        viewport_camera* c=malloc(sizeof(viewport_camera));
        return c;
 }
 
+static void viewport_update_camera_indexes(ViewInfo* view)
+{
+       int ind=0;
+       for(ind=0;ind < view->camera_count;ind ++)
+       {
+               view->cameras[ind]->index=ind;
+       }
+}
+
 viewport_camera* add_camera_to_viewport(ViewInfo * view)
 {
        view->camera_count++;
        view->cameras=(viewport_camera**)realloc(view->cameras,sizeof(viewport_camera *)*view->camera_count);
        view->cameras[view->camera_count-1]=new_viewport_camera(view);
+       viewport_update_camera_indexes(view);
        return view->cameras[view->camera_count-1];
 }
 int delete_camera_from_viewport(ViewInfo * view,viewport_camera* c)
 {
     int ind = 0;
     int found = 0;
-    for (ind; ind < view->camera_count - 1; ind++)
+    for (ind; ind < view->camera_count ; ind++)
        {
                if ((view->cameras[ind] == c) && found == 0)
                    found = 1;
-               if (found == 1)
+               if ((found == 1)&&(ind < (view->camera_count-1)))
                        view->cameras[ind] =view->cameras[ind + 1];
     }
     if (found)
@@ -29,6 +41,7 @@ int delete_camera_from_viewport(ViewInfo * view,viewport_camera* c)
                view->camera_count--;
                view->cameras =
                        realloc(view->cameras, sizeof(viewport_camera*) * view->camera_count);
+               viewport_update_camera_indexes(view);
                return 1;
     }
     return 0;
@@ -60,9 +73,17 @@ int refresh_viewport_camera (ViewInfo * view)
 
 void menu_click_add_camera(void *p)
 {
+       viewport_camera*        c;
+       /*add test cameras*/
+       c=add_camera_to_viewport(view);
+       c->targetx=view->panx;c->targety=view->pany;c->targetz=0;
+       c->x=view->panx;c->y=view->pany;c->z=view->zoom*-1;
+               attach_camera_widget(view);
+
 
 }
 
+int blocksignal=0;
 void menu_click_2d (void *p)
 {
        view->active_camera=-1;
@@ -76,11 +97,15 @@ void menu_click_camera_select(void *p)
 
 void menu_click_camera_remove(void *p)
 {
+       delete_camera_from_viewport(view,view->cameras[(int)((glCompButton*)p)->data]);
+               attach_camera_widget(view);
 
 }
 void menu_click_camera_edit(void *p)
 {
-
+       show_camera_settings(view->cameras
+               [(int)((glCompButton*)p)->data]
+               );
 }
 
 
@@ -98,7 +123,6 @@ void attach_camera_widget(ViewInfo * view)
     glCompButton *b;
     glCompLabel *l;    
     glCompSet *s = view->Topview->topviewmenu;
-       viewport_camera*        c;
        int p_height;
        /*first we need to get rid of the old menu*/
        for (ind=0;ind < s->panelcount; ind ++)
@@ -106,28 +130,22 @@ void attach_camera_widget(ViewInfo * view)
                if (s->panels[ind]->data==3)
                {
                        /*remove buttons in the panel*/
-                       for (ind2=0;ind < s->buttoncount;ind2++)
+                       for (ind2=0;ind2 < s->buttoncount;ind2++)
                        {
                                if(s->buttons[ind2]->panel==s->panels[ind])
+                               {
                                        glCompSetRemoveButton(s,s->buttons[ind2]);
+                                       ind2--;
+                               }       
                        }
                        /*remove panel itself*/
                        glCompSetRemovePanel(s,s->panels[ind]);
+                       break;
                }
        }
 
 
 
-       /*add test cameras*/
-       c=add_camera_to_viewport(view);
-       c->targetx=view->panx;c->targety=view->pany;c->targetz=0;
-       c->x=100;c->y=+200;c->z=view->zoom;
-       c=add_camera_to_viewport(view);
-       c->targetx=view->panx;c->targety=view->pany;c->targetz=0;
-       c->x=-300;c->y=+200;c->z=view->zoom;
-       c=add_camera_to_viewport(view);
-       c->targetx=view->panx;c->targety=view->pany;c->targetz=0;
-       c->x=-100;c->y=-200;c->z=view->zoom;
 
        /*calculate height of panel*/
        p_height=2*PANEL_PADDING+view->camera_count*(CAMERA_BUTTON_HEIGHT+PANEL_PADDING)+CAMERA_BUTTON_HEIGHT;
@@ -183,12 +201,77 @@ void attach_camera_widget(ViewInfo * view)
                glCompSetAddButton(s, b);
                b->callbackfunc = menu_click_camera_edit;
        }
+}
+int show_camera_settings(viewport_camera* c)
+{
 
+       char buf[50];
+       sprintf(buf,"Camera:%i",c->index);
+       gtk_label_set_text((GtkLabel*)glade_xml_get_widget(xml,"dlgcameralabel1"),buf); 
+       gtk_spin_button_set_value((GtkSpinButton *)
+                                 glade_xml_get_widget(xml,"dlgcameraspinbutton1"),
+                                 c->x);
+       gtk_spin_button_set_value((GtkSpinButton *)
+                                 glade_xml_get_widget(xml,"dlgcameraspinbutton2"),
+                                 c->y);
+       gtk_spin_button_set_value((GtkSpinButton *)
+                                 glade_xml_get_widget(xml,"dlgcameraspinbutton3"),
+                                 c->z);
+       gtk_spin_button_set_value((GtkSpinButton *)
+                                 glade_xml_get_widget(xml,"dlgcameraspinbutton4"),
+                                 c->targetx);
+       gtk_spin_button_set_value((GtkSpinButton *)
+                                 glade_xml_get_widget(xml,"dlgcameraspinbutton5"),
+                                 c->targety);
+       gtk_spin_button_set_value((GtkSpinButton *)
+                                 glade_xml_get_widget(xml,"dlgcameraspinbutton6"),
+                                 c->targetz);
+               
 
 
+       gtk_widget_hide(glade_xml_get_widget(xml, "dlgCamera"));
+    gtk_widget_show(glade_xml_get_widget(xml, "dlgCamera"));
+    gtk_window_set_keep_above((GtkWindow *)
+                             glade_xml_get_widget(xml, "dlgCamera"), 1);
+       view->selected_camera=c;
+    return 1;
 
 
+}
+int save_camera_settings(viewport_camera* c)
+{
+    float value;
+       c->x =  (float) gtk_spin_button_get_value((GtkSpinButton *)
+                                         glade_xml_get_widget(xml,"dlgcameraspinbutton1"     ));
+       c->y =  (float) gtk_spin_button_get_value((GtkSpinButton *)
+                                         glade_xml_get_widget(xml,"dlgcameraspinbutton2"     ));
+       c->z =  (float) gtk_spin_button_get_value((GtkSpinButton *)
+                                         glade_xml_get_widget(xml,"dlgcameraspinbutton3"     ));
+       c->targetx =    (float) gtk_spin_button_get_value((GtkSpinButton *)
+                                         glade_xml_get_widget(xml,"dlgcameraspinbutton4"     ));
+       c->targety =    (float) gtk_spin_button_get_value((GtkSpinButton *)
+                                         glade_xml_get_widget(xml,"dlgcameraspinbutton5"     ));
+       c->targetz =    (float) gtk_spin_button_get_value((GtkSpinButton *)
+                                         glade_xml_get_widget(xml,"dlgcameraspinbutton6"     ));
+       return 1;
 
+}
 
+void dlgcameraokbutton_clicked_cb
+(GtkWidget * widget, gpointer user_data)
+{
+       gtk_widget_hide(glade_xml_get_widget(xml, "dlgCamera"));
+       save_camera_settings(view->selected_camera)     ;
 }
 
+void dlgcameracancelbutton_clicked_cb
+(GtkWidget * widget, gpointer user_data)
+{
+       gtk_widget_hide(glade_xml_get_widget(xml, "dlgCamera"));
+}
+
+
+
+
+
+
index 1e132a66a88bca8b1f9d6df0753918a0702d8a8d..4644091c1188d0412ad19b3b2f760dc0624eb966 100644 (file)
@@ -7,5 +7,9 @@ int delete_camera_from_viewport(ViewInfo * view,viewport_camera* c);
 int activate_viewport_camera (ViewInfo * view,int cam_index);
 int refresh_viewport_camera (ViewInfo * view);
 void attach_camera_widget(ViewInfo * view);
+int show_camera_settings(viewport_camera* c);
+int save_camera_settings(viewport_camera* c);
+_BB void dlgcameraokbutton_clicked_cb(GtkWidget * widget, gpointer user_data);
+_BB void dlgcameracancelbutton_clicked_cb(GtkWidget * widget, gpointer user_data);
 
 #endif
\ No newline at end of file