3#include <Gui/RaGui.hpp>
7#include <QPlainTextEdit>
11#include <nlohmann/json.hpp>
13#include <Core/Containers/DynamicVisitor.hpp>
14#include <Core/Containers/VariableSet.hpp>
15#include <Core/Containers/VariableSetEnumManagement.hpp>
16#include <Gui/ParameterSetEditor/ParameterSetEditor.hpp>
17#include <Gui/Widgets/ControlPanel.hpp>
29 BasicUiBuilder( VariableSet& params,
30 VariableSetEditor* pse,
31 const nlohmann::json& constraints ) :
32 m_params { params }, m_pse { pse }, m_constraints { constraints } {
47 virtual ~BasicUiBuilder() =
default;
49 void operator()(
const std::string& name,
bool& p ) {
50 auto onBoolParameterChanged = [pse = this->m_pse, &p, nm = name](
bool val ) {
52 emit pse->parameterModified( nm );
54 if ( m_constraints.contains( name ) ) {
55 if ( m_constraints[name][
"editable"] ) {
56 const auto& m = m_constraints[name];
57 std::string description = m.contains(
"description" ) ? m[
"description"] :
"";
59 m_pse->
addOption( nm, onBoolParameterChanged, p, description );
62 else if ( m_pse->showUnspecified() ) {
63 m_pse->
addOption( name, onBoolParameterChanged, p );
67 template <typename TParam, std::enable_if_t<std::is_arithmetic<TParam>::value,
bool> =
true>
68 void operator()(
const std::string& name, TParam& p ) {
69 using namespace Ra::Core::VariableSetEnumManagement;
70 if ( getEnumConverter<TParam>( m_params, name ) ) {
80 template <
typename TParam,
82 std::enable_if_t<std::is_arithmetic<TParam>::value,
bool> =
true>
88 auto onColorParameterChanged =
91 emit pse->parameterModified( nm );
93 if ( m_constraints.contains( name ) ) {
94 const auto& m = m_constraints[name];
95 std::string description = m.contains(
"description" ) ? m[
"description"] :
"";
97 m_pse->
addColorInput( nm, onColorParameterChanged, p, m[
"maxItems"] == 4, description );
99 else if ( m_pse->showUnspecified() ) {
104 template <
typename T,
int... dim>
105 void operator()(
const std::string& name, Eigen::Matrix<T, dim...>& p ) {
110 template <
typename T,
111 std::enable_if_t<std::is_assignable_v<VariableSet, typename std::decay<T>::type>,
120 const nlohmann::json& constraints() {
return m_constraints; }
125 const nlohmann::json& m_constraints;
Base class for visitors with configurable per-type callbacks. Visiting will be prepared at running ti...
bool addOperator(F &&f)
Add a visiting operator.
Heterogeneous container storing "Variables", that maps a name (std::string) to a value (of any type T...
Management of shader parameters with automatic binding of a named parameter to the corresponding glsl...
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 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)
hepler function to manage enum as underlying types in VariableSet