[vtkusers] Bug in vtkTextActor for accentuated characters?

Pof jd379252 at gmail.com
Fri Sep 3 08:12:15 EDT 2010


Hi all,

I am having trouble displaying accentuated characters in vtkTextActor with
vtk5.6.0 under MS-VC++2005.
Here below is an exemple that reproduces the problem, by printing the same
string than contains accents "é,è,à".
When I run this small prog, as a result I obtain that accentuated characters
(é,è...) are :
- correctly displayed when used in a vtkScalarBarActor title,
- not displayed when incorporated in vtkTextActor.

Any idea where does this come from and how to solve it?

As an additional comment, this used to work correctly under vtk5.0.x, it is
only broken from vtk5.2.x up to vtk5.6.0.

Thanks
JD


//////////////////////////////////////////////////////
////////////////// vtkTextActor bug //////////////////
//////////////////////////////////////////////////////
#include "vtkActor.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkCamera.h"
#include "vtkTextProperty.h"
#include "vtkTextActor.h"
#include "vtkActor2D.h"
#include "vtkLookupTable.h"
#include "vtkScalarBarActor.h"

int main()
{
    // Tested string
    char text[] = "Test: é, è, à";

    // Create an example text actor
    vtkTextActor *textActor = vtkTextActor::New();
    textActor->SetInput(text);

textActor->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
    textActor->SetPosition(0.50,0.50);
    textActor->GetTextProperty()->SetFontSize(30);
    textActor->GetTextProperty()->SetJustificationToCentered();
    textActor->GetTextProperty()->SetColor(1, 0, 0);

    // Create a Lut
    vtkLookupTable *Lut = vtkLookupTable::New();
    Lut->SetHueRange (160.0/240.0, 0.0);
    Lut->SetSaturationRange (1.0, 1.0);
    Lut->SetValueRange (1.0, 1.0);
    Lut->SetTableRange (0,100);
    Lut->Build();

    // Create a ScalarBarActor
    vtkScalarBarActor *scalarBar = vtkScalarBarActor::New();
    scalarBar->SetTitle(text);
    scalarBar->SetLookupTable(Lut);
    scalarBar->SetHeight(0.5);
    scalarBar->SetWidth(0.1);
    scalarBar->SetPosition(0.10,0.01);
    scalarBar->SetPosition2(0.80,0.1);
    scalarBar->SetOrientationToHorizontal();

    // Create the graphics structure
    vtkRenderer *ren = vtkRenderer::New();
    vtkRenderWindow *renWin = vtkRenderWindow::New();
    renWin->AddRenderer(ren);
    renWin->SetSize(600, 600);
    vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
    iren->SetRenderWindow(renWin);

    // Add the actors to the renderer, set the background and size
    ren->AddActor(textActor);
    ren->AddActor(scalarBar);
    ren->SetBackground(0.1, 0.2, 0.4);
    ren->ResetCamera();
    ren->GetActiveCamera()->Zoom(1.0);
    renWin->Render();

    // Starts the event loop
    iren->Start();

    // Do some cleaning
    textActor->Delete();
    Lut->Delete();
    scalarBar->Delete();
    ren->Delete();
    renWin->Delete();
    iren->Delete();

    return 0;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100903/e9213647/attachment.htm>


More information about the vtkusers mailing list