@@ -1406,14 +1406,15 @@ output_draw(struct lstopo_output *loutput)
14061406 hwloc_obj_t root = hwloc_get_root_obj (topology );
14071407 struct lstopo_obj_userdata * rlud = root -> userdata ;
14081408 unsigned depth = 100 ;
1409- unsigned totwidth , totheight , offset , i ;
1409+ unsigned totwidth , totheight , offset , i , j ;
14101410 time_t t ;
14111411 char text [3 ][128 ];
14121412 unsigned ntext = 0 ;
14131413 char hostname [122 ] = "" ;
14141414 const char * forcedhostname = NULL ;
14151415 unsigned long hostname_size = sizeof (hostname );
14161416 unsigned maxtextwidth = 0 , textwidth ;
1417+ unsigned infocount = 0 ;
14171418
14181419 if (legend ) {
14191420 forcedhostname = hwloc_obj_get_info_by_name (hwloc_get_root_obj (topology ), "HostName" );
@@ -1469,6 +1470,15 @@ output_draw(struct lstopo_output *loutput)
14691470 maxtextwidth = textwidth ;
14701471 ntext ++ ;
14711472
1473+ for (i = 0 ; i < root -> infos_count ; i ++ ) {
1474+ if (!strcmp (root -> infos [i ].name , "lstopoLegend" )) {
1475+ infocount ++ ;
1476+ textwidth = get_textwidth (loutput , root -> infos [i ].value , (unsigned ) strlen (root -> infos [i ].value ), fontsize );
1477+ if (textwidth > maxtextwidth )
1478+ maxtextwidth = textwidth ;
1479+ }
1480+ }
1481+
14721482 for (i = 0 ; i < loutput -> legend_append_nr ; i ++ ) {
14731483 textwidth = get_textwidth (loutput , loutput -> legend_append [i ], (unsigned ) strlen (loutput -> legend_append [i ]), fontsize );
14741484 if (textwidth > maxtextwidth )
@@ -1492,7 +1502,7 @@ output_draw(struct lstopo_output *loutput)
14921502 /* loutput height is sum(root, legend) */
14931503 totheight = rlud -> height ;
14941504 if (legend )
1495- totheight += gridsize + (ntext + loutput -> legend_append_nr - 1 ) * (linespacing + fontsize ) + fontsize + gridsize ;
1505+ totheight += gridsize + (ntext + infocount + loutput -> legend_append_nr - 1 ) * (linespacing + fontsize ) + fontsize + gridsize ;
14961506 loutput -> height = totheight ;
14971507
14981508 } else { /* LSTOPO_DRAWING_DRAW */
@@ -1506,11 +1516,18 @@ output_draw(struct lstopo_output *loutput)
15061516 /* Draw legend */
15071517 if (legend ) {
15081518 offset = rlud -> height + gridsize ;
1509- methods -> box (loutput , & WHITE_COLOR , depth , 0 , loutput -> width , totheight , gridsize + (ntext + loutput -> legend_append_nr - 1 ) * (linespacing + fontsize ) + fontsize + gridsize , NULL , 0 );
1519+ methods -> box (loutput , & WHITE_COLOR , depth , 0 , loutput -> width , totheight , gridsize + (ntext + infocount + loutput -> legend_append_nr - 1 ) * (linespacing + fontsize ) + fontsize + gridsize , NULL , 0 );
15101520 for (i = 0 ; i < ntext ; i ++ , offset += linespacing + fontsize )
15111521 methods -> text (loutput , & BLACK_COLOR , fontsize , depth , gridsize , offset , text [i ], NULL , i );
1522+ for (i = 0 , j = 0 ; i < root -> infos_count ; i ++ ) {
1523+ if (!strcmp (root -> infos [i ].name , "lstopoLegend" )) {
1524+ methods -> text (loutput , & BLACK_COLOR , fontsize , depth , gridsize , offset , root -> infos [i ].value , NULL , j + ntext );
1525+ j ++ ;
1526+ offset += linespacing + fontsize ;
1527+ }
1528+ }
15121529 for (i = 0 ; i < loutput -> legend_append_nr ; i ++ , offset += linespacing + fontsize )
1513- methods -> text (loutput , & BLACK_COLOR , fontsize , depth , gridsize , offset , loutput -> legend_append [i ], NULL , i + ntext );
1530+ methods -> text (loutput , & BLACK_COLOR , fontsize , depth , gridsize , offset , loutput -> legend_append [i ], NULL , i + ntext + infocount );
15141531 }
15151532 }
15161533}
0 commit comments