[vtkusers] displaying 2D textannotations

Sercani sercanimailgroups at gmail.com
Fri Jan 23 08:20:49 EST 2009


Hi Andreas;
You can use vtkCaptionActor2D or vtkCaptionRepresentation... They are thread
safe and easy to use...

-----Original Message-----
From: vtkusers-bounces at vtk.org [mailto:vtkusers-bounces at vtk.org] On Behalf
Of Andreas Brüning
Sent: Friday, January 23, 2009 12:48 PM
To: vtkusers at vtk.org
Subject: [vtkusers] displaying 2D textannotations

Dear vtkuser,

i need help to display 2D textannotations in my MFC application. I run
serveral vtkRenderWindows. Each one of them in there own thread(user
interface thread). The windows itself are integrated in a class derived by
CWnd. The windows are able to communicate with each other by using one
single managmentobject. Basically it works like if one window is
manipulateted it sends a message to a managementobject and than this
managementobject decides which other window (or better the scene of which
window) has to be updated. The updateinformation are send by
posthtreadmessage to the windows.
So far i display 3D objects, Images, Lines... and everythings works fast and
robust. But i got problems displaying 2D textannotations. I tried different
ways but all the time i got problems. What i did:

using vtkTextactor: First i instanciate several objects(8 for each window)
of vtkTexactor and place them in the windows. I can display the
textannotations with it and it works well during the runtime. But when i
close the application i get always an error. It is an error while freeing
the heap memory and it occurs when the vtkFreetypeUtilities is releasing the
CacheManager. If i run everything singlethreaded, this error does not occur.


using vtkTextMapper/ vtkActor2D: I tried the same scenario with
vtkTextMapper/ vtkActor2D pairs and the error when i close the application
is gone. But the text is not displayed correct. It is really strange. To
manipulate a scene i developed different methods and i can call them using
the mouse in a window or call them from "outside" by posting messages to the
windowthread(from the managementobject). If i use the mouse everthing works
well, but i call the same methods by posting messages the text is often
messed up. Which means that the spaces between the single characters are not
correct. So sometines i have a big space between the characters and
sometimes the charaters are above each other. If i use the mouse than
everthing is immediately correct. 

using vtkCornerAnnotation: I tried also vtkCornerAnnotation but with this i
cant even display the windows. If i start the application an error occurs
somewhere inside the ftgl libaries. 

Does anyone has an idea what goes wrong? I know it is hard without code, but
my programm is huge and i cant provide everything. I setup the vtkwindow
like this in the Createmethode of my vtkWindow (class derived by CWnd):

m_vtkRenderer = vtkRenderer::New();
m_vtkWin32OpenGLWindow = vtkWin32OpenGLRenderWindow::New();

// setup the window
m_vtkWin32OpenGLWindow->SetWindowId(this->GetSafeHwnd());
m_vtkWin32OpenGLWindow->SetParentId(parent->GetSafeHwnd());

m_vtkInteractor = vtkWin32RenderWindowInteractor::New();
m_vtkWin32OpenGLWindow->AddRenderer(m_vtkRenderer);

m_vtkInteractor->SetRenderWindow(m_vtkWin32OpenGLWindow);

In other methods i setup the rest of the vtkpipeline like shown below:

m_vtkTextMapper_OL = vtkTextMapper::New();
m_vtkTextMapper_OL->GetTextProperty()->SetJustificationToLeft();	
m_vtkTextMapper_OL->GetTextProperty()->SetVerticalJustificationToTop();
m_vtkTextMapper_OL->GetTextProperty()->SetFontFamilyToArial();
m_vtkTextMapper_OL->GetTextProperty()->SetLineSpacing(1.0);
m_vtkTextMapper_OL->GetTextProperty()->SetColor(1.0,1.0,1.0);
m_vtkTextMapper_OL->GetTextProperty()->SetFontSize(12);
			
m_vtkTextMapper_OL->SetInput("first line of text\nbla bla text next line");

m_vtkActorText_OL = vtkActor2D::New();
m_vtkActorText_OL->SetMapper(m_vtkTextMapper_OL);
m_vtkRenderer->AddActor2D(m_vtkActorText_OL);


And by using the MFC messagehandling like OnMouseMove, OnLButtonUp, OnSize
... i interact with the scene.My suggestion of all this is, that the ftgl
libaries are not threadsafe. Is anything known about this? Or what can be
the mistake. If you need more infermation please let me know. 

I hope someone can tell me why i get problems displaying text. I am using
the stable realese version 5.2.0 of Vtk.

thanks in advance 
Andi
____________________________________________________________________
Psssst! Schon vom neuen WEB.DE MultiMessenger gehört? 
Der kann`s mit allen: http://www.produkte.web.de/messenger/?did=3123

_______________________________________________
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at:
http://www.vtk.org/Wiki/VTK_FAQ
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers




More information about the vtkusers mailing list