Debian package version of polhemus's g4term
Janis Streib
30.03.22 8c7455636f3d259c44540ba6da9d3aaee993eeeb
commit | author | age
8c7455 1 // UnitsDlg.cpp
JS 2
3
4 #include <gtk/gtk.h>
5 #include "UnitsDlg.h"
6 #include "G4TrackIncl.h"
7
8
9 UnitsDlg::UnitsDlg(int posUnit,int oriUnit){
10
11   GtkWidget *vbox1,*vbox2,*hbox,*fr1,*fr2;
12   GtkWidget *inch,*ft,*met,*cm,*deg,*rad,*quat;
13
14   m_posUnit=posUnit;
15   m_oriUnit=oriUnit;
16
17   m_dlg=gtk_dialog_new_with_buttons("Set Tracker Units",NULL,GTK_DIALOG_MODAL,GTK_STOCK_OK,
18                   GTK_RESPONSE_OK,GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL,NULL);
19
20   gtk_widget_set_size_request(m_dlg,300,200);
21   fr1=gtk_frame_new("Position");
22   fr2=gtk_frame_new("Orientation");
23   hbox=gtk_box_new(GTK_ORIENTATION_HORIZONTAL,10);
24
25
26   vbox1=gtk_box_new(GTK_ORIENTATION_VERTICAL,5);
27   inch=gtk_radio_button_new_with_label(NULL,"Inches");
28   gtk_box_pack_start(GTK_BOX(vbox1),inch,TRUE,TRUE,3);
29   ft=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(inch),"Feet");
30   gtk_box_pack_start(GTK_BOX(vbox1),ft,TRUE,TRUE,3);
31   cm=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(inch),"cm");
32   gtk_box_pack_start(GTK_BOX(vbox1),cm,TRUE,TRUE,3);
33   met=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(inch),"meters");
34   gtk_box_pack_start(GTK_BOX(vbox1),met,TRUE,TRUE,3);
35   gtk_container_add(GTK_CONTAINER(fr1),vbox1);
36   gtk_box_pack_start(GTK_BOX(hbox),fr1,TRUE,TRUE,5);
37
38   vbox2=gtk_box_new(GTK_ORIENTATION_VERTICAL,5);
39   deg=gtk_radio_button_new_with_label(NULL,"Degrees");
40   gtk_box_pack_start(GTK_BOX(vbox2),deg,TRUE,TRUE,3);
41   rad=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(deg),"Radians");
42   gtk_box_pack_start(GTK_BOX(vbox2),rad,TRUE,TRUE,3);
43   quat=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(deg),"Quaternions");
44   gtk_box_pack_start(GTK_BOX(vbox2),quat,TRUE,TRUE,3);
45   gtk_container_add(GTK_CONTAINER(fr2),vbox2);
46   gtk_box_pack_start(GTK_BOX(hbox),fr2,TRUE,TRUE,5);
47
48   g_signal_connect(inch,"toggled",G_CALLBACK(OnPosRadio),(gpointer)G4_TYPE_INCH);
49   g_signal_connect(ft,"toggled",G_CALLBACK(OnPosRadio),(gpointer)G4_TYPE_FOOT);
50   g_signal_connect(cm,"toggled",G_CALLBACK(OnPosRadio),(gpointer)G4_TYPE_CM);
51   g_signal_connect(met,"toggled",G_CALLBACK(OnPosRadio),(gpointer)G4_TYPE_METER);
52
53   g_object_set_data(G_OBJECT(inch),"pos_unit",&m_posUnit);
54   g_object_set_data(G_OBJECT(ft),"pos_unit",&m_posUnit);
55   g_object_set_data(G_OBJECT(cm),"pos_unit",&m_posUnit);
56   g_object_set_data(G_OBJECT(met),"pos_unit",&m_posUnit);
57
58
59   g_signal_connect(deg,"toggled",G_CALLBACK(OnOriRadio),(gpointer)G4_TYPE_EULER_DEGREE);
60   g_signal_connect(rad,"toggled",G_CALLBACK(OnOriRadio),(gpointer)G4_TYPE_EULER_RADIAN);
61   g_signal_connect(quat,"toggled",G_CALLBACK(OnOriRadio),(gpointer)G4_TYPE_QUATERNION);
62
63   g_object_set_data(G_OBJECT(deg),"ori_unit",&m_oriUnit);
64   g_object_set_data(G_OBJECT(rad),"ori_unit",&m_oriUnit);
65   g_object_set_data(G_OBJECT(quat),"ori_unit",&m_oriUnit);
66
67   gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(inch),posUnit==G4_TYPE_INCH);
68   gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ft),posUnit==G4_TYPE_FOOT);
69   gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cm),posUnit==G4_TYPE_CM);
70   gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(met),posUnit==G4_TYPE_METER);
71
72   gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(deg),oriUnit==G4_TYPE_EULER_DEGREE);
73   gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rad),oriUnit==G4_TYPE_EULER_RADIAN);
74   gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(quat),oriUnit==G4_TYPE_QUATERNION);
75
76   gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(m_dlg))),hbox);
77   gtk_widget_show_all(m_dlg);
78
79 }
80
81
82 void UnitsDlg::OnPosRadio(GtkToggleButton* b,gpointer g){
83
84   int* pPos=(int*)g_object_get_data(G_OBJECT(b),"pos_unit");
85   if (gtk_toggle_button_get_active(b))
86     *pPos=(int)(long)g;
87 }
88
89 void UnitsDlg::OnOriRadio(GtkToggleButton* b,gpointer g){
90
91   int* pOri=(int*)g_object_get_data(G_OBJECT(b),"ori_unit");
92   if (gtk_toggle_button_get_active(b))
93     *pOri=(int)(long)g;
94 }
95
96 void UnitsDlg::GetUnits(int& posUnit,int& oriUnit){
97
98   posUnit=m_posUnit;
99   oriUnit=m_oriUnit;
100 }
101
102 void UnitsDlg::update_data(){}