CTK  0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
ctkVTKConnection.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Library: CTK
4 
5  Copyright (c) Kitware Inc.
6 
7  Licensed under the Apache License, Version 2.0 (the "License");
8  you may not use this file except in compliance with the License.
9  You may obtain a copy of the License at
10 
11  http://www.apache.org/licenses/LICENSE-2.0.txt
12 
13  Unless required by applicable law or agreed to in writing, software
14  distributed under the License is distributed on an "AS IS" BASIS,
15  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  See the License for the specific language governing permissions and
17  limitations under the License.
18 
19 =========================================================================*/
20 
21 #ifndef __ctkVTKConnection_h
22 #define __ctkVTKConnection_h
23 
24 // Qt includes
25 #include <QObject>
26 #include <QVector>
27 
28 // CTK includes
29 #include <ctkPimpl.h>
30 
31 #include "ctkVisualizationVTKCoreExport.h"
32 
33 class vtkObject;
34 class ctkVTKConnectionPrivate;
35 class vtkCallbackCommand;
36 
44 class CTK_VISUALIZATION_VTK_CORE_EXPORT ctkVTKConnection : public QObject
45 {
46 Q_OBJECT
47 
48 public:
49  typedef QObject Superclass;
50  explicit ctkVTKConnection(QObject* parent);
51  virtual ~ctkVTKConnection();
52 
54  QString shortDescription();
55  static QString shortDescription(vtkObject* vtk_obj, unsigned long vtk_event,
56  const QObject* qt_obj, const char* qt_slot = 0);
57 
66  void setup(vtkObject* vtk_obj, unsigned long vtk_event,
67  const QObject* qt_obj, const char* qt_slot, float priority = 0.f,
68  Qt::ConnectionType connectionType = Qt::AutoConnection);
69 
73  static bool isValid(vtkObject* vtk_obj, unsigned long vtk_event,
74  const QObject* qt_obj, const char* qt_slot);
75 
80  void setBlocked(bool block);
81  bool isBlocked()const;
82 
84  bool isEqual(vtkObject* vtk_obj, unsigned long vtk_event,
85  const QObject* qt_obj, const char* qt_slot)const;
86 
89  QString id()const;
90 
93  QObject* object()const;
94 
96  vtkObject* vtkobject() const;
97 
99  void observeDeletion(bool enable);
100  bool deletionObserved()const;
101 
102 Q_SIGNALS:
106  void emitExecute(vtkObject* caller, vtkObject* call_data);
107 
112  void emitExecute(vtkObject* caller, void* call_data, unsigned long vtk_event, void* client_data);
113 
114 protected Q_SLOTS:
117 
118 protected:
119  QScopedPointer<ctkVTKConnectionPrivate> d_ptr;
120  ctkVTKConnection(ctkVTKConnectionPrivate* pimpl, QObject* _parent);
121 
122  void disconnect();
123  virtual void addObserver(vtkObject* caller, unsigned long vtk_event, vtkCallbackCommand* callback, float priority=0.0f);
124  virtual void removeObserver(vtkObject* caller, unsigned long vtk_event, vtkCallbackCommand* callback);
125 
126 private:
127  Q_DECLARE_PRIVATE(ctkVTKConnection);
128  Q_DISABLE_COPY(ctkVTKConnection);
129  friend QDebug operator<<(QDebug dbg, const ctkVTKConnection& connection);
130 };
131 
133 QDebug operator<<(QDebug dbg, const ctkVTKConnection& connection);
134 
135 #endif
ctkVTKConnection::ctkVTKConnection
ctkVTKConnection(ctkVTKConnectionPrivate *pimpl, QObject *_parent)
ctkVTKConnection::observeDeletion
void observeDeletion(bool enable)
false by default, it is slower to observe vtk object deletion
ctkVTKConnection::removeObserver
virtual void removeObserver(vtkObject *caller, unsigned long vtk_event, vtkCallbackCommand *callback)
ctkVTKConnection::isEqual
bool isEqual(vtkObject *vtk_obj, unsigned long vtk_event, const QObject *qt_obj, const char *qt_slot) const
ctkVTKConnection::emitExecute
void emitExecute(vtkObject *caller, void *call_data, unsigned long vtk_event, void *client_data)
ctkVTKConnection::isBlocked
bool isBlocked() const
ctkVTKConnection::Superclass
QObject Superclass
Definition: ctkVTKConnection.h:49
ctkVTKConnection
Definition: ctkVTKConnection.h:45
ctkVTKConnection::id
QString id() const
ctkVTKConnection::~ctkVTKConnection
virtual ~ctkVTKConnection()
ctkVTKConnection::vtkobject
vtkObject * vtkobject() const
Return the vtkObject set using setup() method.
ctkVTKConnection::d_ptr
QScopedPointer< ctkVTKConnectionPrivate > d_ptr
Definition: ctkVTKConnection.h:119
ctkVTKConnection::disconnect
void disconnect()
ctkVTKConnection::shortDescription
QString shortDescription()
ctkVTKConnection::qobjectDeleted
void qobjectDeleted()
ctkVTKConnection::shortDescription
static QString shortDescription(vtkObject *vtk_obj, unsigned long vtk_event, const QObject *qt_obj, const char *qt_slot=0)
ctkVTKConnection::vtkObjectDeleted
void vtkObjectDeleted()
ctkVTKConnection::isValid
static bool isValid(vtkObject *vtk_obj, unsigned long vtk_event, const QObject *qt_obj, const char *qt_slot)
ctkVTKConnection::setBlocked
void setBlocked(bool block)
ctkVTKConnection::deletionObserved
bool deletionObserved() const
ctkVTKConnection::object
QObject * object() const
Return the QObject set using setup() method.
ctkVTKConnection::emitExecute
void emitExecute(vtkObject *caller, vtkObject *call_data)
ctkVTKConnection::ctkVTKConnection
ctkVTKConnection(QObject *parent)
ctkPimpl.h
ctkVTKConnection::addObserver
virtual void addObserver(vtkObject *caller, unsigned long vtk_event, vtkCallbackCommand *callback, float priority=0.0f)
operator<<
QDebug operator<<(QDebug dbg, const ctkVTKConnection &connection)
ctkVTKConnection::setup
void setup(vtkObject *vtk_obj, unsigned long vtk_event, const QObject *qt_obj, const char *qt_slot, float priority=0.f, Qt::ConnectionType connectionType=Qt::AutoConnection)
ctkVTKConnection::operator<<
friend QDebug operator<<(QDebug dbg, const ctkVTKConnection &connection)