[vtkusers] displaying 2D textannotations
Andreas Brüning
mail-andi at web.de
Mon Jan 26 04:08:55 EST 2009
Hey,
thanks for your reply. I tried your cornerAnnotation code snippet and yes it crahses always when i want to display the windows. The error ("Access violation reading location..." in vtkfreetype.dll ) occurs when i call Render() and the error is in Line 272 of pshalgo.c. This belongs to freetype. If i run the programm with only one window everything works well and without errors or leaks. But i want to display three or four windows. I start the programm serveral times and checked if the error occurs always at the same time and i found out that sometimes one window is already displyaing the text sometimes i fails when i call render the first time so i suggest the freetype stuff is not implemented threadsafe. Another thing is that i put the Render call in a global CriticalSection to make sure that the windows cant render at the same time. In this case everything works and displayed correctly but i loose a lot of performance.
The best results i got so far are with vtkTextActors. They display the text always correct. The problem is when i want to close the application. I call the Delete method for every vtkobject. If i would forget one i would get memoryleaks when i close the application.
I am running out of ideas how i can fix this problem. Why the vtkTextactor displays the text correct and fails while closing the application and with vtkTextMapper i can close the application but not display the text correct?
Please help me!
Andi
-----Ursprüngliche Nachricht-----
Von: "Sercani" <sercanimailgroups at gmail.com>
Gesendet: 23.01.09 16:49:30
An: 'Andreas Brüning' <mail-andi at web.de>
Betreff: RE: [vtkusers] displaying 2D textannotations
Allright, i read your first mail "quickly" so missed the main purpose :D You
said that you cant event start the program if you use vtkCornerAnnotation
but where does it exactly crash? I use corner annotations like this:
...............
public static int UPPER_LEFT_CORNER = 2;
public static int LOWER_LEFT_CORNER = 0;
public static int UPPER_RIGHT_CORNER = 3;
public static int LOWER_RIGHT_CORNER = 1;
vtkCornerAnnotation corner=new vtkCornerAnnotation();
corner.GetTextProperty().SetColor(color);
corner.GetTextProperty().SetFontSize(fontsize);
corner.SetMaximumLineHeight(intervalsize);
corner.SetShowSliceAndImage(1);
corner.SetImageActor(imageactor);
panel.GetRenderer().AddActor(corner);
corner.SetText(LOWER_LEFT_CORNER, "some text");
corner.SetText(UPPER_LEFT_CORNER, "some text too");
corner.SetText(LOWER_RIGHT_CORNER, "blabla");
corner.SetText(UPPER_RIGHT_CORNER, "blablabla");
.................
But when something goes wrong with vtk libraries (that i can't understand) i
usually recompile the vtk with the nightly build from cvs...And if something
goes wrong with freeing up the memory, i suggest do not write the delete
functions of your vtk objects to the destructors of your classes,
i used to have problems with those delete functions...
Have a nice day...
Sercani.
-----Original Message-----
From: Andreas Brüning [mailto:mail-andi at web.de]
Sent: Friday, January 23, 2009 5:09 PM
To: Sercani
Subject: RE: [vtkusers] displaying 2D textannotations
Hi,
thank you for the quick answer. I tried vtkCaptionActor2D but i dont know if
it is right for me. I want to display textannotations in the corners of each
window but how can i do this with vtkCaptionActor2D. Can you show me an
example please or how have to configure an vtkCaptionActor2D object for
this?
I tried more possibilities and and it looks like that the vtkTextMapper or
vtkActor2D is not threadsafe.The error described in my first post (with the
characters and th incorrect positions) only happends when i modify a window
from "ouside". This is just the modification of different scenes(in two
windows) at the same time. One with the mouse and the others with messages.
Is it possible to make the vtkTextMapper threadsafe? And how is it with the
vtkTextActor? They display the text correct at runtime but the application
crashs in the end, like described.
thanks for help
Andi
Von: "Sercani" <sercanimailgroups at gmail.com>
Gesendet: 23.01.09 14:21:02
An: <vtkusers at vtk.org>
Betreff: RE: [vtkusers] displaying 2D textannotations
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
____________________________________________________________________
Psssst! Schon vom neuen WEB.DE MultiMessenger gehört?
Der kann`s mit allen: http://www.produkte.web.de/messenger/?did=3123
____________________________________________________________________
Psssst! Schon vom neuen WEB.DE MultiMessenger gehört?
Der kann`s mit allen: http://www.produkte.web.de/messenger/?did=3123
More information about the vtkusers
mailing list