45 #include <visp3/core/vpConfig.h>
55 #include <visp3/core/vpDisplay.h>
56 #include <visp3/gui/vpDisplayX.h>
59 #include <visp3/core/vpDebug.h>
60 #include <visp3/core/vpDisplayException.h>
63 #include <visp3/core/vpMath.h>
83 screen(0), event(), pixmap(), x_color(NULL),
84 screen_depth(8), xcolor(), values(), ximage_data_init(false),
85 RMask(0), GMask(0), BMask(0), RShift(0), GShift(0), BShift(0)
115 screen(0), event(), pixmap(), x_color(NULL),
116 screen_depth(8), xcolor(), values(), ximage_data_init(false),
117 RMask(0), GMask(0), BMask(0), RShift(0), GShift(0), BShift(0)
120 init ( I, x, y, title ) ;
139 screen(0), event(), pixmap(), x_color(NULL),
140 screen_depth(8), xcolor(), values(), ximage_data_init(false),
141 RMask(0), GMask(0), BMask(0), RShift(0), GShift(0), BShift(0)
168 screen(0), event(), pixmap(), x_color(NULL),
169 screen_depth(8), xcolor(), values(), ximage_data_init(false),
170 RMask(0), GMask(0), BMask(0), RShift(0), GShift(0), BShift(0)
173 init ( I, x, y, title ) ;
200 screen(0), event(), pixmap(), x_color(NULL),
201 screen_depth(8), xcolor(), values(), ximage_data_init(false),
202 RMask(0), GMask(0), BMask(0), RShift(0), GShift(0), BShift(0)
231 screen(0), event(), pixmap(), x_color(NULL),
232 screen_depth(8), xcolor(), values(), ximage_data_init(false),
233 RMask(0), GMask(0), BMask(0), RShift(0), GShift(0), BShift(0)
258 if (x_color == NULL) {
279 hints.flags = USPosition;
287 display = XOpenDisplay ( NULL );
290 vpERROR_TRACE (
"Can't connect display on server %s.\n", XDisplayName ( NULL ) );
292 "Can't connect display on server." ) ) ;
295 screen = DefaultScreen (
display );
296 lut = DefaultColormap (
display, screen );
297 screen_depth = (
unsigned int)DefaultDepth (
display, screen );
301 BlackPixel (
display, screen ),
302 WhitePixel (
display, screen ) ) ) == 0 )
306 "Can't create window." ) ) ;
312 if ( screen_depth == 8 )
315 DefaultVisual (
display, screen ), AllocAll ) ;
316 xcolor.flags = DoRed | DoGreen | DoBlue ;
318 for (
unsigned int i = 0 ; i < 256 ; i++ )
321 xcolor.red = 256 * i;
322 xcolor.green = 256 * i;
323 xcolor.blue = 256 * i;
324 XStoreColor (
display, lut, &xcolor );
328 XInstallColormap (
display, lut ) ;
331 else if ( screen_depth == 16 )
333 for (
unsigned int i = 0; i < 256; i ++ )
336 xcolor.red = xcolor.green = xcolor.blue = 256 * i;
337 if ( XAllocColor (
display, lut, &xcolor ) == 0 )
339 vpERROR_TRACE (
"Can't allocate 256 colors. Only %d allocated.", i );
341 "Can't allocate 256 colors." ) ) ;
343 colortable[i] = xcolor.pixel;
347 XInstallColormap (
display, lut ) ;
349 Visual *visual = DefaultVisual (
display, screen);
350 RMask = visual->red_mask;
351 GMask = visual->green_mask;
352 BMask = visual->blue_mask;
354 RShift = 15 -
getMsb(RMask);
355 GShift = 15 -
getMsb(GMask);
356 BShift = 15 -
getMsb(BMask);
362 switch ( screen_depth )
370 xcolor.red = 256 * 192;
371 xcolor.green = 256 * 192;
372 xcolor.blue = 256 * 192;
373 XStoreColor (
display, lut, &xcolor );
378 xcolor.red = 256 * 128;
379 xcolor.green = 256 * 128;
380 xcolor.blue = 256 * 128;
381 XStoreColor (
display, lut, &xcolor );
386 xcolor.red = 256 * 64;
387 xcolor.green = 256 * 64;
388 xcolor.blue = 256 * 64;
389 XStoreColor (
display, lut, &xcolor );
394 xcolor.red = 256 * 255;
395 xcolor.green = 256 * 140;
396 xcolor.blue = 256 * 140;
397 XStoreColor (
display, lut, &xcolor );
402 xcolor.red = 256 * 255;
405 XStoreColor (
display, lut, &xcolor );
410 xcolor.red = 256 * 128;
413 XStoreColor (
display, lut, &xcolor );
418 xcolor.red = 256 * 140;
419 xcolor.green = 256 * 255;
420 xcolor.blue = 256 * 140;
421 XStoreColor (
display, lut, &xcolor );
427 xcolor.green = 256 * 255;
429 XStoreColor (
display, lut, &xcolor );
435 xcolor.green = 256 * 128;
437 XStoreColor (
display, lut, &xcolor );
442 xcolor.red = 256 * 140;
443 xcolor.green = 256 * 140;
444 xcolor.blue = 256 * 255;
445 XStoreColor (
display, lut, &xcolor );
452 xcolor.blue = 256 * 255;
453 XStoreColor (
display, lut, &xcolor );
460 xcolor.blue = 256 * 128;
461 XStoreColor (
display, lut, &xcolor );
466 xcolor.red = 256 * 255;
467 xcolor.green = 256 * 255;
469 XStoreColor (
display, lut, &xcolor );
474 xcolor.red = 256 * 255;
475 xcolor.green = 256 * 165;
477 XStoreColor (
display, lut, &xcolor );
483 xcolor.green = 256 * 255;
484 xcolor.blue = 256 * 255;
485 XStoreColor (
display, lut, &xcolor );
490 xcolor.red = 256 * 128;
492 xcolor.blue = 256 * 128;
493 XStoreColor (
display, lut, &xcolor );
500 xcolor.flags = DoRed | DoGreen | DoBlue ;
507 XAllocColor (
display, lut, &xcolor );
512 xcolor.red = 256* 255;
513 xcolor.green = 256* 255;
514 xcolor.blue = 256* 255;
515 XAllocColor (
display, lut, &xcolor );
520 xcolor.red = 256 * 192;
521 xcolor.green = 256 * 192;
522 xcolor.blue = 256 * 192;
523 XAllocColor (
display, lut, &xcolor );
528 xcolor.red = 256 * 128;
529 xcolor.green = 256 * 128;
530 xcolor.blue = 256 * 128;
531 XAllocColor (
display, lut, &xcolor );
536 xcolor.red = 256 * 64;
537 xcolor.green = 256 * 64;
538 xcolor.blue = 256 * 64;
539 XAllocColor (
display, lut, &xcolor );
544 xcolor.red = 256 * 255;
545 xcolor.green = 256 * 140;
546 xcolor.blue = 256 * 140;
547 XAllocColor (
display, lut, &xcolor );
552 xcolor.red = 256* 255;
555 XAllocColor (
display, lut, &xcolor );
560 xcolor.red = 256* 128;
563 XAllocColor (
display, lut, &xcolor );
568 xcolor.red = 256 * 140;
569 xcolor.green = 256 * 255;
570 xcolor.blue = 256 * 140;
571 XAllocColor (
display, lut, &xcolor );
577 xcolor.green = 256*255;
579 XAllocColor (
display, lut, &xcolor );
585 xcolor.green = 256* 128;
587 XAllocColor (
display, lut, &xcolor );
592 xcolor.red = 256 * 140;
593 xcolor.green = 256 * 140;
594 xcolor.blue = 256 * 255;
595 XAllocColor (
display, lut, &xcolor );
602 xcolor.blue = 256* 255;
603 XAllocColor (
display, lut, &xcolor );
610 xcolor.blue = 256* 128;
611 XAllocColor (
display, lut, &xcolor );
616 xcolor.red = 256 * 255;
617 xcolor.green = 256 * 255;
619 XAllocColor (
display, lut, &xcolor );
624 xcolor.red = 256 * 255;
625 xcolor.green = 256 * 165;
627 XAllocColor (
display, lut, &xcolor );
633 xcolor.green = 256 * 255;
634 xcolor.blue = 256 * 255;
635 XAllocColor (
display, lut, &xcolor );
640 xcolor.red = 256 * 128;
642 xcolor.blue = 256 * 128;
643 XAllocColor (
display, lut, &xcolor );
654 ButtonPressMask | ButtonReleaseMask |
655 KeyPressMask | KeyReleaseMask |
656 StructureNotifyMask |
660 values.plane_mask = AllPlanes;
661 values.fill_style = FillSolid;
662 values.foreground = WhitePixel (
display, screen );
663 values.background = BlackPixel (
display, screen );
665 GCPlaneMask | GCFillStyle | GCForeground | GCBackground,
668 if ( context == NULL )
672 "Can't create graphics context" ) ) ;
685 Ximage = XCreateImage (
display, DefaultVisual (
display, screen ),
686 screen_depth, ZPixmap, 0, NULL,
689 Ximage->data = (
char * ) malloc (
m_height * (
unsigned int)Ximage->bytes_per_line );
690 ximage_data_init =
true;
722 if (x_color == NULL) {
737 hints.flags = USPosition;
746 if ( (
display = XOpenDisplay ( NULL ) ) == NULL )
748 vpERROR_TRACE (
"Can't connect display on server %s.\n", XDisplayName ( NULL ) );
750 "Can't connect display on server." ) ) ;
753 screen = DefaultScreen (
display );
754 lut = DefaultColormap (
display, screen );
755 screen_depth = (
unsigned int)DefaultDepth (
display, screen );
762 BlackPixel (
display, screen ),
763 WhitePixel (
display, screen ) ) ) == 0 )
767 "Can't create window." ) ) ;
773 if ( screen_depth == 8 )
776 DefaultVisual (
display, screen ), AllocAll ) ;
777 xcolor.flags = DoRed | DoGreen | DoBlue ;
779 for (
unsigned int i = 0 ; i < 256 ; i++ )
782 xcolor.red = 256 * i;
783 xcolor.green = 256 * i;
784 xcolor.blue = 256 * i;
785 XStoreColor (
display, lut, &xcolor );
789 XInstallColormap (
display, lut ) ;
792 else if ( screen_depth == 16 )
794 for (
unsigned int i = 0; i < 256; i ++ )
797 xcolor.red = xcolor.green = xcolor.blue = 256 * i;
798 if ( XAllocColor (
display, lut, &xcolor ) == 0 )
800 vpERROR_TRACE (
"Can't allocate 256 colors. Only %d allocated.", i );
802 "Can't allocate 256 colors." ) ) ;
804 colortable[i] = xcolor.pixel;
807 Visual *visual = DefaultVisual (
display, screen);
808 RMask = visual->red_mask;
809 GMask = visual->green_mask;
810 BMask = visual->blue_mask;
812 RShift = 15 -
getMsb(RMask);
813 GShift = 15 -
getMsb(GMask);
814 BShift = 15 -
getMsb(BMask);
817 XInstallColormap (
display, lut ) ;
824 switch ( screen_depth )
833 xcolor.red = 256 * 192;
834 xcolor.green = 256 * 192;
835 xcolor.blue = 256 * 192;
836 XStoreColor (
display, lut, &xcolor );
841 xcolor.red = 256 * 128;
842 xcolor.green = 256 * 128;
843 xcolor.blue = 256 * 128;
844 XStoreColor (
display, lut, &xcolor );
849 xcolor.red = 256 * 64;
850 xcolor.green = 256 * 64;
851 xcolor.blue = 256 * 64;
852 XStoreColor (
display, lut, &xcolor );
857 xcolor.red = 256 * 255;
858 xcolor.green = 256 * 140;
859 xcolor.blue = 256 * 140;
860 XStoreColor (
display, lut, &xcolor );
865 xcolor.red = 256 * 255;
868 XStoreColor (
display, lut, &xcolor );
873 xcolor.red = 256 * 128;
876 XStoreColor (
display, lut, &xcolor );
881 xcolor.red = 256 * 140;
882 xcolor.green = 256 * 255;
883 xcolor.blue = 256 * 140;
884 XStoreColor (
display, lut, &xcolor );
890 xcolor.green = 256 * 255;
892 XStoreColor (
display, lut, &xcolor );
898 xcolor.green = 256 * 128;
900 XStoreColor (
display, lut, &xcolor );
905 xcolor.red = 256 * 140;
906 xcolor.green = 256 * 140;
907 xcolor.blue = 256 * 255;
908 XStoreColor (
display, lut, &xcolor );
915 xcolor.blue = 256 * 255;
916 XStoreColor (
display, lut, &xcolor );
923 xcolor.blue = 256 * 128;
924 XStoreColor (
display, lut, &xcolor );
929 xcolor.red = 256 * 255;
930 xcolor.green = 256 * 255;
932 XStoreColor (
display, lut, &xcolor );
937 xcolor.red = 256 * 255;
938 xcolor.green = 256 * 165;
940 XStoreColor (
display, lut, &xcolor );
946 xcolor.green = 256 * 255;
947 xcolor.blue = 256 * 255;
948 XStoreColor (
display, lut, &xcolor );
953 xcolor.red = 256 * 128;
955 xcolor.blue = 256 * 128;
956 XStoreColor (
display, lut, &xcolor );
963 xcolor.flags = DoRed | DoGreen | DoBlue ;
970 XAllocColor (
display, lut, &xcolor );
975 xcolor.red = 256* 255;
976 xcolor.green = 256* 255;
977 xcolor.blue = 256* 255;
978 XAllocColor (
display, lut, &xcolor );
983 xcolor.red = 256 * 192;
984 xcolor.green = 256 * 192;
985 xcolor.blue = 256 * 192;
986 XAllocColor (
display, lut, &xcolor );
991 xcolor.red = 256 * 128;
992 xcolor.green = 256 * 128;
993 xcolor.blue = 256 * 128;
994 XAllocColor (
display, lut, &xcolor );
999 xcolor.red = 256 * 64;
1000 xcolor.green = 256 * 64;
1001 xcolor.blue = 256 * 64;
1002 XAllocColor (
display, lut, &xcolor );
1007 xcolor.red = 256 * 255;
1008 xcolor.green = 256 * 140;
1009 xcolor.blue = 256 * 140;
1010 XAllocColor (
display, lut, &xcolor );
1015 xcolor.red = 256* 255;
1018 XAllocColor (
display, lut, &xcolor );
1023 xcolor.red = 256* 128;
1026 XAllocColor (
display, lut, &xcolor );
1031 xcolor.red = 256 * 140;
1032 xcolor.green = 256 * 255;
1033 xcolor.blue = 256 * 140;
1034 XAllocColor (
display, lut, &xcolor );
1040 xcolor.green = 256*255;
1042 XAllocColor (
display, lut, &xcolor );
1048 xcolor.green = 256* 128;
1050 XAllocColor (
display, lut, &xcolor );
1055 xcolor.red = 256 * 140;
1056 xcolor.green = 256 * 140;
1057 xcolor.blue = 256 * 255;
1058 XAllocColor (
display, lut, &xcolor );
1065 xcolor.blue = 256* 255;
1066 XAllocColor (
display, lut, &xcolor );
1073 xcolor.blue = 256* 128;
1074 XAllocColor (
display, lut, &xcolor );
1079 xcolor.red = 256 * 255;
1080 xcolor.green = 256 * 255;
1082 XAllocColor (
display, lut, &xcolor );
1087 xcolor.red = 256 * 255;
1088 xcolor.green = 256 * 165;
1090 XAllocColor (
display, lut, &xcolor );
1096 xcolor.green = 256 * 255;
1097 xcolor.blue = 256 * 255;
1098 XAllocColor (
display, lut, &xcolor );
1103 xcolor.red = 256 * 128;
1105 xcolor.blue = 256 * 128;
1106 XAllocColor (
display, lut, &xcolor );
1117 ButtonPressMask | ButtonReleaseMask |
1118 KeyPressMask | KeyReleaseMask |
1119 StructureNotifyMask |
1123 values.plane_mask = AllPlanes;
1124 values.fill_style = FillSolid;
1125 values.foreground = WhitePixel (
display, screen );
1126 values.background = BlackPixel (
display, screen );
1128 GCPlaneMask | GCFillStyle | GCForeground | GCBackground,
1131 if ( context == NULL )
1135 "Can't create graphics context" ) ) ;
1147 Ximage = XCreateImage (
display, DefaultVisual (
display, screen ),
1148 screen_depth, ZPixmap, 0, NULL,
1152 Ximage->data = (
char * ) malloc (
m_height * (
unsigned int)Ximage->bytes_per_line );
1153 ximage_data_init =
true;
1172 void vpDisplayX::init (
unsigned int w,
unsigned int h,
int x,
int y,
const std::string &title)
1176 if (x_color == NULL) {
1197 hints.flags = USPosition;
1204 if ( (
display = XOpenDisplay ( NULL ) ) == NULL )
1206 vpERROR_TRACE (
"Can't connect display on server %s.\n", XDisplayName ( NULL ) );
1208 "Can't connect display on server." ) ) ;
1211 screen = DefaultScreen (
display );
1212 lut = DefaultColormap (
display, screen );
1213 screen_depth = (
unsigned int)DefaultDepth (
display, screen );
1215 vpTRACE (
"Screen depth: %d\n", screen_depth );
1220 BlackPixel (
display, screen ),
1221 WhitePixel (
display, screen ) ) ) == 0 )
1225 "Can't create window." ) ) ;
1232 if ( screen_depth == 8 )
1235 DefaultVisual (
display, screen ), AllocAll ) ;
1236 xcolor.flags = DoRed | DoGreen | DoBlue ;
1238 for (
unsigned int i = 0 ; i < 256 ; i++ )
1241 xcolor.red = 256 * i;
1242 xcolor.green = 256 * i;
1243 xcolor.blue = 256 * i;
1244 XStoreColor (
display, lut, &xcolor );
1248 XInstallColormap (
display, lut ) ;
1251 else if ( screen_depth == 16 )
1253 for (
unsigned int i = 0; i < 256; i ++ )
1256 xcolor.red = xcolor.green = xcolor.blue = 256 * i;
1257 if ( XAllocColor (
display, lut, &xcolor ) == 0 )
1259 vpERROR_TRACE (
"Can't allocate 256 colors. Only %d allocated.", i );
1261 "Can't allocate 256 colors." ) ) ;
1263 colortable[i] = xcolor.pixel;
1267 XInstallColormap (
display, lut ) ;
1269 Visual *visual = DefaultVisual (
display, screen);
1270 RMask = visual->red_mask;
1271 GMask = visual->green_mask;
1272 BMask = visual->blue_mask;
1274 RShift = 15 -
getMsb(RMask);
1275 GShift = 15 -
getMsb(GMask);
1276 BShift = 15 -
getMsb(BMask);
1284 switch ( screen_depth )
1294 xcolor.pixel = 254 ;
1295 xcolor.red = 256 * pcolor.
R;
1296 xcolor.green = 256 * pcolor.
G;
1297 xcolor.blue = 256 * pcolor.
B;
1298 XStoreColor (
display, lut, &xcolor );
1302 xcolor.pixel = 253 ;
1303 xcolor.red = 256 * pcolor.
R;
1304 xcolor.green = 256 * pcolor.
G;
1305 xcolor.blue = 256 * pcolor.
B;
1306 XStoreColor (
display, lut, &xcolor );
1310 xcolor.pixel = 252 ;
1311 xcolor.red = 256 * pcolor.
R;
1312 xcolor.green = 256 * pcolor.
G;
1313 xcolor.blue = 256 * pcolor.
B;
1314 XStoreColor (
display, lut, &xcolor );
1318 xcolor.pixel = 251 ;
1319 xcolor.red = 256 * pcolor.
R;
1320 xcolor.green = 256 * pcolor.
G;
1321 xcolor.blue = 256 * pcolor.
B;
1322 XStoreColor (
display, lut, &xcolor );
1326 xcolor.pixel = 250 ;
1327 xcolor.red = 256 * pcolor.
R;
1328 xcolor.green = 256 * pcolor.
G;
1329 xcolor.blue = 256 * pcolor.
B;
1330 XStoreColor (
display, lut, &xcolor );
1334 xcolor.pixel = 249 ;
1335 xcolor.red = 256 * pcolor.
R;
1336 xcolor.green = 256 * pcolor.
G;
1337 xcolor.blue = 256 * pcolor.
B;
1338 XStoreColor (
display, lut, &xcolor );
1342 xcolor.pixel = 248 ;
1343 xcolor.red = 256 * pcolor.
R;
1344 xcolor.green = 256 * pcolor.
G;
1345 xcolor.blue = 256 * pcolor.
B;
1346 XStoreColor (
display, lut, &xcolor );
1351 xcolor.red = 256 * pcolor.
R;
1352 xcolor.green = 256 * pcolor.
G;
1353 xcolor.blue = 256 * pcolor.
B;
1354 XStoreColor (
display, lut, &xcolor );
1358 xcolor.pixel = 246 ;
1359 xcolor.red = 256 * pcolor.
R;
1360 xcolor.green = 256 * pcolor.
G;
1361 xcolor.blue = 256 * pcolor.
B;
1362 XStoreColor (
display, lut, &xcolor );
1366 xcolor.pixel = 245 ;
1367 xcolor.red = 256 * pcolor.
R;
1368 xcolor.green = 256 * pcolor.
G;
1369 xcolor.blue = 256 * pcolor.
B;
1370 XStoreColor (
display, lut, &xcolor );
1375 xcolor.red = 256 * pcolor.
R;
1376 xcolor.green = 256 * pcolor.
G;
1377 xcolor.blue = 256 * pcolor.
B;
1378 XStoreColor (
display, lut, &xcolor );
1382 xcolor.pixel = 243 ;
1383 xcolor.red = 256 * pcolor.
R;
1384 xcolor.green = 256 * pcolor.
G;
1385 xcolor.blue = 256 * pcolor.
B;
1386 XStoreColor (
display, lut, &xcolor );
1391 xcolor.red = 256 * pcolor.
R;
1392 xcolor.green = 256 * pcolor.
G;
1393 xcolor.blue = 256 * pcolor.
B;
1394 XStoreColor (
display, lut, &xcolor );
1399 xcolor.red = 256 * pcolor.
R;
1400 xcolor.green = 256 * pcolor.
G;
1401 xcolor.blue = 256 * pcolor.
B;
1402 XStoreColor (
display, lut, &xcolor );
1407 xcolor.red = 256 * pcolor.
R;
1408 xcolor.green = 256 * pcolor.
G;
1409 xcolor.blue = 256 * pcolor.
B;
1410 XStoreColor (
display, lut, &xcolor );
1415 xcolor.red = 256 * pcolor.
R;
1416 xcolor.green = 256 * pcolor.
G;
1417 xcolor.blue = 256 * pcolor.
B;
1418 XStoreColor (
display, lut, &xcolor );
1425 xcolor.flags = DoRed | DoGreen | DoBlue ;
1430 xcolor.red = 256 * pcolor.
R;
1431 xcolor.green = 256 * pcolor.
G;
1432 xcolor.blue = 256 * pcolor.
B;
1433 XAllocColor (
display, lut, &xcolor );
1439 xcolor.red = 256 * pcolor.
R;
1440 xcolor.green = 256 * pcolor.
G;
1441 xcolor.blue = 256 * pcolor.
B;
1442 XAllocColor (
display, lut, &xcolor );
1448 xcolor.red = 256 * pcolor.
R;
1449 xcolor.green = 256 * pcolor.
G;
1450 xcolor.blue = 256 * pcolor.
B;
1451 XAllocColor (
display, lut, &xcolor );
1457 xcolor.red = 256 * pcolor.
R;
1458 xcolor.green = 256 * pcolor.
G;
1459 xcolor.blue = 256 * pcolor.
B;
1460 XAllocColor (
display, lut, &xcolor );
1466 xcolor.red = 256 * pcolor.
R;
1467 xcolor.green = 256 * pcolor.
G;
1468 xcolor.blue = 256 * pcolor.
B;
1469 XAllocColor (
display, lut, &xcolor );
1475 xcolor.red = 256 * pcolor.
R;
1476 xcolor.green = 256 * pcolor.
G;
1477 xcolor.blue = 256 * pcolor.
B;
1478 XAllocColor (
display, lut, &xcolor );
1484 xcolor.red = 256 * pcolor.
R;
1485 xcolor.green = 256 * pcolor.
G;
1486 xcolor.blue = 256 * pcolor.
B;
1487 XAllocColor (
display, lut, &xcolor );
1493 xcolor.red = 256 * pcolor.
R;
1494 xcolor.green = 256 * pcolor.
G;
1495 xcolor.blue = 256 * pcolor.
B;
1496 XAllocColor (
display, lut, &xcolor );
1502 xcolor.red = 256 * pcolor.
R;
1503 xcolor.green = 256 * pcolor.
G;
1504 xcolor.blue = 256 * pcolor.
B;
1505 XAllocColor (
display, lut, &xcolor );
1511 xcolor.red = 256 * pcolor.
R;
1512 xcolor.green = 256 * pcolor.
G;
1513 xcolor.blue = 256 * pcolor.
B;
1514 XAllocColor (
display, lut, &xcolor );
1520 xcolor.red = 256 * pcolor.
R;
1521 xcolor.green = 256 * pcolor.
G;
1522 xcolor.blue = 256 * pcolor.
B;
1523 XAllocColor (
display, lut, &xcolor );
1529 xcolor.red = 256 * pcolor.
R;
1530 xcolor.green = 256 * pcolor.
G;
1531 xcolor.blue = 256 * pcolor.
B;
1532 XAllocColor (
display, lut, &xcolor );
1538 xcolor.red = 256 * pcolor.
R;
1539 xcolor.green = 256 * pcolor.
G;
1540 xcolor.blue = 256 * pcolor.
B;
1541 XAllocColor (
display, lut, &xcolor );
1547 xcolor.red = 256 * pcolor.
R;
1548 xcolor.green = 256 * pcolor.
G;
1549 xcolor.blue = 256 * pcolor.
B;
1550 XAllocColor (
display, lut, &xcolor );
1556 xcolor.red = 256 * pcolor.
R;
1557 xcolor.green = 256 * pcolor.
G;
1558 xcolor.blue = 256 * pcolor.
B;
1559 XAllocColor (
display, lut, &xcolor );
1565 xcolor.red = 256 * pcolor.
R;
1566 xcolor.green = 256 * pcolor.
G;
1567 xcolor.blue = 256 * pcolor.
B;
1568 XAllocColor (
display, lut, &xcolor );
1574 xcolor.red = 256 * pcolor.
R;
1575 xcolor.green = 256 * pcolor.
G;
1576 xcolor.blue = 256 * pcolor.
B;
1577 XAllocColor (
display, lut, &xcolor );
1583 xcolor.red = 256 * pcolor.
R;
1584 xcolor.green = 256 * pcolor.
G;
1585 xcolor.blue = 256 * pcolor.
B;
1586 XAllocColor (
display, lut, &xcolor );
1597 ButtonPressMask | ButtonReleaseMask |
1598 KeyPressMask | KeyReleaseMask |
1599 StructureNotifyMask |
1603 values.plane_mask = AllPlanes;
1604 values.fill_style = FillSolid;
1605 values.foreground = WhitePixel (
display, screen );
1606 values.background = BlackPixel (
display, screen );
1608 GCPlaneMask | GCFillStyle | GCForeground | GCBackground,
1611 if ( context == NULL )
1615 "Can't create graphics context" ) ) ;
1627 Ximage = XCreateImage (
display, DefaultVisual (
display, screen ),
1628 screen_depth, ZPixmap, 0, NULL,
1631 Ximage->data = (
char * ) malloc (
m_height * (
unsigned int)Ximage->bytes_per_line );
1632 ximage_data_init =
true;
1664 stringfont = XLoadFont (
display, font.c_str()) ;
1665 XSetFont (
display, context, stringfont);
1676 "X not initialized" ) ) ;
1696 "X not initialized" ) ) ;
1716 "X not initialized" ) ) ;
1735 switch ( screen_depth )
1743 unsigned char *src_8 = (
unsigned char * ) I.
bitmap;
1744 unsigned char *dst_8 = (
unsigned char * ) Ximage->data;
1750 unsigned char nivGris = src_8[i] ;
1751 if ( nivGris > nivGrisMax )
1761 unsigned char *dst_8 = (
unsigned char * ) Ximage->data;
1763 for (
unsigned int i=0; i<
m_height; i++) {
1764 for (
unsigned int j=0; j<
m_width; j++) {
1766 if ( nivGris > nivGrisMax )
1769 dst_8[k++] = nivGris;
1781 unsigned int bytes_per_line = (
unsigned int)Ximage->bytes_per_line;
1783 for (
unsigned int i = 0; i <
m_height ; i++ ) {
1784 unsigned char *dst_8 = (
unsigned char*) Ximage->data + i * bytes_per_line;
1785 unsigned short *dst_16 = (
unsigned short *) dst_8;
1786 for (
unsigned int j=0 ; j <
m_width; j++ )
1788 * ( dst_16 + j ) = (
unsigned short ) colortable[I[i][j]] ;
1793 for (
unsigned int i = 0; i <
m_height ; i++ ) {
1794 unsigned char *dst_8 = (
unsigned char*) Ximage->data + i * bytes_per_line;
1795 unsigned short *dst_16 = (
unsigned short *) dst_8;
1796 for (
unsigned int j=0 ; j <
m_width; j++ )
1798 * ( dst_16 + j ) = (
unsigned short ) colortable[I[i*
m_scale][j*
m_scale]] ;
1812 unsigned char *dst_32 = (
unsigned char* ) Ximage->data;
1815 unsigned char *bitmap = I.
bitmap ;
1816 unsigned char *n = I.
bitmap + size_;
1818 if (XImageByteOrder(
display) == 1) {
1820 while ( bitmap < n )
1822 unsigned char val = * ( bitmap++ );
1824 * ( dst_32 ++ ) = val;
1825 * ( dst_32 ++ ) = val;
1826 * ( dst_32 ++ ) = val;
1831 while ( bitmap < n )
1833 unsigned char val = * ( bitmap++ );
1834 * ( dst_32 ++ ) = val;
1835 * ( dst_32 ++ ) = val;
1836 * ( dst_32 ++ ) = val;
1842 if (XImageByteOrder(
display) == 1) {
1844 for (
unsigned int i=0; i<
m_height; i++) {
1845 for (
unsigned int j=0; j<
m_width; j++) {
1848 * ( dst_32 ++ ) = val;
1849 * ( dst_32 ++ ) = val;
1850 * ( dst_32 ++ ) = val;
1856 for (
unsigned int i=0; i<
m_height; i++) {
1857 for (
unsigned int j=0; j<
m_width; j++) {
1859 * ( dst_32 ++ ) = val;
1860 * ( dst_32 ++ ) = val;
1861 * ( dst_32 ++ ) = val;
1878 "X not initialized" ) ) ;
1896 switch ( screen_depth )
1900 unsigned int r, g, b;
1901 unsigned int bytes_per_line = (
unsigned int)Ximage->bytes_per_line;
1904 for (
unsigned int i = 0; i <
m_height ; i++ ) {
1905 unsigned char *dst_8 = (
unsigned char*) Ximage->data + i * bytes_per_line;
1906 unsigned short *dst_16 = (
unsigned short *) dst_8;
1907 for (
unsigned int j=0 ; j <
m_width; j++ )
1912 * ( dst_16 + j ) = (((r << 8) >> RShift) & RMask) |
1913 (((g << 8) >> GShift) & GMask) |
1914 (((b << 8) >> BShift) & BMask);
1920 for (
unsigned int i = 0; i <
m_height ; i++ ) {
1921 unsigned char *dst_8 = (
unsigned char*) Ximage->data + i * bytes_per_line;
1922 unsigned short *dst_16 = (
unsigned short *) dst_8;
1923 for (
unsigned int j=0 ; j <
m_width; j++ )
1929 * ( dst_16 + j ) = (((r << 8) >> RShift) & RMask) |
1930 (((g << 8) >> GShift) & GMask) |
1931 (((b << 8) >> BShift) & BMask);
1948 unsigned char *dst_32 = NULL;
1949 dst_32 = (
unsigned char* ) Ximage->data;
1953 if (XImageByteOrder(
display) == 1) {
1955 for (
unsigned int i = 0; i < sizeI ; i++ ) {
1956 *(dst_32++) = bitmap->
A;
1957 *(dst_32++) = bitmap->
R;
1958 *(dst_32++) = bitmap->
G;
1959 *(dst_32++) = bitmap->
B;
1965 for (
unsigned int i = 0; i < sizeI; i++ ) {
1966 *(dst_32++) = bitmap->
B;
1967 *(dst_32++) = bitmap->
G;
1968 *(dst_32++) = bitmap->
R;
1969 *(dst_32++) = bitmap->
A;
1975 if (XImageByteOrder(
display) == 1) {
1977 for (
unsigned int i=0; i<
m_height; i++) {
1978 for (
unsigned int j=0; j<
m_width; j++) {
1980 *(dst_32++) = val.
A;
1981 *(dst_32++) = val.
R;
1982 *(dst_32++) = val.
G;
1983 *(dst_32++) = val.
B;
1989 for (
unsigned int i=0; i<
m_height; i++) {
1990 for (
unsigned int j=0; j<
m_width; j++) {
1992 *(dst_32++) = val.
B;
1993 *(dst_32++) = val.
G;
1994 *(dst_32++) = val.
R;
1995 *(dst_32++) = val.
A;
2008 "Unsupported depth (%d bpp) for color display", screen_depth ) ) ;
2014 "X not initialized" ) ) ;
2034 unsigned char *dst_32 = (
unsigned char* ) Ximage->data;
2037 * ( dst_32 ++ ) = *bitmap;
2038 * ( dst_32 ++ ) = *bitmap;
2039 * ( dst_32 ++ ) = *bitmap;
2040 * ( dst_32 ++ ) = *bitmap;
2045 XPutImage (
display, pixmap, context, Ximage, 0, 0, 0, 0,
m_width, m_height );
2051 "X not initialized" ) ) ;
2072 const unsigned int w,
const unsigned int h )
2076 switch ( screen_depth )
2084 unsigned char *src_8 = (
unsigned char * ) I.
bitmap;
2085 unsigned char *dst_8 = (
unsigned char * ) Ximage->data;
2086 unsigned int iwidth = I.
getWidth();
2088 src_8 = src_8 + (int)(iP.
get_i()*iwidth+ iP.
get_j());
2097 unsigned char nivGris = *(src_8+j);
2098 if ( nivGris > nivGrisMax )
2101 *(dst_8+j) = nivGris;
2104 src_8 = src_8 + iwidth;
2114 int i_min = std::max((
int)ceil(iP.
get_i()/
m_scale), 0);
2115 int j_min = std::max((
int)ceil(iP.
get_j()/
m_scale), 0);
2119 unsigned int i_min_ = (
unsigned int)i_min;
2120 unsigned int i_max_ = (
unsigned int)i_max;
2121 unsigned int j_min_ = (
unsigned int)j_min;
2122 unsigned int j_max_ = (
unsigned int)j_max;
2124 for (
unsigned int i=i_min_; i<i_max_; i++) {
2125 unsigned char *dst_8 = (
unsigned char * ) Ximage->data + i*
m_width;
2126 for (
unsigned int j=j_min_; j<j_max_; j++) {
2128 if ( nivGris > nivGrisMax )
2134 XPutImage(
display, pixmap, context, Ximage, j_min, i_min, j_min, i_min, j_max_-j_min_, i_max_-i_min_);
2143 unsigned int bytes_per_line = (
unsigned int)Ximage->bytes_per_line;
2145 for (
unsigned int i = (
unsigned int)iP.
get_i(); i < (
unsigned int)(iP.
get_i()+h) ; i++ ) {
2146 unsigned char *dst_8 = (
unsigned char *) Ximage->data + i * bytes_per_line;
2147 unsigned short *dst_16 = (
unsigned short *) dst_8;
2148 for (
unsigned int j=(
unsigned int)iP.
get_j() ; j < (
unsigned int)(iP.
get_j()+w); j++ )
2150 * ( dst_16 + j ) = (
unsigned short ) colortable[I[i][j]] ;
2157 int i_min = std::max((
int)ceil(iP.
get_i()/
m_scale), 0);
2158 int j_min = std::max((
int)ceil(iP.
get_j()/
m_scale), 0);
2162 unsigned int i_min_ = (
unsigned int)i_min;
2163 unsigned int i_max_ = (
unsigned int)i_max;
2164 unsigned int j_min_ = (
unsigned int)j_min;
2165 unsigned int j_max_ = (
unsigned int)j_max;
2167 for (
unsigned int i=i_min_; i<i_max_; i++) {
2168 unsigned char *dst_8 = (
unsigned char*) Ximage->data + i * bytes_per_line;
2169 unsigned short *dst_16 = (
unsigned short *) dst_8;
2170 for (
unsigned int j=j_min_; j<j_max_; j++) {
2171 * ( dst_16 + j ) = (
unsigned short ) colortable[I[i*
m_scale][j*
m_scale]] ;
2175 XPutImage(
display, pixmap, context, Ximage, j_min, i_min, j_min, i_min, j_max_-j_min_, i_max_-i_min_);
2186 unsigned int iwidth = I.
getWidth();
2188 unsigned char *dst_32 = (
unsigned char* ) Ximage->data + (
int)(iP.
get_i()*4*
m_width+ iP.
get_j()*4);
2190 if (XImageByteOrder(
display) == 1) {
2198 unsigned char val = *(src_8+j);
2200 *(dst_32+4*j+1) = val;
2201 *(dst_32+4*j+2) = val;
2202 *(dst_32+4*j+3) = val;
2205 src_8 = src_8 + iwidth;
2218 unsigned char val = *(src_8+j);
2219 *(dst_32+4*j) = val;
2220 *(dst_32+4*j+1) = val;
2221 *(dst_32+4*j+2) = val;
2225 src_8 = src_8 + iwidth;
2234 int i_min = std::max((
int)ceil(iP.
get_i()/
m_scale), 0);
2235 int j_min = std::max((
int)ceil(iP.
get_j()/
m_scale), 0);
2239 unsigned int i_min_ = (
unsigned int)i_min;
2240 unsigned int i_max_ = (
unsigned int)i_max;
2241 unsigned int j_min_ = (
unsigned int)j_min;
2242 unsigned int j_max_ = (
unsigned int)j_max;
2244 if (XImageByteOrder(
display) == 1) {
2246 for (
unsigned int i=i_min_; i<i_max_; i++) {
2247 unsigned char *dst_32 = (
unsigned char* ) Ximage->data + (
int)(i*4*
m_width + j_min_*4);
2248 for (
unsigned int j=j_min_; j<j_max_; j++) {
2251 * ( dst_32 ++ ) = val;
2252 * ( dst_32 ++ ) = val;
2253 * ( dst_32 ++ ) = val;
2259 for (
unsigned int i=i_min_; i<i_max_; i++) {
2260 unsigned char *dst_32 = (
unsigned char* ) Ximage->data + (
int)(i*4*
m_width + j_min_*4);
2261 for (
unsigned int j=j_min_; j<j_max_; j++) {
2263 * ( dst_32 ++ ) = val;
2264 * ( dst_32 ++ ) = val;
2265 * ( dst_32 ++ ) = val;
2271 XPutImage(
display, pixmap, context, Ximage, j_min, i_min, j_min, i_min, j_max_-j_min_, i_max_-i_min_);
2282 "X not initialized" ) ) ;
2303 const unsigned int w,
const unsigned int h )
2307 switch ( screen_depth )
2311 unsigned int bytes_per_line = (
unsigned int)Ximage->bytes_per_line;
2312 for (
unsigned int i = (
unsigned int)iP.
get_i(); i < (
unsigned int)(iP.
get_i()+h) ; i++ ) {
2313 unsigned char *dst_8 = (
unsigned char *) Ximage->data + i * bytes_per_line;
2314 unsigned short *dst_16 = (
unsigned short *) dst_8;
2315 for (
unsigned int j=(
unsigned int)iP.
get_j() ; j < (
unsigned int)(iP.
get_j()+w); j++ )
2318 unsigned int r = val.
R;
2319 unsigned int g = val.
G;
2320 unsigned int b = val.
B;
2321 * ( dst_16 + j ) = (((r << 8) >> RShift) & RMask) |
2322 (((g << 8) >> GShift) & GMask) |
2323 (((b << 8) >> BShift) & BMask);
2329 unsigned int bytes_per_line = (
unsigned int)Ximage->bytes_per_line;
2330 int i_min = std::max((
int)ceil(iP.
get_i()/
m_scale), 0);
2331 int j_min = std::max((
int)ceil(iP.
get_j()/
m_scale), 0);
2335 unsigned int i_min_ = (
unsigned int)i_min;
2336 unsigned int i_max_ = (
unsigned int)i_max;
2337 unsigned int j_min_ = (
unsigned int)j_min;
2338 unsigned int j_max_ = (
unsigned int)j_max;
2340 for (
unsigned int i=i_min_; i<i_max_; i++) {
2341 unsigned char *dst_8 = (
unsigned char* ) Ximage->data + i * bytes_per_line;
2342 unsigned short *dst_16 = (
unsigned short *) dst_8;
2343 for (
unsigned int j=j_min_; j < j_max_; j++)
2346 unsigned int r = val.
R;
2347 unsigned int g = val.
G;
2348 unsigned int b = val.
B;
2349 * ( dst_16 + j ) = (((r << 8) >> RShift) & RMask) |
2350 (((g << 8) >> GShift) & GMask) |
2351 (((b << 8) >> BShift) & BMask);
2354 XPutImage(
display, pixmap, context, Ximage, j_min, i_min, j_min, i_min, j_max_-j_min_, i_max_-i_min_);
2369 unsigned char *dst_32 = (
unsigned char* ) Ximage->data;
2372 unsigned int iwidth = I.
getWidth();
2374 src_32 = src_32 + (int)(iP.
get_i()*iwidth+ iP.
get_j());
2379 if (XImageByteOrder(
display) == 1) {
2384 *(dst_32+4*j) = (src_32+j)->A;
2385 *(dst_32+4*j+1) = (src_32+j)->R;
2386 *(dst_32+4*j+2) = (src_32+j)->G;
2387 *(dst_32+4*j+3) = (src_32+j)->B;
2391 src_32 = src_32 + iwidth;
2402 *(dst_32+4*j) = (src_32+j)->B;
2403 *(dst_32+4*j+1) = (src_32+j)->G;
2404 *(dst_32+4*j+2) = (src_32+j)->R;
2405 *(dst_32+4*j+3) = (src_32+j)->A;
2409 src_32 = src_32 + iwidth;
2418 int i_min = std::max((
int)ceil(iP.
get_i()/
m_scale), 0);
2419 int j_min = std::max((
int)ceil(iP.
get_j()/
m_scale), 0);
2423 unsigned int i_min_ = (
unsigned int)i_min;
2424 unsigned int i_max_ = (
unsigned int)i_max;
2425 unsigned int j_min_ = (
unsigned int)j_min;
2426 unsigned int j_max_ = (
unsigned int)j_max;
2428 if (XImageByteOrder(
display) == 1) {
2430 for (
unsigned int i=i_min_; i<i_max_; i++) {
2431 unsigned char *dst_32 = (
unsigned char* ) Ximage->data + (
int)(i*4*
m_width + j_min_*4);
2432 for (
unsigned int j=j_min_; j<j_max_; j++) {
2434 *(dst_32++) = val.
A;
2435 *(dst_32++) = val.
R;
2436 *(dst_32++) = val.
G;
2437 *(dst_32++) = val.
B;
2443 for (
unsigned int i=i_min_; i<i_max_; i++) {
2444 unsigned char *dst_32 = (
unsigned char* ) Ximage->data + (
int)(i*4*
m_width + j_min_*4);
2445 for (
unsigned int j=j_min_; j<j_max_; j++) {
2447 *(dst_32++) = val.
B;
2448 *(dst_32++) = val.
G;
2449 *(dst_32++) = val.
R;
2450 *(dst_32++) = val.
A;
2454 XPutImage(
display, pixmap, context, Ximage, j_min, i_min, j_min, i_min, j_max_-j_min_, i_max_-i_min_);
2463 "Unsupported depth (%d bpp) for color display", screen_depth ) ) ;
2469 "X not initialized" ) ) ;
2484 if ( ximage_data_init ==
true )
2485 free ( Ximage->data );
2487 Ximage->data = NULL;
2488 XDestroyImage ( Ximage );
2490 XFreePixmap (
display, pixmap );
2498 if (x_color != NULL) {
2521 "X not initialized" ) ) ;
2542 "X not initialized" ) ) ;
2560 xcolor.red = 256 * color.
R;
2561 xcolor.green = 256 * color.
G;
2562 xcolor.blue = 256 * color.
B;
2563 XAllocColor (
display, lut, &xcolor );
2564 XSetForeground (
display, context, xcolor.pixel );
2569 XFreePixmap (
display, pixmap );
2576 "X not initialized" ) ) ;
2590 unsigned int w,
unsigned int h,
2591 unsigned int thickness)
2600 if ((std::fabs(a) <= std::numeric_limits<double>::epsilon() )&&(std::fabs(b) <= std::numeric_limits<double>::epsilon()) )
2632 "X not initialized" ) ) ;
2654 XSetForeground (
display, context, x_color[color.
id] );
2657 xcolor.red = 256 * color.
R;
2658 xcolor.green = 256 * color.
G;
2659 xcolor.blue = 256 * color.
B;
2660 XAllocColor (
display, lut, &xcolor );
2661 XSetForeground (
display, context, xcolor.pixel );
2663 XDrawString (
display, pixmap, context,
2665 text, (
int)strlen ( text ) );
2670 "X not initialized" ) ) ;
2684 unsigned int radius,
2687 unsigned int thickness )
2691 if ( thickness == 1 ) thickness = 0;
2693 XSetForeground (
display, context, x_color[color.
id] );
2696 xcolor.red = 256 * color.
R;
2697 xcolor.green = 256 * color.
G;
2698 xcolor.blue = 256 * color.
B;
2699 XAllocColor (
display, lut, &xcolor );
2700 XSetForeground (
display, context, xcolor.pixel );
2703 XSetLineAttributes (
display, context, thickness,
2704 LineSolid, CapButt, JoinBevel );
2706 if ( fill ==
false )
2708 XDrawArc (
display, pixmap, context,
2715 XFillArc (
display, pixmap, context,
2724 "X not initialized" ) ) ;
2736 unsigned int cross_size,
2738 unsigned int thickness)
2742 double i = ip.
get_i();
2743 double j = ip.
get_j();
2746 ip1.
set_i( i-cross_size/2 );
2748 ip2.
set_i( i+cross_size/2 );
2753 ip1.
set_j( j-cross_size/2 );
2755 ip2.
set_j( j+cross_size/2 );
2762 "X not initialized" ) ) ;
2774 unsigned int thickness )
2778 if ( thickness == 1 ) thickness = 0;
2781 XSetForeground (
display, context, x_color[color.
id] );
2784 xcolor.red = 256 * color.
R;
2785 xcolor.green = 256 * color.
G;
2786 xcolor.blue = 256 * color.
B;
2787 XAllocColor (
display, lut, &xcolor );
2788 XSetForeground (
display, context, xcolor.pixel );
2791 XSetLineAttributes (
display, context, thickness,
2792 LineOnOffDash, CapButt, JoinBevel );
2794 XDrawLine (
display, pixmap, context,
2803 "X not initialized" ) ) ;
2816 unsigned int thickness )
2820 if ( thickness == 1 ) thickness = 0;
2823 XSetForeground (
display, context, x_color[color.
id] );
2826 xcolor.red = 256 * color.
R;
2827 xcolor.green = 256 * color.
G;
2828 xcolor.blue = 256 * color.
B;
2829 XAllocColor (
display, lut, &xcolor );
2830 XSetForeground (
display, context, xcolor.pixel );
2833 XSetLineAttributes (
display, context, thickness,
2834 LineSolid, CapButt, JoinBevel );
2836 XDrawLine (
display, pixmap, context,
2845 "X not initialized" ) ) ;
2860 XSetForeground (
display, context, x_color[color.
id] );
2863 xcolor.red = 256 * color.
R;
2864 xcolor.green = 256 * color.
G;
2865 xcolor.blue = 256 * color.
B;
2866 XAllocColor (
display, lut, &xcolor );
2867 XSetForeground (
display, context, xcolor.pixel );
2870 if (thickness == 1) {
2871 XDrawPoint (
display, pixmap, context,
2876 XFillRectangle (
display, pixmap, context,
2879 thickness, thickness );
2886 "X not initialized" ) ) ;
2905 unsigned int w,
unsigned int h,
2906 const vpColor &color,
bool fill,
2907 unsigned int thickness )
2911 if ( thickness == 1 ) thickness = 0;
2913 XSetForeground (
display, context, x_color[color.
id] );
2916 xcolor.red = 256 * color.
R;
2917 xcolor.green = 256 * color.
G;
2918 xcolor.blue = 256 * color.
B;
2919 XAllocColor (
display, lut, &xcolor );
2920 XSetForeground (
display, context, xcolor.pixel );
2922 XSetLineAttributes (
display, context, thickness,
2923 LineSolid, CapButt, JoinBevel );
2924 if ( fill ==
false )
2926 XDrawRectangle (
display, pixmap, context,
2933 XFillRectangle (
display, pixmap, context,
2942 "X not initialized" ) ) ;
2961 const vpColor &color,
bool fill,
2962 unsigned int thickness )
2966 if ( thickness == 1 ) thickness = 0;
2968 XSetForeground (
display, context, x_color[color.
id] );
2971 xcolor.red = 256 * color.
R;
2972 xcolor.green = 256 * color.
G;
2973 xcolor.blue = 256 * color.
B;
2974 XAllocColor (
display, lut, &xcolor );
2975 XSetForeground (
display, context, xcolor.pixel );
2978 XSetLineAttributes (
display, context, thickness,
2979 LineSolid, CapButt, JoinBevel );
2985 if ( fill ==
false )
2988 XDrawRectangle (
display, pixmap, context,
2991 w > 0 ? w : 1, h > 0 ? h : 1 );
2995 XFillRectangle (
display, pixmap, context,
3004 "X not initialized" ) ) ;
3022 const vpColor &color,
bool fill,
3023 unsigned int thickness )
3027 if ( thickness == 1 ) thickness = 0;
3029 XSetForeground (
display, context, x_color[color.
id] );
3032 xcolor.red = 256 * color.
R;
3033 xcolor.green = 256 * color.
G;
3034 xcolor.blue = 256 * color.
B;
3035 XAllocColor (
display, lut, &xcolor );
3036 XSetForeground (
display, context, xcolor.pixel );
3039 XSetLineAttributes (
display, context, thickness,
3040 LineSolid, CapButt, JoinBevel );
3042 if ( fill ==
false )
3044 XDrawRectangle (
display, pixmap, context,
3052 XFillRectangle (
display, pixmap, context,
3063 "X not initialized" ) ) ;
3090 Window rootwin, childwin ;
3091 int root_x, root_y, win_x, win_y ;
3092 unsigned int modifier ;
3096 XCheckMaskEvent(
display , ButtonPressMask, &event);
3097 XCheckMaskEvent(
display , ButtonReleaseMask, &event);
3098 XMaskEvent (
display, ButtonPressMask ,&event );
3102 ret = XCheckMaskEvent(
display , ButtonPressMask, &event);
3109 &rootwin, &childwin,
3117 "X not initialized" ) ) ;
3145 Window rootwin, childwin ;
3146 int root_x, root_y, win_x, win_y ;
3147 unsigned int modifier ;
3150 XCheckMaskEvent(
display , ButtonPressMask, &event);
3151 XCheckMaskEvent(
display , ButtonReleaseMask, &event);
3152 XMaskEvent (
display, ButtonPressMask ,&event );
3156 ret = XCheckMaskEvent(
display , ButtonPressMask, &event);
3163 &rootwin, &childwin,
3168 ip.
set_v( (
double)event.xbutton.y * m_scale);
3174 "X not initialized" ) ) ;
3207 Window rootwin, childwin ;
3208 int root_x, root_y, win_x, win_y ;
3209 unsigned int modifier ;
3213 XCheckMaskEvent(
display , ButtonPressMask, &event);
3214 XCheckMaskEvent(
display , ButtonReleaseMask, &event);
3215 XMaskEvent (
display, ButtonPressMask ,&event );
3219 ret = XCheckMaskEvent(
display , ButtonPressMask, &event);
3226 &rootwin, &childwin,
3231 ip.
set_v( (
double)event.xbutton.y * m_scale);
3232 switch ( event.xbutton.button ) {
3242 "X not initialized" ) ) ;
3278 Window rootwin, childwin ;
3279 int root_x, root_y, win_x, win_y ;
3280 unsigned int modifier ;
3284 XCheckMaskEvent(
display , ButtonPressMask, &event);
3285 XCheckMaskEvent(
display , ButtonReleaseMask, &event);
3286 XMaskEvent (
display, ButtonReleaseMask ,&event );
3290 ret = XCheckMaskEvent(
display , ButtonReleaseMask, &event);
3297 &rootwin, &childwin,
3302 ip.
set_v( (
double)event.xbutton.y * m_scale);
3303 switch ( event.xbutton.button ) {
3313 "X not initialized" ) ) ;
3335 AllPlanes, ZPixmap ) ;
3339 unsigned char *src_32 = NULL;
3340 src_32 = (
unsigned char* ) xi->data;
3342 if (screen_depth == 16) {
3343 for (
unsigned int i = 0; i < I.
getHeight() ; i++ ) {
3345 for (
unsigned int j = 0; j <
m_height ; j++ ) {
3347 unsigned long pixel = XGetPixel(xi, (
int)j, (
int)i);
3348 I.
bitmap[ij_].
R = (((pixel & RMask) << RShift) >> 8);
3349 I.
bitmap[ij_].
G = (((pixel & GMask) << GShift) >> 8);
3350 I.
bitmap[ij_].
B = (((pixel & BMask) << BShift) >> 8);
3359 if (XImageByteOrder(
display) == 1) {
3365 I.
bitmap[i].
R = src_32[i*4 + 1] ;
3366 I.
bitmap[i].
G = src_32[i*4 + 2] ;
3367 I.
bitmap[i].
B = src_32[i*4 + 3] ;
3374 I.
bitmap[i].
G = src_32[i*4 + 1] ;
3375 I.
bitmap[i].
R = src_32[i*4 + 2] ;
3382 XDestroyImage ( xi ) ;
3387 "X not initialized" ) ) ;
3400 if ( ( display_ = XOpenDisplay ( NULL ) ) == NULL )
3403 "Can't connect display on server %s.", XDisplayName ( NULL ) ) ) ;
3405 screen_ = DefaultScreen ( display_ );
3406 depth = (
unsigned int)DefaultDepth ( display_, screen_ );
3408 XCloseDisplay ( display_ );
3422 if ( ( display_ = XOpenDisplay ( NULL ) ) == NULL )
3425 "Can't connect display on server %s.", XDisplayName ( NULL ) ) ) ;
3427 screen_ = DefaultScreen ( display_ );
3428 w = (
unsigned int)DisplayWidth ( display_, screen_ );
3429 h = (
unsigned int)DisplayHeight ( display_, screen_ );
3431 XCloseDisplay ( display_ );
3439 unsigned int width, height;
3449 unsigned int width, height;
3483 XMaskEvent (
display, KeyPressMask ,&event );
3487 ret = XCheckMaskEvent(
display , KeyPressMask, &event);
3493 "X not initialized" ) ) ;
3526 XComposeStatus compose_status;
3532 XMaskEvent (
display, KeyPressMask ,&event );
3533 XLookupString ((XKeyEvent *)&event, &buffer, 1,
3534 &keysym, &compose_status);
3539 ret = XCheckMaskEvent(
display , KeyPressMask, &event);
3541 XLookupString ((XKeyEvent *)&event, &buffer, 1,
3542 &keysym, &compose_status);
3549 "X not initialized" ) ) ;
3572 Window rootwin, childwin ;
3573 int root_x, root_y, win_x, win_y ;
3574 unsigned int modifier ;
3576 ret = XCheckMaskEvent(
display , PointerMotionMask, &event);
3582 &rootwin, &childwin,
3587 ip.
set_v( (
double)event.xbutton.y * m_scale);
3593 "X not initialized" ) ) ;
3615 Window rootwin, childwin ;
3616 int root_x, root_y, win_x, win_y ;
3617 unsigned int modifier ;
3625 &rootwin, &childwin,
3630 ip.
set_v( (
double)win_y * m_scale);
3636 "X not initialized" ) ) ;
3648 for (i = 31; i >= 0; --i) {
3649 if (u32val & 0x80000000L)
3656 #elif !defined(VISP_BUILD_SHARED_LIBS)
3658 void dummy_vpDisplayX() {};
void clearDisplay(const vpColor &color=vpColor::white)
void init(vpImage< unsigned char > &I, int winx=-1, int winy=-1, const std::string &title="")
int m_windowYPosition
display position
unsigned int getScreenDepth()
void displayCross(const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness=1)
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
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
void displayImage(const vpImage< unsigned char > &I)
static const vpColor darkBlue
unsigned char G
Green component.
bool m_displayHasBeenInitialized
display has been initialized
static const vpColor green
static int round(const double x)
static const vpColor lightRed
bool getPointerPosition(vpImagePoint &ip)
vpWin32Window window
The window.
static const vpColor orange
unsigned int getScreenWidth()
bool getClick(bool blocking=true)
void set_i(const double ii)
int m_windowXPosition
display position
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 setScale(vpScaleType scaleType, unsigned int width, unsigned int height)
void set_u(const double u)
static double sqr(double x)
void displayCharString(const vpImagePoint &ip, const char *text, const vpColor &color=vpColor::green)
static void display(const vpImage< unsigned char > &I)
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)
resize the image : Image initialization
static const vpColor gray
void displayPoint(const vpImagePoint &ip, const vpColor &color, unsigned int thickness=1)
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 set_j(const double jj)
Error that can be emited by the vpDisplay class and its derivates.
vpScaleType
Values that could be applied to a display to down scale the size of the display.
unsigned char R
Red component.
void setTitle(const std::string &title)
unsigned int getHeight() const
Defines a rectangle in the plane.
void setFont(const std::string &font)
static const vpColor darkGreen
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
static const vpColor yellow
static const vpColor lightBlue
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
unsigned int getScreenHeight()
static const vpColor blue
void displayDotLine(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1)