Commit 1c287098 authored by David E. DeMarle's avatar David E. DeMarle

cleanup by changing from isA vtkMaterialLibrary to hasA

The PV level class no longer changes its ancestry dependent
on cmake config option of use or don't use OSPRay. Instead
it keeps an internal reference and delegates to that.

Other than some long cast lines, this feels cleaner.
parent 3042107a
......@@ -569,7 +569,7 @@
{ "class": "vtkPVImplicitPlaneRepresentation" },
{ "class": "vtkPVLastSelectionInformation" },
{ "class": "vtkPVOpenGLInformation" },
{ "class": "vtkPVOSPRayMaterialLibrary" },
{ "class": "vtkPVMaterialLibrary" },
{ "class": "vtkPVPlotMatrixView" },
{ "class": "vtkPVProminentValuesInformation" },
{ "class": "vtkPVRenderingCapabilitiesInformation" },
......
......@@ -77,7 +77,7 @@ set (Module_SRCS
vtkPVMultiSliceView.cxx
vtkPVOpenGLInformation.cxx
vtkPVOrthographicSliceView.cxx
vtkPVOSPRayMaterialLibrary.cxx
vtkPVMaterialLibrary.cxx
vtkPVParallelCoordinatesRepresentation.cxx
vtkPVPlotMatrixRepresentation.cxx
vtkPVPlotMatrixView.cxx
......
/*=========================================================================
Program: ParaView
Module: vtkPVOSPRayMaterialLibrary.cxx
Module: vtkPVMaterialLibrary.cxx
Copyright (c) Kitware, Inc.
All rights reserved.
......@@ -12,11 +12,14 @@
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkPVOSPRayMaterialLibrary.h"
#include "vtkPVMaterialLibrary.h"
#include "vtkObjectFactory.h"
#include "vtkPVConfig.h"
#include "vtkPVOptions.h"
#ifdef PARAVIEW_USE_OSPRAY
#include "vtkOSPRayMaterialLibrary.h"
#endif
#include "vtkProcessModule.h"
#include <string>
......@@ -28,9 +31,9 @@ const char ENV_PATH_SEP = ';';
const char ENV_PATH_SEP = ':';
#endif
vtkStandardNewMacro(vtkPVOSPRayMaterialLibrary);
vtkStandardNewMacro(vtkPVMaterialLibrary);
//-----------------------------------------------------------------------------
vtkPVOSPRayMaterialLibrary::vtkPVOSPRayMaterialLibrary()
vtkPVMaterialLibrary::vtkPVMaterialLibrary()
{
this->SearchPaths = nullptr;
vtksys::String paths;
......@@ -69,23 +72,32 @@ vtkPVOSPRayMaterialLibrary::vtkPVOSPRayMaterialLibrary()
}
this->SetSearchPaths(paths.c_str());
#ifdef PARAVIEW_USE_OSPRAY
this->MaterialLibrary = vtkOSPRayMaterialLibrary::New();
#else
this->MaterialLibrary = nullptr;
#endif
}
//-----------------------------------------------------------------------------
vtkPVOSPRayMaterialLibrary::~vtkPVOSPRayMaterialLibrary()
vtkPVMaterialLibrary::~vtkPVMaterialLibrary()
{
this->SetSearchPaths(nullptr);
if (this->MaterialLibrary)
{
this->MaterialLibrary->Delete();
}
}
//-----------------------------------------------------------------------------
void vtkPVOSPRayMaterialLibrary::PrintSelf(ostream& os, vtkIndent indent)
void vtkPVMaterialLibrary::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
os << indent << "SearchPaths: " << (this->SearchPaths ? this->SearchPaths : "(none)") << endl;
}
//-----------------------------------------------------------------------------
void vtkPVOSPRayMaterialLibrary::ReadRelativeFile(const char* FileName)
void vtkPVMaterialLibrary::ReadRelativeFile(const char* FileName)
{
#ifdef PARAVIEW_USE_OSPRAY
std::vector<std::string> paths;
......@@ -107,3 +119,41 @@ void vtkPVOSPRayMaterialLibrary::ReadRelativeFile(const char* FileName)
(void)FileName;
#endif
}
//-----------------------------------------------------------------------------
vtkObject* vtkPVMaterialLibrary::GetMaterialLibrary()
{
return this->MaterialLibrary;
}
//-----------------------------------------------------------------------------
bool vtkPVMaterialLibrary::ReadFile(const char* FileName)
{
#ifdef PARAVIEW_USE_OSPRAY
return vtkOSPRayMaterialLibrary::SafeDownCast(this->GetMaterialLibrary())->ReadFile(FileName);
#else
(void)FileName;
return false;
#endif
}
//-----------------------------------------------------------------------------
bool vtkPVMaterialLibrary::ReadBuffer(const char* FileName)
{
#ifdef PARAVIEW_USE_OSPRAY
return vtkOSPRayMaterialLibrary::SafeDownCast(this->GetMaterialLibrary())->ReadBuffer(FileName);
#else
(void)FileName;
return false;
#endif
}
//-----------------------------------------------------------------------------
const char* vtkPVMaterialLibrary::WriteBuffer()
{
#ifdef PARAVIEW_USE_OSPRAY
return vtkOSPRayMaterialLibrary::SafeDownCast(this->GetMaterialLibrary())->WriteBuffer();
#else
return nullptr;
#endif
}
/*=========================================================================
Program: ParaView
Module: vtkPVOSPRayMaterialLibrary.h
Module: vtkPVMaterialLibrary.h
Copyright (c) Kitware, Inc.
All rights reserved.
......@@ -13,45 +13,28 @@
=========================================================================*/
/**
* @class vtkPVOSPRayMaterialLibrary
* @brief Used to load OSPRay Material Library definitions.
* @class vtkPVMaterialLibrary
* @brief manages visual material definitions
*
* vtkPVOSPRayMaterialLibrary helps ParaView to load OSPRay Material files
* from known, generally process relative, locations on the sever.
* vtkPVMaterialLibrary helps ParaView to load visual material definition
* files from known, generally process relative, locations on the sever.
*/
#ifndef vtkPVOSPRayMaterialLibrary_h
#define vtkPVOSPRayMaterialLibrary_h
#ifndef vtkPVMaterialLibrary_h
#define vtkPVMaterialLibrary_h
#include "vtkPVClientServerCoreRenderingModule.h" //needed for exports
#include "vtkPVConfig.h"
#ifdef PARAVIEW_USE_OSPRAY
#include "vtkOSPRayMaterialLibrary.h"
class VTKPVCLIENTSERVERCORERENDERING_EXPORT vtkPVOSPRayMaterialLibrary
: public vtkOSPRayMaterialLibrary
{
public:
static vtkPVOSPRayMaterialLibrary* New();
vtkTypeMacro(vtkPVOSPRayMaterialLibrary, vtkOSPRayMaterialLibrary);
#else
#include "vtkObject.h"
class VTKPVCLIENTSERVERCORERENDERING_EXPORT vtkPVOSPRayMaterialLibrary : public vtkObject
class VTKPVCLIENTSERVERCORERENDERING_EXPORT vtkPVMaterialLibrary : public vtkObject
{
public:
static vtkPVOSPRayMaterialLibrary* New();
vtkTypeMacro(vtkPVOSPRayMaterialLibrary, vtkObject);
// fake API for OSPRayMaterialLibrary
bool ReadFile(const char*) { return false; };
const char* WriteBuffer() { return nullptr; };
bool ReadBuffer(const char*) { return false; };
#endif
static vtkPVMaterialLibrary* New();
vtkTypeMacro(vtkPVMaterialLibrary, vtkObject);
void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
/**
* Unlike parent class's ReadFile, this searches in a number of
* Unlike vtkOSPRayMaterial::ReadFile, this searches in a number of
* relative and environmental paths specified by the SearchPaths
* member variable.
*/
......@@ -64,18 +47,38 @@ public:
*/
vtkGetStringMacro(SearchPaths);
/**
* Returns the underlying material library.
* When compiled withouth OSPRAY, will return nullptr
*/
vtkObject* GetMaterialLibrary();
/**
* Defer to contained MaterialLibrary
*/
bool ReadFile(const char* FileName);
/**
* Defer to contained MaterialLibrary
*/
const char* WriteBuffer();
/**
* Defer to contained MaterialLibrary
*/
bool ReadBuffer(const char*);
protected:
vtkPVOSPRayMaterialLibrary();
~vtkPVOSPRayMaterialLibrary() override;
vtkPVMaterialLibrary();
~vtkPVMaterialLibrary() override;
vtkSetStringMacro(SearchPaths);
char* SearchPaths;
vtkObject* MaterialLibrary;
private:
vtkPVOSPRayMaterialLibrary(const vtkPVOSPRayMaterialLibrary&) = delete;
void operator=(const vtkPVOSPRayMaterialLibrary&) = delete;
vtkPVMaterialLibrary(const vtkPVMaterialLibrary&) = delete;
void operator=(const vtkPVMaterialLibrary&) = delete;
};
#endif
// VTK-HeaderTest-Exclude: vtkPVOSPRayMaterialLibrary.h
......@@ -60,7 +60,7 @@
#include "vtkPVGridAxes3DActor.h"
#include "vtkPVHardwareSelector.h"
#include "vtkPVInteractorStyle.h"
#include "vtkPVOSPRayMaterialLibrary.h"
#include "vtkPVMaterialLibrary.h"
#include "vtkPVOptions.h"
#include "vtkPVServerInformation.h"
#include "vtkPVSession.h"
......@@ -103,6 +103,7 @@
#ifdef PARAVIEW_USE_OSPRAY
#include "vtkOSPRayLightNode.h"
#include "vtkOSPRayMaterialLibrary.h"
#include "vtkOSPRayPass.h"
#include "vtkOSPRayRendererNode.h"
#endif
......@@ -2984,11 +2985,12 @@ bool vtkPVRenderView::GetEnableOSPRay()
}
//----------------------------------------------------------------------------
void vtkPVRenderView::SetMaterialLibrary(vtkPVOSPRayMaterialLibrary* ml)
void vtkPVRenderView::SetMaterialLibrary(vtkPVMaterialLibrary* ml)
{
#ifdef PARAVIEW_USE_OSPRAY
vtkRenderer* ren = this->GetRenderer();
vtkOSPRayRendererNode::SetMaterialLibrary(ml, ren);
vtkOSPRayRendererNode::SetMaterialLibrary(
vtkOSPRayMaterialLibrary::SafeDownCast(ml->GetMaterialLibrary()), ren);
#else
(void)ml;
#endif
......
......@@ -59,7 +59,7 @@ class vtkPVDataRepresentation;
class vtkPVGridAxes3DActor;
class vtkPVHardwareSelector;
class vtkPVInteractorStyle;
class vtkPVOSPRayMaterialLibrary;
class vtkPVMaterialLibrary;
class vtkPVSynchronizedRenderer;
class vtkRenderer;
class vtkRenderViewBase;
......@@ -890,7 +890,7 @@ public:
/**
* For OSPRay, set the library of materials.
*/
virtual void SetMaterialLibrary(vtkPVOSPRayMaterialLibrary*);
virtual void SetMaterialLibrary(vtkPVMaterialLibrary*);
//@{
/**
......
......@@ -17,6 +17,7 @@
#include "vtkCommand.h"
#include "vtkNew.h"
#include "vtkObjectFactory.h"
#include "vtkPVMaterialLibrary.h"
#include "vtkSMMaterialLibraryProxy.h"
#include "vtkSMParaViewPipelineController.h"
#include "vtkSMProperty.h"
......@@ -61,7 +62,8 @@ public:
if (mlp)
{
// todo: is GetClientSideObject guaranteed to succeed?
this->Watchee = vtkOSPRayMaterialLibrary::SafeDownCast(mlp->GetClientSideObject());
this->Watchee = vtkOSPRayMaterialLibrary::SafeDownCast(
vtkPVMaterialLibrary::SafeDownCast(mlp->GetClientSideObject())->GetMaterialLibrary());
if (this->Watchee)
{
this->Watchee->AddObserver(vtkCommand::UpdateDataEvent, this);
......@@ -148,7 +150,8 @@ void vtkSMMaterialDomain::Update(vtkSMProperty* vtkNotUsed(prop))
{
return;
}
vtkOSPRayMaterialLibrary* ml = vtkOSPRayMaterialLibrary::SafeDownCast(mlp->GetClientSideObject());
vtkOSPRayMaterialLibrary* ml = vtkOSPRayMaterialLibrary::SafeDownCast(
vtkPVMaterialLibrary::SafeDownCast(mlp->GetClientSideObject())->GetMaterialLibrary());
if (!ml)
{
return;
......
......@@ -17,6 +17,7 @@
#include "vtkClientServerStream.h"
#include "vtkObjectFactory.h"
#include "vtkPVConfig.h"
#include "vtkPVMaterialLibrary.h"
#include "vtkPVSession.h"
#include "vtkProcessModule.h"
#include "vtkSMPropertyHelper.h"
......@@ -96,8 +97,8 @@ void vtkSMMaterialLibraryProxy::Synchronize()
this->ExecuteStream(stream2, false, vtkProcessModule::CLIENT);
}
vtkOSPRayMaterialLibrary* ml =
vtkOSPRayMaterialLibrary::SafeDownCast(this->GetClientSideObject());
vtkOSPRayMaterialLibrary* ml = vtkOSPRayMaterialLibrary::SafeDownCast(
vtkPVMaterialLibrary::SafeDownCast(this->GetClientSideObject())->GetMaterialLibrary());
ml->Fire();
#else
return;
......
......@@ -104,7 +104,6 @@ SET(requestedResourceFiles
${CMAKE_CURRENT_SOURCE_DIR}/Resources/views_and_representations.xml
${CMAKE_CURRENT_SOURCE_DIR}/Resources/writers.xml
${CMAKE_CURRENT_SOURCE_DIR}/Resources/proxies_opengl2.xml # has to be after views_and_representations
${CMAKE_CURRENT_SOURCE_DIR}/Resources/proxies_ospray.xml
${module_sm_xmls}
)
if (PARAVIEW_USE_MPI)
......
<ServerManagerConfiguration>
<ProxyGroup name="materials">
<MaterialLibraryProxy class="vtkPVOSPRayMaterialLibrary"
name="MaterialLibrary"
processes="client|renderserver">
<StringVectorProperty
default_values=""
label="Load Materials"
name="LoadMaterials"
number_of_elements="1"
panel_visibility="never">
</StringVectorProperty>
</MaterialLibraryProxy>
</ProxyGroup>
</ServerManagerConfiguration>
......@@ -648,5 +648,18 @@
</LightProxy>
<!-- End of additional_lights -->
</ProxyGroup>
<ProxyGroup name="materials">
<MaterialLibraryProxy class="vtkPVMaterialLibrary"
name="MaterialLibrary"
processes="client|renderserver">
<StringVectorProperty
default_values=""
label="Load Materials"
name="LoadMaterials"
number_of_elements="1"
panel_visibility="never">
</StringVectorProperty>
</MaterialLibraryProxy>
</ProxyGroup>
</ServerManagerConfiguration>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment