commit | author | age
|
8c7455
|
1 |
// FrameDlg.cpp |
JS |
2 |
|
|
3 |
#include <gtk/gtk.h> |
|
4 |
#include "FrameDlg.h" |
|
5 |
#include <string.h> |
|
6 |
#include <glib/gprintf.h> |
|
7 |
#include <stdlib.h> |
|
8 |
|
|
9 |
|
|
10 |
FrameDlg::FrameDlg(int t,float* data){ |
|
11 |
|
|
12 |
char title[100]; |
|
13 |
const char* strLab[6]={"Az:","El:","Rl:","X Translation:","Y Translation:","Z Translation:"}; |
|
14 |
int labInd; |
|
15 |
GtkWidget* label[3]; |
|
16 |
GtkWidget* table; |
|
17 |
gchar strVal[20]; |
|
18 |
|
|
19 |
memcpy(m_data,data,sizeof(float)*3); |
|
20 |
if (t==FD_ROT){ |
|
21 |
strcpy(title,"Set Frame Rotation"); |
|
22 |
labInd=0; |
|
23 |
} |
|
24 |
else { |
|
25 |
strcpy(title,"Set Frame Translation"); |
|
26 |
labInd=3; |
|
27 |
} |
|
28 |
|
|
29 |
|
|
30 |
m_dlg=gtk_dialog_new_with_buttons(title,NULL,GTK_DIALOG_MODAL,GTK_STOCK_OK,GTK_RESPONSE_OK, |
|
31 |
GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL,NULL); |
|
32 |
gtk_container_set_border_width(GTK_CONTAINER(m_dlg),30); |
|
33 |
|
|
34 |
for (int i=0;i<3;i++){ |
|
35 |
label[i]=gtk_label_new(strLab[labInd+i]); |
|
36 |
m_entry[i]=gtk_entry_new(); |
|
37 |
g_sprintf(strVal,"%.3f",m_data[i]); |
|
38 |
gtk_entry_set_text(GTK_ENTRY(m_entry[i]),strVal); |
|
39 |
} |
|
40 |
|
|
41 |
table=gtk_grid_new(); |
|
42 |
for (int i=0;i<3;i++){ |
|
43 |
gtk_grid_attach(GTK_GRID(table),label[i],0,i,1,1); |
|
44 |
gtk_grid_attach(GTK_GRID(table),m_entry[i],1,i,1,1); |
|
45 |
} |
|
46 |
gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(m_dlg))),table); |
|
47 |
gtk_widget_show_all(m_dlg); |
|
48 |
|
|
49 |
} |
|
50 |
|
|
51 |
void FrameDlg::update_data(){ |
|
52 |
|
|
53 |
const gchar* str; |
|
54 |
for (int i=0;i<3;i++){ |
|
55 |
str=gtk_entry_get_text(GTK_ENTRY(m_entry[i])); |
|
56 |
m_data[i]=atof(str); |
|
57 |
} |
|
58 |
} |
|
59 |
|
|
60 |
void FrameDlg::GetData(float* data){ |
|
61 |
|
|
62 |
memcpy(data,m_data,sizeof(float)*3); |
|
63 |
} |
|
64 |
|