[vtkusers] PLEASE HELP, convert Tcl to C++ code

Amy Squillacote amy.squillacote at kitware.com
Fri Jan 12 08:11:16 EST 2007


Please keep the discussion on the vtkusers mailing list.



Rio wrote:
> Thanks very much, Amy!
>  
> I'm still a bit confusing about the following:
> > set selPt [picker GetSelectionPoint]
> > set x [lindex $selPt 0]
> > set y [lindex $selPt 1]
>  
> the GetSelectionPoint function is : virtual double 
> vtkAbstractPicker::GetSelectionPoint  (  )
> which means the "selPt" is double type, but what about "lindex", it is 
> a Tcl command, return item number index from list.
>  
> Can I write the code above as:
> double selPt[3]=picker->GetSelectionPoint();
> double x = selPt[0];
> double y = selPt[1];
>  
> double pickPos[3]=picker->GetPickPosition();
> double xp=pickPos[0];
> double yp=pickPos[1];
> double zp=pickPos[2];
You're close. Change double selPt[3]=picker->GetSelectionPoint(); to
double selPt[3];
picker->GetSelectionPoint(selPt);

and do the same for picker->GetPickPosition();


- Amy
>  
> ???
> Any error can you just point out?
> Thanks so much.
>  
>  J.K
>
>  
> On 1/11/07, *Amy Squillacote* <amy.squillacote at kitware.com 
> <mailto:amy.squillacote at kitware.com>> wrote:
>
>
>
>     Rio wrote:
>     >
>     > Hi, I am a quite newbie to VTK.
>     > I am involving in a project. I consider to write a VTK mouse
>     picking
>     > method in C++ code. I know the sample Tcl code, partially as
>     following:
>     >
>     > # Create a text mapper and actor to display the results of picking.
>     > vtkTextMapper textMapper
>     > set tprop [textMapper GetTextProperty]
>     >     $tprop SetFontFamilyToArial
>     >     $tprop SetFontSize 10
>     >     $tprop BoldOn
>     >     $tprop ShadowOn
>     >     $tprop SetColor 1 0 0
>     > vtkActor2D textActor
>     >     textActor VisibilityOff
>     >     textActor SetMapper textMapper
>     >
>     > in the sample, tprop is created, but what kind of object it is?
>     > vtkTextProperty or vtkProperty? Or i dunt need to specify the
>     type of
>     > object?
>     > Can anybody help me what is the code in C++ ???
>     >
>     Take a look at the documentation for vtkTextMapper:
>     http://www.vtk.org/doc/nightly/html/classvtkTextMapper.html
>     <http://www.vtk.org/doc/nightly/html/classvtkTextMapper.html>. The
>     method
>     GetTextProperty returns a vtkTextProperty*. So the following lines of
>     Tcl code
>
>     vtkTextMapper textMapper
>     set tprop [textMapper GetTextProperty]
>
>     look like the following when converted to C++:
>
>     vtkTextMapper *textMapper = vtkTextMapper::New();
>     vtkTextProperty *tprop = textMapper->GetTextProperty();
>
>     - Amy
>
>     >
>     > vtkTextMapper textMapper
>     > set tprop [textMapper GetTextProperty]
>     >
>     > set selPt [picker GetSelectionPoint]
>     > set x [lindex $selPt 0]
>     > set y [lindex $selPt 1]
>     > set pickPos [picker GetPickPosition]
>     > set xp [lindex $pickPos 0]
>     > set yp [lindex $pickPos 1]
>     > set zp [lindex $pickPos 2]
>     >
>     >
>     > Thanks very much!
>     >
>     >
>     >
>     ------------------------------------------------------------------------
>     >
>     > _______________________________________________
>     > This is the private VTK discussion list.
>     > Please keep messages on-topic. Check the FAQ at:
>     http://www.vtk.org/Wiki/VTK_FAQ
>     > Follow this link to subscribe/unsubscribe:
>     > http://www.vtk.org/mailman/listinfo/vtkusers
>     >
>
>



More information about the vtkusers mailing list