Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 
00034 
00035 
00036 
00037 
00038 #include <vtkVersion.h>
00039 #if ((VTK_MAJOR_VERSION == 5) && (VTK_MINOR_VERSION <= 4))
00040 
00041 #include <pcl/visualization/interactor.h>
00042 #include <vtkCommand.h>
00043 
00044 namespace pcl
00045 {
00046   namespace visualization
00047   {
00048     
00049     vtkStandardNewMacro (PCLVisualizerInteractor);
00050     
00051 
00052 
00053 
00054 
00055 
00056     
00058     void 
00059     PCLVisualizerInteractor::stopLoop ()
00060     {
00061   #if defined (_WIN32) || defined (VTK_USE_COCOA) || defined (VTK_USE_CARBON)
00062       BreakLoopFlagOn ();
00063       
00064       
00065       
00066     #if defined (_WIN32)
00067       SendMessage (this->WindowId, RegisterWindowMessage (TEXT ("VTK_BreakWin32Loop")), 0, 0);
00068     #endif
00069   #else
00070       BreakLoopFlagOn ();
00071       XClientMessageEvent client;
00072       memset (&client, 0, sizeof (client));
00073       client.type = ClientMessage;
00074       client.display = DisplayId;
00075       client.window = WindowId;
00076       client.message_type = XInternAtom (client.display, "spinOnce exit", false);
00077       client.format = 32; 
00078       XSendEvent (client.display, client.window, True, NoEventMask, reinterpret_cast<XEvent *>(&client));
00079       XFlush (client.display);
00080   #endif
00081     }
00082 
00083   #if defined (_WIN32) || (defined VTK_USE_COCOA) || defined (VTK_USE_CARBON)
00084 
00085     void 
00086     PCLVisualizerInteractor::Start ()
00087     {
00088       
00089       if (this->HasObserver(vtkCommand::StartEvent) && !this->HandleEventLoop)
00090       {
00091         this->InvokeEvent (vtkCommand::StartEvent, NULL);
00092         return;
00093       }
00094 
00095       
00096       if (!this->Enabled || !this->InstallMessageProc)
00097         return;
00098 
00099       this->StartedMessageLoop = 1;
00100 
00101       MSG msg;
00102       this->BreakLoopFlag=0;
00103       
00104       while (GetMessage (&msg, NULL, 0, 0) && this->BreakLoopFlag == 0)
00105       {
00106         TranslateMessage (&msg);
00107         DispatchMessage (&msg);
00108       }
00109     }
00110 
00112     void 
00113     PCLVisualizerInteractor::SetBreakLoopFlag (int f)
00114     {
00115       if (f)
00116         this->BreakLoopFlagOn ();
00117       else
00118         this->BreakLoopFlagOff ();
00119     }
00120 
00122     void 
00123     PCLVisualizerInteractor::BreakLoopFlagOff ()
00124     {
00125       this->BreakLoopFlag = 0;
00126       this->Modified ();
00127     }
00128 
00130     void 
00131     PCLVisualizerInteractor::BreakLoopFlagOn ()
00132     {
00133       this->BreakLoopFlag = 1;
00134       this->Modified ();
00135     }
00136   #endif
00137   }
00138 }
00139 
00140 #endif