1

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

https://github.com/ocornut/imgui (Docking branch)

https://github.com/epezent/implot

https://github.com/thedmd/imgui-node-editor

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

ImPlots not embedding into 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();
    }
}

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.