Skip to content

Commit

Permalink
nodegraph: rename attribute to pin
Browse files Browse the repository at this point in the history
  • Loading branch information
gwaldron committed Feb 7, 2025
1 parent 01caa6c commit 1a373b8
Show file tree
Hide file tree
Showing 3 changed files with 185 additions and 177 deletions.
46 changes: 23 additions & 23 deletions src/osgEarthImGui/NodeGraphGUI
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ namespace osgEarth
ImGui::EndMenu();
}

if (ImGui::BeginMenu("Add Node"))
if (ImGui::BeginMenu("Nodes"))
{
if (ImGui::MenuItem("Sphere"))
{
Expand Down Expand Up @@ -697,12 +697,12 @@ namespace osgEarth
if (auto* op = dynamic_cast<SelectFeaturesOperation*>(o.get()))
{
ImGui::PushItemWidth(600);
auto code = op->_expression;
auto code = op->expression;

ImGui::Text("Javascript expression:");
if (ImGuiEx::InputTextMultiline("##select_features", &code, ImVec2(600, 200)))
{
op->_expression = code;
op->expression = code;
//updateNodeGraph(); // Force the user to click update
}

Expand Down Expand Up @@ -773,17 +773,17 @@ namespace osgEarth
}


for (auto& attr : o->getInputAttributes())
for (auto& pin : o->getInputPins())
{
ImNodes::BeginInputAttribute(attr.getId());
ImGui::Text(attr.getName().c_str());
ImNodes::BeginInputAttribute(pin.getId());
ImGui::Text(pin.getName().c_str());
ImNodes::EndInputAttribute();
}

for (auto& attr : o->getOutputAttributes())
for (auto& pin : o->getOutputPins())
{
ImNodes::BeginOutputAttribute(attr.getId());
ImGui::Text(attr.getName().c_str());
ImNodes::BeginOutputAttribute(pin.getId());
ImGui::Text(pin.getName().c_str());
ImNodes::EndOutputAttribute();
}

Expand All @@ -807,49 +807,49 @@ namespace osgEarth
{
for (auto& link : o->getLinks())
{
ImNodes::Link(link.getId(), link._sourceAttribute->getId(), link._destinationAttribute->getId());
ImNodes::Link(link.getId(), link._sourcePin->getId(), link._destinationPin->getId());
}
}
}

ImNodes::EndNodeEditor();

int start_attr, end_attr;
if (ImNodes::IsLinkCreated(&start_attr, &end_attr))
int start_pin, end_pin;
if (ImNodes::IsLinkCreated(&start_pin, &end_pin))
{
NodeGraphOperation* startOperation = nullptr;
const NodeAttribute* startAttribute = nullptr;
const Pin* startPin = nullptr;

NodeGraphOperation* endOperation = nullptr;
const NodeAttribute* endAttribute = nullptr;
const Pin* endPin = nullptr;

std::cout << "Creating link between " << start_attr << " and " << end_attr << std::endl;
//std::cout << "Creating link between " << start_pin << " and " << end_pin << std::endl;

// Find the input attribute
for (auto& o : _proceduralModelLayer->getNodeGraph()->operations)
{
for (auto& attr : o->getInputAttributes())
for (auto& pin : o->getInputPins())
{
if (attr.getId() == end_attr)
if (pin.getId() == end_pin)
{
endOperation = o.get();
endAttribute = &attr;
endPin = &pin;
}
}

for (auto& attr : o->getOutputAttributes())
for (auto& pin : o->getOutputPins())
{
if (attr.getId() == start_attr)
if (pin.getId() == start_pin)
{
startOperation = o.get();
startAttribute = &attr;
startPin = &pin;
}
}
}

if (startOperation && startAttribute && endOperation && endAttribute)
if (startOperation && startPin && endOperation && endPin)
{
startOperation->connect(startAttribute->getName(), endOperation, endAttribute->getName());
startOperation->connect(startPin->getName(), endOperation, endPin->getName());
}


Expand Down
Loading

0 comments on commit 1a373b8

Please sign in to comment.