瀏覽代碼

ctkWorkflow - Added associated PythonQt decorator

Jean-Christophe Fillion-Robin 14 年之前
父節點
當前提交
6379ebb085

+ 5 - 5
Applications/ctkSimplePythonShell/ctkSimplePythonQtDecorators.h

@@ -4,6 +4,9 @@
 
 // CTK includes
 #include <ctkAbstractPythonManager.h>
+#include <ctkCorePythonQtDecorators.h>
+#include <ctkWidgetsPythonQtDecorators.h>
+#include <PythonQt.h>
 
 // NOTE:
 //
@@ -21,11 +24,8 @@ public:
   ctkSimplePythonQtDecorators(ctkAbstractPythonManager* pythonManager)
     {
     Q_ASSERT(pythonManager);
-    //pythonManager->registerClassForPythonQt(&qSlicerCoreApplication::staticMetaObject);
-    //pythonManager->registerClassForPythonQt(&qSlicerModuleManager::staticMetaObject);
-    //pythonManager->registerClassForPythonQt(&qSlicerAbstractModule::staticMetaObject);
-    //pythonManager->registerClassForPythonQt(&qSlicerAbstractModuleWidget::staticMetaObject);
-    //pythonManager->registerCPPClassForPythonQt("qSlicerModuleFactoryManager");
+    pythonManager->registerPythonQtDecorator(new ctkCorePythonQtDecorators);
+    pythonManager->registerPythonQtDecorator(new ctkWidgetsPythonQtDecorators);
     }
 
 public slots:

+ 19 - 0
Libs/Core/CMakeLists.txt

@@ -46,6 +46,7 @@ SET(KIT_SRCS
   ctkUtils.h
   ctkWorkflow.h
   ctkWorkflow.cpp
+  ctkWorkflow_p.h
   ctkWorkflowStep.h
   ctkWorkflowStep.cpp
   ctkWorkflowStep_p.h
@@ -59,6 +60,17 @@ IF(CTK_HAVE_BFD)
     )
 ENDIF()
 
