-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlimrendir_keyboardcommands.c
599 lines (524 loc) · 24.8 KB
/
limrendir_keyboardcommands.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
#include <gtk/gtk.h>
#include <gst/gst.h>
#include <arv.h>
#include <limrendir.h>
#include <logroutines.h>
// HELP (h)
void help(LrdViewer *viewer) {
printf("%s***** Available key bindings *****%s\n", tcCYN, tcNRM);
printf("%s*** Quality Of Life ***%s \n", tcMAG, tcNRM);
printf("h .................. Show help \n");
printf("q ................. Quit \n");
printf("F11 ................ Toggle fullscreen \n");
printf("m .................. Toggle window maximization \n");
printf("g .................. Toggle grid \n");
if (!is_record_button_active(viewer)) {
printf("%s*** Camera Control ***%s \n", tcMAG, tcNRM);
printf("+/- ................ Change exposure time (1 us) \n");
printf("Pg Up/Pg Down ...... Change exposure time (100 us) \n");
printf("b .................. Toggle use the maximum available frame rate \n");
printf("n .................. Set the exposure to have a maximum contrast (experimental) \n");
printf("%s*** Field Of View Manipulation ***%s \n", tcMAG, tcNRM);
printf("a .................. See the largest possible field of view \n");
printf("z .................. Zoom on the center of the current field of view \n");
printf("r .................. Toggle Region Of Interest mode \n");
printf("e,s,d,f (E,S,D,F)... Move upper left corner of ROI \n");
printf("i,j,k,l (I,J,K,L)... Move lower right corner of ROI \n");
printf("arrows (keypad) .... Move ROI as a whole \n");
printf("c .................. Crop to the Region Of Interest \n");
}
printf("%s*** Video Acquisition ***%s \n", tcMAG, tcNRM);
printf("SPACE .............. Toggle video acquisition \n");
}
void setup_help_popover (LrdViewer *viewer) {
// QOL
gtk_label_set_markup (GTK_LABEL (viewer->help_key_1), "<b>General Commands</b>\n"
"h\n"
"q\n"
"F11\n"
"m\n"
"g");
gtk_label_set_markup (GTK_LABEL (viewer->help_description_1), "\n"
"Print help\n"
"Quit\n"
"Toggle fullscreen\n"
"Toggle window maximization\n"
"Toggle grid");
// CAMERA CONTROL
gtk_label_set_markup (GTK_LABEL (viewer->help_key_2), "<b>Camera Control</b>\n"
"+/-\n"
"Pg Up/Pg Down\n"
"b\n"
"n");
gtk_label_set_markup (GTK_LABEL (viewer->help_description_2), "\n"
"Change exposure time (1 us)\n"
"Change exposure time (100 us)\n"
"Toggle maximum frame rate \n"
"Optimize exposure (experimental)");
// ROI
gtk_label_set_markup (GTK_LABEL (viewer->help_key_3), "<b>Field Of View Manipulation</b>\n"
"a\n"
"z\n"
"r\n"
"e,s,d,f \t\t(E,S,D,F)\n"
"i,j,k,l \t\t(I,J,K,L)\n"
"↑←↓→ \t(keypad)\n"
"c");
gtk_label_set_markup (GTK_LABEL (viewer->help_description_3), "\n"
"See the largest possible field of view\n"
"Zoom at the center of the FOV\n"
"Toggle Region Of Interest mode\n"
"Move upper left corner of ROI\n"
"Move lower right corner of ROI\n"
"Move ROI as a whole\n"
"Crop to the Region Of Interest");
// VIDEO ACQU
gtk_label_set_markup (GTK_LABEL (viewer->help_key_4), "<b>Video Acquisition</b>\n"
"SPACE");
gtk_label_set_markup (GTK_LABEL (viewer->help_description_4), "\n"
"Toggle video acquisition");
}
// ROI MANIPULATION
gboolean is_roi_possible(LrdViewer *viewer) {
const ArvPixelFormat pixel_format = arv_camera_get_pixel_format (viewer->camera, NULL);
const char *caps_string = arv_pixel_format_to_gst_caps_string (pixel_format);
if (pixel_format == ARV_PIXEL_FORMAT_MONO_8) {
return TRUE;
} else {
log_warning("This pixel format (%s) do not allow for ROI utilization (yet!). Use Mono8 instead.", caps_string);
return FALSE;
}
}
void constrain_roi(LrdViewer *viewer) {
gint width, height;
arv_camera_get_region (viewer->camera, NULL, NULL, &width, &height, NULL);
constrain_roi_to_field_of_view(viewer, width, height);
}
void constrain_roi_to_field_of_view(LrdViewer *viewer, int width, int height) {
// If no roi is defined, make default
if (viewer->roi_x == -1) {
viewer->roi_x = 0;
}
if (viewer->roi_y == -1) {
viewer->roi_y = 0;
}
if (viewer->roi_w == -1) {
viewer->roi_w = width;
}
if (viewer->roi_h == -1) {
viewer->roi_h = height;
}
// Make sure that the roi is included in the field
if (viewer->roi_x < 0) {
viewer->roi_x = 0;
} else if (viewer->roi_x >= width) {
viewer->roi_x = width -1;
}
if (viewer->roi_y < 0) {
viewer->roi_y = 0;
} else if (viewer->roi_y >= height) {
viewer->roi_y = height -1;
}
if (viewer->roi_w < 1) {
viewer->roi_w = 1;
} else if (viewer->roi_w > width - viewer->roi_x) {
viewer->roi_w = width - viewer->roi_x;
}
if (viewer->roi_h < 1) {
viewer->roi_h = 1;
} else if (viewer->roi_h > height - viewer->roi_y) {
viewer->roi_h = height - viewer->roi_y;
}
}
// TOGGLE ROI VISIBILITY (r)
void toggle_roi(LrdViewer *viewer) {
if (is_roi_possible(viewer))
viewer->show_roi = !(viewer->show_roi);
constrain_roi(viewer);
update_status_bar_cb(viewer);
}
// ROI MOVEMENT
enum roiMovementDirection{ROI_DIRECTION_NONE, ROI_DIRECTION_RIGHT, ROI_DIRECTION_LEFT, ROI_DIRECTION_UP, ROI_DIRECTION_DOWN};
enum roiMovementAmplitude{ROI_AMPLITUDE_NONE = 0, ROI_AMPLITUDE_SMALL = 1, ROI_AMPLITUDE_LARGE = 20};
void move_roi_whole(LrdViewer *viewer, enum roiMovementDirection direction, enum roiMovementAmplitude amplitude) {
if (viewer->show_roi) {
if (direction == ROI_DIRECTION_RIGHT) {
viewer->roi_x += (int) amplitude;
} else if (direction == ROI_DIRECTION_LEFT) {
viewer->roi_x -= (int) amplitude;
} else if (direction == ROI_DIRECTION_UP) {
viewer->roi_y -= (int) amplitude;
} else if (direction == ROI_DIRECTION_DOWN) {
viewer->roi_y += (int) amplitude;
}
constrain_roi(viewer);
update_status_bar_cb(viewer);
}
}
void move_roi_lower_right_corner(LrdViewer *viewer, enum roiMovementDirection direction, enum roiMovementAmplitude amplitude) {
if (viewer->show_roi) {
if (direction == ROI_DIRECTION_RIGHT) {
viewer->roi_w += (int) amplitude;
} else if (direction == ROI_DIRECTION_LEFT) {
viewer->roi_w -= (int) amplitude;
} else if (direction == ROI_DIRECTION_UP) {
viewer->roi_h -= (int) amplitude;
} else if (direction == ROI_DIRECTION_DOWN) {
viewer->roi_h += (int) amplitude;
}
constrain_roi(viewer);
update_status_bar_cb(viewer);
}
}
void move_roi_upper_left_corner(LrdViewer *viewer, enum roiMovementDirection direction, enum roiMovementAmplitude amplitude) {
if (viewer->show_roi) {
if (direction == ROI_DIRECTION_RIGHT) {
viewer->roi_x += (int) amplitude;
viewer->roi_w -= (int) amplitude;
} else if (direction == ROI_DIRECTION_LEFT) {
viewer->roi_x -= (int) amplitude;
viewer->roi_w += (int) amplitude;
} else if (direction == ROI_DIRECTION_UP) {
viewer->roi_y -= (int) amplitude;
viewer->roi_h += (int) amplitude;
} else if (direction == ROI_DIRECTION_DOWN) {
viewer->roi_y += (int) amplitude;
viewer->roi_h -= (int) amplitude;
}
constrain_roi(viewer);
update_status_bar_cb(viewer);
}
}
// ROI QOL ROUTINES
void crop_to_roi(LrdViewer *viewer) {
if (!(viewer->show_roi)) {
return;
}
log_debug("Cropping to ROI");
log_trace("====== CROP Start");
gint old_x, old_y, old_width, old_height;
arv_camera_get_region (viewer->camera, &old_x, &old_y, &old_width, &old_height, NULL);
log_trace("Old region: x: %d ; y: %d ; w: %d ; h: %d", old_x, old_y, old_width, old_height);
log_trace("Old ROI: x: %d ; y: %d ; w: %d ; h: %d", viewer->roi_x, viewer->roi_y, viewer->roi_w, viewer->roi_h);
int new_x = old_x + viewer->roi_x;
int new_y = old_y + viewer->roi_y;
int new_width = viewer->roi_w;
int new_height = viewer->roi_h;
log_trace("New target region: x: %d ; y: %d ; w: %d ; h: %d", new_x, new_y, new_width, new_height);
new_x = new_x - new_x%arv_camera_get_x_offset_increment (viewer->camera, NULL);
new_y = new_y - new_x%arv_camera_get_y_offset_increment (viewer->camera, NULL);
new_width = new_width - new_width%arv_camera_get_width_increment (viewer->camera, NULL);
new_height = new_height - new_height%arv_camera_get_height_increment (viewer->camera, NULL);
log_trace("New target region: x: %d ; y: %d ; w: %d ; h: %d (INCREMENT COMPLIANT)", new_x, new_y, new_width, new_height);
log_trace("=== CROP GoToCameraListMode");
select_mode (viewer, TRN_VIEWER_MODE_CAMERA_LIST);
log_trace("=== CROP ChangeWidth");
gtk_spin_button_set_value (GTK_SPIN_BUTTON(viewer->camera_width), new_width);
log_trace("=== CROP ChangeHeight");
gtk_spin_button_set_value (GTK_SPIN_BUTTON(viewer->camera_height), new_height);
log_trace("=== CROP ChangeX");
gtk_spin_button_set_value (GTK_SPIN_BUTTON(viewer->camera_x), new_x);
log_trace("=== CROP ChangeY");
gtk_spin_button_set_value (GTK_SPIN_BUTTON(viewer->camera_y), new_y);
// DEFAULT ROI
log_trace("=== CROP UpdateROI");
viewer->roi_x = 0;
viewer->roi_y = 0;
viewer->roi_w = new_width;
viewer->roi_h = new_height;
if (is_roi_possible(viewer))
viewer->show_roi = TRUE;
log_trace("=== CROP BackToVideoMode");
select_mode (viewer, TRN_VIEWER_MODE_VIDEO);
apply_max_frame_rate_if_wanted (NULL, viewer);
log_trace("====== CROP End");
}
void see_whole_field_of_view(LrdViewer *viewer) {
log_debug("Seeing all the field of view");
log_trace("=== Start VIEWALL");
gint old_x, old_y, old_w, old_h;
arv_camera_get_region (viewer->camera, &old_x, &old_y, &old_w, &old_h, NULL);
log_trace("Old region: x: %d ; y: %d ; w: %d ; h: %d", old_x, old_y, old_w, old_h);
// This ROI is the whole current field of view
int new_roi_x = old_x;
int new_roi_y = old_y;
int new_roi_w = old_w;
int new_roi_h = old_h;
log_trace("Old ROI: x: %d ; y: %d ; w: %d ; h: %d", viewer->roi_x, viewer->roi_y, viewer->roi_w, viewer->roi_h);
if (viewer->show_roi) {
// If there is a used roi, use it instead
new_roi_x += viewer->roi_x;
new_roi_y += viewer->roi_y;
new_roi_w = viewer->roi_w;
new_roi_h = viewer->roi_h;
}
log_trace("New ROI: x: %d ; y: %d ; w: %d ; h: %d", viewer->roi_x, viewer->roi_y, viewer->roi_w, viewer->roi_h);
gint min_x, min_y, max_w, max_h;
arv_camera_get_x_offset_bounds(viewer->camera, &min_x, NULL, NULL);
arv_camera_get_y_offset_bounds(viewer->camera, &min_y, NULL, NULL);
arv_camera_get_width_bounds(viewer->camera, NULL, &max_w, NULL);
arv_camera_get_height_bounds (viewer->camera, NULL, &max_h, NULL);
/*
* FOR SOME CAMERAS (Arv-Fake par ex), arv_camera_get_width_bounds renvoie les bornes ABSOLUES
* POUR D'AUTRES (la manta par ex), arv_camera_get_width_bounds renvoie les bornes possibles sachant l'offset x.
* DANS LE DOUTE on blinde et on met un gros truc dans la max region. Au pire ca ne sera pas pris en compte.
*/
max_w += old_x;
max_h += old_y;
log_trace("Max region: x: %d ; y: %d ; w: %d ; h: %d", min_x, min_y, max_w, max_h);
if (old_x == min_x && old_y == min_y && old_w == max_w && old_h == max_h) {
log_debug("The old fov is already the max fov.");
return;
}
// Setting the range to be sure that the new values will be accepted.
// This is of no consequence since these ranges are redefined after in update_camera_region (called by camera_region_cb)
gtk_spin_button_set_range (GTK_SPIN_BUTTON(viewer->camera_width), 0, max_w + 1);
gtk_spin_button_set_range (GTK_SPIN_BUTTON(viewer->camera_height), 0, max_h + 1);
select_mode (viewer, TRN_VIEWER_MODE_CAMERA_LIST);
g_signal_handler_block (viewer->camera_x, viewer->camera_x_changed);
g_signal_handler_block (viewer->camera_y, viewer->camera_y_changed);
g_signal_handler_block (viewer->camera_width, viewer->camera_width_changed);
g_signal_handler_block (viewer->camera_height, viewer->camera_height_changed);
gtk_spin_button_set_value (GTK_SPIN_BUTTON(viewer->camera_x), min_x);
gtk_spin_button_set_value (GTK_SPIN_BUTTON(viewer->camera_y), min_y);
gtk_spin_button_set_value (GTK_SPIN_BUTTON(viewer->camera_width), max_w);
gtk_spin_button_set_value (GTK_SPIN_BUTTON(viewer->camera_height), max_h);
g_signal_handler_unblock (viewer->camera_x, viewer->camera_x_changed);
g_signal_handler_unblock (viewer->camera_y, viewer->camera_y_changed);
g_signal_handler_unblock (viewer->camera_width, viewer->camera_width_changed);
g_signal_handler_unblock (viewer->camera_height, viewer->camera_height_changed);
if (is_roi_possible(viewer)) {
viewer->roi_x = new_roi_x;
viewer->roi_y = new_roi_y;
viewer->roi_w = new_roi_w;
viewer->roi_h = new_roi_h;
viewer->show_roi = TRUE;
}
camera_region_cb(NULL, viewer);
select_mode (viewer, TRN_VIEWER_MODE_VIDEO);
// update_status_bar_cb(viewer);
log_trace("=== End VIEWALL");
}
void zoomin(LrdViewer *viewer) {
log_debug("Zooming");
log_trace("====== ZOOM Start");
gint old_x, old_y, old_w, old_h;
arv_camera_get_region (viewer->camera, &old_x, &old_y, &old_w, &old_h, NULL);
log_trace("Old region: x: %d ; y: %d ; w: %d ; h: %d", old_x, old_y, old_w, old_h);
viewer->roi_x = old_w/4;
viewer->roi_y = old_h/4;
viewer->roi_w = old_w/2;
viewer->roi_h = old_h/2;
log_trace("New ROI: x: %d ; y: %d ; w: %d ; h: %d", viewer->roi_x, viewer->roi_y, viewer->roi_w, viewer->roi_h);
viewer->show_roi = gtk_true();
crop_to_roi(viewer);
viewer->show_roi = gtk_false();
log_trace("====== ZOOM End");
}
// TOGGLE GRID (g)
void toggle_grid(LrdViewer *viewer) {
if (viewer->grid_type == GRID_NOGRID) {
viewer->grid_type = GRID_HORIZONTAL;
} else if (viewer->grid_type == GRID_HORIZONTAL) {
viewer->grid_type = GRID_BOTH;
} else if (viewer->grid_type == GRID_BOTH) {
viewer->grid_type = GRID_VERTICAL;
} else if (viewer->grid_type == GRID_VERTICAL) {
viewer->grid_type = GRID_NOGRID;
}
log_debug("Switched to a new grid : %d.", viewer->grid_type);
const ArvPixelFormat pixel_format = arv_camera_get_pixel_format (viewer->camera, NULL);
if (pixel_format != ARV_PIXEL_FORMAT_MONO_8) {
const char *caps_string = arv_pixel_format_to_gst_caps_string (pixel_format);
printf("This pixel format (%s) do not allow for grid utilization (yet!). Use Mono8 instead.", caps_string);
}
}
// CHANGE EXPOSURE (+/-/Pg Up/Pg Down)
void change_exposure(LrdViewer *viewer, GtkSpinType direction) {
gtk_spin_button_spin (GTK_SPIN_BUTTON (viewer->exposure_spin_button), direction, 1);
exposure_spin_cb (GTK_SPIN_BUTTON (viewer->exposure_spin_button), viewer);
}
// TOGGLE RECORDING (space)
void toggle_recording(LrdViewer *viewer) {
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(viewer->record_button),!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(viewer->record_button)));
}
// QUIT (q)
void quit(LrdViewer *viewer) {
if (is_record_button_active(viewer)) {
stop_recording (viewer);
}
gtk_window_close (GTK_WINDOW (viewer->main_window));
}
// FULLSCREEN (F11)
void toggle_fullscreen(LrdViewer *viewer) {
if (!viewer->is_fullscreen) {
gtk_window_fullscreen (GTK_WINDOW (viewer->main_window));
viewer->is_fullscreen = TRUE;
} else {
gtk_window_unfullscreen (GTK_WINDOW (viewer->main_window));
viewer->is_fullscreen = FALSE;
}
}
// MAXIMIZE (m)
void toggle_maximize(LrdViewer *viewer) {
if (!gtk_window_is_maximized(GTK_WINDOW (viewer->main_window))) {
gtk_window_maximize(GTK_WINDOW (viewer->main_window));
} else {
gtk_window_unmaximize(GTK_WINDOW (viewer->main_window));
}
}
// GENERAL CONTROL
gint key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer data)
{
log_trace("The keysim named `%s' was pressed", gdk_keyval_name(event->keyval));
LrdViewer *viewer = data;
switch (event->keyval) {
case GDK_KEY_g:
toggle_grid(viewer);
break;
case GDK_KEY_F11:
toggle_fullscreen(viewer);
break;
case GDK_KEY_m:
toggle_maximize(viewer);
break;
case GDK_KEY_space:
toggle_recording(viewer);
break;
case GDK_KEY_h:
help(viewer);
break;
case GDK_KEY_q:
quit(viewer);
break;
default:
break;
}
if (!is_record_button_active(viewer)) {
switch (event->keyval) {
case GDK_KEY_n:
// best_exposure_search_blocking(viewer);
best_exposure_search_nonblocking(viewer);
break;
case GDK_KEY_b:
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (viewer->max_frame_rate_button), !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (viewer->max_frame_rate_button)));
// apply_max_frame_rate_if_wanted(NULL, viewer); // redondant
break;
case GDK_KEY_a:
see_whole_field_of_view(viewer);
break;
case GDK_KEY_c:
crop_to_roi(viewer);
break;
case GDK_KEY_z:
zoomin(viewer);
break;
case GDK_KEY_Up:
move_roi_whole(viewer, ROI_DIRECTION_UP, ROI_AMPLITUDE_SMALL);
break;
case GDK_KEY_Left:
move_roi_whole(viewer, ROI_DIRECTION_LEFT, ROI_AMPLITUDE_SMALL);
break;
case GDK_KEY_Down:
move_roi_whole(viewer, ROI_DIRECTION_DOWN, ROI_AMPLITUDE_SMALL);
break;
case GDK_KEY_Right:
move_roi_whole(viewer, ROI_DIRECTION_RIGHT, ROI_AMPLITUDE_SMALL);
break;
case GDK_KEY_KP_Up:
case GDK_KEY_KP_8:
move_roi_whole(viewer, ROI_DIRECTION_UP, ROI_AMPLITUDE_LARGE);
break;
case GDK_KEY_KP_Left:
case GDK_KEY_KP_4:
move_roi_whole(viewer, ROI_DIRECTION_LEFT, ROI_AMPLITUDE_LARGE);
break;
case GDK_KEY_KP_Down:
case GDK_KEY_KP_2:
move_roi_whole(viewer, ROI_DIRECTION_DOWN, ROI_AMPLITUDE_LARGE);
break;
case GDK_KEY_KP_Right:
case GDK_KEY_KP_6:
move_roi_whole(viewer, ROI_DIRECTION_RIGHT, ROI_AMPLITUDE_LARGE);
break;
case GDK_KEY_e:
move_roi_upper_left_corner(viewer, ROI_DIRECTION_UP, ROI_AMPLITUDE_SMALL);
break;
case GDK_KEY_s:
move_roi_upper_left_corner(viewer, ROI_DIRECTION_LEFT, ROI_AMPLITUDE_SMALL);
break;
case GDK_KEY_d:
move_roi_upper_left_corner(viewer, ROI_DIRECTION_DOWN, ROI_AMPLITUDE_SMALL);
break;
case GDK_KEY_f:
move_roi_upper_left_corner(viewer, ROI_DIRECTION_RIGHT, ROI_AMPLITUDE_SMALL);
break;
case GDK_KEY_E:
move_roi_upper_left_corner(viewer, ROI_DIRECTION_UP, ROI_AMPLITUDE_LARGE);
break;
case GDK_KEY_S:
move_roi_upper_left_corner(viewer, ROI_DIRECTION_LEFT, ROI_AMPLITUDE_LARGE);
break;
case GDK_KEY_D:
move_roi_upper_left_corner(viewer, ROI_DIRECTION_DOWN, ROI_AMPLITUDE_LARGE);
break;
case GDK_KEY_F:
move_roi_upper_left_corner(viewer, ROI_DIRECTION_RIGHT, ROI_AMPLITUDE_LARGE);
break;
case GDK_KEY_i:
move_roi_lower_right_corner(viewer, ROI_DIRECTION_UP, ROI_AMPLITUDE_SMALL);
break;
case GDK_KEY_j:
move_roi_lower_right_corner(viewer, ROI_DIRECTION_LEFT, ROI_AMPLITUDE_SMALL);
break;
case GDK_KEY_k:
move_roi_lower_right_corner(viewer, ROI_DIRECTION_DOWN, ROI_AMPLITUDE_SMALL);
break;
case GDK_KEY_l:
move_roi_lower_right_corner(viewer, ROI_DIRECTION_RIGHT, ROI_AMPLITUDE_SMALL);
break;
case GDK_KEY_I:
move_roi_lower_right_corner(viewer, ROI_DIRECTION_UP, ROI_AMPLITUDE_LARGE);
break;
case GDK_KEY_J:
move_roi_lower_right_corner(viewer, ROI_DIRECTION_LEFT, ROI_AMPLITUDE_LARGE);
break;
case GDK_KEY_K:
move_roi_lower_right_corner(viewer, ROI_DIRECTION_DOWN, ROI_AMPLITUDE_LARGE);
break;
case GDK_KEY_L:
move_roi_lower_right_corner(viewer, ROI_DIRECTION_RIGHT, ROI_AMPLITUDE_LARGE);
break;
case GDK_KEY_r:
toggle_roi(viewer);
break;
case GDK_KEY_plus:
change_exposure(viewer, GTK_SPIN_STEP_FORWARD);
break;
case GDK_KEY_minus:
change_exposure(viewer, GTK_SPIN_STEP_BACKWARD);
break;
case GDK_KEY_Page_Up:
change_exposure(viewer, GTK_SPIN_PAGE_FORWARD);
break;
case GDK_KEY_Page_Down:
change_exposure(viewer, GTK_SPIN_PAGE_BACKWARD);
break;
default:
break;
}
}
}
// Key listener toggle
void start_key_listener(LrdViewer *viewer) {
gtk_widget_add_events(viewer->main_window, GDK_KEY_PRESS_MASK);
viewer->keypress_handler_id = g_signal_connect (G_OBJECT (viewer->main_window), "key_press_event",
G_CALLBACK (key_press_cb), viewer);
}
void stop_key_listener(LrdViewer *viewer) {
if (viewer->keypress_handler_id != 0) {
// gtk_widget_add_events(viewer->main_window, GDK_KEY_PRESS_MASK);
g_signal_handler_disconnect (G_OBJECT (viewer->main_window), viewer->keypress_handler_id);
}
viewer->keypress_handler_id = 0;
}