49 #include <visp/vpConfig.h>
59 #include <visp/vpDisplay.h>
60 #include <visp/vpDisplayX.h>
63 #include <visp/vpDebug.h>
64 #include <visp/vpDisplayException.h>
67 #include <visp/vpMath.h>
83 : display(NULL), window(), Ximage(NULL), lut(), context(),
84 screen(0), planes(0), event(), pixmap(), x_color(NULL),
85 screen_depth(8), xcolor(), values(), size(0), ximage_data_init(false),
86 RMask(0), GMask(0), BMask(0), RShift(0), GShift(0), BShift(0)
88 init ( I, x, y, title ) ;
105 : display(NULL), window(), Ximage(NULL), lut(), context(),
106 screen(0), planes(0), event(), pixmap(), x_color(NULL),
107 screen_depth(8), xcolor(), values(), size(0), ximage_data_init(false),
108 RMask(0), GMask(0), BMask(0), RShift(0), GShift(0), BShift(0)
110 init ( I, x, y, title ) ;
136 : display(NULL), window(), Ximage(NULL), lut(), context(),
137 screen(0), planes(0), event(), pixmap(), x_color(NULL),
138 screen_depth(8), xcolor(), values(), size(0), ximage_data_init(false),
139 RMask(0), GMask(0), BMask(0), RShift(0), GShift(0), BShift(0)
145 title_ = std::string(title);
147 title_ = std::string(
" ");
170 : display(NULL), window(), Ximage(NULL), lut(), context(),
171 screen(0), planes(0), event(), pixmap(), x_color(NULL),
172 screen_depth(8), xcolor(), values(), size(0), ximage_data_init(false),
173 RMask(0), GMask(0), BMask(0), RShift(0), GShift(0), BShift(0)
197 if (x_color == NULL) {
209 title_ = std::string(title);
211 title_ = std::string(
" ");
220 hints.flags = USPosition;
228 display = XOpenDisplay ( NULL );
229 if ( display == NULL )
231 vpERROR_TRACE (
"Can't connect display on server %s.\n", XDisplayName ( NULL ) );
233 "Can't connect display on server." ) ) ;
236 screen = DefaultScreen ( display );
237 lut = DefaultColormap ( display, screen );
238 screen_depth = (
unsigned int)DefaultDepth ( display, screen );
240 if ( ( window = XCreateSimpleWindow ( display, RootWindow ( display, screen ),
242 BlackPixel ( display, screen ),
243 WhitePixel ( display, screen ) ) ) == 0 )
247 "Can't create window." ) ) ;
253 if ( screen_depth == 8 )
255 lut = XCreateColormap ( display, window,
256 DefaultVisual ( display, screen ), AllocAll ) ;
257 xcolor.flags = DoRed | DoGreen | DoBlue ;
259 for (
unsigned int i = 0 ; i < 256 ; i++ )
262 xcolor.red = 256 * i;
263 xcolor.green = 256 * i;
264 xcolor.blue = 256 * i;
265 XStoreColor ( display, lut, &xcolor );
268 XSetWindowColormap ( display, window, lut ) ;
269 XInstallColormap ( display, lut ) ;
272 else if ( screen_depth == 16 )
274 for (
unsigned int i = 0; i < 256; i ++ )
277 xcolor.red = xcolor.green = xcolor.blue = 256 * i;
278 if ( XAllocColor ( display, lut, &xcolor ) == 0 )
280 vpERROR_TRACE (
"Can't allocate 256 colors. Only %d allocated.", i );
282 "Can't allocate 256 colors." ) ) ;
284 colortable[i] = xcolor.pixel;
287 XSetWindowColormap ( display, window, lut ) ;
288 XInstallColormap ( display, lut ) ;
290 Visual *visual = DefaultVisual (display, screen);
291 RMask = visual->red_mask;
292 GMask = visual->green_mask;
293 BMask = visual->blue_mask;
295 RShift = 15 -
getMsb(RMask);
296 GShift = 15 -
getMsb(GMask);
297 BShift = 15 -
getMsb(BMask);
303 switch ( screen_depth )
311 xcolor.red = 256 * 192;
312 xcolor.green = 256 * 192;
313 xcolor.blue = 256 * 192;
314 XStoreColor ( display, lut, &xcolor );
319 xcolor.red = 256 * 128;
320 xcolor.green = 256 * 128;
321 xcolor.blue = 256 * 128;
322 XStoreColor ( display, lut, &xcolor );
327 xcolor.red = 256 * 64;
328 xcolor.green = 256 * 64;
329 xcolor.blue = 256 * 64;
330 XStoreColor ( display, lut, &xcolor );
335 xcolor.red = 256 * 255;
336 xcolor.green = 256 * 140;
337 xcolor.blue = 256 * 140;
338 XStoreColor ( display, lut, &xcolor );
343 xcolor.red = 256 * 255;
346 XStoreColor ( display, lut, &xcolor );
351 xcolor.red = 256 * 128;
354 XStoreColor ( display, lut, &xcolor );
359 xcolor.red = 256 * 140;
360 xcolor.green = 256 * 255;
361 xcolor.blue = 256 * 140;
362 XStoreColor ( display, lut, &xcolor );
368 xcolor.green = 256 * 255;
370 XStoreColor ( display, lut, &xcolor );
376 xcolor.green = 256 * 128;
378 XStoreColor ( display, lut, &xcolor );
383 xcolor.red = 256 * 140;
384 xcolor.green = 256 * 140;
385 xcolor.blue = 256 * 255;
386 XStoreColor ( display, lut, &xcolor );
393 xcolor.blue = 256 * 255;
394 XStoreColor ( display, lut, &xcolor );
401 xcolor.blue = 256 * 128;
402 XStoreColor ( display, lut, &xcolor );
407 xcolor.red = 256 * 255;
408 xcolor.green = 256 * 255;
410 XStoreColor ( display, lut, &xcolor );
415 xcolor.red = 256 * 255;
416 xcolor.green = 256 * 165;
418 XStoreColor ( display, lut, &xcolor );
424 xcolor.green = 256 * 255;
425 xcolor.blue = 256 * 255;
426 XStoreColor ( display, lut, &xcolor );
431 xcolor.red = 256 * 128;
433 xcolor.blue = 256 * 128;
434 XStoreColor ( display, lut, &xcolor );
441 xcolor.flags = DoRed | DoGreen | DoBlue ;
448 XAllocColor ( display, lut, &xcolor );
453 xcolor.red = 256* 255;
454 xcolor.green = 256* 255;
455 xcolor.blue = 256* 255;
456 XAllocColor ( display, lut, &xcolor );
461 xcolor.red = 256 * 192;
462 xcolor.green = 256 * 192;
463 xcolor.blue = 256 * 192;
464 XAllocColor ( display, lut, &xcolor );
469 xcolor.red = 256 * 128;
470 xcolor.green = 256 * 128;
471 xcolor.blue = 256 * 128;
472 XAllocColor ( display, lut, &xcolor );
477 xcolor.red = 256 * 64;
478 xcolor.green = 256 * 64;
479 xcolor.blue = 256 * 64;
480 XAllocColor ( display, lut, &xcolor );
485 xcolor.red = 256 * 255;
486 xcolor.green = 256 * 140;
487 xcolor.blue = 256 * 140;
488 XAllocColor ( display, lut, &xcolor );
493 xcolor.red = 256* 255;
496 XAllocColor ( display, lut, &xcolor );
501 xcolor.red = 256* 128;
504 XAllocColor ( display, lut, &xcolor );
509 xcolor.red = 256 * 140;
510 xcolor.green = 256 * 255;
511 xcolor.blue = 256 * 140;
512 XAllocColor ( display, lut, &xcolor );
518 xcolor.green = 256*255;
520 XAllocColor ( display, lut, &xcolor );
526 xcolor.green = 256* 128;
528 XAllocColor ( display, lut, &xcolor );
533 xcolor.red = 256 * 140;
534 xcolor.green = 256 * 140;
535 xcolor.blue = 256 * 255;
536 XAllocColor ( display, lut, &xcolor );
543 xcolor.blue = 256* 255;
544 XAllocColor ( display, lut, &xcolor );
551 xcolor.blue = 256* 128;
552 XAllocColor ( display, lut, &xcolor );
557 xcolor.red = 256 * 255;
558 xcolor.green = 256 * 255;
560 XAllocColor ( display, lut, &xcolor );
565 xcolor.red = 256 * 255;
566 xcolor.green = 256 * 165;
568 XAllocColor ( display, lut, &xcolor );
574 xcolor.green = 256 * 255;
575 xcolor.blue = 256 * 255;
576 XAllocColor ( display, lut, &xcolor );
581 xcolor.red = 256 * 128;
583 xcolor.blue = 256 * 128;
584 XAllocColor ( display, lut, &xcolor );
590 XSetStandardProperties ( display, window, this->
title_.c_str(), this->
title_.c_str(), None, 0, 0, &hints );
591 XMapWindow ( display, window ) ;
593 XSelectInput ( display, window,
595 ButtonPressMask | ButtonReleaseMask |
596 KeyPressMask | KeyReleaseMask |
597 StructureNotifyMask |
601 values.plane_mask = AllPlanes;
602 values.fill_style = FillSolid;
603 values.foreground = WhitePixel ( display, screen );
604 values.background = BlackPixel ( display, screen );
605 context = XCreateGC ( display, window,
606 GCPlaneMask | GCFillStyle | GCForeground | GCBackground,
609 if ( context == NULL )
613 "Can't create graphics context" ) ) ;
618 pixmap = XCreatePixmap ( display, window,
width,
height, screen_depth );
626 Ximage = XCreateImage ( display, DefaultVisual ( display, screen ),
627 screen_depth, ZPixmap, 0, NULL,
630 Ximage->data = (
char * ) malloc ( I.
getHeight() * (
unsigned int)Ximage->bytes_per_line );
631 ximage_data_init =
true;
636 XStoreName ( display, window,
title_.c_str() );
638 XSync ( display, 1 );
662 if (x_color == NULL) {
668 title_ = std::string(title);
670 title_ = std::string(
" ");
679 hints.flags = USPosition;
688 if ( ( display = XOpenDisplay ( NULL ) ) == NULL )
690 vpERROR_TRACE (
"Can't connect display on server %s.\n", XDisplayName ( NULL ) );
692 "Can't connect display on server." ) ) ;
695 screen = DefaultScreen ( display );
696 lut = DefaultColormap ( display, screen );
697 screen_depth = (
unsigned int)DefaultDepth ( display, screen );
701 if ( ( window = XCreateSimpleWindow ( display, RootWindow ( display, screen ),
704 BlackPixel ( display, screen ),
705 WhitePixel ( display, screen ) ) ) == 0 )
709 "Can't create window." ) ) ;
715 if ( screen_depth == 8 )
717 lut = XCreateColormap ( display, window,
718 DefaultVisual ( display, screen ), AllocAll ) ;
719 xcolor.flags = DoRed | DoGreen | DoBlue ;
721 for (
unsigned int i = 0 ; i < 256 ; i++ )
724 xcolor.red = 256 * i;
725 xcolor.green = 256 * i;
726 xcolor.blue = 256 * i;
727 XStoreColor ( display, lut, &xcolor );
730 XSetWindowColormap ( display, window, lut ) ;
731 XInstallColormap ( display, lut ) ;
734 else if ( screen_depth == 16 )
736 for (
unsigned int i = 0; i < 256; i ++ )
739 xcolor.red = xcolor.green = xcolor.blue = 256 * i;
740 if ( XAllocColor ( display, lut, &xcolor ) == 0 )
742 vpERROR_TRACE (
"Can't allocate 256 colors. Only %d allocated.", i );
744 "Can't allocate 256 colors." ) ) ;
746 colortable[i] = xcolor.pixel;
749 Visual *visual = DefaultVisual (display, screen);
750 RMask = visual->red_mask;
751 GMask = visual->green_mask;
752 BMask = visual->blue_mask;
754 RShift = 15 -
getMsb(RMask);
755 GShift = 15 -
getMsb(GMask);
756 BShift = 15 -
getMsb(BMask);
758 XSetWindowColormap ( display, window, lut ) ;
759 XInstallColormap ( display, lut ) ;
766 switch ( screen_depth )
775 xcolor.red = 256 * 192;
776 xcolor.green = 256 * 192;
777 xcolor.blue = 256 * 192;
778 XStoreColor ( display, lut, &xcolor );
783 xcolor.red = 256 * 128;
784 xcolor.green = 256 * 128;
785 xcolor.blue = 256 * 128;
786 XStoreColor ( display, lut, &xcolor );
791 xcolor.red = 256 * 64;
792 xcolor.green = 256 * 64;
793 xcolor.blue = 256 * 64;
794 XStoreColor ( display, lut, &xcolor );
799 xcolor.red = 256 * 255;
800 xcolor.green = 256 * 140;
801 xcolor.blue = 256 * 140;
802 XStoreColor ( display, lut, &xcolor );
807 xcolor.red = 256 * 255;
810 XStoreColor ( display, lut, &xcolor );
815 xcolor.red = 256 * 128;
818 XStoreColor ( display, lut, &xcolor );
823 xcolor.red = 256 * 140;
824 xcolor.green = 256 * 255;
825 xcolor.blue = 256 * 140;
826 XStoreColor ( display, lut, &xcolor );
832 xcolor.green = 256 * 255;
834 XStoreColor ( display, lut, &xcolor );
840 xcolor.green = 256 * 128;
842 XStoreColor ( display, lut, &xcolor );
847 xcolor.red = 256 * 140;
848 xcolor.green = 256 * 140;
849 xcolor.blue = 256 * 255;
850 XStoreColor ( display, lut, &xcolor );
857 xcolor.blue = 256 * 255;
858 XStoreColor ( display, lut, &xcolor );
865 xcolor.blue = 256 * 128;
866 XStoreColor ( display, lut, &xcolor );
871 xcolor.red = 256 * 255;
872 xcolor.green = 256 * 255;
874 XStoreColor ( display, lut, &xcolor );
879 xcolor.red = 256 * 255;
880 xcolor.green = 256 * 165;
882 XStoreColor ( display, lut, &xcolor );
888 xcolor.green = 256 * 255;
889 xcolor.blue = 256 * 255;
890 XStoreColor ( display, lut, &xcolor );
895 xcolor.red = 256 * 128;
897 xcolor.blue = 256 * 128;
898 XStoreColor ( display, lut, &xcolor );
905 xcolor.flags = DoRed | DoGreen | DoBlue ;
912 XAllocColor ( display, lut, &xcolor );
917 xcolor.red = 256* 255;
918 xcolor.green = 256* 255;
919 xcolor.blue = 256* 255;
920 XAllocColor ( display, lut, &xcolor );
925 xcolor.red = 256 * 192;
926 xcolor.green = 256 * 192;
927 xcolor.blue = 256 * 192;
928 XAllocColor ( display, lut, &xcolor );
933 xcolor.red = 256 * 128;
934 xcolor.green = 256 * 128;
935 xcolor.blue = 256 * 128;
936 XAllocColor ( display, lut, &xcolor );
941 xcolor.red = 256 * 64;
942 xcolor.green = 256 * 64;
943 xcolor.blue = 256 * 64;
944 XAllocColor ( display, lut, &xcolor );
949 xcolor.red = 256 * 255;
950 xcolor.green = 256 * 140;
951 xcolor.blue = 256 * 140;
952 XAllocColor ( display, lut, &xcolor );
957 xcolor.red = 256* 255;
960 XAllocColor ( display, lut, &xcolor );
965 xcolor.red = 256* 128;
968 XAllocColor ( display, lut, &xcolor );
973 xcolor.red = 256 * 140;
974 xcolor.green = 256 * 255;
975 xcolor.blue = 256 * 140;
976 XAllocColor ( display, lut, &xcolor );
982 xcolor.green = 256*255;
984 XAllocColor ( display, lut, &xcolor );
990 xcolor.green = 256* 128;
992 XAllocColor ( display, lut, &xcolor );
997 xcolor.red = 256 * 140;
998 xcolor.green = 256 * 140;
999 xcolor.blue = 256 * 255;
1000 XAllocColor ( display, lut, &xcolor );
1007 xcolor.blue = 256* 255;
1008 XAllocColor ( display, lut, &xcolor );
1015 xcolor.blue = 256* 128;
1016 XAllocColor ( display, lut, &xcolor );
1021 xcolor.red = 256 * 255;
1022 xcolor.green = 256 * 255;
1024 XAllocColor ( display, lut, &xcolor );
1029 xcolor.red = 256 * 255;
1030 xcolor.green = 256 * 165;
1032 XAllocColor ( display, lut, &xcolor );
1038 xcolor.green = 256 * 255;
1039 xcolor.blue = 256 * 255;
1040 XAllocColor ( display, lut, &xcolor );
1045 xcolor.red = 256 * 128;
1047 xcolor.blue = 256 * 128;
1048 XAllocColor ( display, lut, &xcolor );
1054 XSetStandardProperties ( display, window, this->
title_.c_str(), this->
title_.c_str(), None, 0, 0, &hints );
1055 XMapWindow ( display, window ) ;
1057 XSelectInput ( display, window,
1059 ButtonPressMask | ButtonReleaseMask |
1060 KeyPressMask | KeyReleaseMask |
1061 StructureNotifyMask |
1065 values.plane_mask = AllPlanes;
1066 values.fill_style = FillSolid;
1067 values.foreground = WhitePixel ( display, screen );
1068 values.background = BlackPixel ( display, screen );
1069 context = XCreateGC ( display, window,
1070 GCPlaneMask | GCFillStyle | GCForeground | GCBackground,
1073 if ( context == NULL )
1077 "Can't create graphics context" ) ) ;
1081 pixmap = XCreatePixmap ( display, window,
width,
height, screen_depth );
1089 Ximage = XCreateImage ( display, DefaultVisual ( display, screen ),
1090 screen_depth, ZPixmap, 0, NULL,
1094 Ximage->data = (
char * ) malloc ( I.
getHeight() * (
unsigned int)Ximage->bytes_per_line );
1095 ximage_data_init =
true;
1100 XSync ( display,
true );
1102 XStoreName ( display, window,
title_.c_str() );
1134 hints.flags = USPosition;
1140 title_ = std::string(title);
1142 title_ = std::string(
" ");
1144 if ( ( display = XOpenDisplay ( NULL ) ) == NULL )
1146 vpERROR_TRACE (
"Can't connect display on server %s.\n", XDisplayName ( NULL ) );
1148 "Can't connect display on server." ) ) ;
1151 screen = DefaultScreen ( display );
1152 lut = DefaultColormap ( display, screen );
1153 screen_depth = (
unsigned int)DefaultDepth ( display, screen );
1155 vpTRACE (
"Screen depth: %d\n", screen_depth );
1157 if ( ( window = XCreateSimpleWindow ( display, RootWindow ( display, screen ),
1160 BlackPixel ( display, screen ),
1161 WhitePixel ( display, screen ) ) ) == 0 )
1165 "Can't create window." ) ) ;
1172 if ( screen_depth == 8 )
1174 lut = XCreateColormap ( display, window,
1175 DefaultVisual ( display, screen ), AllocAll ) ;
1176 xcolor.flags = DoRed | DoGreen | DoBlue ;
1178 for (
unsigned int i = 0 ; i < 256 ; i++ )
1181 xcolor.red = 256 * i;
1182 xcolor.green = 256 * i;
1183 xcolor.blue = 256 * i;
1184 XStoreColor ( display, lut, &xcolor );
1187 XSetWindowColormap ( display, window, lut ) ;
1188 XInstallColormap ( display, lut ) ;
1191 else if ( screen_depth == 16 )
1193 for (
unsigned int i = 0; i < 256; i ++ )
1196 xcolor.red = xcolor.green = xcolor.blue = 256 * i;
1197 if ( XAllocColor ( display, lut, &xcolor ) == 0 )
1199 vpERROR_TRACE (
"Can't allocate 256 colors. Only %d allocated.", i );
1201 "Can't allocate 256 colors." ) ) ;
1203 colortable[i] = xcolor.pixel;
1206 XSetWindowColormap ( display, window, lut ) ;
1207 XInstallColormap ( display, lut ) ;
1209 Visual *visual = DefaultVisual (display, screen);
1210 RMask = visual->red_mask;
1211 GMask = visual->green_mask;
1212 BMask = visual->blue_mask;
1214 RShift = 15 -
getMsb(RMask);
1215 GShift = 15 -
getMsb(GMask);
1216 BShift = 15 -
getMsb(BMask);
1224 switch ( screen_depth )
1234 xcolor.pixel = 254 ;
1235 xcolor.red = 256 * pcolor.
R;
1236 xcolor.green = 256 * pcolor.
G;
1237 xcolor.blue = 256 * pcolor.
B;
1238 XStoreColor ( display, lut, &xcolor );
1242 xcolor.pixel = 253 ;
1243 xcolor.red = 256 * pcolor.
R;
1244 xcolor.green = 256 * pcolor.
G;
1245 xcolor.blue = 256 * pcolor.
B;
1246 XStoreColor ( display, lut, &xcolor );
1250 xcolor.pixel = 252 ;
1251 xcolor.red = 256 * pcolor.
R;
1252 xcolor.green = 256 * pcolor.
G;
1253 xcolor.blue = 256 * pcolor.
B;
1254 XStoreColor ( display, lut, &xcolor );
1258 xcolor.pixel = 251 ;
1259 xcolor.red = 256 * pcolor.
R;
1260 xcolor.green = 256 * pcolor.
G;
1261 xcolor.blue = 256 * pcolor.
B;
1262 XStoreColor ( display, lut, &xcolor );
1266 xcolor.pixel = 250 ;
1267 xcolor.red = 256 * pcolor.
R;
1268 xcolor.green = 256 * pcolor.
G;
1269 xcolor.blue = 256 * pcolor.
B;
1270 XStoreColor ( display, lut, &xcolor );
1274 xcolor.pixel = 249 ;
1275 xcolor.red = 256 * pcolor.
R;
1276 xcolor.green = 256 * pcolor.
G;
1277 xcolor.blue = 256 * pcolor.
B;
1278 XStoreColor ( display, lut, &xcolor );
1282 xcolor.pixel = 248 ;
1283 xcolor.red = 256 * pcolor.
R;
1284 xcolor.green = 256 * pcolor.
G;
1285 xcolor.blue = 256 * pcolor.
B;
1286 XStoreColor ( display, lut, &xcolor );
1291 xcolor.red = 256 * pcolor.
R;
1292 xcolor.green = 256 * pcolor.
G;
1293 xcolor.blue = 256 * pcolor.
B;
1294 XStoreColor ( display, lut, &xcolor );
1298 xcolor.pixel = 246 ;
1299 xcolor.red = 256 * pcolor.
R;
1300 xcolor.green = 256 * pcolor.
G;
1301 xcolor.blue = 256 * pcolor.
B;
1302 XStoreColor ( display, lut, &xcolor );
1306 xcolor.pixel = 245 ;
1307 xcolor.red = 256 * pcolor.
R;
1308 xcolor.green = 256 * pcolor.
G;
1309 xcolor.blue = 256 * pcolor.
B;
1310 XStoreColor ( display, lut, &xcolor );
1315 xcolor.red = 256 * pcolor.
R;
1316 xcolor.green = 256 * pcolor.
G;
1317 xcolor.blue = 256 * pcolor.
B;
1318 XStoreColor ( display, lut, &xcolor );
1322 xcolor.pixel = 243 ;
1323 xcolor.red = 256 * pcolor.
R;
1324 xcolor.green = 256 * pcolor.
G;
1325 xcolor.blue = 256 * pcolor.
B;
1326 XStoreColor ( display, lut, &xcolor );
1331 xcolor.red = 256 * pcolor.
R;
1332 xcolor.green = 256 * pcolor.
G;
1333 xcolor.blue = 256 * pcolor.
B;
1334 XStoreColor ( display, lut, &xcolor );
1339 xcolor.red = 256 * pcolor.
R;
1340 xcolor.green = 256 * pcolor.
G;
1341 xcolor.blue = 256 * pcolor.
B;
1342 XStoreColor ( display, lut, &xcolor );
1347 xcolor.red = 256 * pcolor.
R;
1348 xcolor.green = 256 * pcolor.
G;
1349 xcolor.blue = 256 * pcolor.
B;
1350 XStoreColor ( display, lut, &xcolor );
1355 xcolor.red = 256 * pcolor.
R;
1356 xcolor.green = 256 * pcolor.
G;
1357 xcolor.blue = 256 * pcolor.
B;
1358 XStoreColor ( display, lut, &xcolor );
1365 xcolor.flags = DoRed | DoGreen | DoBlue ;
1370 xcolor.red = 256 * pcolor.
R;
1371 xcolor.green = 256 * pcolor.
G;
1372 xcolor.blue = 256 * pcolor.
B;
1373 XAllocColor ( display, lut, &xcolor );
1379 xcolor.red = 256 * pcolor.
R;
1380 xcolor.green = 256 * pcolor.
G;
1381 xcolor.blue = 256 * pcolor.
B;
1382 XAllocColor ( display, lut, &xcolor );
1388 xcolor.red = 256 * pcolor.
R;
1389 xcolor.green = 256 * pcolor.
G;
1390 xcolor.blue = 256 * pcolor.
B;
1391 XAllocColor ( display, lut, &xcolor );
1397 xcolor.red = 256 * pcolor.
R;
1398 xcolor.green = 256 * pcolor.
G;
1399 xcolor.blue = 256 * pcolor.
B;
1400 XAllocColor ( display, lut, &xcolor );
1406 xcolor.red = 256 * pcolor.
R;
1407 xcolor.green = 256 * pcolor.
G;
1408 xcolor.blue = 256 * pcolor.
B;
1409 XAllocColor ( display, lut, &xcolor );
1415 xcolor.red = 256 * pcolor.
R;
1416 xcolor.green = 256 * pcolor.
G;
1417 xcolor.blue = 256 * pcolor.
B;
1418 XAllocColor ( display, lut, &xcolor );
1424 xcolor.red = 256 * pcolor.
R;
1425 xcolor.green = 256 * pcolor.
G;
1426 xcolor.blue = 256 * pcolor.
B;
1427 XAllocColor ( display, lut, &xcolor );
1433 xcolor.red = 256 * pcolor.
R;
1434 xcolor.green = 256 * pcolor.
G;
1435 xcolor.blue = 256 * pcolor.
B;
1436 XAllocColor ( display, lut, &xcolor );
1442 xcolor.red = 256 * pcolor.
R;
1443 xcolor.green = 256 * pcolor.
G;
1444 xcolor.blue = 256 * pcolor.
B;
1445 XAllocColor ( display, lut, &xcolor );
1451 xcolor.red = 256 * pcolor.
R;
1452 xcolor.green = 256 * pcolor.
G;
1453 xcolor.blue = 256 * pcolor.
B;
1454 XAllocColor ( display, lut, &xcolor );
1460 xcolor.red = 256 * pcolor.
R;
1461 xcolor.green = 256 * pcolor.
G;
1462 xcolor.blue = 256 * pcolor.
B;
1463 XAllocColor ( display, lut, &xcolor );
1469 xcolor.red = 256 * pcolor.
R;
1470 xcolor.green = 256 * pcolor.
G;
1471 xcolor.blue = 256 * pcolor.
B;
1472 XAllocColor ( display, lut, &xcolor );
1478 xcolor.red = 256 * pcolor.
R;
1479 xcolor.green = 256 * pcolor.
G;
1480 xcolor.blue = 256 * pcolor.
B;
1481 XAllocColor ( display, lut, &xcolor );
1487 xcolor.red = 256 * pcolor.
R;
1488 xcolor.green = 256 * pcolor.
G;
1489 xcolor.blue = 256 * pcolor.
B;
1490 XAllocColor ( display, lut, &xcolor );
1496 xcolor.red = 256 * pcolor.
R;
1497 xcolor.green = 256 * pcolor.
G;
1498 xcolor.blue = 256 * pcolor.
B;
1499 XAllocColor ( display, lut, &xcolor );
1505 xcolor.red = 256 * pcolor.
R;
1506 xcolor.green = 256 * pcolor.
G;
1507 xcolor.blue = 256 * pcolor.
B;
1508 XAllocColor ( display, lut, &xcolor );
1514 xcolor.red = 256 * pcolor.
R;
1515 xcolor.green = 256 * pcolor.
G;
1516 xcolor.blue = 256 * pcolor.
B;
1517 XAllocColor ( display, lut, &xcolor );
1523 xcolor.red = 256 * pcolor.
R;
1524 xcolor.green = 256 * pcolor.
G;
1525 xcolor.blue = 256 * pcolor.
B;
1526 XAllocColor ( display, lut, &xcolor );
1532 XSetStandardProperties ( display, window, this->
title_.c_str(), this->
title_.c_str(), None, 0, 0, &hints );
1533 XMapWindow ( display, window ) ;
1535 XSelectInput ( display, window,
1537 ButtonPressMask | ButtonReleaseMask |
1538 KeyPressMask | KeyReleaseMask |
1539 StructureNotifyMask |
1543 values.plane_mask = AllPlanes;
1544 values.fill_style = FillSolid;
1545 values.foreground = WhitePixel ( display, screen );
1546 values.background = BlackPixel ( display, screen );
1547 context = XCreateGC ( display, window,
1548 GCPlaneMask | GCFillStyle | GCForeground | GCBackground,
1551 if ( context == NULL )
1555 "Can't create graphics context" ) ) ;
1559 pixmap = XCreatePixmap ( display, window,
width,
height, screen_depth );
1567 Ximage = XCreateImage ( display, DefaultVisual ( display, screen ),
1568 screen_depth, ZPixmap, 0, NULL,
1571 Ximage->data = (
char * ) malloc (
height * (
unsigned int)Ximage->bytes_per_line );
1572 ximage_data_init =
true;
1576 XSync ( display,
true );
1578 XStoreName ( display, window,
title_.c_str() );
1604 stringfont = XLoadFont (display, font) ;
1605 XSetFont (display, context, stringfont);
1618 "X not initialized" ) ) ;
1632 title_ = std::string(title);
1634 title_ = std::string(
" ");
1635 XStoreName ( display, window,
title_.c_str() );
1641 "X not initialized" ) ) ;
1656 XMoveWindow(display, window, winx, winy);
1662 "X not initialized" ) ) ;
1682 switch ( screen_depth )
1686 unsigned char *src_8 = NULL;
1687 unsigned char *dst_8 = NULL;
1688 src_8 = (
unsigned char * ) I.
bitmap;
1689 dst_8 = (
unsigned char * ) Ximage->data;
1695 unsigned char nivGris;
1700 nivGris = src_8[i] ;
1701 if ( nivGris > nivGrisMax )
1710 XPutImage ( display, pixmap, context, Ximage, 0, 0, 0, 0,
width,
height );
1711 XSetWindowBackgroundPixmap ( display, window, pixmap );
1718 unsigned short *dst_16 = (
unsigned short* ) Ximage->data;
1719 unsigned char *dst_8 = NULL;
1720 unsigned int bytes_per_line = (
unsigned int)Ximage->bytes_per_line;
1721 for (
unsigned int i = 0; i <
height ; i++ ) {
1722 dst_8 = (
unsigned char*) Ximage->data + i * bytes_per_line;
1723 dst_16 = (
unsigned short *) dst_8;
1724 for (
unsigned int j=0 ; j <
width; j++ )
1726 * ( dst_16 + j ) = (
unsigned short ) colortable[I[i][j]] ;
1731 XPutImage ( display, pixmap, context, Ximage, 0, 0, 0, 0,
width, height );
1732 XSetWindowBackgroundPixmap ( display, window, pixmap );
1741 unsigned char *dst_32 = NULL;
1743 dst_32 = (
unsigned char* ) Ximage->data;
1744 unsigned char *bitmap = I.
bitmap ;
1745 unsigned char *n = I.
bitmap + size_;
1747 while ( bitmap < n )
1749 unsigned char val = * ( bitmap++ );
1750 * ( dst_32 ++ ) = val;
1751 * ( dst_32 ++ ) = val;
1752 * ( dst_32 ++ ) = val;
1753 * ( dst_32 ++ ) = val;
1757 XPutImage ( display, pixmap, context, Ximage, 0, 0, 0, 0,
width, height );
1758 XSetWindowBackgroundPixmap ( display, window, pixmap );
1769 "X not initialized" ) ) ;
1787 switch ( screen_depth )
1790 unsigned short *dst_16 = NULL;
1791 unsigned char *dst_8 = NULL;
1793 unsigned int r, g, b;
1794 unsigned int bytes_per_line = (
unsigned int)Ximage->bytes_per_line;
1796 for (
unsigned int i = 0; i <
height ; i++ ) {
1797 dst_8 = (
unsigned char*) Ximage->data + i * bytes_per_line;
1798 dst_16 = (
unsigned short *) dst_8;
1799 for (
unsigned int j=0 ; j <
width; j++ )
1804 * ( dst_16 + j ) = (((r << 8) >> RShift) & RMask) |
1805 (((g << 8) >> GShift) & GMask) |
1806 (((b << 8) >> BShift) & BMask);
1811 XPutImage ( display, pixmap, context, Ximage, 0, 0, 0, 0,
width, height );
1812 XSetWindowBackgroundPixmap ( display, window, pixmap );
1822 unsigned char *dst_32 = NULL;
1823 dst_32 = (
unsigned char* ) Ximage->data;
1826 if (XImageByteOrder(display) == 1) {
1828 for (
unsigned int i = 0; i < sizeI ; i++ ) {
1829 *(dst_32++) = bitmap->A;
1830 *(dst_32++) = bitmap->R;
1831 *(dst_32++) = bitmap->G;
1832 *(dst_32++) = bitmap->B;
1838 for (
unsigned int i = 0; i < sizeI; i++ ) {
1839 *(dst_32++) = bitmap->B;
1840 *(dst_32++) = bitmap->G;
1841 *(dst_32++) = bitmap->R;
1842 *(dst_32++) = bitmap->A;
1847 XPutImage ( display, pixmap, context, Ximage, 0, 0, 0, 0,
width,
height );
1848 XSetWindowBackgroundPixmap ( display, window, pixmap );
1855 vpERROR_TRACE (
"Unsupported depth (%d bpp) for color display",
1858 "Unsupported depth for color display" ) ) ;
1865 "X not initialized" ) ) ;
1882 unsigned char *dst_32 = NULL;
1887 dst_32 = (
unsigned char* ) Ximage->data;
1889 for (
unsigned int i = 0; i <
width *
height; i++ )
1891 * ( dst_32 ++ ) = *I;
1892 * ( dst_32 ++ ) = *I;
1893 * ( dst_32 ++ ) = *I;
1894 * ( dst_32 ++ ) = *I;
1899 XPutImage ( display, pixmap, context, Ximage, 0, 0, 0, 0,
width, height );
1900 XSetWindowBackgroundPixmap ( display, window, pixmap );
1908 "X not initialized" ) ) ;
1929 const unsigned int w,
const unsigned int h )
1933 switch ( screen_depth )
1937 unsigned char *src_8 = NULL;
1938 unsigned char *dst_8 = NULL;
1939 src_8 = (
unsigned char * ) I.
bitmap;
1940 dst_8 = (
unsigned char * ) Ximage->data;
1945 unsigned char nivGris;
1949 unsigned int iwidth = I.
getWidth();
1951 src_8 = src_8 + (int)(iP.
get_i()*iwidth+ iP.
get_j());
1960 nivGris = *(src_8+j);
1961 if ( nivGris > nivGrisMax )
1964 *(dst_8+j) = nivGris;
1967 src_8 = src_8 + iwidth;
1968 dst_8 = dst_8 + this->
width;
1974 XPutImage ( display, pixmap, context, Ximage, (
int)iP.
get_u(), (int)iP.
get_v(), (int)iP.
get_u(), (int)iP.
get_v(), w, h );
1975 XSetWindowBackgroundPixmap ( display, window, pixmap );
1982 unsigned short *dst_16 = NULL;
1983 unsigned char *dst_8 = NULL;
1984 unsigned int bytes_per_line = (
unsigned int)Ximage->bytes_per_line;
1985 for (
unsigned int i = (
unsigned int)iP.
get_i(); i < (
unsigned int)(iP.
get_i()+h) ; i++ ) {
1986 dst_8 = (
unsigned char *) Ximage->data + i * bytes_per_line;
1987 dst_16 = (
unsigned short *) dst_8;
1988 for (
unsigned int j=(
unsigned int)iP.
get_j() ; j < (
unsigned int)(iP.
get_j()+w); j++ )
1990 * ( dst_16 + j ) = (
unsigned short ) colortable[I[i][j]] ;
2018 XPutImage ( display, pixmap, context, Ximage, (
int)iP.
get_u(), (int)iP.
get_v(), (int)iP.
get_u(), (int)iP.
get_v(), w, h );
2019 XSetWindowBackgroundPixmap ( display, window, pixmap );
2028 unsigned char *dst_32 = NULL;
2030 dst_32 = (
unsigned char* ) Ximage->data;
2031 unsigned char *src_8 = I.
bitmap ;
2034 unsigned int iwidth = I.
getWidth();
2036 src_8 = src_8 + (int)(iP.
get_i()*iwidth+ iP.
get_j());
2045 unsigned char val = *(src_8+j);
2046 *(dst_32+4*j) = val;
2047 *(dst_32+4*j+1) = val;
2048 *(dst_32+4*j+2) = val;
2049 *(dst_32+4*j+3) = val;
2052 src_8 = src_8 + iwidth;
2053 dst_32 = dst_32 + 4*this->
width;
2058 XPutImage ( display, pixmap, context, Ximage, (
int)iP.
get_u(), (int)iP.
get_v(), (int)iP.
get_u(), (int)iP.
get_v(), w, h );
2059 XSetWindowBackgroundPixmap ( display, window, pixmap );
2070 "X not initialized" ) ) ;
2091 const unsigned int w,
const unsigned int h )
2095 switch ( screen_depth )
2098 unsigned short *dst_16 = NULL;
2099 unsigned char *dst_8 = NULL;
2100 unsigned int r, g, b;
2101 unsigned int bytes_per_line = (
unsigned int)Ximage->bytes_per_line;
2102 for (
unsigned int i = (
unsigned int)iP.
get_i(); i < (
unsigned int)(iP.
get_i()+h) ; i++ ) {
2103 dst_8 = (
unsigned char *) Ximage->data + i * bytes_per_line;
2104 dst_16 = (
unsigned short *) dst_8;
2105 for (
unsigned int j=(
unsigned int)iP.
get_j() ; j < (
unsigned int)(iP.
get_j()+w); j++ )
2110 * ( dst_16 + j ) = (((r << 8) >> RShift) & RMask) |
2111 (((g << 8) >> GShift) & GMask) |
2112 (((b << 8) >> BShift) & BMask);
2116 XPutImage ( display, pixmap, context, Ximage, 0, 0, 0, 0,
width,
height );
2117 XSetWindowBackgroundPixmap ( display, window, pixmap );
2128 unsigned char *dst_32 = NULL;
2129 dst_32 = (
unsigned char* ) Ximage->data;
2133 unsigned int iwidth = I.
getWidth();
2135 src_32 = src_32 + (int)(iP.
get_i()*iwidth+ iP.
get_j());
2140 if (XImageByteOrder(display) == 1) {
2145 *(dst_32+4*j) = (src_32+j)->A;
2146 *(dst_32+4*j+1) = (src_32+j)->R;
2147 *(dst_32+4*j+2) = (src_32+j)->G;
2148 *(dst_32+4*j+3) = (src_32+j)->B;
2152 src_32 = src_32 + iwidth;
2153 dst_32 = dst_32 + 4*this->
width;
2163 *(dst_32+4*j) = (src_32+j)->B;
2164 *(dst_32+4*j+1) = (src_32+j)->G;
2165 *(dst_32+4*j+2) = (src_32+j)->R;
2166 *(dst_32+4*j+3) = (src_32+j)->A;
2170 src_32 = src_32 + iwidth;
2171 dst_32 = dst_32 + 4*this->
width;
2177 XPutImage ( display, pixmap, context, Ximage, (
int)iP.
get_u(), (int)iP.
get_v(), (int)iP.
get_u(), (int)iP.
get_v(), w, h );
2178 XSetWindowBackgroundPixmap ( display, window, pixmap );
2185 vpERROR_TRACE (
"Unsupported depth (%d bpp) for color display",
2188 "Unsupported depth for color display" ) ) ;
2195 "X not initialized" ) ) ;
2210 if ( ximage_data_init ==
true )
2211 free ( Ximage->data );
2213 Ximage->data = NULL;
2214 XDestroyImage ( Ximage );
2216 XFreePixmap ( display, pixmap );
2218 XFreeGC ( display, context );
2219 XDestroyWindow ( display, window );
2220 XCloseDisplay ( display );
2224 if (x_color != NULL) {
2241 XClearWindow ( display, window );
2249 "X not initialized" ) ) ;
2265 XClearArea ( display, window,(
int)iP.
get_u(),(int)iP.
get_v(),w,h,0 );
2272 "X not initialized" ) ) ;
2287 XSetWindowBackground ( display, window, x_color[color.
id] );
2290 xcolor.red = 256 * color.
R;
2291 xcolor.green = 256 * color.
G;
2292 xcolor.blue = 256 * color.
B;
2293 XAllocColor ( display, lut, &xcolor );
2294 XSetForeground ( display, context, xcolor.pixel );
2297 XClearWindow ( display, window );
2299 XFreePixmap ( display, pixmap );
2301 pixmap = XCreatePixmap ( display, window,
width,
height, screen_depth );
2307 "X not initialized" ) ) ;
2321 unsigned int w,
unsigned int h,
2322 unsigned int thickness)
2333 if ((std::fabs(a) <= std::numeric_limits<double>::epsilon() )&&(std::fabs(b) <= std::numeric_limits<double>::epsilon()) )
2372 "X not initialized" ) ) ;
2394 XSetForeground ( display, context, x_color[color.
id] );
2397 xcolor.red = 256 * color.
R;
2398 xcolor.green = 256 * color.
G;
2399 xcolor.blue = 256 * color.
B;
2400 XAllocColor ( display, lut, &xcolor );
2401 XSetForeground ( display, context, xcolor.pixel );
2403 XDrawString ( display, pixmap, context,
2405 text, (int)strlen ( text ) );
2411 "X not initialized" ) ) ;
2425 unsigned int radius,
2428 unsigned int thickness )
2432 if ( thickness == 1 ) thickness = 0;
2434 XSetForeground ( display, context, x_color[color.
id] );
2437 xcolor.red = 256 * color.
R;
2438 xcolor.green = 256 * color.
G;
2439 xcolor.blue = 256 * color.
B;
2440 XAllocColor ( display, lut, &xcolor );
2441 XSetForeground ( display, context, xcolor.pixel );
2444 XSetLineAttributes ( display, context, thickness,
2445 LineSolid, CapButt, JoinBevel );
2447 if ( fill ==
false )
2449 XDrawArc ( display, pixmap, context,
2452 radius*2, radius*2, 0, 23040 );
2456 XFillArc ( display, pixmap, context,
2459 radius*2, radius*2, 0, 23040 );
2466 "X not initialized" ) ) ;
2478 unsigned int cross_size,
2480 unsigned int thickness)
2486 double i = ip.
get_i();
2487 double j = ip.
get_j();
2490 ip1.
set_i( i-cross_size/2 );
2492 ip2.
set_i( i+cross_size/2 );
2497 ip1.
set_j( j-cross_size/2 );
2499 ip2.
set_j( j+cross_size/2 );
2514 "X not initialized" ) ) ;
2527 unsigned int thickness )
2532 if ( thickness == 1 ) thickness = 0;
2535 XSetForeground ( display, context, x_color[color.
id] );
2538 xcolor.red = 256 * color.
R;
2539 xcolor.green = 256 * color.
G;
2540 xcolor.blue = 256 * color.
B;
2541 XAllocColor ( display, lut, &xcolor );
2542 XSetForeground ( display, context, xcolor.pixel );
2545 XSetLineAttributes ( display, context, thickness,
2546 LineOnOffDash, CapButt, JoinBevel );
2548 XDrawLine ( display, pixmap, context,
2558 "X not initialized" ) ) ;
2571 unsigned int thickness )
2575 if ( thickness == 1 ) thickness = 0;
2578 XSetForeground ( display, context, x_color[color.
id] );
2581 xcolor.red = 256 * color.
R;
2582 xcolor.green = 256 * color.
G;
2583 xcolor.blue = 256 * color.
B;
2584 XAllocColor ( display, lut, &xcolor );
2585 XSetForeground ( display, context, xcolor.pixel );
2588 XSetLineAttributes ( display, context, thickness,
2589 LineSolid, CapButt, JoinBevel );
2591 XDrawLine ( display, pixmap, context,
2601 "X not initialized" ) ) ;
2616 XSetForeground ( display, context, x_color[color.
id] );
2619 xcolor.red = 256 * color.
R;
2620 xcolor.green = 256 * color.
G;
2621 xcolor.blue = 256 * color.
B;
2622 XAllocColor ( display, lut, &xcolor );
2623 XSetForeground ( display, context, xcolor.pixel );
2626 XDrawPoint ( display, pixmap, context,
2634 "X not initialized" ) ) ;
2653 unsigned int w,
unsigned int h,
2654 const vpColor &color,
bool fill,
2655 unsigned int thickness )
2659 if ( thickness == 1 ) thickness = 0;
2661 XSetForeground ( display, context, x_color[color.
id] );
2664 xcolor.red = 256 * color.
R;
2665 xcolor.green = 256 * color.
G;
2666 xcolor.blue = 256 * color.
B;
2667 XAllocColor ( display, lut, &xcolor );
2668 XSetForeground ( display, context, xcolor.pixel );
2670 XSetLineAttributes ( display, context, thickness,
2671 LineSolid, CapButt, JoinBevel );
2672 if ( fill ==
false )
2674 XDrawRectangle ( display, pixmap, context,
2681 XFillRectangle ( display, pixmap, context,
2691 "X not initialized" ) ) ;
2710 const vpColor &color,
bool fill,
2711 unsigned int thickness )
2715 if ( thickness == 1 ) thickness = 0;
2717 XSetForeground ( display, context, x_color[color.
id] );
2720 xcolor.red = 256 * color.
R;
2721 xcolor.green = 256 * color.
G;
2722 xcolor.blue = 256 * color.
B;
2723 XAllocColor ( display, lut, &xcolor );
2724 XSetForeground ( display, context, xcolor.pixel );
2727 XSetLineAttributes ( display, context, thickness,
2728 LineSolid, CapButt, JoinBevel );
2732 if ( fill ==
false )
2735 XDrawRectangle ( display, pixmap, context,
2738 w > 0 ? w-1 : 1, h > 0 ? h : 1 );
2742 XFillRectangle ( display, pixmap, context,
2752 "X not initialized" ) ) ;
2770 const vpColor &color,
bool fill,
2771 unsigned int thickness )
2775 if ( thickness == 1 ) thickness = 0;
2777 XSetForeground ( display, context, x_color[color.
id] );
2780 xcolor.red = 256 * color.
R;
2781 xcolor.green = 256 * color.
G;
2782 xcolor.blue = 256 * color.
B;
2783 XAllocColor ( display, lut, &xcolor );
2784 XSetForeground ( display, context, xcolor.pixel );
2787 XSetLineAttributes ( display, context, thickness,
2788 LineSolid, CapButt, JoinBevel );
2790 if ( fill ==
false )
2792 XDrawRectangle ( display, pixmap, context,
2800 XFillRectangle ( display, pixmap, context,
2812 "X not initialized" ) ) ;
2839 Window rootwin, childwin ;
2840 int root_x, root_y, win_x, win_y ;
2841 unsigned int modifier ;
2845 XCheckMaskEvent(display , ButtonPressMask, &event);
2846 XCheckMaskEvent(display , ButtonReleaseMask, &event);
2847 XMaskEvent ( display, ButtonPressMask ,&event );
2851 ret = XCheckMaskEvent(display , ButtonPressMask, &event);
2856 if ( XQueryPointer ( display,
2858 &rootwin, &childwin,
2867 "X not initialized" ) ) ;
2895 Window rootwin, childwin ;
2896 int root_x, root_y, win_x, win_y ;
2897 unsigned int modifier ;
2900 XCheckMaskEvent(display , ButtonPressMask, &event);
2901 XCheckMaskEvent(display , ButtonReleaseMask, &event);
2902 XMaskEvent ( display, ButtonPressMask ,&event );
2906 ret = XCheckMaskEvent(display , ButtonPressMask, &event);
2911 if ( XQueryPointer ( display,
2913 &rootwin, &childwin,
2917 ip.
set_u( (
double)event.xbutton.x );
2918 ip.
set_v( (
double)event.xbutton.y );
2925 "X not initialized" ) ) ;
2958 Window rootwin, childwin ;
2959 int root_x, root_y, win_x, win_y ;
2960 unsigned int modifier ;
2964 XCheckMaskEvent(display , ButtonPressMask, &event);
2965 XCheckMaskEvent(display , ButtonReleaseMask, &event);
2966 XMaskEvent ( display, ButtonPressMask ,&event );
2970 ret = XCheckMaskEvent(display , ButtonPressMask, &event);
2975 if ( XQueryPointer ( display,
2977 &rootwin, &childwin,
2981 ip.
set_u( (
double)event.xbutton.x );
2982 ip.
set_v( (
double)event.xbutton.y );
2983 switch ( event.xbutton.button ) {
2994 "X not initialized" ) ) ;
3030 Window rootwin, childwin ;
3031 int root_x, root_y, win_x, win_y ;
3032 unsigned int modifier ;
3036 XCheckMaskEvent(display , ButtonPressMask, &event);
3037 XCheckMaskEvent(display , ButtonReleaseMask, &event);
3038 XMaskEvent ( display, ButtonReleaseMask ,&event );
3042 ret = XCheckMaskEvent(display , ButtonReleaseMask, &event);
3047 if ( XQueryPointer ( display,
3049 &rootwin, &childwin,
3053 ip.
set_u( (
double)event.xbutton.x );
3054 ip.
set_v( (
double)event.xbutton.y );
3055 switch ( event.xbutton.button ) {
3066 "X not initialized" ) ) ;
3083 XCopyArea (display,window, pixmap, context,
3087 AllPlanes, ZPixmap ) ;
3099 unsigned char *src_32 = NULL;
3100 src_32 = (
unsigned char* ) xi->data;
3102 if (screen_depth == 16) {
3103 for (
unsigned int i = 0; i < I.
getHeight() ; i++ ) {
3105 for (
unsigned int j = 0; j < I.
getWidth() ; j++ ) {
3107 unsigned long pixel = XGetPixel(xi, (
int)j, (
int)i);
3108 I.
bitmap[ij_].
R = (((pixel & RMask) << RShift) >> 8);
3109 I.
bitmap[ij_].
G = (((pixel & GMask) << GShift) >> 8);
3110 I.
bitmap[ij_].
B = (((pixel & BMask) << BShift) >> 8);
3117 if (XImageByteOrder(display) == 1) {
3121 I.
bitmap[i].
R = src_32[i*4 + 1] ;
3122 I.
bitmap[i].
G = src_32[i*4 + 2] ;
3123 I.
bitmap[i].
B = src_32[i*4 + 3] ;
3130 I.
bitmap[i].
G = src_32[i*4 + 1] ;
3131 I.
bitmap[i].
R = src_32[i*4 + 2] ;
3132 I.
bitmap[i].
A = src_32[i*4 + 3] ;
3136 XDestroyImage ( xi ) ;
3142 "X not initialized" ) ) ;
3155 if ( ( display_ = XOpenDisplay ( NULL ) ) == NULL )
3158 XDisplayName ( NULL ) );
3160 "Can't connect display on server." ) ) ;
3162 screen_ = DefaultScreen ( display_ );
3163 depth = (
unsigned int)DefaultDepth ( display_, screen_ );
3165 XCloseDisplay ( display_ );
3179 if ( ( display_ = XOpenDisplay ( NULL ) ) == NULL )
3182 XDisplayName ( NULL ) );
3184 "Can't connect display on server." ) ) ;
3186 screen_ = DefaultScreen ( display_ );
3187 w = (
unsigned int)DisplayWidth ( display_, screen_ );
3188 h = (
unsigned int)DisplayHeight ( display_, screen_ );
3190 XCloseDisplay ( display_ );
3221 XMaskEvent ( display, KeyPressMask ,&event );
3225 ret = XCheckMaskEvent(display , KeyPressMask, &event);
3231 "X not initialized" ) ) ;
3265 XComposeStatus compose_status;
3271 XMaskEvent ( display, KeyPressMask ,&event );
3272 XLookupString ((XKeyEvent *)&event, &buffer, 1,
3273 &keysym, &compose_status);
3275 sprintf(
string,
"%c", buffer);
3279 ret = XCheckMaskEvent(display , KeyPressMask, &event);
3281 XLookupString ((XKeyEvent *)&event, &buffer, 1,
3282 &keysym, &compose_status);
3283 sprintf(
string,
"%c", buffer);
3290 "X not initialized" ) ) ;
3313 Window rootwin, childwin ;
3314 int root_x, root_y, win_x, win_y ;
3315 unsigned int modifier ;
3317 ret = XCheckMaskEvent(display , PointerMotionMask, &event);
3321 if ( XQueryPointer ( display,
3323 &rootwin, &childwin,
3327 ip.
set_u( (
double)event.xbutton.x );
3328 ip.
set_v( (
double)event.xbutton.y );
3335 "X not initialized" ) ) ;
3357 Window rootwin, childwin ;
3358 int root_x, root_y, win_x, win_y ;
3359 unsigned int modifier ;
3365 if ( XQueryPointer ( display,
3367 &rootwin, &childwin,
3371 ip.
set_u( (
double)win_x );
3372 ip.
set_v( (
double)win_y );
3379 "X not initialized" ) ) ;
3391 for (i = 31; i >= 0; --i) {
3392 if (u32val & 0x80000000L)
void clearDisplay(const vpColor &color=vpColor::white)
unsigned int getScreenDepth()
void displayCross(const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness=1)
void setFont(const char *font)
void displayRectangle(const vpImagePoint &topLeft, unsigned int width, unsigned int height, const vpColor &color, bool fill=false, unsigned int thickness=1)
bool getClickUp(vpImagePoint &ip, vpMouseButton::vpMouseButtonType &button, bool blocking=true)
unsigned int getWidth() const
void displayImage(const vpImage< vpRGBa > &I)
unsigned char B
Blue component.
Type * bitmap
points toward the bitmap
static const vpColor black
static const vpColor darkRed
Class to define colors available for display functionnalities.
static const vpColor lightGray
static const vpColor darkBlue
bool displayHasBeenInitialized
display has been initialized
unsigned char G
Green component.
static const vpColor green
unsigned int getHeight() const
static int round(const double x)
static const vpColor lightRed
Class that defines a RGB 32 bits structure.
bool getPointerPosition(vpImagePoint &ip)
static const vpColor orange
bool getClick(bool blocking=true)
void set_i(const double ii)
void displayImageROI(const vpImage< unsigned char > &I, const vpImagePoint &iP, const unsigned int width, const unsigned int height)
static const vpColor cyan
static const vpColor lightGreen
void set_u(const double u)
static double sqr(double x)
void displayCharString(const vpImagePoint &ip, const char *text, const vpColor &color=vpColor::green)
void getScreenSize(unsigned int &width, unsigned int &height)
void set_v(const double v)
unsigned char A
Additionnal component.
int getMsb(unsigned int u32val)
bool getKeyboardEvent(bool blocking=true)
void resize(const unsigned int h, const unsigned int w)
set the size of the image without initializing it.
static const vpColor gray
void flushDisplayROI(const vpImagePoint &iP, const unsigned int width, const unsigned int height)
void setWindowPosition(int winx, int winy)
static const vpColor darkGray
void displayLine(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1)
void displayArrow(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color=vpColor::white, unsigned int w=4, unsigned int h=2, unsigned int thickness=1)
void setTitle(const char *title)
void set_j(const double jj)
Error that can be emited by the vpDisplay class and its derivates.
void displayPoint(const vpImagePoint &ip, const vpColor &color)
int windowXPosition
display position
unsigned char R
Red component.
unsigned int getWidth() const
unsigned int getHeight() const
Defines a rectangle in the plane.
static const vpColor darkGreen
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
void init(vpImage< unsigned char > &I, int winx=-1, int winy=-1, const char *title=NULL)
static const vpColor yellow
static const vpColor lightBlue
int windowYPosition
display position
static const vpColor purple
static const vpColor white
void displayCircle(const vpImagePoint ¢er, unsigned int radius, const vpColor &color, bool fill=false, unsigned int thickness=1)
bool getPointerMotionEvent(vpImagePoint &ip)
static double distance(const vpImagePoint &iP1, const vpImagePoint &iP2)
void getImage(vpImage< vpRGBa > &I)
get the window pixmap and put it in vpRGBa image
static const vpColor blue
void displayDotLine(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1)