Skip to content

Commit

Permalink
[example][dataflow] modify rendering demo.
Browse files Browse the repository at this point in the history
  • Loading branch information
MathiasPaulin committed Nov 4, 2022
1 parent 31fa918 commit 0c6ebf3
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions examples/DataflowExamples/GraphRendering/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include <Gui/RadiumWindow/SimpleWindow.hpp>
#include <Gui/Viewer/Viewer.hpp>

#include <Dataflow/QtGui/GraphEditor/GraphEditorWindow.hpp>

// Qt Widgets
#include <QtWidgets>

Expand Down Expand Up @@ -83,13 +85,48 @@ class DemoWindowFactory : public BaseApplication::WindowFactory
int renderNum = 0;

for ( const auto& rndr : renderers ) {
std::cout << "adding renderer : " << rndr->getRendererName() << "\n";

window->addRenderer( rndr->getRendererName(), rndr );
auto rndAct = new QAction( rndr->getRendererName().c_str(), window );
renderMenu->addAction( rndAct );
QAction::connect( rndAct, &QAction::triggered, [renderNum, window]() {
window->getViewer()->changeRenderer( renderNum );
window->getViewer()->needUpdate();
} );

// nodeToolBar* ff;
// build a toolbar for the renderers
if ( rndr->getRendererName() == "Custom Node Renderer" ) {
auto nodeToolBar = window->addToolBar( "NodeGraph control" );
nodeToolBar->setObjectName( "Edit Graph" );
auto grphAction = new QAction( "Edit Graph", window );
nodeToolBar->addAction( grphAction );
nodeToolBar->hide();
auto* cnfgRndr =
dynamic_cast<Ra::Dataflow::Rendering::Renderer::ControllableRenderer*>(
rndr.get() );

QAction::connect( grphAction, &QAction::triggered, [cnfgRndr]() {
auto& nbrCtrl =
dynamic_cast<Ra::Dataflow::Rendering::Renderer::RenderGraphController&>(
cnfgRndr->getController() );
auto editor = new Ra::Dataflow::QtGui::GraphEditor::GraphEditorWindow(
nbrCtrl.getGraph() );
editor->show();
} );
QAction::connect(
rndAct, &QAction::triggered, [nodeToolBar]() { nodeToolBar->show(); } );
}
else {
QAction::connect( rndAct, &QAction::triggered, [window]() {
auto toolbars = window->findChildren<QToolBar*>();
for ( auto tb : toolbars ) {
if ( tb->objectName() == "Edit Graph" ) { tb->hide(); }
}
} );
}

++renderNum;
}
}
Expand Down

0 comments on commit 0c6ebf3

Please sign in to comment.