forked from Slicer/Slicer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Remove public setInstance function and do the cleanup in a private cleanup function - Add PythonQtDecorator classes to be able to use the instance function as static in Python to create the factory class - Make constructor and destructor private to prevent accidental wrong use (add PythonQtWrapper generated class as friend to allow this) - Update usage of these factories that used the workaround to fix non-static instance function Re commontk/CTK#970
- Loading branch information
Showing
10 changed files
with
177 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
Modules/Loadable/Markups/Widgets/qSlicerMarkupsModuleWidgetsPythonQtDecorators.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/*=auto========================================================================= | ||
Portions (c) Copyright 2005 Brigham and Women's Hospital (BWH) | ||
All Rights Reserved. | ||
See COPYRIGHT.txt | ||
or http://www.slicer.org/copyright/copyright.txt for details. | ||
Program: 3D Slicer | ||
=========================================================================auto=*/ | ||
|
||
#ifndef __qSlicerMarkupsModuleWidgetsPythonQtDecorators_h | ||
#define __qSlicerMarkupsModuleWidgetsPythonQtDecorators_h | ||
|
||
// PythonQt includes | ||
#include <PythonQt.h> | ||
|
||
// Slicer includes | ||
#include "qSlicerMarkupsAdditionalOptionsWidgetsFactory.h" | ||
|
||
#include "qSlicerMarkupsModuleWidgetsExport.h" | ||
|
||
// NOTE: | ||
// | ||
// For decorators it is assumed that the methods will never be called | ||
// with the self argument as nullptr. The self argument is the first argument | ||
// for non-static methods. | ||
// | ||
|
||
class qSlicerMarkupsModuleWidgetsPythonQtDecorators : public QObject | ||
{ | ||
Q_OBJECT | ||
public: | ||
|
||
qSlicerMarkupsModuleWidgetsPythonQtDecorators() | ||
{ | ||
//PythonQt::self()->registerClass(&qSlicerMarkupsAdditionalOptionsWidgetsFactory::staticMetaObject); | ||
// Note: Use registerCPPClassForPythonQt to register pure Cpp classes | ||
} | ||
|
||
public slots: | ||
|
||
//---------------------------------------------------------------------------- | ||
// qSlicerMarkupsAdditionalOptionsWidgetsFactory | ||
|
||
//---------------------------------------------------------------------------- | ||
// static methods | ||
|
||
//---------------------------------------------------------------------------- | ||
qSlicerMarkupsAdditionalOptionsWidgetsFactory* static_qSlicerMarkupsAdditionalOptionsWidgetsFactory_instance() | ||
{ | ||
return qSlicerMarkupsAdditionalOptionsWidgetsFactory::instance(); | ||
} | ||
|
||
//---------------------------------------------------------------------------- | ||
// instance methods | ||
|
||
//---------------------------------------------------------------------------- | ||
bool registerAdditionalOptionsWidget(qSlicerMarkupsAdditionalOptionsWidgetsFactory* factory, | ||
PythonQtPassOwnershipToCPP<qSlicerMarkupsAdditionalOptionsWidget*> plugin) | ||
{ | ||
return factory->registerAdditionalOptionsWidget(plugin); | ||
} | ||
}; | ||
|
||
//----------------------------------------------------------------------------- | ||
void initqSlicerMarkupsModuleWidgetsPythonQtDecorators() | ||
{ | ||
PythonQt::self()->addDecorators(new qSlicerMarkupsModuleWidgetsPythonQtDecorators); | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
...oadable/Segmentations/EditorEffects/qSlicerSegmentationsEditorEffectsPythonQtDecorators.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/*=auto========================================================================= | ||
Portions (c) Copyright 2005 Brigham and Women's Hospital (BWH) | ||
All Rights Reserved. | ||
See COPYRIGHT.txt | ||
or http://www.slicer.org/copyright/copyright.txt for details. | ||
Program: 3D Slicer | ||
=========================================================================auto=*/ | ||
|
||
#ifndef __qSlicerSegmentationsEditorEffectsPythonQtDecorators_h | ||
#define __qSlicerSegmentationsEditorEffectsPythonQtDecorators_h | ||
|
||
// PythonQt includes | ||
#include <PythonQt.h> | ||
|
||
// Slicer includes | ||
#include "qSlicerSegmentEditorEffectFactory.h" | ||
|
||
#include "qSlicerSegmentationsEditorEffectsExport.h" | ||
|
||
// NOTE: | ||
// | ||
// For decorators it is assumed that the methods will never be called | ||
// with the self argument as nullptr. The self argument is the first argument | ||
// for non-static methods. | ||
// | ||
|
||
class qSlicerSegmentationsEditorEffectsPythonQtDecorators : public QObject | ||
{ | ||
Q_OBJECT | ||
public: | ||
|
||
qSlicerSegmentationsEditorEffectsPythonQtDecorators() | ||
{ | ||
//PythonQt::self()->registerClass(&qSlicerSegmentEditorEffectFactory::staticMetaObject); | ||
// Note: Use registerCPPClassForPythonQt to register pure Cpp classes | ||
} | ||
|
||
public slots: | ||
|
||
//---------------------------------------------------------------------------- | ||
// qSlicerSegmentEditorEffectFactory | ||
|
||
//---------------------------------------------------------------------------- | ||
// static methods | ||
|
||
//---------------------------------------------------------------------------- | ||
qSlicerSegmentEditorEffectFactory* static_qSlicerSegmentEditorEffectFactory_instance() | ||
{ | ||
return qSlicerSegmentEditorEffectFactory::instance(); | ||
} | ||
|
||
//---------------------------------------------------------------------------- | ||
// instance methods | ||
|
||
//---------------------------------------------------------------------------- | ||
bool registerEffect(qSlicerSegmentEditorEffectFactory* factory, | ||
PythonQtPassOwnershipToCPP<qSlicerSegmentEditorAbstractEffect*> plugin) | ||
{ | ||
return factory->registerEffect(plugin); | ||
} | ||
}; | ||
|
||
//----------------------------------------------------------------------------- | ||
void initqSlicerSegmentationsEditorEffectsPythonQtDecorators() | ||
{ | ||
PythonQt::self()->addDecorators(new qSlicerSegmentationsEditorEffectsPythonQtDecorators); | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters