cuikexplore_callbacks.c
Go to the documentation of this file.
1 #include "cuikexplore.h"
2 
5 #include "cuikplay_support.h"
6 
7 #include <gtk/gtk.h>
8 
9 #include <stdlib.h>
10 #include <unistd.h>
11 #include <time.h>
12 
23 void on_cuikexplore_plus_clicked(GtkButton *button,
24  gpointer user_data)
25 {
27  signed int k;
28  const char *name;
29 
30 
31  c=(TCuikexploreControl *)user_data;
32 
33  name=gtk_widget_get_name(GTK_WIDGET(button));
34  k=atoi(&(name[1]));
35 
36  c->vect[c->ndx[k]]+=c->step;
37 
38  fprintf(stderr,"+[%u]\n",c->ndx[k]);
39 
40  c->changed=TRUE;
41  c->oneStep=TRUE;
42 }
43 
44 void on_cuikexplore_up_pressed(GtkButton *button,
45  gpointer user_data)
46 {
48  signed int k;
49  const char *name;
50 
51 
52  c=(TCuikexploreControl *)user_data;
53 
54  name=gtk_widget_get_name(GTK_WIDGET(button));
55  k=atoi(&(name[1]));
56 
57  c->vect[c->ndx[k]]+=c->step;
58 
59  fprintf(stderr,"<+[%u]\n",c->ndx[k]);
60 
61  c->changed=TRUE;
62  c->oneStep=FALSE;
63 }
64 
65 void on_cuikexplore_up_released(GtkButton *button,
66  gpointer user_data)
67 {
69  signed int k;
70  const char *name;
71 
72 
73  c=(TCuikexploreControl *)user_data;
74 
75  name=gtk_widget_get_name(GTK_WIDGET(button));
76  k=atoi(&(name[1]));
77 
78  c->vect[c->ndx[k]]=0;
79 
80  fprintf(stderr,"+[%u]>\n",c->ndx[k]);
81 
82  c->changed=FALSE;
83 }
84 
85 void on_cuikexplore_minus_clicked(GtkButton *button,
86  gpointer user_data)
87 {
89  signed int k;
90  const char *name;
91 
92 
93  c=(TCuikexploreControl *)user_data;
94 
95  name=gtk_widget_get_name(GTK_WIDGET(button));
96  k=atoi(&(name[1]));
97 
98  c->vect[c->ndx[k]]-=c->step;
99 
100  fprintf(stderr,"-[%u]\n",c->ndx[k]);
101 
102  c->changed=TRUE;
103  c->oneStep=TRUE;
104 }
105 
106 
107 void on_cuikexplore_down_pressed(GtkButton *button,
108  gpointer user_data)
109 {
111  signed int k;
112  const char *name;
113 
114  c=(TCuikexploreControl *)user_data;
115 
116  name=gtk_widget_get_name(GTK_WIDGET(button));
117  k=atoi(&(name[1]));
118 
119  c->vect[c->ndx[k]]-=c->step;
120 
121  fprintf(stderr,"<-[%u]\n",c->ndx[k]);
122  c->changed=TRUE;
123  c->oneStep=FALSE;
124 }
125 
126 void on_cuikexplore_down_released(GtkButton *button,
127  gpointer user_data)
128 {
130  signed int k;
131  const char *name;
132 
133 
134  c=(TCuikexploreControl *)user_data;
135 
136  name=gtk_widget_get_name(GTK_WIDGET(button));
137  k=atoi(&(name[1]));
138 
139  c->vect[c->ndx[k]]=0;
140 
141  fprintf(stderr,"-[%u]>\n",c->ndx[k]);
142 
143  c->changed=FALSE;
144 }
145 
146 void on_cuikexplore_quit(GtkButton *button,
147  gpointer user_data)
148 {
150 
151  c=(TCuikexploreControl *)user_data;
152  c->end=TRUE;
153 }
154 
155 void on_cuikexplore_menu_changed(GtkComboBox *menu,
156  gpointer user_data)
157 {
159  signed int k;
160  unsigned int i,new;
161  boolean found;
162  const char *name;
163 
164  c=(TCuikexploreControl *)user_data;
165 
166  name=gtk_widget_get_name(GTK_WIDGET(menu));
167  k=atoi(&(name[1]));
168 
169  new=gtk_combo_box_get_active(menu);
170  found=FALSE;
171  i=0;
172  while((!found)&&(i<c->k))
173  {
174  found=((i!=k)&&(c->ndx[i]==new));
175  i++;
176  }
177  if (found)
178  {
179  fprintf(stderr,"Parameter %u is already in use\n",new);
180  gtk_combo_box_set_active(menu,c->ndx[k]);
181  }
182  else
183  {
184  c->ndx[k]=gtk_combo_box_get_active(menu);
185  fprintf(stderr,"Menu[%u]=%u\n",k,c->ndx[k]);
186  }
187 }
188 
189 
190 void on_cuikexplore_save(GtkButton *button,
191  gpointer user_data)
192 {
193  Tfilename fn;
194  FILE *f;
195  unsigned int i;
197 
198  c=(TCuikexploreControl *)user_data;
199 
200  CreateFileName(NULL,c->fw,"_explore",JOINTS_EXT,&fn);
201  f=fopen(GetFileFullName(&fn),"w");
202  if (!f)
203  Error("Can not open output file for dofs from cuikexplore");
204 
205  fprintf(stderr,"\n\n\nSaving dof to : %s\n",GetFileFullName(&fn));
206 
207  for(i=0;i<c->m;i++)
208  fprintf(f,"%.12f ",c->point[i]);
209  fprintf(f,"\n");
210 
211  fclose(f);
212  DeleteFileName(&fn);
213 }
214 
215 void on_cuikexplore_step_changed(GtkEntry *entry,
216  gpointer user_data)
217 {
219  double newStep;
220  char string[20];
221 
222  c=(TCuikexploreControl *)user_data;
223  newStep=atof(gtk_entry_get_text(entry));
224  if (newStep==0)
225  {
226  fprintf(stderr,"Error in the input step\n");
227  }
228  else
229  {
230  c->step=newStep;
231  fprintf(stderr,"New advance step: %g\n",c->step);
232  }
233  sprintf(string,"%f",c->step);
234  gtk_entry_set_text(entry,string);
235 }
236 
237 void on_cuikexplore_reset(GtkButton *button,
238  gpointer user_data)
239 {
241 
242  c=(TCuikexploreControl *)user_data;
243 
244  c->reset=TRUE;
245 }
void on_cuikexplore_down_pressed(GtkButton *button, gpointer user_data)
Callback function for the minus buttons.
#define FALSE
FALSE.
Definition: boolean.h:30
Data structure to hold the information about the name of a file.
Definition: filename.h:248
Headers of the GTK callback functions for cuikexplore.
#define TRUE
TRUE.
Definition: boolean.h:21
void Error(const char *s)
General error function.
Definition: error.c:80
void on_cuikexplore_minus_clicked(GtkButton *button, gpointer user_data)
Callback function for the plus buttons.
void DeleteFileName(Tfilename *fn)
Destructor.
Definition: filename.c:205
void on_cuikexplore_down_released(GtkButton *button, gpointer user_data)
Callback function for the plus buttons.
Definition of the cuikexplore control structure.
void on_cuikexplore_reset(GtkButton *button, gpointer user_data)
Callback function for the reset button.
void on_cuikexplore_menu_changed(GtkComboBox *menu, gpointer user_data)
Callback function for the menus.
void on_cuikexplore_plus_clicked(GtkButton *button, gpointer user_data)
Callback function for the plus buttons.
void CreateFileName(char *path, char *name, char *suffix, char *ext, Tfilename *fn)
Constructor.
Definition: filename.c:22
void on_cuikexplore_save(GtkButton *button, gpointer user_data)
Callback function for the save button.
char * GetFileFullName(Tfilename *fn)
Gets the file full name (paht+name+extension).
Definition: filename.c:151
void on_cuikexplore_quit(GtkButton *button, gpointer user_data)
Callback function for the quit button.
#define JOINTS_EXT
File extension for files with samples represented by the joint values.
Definition: filename.h:187
void on_cuikexplore_step_changed(GtkEntry *entry, gpointer user_data)
Callback function for the step entry.
unsigned int * ndx
Definition: cuikexplore.h:30
unsigned int m
Definition: cuikexplore.h:31
Definition of the cuikexplore control structure.
Definition: cuikexplore.h:23
void on_cuikexplore_up_released(GtkButton *button, gpointer user_data)
Callback function for the plus buttons.
void on_cuikexplore_up_pressed(GtkButton *button, gpointer user_data)
Callback function for the plus buttons.
Headers of the GTK interface functions for cuikexplore.
Headers of the GTK support functions for cuikplay.