[vtkusers] mous interaction in vtk,	problem with using vtkCallbackCommand
    한종철 
    madness78 at pusan.ac.kr
       
    Thu Sep 13 08:58:33 EDT 2007
    
    
  
Hi,
I’ve got a problem with using vtkCallBackCommand to do custom mouse
interaction.
Something I want is drawing lines ,getting coordinate point which the mouse
was pointed by no means of using mouse control and texting the point in the
Window. 
I’ve tried a lot of things but I couldn’t solve it.
I’m quite hurry. Please answer me and Please give me some sample code so
that I can understand easily.
 
This is my Code.
 
           
           
static void handle_double_click(vtkObject* obj, unsigned long,
                                void*, void*)
{
  vtkRenderWindowInteractor* iren =
vtkRenderWindowInteractor::SafeDownCast(obj);
  vtkRenderer *pvtkRenderer  = vtkRenderer::New();
             vtkTextMapper *pvtkTextMapper = vtkTextMapper::New();
             vtkActor2D *pvtkActor2D = vtkActor2D::New();
             vtkMFCWindow *pvtkMFCWindow;
             
 
 
             vtkActor *pvtkActor = vtkActor::New();
 
  if(iren && iren->GetRepeatCount())
    {
             
 
 
             vtkActor *pvtkActor = vtkActor::New();
             pvtkTextMapper->SetInput("Hello World");
             pvtkTextMapper->GetTextProperty()->SetFontSize(24);
             pvtkTextMapper->GetTextProperty()->SetColor(255,1,1);
      pvtkActor2D->SetMapper(pvtkTextMapper);
             //pvtkMFCWindow -> GetRenderWindow()->AddActor(pvtkActor2D);
             //pvtkMFCWindow -> GetRenderWindow()->
AddRenderer(pvtkRenderer);
    
    }
}
 
 
 
void CVolCadView::OnInitialUpdate() 
{
           CView::OnInitialUpdate();
           
           // TODO: Add your specialized code here and/or call the base
class
           if (this -> pvtkMFCWindow) delete this ->pvtkMFCWindow;
           
           this -> pvtkMFCWindow = new vtkMFCWindow(this);
           this -> pvtkMFCWindow -> GetRenderWindow()-> AddRenderer(this-
>pvtkRenderer);
           
           
           // get double click events
           vtkCallbackCommand* callback = vtkCallbackCommand::New();
           callback->SetCallback(handle_double_click);
           this->pvtkMFCWindow->GetInteractor()-
>AddObserver(vtkCommand::LeftButtonPressEvent, callback, 1.0);
}
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20070913/af6c174c/attachment.htm>
    
    
More information about the vtkusers
mailing list