admin管理员组

文章数量:1289637

I'm working on a project that uses nodes and plots. I chose to use ImGui alongside ImPlots and imgui-node-editor.

(Docking branch)

I want to be able to embed an ImPlot plot into an imgui-node-editor node

Assuming everything is set up correctly, which it is.

ax::NodeEditor::BeginNode(1);
if (ImPlot::BeginPlot("BlankPlot")) {
    ImPlot::EndPlot();
}
ax::NodeEditor::EndNode();

(Example, not my actual implementation.) Draws outside of the bounds of the node

As for my specific implementation: (I'm including this because I'm not sure if this matters or not)

Editor.cpp (Excerpt from Draw loop)

    // Loop through all nodes in Nodes::nodes
    for (auto it = Nodes::nodes.begin(); it != Nodes::nodes.end(); ) {
        // Get node
        Nodes::BaseNode* node = it->get();
        // Begin drawing  Node
        ax::NodeEditor::BeginNode(node->GetNodeID()); // Begins Node, sets ID from node's GetNodeID (See BaseNode.h and BaseNode.cpp)
        node->Draw();                          // Draws node (Defined for every class inheriting from BaseNode)
        if (!node->IsOpen()) {                 // Checks if node should still be open (See BaseNode.h and BaseNode.cpp)
            it = Nodes::nodes.erase(it);       // If node should be closed, remove it from Nodes::nodes
        } else {
            ++it;                              // Else, keep chugging along
        }
        ax::NodeEditor::EndNode();
    }

ScopeNode.cpp

void Oscil::Nodes::ScopeNode::Draw() {
    ImGui::Text("Node A");
    ax::NodeEditor::BeginPin(Nodes::GetConnectionID(GetNodeID(), 1), ax::NodeEditor::PinKind::Input);
    ImGui::Text("-> In");
    ax::NodeEditor::EndPin();
    
    if (ImPlot::BeginPlot("OscilloscopePlot")) {
        //ImPlot::PlotLine("Line1", {1, 2, 3, 4, 5, 6, 6});
        ImPlot::EndPlot();
    }
}

本文标签: cHow do I properly draw an ImPlots plot into a imguinodeeditor nodeStack Overflow