Janis Streib
30.03.22 00027aa5bb1da6f2d44c03a082988de8c64dab4a
Commit | Autor | Alter
8c7455 1 // IncrDlg.cpp
JS 2
3 #include <gtk/gtk.h>
4 #include "IncrDlg.h"
5 #include <glib/gprintf.h>
6 #include <stdlib.h>
7
8 IncrDlg::IncrDlg(float nPos,float nOri){
9
10   m_posIncr=nPos;
11   m_oriIncr=nOri;
12   gchar str[100];
13
14   m_dlg=gtk_dialog_new_with_buttons("Specify Increments",NULL,GTK_DIALOG_MODAL,GTK_STOCK_OK,
15                     GTK_RESPONSE_OK,GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL,NULL);
16
17   GtkWidget* table=gtk_grid_new();
18   GtkWidget *lab1,*lab2;
19
20   lab1=gtk_label_new("Position Increment");
21   lab2=gtk_label_new("Orientation Increment");
22   m_entry_p=gtk_entry_new();
23   m_entry_o=gtk_entry_new();
24
25
26   gtk_container_set_border_width(GTK_CONTAINER(table),10);
27   gtk_grid_set_column_spacing(GTK_GRID(table),25);
28   gtk_grid_attach(GTK_GRID(table),lab1,0,1,1,1);
29   gtk_grid_attach(GTK_GRID(table),lab2,0,2,1,1);
30   gtk_grid_attach(GTK_GRID(table),m_entry_p,1,1,1,1);
31   gtk_grid_attach(GTK_GRID(table),m_entry_o,1,2,1,1);
32
33
34   gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(m_dlg))),table);
35
36   g_sprintf(str,"%.3f",m_posIncr);
37   gtk_entry_set_text(GTK_ENTRY(m_entry_p),str);
38   g_sprintf(str,"%.3f",m_oriIncr);
39   gtk_entry_set_text(GTK_ENTRY(m_entry_o),str);
40
41   gtk_widget_show_all(m_dlg);
42
43 }
44
45 void IncrDlg::update_data(){
46
47   const gchar* str=gtk_entry_get_text(GTK_ENTRY(m_entry_p));
48   m_posIncr=atof(str);
49
50
51   str=gtk_entry_get_text(GTK_ENTRY(m_entry_o));
52   m_oriIncr=atof(str);
53
54 }
55
56 void IncrDlg::get_increments(float& nPos,float& nOri){
57
58   nPos=m_posIncr;
59   nOri=m_oriIncr;
60 }