[vtkusers] Usage of vtkLabelRenderStrategy
Marcus D. Hanwell
marcus.hanwell at kitware.com
Thu May 13 09:51:59 EDT 2010
On Thu, May 13, 2010 at 8:15 AM, Oliver Kania
<kania.oliver at googlemail.com>wrote:
> Hello,
>
> I frequently use vtkTextActor within a graphics library I wrote.
> Is it somehow possible to replace these occurences with a
> vtkLabelRenderStrategy, maybe within a vtkContextDevice ?
> The reason I want to do this is simply to enable rendering of unicode
> characters, more precisely certain characters
> that are not within the 7-Bit ascii set which text actor allows.
>
> The following sample code does not show any text :
>
>
> --------------------------------------------------------------------------------
> vtkRenderWindow *renWin = vtkRenderWindow::New();
> renWin->AddRenderer( ren1 );
> renWin->SetSize( 300, 300 );
> vtkStdString l_vtkStdStr("Hallo");
> float f_coords[] = {50.0f,50.0f};
>
> l_vtkDevice->Begin(ren1);
> l_vtkDevice->DrawString(f_coords,l_vtkProp,l_vtkStdStr);
> l_vtkDevice->End();
>
> renWin->GetInteractor()->Render();
>
> --------------------------------------------------------------------------------
>
> I also tried using vtkLabelRenderStrategy directly etc.
>
If you take a look at the vtkLabelRenderStrategy Doxygen documentation,
http://www.vtk.org/doc/nightly/html/classvtkLabelRenderStrategy.html
It has functions such as,
virtual void RenderLabel (int x[2], vtkTextProperty *tprop, vtkUnicodeString
label)
You will need to use vtkUnicodeString to store unicode characters, but this
should work (I haven't had chance to test it out yet). The
vtkQtLabelRenderStrategy is likely to work well as Qt handles Unicode
rendering really well, and I have used this in the past. I will be adding
extra overloads to the vtkContext2D class to take unicode strings in
addition to the standard string.
Thanks,
Marcus
--
Marcus D. Hanwell, Ph.D.
R&D Engineer, Kitware Inc.
(518) 881-4937
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100513/28a4e2d1/attachment.htm>
More information about the vtkusers
mailing list