
Mon, 10/31/2011 - 14:07
Forums:
Hello all,
the SetAngle() method of the Prs3d_LineAspect class does not work. Does anybody know why, or is there another solution in the OOCT framework?
My code:
Handle(Prs3d_Presentation) aPresentation = new Prs3d_Presentation(myAISContext->CurrentViewer()->Viewer());
Handle(Prs3d_TextAspect)aTextAspect = new Prs3d_TextAspect();
aTextAspect->SetHeight(30.0);
aTextAspect->SetColor(Quantity_NOC_GREEN);
aTextAspect->SetAngle(90.0);
Prs3d_Text::Draw(aPresentation, aTextAspect, "MyText", gp_Pnt(0, 0, 0));
aPresentation->Display();
Thank you to any help I will get.
Kind regards
Arno
Fri, 11/11/2011 - 14:45
Does nobody have a solution for this problem or is it a bug in OCCT???
Fri, 11/11/2011 - 15:02
Dear Arno,
Support of text angle is not implemented in OCCT for the moment.
If the problem is urgent for you, I can propose you our services.
You may contact us via Contact Form http://www.opencascade.org/about/contacts/.
We will try to find a solution/workaround acceptable for you.
Regards
Fri, 11/11/2011 - 18:01
Is there any other solution/workaround to rotate a text? For example to convert the text to a shape and then rotate the shape? Or could I draw a 2D text in 3D view?
Kind regards
Arno
Wed, 01/25/2012 - 10:21
Hi all,
does anybody know to draw rotated text in OCCT? How did you fix that problem with a workaround or are there other ways to do this?
I appreciate any help.
Many thanks
Arno Hofmann
Wed, 01/25/2012 - 14:27
Hi Arno,
I'm new to occ, but maybe I have an idea for you.
I have read in the forum, you can use Visual3d_Layer to display text as an overlay in the viewer.
Maybe it is possible to rotate the text in this way.
http://www.opencascade.org/org/forum/thread_10845/
http://www.opencascade.org/org/forum/thread_10090/
http://www.opencascade.org/org/forum/thread_15849/
Regards
Alex
Wed, 01/25/2012 - 22:10
Hi Alex,
thank you for your good idea :-)
I already know the Visual3d_Layer.
Visual3d_Layer* myLayer=new Visual3d_Layer(myView->View()->ViewManager(), Aspect_TOL_OVERLAY, Standard_False);
myLayer->SetViewport(w,h);
myLayer->SetOrtho(0,w,h,0,(Aspect_TypeOfConstraint) -1);
// then you could draw on the given layer
myLayer->Begin();
// draw some text
Standard_CString aString = "TEST";
int xPos = w/2;
int yPos = h/2;
int textSize = 10;
myLayer->SetTextAttributes( Graphic3d_NOF_ASCII_ITALIC_COMPLEX, Aspect_TODT_NORMAL, Quantity_NOC_ORANGE );
myLayer->DrawText(aString, xPos, yPos, textSize);
But I don't know how to rotate the given text.
Kind regards
Arno
Thu, 01/26/2012 - 13:44
Hi Arno,
sorry my fault.
I thought it would be possible to rotate the layer and the text rotates with.
But I've read something else in visu.pdf
Have you try the Graphic2d_Text class (6. 4 Dealing with text)?
Or for 3D the Graphic3d_Group::Text (5. 1. 7 Graphic3d text)
If I understand correctly, it should be possible to specify an angle for the text.
Sorry if I'm wrong, but I have not used this part of OCC before.
Regards
Alex
Fri, 01/27/2012 - 10:23
Hi Alex,
Graphic2d_Text would be a good idea, but I don't know if i can draw 2d text in a 3d viewer.
Well, Graphic3d_Group::Text I have never used, I should dealing with them.
The code below doesn't work:
Handle(Prs3d_Presentation) aPresentation= new Prs3d_Presentation(myAISContext->CurrentViewer()->Viewer());
Handle(Prs3d_TextAspect)aTextAspect = new Prs3d_TextAspect();
aTextAspect->SetFont(aFontName); // Graphic3d_NOF_ASCII_SIMPLEX
aTextAspect->SetHeight(height);
aTextAspect->SetColor(color);
aTextAspect->SetAngle(rotation);
Prs3d_TextAspect::SetAngle is not implemented yet in OCCT.
Kind regards
Arno
Fri, 01/27/2012 - 13:46
Hi Arno,
I think I have good news :)
For me it works with the code below (the text is drawn with 90°):
Handle (Prs3d_Presentation) aPrs = new Prs3d_Presentation(ViewerTest::GetAISContext()->CurrentViewer()->Viewer());
// get the group
Handle (Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (aPrs);
// change the text aspect
Handle(Graphic3d_AspectText3d) aTextAspect = new Graphic3d_AspectText3d ();
aTextAspect->SetTextZoomable (Standard_True);
aTextAspect->SetTextAngle (90.0);
aGroup->SetPrimitivesAspect (aTextAspect);
// add a text primitive to the structure
Graphic3d_Vertex aPoint (1, 1, 1);
aGroup->Text (Standard_CString ("Text"), aPoint, 20.0);
aPrs->Display();
ViewerTest::GetAISContext()->UpdateCurrentViewer();
Hope that helps you.
Regards
Alex
Fri, 01/27/2012 - 21:52
Hi Alex,
you make my day! It really works, it's so great!!!
Well, the problem was the class Prs3d_TextAspect, but the class Graphic3d_AspectText3d can rotate the text.
Thank you again.
Kind regards
Arno