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  c=(TCuikexploreControl *)user_data;
31 
32  name=gtk_widget_get_name(GTK_WIDGET(button));
33  k=atoi(&(name[1]));
34 
35  c->vectDOF[c->ndx[k]]+=c->step;
36 
37  fprintf(stderr,"+[%u]\n",c->ndx[k]);
38 
39  c->changed=TRUE;
40  c->oneStep=TRUE;
41 }
42 
43 void on_cuikexplore_up_pressed(GtkButton *button,
44  gpointer user_data)
45 {
47  signed int k;
48  const char *name;
49 
50  c=(TCuikexploreControl *)user_data;
51 
52  name=gtk_widget_get_name(GTK_WIDGET(button));
53  k=atoi(&(name[1]));
54 
55  c->vectDOF[c->ndx[k]]+=c->step;
56 
57  fprintf(stderr,"<+[%u]\n",c->ndx[k]);
58 
59  c->changed=TRUE;
60  c->oneStep=FALSE;
61 }
62 
63 void on_cuikexplore_up_released(GtkButton *button,
64  gpointer user_data)
65 {
67  signed int k;
68  const char *name;
69 
70  c=(TCuikexploreControl *)user_data;
71 
72  name=gtk_widget_get_name(GTK_WIDGET(button));
73  k=atoi(&(name[1]));
74 
75  c->vectDOF[c->ndx[k]]=0;
76 
77  fprintf(stderr,"+[%u]>\n",c->ndx[k]);
78 
79  c->changed=FALSE;
80 }
81 
82 void on_cuikexplore_minus_clicked(GtkButton *button,
83  gpointer user_data)
84 {
86  signed int k;
87  const char *name;
88 
89  c=(TCuikexploreControl *)user_data;
90 
91  name=gtk_widget_get_name(GTK_WIDGET(button));
92  k=atoi(&(name[1]));
93 
94  c->vectDOF[c->ndx[k]]-=c->step;
95 
96  fprintf(stderr,"-[%u]\n",c->ndx[k]);
97 
98  c->changed=TRUE;
99  c->oneStep=TRUE;
100 }
101 
102 
103 void on_cuikexplore_down_pressed(GtkButton *button,
104  gpointer user_data)
105 {
107  signed int k;
108  const char *name;
109 
110  c=(TCuikexploreControl *)user_data;
111 
112  name=gtk_widget_get_name(GTK_WIDGET(button));
113  k=atoi(&(name[1]));
114 
115  c->vectDOF[c->ndx[k]]-=c->step;
116 
117  fprintf(stderr,"<-[%u]\n",c->ndx[k]);
118  c->changed=TRUE;
119  c->oneStep=FALSE;
120 }
121 
122 void on_cuikexplore_down_released(GtkButton *button,
123  gpointer user_data)
124 {
126  signed int k;
127  const char *name;
128 
129  c=(TCuikexploreControl *)user_data;
130 
131  name=gtk_widget_get_name(GTK_WIDGET(button));
132  k=atoi(&(name[1]));
133 
134  c->vectDOF[c->ndx[k]]=0;
135 
136  fprintf(stderr,"-[%u]>\n",c->ndx[k]);
137 
138  c->changed=FALSE;
139 }
140 
141 void on_cuikexplore_quit(GtkButton *button,
142  gpointer user_data)
143 {
145 
146  c=(TCuikexploreControl *)user_data;
147  c->end=TRUE;
148 }
149 
150 void on_cuikexplore_menu_changed(GtkComboBox *menu,
151  gpointer user_data)
152 {
154  signed int k;
155  unsigned int i,new;
156  boolean found;
157  const char *name;
158 
159  c=(TCuikexploreControl *)user_data;
160 
161  name=gtk_widget_get_name(GTK_WIDGET(menu));
162  k=atoi(&(name[1]));
163 
164  new=c->e2d[gtk_combo_box_get_active(menu)];
165  found=FALSE;
166  i=0;
167  while((!found)&&(i<c->k))
168  {
169  found=((i!=k)&&(c->ndx[i]==new));
170  i++;
171  }
172  if (found)
173  {
174  fprintf(stderr,"Parameter %u is already in use\n",new);
175  gtk_combo_box_set_active(menu,c->d2e[c->ndx[k]]);
176  }
177  else
178  {
179  c->ndx[k]=new; //c->d2e[gtk_combo_box_get_active(menu)];
180  fprintf(stderr,"Menu[%u]=%u\n",k,new);
181  }
182 }
183 
184 
185 void on_cuikexplore_save(GtkButton *button,
186  gpointer user_data)
187 {
188  Tfilename fn;
189  FILE *f;
190  unsigned int i;
192 
193  c=(TCuikexploreControl *)user_data;
194 
195  if (c->rep==REP_JOINTS)
196  CreateFileName(NULL,c->fw,"_explore",JOINTS_EXT,&fn);
197  else
198  CreateFileName(NULL,c->fw,"_explore",LINKS_EXT,&fn);
199  f=fopen(GetFileFullName(&fn),"w");
200  if (!f)
201  Error("Can not open output file for dofs from cuikexplore");
202 
203  fprintf(stderr,"\n\n\nSaving configuration to : %s\n",GetFileFullName(&fn));
204 
205  for(i=0;i<c->m;i++)
206  fprintf(f,"%.16f ",c->point[i]);
207  fprintf(f,"\n");
208 
209  fclose(f);
210  DeleteFileName(&fn);
211 }
212 
213 void on_cuikexplore_step_changed(GtkEntry *entry,
214  gpointer user_data)
215 {
217  double newStep;
218  char string[20];
219 
220  c=(TCuikexploreControl *)user_data;
221  newStep=atof(gtk_entry_get_text(entry));
222  if (newStep==0)
223  fprintf(stderr,"Error in the input step\n");
224  else
225  {
226  c->step=newStep;
227  fprintf(stderr,"New advance step: %g\n",c->step);
228  }
229  sprintf(string,"%f",c->step);
230  gtk_entry_set_text(entry,string);
231 }
232 
233 void on_cuikexplore_reset(GtkButton *button,
234  gpointer user_data)
235 {
237 
238  c=(TCuikexploreControl *)user_data;
239 
240  c->reset=TRUE;
241 }
void on_cuikexplore_down_pressed(GtkButton *button, gpointer user_data)
Callback function for the minus buttons.
#define REP_JOINTS
One of the possible values of the REPRESENTATION parameter.
Definition: parameters.h:60
#define FALSE
FALSE.
Definition: boolean.h:30
Data structure to hold the information about the name of a file.
Definition: filename.h:271
unsigned int * e2d
Definition: cuikexplore.h:31
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:188
unsigned int * d2e
Definition: cuikexplore.h:33
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:35
Definition of the cuikexplore control structure.
Definition: cuikexplore.h:23
unsigned int rep
Definition: cuikexplore.h:36
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.
#define LINKS_EXT
File extension for files with samples represented by the link poses.
Definition: filename.h:181
Headers of the GTK interface functions for cuikexplore.
Headers of the GTK support functions for cuikplay.