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

[librender] correct management of node metadata (e.g. position given by the editor)

parent 7f6e3148
No related branches found
No related tags found
No related merge requests found
......@@ -68,6 +68,8 @@ public:
virtual void updateState() {}
virtual void addMetaData(QJsonObject&) {}
public:
QJsonObject
......
......@@ -438,6 +438,13 @@ setNodePosition(Node& node, const QPointF& pos) const
{
node.nodeGraphicsObject().setPos(pos);
node.nodeGraphicsObject().moveConnections();
QJsonObject obj;
obj["x"] = node.nodeGraphicsObject().pos().x();
obj["y"] = node.nodeGraphicsObject().pos().y();
QJsonObject nodeJson;
nodeJson["position"] = obj;
node.nodeDataModel()->addMetaData(nodeJson);
}
......
......@@ -79,6 +79,12 @@ class NodeAdapterModel : public QtNodes::NodeDataModel
checkConnections();
}
void addMetaData(QJsonObject& json) override {
nlohmann::json data;
NodeDataModelTools::QJsonObjectToNlohmannObject(json, data);
m_node->addJsonMetaData(data);
}
private:
QtNodes::NodeDataType IOToDataType( size_t hashType, const std::string& ioName ) const {
return QtNodes::NodeDataType{ std::to_string( hashType ).c_str(), ioName.c_str() };
......
......@@ -5,6 +5,7 @@
#include <nodes/ConnectionStyle>
#include <nodes/NodeData>
#include <nodes/Node>
#include <RadiumNBR/NodeGraph/RenderGraph.hpp>
......@@ -108,6 +109,15 @@ void RenderGraphEditorView::connectAll() {
std::cout << "QtNodes::FlowScene::connectionDeleted\n";
emit needUpdate();
} ) );
connections.push_back(
QObject::connect(scene, &QtNodes::FlowScene::nodeMoved, [](QtNodes::Node &n, const QPointF& pos) {
QJsonObject obj;
obj["x"] = n.nodeGraphicsObject().pos().x();
obj["y"] = n.nodeGraphicsObject().pos().y();
QJsonObject nodeJson;
nodeJson["position"] = obj;
n.nodeDataModel()->addMetaData(nodeJson);
} ) );
}
void RenderGraphEditorView::setGraph( RenderGraph* rg ) {
......
......@@ -102,3 +102,9 @@ void Node::toJson( nlohmann::json& data ) const {
{ std::cout << "\t" << key << " : " << value << "\n"; }
*/
}
void Node::addJsonMetaData(const nlohmann::json& data ) {
for ( auto& [key, value] : data.items() ) {
m_extraJsonData[key] = value;
}
}
......@@ -98,8 +98,11 @@ class NodeBasedRenderer_LIBRARY_API Node
/// Fill the node from its json description
void fromJson( const nlohmann::json& data );
/// Add a metadata to the node to store application specific informations (e.g. position pour l'editeur
void addJsonMetaData(const nlohmann::json& data );
/// Give access to extra json data stored on the node by external application components
nlohmann::json& getExtraJsonData() { return m_extraJsonData; }
nlohmann::json& getJsonMetaData() { return m_extraJsonData; }
/// Build a render technic per material.
/// @param ro The render object to get the material from
......
......@@ -3,121 +3,127 @@
{
"in_id": "{aa0f14a1-bb34-43a6-a11d-5b88404d254d}",
"in_index": 0,
"out_id": "{54d687ca-0921-48df-899b-02883c8c9650}",
"out_id": "{16dc911c-bf8a-4e45-a5c7-6ea14a4c0044}",
"out_index": 0
},
{
"in_id": "{aa0f14a1-bb34-43a6-a11d-5b88404d254d}",
"in_index": 1,
"out_id": "{f922db1f-83b5-4907-8b47-95c35f80ce38}",
"out_id": "{71b21c1d-4441-48de-89c0-173333aad7ca}",
"out_index": 0
},
{
"in_id": "{aa0f14a1-bb34-43a6-a11d-5b88404d254d}",
"in_index": 2,
"out_id": "{f4584385-2400-4cb1-b7b1-70411ded95eb}",
"out_index": 1
"out_id": "{16dc911c-bf8a-4e45-a5c7-6ea14a4c0044}",
"out_index": 0
},
{
"in_id": "{aa0f14a1-bb34-43a6-a11d-5b88404d254d}",
"in_index": 3,
"out_id": "{6dbbb7b7-e370-4dc6-8eff-33621dea9665}",
"out_id": "{b81f15ff-c2cf-486d-b100-8d1856a33a46}",
"out_index": 1
},
{
"in_id": "{aa0f14a1-bb34-43a6-a11d-5b88404d254d}",
"in_index": 4,
"out_id": "{6dbbb7b7-e370-4dc6-8eff-33621dea9665}",
"out_id": "{f9850218-681e-4cad-8941-b59377701b85}",
"out_index": 1
},
{
"in_id": "{aa0f14a1-bb34-43a6-a11d-5b88404d254d}",
"in_index": 5,
"out_id": "{f9850218-681e-4cad-8941-b59377701b85}",
"out_index": 2
},
{
"in_id": "{f4584385-2400-4cb1-b7b1-70411ded95eb}",
"in_id": "{b81f15ff-c2cf-486d-b100-8d1856a33a46}",
"in_index": 0,
"out_id": "{d07939d8-46d5-4d48-90fa-4ab2a4eebf30}",
"out_index": 0
},
{
"in_id": "{f4584385-2400-4cb1-b7b1-70411ded95eb}",
"in_id": "{b81f15ff-c2cf-486d-b100-8d1856a33a46}",
"in_index": 1,
"out_id": "{6ceda554-f6d1-4cf0-a36d-e811fc0ad3f1}",
"out_index": 0
},
{
"in_id": "{f4584385-2400-4cb1-b7b1-70411ded95eb}",
"in_id": "{b81f15ff-c2cf-486d-b100-8d1856a33a46}",
"in_index": 2,
"out_id": "{c6d4682c-2a02-467a-9c5c-5511b63b17ba}",
"out_index": 0
},
{
"in_id": "{6dbbb7b7-e370-4dc6-8eff-33621dea9665}",
"in_id": "{c3050daf-8625-4976-a6f9-e8d8ee9389ca}",
"in_index": 0,
"out_id": "{f4584385-2400-4cb1-b7b1-70411ded95eb}",
"out_id": "{0acab8a1-614a-47ae-8659-08622032230f}",
"out_index": 0
},
{
"in_id": "{6dbbb7b7-e370-4dc6-8eff-33621dea9665}",
"in_id": "{f9850218-681e-4cad-8941-b59377701b85}",
"in_index": 0,
"out_id": "{b81f15ff-c2cf-486d-b100-8d1856a33a46}",
"out_index": 0
},
{
"in_id": "{f9850218-681e-4cad-8941-b59377701b85}",
"in_index": 1,
"out_id": "{f4584385-2400-4cb1-b7b1-70411ded95eb}",
"out_id": "{b81f15ff-c2cf-486d-b100-8d1856a33a46}",
"out_index": 1
},
{
"in_id": "{6dbbb7b7-e370-4dc6-8eff-33621dea9665}",
"in_id": "{f9850218-681e-4cad-8941-b59377701b85}",
"in_index": 2,
"out_id": "{46bb5a05-2255-41e4-a6c1-38b5d23de1a8}",
"out_id": "{faa78a3d-ccc1-4ec0-ad94-107dca987185}",
"out_index": 0
},
{
"in_id": "{6dbbb7b7-e370-4dc6-8eff-33621dea9665}",
"in_id": "{f9850218-681e-4cad-8941-b59377701b85}",
"in_index": 3,
"out_id": "{6ceda554-f6d1-4cf0-a36d-e811fc0ad3f1}",
"out_index": 0
},
{
"in_id": "{6dbbb7b7-e370-4dc6-8eff-33621dea9665}",
"in_id": "{f9850218-681e-4cad-8941-b59377701b85}",
"in_index": 4,
"out_id": "{c6d4682c-2a02-467a-9c5c-5511b63b17ba}",
"out_index": 0
},
{
"in_id": "{46bb5a05-2255-41e4-a6c1-38b5d23de1a8}",
"in_id": "{faa78a3d-ccc1-4ec0-ad94-107dca987185}",
"in_index": 0,
"out_id": "{d07939d8-46d5-4d48-90fa-4ab2a4eebf30}",
"out_index": 0
},
{
"in_id": "{54d687ca-0921-48df-899b-02883c8c9650}",
"in_id": "{71b21c1d-4441-48de-89c0-173333aad7ca}",
"in_index": 0,
"out_id": "{6dbbb7b7-e370-4dc6-8eff-33621dea9665}",
"out_id": "{c3050daf-8625-4976-a6f9-e8d8ee9389ca}",
"out_index": 0
},
{
"in_id": "{f922db1f-83b5-4907-8b47-95c35f80ce38}",
"in_index": 0,
"out_id": "{5265b672-a9f5-4d7a-88ad-be9181615f33}",
"out_index": 0
},
{
"in_id": "{f922db1f-83b5-4907-8b47-95c35f80ce38}",
"in_id": "{71b21c1d-4441-48de-89c0-173333aad7ca}",
"in_index": 1,
"out_id": "{f4584385-2400-4cb1-b7b1-70411ded95eb}",
"out_id": "{b81f15ff-c2cf-486d-b100-8d1856a33a46}",
"out_index": 1
},
{
"in_id": "{f922db1f-83b5-4907-8b47-95c35f80ce38}",
"in_id": "{71b21c1d-4441-48de-89c0-173333aad7ca}",
"in_index": 3,
"out_id": "{d07939d8-46d5-4d48-90fa-4ab2a4eebf30}",
"out_index": 0
},
{
"in_id": "{f922db1f-83b5-4907-8b47-95c35f80ce38}",
"in_id": "{71b21c1d-4441-48de-89c0-173333aad7ca}",
"in_index": 4,
"out_id": "{6ceda554-f6d1-4cf0-a36d-e811fc0ad3f1}",
"out_index": 0
},
{
"in_id": "{5265b672-a9f5-4d7a-88ad-be9181615f33}",
"in_id": "{16dc911c-bf8a-4e45-a5c7-6ea14a4c0044}",
"in_index": 0,
"out_id": "{6d109dde-cc2e-4fd3-a229-8e9eb6c80160}",
"out_id": "{f9850218-681e-4cad-8941-b59377701b85}",
"out_index": 0
}
],
......@@ -129,8 +135,8 @@
"name": "RenderObjects"
},
"position": {
"x": 48,
"y": 56.400000000000006
"x": 10.800000190734863,
"y": 8.400001525878906
}
},
{
......@@ -140,8 +146,8 @@
"name": "Lights"
},
"position": {
"x": 55.20000000000002,
"y": 230.39999999999998
"x": 8.40000057220459,
"y": 238.79998779296875
}
},
{
......@@ -151,8 +157,8 @@
"name": "Cameras"
},
"position": {
"x": 49.20000000000002,
"y": 125.99999999999997
"x": 9.600000381469727,
"y": 126.0
}
},
{
......@@ -162,68 +168,92 @@
"name": "Display Sink"
},
"position": {
"x": 648.0000000000001,
"y": 29.99999999999997
"x": 1192.800048828125,
"y": 10.800000190734863
}
},
{
"id": "{f4584385-2400-4cb1-b7b1-70411ded95eb}",
"id": "{b81f15ff-c2cf-486d-b100-8d1856a33a46}",
"model": {
"instance": "SimpleNode4",
"name": "Simple Render Pass"
},
"position": {
"x": 253.2,
"y": 92.39999999999999
"x": 212.40000915527344,
"y": 43.20000076293945
}
},
{
"id": "{6dbbb7b7-e370-4dc6-8eff-33621dea9665}",
"id": "{0acab8a1-614a-47ae-8659-08622032230f}",
"model": {
"instance": "TransparencyNode5",
"name": "Transparency Pass"
"instance": "ColorTextureNode5",
"name": "Color Texture"
},
"position": {
"x": 9.600000381469727,
"y": 449.6000061035156
}
},
{
"id": "{46bb5a05-2255-41e4-a6c1-38b5d23de1a8}",
"id": "{c3050daf-8625-4976-a6f9-e8d8ee9389ca}",
"model": {
"filteredType": "Transparent",
"instance": "FilterROByTypeNode6",
"name": "Filter RenderObjects By Type"
"clearColor": [
0.40000003576278687,
0.4862745404243469,
0.501960813999176
],
"instance": "ClearColorNode6",
"name": "Clear Color Pass"
},
"position": {
"x": 160.8000030517578,
"y": 344.3999938964844
}
},
{
"id": "{54d687ca-0921-48df-899b-02883c8c9650}",
"id": "{f9850218-681e-4cad-8941-b59377701b85}",
"model": {
"instance": "FXAANode7",
"name": "FXAA"
"instance": "TransparencyNode7",
"name": "Transparency Pass"
},
"position": {
"x": 609.5999755859375,
"y": 8.400012016296387
}
},
{
"id": "{f922db1f-83b5-4907-8b47-95c35f80ce38}",
"id": "{faa78a3d-ccc1-4ec0-ad94-107dca987185}",
"model": {
"activated": true,
"instance": "WireframeNode8",
"name": "Wireframe Pass"
"filteredType": "Transparent",
"instance": "FilterROByTypeNode8",
"name": "Filter RenderObjects By Type"
},
"position": {
"x": 208.80001831054688,
"y": -121.20000457763672
}
},
{
"id": "{6d109dde-cc2e-4fd3-a229-8e9eb6c80160}",
"id": "{71b21c1d-4441-48de-89c0-173333aad7ca}",
"model": {
"instance": "ColorTextureNode9",
"name": "Color Texture"
"activated": true,
"instance": "WireframeNode9",
"name": "Wireframe Pass"
},
"position": {
"x": 609.5999755859375,
"y": 307.1999816894531
}
},
{
"id": "{5265b672-a9f5-4d7a-88ad-be9181615f33}",
"id": "{16dc911c-bf8a-4e45-a5c7-6ea14a4c0044}",
"model": {
"clearColor": [
0.4078431725502014,
0.4078431725502014,
0.4078431725502014
],
"instance": "ClearColorNode10",
"name": "Clear Color Pass"
"instance": "FXAANode10",
"name": "FXAA"
},
"position": {
"x": 891.5999755859375,
"y": -60.0
}
}
]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment