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

expose OSPRAY based Materials

parent f6ca906b
......@@ -50,6 +50,7 @@
#ifdef PARAVIEW_USE_OSPRAY
#include "vtkOSPRayActorNode.h"
#include "vtkOSPRayMaterialLibrary.h"
#endif
#include <vtksys/SystemTools.hxx>
......@@ -169,6 +170,11 @@ vtkGeometryRepresentation::vtkGeometryRepresentation()
this->Actor = vtkPVLODActor::New();
this->Property = vtkProperty::New();
#ifdef PARAVIEW_USE_OSPRAY
vtkSmartPointer<vtkOSPRayMaterialLibrary> ml = vtkOSPRayMaterialLibrary::GetInstance();
ml->LoadMaterials(this->Property);
#endif
// setup composite display attributes
vtkCompositeDataDisplayAttributes* compositeAttributes = vtkCompositeDataDisplayAttributes::New();
vtkCompositePolyDataMapper2::SafeDownCast(this->Mapper)
......@@ -1057,3 +1063,21 @@ void vtkGeometryRepresentation::SetScalingFunction(vtkPiecewiseFunction* pwf)
(void)pwf;
#endif
}
//----------------------------------------------------------------------------
void vtkGeometryRepresentation::SetMaterial(const char* val)
{
#ifdef PARAVIEW_USE_OSPRAY
if (!strcmp(val, "None"))
{
this->Property->SetMaterialName(nullptr);
}
else
{
this->Property->SetMaterialName(val);
}
#else
(void)val;
#endif
}
......@@ -258,6 +258,11 @@ public:
virtual void SetScalingFunction(vtkPiecewiseFunction* pwf);
//@}
/**
* For OSPRay, choose from among the materials.
*/
virtual void SetMaterial(const char*);
//@{
/**
* Specify whether or not to redistribute the data. The default is false
......
......@@ -102,6 +102,7 @@
#ifdef PARAVIEW_USE_OSPRAY
#include "vtkOSPRayLightNode.h"
#include "vtkOSPRayMaterialLibrary.h"
#include "vtkOSPRayPass.h"
#include "vtkOSPRayRendererNode.h"
#endif
......@@ -3030,6 +3031,26 @@ bool vtkPVRenderView::GetEnableOSPRay()
return this->Internals->IsInOSPRay;
}
//----------------------------------------------------------------------------
void vtkPVRenderView::SetMaterialLibrary(const char* val)
{
#ifdef PARAVIEW_USE_OSPRAY
if (!strcmp(val, "None"))
{
;
}
else
{
// TODO: should only do this when val is changed
vtkSmartPointer<vtkOSPRayMaterialLibrary> ml = vtkOSPRayMaterialLibrary::GetInstance();
ml->ReadFile(val, this->GetRenderer());
vtkOSPRayMaterialLibrary::GetInstance()->Fire();
}
#else
(void)val;
#endif
}
//----------------------------------------------------------------------------
void vtkPVRenderView::SetOSPRayRendererType(std::string name)
{
......
......@@ -897,6 +897,11 @@ public:
*/
void SetOSPRayRendererType(std::string);
/**
* For OSPRay, loads a set of materials.
*/
virtual void SetMaterialLibrary(const char*);
//@{
/**
* DiscreteCameras are a collection of cameras when specified,
......
......@@ -47,6 +47,7 @@ set (Module_SRCS
vtkSMDataDeliveryManager.cxx
vtkSMFunctionalBagChartSeriesSelectionDomain.cxx
vtkSMImplicitPlaneRepresentationProxy.cxx
vtkSMMaterialDomain.cxx
vtkSMMultiSliceViewProxy.cxx
vtkSMNewWidgetRepresentationProxy.cxx
vtkSMOrthographicSliceViewProxy.cxx
......
set (__dependencies)
if (PARAVIEW_USE_OSPRAY)
list (APPEND __dependencies vtkRenderingOSPRay)
endif ()
vtk_module(vtkPVServerManagerRendering
GROUPS
ParaViewRendering
......@@ -7,6 +12,7 @@ vtk_module(vtkPVServerManagerRendering
vtkPVServerImplementationRendering
vtkPVServerManagerCore
vtkjsoncpp
${__dependencies}
PRIVATE_DEPENDS
vtkCommonColor
vtksys
......
/*=========================================================================
Program: ParaView
Module: vtkSMMaterialDomain.cxx
Copyright (c) Kitware, Inc.
All rights reserved.
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkSMMaterialDomain.h"
#include "vtkCommand.h"
#include "vtkNew.h"
#include "vtkOSPRayMaterialLibrary.h"
#include "vtkObjectFactory.h"
#include "vtkSMProperty.h"
#include "vtkStdString.h"
class vtkSMMaterialObserver : public vtkCommand
{
public:
static vtkSMMaterialObserver* New() { return new vtkSMMaterialObserver; }
vtkTypeMacro(vtkSMMaterialObserver, vtkCommand);
void Execute(vtkObject* caller, unsigned long eventid, void* calldata) VTK_OVERRIDE
{
this->Owner->CallMeSometime();
}
vtkSMMaterialDomain* Owner;
};
//---------------------------------------------------------------------------
vtkStandardNewMacro(vtkSMMaterialDomain);
//---------------------------------------------------------------------------
vtkSMMaterialDomain::vtkSMMaterialDomain()
{
vtkNew<vtkSMMaterialObserver> observer;
observer->Owner = this;
vtkOSPRayMaterialLibrary::GetInstance()->AddObserver(vtkCommand::UpdateDataEvent, observer.Get());
}
//---------------------------------------------------------------------------
vtkSMMaterialDomain::~vtkSMMaterialDomain()
{
}
//---------------------------------------------------------------------------
void vtkSMMaterialDomain::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
}
//---------------------------------------------------------------------------
int vtkSMMaterialDomain::ReadXMLAttributes(vtkSMProperty* prop, vtkPVXMLElement* element)
{
int retVal = this->Superclass::ReadXMLAttributes(prop, element);
if (!retVal)
{
return 0;
}
// throw away whatever XML said our strings are and call update instead
this->Update(nullptr);
return 1;
}
//---------------------------------------------------------------------------
void vtkSMMaterialDomain::CallMeSometime()
{
this->Update(nullptr);
this->DomainModified();
}
//---------------------------------------------------------------------------
void vtkSMMaterialDomain::Update(vtkSMProperty* vtkNotUsed(prop))
{
std::vector<vtkStdString> sa;
sa.push_back(vtkStdString("None"));
std::set<std::string> materialNames = vtkOSPRayMaterialLibrary::GetInstance()->GetMaterialNames();
std::set<std::string>::iterator it = materialNames.begin();
while (it != materialNames.end())
{
sa.push_back(*it);
it++;
}
if (materialNames.size() > 1)
{
sa.push_back(vtkStdString("MasterMaterial"));
}
this->SetStrings(sa);
}
/*=========================================================================
Program: ParaView
Module: vtkSMMaterialDomain.h
Copyright (c) Kitware, Inc.
All rights reserved.
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
/**
* @class vtkSMMaterialDomain
* @brief ...
*
* ...
*/
#ifndef vtkSMMaterialDomain_h
#define vtkSMMaterialDomain_h
#include "vtkPVServerManagerRenderingModule.h" //needed for exports
#include "vtkSMStringListDomain.h"
class VTKPVSERVERMANAGERRENDERING_EXPORT vtkSMMaterialDomain : public vtkSMStringListDomain
{
public:
static vtkSMMaterialDomain* New();
vtkTypeMacro(vtkSMMaterialDomain, vtkSMStringListDomain);
void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
/**
* Overridden to get list of materials from materiallibrary singleton.
*/
virtual void Update(vtkSMProperty*) VTK_OVERRIDE;
protected:
vtkSMMaterialDomain();
~vtkSMMaterialDomain();
virtual int ReadXMLAttributes(vtkSMProperty* prop, vtkPVXMLElement* element) VTK_OVERRIDE;
void CallMeSometime();
friend class vtkSMMaterialObserver;
private:
vtkSMMaterialDomain(const vtkSMMaterialDomain&) VTK_DELETE_FUNCTION;
void operator=(const vtkSMMaterialDomain&) VTK_DELETE_FUNCTION;
};
#endif
......@@ -2641,7 +2641,19 @@
remove_command="RemoveLight"
repeatable="1">
</ProxyProperty>
<StringVectorProperty command="SetMaterialLibrary"
name="OSPRayLibrary"
label="OSPRay Material Library"
number_of_elements="1"
panel_visibility="advanced"
default_values="None">
<Documentation>Load a set of Materials that can be colored with.</Documentation>
<FileListDomain name="files" />
<Hints>
<PropertyWidgetDecorator type="OSPRayHidingDecorator" />
<FileChooser extensions="json" file_description="material library files" />
</Hints>
</StringVectorProperty>
<PropertyGroup label="Orientation Axes">
<Property name="OrientationAxesVisibility"/>
<Property name="OrientationAxesInteractivity"/>
......@@ -2720,6 +2732,7 @@
<Property name="SamplesPerPixel"/>
<Property name="MaxFrames"/>
<Property name="LightScale"/>
<Property name="OSPRayLibrary" />
</PropertyGroup>
</RenderViewProxy>
......@@ -3681,12 +3694,7 @@
<Property name="OSPRayUseScaleArray" />
<Property name="OSPRayScaleArray" />
<Property name="OSPRayScaleFunction" />
<Hints>
<PropertyWidgetDecorator type="GenericDecorator"
mode="visibility"
property="Representation"
value="Surface" />
</Hints>
<Property name="OSPRayMaterial" />
</PropertyGroup>
</ExposedProperties>
......@@ -10250,6 +10258,20 @@
<PropertyWidgetDecorator type="OSPRayHidingDecorator" />
</Hints>
</ProxyProperty>
<StringVectorProperty command="SetMaterial"
name="OSPRayMaterial"
label="OSPRay Material"
number_of_elements="1"
panel_visibility="advanced"
default_values="None">
<Documentation>Set the material to paint this object with.</Documentation>
<MaterialDomain name="string_list">
</MaterialDomain>
<Hints>
<PropertyWidgetDecorator type="OSPRayHidingDecorator" />
</Hints>
</StringVectorProperty>
<!-- End of SurfaceRepresentationBase -->
</RepresentationProxy>
......
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