Commit 72d21070 authored by Charles Gueunet's avatar Charles Gueunet 🎸 Committed by Kitware Robot
Browse files

Merge topic 'ShaderBall'

c94d6b97 Add a release note
dd248f33 Change SB background color
06bd6d1b Move shader ball in it own module
bb56b812 reviewer's remarks
3848de52

 Add a shader ball to the Material Editor

Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Acked-by: Mathieu Westphal's avatarMathieu Westphal <mathieu.westphal@kitware.com>
Acked-by: Lucas Givord's avatarLucas Givord <lucas.givord@kitware.com>
Merge-request: !5247
parents 6011921f c94d6b97
......@@ -364,6 +364,11 @@ paraview_require_module(
MODULES VTK::RenderingRayTracing
EXCLUSIVE)
paraview_require_module(
CONDITION PARAVIEW_ENABLE_RAYTRACING AND VTK_ENABLE_OSPRAY
MODULES ParaView::VTKExtensionsShaderBall
EXCLUSIVE)
paraview_require_module(
CONDITION PARAVIEW_ENABLE_NVPIPE
MODULES ParaView::nvpipe
......
......@@ -135,7 +135,8 @@ ParaViewMainWindow::ParaViewMainWindow()
#endif
#if PARAVIEW_USE_MATERIALEDITOR
pqMaterialEditor* materialEditor = new pqMaterialEditor(this);
pqMaterialEditor* materialEditor =
new pqMaterialEditor(this, this->Internals->materialEditorDock);
materialEditor->setObjectName("materialEditorPanel");
this->Internals->materialEditorDock->setWidget(materialEditor);
#endif
......
7d60b93a8b505431bfc69e73cb44ba2cf760ef6ea75585d96ba8543a009d2c15e2ffb115f37ae3a6f989d07513e3fd4ba3aaff1feca42a55a74534209e632f23
7933104a172f41544ecf1cdacce87039adac1a8191109c0df7c6864f85c7cf900dd8408d9a9dab1712186015939613f8cd886e817bcaa3c1e1ef1690c247c2a8
03b042bd85b082695a9b4cc74a75ebfdf1d8166915ce43d369077c79c87bbd5ac3555343dc41b5ec319eb3a44a551aa705fbfa16d79b561ebc5c7409ad5adcdf
......@@ -424,6 +424,9 @@ ExternalData_Expand_Arguments(ParaViewData _
"DATA{${CMAKE_CURRENT_SOURCE_DIR}/../Data/Baseline/MaterialEditorSaveMaterials1.png}"
"DATA{${CMAKE_CURRENT_SOURCE_DIR}/../Data/Baseline/MaterialEditorSaveMaterials2.png}"
"DATA{${CMAKE_CURRENT_SOURCE_DIR}/../Data/Baseline/MaterialEditorSaveMaterials3.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}"
......@@ -1652,6 +1655,7 @@ if (paraview_use_materialeditor)
MaterialEditorCreateMaterials.xml
MaterialEditorLoadMaterials.xml
MaterialEditorSaveMaterials.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>
## Add Shader ball to the Material Editor
The material editor now has a Shader ball to preview the current material. This allows
to edit quickly a lot of material without having to attach them on the scene, or even to
enable Ray tracing on the main render window.
The number of sample used for the shader ball can be customized to get the best
performance / quality ratio.
......@@ -20,6 +20,67 @@
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<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>
</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>50</number>
</property>
<property name="value">
<number>2</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QVTKOpenGLNativeWidget" name="RenderWidget">
<property name="sizePolicy">
<sizepolicy vsizetype="Expanding" hsizetype="Expanding">
<horstretch>0.9</horstretch>
<verstretch>0.9</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>300</width>
<height>300</height>
</size>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="MaterialListLayout">
<property name="spacing">
......@@ -265,6 +326,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"/>
......
......@@ -52,6 +52,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <QPushButton>
#include <QVector2D>
#include <QVector3D>
#include <QVector4D>
//-----------------------------------------------------------------------------
pqMaterialAttributesDelegate::pqMaterialAttributesDelegate(QObject* parent)
......@@ -250,6 +251,14 @@ 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:
{
auto editor = new QPushButton(parent);
......
......@@ -39,15 +39,16 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "vtkJPEGReader.h"
#include "vtkMath.h"
#include "vtkOSPRayMaterialLibrary.h"
#include "vtkOSPRayRendererNode.h"
#include "vtkPNGReader.h"
#include "vtkPNMReader.h"
#include "vtkPVMaterialLibrary.h"
#include "vtkPVRenderView.h"
#include "vtkProcessModule.h"
#include "vtkSMMaterialLibraryProxy.h"
#include "vtkSMPropertyHelper.h"
#include "vtkSMProxyManager.h"
#include "vtkSMSessionProxyManager.h"
#include "vtkShaderBallScene.h"
#include "vtkTexture.h"
#include "pqActiveObjects.h"
......@@ -62,6 +63,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "pqView.h"
#include <QAbstractTableModel>
#include <QDockWidget>
#include <QMetaProperty>
#include <QSet>
#include <QStandardItemModel>
......@@ -454,11 +456,19 @@ public:
pqMaterialProxyModel AttributesModel;
vtkOSPRayMaterialLibrary* MaterialLibrary = nullptr;
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);
......@@ -467,10 +477,23 @@ public:
}
~pqInternals() = default;
vtkRenderer* getRenderer() const noexcept { return this->ShaderBall->GetRenderer(); }
void setMaterialName(const char* matName) { this->ShaderBall->SetMaterialName(matName); }
void resetShaderBall()
{
this->ShaderBall->ResetOSPrayPass();
this->ShaderBall->Render();
}
public Q_SLOTS:
void Render() { this->ShaderBall->Render(); }
};
//-----------------------------------------------------------------------------
pqMaterialEditor::pqMaterialEditor(QWidget* parentObject)
pqMaterialEditor::pqMaterialEditor(QWidget* parentObject, QDockWidget* vtkNotUsed(dockWidget))
: Superclass(parentObject)
, Internals(new pqMaterialEditor::pqInternals(this))
{
......@@ -500,6 +523,22 @@ 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);
this->Internals->ShaderBall->Render();
});
QObject::connect(
this->Internals->Ui.ShaderBallNumberOfSamples, &QSpinBox::editingFinished, [this]() {
this->Internals->ShaderBall->SetNumberOfSamples(
this->Internals->Ui.ShaderBallNumberOfSamples->value());
this->Internals->ShaderBall->Render();
});
QObject::connect(
&pqActiveObjects::instance(), &pqActiveObjects::serverChanged, [this](pqServer* server) {
this->Internals->AttributesModel.reset();
......@@ -574,6 +613,10 @@ void pqMaterialEditor::addMaterial()
dialog->setMaterialLibrary(ml);
dialog->setAttribute(Qt::WA_DeleteOnClose);
dialog->show();
vtkOSPRayRendererNode::SetMaterialLibrary(
this->Internals->MaterialLibrary, this->Internals->getRenderer());
QObject::connect(dialog, &pqNewMaterialDialog::accepted, [=]() {
const std::string matName = dialog->name().toStdString();
ml->AddMaterial(matName, dialog->type().toUtf8().data());
......@@ -594,6 +637,10 @@ void pqMaterialEditor::removeMaterial()
{
this->Internals->AttributesModel.reset();
const auto& removedMaterial = this->currentMaterialName();
if (removedMaterial.isEmpty())
{
return;
}
ml->RemoveMaterial(removedMaterial.toStdString());
// Needed so representations that used this material stop using it
......@@ -623,6 +670,7 @@ void pqMaterialEditor::removeMaterial()
// Needed to update vtkSMMaterialDomain instances
ml->Fire();
this->updateCurrentMaterial(this->currentMaterialName().toStdString());
this->Internals->ShaderBall->Modified();
}
}
......@@ -742,6 +790,9 @@ void pqMaterialEditor::addProperty()
std::string matName = this->currentMaterialName().toStdString();
::AddDefaultValue(ml, matName, params[0]);
this->Internals->AttributesModel.setMaterial(ml, matName);
this->updateCurrentMaterial(matName);
this->Internals->ShaderBall->Modified();
}
}
......@@ -772,6 +823,7 @@ void pqMaterialEditor::removeProperty()
ml->RemoveShaderVariable(matName, var.toStdString());
}
this->updateCurrentMaterial(matName);
this->Internals->ShaderBall->Modified();
}
}
}
......@@ -788,14 +840,15 @@ void pqMaterialEditor::removeAllProperties()
ml->RemoveAllTextures(matName);
this->updateCurrentMaterial(matName);
this->Internals->ShaderBall->Modified();
}
}
//-----------------------------------------------------------------------------
void pqMaterialEditor::propertyChanged(const QModelIndex& topLeft, const QModelIndex& botRight)
void pqMaterialEditor::propertyChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight)
{
Q_UNUSED(topLeft);
Q_UNUSED(botRight);
Q_UNUSED(bottomRight);
// update material and render
QString matName = this->currentMaterialName();
......@@ -862,7 +915,11 @@ void pqMaterialEditor::updateMaterialList()
void pqMaterialEditor::updateCurrentMaterialWithIndex(int index)
{
const QString& label = this->Internals->Ui.SelectMaterial->itemText(index);
this->updateCurrentMaterial(label.toStdString());
if (!label.isEmpty())
{
this->updateCurrentMaterial(label.toStdString());
this->Internals->setMaterialName(label.toStdString().c_str());
}
}
//-----------------------------------------------------------------------------
......
......@@ -40,6 +40,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
class vtkOSPRayMaterialLibrary;
class vtkSMProxy;
class QDockWidget;
/**
* @brief pqMaterialEditor is a widget that can be used to edit the OSPRay materials.
......@@ -56,7 +57,7 @@ class PQAPPLICATIONCOMPONENTS_EXPORT pqMaterialEditor : public QWidget
typedef QWidget Superclass;
public:
pqMaterialEditor(QWidget* parent = nullptr);
pqMaterialEditor(QWidget* parent = nullptr, QDockWidget* dockWidget = nullptr);
~pqMaterialEditor() override;
/**
......
......@@ -24,6 +24,7 @@ PRIVATE_DEPENDS
VTK::IOCore
OPTIONAL_DEPENDS
ParaView::nvpipe
ParaView::VTKExtensionsShaderBall
VTK::PythonInterpreter
VTK::RenderingRayTracing
......
......@@ -9,7 +9,7 @@ mark_as_advanced(smooth_flash)
vtk_add_test_cxx(vtkPVVTKExtensionsRenderingCxxTests tests
NO_VALID NO_OUTPUT
# This was basically ignored in the previous version.
# This was basically ignored in the previous version.
# https://gitlab.kitware.com/paraview/paraview/-/issues/20691
# TestResampledAMRImageSourceWithPointData.cxx
TestImageCompressors.cxx
......
#==========================================================================
#
# 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.
#
#==========================================================================
# HDRi created by Andreas Mischok, shared under CC-0, from: https://polyhaven.com/a/spiaggia_di_mondello
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::VTKExtensionsShaderBall
NOWRAP_CLASSES vtkShaderBallScene
CLASSES ${textures}
SOURCES "${skybox_source}" "${shaderBallTexture_source}"
PRIVATE_HEADERS "${skybox_header}" "${shaderBallTexture_header}")
if (NOT paraview_use_materialeditor)
message(FATAL_ERROR "ShadeBall required the MaterialEditor")
endif()
NAME
ParaView::VTKExtensionsShaderBall
LIBRARY_NAME
vtkExtensionsShaderBall
KIT
ParaView::CoreKit
GROUPS
Rendering
DEPENDS
VTK::CommonCore
VTK::CommonColor
PRIVATE_DEPENDS
VTK::FiltersSources
VTK::IOImage
VTK::RenderingCore
VTK::RenderingOpenGL2
VTK::RenderingRayTracing
VTK::IOXML
/*=========================================================================
Program: ParaView
Module: vtkShaderBallScene.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.
=========================================================================*/
#include "vtkShaderBallScene.h"
#include "vtkActor.h"
#include "vtkCamera.h"
#include "vtkFloatArray.h"
#include "vtkGenericOpenGLRenderWindow.h"
#include "vtkImageData.h"
#include "vtkJPEGReader.h"
#include "vtkNamedColors.h"
#include "vtkOSPRayPass.h"
#include "vtkOSPRayRendererNode.h"
#include "vtkObjectFactory.h"
#include "vtkOpenGLSkybox.h"
#include "vtkPNGReader.h"
#include "vtkPlaneSource.h"
#include "vtkPointData.h"
#include "vtkPolyDataMapper.h"
#include "vtkProperty.h"
#include "vtkRenderer.h"
#include "vtkSphereSource.h"
#include "vtkTexture.h"
#include "vtkXMLImageDataWriter.h"
#include "ShaderBallSkybox.h" // Expose the jpg buffer of the skybox as 'ShaderBallSkybox'
#include "ShaderBallTexture.h" // Expose the png buffer of the plane texture as 'ShaderBallTexture'
namespace details
{
void AddCurvedPlane(vtkRenderer* renderer)
{
vtkNew<vtkPlaneSource> plane;
const double size = 3.5;
const double yPos = -0.5;
plane->SetOrigin(-size, yPos, size);
plane->SetPoint1(size, yPos, size);
plane->SetPoint2(-size, yPos, -1.8 * size);
plane->SetNormal(0., 1., 0.);
plane->SetResolution(2, 130);
plane->Update();