AIS_TextLabel vertical alignement

Hello all.

I'm facing a problem using AIS_TextLabel and the vertical alignement.

I'm placing such object near to a line with the SetPosition function (in fact at the center of a line).

When using the SetVJustification function with Graphic3d_VTA_TOP, the display is nice, there is a small space behind the line and the label (see in first attached screenshot [1-aligntop.jpg]).

But when using Graphic3d_VTA_BOTTOM, the text is really too near from the line (see in second attached screenshot [2-alignbottom.jpg]).

Does anyone knows a way to add a small margin when using bottom alignement or an option to configure to get a small space between the line and the text ?

My text always follows the line direction, updating its angle when the camera moves.

Thank you very much.

gkv311 n's picture

I think that AIS_TextLabel lacks an option for what you are trying to achieve. You would have to subclass this presentation or define your own to make this precisely. This could be done by adding a local transformation or adjusting transform persistence.

What I may suggest is a workaround by using center alignment option and an extra empty line in text.

pload VISUALIZATION;
vinit View1;
vfront;
vpoint p0 0 0 0;
vpoint p1 1 0 0;
vsegment s p0 p1;
vdisplay s;
vfit;
vdrawtext tt "100 topp" -pos 0 0 0 -color WHITE  -valign top -height 40;
vbounding tt;
vdrawtext tc "100 cenp\n" -pos 0 0 0 -color GREEN  -valign center -height 40;
vbounding tc;
vdrawtext tb "100 botp" -pos 0.2 0 0 -color RED -valign bottom -height 40;
vbounding tb;

screenshot

Guillaume CHAFFAROD's picture

Nice hack !!
I just have to count number of lines to ensure that I add enough line breaks if the original text should have line breaks, but it works like a charm.

Thank you very much.