<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="GENERATOR" content="MSHTML 8.00.6001.19403">
</head>
<body>
<div><span class="131395210-12042013"><font size="2" face="Arial">Hi guys,</font></span></div>
<div><span class="131395210-12042013"><font size="2" face="Arial"></font></span> </div>
<div><span class="131395210-12042013"><font size="2" face="Arial">wondering what I did wrong: I want to display a 2D image as an annotation. can do the job many ways, one is with imagemapper and actor2d but rescaling just looked bad.</font></span></div>
<div><span class="131395210-12042013"><font size="2" face="Arial"></font></span> </div>
<div><span class="131395210-12042013"><font size="2" face="Arial">So I decided to use vtkTexturedActor2D, since the vtkTexture works so well in 2D. I want to give the user the opportunity to scale ans position the image. Positioning works, but scaling the actor
just wont work. Scaling the texture/imagedata itself is not an option.</font></span></div>
<div><span class="131395210-12042013"><font size="2" face="Arial"></font></span> </div>
<div><span class="131395210-12042013"><font size="2" face="Arial"></font></span> </div>
<div><span class="131395210-12042013"><font size="2" face="Arial"></font></span> </div>
<div><span class="131395210-12042013"><font size="2" face="Arial">Ideas are very much appreciated,</font></span></div>
<div><span class="131395210-12042013"><font size="2" face="Arial"></font></span> </div>
<div><span class="131395210-12042013"><font size="2" face="Arial">Thanks,<br>
Martin</font></span></div>
<div><font size="2" face="Arial"></font> </div>
<div><font size="2" face="Arial"></font> </div>
<div><font size="2" face="Arial"># ###############<br>
# a plane and texcoords<span class="131395210-12042013">, image in "png"</span><br>
plane = vtk.vtkPolyData();</font></div>
<div><font size="2" face="Arial"></font> </div>
<div><font size="2" face="Arial">X = png.GetOutput().GetDimensions()[0]<br>
Y = png.GetOutput().GetDimensions()[1]</font></div>
<div><font size="2" face="Arial"></font> </div>
<div><font size="2" face="Arial">texcoords = vtk.vtkFloatArray()<br>
texcoords.SetNumberOfComponents(2)<br>
texcoords.InsertNextTuple([0,0])<br>
texcoords.InsertNextTuple([0,1])<br>
texcoords.InsertNextTuple([1,1])<br>
texcoords.InsertNextTuple([1,0])</font></div>
<div><font size="2" face="Arial"></font> </div>
<div><font size="2" face="Arial">points = vtk.vtkPoints();<br>
points.InsertNextPoint([0 , 0 , 0]);<br>
points.InsertNextPoint([0 , Y , 0]);<br>
points.InsertNextPoint([X , Y , 0]);<br>
points.InsertNextPoint([X , 0 , 0]);</font></div>
<div><font size="2" face="Arial"></font> </div>
<div><font size="2" face="Arial">poly = vtk.vtkPolygon()<br>
poly.GetPointIds().SetNumberOfIds(4)<br>
poly.GetPointIds().SetId(0,0)<br>
poly.GetPointIds().SetId(1,1)<br>
poly.GetPointIds().SetId(2,2)<br>
poly.GetPointIds().SetId(3,3)</font></div>
<div> </div>
<div><font size="2" face="Arial">polygons = vtk.vtkCellArray()<br>
polygons.InsertNextCell(poly)</font></div>
<div><font size="2" face="Arial"></font> </div>
<div><font size="2" face="Arial">pd2d = vtk.vtkPolyData()<br>
pd2d.SetPoints(points)<br>
pd2d.GetPointData().SetTCoords(texcoords)<br>
pd2d.SetPolys(polygons)</font></div>
<div><font size="2" face="Arial"></font> </div>
<div><font size="2" face="Arial">pdm = vtk.vtkPolyDataMapper2D()<br>
pdm.SetInput(pd2d)</font></div>
<div><font size="2" face="Arial"></font> </div>
<div><font size="2" face="Arial"></font> </div>
<div><font size="2" face="Arial"><span class="131395210-12042013"># vtktexturedActor stuff</span></font></div>
<div><font size="2" face="Arial">act5 = vtk.vtkTexturedActor2D()<br>
act5.SetMapper(pdm)<br>
act5.SetTexture(tex2d)<br>
act5.GetPositionCoordinate().SetCoordinateSystemToNormalizedViewport()<br>
act5.GetPositionCoordinate().SetValue(0.333, 0.333)<br>
</font></div>
<div><font size="2" face="Arial"><span class="131395210-12042013"># all of these do not work</span></font></div>
<div><font size="2" face="Arial"><span class="131395210-12042013">act5.GetPosition2Coordinate().SetValue(0.333, 0.333)</span></font></div>
<div><font size="2" face="Arial">act5.SetHeight(120)</font></div>
<div><font size="2" face="Arial"><span class="131395210-12042013">act5.SetWidth(90)</span></font></div>
<div><font face="Arial"><font size="2">act5.SetPosition2(0.1,0.1)<br>
</div>
<div></font></font><font size="2" face="Arial"></font> </div>
<div><font size="2" face="Arial"></font> </div>
<div><font size="2" face="Arial"><span class="131395210-12042013"># add to renderer</span></font></div>
<div><font size="2" face="Arial">ren.AddActor2D(act5)</font></div>
</body>
</html>