#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)
view->camera_count--;
view->cameras =
realloc(view->cameras, sizeof(viewport_camera*) * view->camera_count);
+ viewport_update_camera_indexes(view);
return 1;
}
return 0;
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;
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]
+ );
}
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 ++)
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;
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"));
+}
+
+
+
+
+
+