[vtkusers] TCL to C++, need HELP

Naim naim at electromagneticworks.com
Fri Feb 2 10:27:57 EST 2007


Hi Rio,

 

Before calling OnLeftButtonUp, add it to the callback function :

 

vtkCallbackCommand* cbc = vtkCallbackCommand::New();

      cbc->SetCallback(OnLeftButtonUp);

      cbc->SetClientData((void*)prenderer->GetActiveCamera());

      piren->AddObserver(vtkCommand::LeftButtonReleaseEvent , cbc);

      cbc->Delete();

 

 

piren = vtkWin32RenderWindowInteractor::New();

vtkPointPicker *pointpicker = vtkPointPicker::New();

pointpicker->SetTolerance(0.1);

piren->SetPicker(pointpicker);

 

void OnLeftButtonUp(vtkObject* caller, unsigned long eid, void* clientdata,
void* calldata)

{

 

      //get the picker handle from the interactor

      vtkPointPicker  *pointpicker = (vtkPointPicker
*)(piren->GetPicker());

            

      //get the mouse position

      int * pos = piren->GetEventPosition();

      

      //start the picking process

      if ( pointpicker->Pick((double)pos[0], (double)pos[1], 0.0, prenderer)
!= 0)

      {

            //get the list of picked point

            vtkPoints* thePointList = pointpicker->GetPickedPositions();

 

            //get the number of picked points

            int nbrpoints = thePointList->GetNumberOfPoints();

                        

            if (nbrpoints<=0)

                  return;

 

            //get the real id in the model of picked point

 

            int FoundPointID = myModel->FindPoint( thePointList->GetPoint(0)
);

 

            //id was found 

            if ( FoundPointID>=0 )

            {

                  double * pointVal = myModel->GetPoint(FoundPointID);

                        

                  // ... do code

 

                  // cleanup

                        

            }//end if ( FoundPointID>=0 )

 

      }//end if ( pointpicker->Pick(pos[0],pos[1],0, m_prenderer) != 0)

}

 

Naim Himrane

Electromagneticworks Inc.

  _____  

From: vtkusers-bounces+naim=electromagneticworks.com at vtk.org
[mailto:vtkusers-bounces+naim=electromagneticworks.com at vtk.org] On Behalf Of
Rio
Sent: February 2, 2007 6:36 AM
To: vtkusers at vtk.org
Subject: [vtkusers] TCL to C++, need HELP

 

Hi, everyone,

 

I am new to Tcl programming, a task require me to write a mouse selection
function. I have the code in tcl, and need to translate to C++. Finished
part of the work, but still not sure about the callbacl function, the code
is in tcl: 

 

int Controller::cbLBR() // 
{
// global MouseMotion
  
  if (int MouseMotion == 0) {
    eval picker Pick [iren GetEventPosition] 0 ren1
  }
  // Do the default things for the trackball style
  style OnLeftButtonUp 
  }

 

Really dunt know how to convert : eval picker Pick [iren GetEventPosition] 0
ren1

to C++. . .

Anyone can help? any suggestions?

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20070202/9cdaa58e/attachment.htm>


More information about the vtkusers mailing list