Open CASCADE, the 3D modelling kernel
3D modeling & numerical simulation

Open CASCADEShowroomGet it!Developer CornerSupport and ProductsAbout us
Technical overview
Areas of use
Advantages
FAQ
Screenshots
Shape factory
Shape gallery
Demonstrations
What's new
System requirements
Download Center
Public license
Documentation
Getting started
Forum
Open Source community
Training and e-learning
A la Carte Support
Value-added software
Complementary Components
Customer Corner
Company Profile
Marketing Materials
Contact Us
News
Home / Developer Corner / Forum / Text Height and Visual3d_Layer Text Height

Forum

Text Height and Visual3d_Layer Text Height
Domagoj Baronica2007/01/21 20:58
Hi,

I'm having problems setting the height of text in my 3D viewer. Here is the code:
TCollection_ExtendedString aTCoText(text);
gp_Pnt aPnt, OrigineDimZT(0,0,0);
OrigineDimZT=textPlace;
BRepBuilderAPI_MakeVertex vert(OrigineDimZT);

Handle(Prs3d_Presentation) aPresentation= new Prs3d_Presentation(m_pAISContext->CurrentViewer()->Viewer(),Standard_True);
Handle(Prs3d_TextAspect) aTextAspect= new Prs3d_TextAspect();
aTextAspect->SetHeight(15);
Prs3d_Text::Draw(aPresentation,aTextAspect,aTCoText, OrigineDimZT);

I tried many different values in SetHeight method, but the text height is unchanged in the viewer. It really bothers me because it makes OC text functionality almost unusable.

In addition, the same behavior is seen when I use Visual3d_Layer to display text as an overlay in the viewer. The size of text can't be changed.

Is there any other way to display 2D and 3D text in 3D viewer?

Thanks
Pawel2009/06/04 10:58
Hi,

I observe a similar behavior using Visual3d_Layer. No matter what font I use I have to set the text size to 12.0 (it's quite small) otherwise it won't be displayed. I use the following code:

myLayer->SetColor (color);                    
myLayer->SetTextAttributes(Graphic3d_NOF_ASCII_MONO, Aspect_TODT_NORMAL, color);
myLayer->DrawText(myString, 0, 0, 12.0);

Anyone has an idea why?
Pawel
Paul Jimenez2009/06/04 11:52
I had a similar problem where the text would sometimes disappear just because. At the end, it had to do with the order of methods being called. It is also worth noting that the starting point of the text MUST BE inside the canvas.

The order I use here is as follows:

SetTextAttributes
TextSize (you may not need it)
SetColor
DrawText

So... just try switching SetColor and SetTextAttributes and see if that works for you.
Pawel2009/06/04 12:42
Hi Paul,

thanks for your reply. Well, I tried and I guess something strange is going on here... Switching the order of the calls does not help in my case but... in the meanwhile I implemented redrawing of the layer according to the view rotation/zooming etc. The strange thing is that if I use "12.0" as the text size it gets displayed correctly the first time I draw it. Different values of the text size work after the layer is redrawn (e.g. after zooming in my case).

I keep on investigating. Displaying of the ColorScale with different text sizes works so it should also work for the layer.

By the way, is this possible to display both the ColorScale and a user-drawn layer at the same time? One seems to erase the other in my case.

Pawel

P.S. Thanks for the post: http://www.opencascade.org/org/forum/thread_10090/ - really helpful.
Paul Jimenez2009/06/04 12:55
I have no idea what you mean by ColorScale.

What I highly recommend you is that you search the forums for OCCPATCH. There is a post that deals with font size in the layer and another one with the layer not being re-drawn in a few cases.

After applying those patches, the over-layer I use works just fine. I only use a single font size, though.
Pawel2009/06/04 13:00
By ColorScale I meant a call to

myView->ColorScaleDisplay().

I have a version with some OCCPATCHes applied. I'll see if I have the corresponding patches and experiment with that.

Thanks
Pawel

Pawel2009/06/04 19:26
Hi Paul,

I found a workaround for displaying texts on a layer which looks like this:

//dummy call to set text attributes
myLayer->Begin();                    
myLayer->SetColor (color);
myLayer->SetTextAttributes(Graphic3d_NOF_ASCII_MONO, Aspect_TODT_NORMAL, scaleTextColor);
myLayer->DrawText("test", 0, 0, textSize);
myLayer->End();

//the desired functionality
myLayer->Clear();
myLayer->Begin();                    
myLayer->SetViewport(w ? w : 1, h ? h : 1);
myLayer->SetOrtho(0., extremumValue, 0., extremumValue, Aspect_TOC_TOP_LEFT);
myLayer->SetColor (color);
myLayer->SetTextAttributes(Graphic3d_NOF_ASCII_MONO, Aspect_TODT_NORMAL, color);                              
myLayer->DrawText(myString, 0, 0, textSize);

However, I already noticed two problems: (1)Unfortunately, I don't think it works for line width. (2) Besides it affects the font of the color scale.

So I'm going to test your patch: http://www.opencascade.org/org/forum/thread_15016/ tomorrow or Monday.

Pawel
Pawel2009/06/08 19:40
Hi Paul,

after some testing I guess I'm again more confused than before. I've tested three applications: one had no problem with setting the font size, one used the workaround I posted before, the last one could only work with the font size = 12.0 ...

So I applied two patches:
- one (http://www.opencascade.org/org/forum/thread_16172/ from François Lauzon) dealing with the layer not being redrawn under some conditions (I can confirm it works)
- the one from you (http://www.opencascade.org/org/forum/thread_15016/) dealing with line width and text size. To restrict the number of test cases I tested only the text size. Unfortunately, the patch didn't work for me... Again, I saw an interference with the font used by the ColorScale so there are a couple of things which I hope I will review soon to get it work.

Pawel
Paul Jimenez2009/06/09 07:52
Does the application that has no problems show the ColorScale? It may be an issue with that.

Anyway, I have had plenty of weird issues with OpenCASCADE's Visualization. Many of those issues have been solved with some patches, but others require trying different methods to work around them.

It is nice the team is working now in a new set of Visualization classes (NIS), but it is still far from complete. It also has problems (with the PC I use here with Intel graphics shapes are not drawn, yet they can be highlighted).

As usual, if you find a patch or workaround, do not forget to mention it.
 
 
Latest news
  • FAQ section updated
  • OPEN CASCADE Uses Intel ® Parallel Studio XE to Introduce Parallelism into SALOME SMESH Module
  • Open CASCADE Technology 6.5.2 is available for download!

  • © OPEN CASCADE 2000 - 2012  |  Search  |  Contacts   |  Site map