Skip to content

Commit

Permalink
Split GL2PSExporter into an abstract base and OpenGL override.
Browse files Browse the repository at this point in the history
  • Loading branch information
David C. Lonie committed Jan 18, 2016
1 parent fee4ea5 commit b48e9f4
Show file tree
Hide file tree
Showing 11 changed files with 1,122 additions and 945 deletions.
1 change: 1 addition & 0 deletions CMake/vtkBackends.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,5 @@ if (VTK_RENDERING_BACKEND STREQUAL "None")
vtk_module(vtkRenderingNone )
vtk_module(vtkRenderingContextNone )
vtk_module(vtkRenderingVolumeNone )
vtk_module(vtkIOExportNone ) # GL2PSExporter differs on OGL backends
endif()
8 changes: 6 additions & 2 deletions Common/Core/vtkObjectFactory.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ static vtkCleanUpObjectFactory vtkCleanUpObjectFactoryGlobal;
// Create an instance of a named vtk object using the loaded
// factories

vtkObject* vtkObjectFactory::CreateInstance(const char* vtkclassname)
vtkObject* vtkObjectFactory::CreateInstance(const char* vtkclassname,
bool isAbstract)
{
if(!vtkObjectFactory::RegisteredFactories)
{
Expand All @@ -68,9 +69,12 @@ vtkObject* vtkObjectFactory::CreateInstance(const char* vtkclassname)
// if the factory does not create the object, then
// the object will be created with the name passed in,
// so register the construction
if (!isAbstract)
{
#ifdef VTK_DEBUG_LEAKS
vtkDebugLeaks::ConstructClass(vtkclassname);
vtkDebugLeaks::ConstructClass(vtkclassname);
#endif
}

return 0;
}
Expand Down
10 changes: 7 additions & 3 deletions Common/Core/vtkObjectFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ class VTKCOMMONCORE_EXPORT vtkObjectFactory : public vtkObject
// Each loaded vtkObjectFactory will be asked in the order
// the factory was in the VTK_AUTOLOAD_PATH. After the
// first factory returns the object no other factories are asked.
static vtkObject* CreateInstance(const char* vtkclassname);
// If the requested class is abstract, set isAbstract to true. Otherwise
// it is assumed that an instance of 'vtkclassname' will be instantiated
// by the caller when no override is found.
static vtkObject* CreateInstance(const char* vtkclassname,
bool isAbstract = false);

// Description:
// Call vtkDebugLeaks::ConstructClass if necessary. Does not attempt
Expand Down Expand Up @@ -284,7 +288,7 @@ vtkObjectFactory* vtkLoad() \

// Macro to implement the body of the object factory form of the New() method.
#define VTK_OBJECT_FACTORY_NEW_BODY(thisClass) \
vtkObject* ret = vtkObjectFactory::CreateInstance(#thisClass); \
vtkObject* ret = vtkObjectFactory::CreateInstance(#thisClass, false); \
if(ret) \
{ \
return static_cast<thisClass*>(ret); \
Expand All @@ -295,7 +299,7 @@ vtkObjectFactory* vtkLoad() \
// method, i.e. an abstract base class that can only be instantiated if the
// object factory overrides it.
#define VTK_ABSTRACT_OBJECT_FACTORY_NEW_BODY(thisClass) \
vtkObject* ret = vtkObjectFactory::CreateInstance(#thisClass); \
vtkObject* ret = vtkObjectFactory::CreateInstance(#thisClass, true); \
if(ret) \
{ \
return static_cast<thisClass*>(ret); \
Expand Down
10 changes: 4 additions & 6 deletions IO/Export/module.cmake
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
if(VTK_RENDERING_BACKEND STREQUAL "OpenGL")
set(opengl_depends vtkRenderingGL2PS)
set(private_opengl_depends vtkgl2ps)
set(test_opengl_depends vtkIOExportOpenGL)
endif()
vtk_module(vtkIOExport
GROUPS
Rendering
DEPENDS
vtkCommonCore
vtkRenderingAnnotation
vtkRenderingContext2D
vtkRenderingCore
vtkRenderingFreeType
${opengl_depends}
vtkRenderingLabel
vtkRendering${VTK_RENDERING_BACKEND}
vtkImagingCore
vtkRenderingCore
PRIVATE_DEPENDS
vtkIOImage
vtkFiltersGeometry
Expand All @@ -23,9 +19,11 @@ vtk_module(vtkIOExport
vtkCommonColor
vtkChartsCore
vtkInteractionImage
${test_opengl_depends}
vtkTestingRendering
vtkInteractionStyle
vtkRenderingAnnotation
vtkRenderingLabel
vtkRenderingVolume${VTK_RENDERING_BACKEND}
vtkRenderingContext${VTK_RENDERING_BACKEND}
vtkViewsContext2D
Expand Down
Loading

0 comments on commit b48e9f4

Please sign in to comment.