001/* 002 * Copyright 2010, 2011 Institut Pasteur. 003 * 004 * This file is part of ICY. 005 * 006 * ICY is free software: you can redistribute it and/or modify 007 * it under the terms of the GNU General Public License as published by 008 * the Free Software Foundation, either version 3 of the License, or 009 * (at your option) any later version. 010 * 011 * ICY is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 014 * GNU General Public License for more details. 015 * 016 * You should have received a copy of the GNU General Public License 017 * along with ICY. If not, see <http://www.gnu.org/licenses/>. 018 */ 019package plugins.tutorial.vtk; 020 021import icy.painter.Overlay; 022import icy.painter.VtkPainter; 023import vtk.vtkActor; 024import vtk.vtkFollower; 025import vtk.vtkPolyDataMapper; 026import vtk.vtkProp; 027import vtk.vtkVectorText; 028 029/** 030 * @author stephane 031 */ 032public class VtkText3DPainter extends Overlay implements VtkPainter 033{ 034 private vtkFollower textActor; 035 036 public VtkText3DPainter() 037 { 038 super("VTK 3D text"); 039 040 init(); 041 } 042 043 // init vtk objects 044 private void init() 045 { 046 // Create the 3D text and the associated mapper and follower (a type of actor) 047 // Position the text so it is displayed over the origin of the axes. 048 final vtkVectorText atext = new vtkVectorText(); 049 atext.SetText("Origin"); 050 051 final vtkPolyDataMapper textMapper = new vtkPolyDataMapper(); 052 textMapper.SetInputConnection(atext.GetOutputPort()); 053 054 textActor = new vtkFollower(); 055 textActor.SetMapper(textMapper); 056 textActor.SetScale(100, 100, 100); 057 // textActor.AddPosition(0, -0.1, 0); 058 } 059 060 @Override 061 public vtkProp[] getProps() 062 { 063 return new vtkActor[] {textActor}; 064 } 065}