Skip to content

Commit b6e7ee1

Browse files
committed
Inserting new module works
1 parent 4d77bf2 commit b6e7ee1

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/Interface/Application/NetworkEditor.cc

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ void NetworkEditor::connectNewModule(const ModuleHandle& moduleToConnectTo, cons
240240
if (newConnectionInputPort)
241241
{
242242
qDebug() << "found port object to connect up with:" << newConnectionInputPort;
243+
controller_->removeConnection(*newConnectionInputPort->firstConnectionId());
243244
newConnectionInputPort->deleteConnectionsLater();
244245
}
245246
else
@@ -359,11 +360,19 @@ void NetworkEditor::setupModuleWidget(ModuleWidget* module)
359360
connect(this, SIGNAL(networkExecuted()), module, SLOT(resetProgressBar()));
360361

361362
proxy->setZValue(zLevelManager_->get_max());
362-
while (!scene_->items(lastModulePosition_.x() - 20, lastModulePosition_.y() - 20, 40, 40).isEmpty())
363+
364+
if (!insertingNewModuleAlongConnection_)
365+
{
366+
while (!scene_->items(lastModulePosition_.x() - 20, lastModulePosition_.y() - 20, 40, 40).isEmpty())
367+
{
368+
lastModulePosition_ += QPointF(20, -20);
369+
}
370+
proxy->setPos(lastModulePosition_);
371+
}
372+
else
363373
{
364-
lastModulePosition_ += QPointF(20, -20);
374+
//TODO: find midpoint of two connected modules, set position there
365375
}
366-
proxy->setPos(lastModulePosition_);
367376

368377
proxy->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemSendsGeometryChanges);
369378
connect(scene_, SIGNAL(selectionChanged()), proxy, SLOT(highlightIfSelected()));

src/Interface/Application/NetworkEditor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ namespace Gui {
298298
boost::shared_ptr<ZLevelManager> zLevelManager_;
299299
std::string latestModuleId_;
300300
bool fileLoading_;
301+
bool insertingNewModuleAlongConnection_ { false };
301302
PreexecuteFunc preexecute_;
302303
};
303304
}

0 commit comments

Comments
 (0)