MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/MaterialX / createNodes

Method createNodes

source/MaterialXGraphEditor/Graph.cpp:1980–2265  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1978}
1979
1980std::vector<int> Graph::createNodes(bool nodegraph)
1981{
1982 std::vector<int> outputNum;
1983
1984 const auto& nodeEditorStyle = ed::GetStyle();
1985 const float hdrInset = nodeEditorStyle.NodeBorderWidth;
1986 const float hdrPadL = nodeEditorStyle.NodePadding.x - hdrInset;
1987 const float hdrPadT = nodeEditorStyle.NodePadding.y - hdrInset;
1988 const float hdrPadB = hdrPadT;
1989 const float hdrTextIndent = 4.0f;
1990 const float hdrBottomSpacing = hdrPadB;
1991 const float hdrRounding = std::max(nodeEditorStyle.NodeRounding - hdrInset, 0.0f);
1992
1993 for (UiNodePtr node : _state.nodes)
1994 {
1995 if (node->getCategory() == "group")
1996 {
1997 buildGroupNode(node);
1998 }
1999 else
2000 {
2001 // Color for output pin
2002 std::string outputType;
2003 if (node->getNode() != nullptr)
2004 {
2005 ed::BeginNode(node->getId());
2006 ImGui::PushID(node->getId());
2007 ImGui::SetWindowFontScale(1.2f * _fontScale);
2008 ImGui::GetWindowDrawList()->AddRectFilled(
2009 ImGui::GetCursorScreenPos() + ImVec2(-hdrPadL, -hdrPadT),
2010 ImGui::GetCursorScreenPos() + ImVec2(ed::GetNodeSize(node->getId()).x - hdrPadL - 2.f * hdrInset, ImGui::GetTextLineHeight() + hdrPadB),
2011 ImColor(ImColor(55, 55, 55, 255)), hdrRounding);
2012 ImGui::GetWindowDrawList()->AddRectFilled(
2013 ImGui::GetCursorScreenPos() + ImVec2(-hdrPadL, 3),
2014 ImGui::GetCursorScreenPos() + ImVec2(ed::GetNodeSize(node->getId()).x - hdrPadL - 2.f * hdrInset, ImGui::GetTextLineHeight() + hdrPadB),
2015 ImColor(ImColor(55, 55, 55, 255)), 0.f);
2016 ImGui::Indent(hdrTextIndent);
2017 ImGui::Text("%s", node->getName().c_str());
2018 ImGui::Unindent(hdrTextIndent);
2019 ImGui::SetWindowFontScale(_fontScale);
2020 ImGui::Dummy(ImVec2(0, hdrBottomSpacing));
2021
2022 std::string longestInputLabel = node->getName();
2023 for (UiPinPtr pin : node->getInputPins())
2024 {
2025 UiNodePtr upUiNode = node->getConnectedNode(pin->getName());
2026 if (upUiNode)
2027 {
2028 size_t pinIndex = 0;
2029 if (upUiNode->getOutputPins().size() > 0)
2030 {
2031 const std::string outputString = pin->getInput()->getOutputString();
2032 if (!outputString.empty())
2033 {
2034 for (size_t i = 0; i < upUiNode->getOutputPins().size(); i++)
2035 {
2036 UiPinPtr outPin = upUiNode->getOutputPins()[i];
2037 if (outPin->getName() == outputString)

Callers

nothing calls this directly

Calls 15

getCategoryMethod · 0.80
getIdMethod · 0.80
c_strMethod · 0.80
addConnectionMethod · 0.80
setConnectedMethod · 0.80
getConnectedMethod · 0.80
push_backMethod · 0.80
getPinIdMethod · 0.80
getNodeGraphMethod · 0.80
maxFunction · 0.50
getNodeMethod · 0.45
getNameMethod · 0.45

Tested by

no test coverage detected