fix fx schematic links disappear

This commit is contained in:
shun-iwasawa 2022-03-15 12:59:23 +09:00 committed by manongjohn
parent fb88fabf54
commit 0a55a9b170
2 changed files with 32 additions and 7 deletions

View file

@ -1616,13 +1616,25 @@ void FxSchematicPort::mouseMoveEvent(QGraphicsSceneMouseEvent *me) {
if (!m_ghostLinks.isEmpty() && !m_ghostLinks[0]->isVisible())
m_ghostLinks[0]->show();
bool cntr = me->modifiers() == Qt::ControlModifier;
if (!m_linkingTo) {
if (m_currentTargetPort) {
m_currentTargetPort->resetSnappedLinksOnDynamicPortFx();
m_currentTargetPort = 0;
}
return;
}
FxSchematicPort *targetPort = dynamic_cast<FxSchematicPort *>(m_linkingTo);
assert(targetPort);
if (m_currentTargetPort == targetPort) return;
if (m_currentTargetPort) {
m_currentTargetPort->resetSnappedLinksOnDynamicPortFx();
m_currentTargetPort = 0;
}
if (!m_linkingTo) return;
FxSchematicPort *targetPort = dynamic_cast<FxSchematicPort *>(m_linkingTo);
assert(targetPort);
m_currentTargetPort = targetPort;
TFx *targetFx = targetPort->getOwnerFx();
TZeraryColumnFx *colFx = dynamic_cast<TZeraryColumnFx *>(targetFx);
@ -1643,8 +1655,16 @@ void FxSchematicPort::mouseMoveEvent(QGraphicsSceneMouseEvent *me) {
targetFx->dynamicPortGroup(groupId)->ports();
int portId = getIndex(targetFxPort, groupedPorts);
if (portId == -1) return;
if (targetFx != m_ownerFx && cntr && getType() == eFxOutputPort)
targetPort->handleSnappedLinksOnDynamicPortFx(groupedPorts, portId);
if (targetFx != m_ownerFx && getType() == eFxOutputPort) {
// inserting a link above
if (cntr)
targetPort->handleSnappedLinksOnDynamicPortFx(groupedPorts, portId);
// replacing a link
else
targetPort->handleSnappedLinksOnDynamicPortFx(groupedPorts, portId,
portId);
}
// switching links in the connected ports
else if (targetFx == m_ownerFx && getType() == eFxInputPort) {
if (!m_ghostLinks.isEmpty()) {
for (SchematicLink *ghostLink : m_ghostLinks)

View file

@ -853,6 +853,7 @@ void SchematicPort::mouseMoveEvent(QGraphicsSceneMouseEvent *me) {
// Snapping
SchematicPort *linkingTo = searchPort(me->scenePos());
if (!linkingTo) {
for (SchematicLink *ghostLink : m_ghostLinks) {
ghostLink->updateEndPos(me->scenePos());
@ -864,8 +865,12 @@ void SchematicPort::mouseMoveEvent(QGraphicsSceneMouseEvent *me) {
m_linkingTo = nullptr;
}
}
// if to be connected something
else if (linkingTo != this) {
// if to be connected something new
else if (linkingTo != this && m_linkingTo != linkingTo) {
if (m_linkingTo) {
m_linkingTo->highLight(false);
m_linkingTo->update();
}
m_linkingTo = linkingTo;
for (SchematicLink *ghostLink : m_ghostLinks) {
ghostLink->updatePath(ghostLink->getStartPort(), linkingTo);