[vtk-developers] Mix of TextMapper color and Actor2d color broken

Xabi Riobe xabivtk at gmail.com
Tue Nov 17 07:37:28 EST 2015


Hi,

There is an issue when combining vtkTextMapper->GetTextProperty()->SetColor
and vtkActor2D->GetProperty()->SetColor

Before digging into what causes the issue, i would like to know what is the
expected result?

here are different behaviours when setting a vtkTextMapper to a vtkActor2D:

with VTK 5.10 :

TextProperty RED + ActorProperty WHITE => Text RED
TextProperty WHITE + ActorProperty GREEN => Text WHITE
TextProperty RED + ActorProperty GREEN => Text RED

with VTK 6.3 and master, OpenGL 1&2:

TextProperty RED + ActorProperty WHITE => Text RED
TextProperty WHITE + ActorProperty GREEN => Text GREEN
TextProperty RED + ActorProperty GREEN => Text BLACK

with vtk 5.10, the vtkTextProperty has always priority, whereas with newer
versions if only one color is set it is taken into acount, with an obvious
issue when both of them are set.


here is a simple test:


#include <vtkActor2D.h>
#include <vtkProperty2D.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkSmartPointer.h>
#include <vtkTextMapper.h>
#include <vtkTextProperty.h>

int main ( int argc, char *argv[] )
{
   vtkSmartPointer<vtkRenderer> renderer =
      vtkSmartPointer<vtkRenderer>::New();
   vtkSmartPointer<vtkRenderWindow> renderWindow =
      vtkSmartPointer<vtkRenderWindow>::New();
   renderWindow->AddRenderer(renderer);
   vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
      vtkSmartPointer<vtkRenderWindowInteractor>::New();
   renderWindowInteractor->SetRenderWindow(renderWindow);

   vtkSmartPointer<vtkTextMapper> textmap =
      vtkSmartPointer<vtkTextMapper>::New();
   textmap->SetInput("TEST");
   textmap->GetTextProperty()->SetColor(1, 0, 0);

   vtkSmartPointer<vtkActor2D> actor2D =
      vtkSmartPointer<vtkActor2D>::New();
   actor2D->SetMapper(textmap);
   actor2D->GetProperty()->SetColor(0, 1, 0);

   renderer->AddActor2D(actor2D);

   renderWindow->Render();
   renderWindowInteractor->Start();

   return EXIT_SUCCESS;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20151117/09561698/attachment.html>


More information about the vtk-developers mailing list