[vtkusers] vtkActor2D problem transparence/opacity

David Lonie david.lonie at kitware.com
Thu Aug 11 10:10:41 EDT 2016


On Wed, Aug 10, 2016 at 2:49 AM, AlexUtrobin <AlexUtrobin at yandex.ru> wrote:
> Hello! I use vtkScalarBarActor and vtkTextActor, they are not bright and
> clear. I think it is a problem with all vtkActor2D. Below is the code and
> the picture demonstrate the problem. Please, tell me how to solve the
> problem.
>
>         Java and VTK 7.0.
>
>         vtkRenderWindowPanel mRenderWindowPanel1 = new
> vtkRenderWindowPanel();
>         mRenderWindowPanel1.GetRenderer().SetBackground(1, 1, 1);//White
>         mRenderWindowPanel1.GetRenderer().ResetCamera();
>         mRenderWindowPanel1.GetRenderWindow().PointSmoothingOn();
>         mRenderWindowPanel1.GetRenderWindow().LineSmoothingOn();
>         mRenderWindowPanel1.GetRenderWindow().PolygonSmoothingOn();
>         mRenderWindowPanel1.setSize(jPanel1.getSize());
>         jPanel1.add(mRenderWindowPanel1);
>
>         vtkTextActor mActorTitle = new vtkTextActor();
>         mActorTitle.GetTextProperty().SetFontFamily(4); //4-Шрифт из файла
>         mActorTitle.GetTextProperty().SetFontFile("font.ttf");
>         mActorTitle.GetTextProperty().SetFontSize(SizeTitle);
>         try {
>             mActorTitle.SetInput(new String(title.getBytes("UTF-8")));
>         } catch (UnsupportedEncodingException ex) {
>             Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null,
> ex);
>         }
>         mActorTitle.SetDisplayPosition(5,
> jPanel1.getSize().height-SizeTitle-6);
>         mActorTitle.GetTextProperty().SetColor(0.0, 0.0, 0.0);
>         mRenderWindowPanel1.GetRenderer().AddActor(mActorTitle);

The code looks fine to me, I'm not sure why the text is coming out
grey. A few ideas that might help track the issue down:

1) Print out the color and opacity properties in the vtkTextPropery
objects to verify them. Maybe there's a surprise in there.
2) Try turning off the point/line/polygon smoothing and see if that's
somehow interacting with the rendering.
3) Try using one of the standard fonts bundled with VTK (e.g.
SetFontFamilyToTimes() or similar)).

Dave


More information about the vtkusers mailing list