34{
35 DrawHeader("Visualizer");
36 inputPins[0]->Render();
37 ImGui::Text("In");
38 ImGui::SameLine();
39 ImGui::Dummy(ImVec2(150, 10));
40 ImGui::SameLine();
41 ImGui::Text("Out");
42 outputPins[0]->Render();
43 ImGui::NewLine();
44
45 if (ImGui::Button("Update"))
46 {
47 if (outputPins[0]->IsLinked())
48 {
49 map.clear();
50 mutex.lock();
51 bool isIl = inputPins[0]->IsLinked();
53
54 for (int i = 0; i < inputC.maxX; i++)
55 {
56 for (int j = 0; j < inputC.maxY; j++)
57 {
58 if (isIl)
59 {
60 p = inputC;
61 p.y = i;
62 p.x = j;
63 map.push_back(inputPins[0]->other->Evaluate(p).value);
64 }
65
66 else
67 {
68 map.push_back(0.0f);
69 }
70 }
71 }
72
73 mutex.unlock();
74 }
75
76 else
77 {
78 ShowMessageBox("Output pin must be connected in order to visualize", "Error");
79 }
80 }
81
82 ImGui::NewLine();
83 ImGui::Text("Right Click to visualize!");
84
85 if (map.size() > 0)
86 {
87 ImGuiNodeEditor::Suspend();
88
89 if (ImGui::BeginPopupContextWindow(MAKE_IMGUI_LABEL(id, "Plot")))
90 {
91 ImGui::BeginChild(MAKE_IMGUI_LABEL(id, "PlotChild"), ImVec2(300, 300));
92
93 if (ImPlot::BeginPlot(MAKE_IMGUI_ID(id)))
94 {
95 ImPlot::PlotHeatmap<float>(MAKE_IMGUI_ID(outputPins[0]->id), map.data(), inputC.maxY, inputC.maxX);
96 ImPlot::EndPlot();
97 }
98
99 ImGui::EndChild();
100 ImGui::EndPopup();
101 }
102
103 ImGuiNodeEditor::Resume();
104 }
105}