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
ctkVTKObjectEventsObserver::addConnection
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::blockConnection
int blockConnection(bool block, vtkObject *vtk_obj, unsigned long vtk_event, const QObject *qt_obj)
ctkVTKObjectEventsObserver::ctkVTKObjectEventsObserver
ctkVTKObjectEventsObserver(QObject *parent=0)
ctkVTKConnectionFactory::instance
static ctkVTKConnectionFactory * instance()
ctkVTKObjectEventsObserver::printAdditionalInfo
virtual void printAdditionalInfo()
ctkVTKObjectEventsObserver::blockAllConnections
bool blockAllConnections(bool block)
ctkVTKObjectEventsObserver::addConnection
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)
ctkVTKObjectEventsObserver
Connect vtkObject events with QObject slots. Helper class that provides utility methods for connectin...
Definition: ctkVTKObjectEventsObserver.h:45
ctkVTKObjectEventsObserver::containsConnection
bool containsConnection(vtkObject *vtk_obj, unsigned long vtk_event=vtkCommand::NoEvent, const QObject *qt_obj=0, const char *qt_slot=0) const
ctkVTKConnectionFactory::setInstance
static void setInstance(ctkVTKConnectionFactory *newInstance)
CTK_SINGLETON_DECLARE
#define CTK_SINGLETON_DECLARE(NAME)
Inspired from VTK/Utilities/kwsys/SystemTools class.
Definition: ctkSingleton.h:38
ctkVTKObjectEventsObserver::reconnection
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)
ctkVTKObjectEventsObserver::Superclass
QObject Superclass
Definition: ctkVTKObjectEventsObserver.h:62
ctkVTKConnection
Definition: ctkVTKConnection.h:45
ctkVTKObjectEventsObserver::connectionsBlocked
bool connectionsBlocked() const
CTK_SINGLETON_DECLARE_INITIALIZER
#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
ctkVTKObjectEventsObserver::d_ptr
QScopedPointer< ctkVTKObjectEventsObserverPrivate > d_ptr
Definition: ctkVTKObjectEventsObserver.h:165
ctkVTKObjectEventsObserver::setStrictTypeCheck
void setStrictTypeCheck(bool check)
ctkVTKConnectionFactory::~ctkVTKConnectionFactory
virtual ~ctkVTKConnectionFactory()
ctkVTKObjectEventsObserver::removeConnection
int removeConnection(vtkObject *vtk_obj, unsigned long vtk_event=vtkCommand::NoEvent, const QObject *qt_obj=0, const char *qt_slot=0)
ctkVTKObjectEventsObserver::blockConnection
bool blockConnection(const QString &id, bool blocked)
ctkVTKConnectionFactory
Definition: ctkVTKObjectEventsObserver.h:176
ctkVTKConnectionFactory::ctkVTKConnectionFactory
ctkVTKConnectionFactory()
ctkVTKObjectEventsObserver::strictTypeCheck
bool strictTypeCheck() const
ctkSingleton.h
ctkVTKObjectEventsObserver::removeAllConnections
int removeAllConnections()
ctkVTKConnectionFactory::createConnection
virtual ctkVTKConnection * createConnection(ctkVTKObjectEventsObserver *) const
ctkVTKObjectEventsObserver::~ctkVTKObjectEventsObserver
virtual ~ctkVTKObjectEventsObserver()