+IF(CTK_WRAP_PYTHONQT_LIGHT)
+  LIST(APPEND KIT_SRCS
+    ctkCorePythonQtDecorators.h
+    )
+  # Let's make sure the decorator are not wrapped !
+  SET_SOURCE_FILES_PROPERTIES(
+    ctkCorePythonQtDecorators.h
+    WRAP_EXCLUDE
+    )
+ENDIF()
+
 # Headers that should run through moc
 SET(KIT_MOC_SRCS
   ctkCommandLineParser.h
@@ -68,10 +80,17 @@ SET(KIT_MOC_SRCS
   ctkTransferFunction.h
   ctkTransferFunctionRepresentation.h
   ctkWorkflow.h
+  ctkWorkflow_p.h
   ctkWorkflowStep_p.h
   ctkWorkflowTransitions.h
   )
 
+IF(CTK_WRAP_PYTHONQT_LIGHT)
+  LIST(APPEND KIT_MOC_SRCS
+    ctkCorePythonQtDecorators.h
+    )
+ENDIF()
+
 # UI files
 SET(KIT_UI_FORMS
 )

+ 156 - 0
Libs/Core/ctkCorePythonQtDecorators.h

@@ -0,0 +1,156 @@
+/*=auto=========================================================================
+
+ Portions (c) Copyright 2005 Brigham and Women's Hospital (BWH) 
+ All Rights Reserved.
+
+ See Doc/copyright/copyright.txt
+ or http://www.slicer.org/copyright/copyright.txt for details.
+
+ Program:   3D Slicer
+
+=========================================================================auto=*/
+
+#ifndef __ctkCorePythonQtDecorators_h
+#define __ctkCorePythonQtDecorators_h
+
+// Qt includes
+#include <QObject>
+
+// PythonQt includes
+#include <PythonQt.h>
+
+// CTK includes
+#include <ctkWorkflowStep.h>
+#include <ctkWorkflowTransitions.h>
+
+#include "ctkCoreExport.h"
+
+// NOTE:
+//
+// For decorators it is assumed that the methods will never be called
+// with the self argument as NULL.  The self argument is the first argument
+// for non-static methods.
+//
+
+class CTK_CORE_EXPORT ctkCorePythonQtDecorators : public QObject
+{
+  Q_OBJECT
+public:
+
+  ctkCorePythonQtDecorators()
+    {
+    PythonQt::self()->registerCPPClass("ctkWorkflowStep", 0, "CTKCore");
+    PythonQt::self()->registerClass(&ctkWorkflowInterstepTransition::staticMetaObject, "CTKCore");
+    }
+
+public slots:
+
+  //
+  // ctkWorkflowStep
+  //
+
+  ctkWorkflowStep* new_ctkWorkflowStep()
+    {
+    return new ctkWorkflowStep();
+    }
+
+  ctkWorkflowStep* new_ctkWorkflowStep(ctkWorkflow* newWorkflow, const QString& newId = QString())
+    {
+    return new ctkWorkflowStep(newWorkflow, newId);
+    }
+
+  void delete_ctkWorkflowStep(ctkWorkflowStep * step)
+    {
+    delete step;
+    }
+    
+  ctkWorkflow* workflow(ctkWorkflowStep* step)const
+    {
+    return step->workflow();
+    }
+
+  QString id(ctkWorkflowStep* step)const
+    {
+    return step->id();
+    }
+
+  QString name(ctkWorkflowStep* step)const
+    {
+    return step->name();
+    }
+    
+  void setName(ctkWorkflowStep* step, const QString& newName)
+    {
+    step->setName(newName);
+    }
+
+  QString description(ctkWorkflowStep* step)const
+    {
+    return step->description();
+    }
+    
+  void setDescription(ctkWorkflowStep* step, const QString& newDescription)
+    {
+    step->setDescription(newDescription);
+    }
+
+  QString statusText(ctkWorkflowStep* step)const
+    {
+    return step->statusText();
+    }
+
+  bool hasValidateCommand(ctkWorkflowStep* step)const
+    {
+    return step->hasValidateCommand();
+    }
+    
+  void setHasValidateCommand(ctkWorkflowStep* step, bool newHasValidateCommand)
+    {
+    step->setHasValidateCommand(newHasValidateCommand);
+    }
+
+  bool hasOnEntryCommand(ctkWorkflowStep* step)const
+    {
+    return step->hasOnEntryCommand();
+    }
+    
+  void setHasOnEntryCommand(ctkWorkflowStep* step, bool newHasOnEntryCommand)
+    {
+    step->setHasOnEntryCommand(newHasOnEntryCommand);
+    }
+
+  bool hasOnExitCommand(ctkWorkflowStep* step)const
+    {
+    return step->hasOnExitCommand();
+    }
+    
+  void setHasOnExitCommand(ctkWorkflowStep* step, bool newHasOnExitCommand)
+    {
+    step->setHasOnExitCommand(newHasOnExitCommand);
+    }
+  
+  QObject* ctkWorkflowStepQObject(ctkWorkflowStep* step)
+    {
+    return step->ctkWorkflowStepQObject();
+    }
+
+  //
+  // ctkWorkflowInterstepTransition
+  //
+  ctkWorkflowInterstepTransition* new_ctkWorkflowInterstepTransition(ctkWorkflowInterstepTransition::InterstepTransitionType newTransitionType)
+    {
+    return new ctkWorkflowInterstepTransition(newTransitionType);
+    }
+  
+  ctkWorkflowInterstepTransition* new_ctkWorkflowInterstepTransition(ctkWorkflowInterstepTransition::InterstepTransitionType newTransitionType, const QString& newId)
+    {
+    return new ctkWorkflowInterstepTransition(newTransitionType, newId);
+    }
+    
+  void delete_ctkWorkflowInterstepTransition(ctkWorkflowInterstepTransition * transition)
+    {
+    delete transition;
+    }
+};
+
+#endif

+ 18 - 0
Libs/Widgets/CMakeLists.txt

@@ -121,6 +121,17 @@ SET(KIT_SRCS
   ctkDateRangeWidget.h
   )
 
+IF(CTK_WRAP_PYTHONQT_LIGHT)
+  LIST(APPEND KIT_SRCS
+    ctkWidgetsPythonQtDecorators.h
+    )
+  # Let's make sure the decorator are not wrapped !
+  SET_SOURCE_FILES_PROPERTIES(
+    ctkWidgetsPythonQtDecorators.h
+    WRAP_EXCLUDE
+    )
+ENDIF()
+
 # Headers that should run through moc
 SET(KIT_MOC_SRCS
   ctkWorkflowAbstractWidgetStep_p.h
@@ -179,6 +190,13 @@ SET(KIT_MOC_SRCS
   ctkDateRangeWidget.h
   )
 
+
+IF(CTK_WRAP_PYTHONQT_LIGHT)
+  LIST(APPEND KIT_MOC_SRCS
+    ctkWidgetsPythonQtDecorators.h
+    )
+ENDIF()
+
 # UI files
 SET(KIT_UI_FORMS
   Resources/UI/ctkAddRemoveComboBox.ui

+ 70 - 0
Libs/Widgets/ctkWidgetsPythonQtDecorators.h

@@ -0,0 +1,70 @@
+/*=auto=========================================================================
+
+ Portions (c) Copyright 2005 Brigham and Women's Hospital (BWH) 
+ All Rights Reserved.
+
+ See Doc/copyright/copyright.txt
+ or http://www.slicer.org/copyright/copyright.txt for details.
+
+ Program:   3D Slicer
+
+=========================================================================auto=*/
+
+#ifndef __ctkWidgetsPythonQtDecorators_h
+#define __ctkWidgetsPythonQtDecorators_h
+
+// Qt includes
+#include <QObject>
+
+// PythonQt includes
+#include <PythonQt.h>
+
+// CTK includes
+#include <ctkWorkflowWidgetStep.h>
+
+#include "ctkWidgetsExport.h"
+
+// NOTE:
+//
+// For decorators it is assumed that the methods will never be called
+// with the self argument as NULL.  The self argument is the first argument
+// for non-static methods.
+//
+
+class CTK_WIDGETS_EXPORT ctkWidgetsPythonQtDecorators : public QObject
+{
+  Q_OBJECT
+public:
+
+  ctkWidgetsPythonQtDecorators()
+    {
+    PythonQt::self()->addParentClass("ctkWorkflowWidgetStep", "ctkWorkflowStep",
+                                     PythonQtUpcastingOffset<ctkWorkflowWidgetStep,ctkWorkflowStep>());
+    }
+
+public slots:
+
+  bool hasCreateUserInterfaceCommand(ctkWorkflowWidgetStep* step)const
+    {
+    return step->hasCreateUserInterfaceCommand();
+    }
+
+  void setHasCreateUserInterfaceCommand(
+    ctkWorkflowWidgetStep* step, bool newHasCreateUserInterfaceCommand)
+    {
+    step->setHasCreateUserInterfaceCommand(newHasCreateUserInterfaceCommand);
+    }
+
+  bool hasShowUserInterfaceCommand(ctkWorkflowWidgetStep* step)const
+    {
+    return step->hasShowUserInterfaceCommand();
+    }
+
+  void setHasShowUserInterfaceCommand(
+    ctkWorkflowWidgetStep* step, bool newHasShowUserInterfaceCommand)
+    {
+    step->setHasShowUserInterfaceCommand(newHasShowUserInterfaceCommand);
+    }
+};
+
+#endif