Skip to content
Snippets Groups Projects
Commit 218eea89 authored by Mathias Paulin's avatar Mathias Paulin :speech_balloon:
Browse files

improve renderedGui

parent 78a6f0db
Branches develop
No related tags found
No related merge requests found
...@@ -8,25 +8,12 @@ namespace Mara { ...@@ -8,25 +8,12 @@ namespace Mara {
RendererControl::RendererControl( QWidget* /*parent*/ ) { RendererControl::RendererControl( QWidget* /*parent*/ ) {
setupUi( this ); setupUi( this );
auto textureSelector = new QFrame( confPanel ); auto textureSelectorLayout = new QHBoxLayout( this );
textureSelector->setObjectName( QString::fromUtf8( "textureSelector" ) ); textureSelectorLayout->addWidget( new QLabel( "Image to display" ) );
textureSelector->setFrameShape( QFrame::NoFrame ); m_textureList = new QComboBox();
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 ) );
textureSelectorLayout->addWidget( m_textureList ); textureSelectorLayout->addWidget( m_textureList );
panelLayout->addWidget( textureSelector ); panelLayout->addLayout(textureSelectorLayout);
panelLayout->addStretch();
auto vertFiller = new QSpacerItem( 20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding );
panelLayout->addSpacerItem( vertFiller );
connect( rendererList, connect( rendererList,
static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ),
......
...@@ -8,6 +8,24 @@ RadiumNBR::Gui::RendererPanel* buildRadiumNBRGui( FullFeatureRenderer* renderer, ...@@ -8,6 +8,24 @@ RadiumNBR::Gui::RendererPanel* buildRadiumNBRGui( FullFeatureRenderer* renderer,
const std::function<void()>& appUpdateCallback ) { const std::function<void()>& appUpdateCallback ) {
auto controlPanel = new RendererPanel( renderer->getRendererName() ); 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( controlPanel->addOption(
" Show Debug ", " Show Debug ",
[renderer, appUpdateCallback]( bool b ) { [renderer, appUpdateCallback]( bool b ) {
...@@ -23,23 +41,19 @@ RadiumNBR::Gui::RendererPanel* buildRadiumNBRGui( FullFeatureRenderer* renderer, ...@@ -23,23 +41,19 @@ RadiumNBR::Gui::RendererPanel* buildRadiumNBRGui( FullFeatureRenderer* renderer,
appUpdateCallback(); appUpdateCallback();
}, },
false ); 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 ) { auto envmpClbck = [renderer, appUpdateCallback]( const std::string& files ) {
renderer->setEnvMap( files ); renderer->setEnvMap( files );
appUpdateCallback(); appUpdateCallback();
}; };
controlPanel->beginLayout(QBoxLayout::LeftToRight);
controlPanel->addFileInput( controlPanel->addFileInput(
"Environment map", envmpClbck, "../", "Images (*.png *.jpg *.pfm *.exr *hdr)" ); "Environment map", envmpClbck, "../", "Images (*.png *.jpg *.pfm *.exr *hdr)" );
controlPanel->beginLayout(QBoxLayout::TopToBottom );
controlPanel->addOption( controlPanel->addOption(
" Show envMap ", " Show envMap ",
[renderer, appUpdateCallback]( bool b ) { [renderer, appUpdateCallback]( bool b ) {
...@@ -55,12 +69,11 @@ RadiumNBR::Gui::RendererPanel* buildRadiumNBRGui( FullFeatureRenderer* renderer, ...@@ -55,12 +69,11 @@ RadiumNBR::Gui::RendererPanel* buildRadiumNBRGui( FullFeatureRenderer* renderer,
appUpdateCallback(); appUpdateCallback();
}, },
100 ); 100 );
controlPanel->endLayout();
controlPanel->endLayout(true);
controlPanel->addOption( " Wireframe rendering", [renderer, appUpdateCallback]( bool b ) { // AO control
renderer->wireframeMode( b ); controlPanel->beginLayout(QBoxLayout::LeftToRight);
appUpdateCallback();
} );
controlPanel->addScalarInput( controlPanel->addScalarInput(
"AO radius", "AO radius",
[renderer, appUpdateCallback]( double r ) { [renderer, appUpdateCallback]( double r ) {
...@@ -82,6 +95,7 @@ RadiumNBR::Gui::RendererPanel* buildRadiumNBRGui( FullFeatureRenderer* renderer, ...@@ -82,6 +95,7 @@ RadiumNBR::Gui::RendererPanel* buildRadiumNBRGui( FullFeatureRenderer* renderer,
0, 0,
4096, 4096,
0 ); 0 );
controlPanel->endLayout();
return controlPanel; return controlPanel;
} }
......
...@@ -15,12 +15,16 @@ namespace Gui { ...@@ -15,12 +15,16 @@ namespace Gui {
RendererPanel::RendererPanel( const std::string& name, QWidget* parent ) : QFrame( parent ) { RendererPanel::RendererPanel( const std::string& name, QWidget* parent ) : QFrame( parent ) {
setObjectName( name.c_str() ); setObjectName( name.c_str() );
m_currentLayout = new QVBoxLayout( this );
setLayout( m_currentLayout );
auto panelName = new QLabel( this ); auto panelName = new QLabel( this );
panelName->setFrameStyle( QFrame::HLine ); panelName->setFrameStyle( QFrame::HLine );
m_contentLayout = new QVBoxLayout( this ); m_currentLayout->addWidget( panelName );
m_contentLayout->addWidget( panelName ); //addSeparator();
setLayout( m_contentLayout );
setVisible( false ); setVisible( false );
m_layouts.push( m_currentLayout );
} }
// Method to populate the panel // Method to populate the panel
...@@ -28,9 +32,10 @@ void RendererPanel::addOption( const std::string& name, ...@@ -28,9 +32,10 @@ void RendererPanel::addOption( const std::string& name,
std::function<void( bool )> callback, std::function<void( bool )> callback,
bool set ) { bool set ) {
auto button = new QRadioButton( name.c_str(), this ); auto button = new QRadioButton( name.c_str(), this );
button->setLayoutDirection( Qt::RightToLeft );
button->setAutoExclusive( false ); button->setAutoExclusive( false );
button->setChecked( set ); button->setChecked( set );
m_contentLayout->addWidget( button ); m_currentLayout->addWidget( button );
connect( button, &QRadioButton::toggled, std::move( callback ) ); connect( button, &QRadioButton::toggled, std::move( callback ) );
} }
...@@ -54,7 +59,7 @@ void RendererPanel::addScalarInput( const std::string& name, ...@@ -54,7 +59,7 @@ void RendererPanel::addScalarInput( const std::string& name,
inputLayout->addWidget( inputField ); inputLayout->addWidget( inputField );
connect( connect(
inputField, QOverload<double>::of( &QDoubleSpinBox::valueChanged ), std::move( callback ) ); inputField, QOverload<double>::of( &QDoubleSpinBox::valueChanged ), std::move( callback ) );
m_contentLayout->addLayout( inputLayout ); m_currentLayout->addLayout( inputLayout );
} }
void RendererPanel::addSliderInput( const std::string& name, void RendererPanel::addSliderInput( const std::string& name,
...@@ -69,7 +74,7 @@ void RendererPanel::addSliderInput( const std::string& name, ...@@ -69,7 +74,7 @@ void RendererPanel::addSliderInput( const std::string& name,
inputLayout->addWidget( inputLabel ); inputLayout->addWidget( inputLabel );
inputLayout->addWidget( inputField ); inputLayout->addWidget( inputField );
connect( inputField, &QSlider::valueChanged, std::move( callback ) ); connect( inputField, &QSlider::valueChanged, std::move( callback ) );
m_contentLayout->addLayout( inputLayout ); m_currentLayout->addLayout( inputLayout );
} }
void RendererPanel::addColorInput( void RendererPanel::addColorInput(
const std::string& name, const std::string& name,
...@@ -98,7 +103,7 @@ void RendererPanel::addColorInput( ...@@ -98,7 +103,7 @@ void RendererPanel::addColorInput(
return c; return c;
}; };
connect( button, &QPushButton::clicked, clrDlg ); connect( button, &QPushButton::clicked, clrDlg );
m_contentLayout->addWidget( button ); m_currentLayout->addWidget( button );
} }
void RendererPanel::addFileInput( const std::string& name, void RendererPanel::addFileInput( const std::string& name,
...@@ -124,7 +129,40 @@ void RendererPanel::addFileInput( const std::string& name, ...@@ -124,7 +129,40 @@ void RendererPanel::addFileInput( const std::string& name,
{ callback( "" ); } { callback( "" ); }
}; };
connect( button, &QPushButton::clicked, fileDialog ); 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 Gui
} // namespace RadiumNBR } // namespace RadiumNBR
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <functional> #include <functional>
#include <string> #include <string>
#include <stack>
#include <Core/Utils/Color.hpp> #include <Core/Utils/Color.hpp>
...@@ -37,6 +38,29 @@ class NodeBasedRenderer_LIBRARY_API RendererPanel : public QFrame ...@@ -37,6 +38,29 @@ class NodeBasedRenderer_LIBRARY_API RendererPanel : public QFrame
/**Methods to populate the panel with dedicated ui elements. /**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 /** Add an option to the panel
* An option is an on/off checkbox to activate a state of the renderer. * An option is an on/off checkbox to activate a state of the renderer.
* @param name The name of the option * @param name The name of the option
...@@ -104,6 +128,12 @@ class NodeBasedRenderer_LIBRARY_API RendererPanel : public QFrame ...@@ -104,6 +128,12 @@ class NodeBasedRenderer_LIBRARY_API RendererPanel : public QFrame
private: private:
/// The layout to organise the ui elements /// The layout to organise the ui elements
QVBoxLayout* m_contentLayout; 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 Gui
} // namespace RadiumNBR } // namespace RadiumNBR
...@@ -124,7 +124,7 @@ class NodeBasedRenderer_LIBRARY_API RenderPass ...@@ -124,7 +124,7 @@ class NodeBasedRenderer_LIBRARY_API RenderPass
inline void deactivate() { m_active = false; } inline void deactivate() { m_active = false; }
// is the pass active ? // 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 ); } [[nodiscard]] inline int index() const { return int( m_idx ); }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment