VTK
dox/GUISupport/Qt/vtkQtConnection.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Copyright 2004 Sandia Corporation.
00004   Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00005   license for use of this work by or on behalf of the
00006   U.S. Government. Redistribution and use in source and binary forms, with
00007   or without modification, are permitted provided that this Notice and any
00008   statement of authorship are reproduced on all copies.
00009 
00010 =========================================================================*/
00011 
00012 /*========================================================================
00013  For general information about using VTK and Qt, see:
00014  http://www.trolltech.com/products/3rdparty/vtksupport.html
00015 =========================================================================*/
00016 
00017 /*========================================================================
00018  !!! WARNING for those who want to contribute code to this file.
00019  !!! If you use a commercial edition of Qt, you can modify this code.
00020  !!! If you use an open source version of Qt, you are free to modify
00021  !!! and use this code within the guidelines of the GPL license.
00022  !!! Unfortunately, you cannot contribute the changes back into this
00023  !!! file.  Doing so creates a conflict between the GPL and BSD-like VTK
00024  !!! license.
00025 =========================================================================*/
00026 
00027 // .SECTION Description
00028 // vtkQtConnection is an internal class.
00029 
00030 
00031 #ifndef VTK_QT_CONNECTION
00032 #define VTK_QT_CONNECTION
00033 
00034 #include "vtkObject.h"
00035 #include "vtkCommand.h"  // for event defines
00036 #include "qobject.h"
00037 
00038 class QObject;
00039 class vtkCallbackCommand;
00040 class vtkEventQtSlotConnect;
00041 
00042 // class for managing a single VTK/Qt connection
00043 // not to be included in other projects
00044 // only here for moc to process for vtkEventQtSlotConnect
00045 class vtkQtConnection : public QObject
00046 {
00047   Q_OBJECT
00048 
00049   public:
00050 
00051     // constructor
00052     vtkQtConnection(vtkEventQtSlotConnect* owner);
00053 
00054     // destructor, disconnect if necessary
00055     ~vtkQtConnection();
00056 
00057     // print function
00058     void PrintSelf(ostream& os, vtkIndent indent);
00059 
00060     // callback from VTK to emit signal
00061     void Execute(vtkObject* caller, unsigned long event, void* client_data);
00062 
00063     // set the connection
00064     void SetConnection(vtkObject* vtk_obj, unsigned long event,
00065                        const QObject* qt_obj, const char* slot,
00066                        void* client_data, float priority=0.0
00067                          ,Qt::ConnectionType type = Qt::AutoConnection);
00068 
00069     // check if a connection matches input parameters
00070     bool IsConnection(vtkObject* vtk_obj, unsigned long event,
00071                       const QObject* qt_obj, const char* slot,
00072                       void* client_data);
00073 
00074     static void DoCallback(vtkObject* vtk_obj, unsigned long event,
00075                            void* client_data, void* call_data);
00076 
00077   signals:
00078     // the qt signal for moc to take care of
00079     void EmitExecute(vtkObject*, unsigned long, void* client_data, void* call_data, vtkCommand*);
00080 
00081   protected slots:
00082     void deleteConnection();
00083 
00084   protected:
00085 
00086     // the connection information
00087     vtkObject* VTKObject;
00088     vtkCallbackCommand* Callback;
00089     const QObject* QtObject;
00090     void* ClientData;
00091     unsigned long VTKEvent;
00092     QString QtSlot;
00093     vtkEventQtSlotConnect* Owner;
00094 
00095   private:
00096     vtkQtConnection(const vtkQtConnection&);
00097     void operator=(const vtkQtConnection&);
00098 
00099 };
00100 
00101 #endif
00102