diff --git a/src/Mara/Gui/RendererControl.cpp b/src/Mara/Gui/RendererControl.cpp index 37b2778713530514693070134d72eeffc3083716..8e1c054d6ec5e9a77f1ab76c64a070ade862dce2 100644 --- a/src/Mara/Gui/RendererControl.cpp +++ b/src/Mara/Gui/RendererControl.cpp @@ -8,25 +8,12 @@ namespace Mara { RendererControl::RendererControl( QWidget* /*parent*/ ) { setupUi( this ); - auto textureSelector = new QFrame( confPanel ); - textureSelector->setObjectName( QString::fromUtf8( "textureSelector" ) ); - textureSelector->setFrameShape( QFrame::NoFrame ); - - auto textureSelectorLayout = new QHBoxLayout( textureSelector ); - textureSelectorLayout->setObjectName( QString::fromUtf8( "textureSelectorLayout" ) ); - auto selectorLabel = new QLabel( "View", textureSelector ); - selectorLabel->setObjectName( QString::fromUtf8( "selectorLabel" ) ); - selectorLabel->setMinimumSize( QSize( 30, 26 ) ); - selectorLabel->setMaximumSize( QSize( 100, 26 ) ); - textureSelectorLayout->addWidget( selectorLabel ); - m_textureList = new QComboBox( textureSelector ); - m_textureList->setObjectName( QString::fromUtf8( "textureList" ) ); - m_textureList->setMinimumSize( QSize( 459, 0 ) ); + auto textureSelectorLayout = new QHBoxLayout( this ); + textureSelectorLayout->addWidget( new QLabel( "Image to display" ) ); + m_textureList = new QComboBox(); textureSelectorLayout->addWidget( m_textureList ); - panelLayout->addWidget( textureSelector ); - - auto vertFiller = new QSpacerItem( 20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding ); - panelLayout->addSpacerItem( vertFiller ); + panelLayout->addLayout(textureSelectorLayout); + panelLayout->addStretch(); connect( rendererList, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), diff --git a/src/libRender/RadiumNBR/Gui/FullFeaturedRendererGui.cpp b/src/libRender/RadiumNBR/Gui/FullFeaturedRendererGui.cpp index 900728206dff8ca663b9f8b7a08cbe9473998705..49fd5b04014777c0b188afb5903df41762c90018 100644 --- a/src/libRender/RadiumNBR/Gui/FullFeaturedRendererGui.cpp +++ b/src/libRender/RadiumNBR/Gui/FullFeaturedRendererGui.cpp @@ -8,6 +8,24 @@ RadiumNBR::Gui::RendererPanel* buildRadiumNBRGui( FullFeatureRenderer* renderer, const std::function<void()>& appUpdateCallback ) { auto controlPanel = new RendererPanel( renderer->getRendererName() ); + auto defColor = Ra::Core::Utils::Color::linearRGBTosRGB( renderer->getBackgroundColor() ); + auto clrClbck = [renderer, appUpdateCallback]( const Ra::Core::Utils::Color& clr ) { + // set the background color for all passes that need it + renderer->setBackgroundColor( clr ); + appUpdateCallback(); + }; + controlPanel->addColorInput( "Background Color", clrClbck, defColor ); + + controlPanel->addSeparator(); + + controlPanel->beginLayout(QBoxLayout::LeftToRight); + + controlPanel->addOption( " Wireframe rendering", [renderer, appUpdateCallback]( bool b ) { + renderer->wireframeMode( b ); + appUpdateCallback(); + } ); + + controlPanel->addOption( " Show Debug ", [renderer, appUpdateCallback]( bool b ) { @@ -23,23 +41,19 @@ RadiumNBR::Gui::RendererPanel* buildRadiumNBRGui( FullFeatureRenderer* renderer, appUpdateCallback(); }, false ); + controlPanel->endLayout( true ); - auto defColor = Ra::Core::Utils::Color::linearRGBTosRGB( renderer->getBackgroundColor() ); - auto clrClbck = [renderer, appUpdateCallback]( const Ra::Core::Utils::Color& clr ) { - // set the background color for all passes that need it - renderer->setBackgroundColor( clr ); - appUpdateCallback(); - }; - controlPanel->addColorInput( "Background Color", clrClbck, defColor ); auto envmpClbck = [renderer, appUpdateCallback]( const std::string& files ) { renderer->setEnvMap( files ); appUpdateCallback(); }; + controlPanel->beginLayout(QBoxLayout::LeftToRight); controlPanel->addFileInput( "Environment map", envmpClbck, "../", "Images (*.png *.jpg *.pfm *.exr *hdr)" ); + controlPanel->beginLayout(QBoxLayout::TopToBottom ); controlPanel->addOption( " Show envMap ", [renderer, appUpdateCallback]( bool b ) { @@ -55,12 +69,11 @@ RadiumNBR::Gui::RendererPanel* buildRadiumNBRGui( FullFeatureRenderer* renderer, appUpdateCallback(); }, 100 ); + controlPanel->endLayout(); + controlPanel->endLayout(true); - controlPanel->addOption( " Wireframe rendering", [renderer, appUpdateCallback]( bool b ) { - renderer->wireframeMode( b ); - appUpdateCallback(); - } ); - + // AO control + controlPanel->beginLayout(QBoxLayout::LeftToRight); controlPanel->addScalarInput( "AO radius", [renderer, appUpdateCallback]( double r ) { @@ -82,6 +95,7 @@ RadiumNBR::Gui::RendererPanel* buildRadiumNBRGui( FullFeatureRenderer* renderer, 0, 4096, 0 ); + controlPanel->endLayout(); return controlPanel; } diff --git a/src/libRender/RadiumNBR/Gui/RendererPanel.cpp b/src/libRender/RadiumNBR/Gui/RendererPanel.cpp index 9f7d40e247230a3946c6668de3b356ff0fc13e1c..4aa1a7f734f50cf4a01408f4466a15ae27cd9223 100644 --- a/src/libRender/RadiumNBR/Gui/RendererPanel.cpp +++ b/src/libRender/RadiumNBR/Gui/RendererPanel.cpp @@ -15,12 +15,16 @@ namespace Gui { RendererPanel::RendererPanel( const std::string& name, QWidget* parent ) : QFrame( parent ) { setObjectName( name.c_str() ); + + m_currentLayout = new QVBoxLayout( this ); + setLayout( m_currentLayout ); auto panelName = new QLabel( this ); panelName->setFrameStyle( QFrame::HLine ); - m_contentLayout = new QVBoxLayout( this ); - m_contentLayout->addWidget( panelName ); - setLayout( m_contentLayout ); + m_currentLayout->addWidget( panelName ); + //addSeparator(); setVisible( false ); + m_layouts.push( m_currentLayout ); + } // Method to populate the panel @@ -28,9 +32,10 @@ void RendererPanel::addOption( const std::string& name, std::function<void( bool )> callback, bool set ) { auto button = new QRadioButton( name.c_str(), this ); + button->setLayoutDirection( Qt::RightToLeft ); button->setAutoExclusive( false ); button->setChecked( set ); - m_contentLayout->addWidget( button ); + m_currentLayout->addWidget( button ); connect( button, &QRadioButton::toggled, std::move( callback ) ); } @@ -54,7 +59,7 @@ void RendererPanel::addScalarInput( const std::string& name, inputLayout->addWidget( inputField ); connect( inputField, QOverload<double>::of( &QDoubleSpinBox::valueChanged ), std::move( callback ) ); - m_contentLayout->addLayout( inputLayout ); + m_currentLayout->addLayout( inputLayout ); } void RendererPanel::addSliderInput( const std::string& name, @@ -69,7 +74,7 @@ void RendererPanel::addSliderInput( const std::string& name, inputLayout->addWidget( inputLabel ); inputLayout->addWidget( inputField ); connect( inputField, &QSlider::valueChanged, std::move( callback ) ); - m_contentLayout->addLayout( inputLayout ); + m_currentLayout->addLayout( inputLayout ); } void RendererPanel::addColorInput( const std::string& name, @@ -98,7 +103,7 @@ void RendererPanel::addColorInput( return c; }; connect( button, &QPushButton::clicked, clrDlg ); - m_contentLayout->addWidget( button ); + m_currentLayout->addWidget( button ); } void RendererPanel::addFileInput( const std::string& name, @@ -124,7 +129,40 @@ void RendererPanel::addFileInput( const std::string& name, { callback( "" ); } }; connect( button, &QPushButton::clicked, fileDialog ); - m_contentLayout->addWidget( button ); + m_currentLayout->addWidget( button ); +} + +void RendererPanel::beginLayout(QBoxLayout::Direction dir) { + m_layouts.push(m_currentLayout); + m_currentLayout = new QBoxLayout( dir ); } + +void RendererPanel::endLayout( bool separator ) { + m_layouts.top()->addLayout( m_currentLayout ); + m_currentLayout = m_layouts.top(); + if ( separator ) { + addSeparator(); + } + m_layouts.pop(); +} + +void RendererPanel::addSeparator() { + QFrame* line = new QFrame(); + switch ( m_currentLayout->direction() ) { + case QBoxLayout::LeftToRight: + case QBoxLayout::RightToLeft: + line->setFrameShape(QFrame::VLine); + break; + case QBoxLayout::TopToBottom: + case QBoxLayout::BottomToTop: + line->setFrameShape(QFrame::HLine); + break; + default: + line->setFrameShape(QFrame::HLine); + } + line->setFrameShadow(QFrame::Sunken); + m_currentLayout->addWidget( line ); +} + } // namespace Gui } // namespace RadiumNBR diff --git a/src/libRender/RadiumNBR/Gui/RendererPanel.hpp b/src/libRender/RadiumNBR/Gui/RendererPanel.hpp index 0e7c1df3908e9521237a5b124fb621703537eea5..62429724839ece517b7178e443a86c677bf2111b 100644 --- a/src/libRender/RadiumNBR/Gui/RendererPanel.hpp +++ b/src/libRender/RadiumNBR/Gui/RendererPanel.hpp @@ -6,6 +6,7 @@ #include <functional> #include <string> +#include <stack> #include <Core/Utils/Color.hpp> @@ -37,6 +38,29 @@ class NodeBasedRenderer_LIBRARY_API RendererPanel : public QFrame /**Methods to populate the panel with dedicated ui elements. */ /** @{ */ + + /** + * Open a box layout to organise the widgets + * @param dir the direction of the layout + * direction could be : + * - QBoxLayout::LeftToRight + * - QBoxLayout::RightToLeft + * - QBoxLayout::TopToBottom + * - QBoxLayout::BottomToTop + */ + void beginLayout(QBoxLayout::Direction dir = QBoxLayout::LeftToRight); + + /** + * Close the current layout. + * When no layout is opened, widgets are arranged vertically into the panel + */ + void endLayout( bool separator = false ); + + /** + * Add a separator + */ + void addSeparator(); + /** Add an option to the panel * An option is an on/off checkbox to activate a state of the renderer. * @param name The name of the option @@ -104,6 +128,12 @@ class NodeBasedRenderer_LIBRARY_API RendererPanel : public QFrame private: /// The layout to organise the ui elements QVBoxLayout* m_contentLayout; + + /// The current layout where UI element will be added + QBoxLayout *m_currentLayout; + + /// The stack of layouts + std::stack<QBoxLayout *> m_layouts; }; } // namespace Gui } // namespace RadiumNBR diff --git a/src/libRender/RadiumNBR/RenderPass.hpp b/src/libRender/RadiumNBR/RenderPass.hpp index b83d286cb133d4acf6f310fd759a5c44c7638b0a..ec83ad1f158a80a9b11cba71a00431c39143d39a 100644 --- a/src/libRender/RadiumNBR/RenderPass.hpp +++ b/src/libRender/RadiumNBR/RenderPass.hpp @@ -124,7 +124,7 @@ class NodeBasedRenderer_LIBRARY_API RenderPass inline void deactivate() { m_active = false; } // is the pass active ? - [[nodiscard]] inline bool isActive() { return m_active; } + [[nodiscard]] inline bool isActive() const { return m_active; } [[nodiscard]] inline int index() const { return int( m_idx ); }