| 4091 | } |
| 4092 | |
| 4093 | void Graph::drawGraph(ImVec2 mousePos) |
| 4094 | { |
| 4095 | if (_searchNodeId > 0) |
| 4096 | { |
| 4097 | ed::SelectNode(_searchNodeId); |
| 4098 | ed::NavigateToSelection(); |
| 4099 | _searchNodeId = -1; |
| 4100 | } |
| 4101 | |
| 4102 | bool TextCursor = false; |
| 4103 | |
| 4104 | // Center imgui window and set size |
| 4105 | ImGuiIO& io2 = ImGui::GetIO(); |
| 4106 | ImGui::SetNextWindowSize(io2.DisplaySize); |
| 4107 | ImGui::SetNextWindowPos(ImVec2(io2.DisplaySize.x * 0.5f, io2.DisplaySize.y * 0.5f), ImGuiCond_Always, ImVec2(0.5f, 0.5f)); |
| 4108 | ImGui::Begin("MaterialX", nullptr, ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoSavedSettings); |
| 4109 | |
| 4110 | io2.ConfigFlags = ImGuiConfigFlags_IsSRGB | ImGuiConfigFlags_NavEnableKeyboard; |
| 4111 | io2.MouseDoubleClickTime = .5; |
| 4112 | graphButtons(); |
| 4113 | |
| 4114 | ed::Begin("My Editor"); |
| 4115 | { |
| 4116 | ed::Suspend(); |
| 4117 | |
| 4118 | // Set up popups for adding a node when tab is pressed |
| 4119 | ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(8.f, 8.f)); |
| 4120 | ImGui::SetNextWindowSizeConstraints(ImVec2(250.0f, 300.0f), ImVec2(-1.0f, 500.0f)); |
| 4121 | addNodePopup(TextCursor); |
| 4122 | searchNodePopup(TextCursor); |
| 4123 | addPinPopup(); |
| 4124 | readOnlyPopup(); |
| 4125 | ImGui::PopStyleVar(); |
| 4126 | |
| 4127 | ed::Resume(); |
| 4128 | |
| 4129 | // Gather selected nodes / links - from ImGui Node Editor blueprints-example.cpp |
| 4130 | std::vector<ed::NodeId> selectedNodes; |
| 4131 | std::vector<ed::LinkId> selectedLinks; |
| 4132 | selectedNodes.resize(ed::GetSelectedObjectCount()); |
| 4133 | selectedLinks.resize(ed::GetSelectedObjectCount()); |
| 4134 | |
| 4135 | int nodeCount = ed::GetSelectedNodes(selectedNodes.data(), static_cast<int>(selectedNodes.size())); |
| 4136 | int linkCount = ed::GetSelectedLinks(selectedLinks.data(), static_cast<int>(selectedLinks.size())); |
| 4137 | |
| 4138 | selectedNodes.resize(nodeCount); |
| 4139 | selectedLinks.resize(linkCount); |
| 4140 | if (io2.KeyCtrl && io2.MouseDown[0]) |
| 4141 | { |
| 4142 | _ctrlClick = true; |
| 4143 | } |
| 4144 | |
| 4145 | // Set current node based off of selected node |
| 4146 | if (selectedNodes.size() > 0) |
| 4147 | { |
| 4148 | int graphPos = findNode(int(selectedNodes[0].Get())); |
| 4149 | if (graphPos > -1) |
| 4150 | { |
no test coverage detected