Diameter symbol with 2D Text

Hi all,

does anybody know, how to draw the diameter sign with 2D text?

My code:

void My_2D_Text::SetContext(const Handle(AIS2D_InteractiveContext)& theContext)
{
AIS2D_InteractiveObject::SetContext(theContext);

Handle(Graphic2d_Text) text;
text = new Graphic2d_Text(this, "Ø", 0, 0, 90, Aspect_TOT_SOLID, 1.);
text->SetFontIndex (1);
text->SetColorIndex (1);
text->SetZoomable (Standard_True);
text->SetAlignment (Graphic2d_TOA_LEFT);
}

Sadly OCCT doesn't draw it.

Thank you

Arno

Forum supervisor's picture

Dear Arno,
It seems you are wrong,
OCCT draws it (see the attached picture).
Draw reproducer:
pload ALL
v2dinit
v2dtext "Ø225" 0 10
Regards

Attachments: 
Denis Barbier's picture

It works only if sizeof(wchar_t) == sizeof(short), which is wrong on Linux for instance.

Arno Hofmann's picture

Dear Supervisor,

thank you for your draw reproducer.

Sorry, but what is v2dtext? How could I reproduce your sample with Graphic2d_Text? Have I to use wchar_t?

Kind regards

Arno

Forum supervisor's picture

Dear Arno,
'v2dtext' is a Draw command.
Usage : v2dtext text_str position(x y) [angle scale font]
You may find it at the Viewer2dTest_ViewerCommands.cxx file.
Regards

Arno Hofmann's picture

Dear Supervisor,

you're right, your sample works well, I was wrong!

But my code doesn't work yet. Could it be my initialization of the viewer is wrong?

bool OCCT_2DViewer::InitViewer(void* wnd)
{
Handle(Graphic3d_WNTGraphicDevice) theGraphicDevice;

try
{
theGraphicDevice = new Graphic3d_WNTGraphicDevice();
}
catch (Standard_Failure)
{
return false;
}

TCollection_ExtendedString a2DName("Visu2D");
myViewer = new V2d_Viewer(theGraphicDevice,a2DName.ToExtString());
myViewer->SetCircularGridValues(0,0,1,8,0);
myViewer->SetRectangularGridValues(0,0,1,1,0);
myAISInteractiveContext2D = new AIS2D_InteractiveContext(myViewer);

Handle(WNT_Window) aWNTWindow = new WNT_Window(theGraphicDevice, reinterpret_cast (wnd));
aWNTWindow->SetBackground(Quantity_NOC_MATRAGRAY);

// force drawing into offscreen bitmap
aWNTWindow->SetDoubleBuffer(Standard_True);

Handle(WNT_WDriver) aDriver = new WNT_WDriver(aWNTWindow);
myView = new V2d_View(aDriver, myViewer, 0, 0, 50);

if (!aWNTWindow->IsMapped()) aWNTWindow->Map();
UpdateView();
RedrawView();

return true;
}

void CAD_2D_Text::SetContext(const Handle(AIS2D_InteractiveContext)& theContext)
{
AIS2D_InteractiveObject::SetContext(theContext);

Handle(Graphic2d_Text) text = new Graphic2d_Text(this, TCollection_ExtendedString("Ø"), _pBasePoint->GetX(), _pBasePoint->GetY(), _rotation * PI180, Aspect_TOT_SOLID, factor);
text->SetFontIndex (1);
text->SetColorIndex (colorIndex);
text->SetZoomable (Standard_True);
text->SetAlignment (Graphic2d_TOA_LEFT);
}

Kind regards

Arno

Forum supervisor's picture

Dear Arno,
You may easy check it tracking implementation of the 'v2init' command.
See Viewer2dTest::ViewerInit (aPxLeft, aPxTop, aPxWidth, aPxHeight).
Regards

Arno Hofmann's picture

Dear Supervisor,

the diameter character works fine, but when it was drawn the x coordinate value is very big. After that, I cannot move the geometry in the x coordinate.

When I draw a text without any diameter character the value of the x coordinate is normal, none problems about that.

Please check attached picture.

Kind regards

Arno

Attachments: