click_trackball_interactor_style.cpp
Go to the documentation of this file.
00001 #include <pcl/apps/cloud_composer/point_selectors/click_trackball_interactor_style.h>
00002 #include <pcl/apps/cloud_composer/point_selectors/manipulation_event.h>
00003 #include <pcl/apps/cloud_composer/project_model.h>
00004 
00005 
00006 namespace pcl
00007 {
00008   namespace cloud_composer
00009   {
00010     vtkStandardNewMacro(ClickTrackballStyleInteractor);
00011   }
00012 }
00013 
00014 pcl::cloud_composer::ClickTrackballStyleInteractor::ClickTrackballStyleInteractor ()
00015   : vtkInteractorStyleTrackballActor ()
00016 {
00017   manipulation_complete_event_ = interactor_events::MANIPULATION_COMPLETE_EVENT;
00018   start_matrix_= vtkSmartPointer<vtkMatrix4x4>::New ();
00019   end_matrix_ = vtkSmartPointer<vtkMatrix4x4>::New ();
00020   transform_ = vtkSmartPointer<vtkTransform>::New ();
00021 }
00022 
00023 pcl::cloud_composer::ClickTrackballStyleInteractor::~ClickTrackballStyleInteractor ()
00024 {
00025   
00026 }
00027 
00028 void
00029 pcl::cloud_composer::ClickTrackballStyleInteractor::OnLeftButtonDown ()
00030 {
00031   vtkInteractorStyleTrackballActor::OnLeftButtonDown();
00032   
00033   vtkActor* selected_actor = vtkActor::SafeDownCast(this->InteractionProp);
00034   if (selected_actor)
00035     selected_actor->GetMatrix (start_matrix_);
00036   
00037 }
00038 
00039 void
00040 pcl::cloud_composer::ClickTrackballStyleInteractor::OnRightButtonDown ()
00041 {
00042   vtkInteractorStyleTrackballActor::OnRightButtonDown();
00043   
00044   vtkActor* selected_actor = vtkActor::SafeDownCast(this->InteractionProp);
00045   if (selected_actor)
00046     selected_actor->GetMatrix (start_matrix_);
00047   
00048 }
00049 
00050 void
00051 pcl::cloud_composer::ClickTrackballStyleInteractor::OnLeftButtonUp ()
00052 {
00053   vtkInteractorStyleTrackballActor::OnLeftButtonUp();
00054   vtkActor* selected_actor = vtkActor::SafeDownCast(this->InteractionProp);
00055   if (selected_actor)
00056   {
00057     ManipulationEvent* manip_event = new ManipulationEvent ();
00058     //Fetch the actor we manipulated
00059     
00060     selected_actor->GetMatrix (end_matrix_);
00061     // Find the id of the actor we manipulated
00062     pcl::visualization::CloudActorMap::const_iterator end = actors_->end ();
00063     QString manipulated_id;
00064     for( pcl::visualization::CloudActorMap::const_iterator itr = actors_->begin (); itr != end; ++itr)
00065     {
00066       //qDebug () << "Id = "<<QString::fromStdString (itr->first);
00067       if ( (itr->second).actor == selected_actor)
00068       {
00069         manipulated_id = (QString::fromStdString (itr->first));
00070         
00071       }
00072     }
00073     if ( !manipulated_id.isEmpty() )
00074     {
00075       manip_event->addManipulation (manipulated_id, start_matrix_, end_matrix_);
00076       this->InvokeEvent (this->manipulation_complete_event_, manip_event);
00077     }
00078     else
00079     {
00080       qWarning () << "Could not find actor which matches manipulated actor in ClickTrackballStyleInteractor::OnLeftButtonUp!!!";
00081     }
00082   }
00083 }
00084 
00085 void
00086 pcl::cloud_composer::ClickTrackballStyleInteractor::OnRightButtonUp ()
00087 {
00088   vtkInteractorStyleTrackballActor::OnRightButtonUp();
00089   vtkActor* selected_actor = vtkActor::SafeDownCast(this->InteractionProp);
00090   if (selected_actor)
00091   {
00092     ManipulationEvent* manip_event = new ManipulationEvent ();
00093     //Fetch the actor we manipulated
00094     
00095     selected_actor->GetMatrix (end_matrix_);
00096     // Find the id of the actor we manipulated
00097     pcl::visualization::CloudActorMap::const_iterator end = actors_->end ();
00098     QString manipulated_id;
00099     for( pcl::visualization::CloudActorMap::const_iterator itr = actors_->begin (); itr != end; ++itr)
00100     {
00101       //qDebug () << "Id = "<<QString::fromStdString (itr->first);
00102       if ( (itr->second).actor == selected_actor)
00103       {
00104         manipulated_id = (QString::fromStdString (itr->first));
00105         
00106       }
00107     }
00108     if ( !manipulated_id.isEmpty() )
00109     {
00110       manip_event->addManipulation (manipulated_id, start_matrix_, end_matrix_);
00111       this->InvokeEvent (this->manipulation_complete_event_, manip_event);
00112     }
00113     else
00114     {
00115       qWarning () << "Could not find actor which matches manipulated actor in ClickTrackballStyleInteractor::OnRightButtonUp!!!";
00116     }
00117   }
00118    
00119 }
00120 
00121 


pcl
Author(s): Open Perception
autogenerated on Wed Aug 26 2015 15:22:36