Commit b1198b79 authored by Thomas Caissard's avatar Thomas Caissard Committed by Paul Lafoix
Browse files

Add a shader ball to the Material Editor

parent 318619fa
Pipeline #248934 failed with stages
......@@ -158,9 +158,9 @@ if (PARAVIEW_USE_QTHELP AND NOT PARAVIEW_USE_QTWEBENGINE)
endif()
if (PARAVIEW_ENABLE_RAYTRACING AND VTK_ENABLE_OSPRAY)
set(paraview_use_materialeditor ON)
set(PARAVIEW_USE_MATERIALEDITOR ON)
else ()
set(paraview_use_materialeditor OFF)
set(PARAVIEW_USE_MATERIALEDITOR OFF)
endif ()
#========================================================================
......@@ -348,6 +348,11 @@ paraview_require_module(
MODULES VTK::RenderingRayTracing
EXCLUSIVE)
paraview_require_module(
CONDITION PARAVIEW_ENABLE_RAYTRACING AND VTK_ENABLE_OSPRAY
MODULES ParaView::VTKExtensionsRendering
EXCLUSIVE)
paraview_require_module(
CONDITION PARAVIEW_ENABLE_NVPIPE
MODULES ParaView::nvpipe
......
......@@ -103,7 +103,7 @@ endif ()
target_compile_definitions(paraview
PRIVATE
"PARAVIEW_USE_MATERIALEDITOR=$<BOOL:${paraview_use_materialeditor}>")
"PARAVIEW_USE_MATERIALEDITOR=$<BOOL:${PARAVIEW_USE_MATERIALEDITOR}>")
if (PARAVIEW_INSTALL_DEVELOPMENT_FILES)
export(
......
7d60b93a8b505431bfc69e73cb44ba2cf760ef6ea75585d96ba8543a009d2c15e2ffb115f37ae3a6f989d07513e3fd4ba3aaff1feca42a55a74534209e632f23
7933104a172f41544ecf1cdacce87039adac1a8191109c0df7c6864f85c7cf900dd8408d9a9dab1712186015939613f8cd886e817bcaa3c1e1ef1690c247c2a8
03b042bd85b082695a9b4cc74a75ebfdf1d8166915ce43d369077c79c87bbd5ac3555343dc41b5ec319eb3a44a551aa705fbfa16d79b561ebc5c7409ad5adcdf
......@@ -367,6 +367,9 @@ ExternalData_Expand_Arguments(ParaViewData _
"DATA{${CMAKE_CURRENT_SOURCE_DIR}/../Data/Baseline/MaterialEditorCreateMaterials3.png}"
"DATA{${CMAKE_CURRENT_SOURCE_DIR}/../Data/Baseline/MaterialEditorLoadMaterials1.png}"
"DATA{${CMAKE_CURRENT_SOURCE_DIR}/../Data/Baseline/MaterialEditorLoadMaterials2.png}"
"DATA{${CMAKE_CURRENT_SOURCE_DIR}/../Data/Baseline/MaterialEditorShaderBallScene1.png}"
"DATA{${CMAKE_CURRENT_SOURCE_DIR}/../Data/Baseline/MaterialEditorShaderBallScene2.png}"
"DATA{${CMAKE_CURRENT_SOURCE_DIR}/../Data/Baseline/MaterialEditorShaderBallScene3.png}"
"DATA{${CMAKE_CURRENT_SOURCE_DIR}/../Data/Baseline/MathTextColumn.png}"
"DATA{${CMAKE_CURRENT_SOURCE_DIR}/../Data/Baseline/MergePointBlocks.png}"
"DATA{${CMAKE_CURRENT_SOURCE_DIR}/../Data/Baseline/MergeVectorComponents.png}"
......@@ -1468,10 +1471,11 @@ endif(PARAVIEW_SSH_SERVERS_TESTING)
#------------------------------------------------------------------------------
# Add tests for OSPRay material editor
if (paraview_use_materialeditor)
if (PARAVIEW_USE_MATERIALEDITOR)
list(APPEND TESTS_WITH_INLINE_COMPARES
MaterialEditorCreateMaterials.xml
MaterialEditorLoadMaterials.xml
MaterialEditorShaderBallScene.xml
)
endif ()
......
<?xml version="1.0" ?>
<pqevents>
<!-- Activate the Material Editor -->
<pqevent object="pqClientMainWindow/menubar" command="activate" arguments="menu_View" />
<pqevent object="pqClientMainWindow/menubar/menu_View" command="activate" arguments="Material Editor" />
<!-- Create a new principled material 'mat1'-->
<pqevent object="pqClientMainWindow/materialEditorDock/materialEditorPanel/AddMaterial" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/NewMaterial/MaterialType" command="activated" arguments="principled" />
<pqevent object="pqClientMainWindow/NewMaterial" command="key" arguments="16777248" />
<pqevent object="pqClientMainWindow/NewMaterial/MaterialName" command="key" arguments="16777248" />
<pqevent object="pqClientMainWindow/NewMaterial/MaterialName" command="set_string" arguments="mat1" />
<pqevent object="pqClientMainWindow/NewMaterial/ButtonBox/1QPushButton0" command="activate" arguments="" />
<!-- add a new property -->
<pqevent object="pqClientMainWindow/materialEditorDock/materialEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/AddProperty" command="activate" arguments="" />
<!-- Select baseColor property -->
<pqevent object="pqClientMainWindow/materialEditorDock/materialEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesView" command="setCurrent" arguments="0.0" />
<pqevent object="pqClientMainWindow/materialEditorDock/materialEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesView" command="setSelection" arguments="0.0,0.0" />
<pqevent object="pqClientMainWindow/materialEditorDock/materialEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesView" command="doubleClick" arguments="0.0" />
<pqevent object="pqClientMainWindow/materialEditorDock/materialEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesView" command="edit" arguments="0.0" />
<pqevent object="pqClientMainWindow/materialEditorDock/materialEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesView/qt_scrollarea_viewport/1QComboBox0" command="activated" arguments="baseColor" />
<!-- Set baseColor to 29,255,55 -->
<pqevent object="pqClientMainWindow/materialEditorDock/materialEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesView" command="setCurrent" arguments="0.1" />
<pqevent object="pqClientMainWindow/materialEditorDock/materialEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesView" command="setSelection" arguments="0.1,0.1" />
<pqevent object="pqClientMainWindow/materialEditorDock/materialEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesView" command="doubleClick" arguments="0.1" />
<pqevent object="pqClientMainWindow/materialEditorDock/materialEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesView" command="edit" arguments="0.1" />
<pqevent object="pqClientMainWindow/materialEditorDock/materialEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesView/qt_scrollarea_viewport/1pqColorChooserButton0" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/materialEditorDock/materialEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesView/qt_scrollarea_viewport/1pqColorChooserButton0/1QColorDialog0" command="setChosenColor" arguments="29,255,55" />
<pqevent object="pqClientMainWindow/materialEditorDock/materialEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesView/qt_scrollarea_viewport/1pqColorChooserButton0/1QColorDialog0" command="done" arguments="1" />
<!-- select an other property just to update the modified property -->
<!-- because the properties are modified/updated only when focus goes out.. -->
<pqevent object="pqClientMainWindow/materialEditorDock/materialEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesView" command="setCurrent" arguments="0.0" />
<pqevent object="pqClientMainWindow/materialEditorDock/materialEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesView" command="setSelection" arguments="0.0,0.0" />
<!-- end useless input to update property -->
<!-- Add a new property for roughness -->
<pqevent object="pqClientMainWindow/materialEditorDock/materialEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/AddProperty" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/materialEditorDock/materialEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesView" command="setCurrent" arguments="1.0" />
<pqevent object="pqClientMainWindow/materialEditorDock/materialEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesView" command="setSelection" arguments="1.0,1.0" />
<pqevent object="pqClientMainWindow/materialEditorDock/materialEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesView" command="doubleClick" arguments="1.0" />
<pqevent object="pqClientMainWindow/materialEditorDock/materialEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesView" command="edit" arguments="1.0" />
<pqevent object="pqClientMainWindow/materialEditorDock/materialEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesView/qt_scrollarea_viewport/1QComboBox0" command="activated" arguments="roughness" />
<pqevent object="pqClientMainWindow/materialEditorDock/materialEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesView" command="setCurrent" arguments="1.1" />
<pqevent object="pqClientMainWindow/materialEditorDock/materialEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesView" command="setSelection" arguments="1.1,1.1" />
<pqevent object="pqClientMainWindow/materialEditorDock/materialEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesView" command="doubleClick" arguments="1.1" />
<pqevent object="pqClientMainWindow/materialEditorDock/materialEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesView" command="edit" arguments="1.1" />
<pqevent object="pqClientMainWindow/materialEditorDock/materialEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesView/qt_scrollarea_viewport/1pqDoubleSliderWidget0/Slider" command="set_int" arguments="5" />
<!-- select an other property just to update the modified property -->
<!-- because the properties are modified/updated only when focus goes out.. -->
<pqevent object="pqClientMainWindow/materialEditorDock/materialEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesView" command="setCurrent" arguments="0.0" />
<pqevent object="pqClientMainWindow/materialEditorDock/materialEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesView" command="setSelection" arguments="0.0,0.0" />
<!-- end useless input to update property -->
<!-- Add a new property for metallic -->
<pqevent object="pqClientMainWindow/materialEditorDock/materialEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/AddProperty" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/materialEditorDock/materialEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesView" command="setCurrent" arguments="2.0" />
<pqevent object="pqClientMainWindow/materialEditorDock/materialEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesView" command="setSelection" arguments="2.0,2.0" />
<pqevent object="pqClientMainWindow/materialEditorDock/materialEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesView" command="doubleClick" arguments="2.0" />
<pqevent object="pqClientMainWindow/materialEditorDock/materialEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesView" command="edit" arguments="2.0" />
<pqevent object="pqClientMainWindow/materialEditorDock/materialEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesView/qt_scrollarea_viewport/1QComboBox0" command="activated" arguments="metallic" />
<!-- select an other property just to update the modified property -->
<!-- because the properties are modified/updated only when focus goes out.. -->
<pqevent object="pqClientMainWindow/materialEditorDock/materialEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesView" command="setCurrent" arguments="0.0" />
<pqevent object="pqClientMainWindow/materialEditorDock/materialEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesView" command="setSelection" arguments="0.0,0.0" />
<!-- end useless input to update property -->
<!-- Show the shader ball -->
<pqevent object="pqClientMainWindow/materialEditorDock/materialEditorPanel/ShowShaderBall" command="set_boolean" arguments="true" />
<!-- Change the number of samples to 10 -->
<pqevent object="pqClientMainWindow/materialEditorDock/materialEditorPanel/ShaderBallNumberOfSamples" command="set_int" arguments="10" />
<pqcompareview object="pqClientMainWindow/materialEditorDock/materialEditorPanel/RenderWidget" baseline="$PARAVIEW_DATA_ROOT/Clients/ParaView/Testing/Data/Baseline/MaterialEditorShaderBallScene1.png" width="400" height="400" />
<!-- Remove base color property -->
<pqevent object="pqClientMainWindow/materialEditorDock/materialEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesView" command="setSelection" arguments="0.0,0.0" />
<pqevent object="pqClientMainWindow/materialEditorDock/materialEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/RemoveProperty" command="activate" arguments="" />
<pqcompareview object="pqClientMainWindow/materialEditorDock/materialEditorPanel/RenderWidget" baseline="$PARAVIEW_DATA_ROOT/Clients/ParaView/Testing/Data/Baseline/MaterialEditorShaderBallScene2.png" width="400" height="400" />
<!-- Remove all properties -->
<pqevent object="pqClientMainWindow/materialEditorDock/materialEditorPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/DeleteProperties" command="activate" arguments="" />
<pqcompareview object="pqClientMainWindow/materialEditorDock/materialEditorPanel/RenderWidget" baseline="$PARAVIEW_DATA_ROOT/Clients/ParaView/Testing/Data/Baseline/MaterialEditorShaderBallScene3.png" width="400" height="400" />
<!-- Hide the shader ball -->
<pqevent object="pqClientMainWindow/materialEditorDock/materialEditorPanel/ShowShaderBall" command="set_boolean" arguments="false" />
</pqevents>
......@@ -286,7 +286,7 @@ set(qt_components
Widgets
Svg)
if (paraview_use_materialeditor)
if (PARAVIEW_USE_MATERIALEDITOR)
list(APPEND classes
pqMaterialAttributesDelegate
pqMaterialEditor
......
......@@ -230,6 +230,68 @@
</widget>
</widget>
</item>
<item>
<widget class="QCheckBox" name="ShowShaderBall">
<property name="toolTip">
<string>Show / Hide the Shader Ball.</string>
</property>
<property name="text">
<string>Show Shader Ball</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="NumberOfSamplesLayout">
<item>
<widget class="QLabel" name="TypeLabel1">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Number of samples per pixels</string>
</property>
<property name="textFormat">
<enum>Qt::AutoText</enum>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="ShaderBallNumberOfSamples">
<property name="toolTip">
<string>Set the number of samples for the Shader Ball Scene.</string>
</property>
<property name="minimum" >
<number>1</number>
</property>
<property name="maximum" >
<number>500</number>
</property>
<property name="value">
<number>4</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QVTKOpenGLNativeWidget" name="RenderWidget">
<property name="sizePolicy">
<sizepolicy vsizetype="Expanding" hsizetype="Expanding">
<horstretch>1</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>300</width>
<height>300</height>
</size>
</property>
</widget>
</item>
<item>
<spacer name="VerticalSpacer">
<property name="orientation">
......@@ -251,6 +313,11 @@
<extends>QTableView</extends>
<header>pqExpandableTableView.h</header>
</customwidget>
<customwidget>
<class>QVTKOpenGLNativeWidget</class>
<extends>QOpenGLWidget</extends>
<header>QVTKOpenGLNativeWidget.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../../../Widgets/Resources/QtWidgets.qrc"/>
......
......@@ -50,6 +50,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <QPainter>
#include <QVector2D>
#include <QVector3D>
#include <QVector4D>
//-----------------------------------------------------------------------------
pqMaterialAttributesDelegate::pqMaterialAttributesDelegate(QObject* parent)
......@@ -167,10 +168,10 @@ QWidget* pqMaterialAttributesDelegate::createEditor(
// add current material
paramsList << index.data(Qt::EditRole).toString();
pqMaterialEditor* parent = qobject_cast<pqMaterialEditor*>(this->parent());
if (parent)
pqMaterialEditor* parentEditor = qobject_cast<pqMaterialEditor*>(this->parent());
if (parentEditor)
{
for (auto p : parent->availableParameters())
for (auto p : parentEditor->availableParameters())
{
paramsList << p.c_str();
}
......@@ -250,6 +251,12 @@ QWidget* pqMaterialAttributesDelegate::createEditor(
new pqVectorWidgetImpl<QVector3D, 3>(variant.value<QVector3D>(), parent);
return widget;
}
case vtkOSPRayMaterialLibrary::ParameterType::VEC4:
{
pqVectorWidgetImpl<QVector4D, 4>* widget =
new pqVectorWidgetImpl<QVector4D, 4>(variant.value<QVector4D>(), parent);
return widget;
}
case vtkOSPRayMaterialLibrary::ParameterType::FLOAT_DATA:
return nullptr;
case vtkOSPRayMaterialLibrary::ParameterType::TEXTURE:
......
......@@ -60,7 +60,7 @@ public:
/**
* do nothing, everything is handled in createEditor method
*/
void setEditorData(QWidget* editor, const QModelIndex& index) const override{};
// void setEditorData(QWidget* editor, const QModelIndex& index) const override {};
/**
* Gets data from the editor widget and stores it in the specified model at the item index
......
......@@ -36,6 +36,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "vtkCommand.h"
#include "vtkMath.h"
#include "vtkOSPRayMaterialLibrary.h"
#include "vtkOSPRayRendererNode.h"
#include "vtkPVMaterial.h"
#include "vtkPVMaterialLibrary.h"
#include "vtkPVRenderView.h"
......@@ -44,6 +45,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "vtkSMPropertyHelper.h"
#include "vtkSMProxyManager.h"
#include "vtkSMSessionProxyManager.h"
#include "vtkShaderBallScene.h"
#include "pqActiveObjects.h"
#include "pqApplicationCore.h"
......@@ -114,7 +116,11 @@ public:
/**
* Returns the number of columns (two in our case)
*/
int columnCount(const QModelIndex& parent = QModelIndex()) const override { return 2; }
int columnCount(const QModelIndex& parent = QModelIndex()) const override
{
(void)parent;
return 2;
}
/**
* Returns the material attribute name at row
......@@ -178,6 +184,7 @@ QVariant pqMaterialProxyModel::headerData(int section, Qt::Orientation orientati
//-----------------------------------------------------------------------------
int pqMaterialProxyModel::rowCount(const QModelIndex& parent) const
{
(void)parent;
if (!this->Proxy)
{
return 0;
......@@ -373,11 +380,19 @@ public:
pqMaterialProxyModel AttributesModel;
vtkNew<vtkShaderBallScene> ShaderBall;
pqInternals(pqMaterialEditor* self)
{
this->Ui.setupUi(self);
this->Ui.PropertiesView->setModel(&this->AttributesModel);
this->Ui.RenderWidget->setRenderWindow(this->ShaderBall->GetWindow());
this->Ui.RenderWidget->setEnableHiDPI(true);
this->Ui.RenderWidget->hide();
this->Ui.PropertiesView->horizontalHeader()->setHighlightSections(false);
this->Ui.PropertiesView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
this->Ui.PropertiesView->horizontalHeader()->setStretchLastSection(true);
......@@ -385,6 +400,15 @@ public:
}
~pqInternals() = default;
vtkRenderer* getRenderer() const noexcept { return this->ShaderBall->GetRenderer(); }
void setMaterialName(const char* matName) { this->ShaderBall->SetMaterialName(matName); }
void resetShaderBall() { this->ShaderBall->ResetPass(); }
public slots:
void Render() { this->ShaderBall->Render(); }
};
//-----------------------------------------------------------------------------
......@@ -418,6 +442,21 @@ pqMaterialEditor::pqMaterialEditor(QWidget* parentObject)
QObject::connect(&this->Internals->AttributesModel, &QAbstractTableModel::dataChanged, this,
&pqMaterialEditor::propertyChanged);
// Shader Ball
QObject::connect(this->Internals->Ui.SelectMaterial,
QOverload<int>::of(&QComboBox::currentIndexChanged), [this]() { this->Internals->Render(); });
QObject::connect(&this->Internals->AttributesModel, &pqMaterialProxyModel::dataChanged,
[this]() { this->Internals->ShaderBall->Modified(); });
QObject::connect(this->Internals->Ui.ShowShaderBall, &QCheckBox::stateChanged, [this](int state) {
this->Internals->Ui.RenderWidget->setVisible(state);
this->Internals->ShaderBall->SetVisible(state);
});
QObject::connect(
this->Internals->Ui.ShaderBallNumberOfSamples, &QSpinBox::editingFinished, [this]() {
this->Internals->ShaderBall->SetNumberOfSamples(
this->Internals->Ui.ShaderBallNumberOfSamples->value());
});
QObject::connect(
&pqActiveObjects::instance(), &pqActiveObjects::serverChanged, [this](pqServer* server) {
if (server)
......@@ -440,6 +479,13 @@ pqMaterialEditor::~pqMaterialEditor()
this->Internals = nullptr;
}
//-----------------------------------------------------------------------------
void pqMaterialEditor::resizeEvent(QResizeEvent* event)
{
(void)event;
this->Internals->resetShaderBall();
}
//-----------------------------------------------------------------------------
QString pqMaterialEditor::currentMaterialName()
{
......@@ -503,6 +549,9 @@ void pqMaterialEditor::addMaterial()
dialog->setAttribute(Qt::WA_DeleteOnClose);
dialog->show();
vtkOSPRayRendererNode::SetMaterialLibrary(
this->materialLibrary(), this->Internals->getRenderer());
QObject::connect(dialog, &pqNewMaterialDialog::accepted, [=]() {
pqObjectBuilder* builder = pqApplicationCore::instance()->getObjectBuilder();
pqServer* server = pqActiveObjects::instance().activeServer();
......@@ -564,6 +613,7 @@ void pqMaterialEditor::removeMaterial()
server->proxyManager()->UnRegisterProxy(mp->GetXMLGroup(), mp->GetXMLName(), mp);
this->updateMaterialList();
this->Internals->ShaderBall->Modified();
}
}
}
......@@ -660,7 +710,12 @@ std::vector<std::string> pqMaterialEditor::availableParameters()
//-----------------------------------------------------------------------------
void pqMaterialEditor::loadMaterials()
{
pqLoadMaterialsReaction::loadMaterials();
auto materialLibrary = this->materialLibrary();
if (vtkOSPRayRendererNode::GetMaterialLibrary(this->Internals->getRenderer()) != materialLibrary)
{
vtkOSPRayRendererNode::SetMaterialLibrary(
this->materialLibrary(), this->Internals->getRenderer());
}
}
//-----------------------------------------------------------------------------
......@@ -723,6 +778,7 @@ void pqMaterialEditor::addProperty()
mp->UpdateVTKObjects();
this->updateCurrentMaterial(matName);
this->Internals->ShaderBall->Modified();
}
}
......@@ -746,6 +802,7 @@ void pqMaterialEditor::removeProperties(vtkSMProxy* proxy, const QSet<QString>&
vtkSMPropertyHelper(proxy, "DoubleVariables").SetNumberOfElements(newNbElem);
proxy->UpdateVTKObjects();
this->Internals->ShaderBall->Modified();
}
//-----------------------------------------------------------------------------
......@@ -793,11 +850,12 @@ void pqMaterialEditor::removeAllProperties()
mp->UpdateVTKObjects();
this->updateCurrentMaterial(matName);
this->Internals->ShaderBall->Modified();
}
}
//-----------------------------------------------------------------------------
void pqMaterialEditor::propertyChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight)
void pqMaterialEditor::propertyChanged()
{
// update material and render
QString matName = this->currentMaterialName();
......@@ -885,6 +943,8 @@ void pqMaterialEditor::updateCurrentMaterial(const QString& label)
{
proxy = this->materialProxy(label);
materialTypeLabel += vtkSMPropertyHelper(proxy, "Type").GetAsString();
const char* materialName = vtkSMPropertyHelper(proxy, "Name").GetAsString();
this->Internals->setMaterialName(materialName);
}
else
{
......@@ -895,5 +955,5 @@ void pqMaterialEditor::updateCurrentMaterial(const QString& label)
this->Internals->AttributesModel.setProxy(proxy);
this->Internals->AttributesModel.reset();
this->propertyChanged(QModelIndex(), QModelIndex());
this->propertyChanged();
}
......@@ -112,12 +112,14 @@ protected slots:
void removeProperty();
void removeAllProperties();
void propertyChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight);
void propertyChanged();
protected:
void removeProperties(vtkSMProxy* proxy, const QSet<QString>& variables);
void addNewProperty(vtkSMProxy* proxy, const QString& prop);
void resizeEvent(QResizeEvent* event) override;
/**
* Return a unique material name given a desired name.
*
......
......@@ -22,6 +22,7 @@ PRIVATE_DEPENDS
VTK::IOCore
OPTIONAL_DEPENDS
ParaView::nvpipe
ParaView::VTKExtensionsRendering
VTK::PythonInterpreter
VTK::RenderingRayTracing
......
#==========================================================================
#
# Program: ParaView
#
# Copyright (c) 2005-2008 Sandia Corporation, Kitware Inc.
# All rights reserved.
#
# ParaView is a free software; you can redistribute it and/or modify it
# under the terms of the ParaView license version 1.2.
#
# See License_v1.2.txt for the full ParaView license.
# A copy of this license can be obtained by contacting
# Kitware Inc.
# 28 Corporate Drive
# Clifton Park, NY 12065
# USA
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
#==========================================================================
vtk_encode_string(
INPUT "ShaderBallSkybox.jpg"
HEADER_OUTPUT skybox_header
SOURCE_OUTPUT skybox_source
BINARY)
vtk_encode_string(
INPUT "ShaderBallTexture.png"
HEADER_OUTPUT shaderBallTexture_header
SOURCE_OUTPUT shaderBallTexture_source
BINARY)
vtk_module_add_module(ParaView::VTKExtensionsRendering
NOWRAP_CLASSES vtkShaderBallScene
CLASSES ${textures}
SOURCES "${skybox_source}" "${shaderBallTexture_source}"
PRIVATE_HEADERS "${skybox_header}" "${shaderBallTexture_header}")
NAME
ParaView::VTKExtensionsRendering
LIBRARY_NAME
vtkExtensionsRendering
KIT
ParaView::CoreKit
GROUPS
Rendering
DEPENDS
VTK::CommonCore
PRIVATE_DEPENDS
VTK::FiltersSources
VTK::IOImage
VTK::RenderingCore
VTK::RenderingOpenGL2
VTK::RenderingRayTracing
VTK::IOXML
/*=========================================================================
Program: ParaView
Module: vtkShaderBallScene.cxx
Copyright (c) 2005,2006 Sandia Corporation, Kitware Inc.
All rights reserved.
ParaView is a free software; you can redistribute it and/or modify it
under the terms of the ParaView license version 1.2.
See License_v1.2.txt for the full ParaView license.
A copy of this license can be obtained by contacting
Kitware Inc.
28 Corporate Drive
Clifton Park, NY 12065
USA
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR