1#include <Gui/ParameterSetEditor/ParameterSetEditor.hpp>
3#include <Engine/Data/Material.hpp>
4#include <Gui/Widgets/ControlPanel.hpp>
13using json = nlohmann::json;
16using namespace Engine;
27 m_pse { pse }, m_constraints { constraints } {}
30 auto onBoolParameterChanged = [pse = this->m_pse, &p, nm = name](
bool val ) {
34 if ( m_constraints.contains( name ) ) {
35 if ( m_constraints[name][
"editable"] ) {
36 const auto& m = m_constraints[name];
37 std::string description = m.contains(
"description" ) ? m[
"description"] :
"";
39 m_pse->
addOption( nm, onBoolParameterChanged, p, description );
42 else if ( m_pse->showUnspecified() ) {
43 m_pse->
addOption( name, onBoolParameterChanged, p );
47 template <typename TParam, std::enable_if_t<std::is_arithmetic<TParam>::value,
bool> =
true>
49 using namespace Ra::Core::VariableSetEnumManagement;
50 if ( getEnumConverter<TParam>( params, name ) ) {
59 template <
typename TParam,
61 std::enable_if_t<std::is_arithmetic<TParam>::value,
bool> =
true>
70 auto onColorParameterChanged =
72 params.setVariable( nm, val );
75 if ( m_constraints.contains( name ) ) {
76 const auto& m = m_constraints[name];
77 std::string description = m.contains(
"description" ) ? m[
"description"] :
"";
79 m_pse->
addColorInput( nm, onColorParameterChanged, p, m[
"maxItems"] == 4, description );
81 else if ( m_pse->showUnspecified() ) {
86 template <
template <
typename,
int...>
typename M,
typename T,
int... dim>
106 const json& m_constraints;
110VariableSetEditor::VariableSetEditor(
const std::string& name, QWidget* parent ) :
111 ControlPanel( name, !name.empty(), parent ) {}
116 params.
visit( uiBuilder, params );
Heterogeneous container storing "Variables", that maps a name (std::string) to a value (of any type T...
void visit(F &&visitor) const
Visit the container using a user defined visitor.
Management of shader parameters with automatic binding of a named parameter to the corresponding glsl...
Core::Utils::TypeList< bool, Core::Utils::Color, int, uint, Scalar, TextureInfo, std::vector< int >, std::vector< uint >, std::vector< Scalar >, Core::Vector2, Core::Vector3, Core::Vector4, Core::Matrix2, Core::Matrix3, Core::Matrix4, RenderParameters > BindableTypes
List of bindable types, to be used with static visitors.
Simple Widget for RenderParameter editing The editor will expose a control panel containing all of th...
void addNumberWidget(const std::string &name, T &initial, Core::VariableSet ¶ms, const nlohmann::json &metadata)
void setupUi(Core::VariableSet ¶ms, const nlohmann::json &constraints)
Setup UI according to params and constraints.
void addVectorWidget(const std::string &key, std::vector< T > &initial, Core::VariableSet ¶ms, const nlohmann::json &metadata)
void addEnumWidget(const std::string &name, T &initial, Core::VariableSet ¶ms, const nlohmann::json ¶mMetadata)
Add a combobox allowing to chose the value of an enumerator.
void addMatrixWidget(const std::string &key, T &initial, Core::VariableSet ¶ms, const nlohmann::json &metadata)
void parameterModified(const std::string &name)
hepler function to manage enum as underlying types in VariableSet