diff --git a/src/libRender/CMakeLists.txt b/src/libRender/CMakeLists.txt index d43a3c565c0ce28ae07af877fe45013d0fbd90a9..0eb4180b0078d41a6f4c177364766fde95151d21 100644 --- a/src/libRender/CMakeLists.txt +++ b/src/libRender/CMakeLists.txt @@ -276,10 +276,11 @@ set(gui_sources RadiumNBR/Gui/HoverPoints.cpp RadiumNBR/Gui/TransferEditor.cpp - RadiumNBR/Gui/RenderGraphEditor/RenderGraphEditorView.cpp + RadiumNBR/Gui/RenderGraphEditor/WidgetFactory.cpp RadiumNBR/Gui/RenderGraphEditor/ColorSlider.cpp RadiumNBR/Gui/RenderGraphEditor/NodeAdapterModel.cpp + RadiumNBR/Gui/RenderGraphEditor/RenderGraphEditorView.cpp RadiumNBR/VolumeVisualization/Gui/VolumeVisualizationGui.cpp RadiumNBR/Gui/MultiPassControllerGui.cpp RadiumNBR/Gui/NodeGraphControllerGui.cpp diff --git a/src/libRender/RadiumNBR/Gui/NodeEditor/src/FlowScene.cpp b/src/libRender/RadiumNBR/Gui/NodeEditor/src/FlowScene.cpp index 65d779e0dc3c25850930060f0ae6150c28a1a986..7f9f722871eee222a648c4a2920b09db99bc7400 100644 --- a/src/libRender/RadiumNBR/Gui/NodeEditor/src/FlowScene.cpp +++ b/src/libRender/RadiumNBR/Gui/NodeEditor/src/FlowScene.cpp @@ -209,7 +209,7 @@ createNode(std::unique_ptr<NodeDataModel> && dataModel) return *nodePtr; } - +// TODO MTHS -- Add a method that takes a datamodel and only create the node. Node& FlowScene:: restoreNode(QJsonObject const& nodeJson) diff --git a/src/libRender/RadiumNBR/Gui/NodeEditor/src/Node.cpp b/src/libRender/RadiumNBR/Gui/NodeEditor/src/Node.cpp index 5ef599d0d0f3b18a360580e16547936d6b3a22c7..7a859f3249b2d5830e00246c2b14bc32445946a5 100644 --- a/src/libRender/RadiumNBR/Gui/NodeEditor/src/Node.cpp +++ b/src/libRender/RadiumNBR/Gui/NodeEditor/src/Node.cpp @@ -23,6 +23,7 @@ using QtNodes::NodeGraphicsObject; using QtNodes::PortIndex; using QtNodes::PortType; +// TODO MTHS -- get uuid from datamodel instead of generating one Node:: Node(std::unique_ptr<NodeDataModel> && dataModel) : _uid(QUuid::createUuid()) @@ -86,8 +87,7 @@ restore(QJsonObject const& json) _nodeDataModel->restore(json); // This prevent to have different instances (aliases) of the same node in the graph _uid = QUuid(_nodeDataModel->uuid()); - // TODO : remove the following when aliases are OK - _uid = QUuid(json["id"].toString()); + // TODO : Find a way to make Node aliasing available QJsonObject positionJson = json["position"].toObject(); QPointF point(positionJson["x"].toDouble(), diff --git a/src/libRender/RadiumNBR/Gui/NodeGraphControllerGui.cpp b/src/libRender/RadiumNBR/Gui/NodeGraphControllerGui.cpp index d62495e3e10598c0b1672ed47c24c67124b324b7..3f10f8acc49b61dfe77617b51ed6f8b9a6f49da9 100644 --- a/src/libRender/RadiumNBR/Gui/NodeGraphControllerGui.cpp +++ b/src/libRender/RadiumNBR/Gui/NodeGraphControllerGui.cpp @@ -21,9 +21,8 @@ buildNodeGraphControllerGui( NodeBasedRenderer* renderer, auto controlPanel = new RendererPanel( renderer->getRendererName() ); auto nodeEditor = new RenderGraphEditorView( nullptr ); - nodeEditor->current = renderer; - auto editorRegistry = NodeGraphQtEditor::initializeNodeRegistry( renderer->getRenderGraph() ); - nodeEditor->scene->setRegistry( editorRegistry ); + nodeEditor->setGraph( renderer->getRenderGraph() ); + // TODO: find a way to refresh the main window when a widget gets updated instead of // when the mouse moves diff --git a/src/libRender/RadiumNBR/Gui/RenderGraphEditor/ConnectionStatusData.hpp b/src/libRender/RadiumNBR/Gui/RenderGraphEditor/ConnectionStatusData.hpp index 09fb79a2778998502e5975c7487d69ec99eaf2f2..3d25e7a00e8bc604a1f366a85d5801f7a8ad6c73 100644 --- a/src/libRender/RadiumNBR/Gui/RenderGraphEditor/ConnectionStatusData.hpp +++ b/src/libRender/RadiumNBR/Gui/RenderGraphEditor/ConnectionStatusData.hpp @@ -1,8 +1,8 @@ #pragma once #include <RadiumNBR/NodeBasedRendererMacro.hpp> -#include <nodes/NodeDataModel> +#include <RadiumNBR/NodeGraph/Node.hpp> -#include "RadiumNBR/NodeGraph/Node.hpp" +#include <nodes/NodeDataModel> #include <string> diff --git a/src/libRender/RadiumNBR/NodeBasedRenderer.cpp b/src/libRender/RadiumNBR/NodeBasedRenderer.cpp index c400b1ee588f959cad4b03f5e4077aa81395f958..e9f71a3efdd5b9b16827654f2f3bab5bc6f62cd0 100644 --- a/src/libRender/RadiumNBR/NodeBasedRenderer.cpp +++ b/src/libRender/RadiumNBR/NodeBasedRenderer.cpp @@ -86,7 +86,6 @@ void NodeBasedRenderer::loadFromJson( const std::string& jsonFilePath ) { } void NodeBasedRenderer::compileRenderGraph() { - std::cout << "NodeBasedRenderer::compileRenderGraph\n"; m_originalRenderGraph.init(); m_originalRenderGraph.resize( m_width, m_height ); buildAllRenderTechniques(); @@ -282,24 +281,25 @@ void NodeBasedRenderer::uiInternal( const ViewingParameters& renderData ) { } void NodeBasedRenderer::postProcessInternal( const ViewingParameters& /* renderData */ ) { + if (m_colorTexture) { + m_postprocessFbo->bind(); - m_postprocessFbo->bind(); - - GL_ASSERT( glDrawBuffers( 1, buffers ) ); + GL_ASSERT( glDrawBuffers( 1, buffers ) ); - GL_ASSERT( glDisable( GL_DEPTH_TEST ) ); - GL_ASSERT( glDepthMask( GL_FALSE ) ); + GL_ASSERT( glDisable( GL_DEPTH_TEST ) ); + GL_ASSERT( glDepthMask( GL_FALSE ) ); - auto shader = m_postProcessEnabled ? m_shaderProgramManager->getShaderProgram( "Hdr2Ldr" ) - : m_shaderProgramManager->getShaderProgram( "DrawScreen" ); - shader->bind(); - shader->setUniform( "screenTexture", m_colorTexture, 0 ); - m_quadMesh->render( shader ); + auto shader = m_postProcessEnabled ? m_shaderProgramManager->getShaderProgram( "Hdr2Ldr" ) + : m_shaderProgramManager->getShaderProgram( "DrawScreen" ); + shader->bind(); + shader->setUniform( "screenTexture", m_colorTexture, 0 ); + m_quadMesh->render( shader ); - GL_ASSERT( glDepthMask( GL_TRUE ) ); - GL_ASSERT( glEnable( GL_DEPTH_TEST ) ); + GL_ASSERT( glDepthMask( GL_TRUE ) ); + GL_ASSERT( glEnable( GL_DEPTH_TEST ) ); - m_postprocessFbo->unbind(); + m_postprocessFbo->unbind(); + } } void NodeBasedRenderer::updateStepInternal( const ViewingParameters& renderData ) { @@ -345,8 +345,8 @@ void NodeBasedRenderer::setDisplayNode( DisplaySinkNode* displayNode ) { void NodeBasedRenderer::observeDisplaySink( const std::vector<NodeTypeTexture*>& graphOutput ) { // TODO : find a way to make the renderer observable to manage ouput texture in the applicaiton // gui if needed - std::cout << "NodeBasedRenderer::observeDisplaySink - connected textures (" - << graphOutput.size() << ") : \n"; + // std::cout << "NodeBasedRenderer::observeDisplaySink - connected textures (" + // << graphOutput.size() << ") : \n"; /* for ( const auto t : graphOutput ) { diff --git a/src/libRender/RadiumNBR/NodeGraph/RenderGraph.cpp b/src/libRender/RadiumNBR/NodeGraph/RenderGraph.cpp index f6ed666e5b7a03e04419f7084ed5cd6d23b3887f..e52a7372a42eeca2c62f3644a14d69bd2d62ff62 100644 --- a/src/libRender/RadiumNBR/NodeGraph/RenderGraph.cpp +++ b/src/libRender/RadiumNBR/NodeGraph/RenderGraph.cpp @@ -149,15 +149,17 @@ void RenderGraph::loadFromJson( const std::string& jsonFilePath ) { { std::cerr << "Error when reading JSON file \"" << jsonFilePath << "\": Output index " << fromIndex << " for node \"" - << nodeFrom->getName() << "\" must be between 0 and " - << nodeFrom->getOutputs().size() - 1 << "." << std::endl; + << nodeFrom->getTypeName() << "\" must be between 0 and " + << nodeFrom->getOutputs().size() - 1 << ". Link not added." << std::endl; + continue; } } else { std::cerr << "Error when reading JSON file \"" << jsonFilePath - << "\": Could not find a node associated with id " << l["out_id"] << "." + << "\": Could not find a node associated with id " << l["out_id"] << ". Link not added." << std::endl; + continue; } if ( nodeById.find( l["in_id"] ) != nodeById.end() ) @@ -170,16 +172,18 @@ void RenderGraph::loadFromJson( const std::string& jsonFilePath ) { else { std::cerr << "Error when reading JSON file \"" << jsonFilePath << "\": Input index " - << toIndex << " for node \"" << nodeTo->getName() - << "\" must be between 0 and " << nodeTo->getInputs().size() - 1 << "." + << toIndex << " for node \"" << nodeTo->getTypeName() + << "\" must be between 0 and " << nodeTo->getInputs().size() - 1 << ". Link not added." << std::endl; + continue; } } else { std::cerr << "Error when reading JSON file \"" << jsonFilePath - << "\": Could not find a node associated with id " << l["in_id"] << "." + << "\": Could not find a node associated with id " << l["in_id"] << ". Link not added." << std::endl; + continue; } if ( nodeFrom && ( fromOutput != "" ) && nodeTo && ( toInput != "" ) ) @@ -188,7 +192,7 @@ void RenderGraph::loadFromJson( const std::string& jsonFilePath ) { { std::cerr << "Error when reading JSON file \"" << jsonFilePath << "\": Could not add a link (missing or wrong information, please refer to " - "the previous error messages)." + "the previous error messages). Link not added." << std::endl; } } @@ -200,7 +204,7 @@ bool RenderGraph::addNode( Node* newNode ) { << newNode->getName() << "\"..." << std::endl; #endif // Check if the new node already exists (= same name) - if ( findNode( newNode->getName() ) == -1 ) + if ( findNode( newNode->getTypeName() ) == -1 ) { #ifdef GRAPH_CALL_TRACE std::cout << "\e[32m\e[1mRenderGraph\e[0m \"" << m_name << "\": success adding node \"" @@ -226,7 +230,7 @@ bool RenderGraph::removeNode( Node* node ) { #endif // Check if the new node already exists (= same name) int index = -1; - if ( ( index = findNode( node->getName() ) ) == -1 ) + if ( ( index = findNode( node->getTypeName() ) ) == -1 ) { #ifdef GRAPH_CALL_TRACE std::cerr << "\e[32m\e[1mRenderGraph\e[0m \"" << m_name << "\": could not remove node \"" @@ -257,7 +261,7 @@ bool RenderGraph::addLink( Node* nodeFrom, << std::endl; #endif // Check node "from" existence in the graph - if ( findNode( nodeFrom->getName() ) == -1 ) + if ( findNode( nodeFrom->getTypeName() ) == -1 ) { #ifdef GRAPH_CALL_TRACE std::cerr << "ADD LINK : node \"from\" \"" + nodeFrom->getName() + "\" does not exist." @@ -267,7 +271,7 @@ bool RenderGraph::addLink( Node* nodeFrom, } // Check node "to" existence in the graph - if ( findNode( nodeTo->getName() ) == -1 ) + if ( findNode( nodeTo->getTypeName() ) == -1 ) { #ifdef GRAPH_CALL_TRACE std::cerr << "ADD LINK : node \"to\" \"" + nodeTo->getName() + "\" does not exist." @@ -367,7 +371,7 @@ bool RenderGraph::addLink( Node* nodeFrom, bool RenderGraph::removeLink( Node* node, const std::string& nodeInputName ) { // Check node's existence in the graph - if ( findNode( node->getName() ) == -1 ) + if ( findNode( node->getTypeName() ) == -1 ) { #ifdef GRAPH_CALL_TRACE std::cerr << "REMOVE LINK : node \"" + node->getName() + "\" does not exist." << std::endl; @@ -410,7 +414,7 @@ bool RenderGraph::removeLink( Node* node, const std::string& nodeInputName ) { int RenderGraph::findNode( const std::string& name ) { for ( size_t i = 0; i < m_nodes.size(); i++ ) { - if ( m_nodes[i]->getName() == name ) { return i; } + if ( m_nodes[i]->getTypeName() == name ) { return i; } } return -1; diff --git a/src/libRender/RadiumNBR/NodeGraph/RenderGraph.hpp b/src/libRender/RadiumNBR/NodeGraph/RenderGraph.hpp index 7c18fc13104a136f20f08f5e19559a417fd7f3cf..0a415fa8cca7b455a85733edcfab3e8b9d8352f7 100644 --- a/src/libRender/RadiumNBR/NodeGraph/RenderGraph.hpp +++ b/src/libRender/RadiumNBR/NodeGraph/RenderGraph.hpp @@ -1,9 +1,12 @@ #pragma once #include <RadiumNBR/NodeBasedRendererMacro.hpp> -#include <RadiumNBR/NodeGraph/Node.hpp> + #include <RadiumNBR/NodeGraph/PremadeNodes/Sinks/DisplaySinkNode.hpp> #include <RadiumNBR/NodeGraph/PremadeNodes/Sources/DataNode.hpp> +#include <RadiumNBR/NodeGraph/Node.hpp> + + // TODO : Find a new name, it is not a RENDER graph only anymore class NodeBasedRenderer_LIBRARY_API RenderGraph : public Node {