[vtkusers] Drawing objects interactively in VTK..??

Rakesh Patil rakeshthp at in.com
Thu Apr 8 13:05:45 EDT 2010


Hi Darshan,In the mouse click event, i have the followin block of code.. vtkCamera *camera = this>Interactor>GetRenderWindow()>GetRenderers()>GetFirstRenderer()>GetActiveCamera(); double *n = new double[2];n = camera>GetClippingRange();vtkSmartPointer coordinate = vtkSmartPointer::New(); coordinate>SetCoordinateSystemToDisplay(); coordinate>SetValue(x,y); // display coordinates double *pt = new double[3]; pt = coordinate>GetComputedWorldValue(this>Interactor>GetRenderWindow()>GetRenderers()>GetFirstRenderer());mainPG::getInstance()>newArc>InsertNextPoint( pt[0]*pt[2], pt[1]*pt[2], pt[2]*1*n[0]);mainPG::getInstance()>newArc>EndOfDrawing(false);So here, for each mouse click event, the values are stored in an object called newArc.. I use right click to stop the iteractively drawing..Thus for the right click event, i call,mainPG::getInstance()>newArc>EndOfDrawing(true);mainPG::getInstance()>newArc>Update();Here the Update() function causes that object to create an actor and displ
 ay it in the render window. But i still not getting the way it comes using vtkImageTracerWidget.. I mean, i ckick at one place and it really get displayed somewhere else..Any more ideas or suggestions..??ThanksRegardsRakesh Patil Original message From:Darshan Pai< darshanpai at gmail.com >Date: 08 Apr 10 08:13:18Subject:Re: [vtkusers] Drawing objects interactively in VTK..??To: Rakesh Patil Did you multiply z with the near clipping plane . because I could reproduce what you want to do without the actor . Anyway if that is not working for you then I don't have any other explanations at this time :) RegardsDarshanOn Wed, Apr 7, 2010 at 9:58 PM, Rakesh Patilwrote:Yes..I did try that at the very beginning... Not only this but i tried out the various combination of the coordinates.. none of them matched for me... :)vtkImageTracerWidget is performing the task what i want.. but it needs a prop beneath it.... and for me, it is with or without prop object.. wither ways it should be poss
 ible for me to draw... Any suggestions..??ThanksRegardsRakesh Patil Original message From:Darshan Pai< darshanpai at gmail.com > Date: 08 Apr 10 04:55:02Subject: Re: [vtkusers] Drawing objects interactively in VTK..??To: Rakesh Patil replied too fast . The displaytoview() and viewToWorld does not take points as input.But you can use the vtkCoordinate . Try this particular snippet of code. vtkCamera *camera = renderer>GetActiveCamera(); double *n = new double[2];n = camera>GetClippingRange();vtkSmartPointer coordinate = vtkSmartPointer::New(); coordinate>SetCoordinateSystemToDisplay(); coordinate>SetValue(x,y); // display coordinates double *pt = new double[3]; pt = coordinate>GetComputedWorldValue(renderer); coutdoing is at every left button down event, i get the mouse position and store> it is a vector list. Later using this points am displaying on the rendering> window.>> But when i do this, i noticed the following:>>The mouse position values are totally different from the th
 e points which> are displayed.. I mean, i click at one location, and it is displayed at far> end another location..>> I tried changing the coordinate system also.. Still the result is > unchanged..>> Any suggestions how it is to be done..??>> Thanks> Rakesh Patil>Sounds like you may need a coordinate system conversion in theresomewhere, check out:http://vtk.org/Wiki/VTK/Examples/CoordinateIt also sounds like you are trying to duplicate already working code in: http://vtk.org/Wiki/VTK/Examples/Widgets/ImageTracerWidgetThanks,DavidGet Yourself a cool, short @in.com Email ID now! Powered by www.kitware.comVisit other Kitware opensource projects at http://www.kitware.com/opensource/opensource.htmlPlease keep messages ontopic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTKFAQFollow this link to subscribe/unsubscribe: http://www.vtk.org/mailman/listinfo/vtkusers 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100408/bcbd187f/attachment.htm>


More information about the vtkusers mailing list