<br>Hi David,<br><br>Thanks for your precious information. It will be grateful of you if you guide me in implementing this feature. How do I hook into the Renderer's StartEvent.?? Where my callback command should be implemented?? <br><br>Thanks<br><blockquote><br>---------- Original message ----------<br>From:David Gobbi&lt; david.gobbi@gmail.com &gt;<br>Date: 28 Jan 10 23:04:33<br>Subject:  Re: [vtkusers] Vector arrows form a solid patch. How to rectify??<br>To: Rakesh Patil <rakeshthp@in.com><br><br>Hi Rakesh,<br><br>I've had to deal with this same issue in my own software.  A good<br>solution is to use observers.<br><br>Usually, I hook into the Renderer's StartEvent.  Inside my<br>CommandCallback, I check the renderer to see how much I need to scale<br>the actor in order make it always be the same number of pixels across:<br><br>double vtkSurfaceCursor::ComputeScale(const double position[3],<br>                                      vtkRenderer *renderer)<br>{<br>  // Find
  the cursor scale factor such that 1 data unit length<br>  // equals 1 screen pixel at the cursor's distance from the camera.<br>  // Start by computing the height of the window at the cursor position.<br>  double worldHeight = 1.0;<br>  vtkCamera *camera = renderer-&gt;GetActiveCamera();<br>  if (camera-&gt;GetParallelProjection())<br>    {<br>    worldHeight = 2*camera-&gt;GetParallelScale();<br>    }<br>  else<br>    {<br>    double cameraPosition[3];<br>    camera-&gt;GetPosition(cameraPosition);<br>    worldHeight = 2*(sqrt(vtkMath::Distance2BetweenPoints(position,<br>                                                        cameraPosition))<br>                     * tan(0.5*camera-&gt;GetViewAngle()/57.296));<br>    }<br><br>  // Compare world height to window height.<br>  int windowHeight = renderer-&gt;GetSize()[1];<br>  double scale = 1.0;<br>  if (windowHeight &gt; 0)<br>    {<br>    scale = worldHeight/windowHeight;<br>    }<br><br>  return scale;<br>}<br><br>I hope
  this is the sort of thing that you were looking for.<br><br> - David G<br><br><br>On Thu, Jan 28, 2010 at 9:53 AM, Rakesh Patil <rakeshthp@in.com> wrote:<br>&gt;<br>&gt; i guess, the way i explained the problem was not correct.. here it goes,<br>&gt;<br>&gt; for a large area, if i draw vecot of actual size, it will be visible as a<br>&gt; small dot. So i need to scale and make it<br>&gt; large enough that it is visible properly.. And as i zoom in, and go closer<br>&gt; to them, they must slowly,<br>&gt; shrink to their actual size...<br>&gt;<br>&gt; As kaarthik said, i think i need to write my own actor . But how to do it,<br>&gt; am not able to understand..<br>&gt; can anyone guide me..??<br>&gt;<br>&gt; Thanks<br>&gt; Regards<br>&gt;<br>&gt; ---------- Original message ----------<br>&gt; From:David Doria&lt; daviddoria+vtk@gmail.com &gt;<br>&gt; Date: 27 Jan 10 19:54:04<br>&gt; Subject: Re: [vtkusers] Vector arrows form a solid patch. How to rectify??<br>&gt; To: rakeshth
 p@in.com<br>&gt;<br>&gt; On Wed, Jan 27, 2010 at 8:56 AM, Rakesh Patil wrote:<br>&gt;&gt; Hello,<br>&gt;&gt;<br>&gt;&gt; I dont know mush about wrapping the code. It would be nice if anyone helps<br>&gt;&gt; me out. Here is my code to display vectors<br>&gt;&gt;<br>&gt;&gt; unsigned int num_pts = x.size();<br>&gt;&gt;<br>&gt;&gt; vtkPoints *pts = vtkPoints::New();<br>&gt;&gt; pts-&gt;SetNumberOfPoints(num_pts);<br>&gt;&gt;<br>&gt;&gt; vtkDoubleArray *vecArr = vtkDoubleArray::New();<br>&gt;&gt; vecArr-&gt;SetNumberOfComponents(3);<br>&gt;&gt; vecArr-&gt;SetNumberOfTuples(num_pts);<br>&gt;&gt;<br>&gt;&gt; for( unsigned int i=0; i &lt; num_pts; i++)<br>&gt;&gt; {<br>&gt;&gt; pts-&gt;InsertPoint(i, x(i), y(i), 0);<br>&gt;&gt; vecArr-&gt;InsertTuple2(i, vel_u(i), vel_v(i));<br>&gt;&gt; }<br>&gt;&gt;<br>&gt;&gt; unsigned int num_cells = elem.rows(); // elem is a matrix that contains<br>&gt;&gt; the<br>&gt;&gt; index of nodes of elements in the mesh<br>&gt;&gt;<br>&gt;&gt; vtkCellA
 rray *cellA = vtlCellArray::New();<br>&gt;&gt; cellA-&gt;SetNumberOfCells(num_cells);<br>&gt;&gt;<br>&gt;&gt; for (unsigned int i=0; i &lt; num_cells; i++)<br>&gt;&gt; {<br>&gt;&gt; cellA-&gt;InsertNextCell(3);<br>&gt;&gt; cellA-&gt;InsertCellPoint( elem(i, 0) );<br>&gt;&gt; cellA-&gt;InsertCellPoint( elem(i, 1) );<br>&gt;&gt; cellA-&gt;InsertCellPoint( elem(i, 2) );<br>&gt;&gt; }<br>&gt;&gt;<br>&gt;&gt; vtkUnstructuredGrid *uGrid = vtkUnstructuredGrid::New();<br>&gt;&gt; uGrid-&gt;Allocate(num_cells, num_cells);<br>&gt;&gt; uGrid-&gt;SetCells( VTK_TRIANGLE, cellA);<br>&gt;&gt; uGrid-&gt;SetPoints(pts);<br>&gt;&gt; uGrid-&gt;GetPointData()-&gt;SetVector(vecArr);<br>&gt;&gt;<br>&gt;&gt; vtkGlyph2D *glyph = vtkGlyph2D::New();<br>&gt;&gt; glyph-&gt;SetInput(uGrid);<br>&gt;&gt; glyph-&gt;SetColorModeToColorByVector();<br>&gt;&gt; glyph-&gt;OrientOn();<br>&gt;&gt; glyph-&gt;SetScaleFactor(1);<br>&gt;&gt;<br>&gt;&gt; vtkGlyphSource2D *glyphSource = vtkGlyphSource2D::New();<br>&gt;
 &gt; glyphSource-&gt;FilledOff();<br>&gt;&gt; glyphSource-&gt;SetGlyphTypeToArrow();<br>&gt;&gt;<br>&gt;&gt; glyph-&gt;SetInputConnection(1, glyphSource-&gt;GetOutputPort());<br>&gt;&gt;<br>&gt;&gt; vtkPolyDataMapper *gMapper = vtkPolyDataMapper::New();<br>&gt;&gt; gMapper-&gt;SetInput( glyph-&gt;GetOutput());<br>&gt;&gt; gMapper-&gt;ScalarVisibilityOn();<br>&gt;&gt; gMapper-&gt;SetScalarRange(uGrid-&gt;GetScalarRange());<br>&gt;&gt;<br>&gt;&gt; vtkActor *gactor = vtkActor::New();&lt; br&gt;&gt; gactor-&gt;SetMapper(gMapper);<br>&gt;&gt;<br>&gt;&gt; pRenderer-&gt;AddActor(gactor);<br>&gt;&gt;<br>&gt;&gt; pRenderer-&gt;Rese tCamera();<br>&gt;&gt;<br>&gt;&gt; Do i need to derive a class from vtkActor and override<br>&gt;&gt; RenderOpaqueGeometry<br>&gt;&gt; code..?? If so, then how do i scale the glyphs..?? and which part will<br>&gt;&gt; this<br>&gt;&gt; code come into picture. Am not that much expert in C++ but can manage with<br>&gt;&gt; a<br>&gt;&gt; guidance.<br>&gt;&gt;<
 br>&gt;&gt; Thanks<br>&gt;&gt;<br>&gt;&gt; Regards<br>&gt;&gt;<br>&gt;&gt; ---------- Original message ----------<br>&gt;&gt; From:Karthik Krishnan&lt; karthik.krishnan@kitware.com &gt;<br>&gt;&gt; Date: 25 Jan 10 17:08:12<br>&gt;&gt; Subject: Re: [vtkusers] Vector arrows form a solid patch. How to rectify??<br>&gt;&gt; To: Rakesh Patil<br>&gt;&gt;<br>&gt;&gt; You'll have to write your own actor wrapping around your existing code<br>&gt;&gt; and overriding RenderOpaqueGeometry. Its not hard. See several actors<br>&gt;&gt; in VTK/Rendering that scale their font size based on the size of the<br>&gt;&gt; viewport etc. Yo u may have to do something similar scaling your glyphs<br>&gt;&gt; based on the parallel scale / view angle.<br>&gt;&gt;<br>&gt;&gt; On Sat, Jan 23, 2010 at 12:49 PM, Rakesh Patil wrote:<br>&gt;&gt;&gt; hello,<br>&gt;&gt;&gt;<br>&gt;&gt;&gt; When i display a vector plot using vtk, it is shown very small like a<br>&gt;&gt;&gt; dot.<br>&gt;&gt;&gt; And when i zoo
 m into it, it gets more visible and big. But, i want it in<br>&gt;&gt;&gt; such a way, that when i display it, at the initial stage itself, the<br>&gt;&gt;&gt; vectors<br>&gt;&gt;&gt; must be big enough that can be seen. And when we zoom into it, then the<br>&gt;&gt;&gt; arrow size must proportionately become small. I Used setscalefactor for<br>&gt;&gt;&gt; glyph object and got the arrow size increased.<br>&gt;&gt;&gt;<br>&gt;&gt;&gt; But where the data is very dense, there a solid patch is formed due to<br>&gt;&gt;&gt; which<br>&gt;&gt;&gt; i cannot make out whats the length of the arrow. So as we zoom in, the<br>&gt;&gt;&gt; arrow<br>&gt;&gt;&gt; size must be reduced so that at the denser location, i ca n differentiate<br>&gt;&gt;&gt; among two vectors. How can i do this..??<br>&gt;&gt;&gt;<br>&gt;&gt;&gt; Thanks in advance<br>&gt;&gt;&gt;<br>&gt;&gt;&gt; Regards<br>&gt;&gt;&gt; Rakesh<br>&gt;&gt;&gt;<br>&gt;&gt;&gt; Get Yourself a cool, short @in.com Email ID now!<br>&gt;
 &gt;&gt; _______________________________________ ________<br>&gt;&gt;&gt; Powered by <a target=\"_blank\" href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>&gt;&gt;&gt;<br>&gt;&gt;&gt; Visit other Kitware open-source projects at<br>&gt;&gt;&gt; <a target=\"_blank\" href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>&gt;&gt;&gt;<br>&gt;&gt;&gt; Please keep messages on-topic and check the VTK FAQ at:<br>&gt;&gt;&gt; <a target=\"_blank\" href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>&gt;&gt;&gt;<br>&gt;&gt;&gt; Follow this link to subscribe/unsubscribe:<br>&gt;&gt;&gt; <a target=\"_blank\" href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>&gt;&gt;<br>&gt;&gt; _________________________________<br>&gt;&gt; Karthik Krishnan<br>&gt;<br>&gt; This is only a very partial a
 nswer, but you can scale an arrow using<br>&gt; the vtkTransformFilter like this:<br>&gt;<br>&gt; <a target=\"_blank\" href="http://www.vtk.org/Wiki/VTK/Examples/TransformFilter" target="_blank">http://www.vtk.org/Wiki/VTK/Examples/TransformFilter</a><br>&gt;<br>&gt; Thanks,<br>&gt;<br>&gt; David<br>&gt; _______________________________________________<br>&gt; Powered by <a target=\"_blank\" href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>&gt;<br>&gt; Visit other Kitware open-source projects at<br>&gt; <a target=\"_blank\" href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>&gt;<br>&gt; Please keep messages on-topic and check the VTK FAQ at:<br>&gt; <a target=\"_blank\" href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>&gt;<br>&gt; Follow this link to subscribe/unsubscribe:<br>&gt; <a target=\"_blank\" href="http://www.vtk.org/mailman/
 listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>&gt; &lt; /blockquote&gt;<br>&gt;<br>&gt; Get Yourself a cool, short @in.com Email ID now!<br>&gt;<br>&gt; _______________________________________________<br>&gt; Powered by <a target=\"_blank\" href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>&gt;<br>&gt; Visit other Kitware open-source projects at<br>&gt; <a target=\"_blank\" href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>&gt;<br>&gt; Please keep messages on-topic and check the VTK FAQ at:<br>&gt; <a target=\"_blank\" href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>&gt;<br>&gt; Follow this link to subscribe/unsubscribe:<br>&gt; <a target=\"_blank\" href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>&gt;<br>&gt;<br></rakesht
 hp@in.com></rakeshthp@in.com></blockquote>