CTK  0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
ctkVTKObjectEventsObserver.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 __ctkVTKObjectEventsObserver_h
22 #define __ctkVTKObjectEventsObserver_h
23 
25 #include <QObject>
26 #include <QList>
27 #include <QString>
28 
30 #include <ctkSingleton.h>
31 #include "ctkVisualizationVTKCoreExport.h"
32 class ctkVTKConnection;
33 class ctkVTKObjectEventsObserverPrivate;
34 
36 #include <vtkCommand.h>
37 class vtkObject;
38 
39 //-----------------------------------------------------------------------------
44 class CTK_VISUALIZATION_VTK_CORE_EXPORT ctkVTKObjectEventsObserver : public QObject
45 {
46 Q_OBJECT
60  Q_PROPERTY(bool strictTypeCheck READ strictTypeCheck WRITE setStrictTypeCheck)
61 public:
62  typedef QObject Superclass;
63  explicit ctkVTKObjectEventsObserver(QObject* parent = 0);
65 
66  virtual void printAdditionalInfo();
67 
70  bool strictTypeCheck()const;
74  void setStrictTypeCheck(bool check);
75 
99  QString addConnection(vtkObject* vtk_obj, unsigned long vtk_event,
100  const QObject* qt_obj, const char* qt_slot, float priority = 0.0,
101  Qt::ConnectionType connectionType = Qt::AutoConnection);
102 
108  QString addConnection(vtkObject* old_vtk_obj,
109  vtkObject* vtk_obj, unsigned long vtk_event,
110  const QObject* qt_obj, const char* qt_slot, float priority = 0.0,
111  Qt::ConnectionType connectionType = Qt::AutoConnection);
112 
118  QString reconnection(vtkObject* vtk_obj, unsigned long vtk_event,
119  const QObject* qt_obj, const char* qt_slot,
120  float priority = 0.0,
121  Qt::ConnectionType connectionType = Qt::AutoConnection);
122 
129  int removeConnection(vtkObject* vtk_obj, unsigned long vtk_event = vtkCommand::NoEvent,
130  const QObject* qt_obj = 0, const char* qt_slot = 0);
131 
136 
140  bool blockAllConnections(bool block);
141 
145  bool connectionsBlocked()const;
146 
150  int blockConnection(bool block, vtkObject* vtk_obj,
151  unsigned long vtk_event, const QObject* qt_obj);
155  bool blockConnection(const QString& id, bool blocked);
156 
161  bool containsConnection(vtkObject* vtk_obj, unsigned long vtk_event = vtkCommand::NoEvent,
162  const QObject* qt_obj =0, const char* qt_slot =0)const;
163 
164 protected:
165  QScopedPointer<ctkVTKObjectEventsObserverPrivate> d_ptr;
166 
167 private:
168  Q_DECLARE_PRIVATE(ctkVTKObjectEventsObserver);
169  Q_DISABLE_COPY(ctkVTKObjectEventsObserver);
170 
171 };
172 
173 //-----------------------------------------------------------------------------
175 class CTK_VISUALIZATION_VTK_CORE_EXPORT ctkVTKConnectionFactory
176 {
177 public:
179 
184  static void setInstance(ctkVTKConnectionFactory* newInstance);
185 
187 protected:
191 };
192 CTK_SINGLETON_DECLARE_INITIALIZER(CTK_VISUALIZATION_VTK_CORE_EXPORT, ctkVTKConnectionFactory)
193 
194 #endif
static void setInstance(ctkVTKConnectionFactory *newInstance)
virtual ctkVTKConnection * createConnection(ctkVTKObjectEventsObserver *) const
static ctkVTKConnectionFactory * instance()
virtual ~ctkVTKConnectionFactory()
Connect vtkObject events with QObject slots. Helper class that provides utility methods for connectin...
QString addConnection(vtkObject *vtk_obj, unsigned long vtk_event, const QObject *qt_obj, const char *qt_slot, float priority=0.0, Qt::ConnectionType connectionType=Qt::AutoConnection)
ctkVTKObjectEventsObserver(QObject *parent=0)
void setStrictTypeCheck(bool check)
int blockConnection(bool block, vtkObject *vtk_obj, unsigned long vtk_event, const QObject *qt_obj)
virtual ~ctkVTKObjectEventsObserver()
QString reconnection(vtkObject *vtk_obj, unsigned long vtk_event, const QObject *qt_obj, const char *qt_slot, float priority=0.0, Qt::ConnectionType connectionType=Qt::AutoConnection)
QScopedPointer< ctkVTKObjectEventsObserverPrivate > d_ptr
bool connectionsBlocked() const
bool containsConnection(vtkObject *vtk_obj, unsigned long vtk_event=vtkCommand::NoEvent, const QObject *qt_obj=0, const char *qt_slot=0) const
int removeConnection(vtkObject *vtk_obj, unsigned long vtk_event=vtkCommand::NoEvent, const QObject *qt_obj=0, const char *qt_slot=0)
bool blockConnection(const QString &id, bool blocked)
virtual void printAdditionalInfo()
bool blockAllConnections(bool block)
QString addConnection(vtkObject *old_vtk_obj, vtkObject *vtk_obj, unsigned long vtk_event, const QObject *qt_obj, const char *qt_slot, float priority=0.0, Qt::ConnectionType connectionType=Qt::AutoConnection)
#define CTK_SINGLETON_DECLARE_INITIALIZER(EXPORT_DIRECTIVE, NAME)
Should be added at the bottom of the header file, after the class declaration.
Definition: ctkSingleton.h:54
#define CTK_SINGLETON_DECLARE(NAME)
Inspired from VTK/Utilities/kwsys/SystemTools class.
Definition: ctkSingleton.h:38