From 0c6ebf3f66f326225d46abb794f22978e26b23d1 Mon Sep 17 00:00:00 2001 From: Mathias Paulin Date: Fri, 4 Nov 2022 17:13:02 +0100 Subject: [PATCH] [example][dataflow] modify rendering demo. --- .../DataflowExamples/GraphRendering/main.cpp | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/examples/DataflowExamples/GraphRendering/main.cpp b/examples/DataflowExamples/GraphRendering/main.cpp index fdf6d39eb2f..4f95390eb10 100644 --- a/examples/DataflowExamples/GraphRendering/main.cpp +++ b/examples/DataflowExamples/GraphRendering/main.cpp @@ -12,6 +12,8 @@ #include #include +#include + // Qt Widgets #include @@ -83,6 +85,8 @@ 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 ); @@ -90,6 +94,39 @@ class DemoWindowFactory : public BaseApplication::WindowFactory 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( + rndr.get() ); + + QAction::connect( grphAction, &QAction::triggered, [cnfgRndr]() { + auto& nbrCtrl = + dynamic_cast( + 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(); + for ( auto tb : toolbars ) { + if ( tb->objectName() == "Edit Graph" ) { tb->hide(); } + } + } ); + } + ++renderNum; } }