From 3e895dbe5d0b3b148fb831d488505fc23e5bc58b Mon Sep 17 00:00:00 2001 From: afaina Date: Thu, 24 Mar 2022 11:51:18 +0100 Subject: [PATCH 1/4] Fixes movement of the wires when dragging bendpoints of 4 or more wires (fixes #3006). --- src/items/wire.cpp | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/items/wire.cpp b/src/items/wire.cpp index c7906e876..c18c53883 100644 --- a/src/items/wire.cpp +++ b/src/items/wire.cpp @@ -600,22 +600,31 @@ void Wire::mouseMoveEventAux(QPointF eventPos, Qt::KeyboardModifiers modifiers) } setConnector1Rect(); - - QSet allTo; - allTo.insert(whichConnectorItem); + QList allToList; foreach (ConnectorItem * toConnectorItem, whichConnectorItem->connectedToItems()) { Wire * chainedWire = qobject_cast(toConnectorItem->attachedTo()); if (chainedWire == NULL) continue; - allTo.insert(toConnectorItem); - foreach (ConnectorItem * subTo, toConnectorItem->connectedToItems()) { - allTo.insert(subTo); + if(!allToList.contains(toConnectorItem)) { + allToList.append(toConnectorItem); } } - allTo.remove(whichConnectorItem); - // TODO: this could all be determined once at mouse press time + for (int i = 0; i < allToList.size(); i++) { + ConnectorItem * conItem = allToList.at(i); + foreach(ConnectorItem * toConnectorItem, conItem->connectedToItems()) { + Wire * chainedWire = qobject_cast(toConnectorItem->attachedTo()); + if (chainedWire == NULL) continue; + + if(!allToList.contains(toConnectorItem)) { + allToList.append(toConnectorItem); + } + } + } + QSet allTo(allToList.begin(), allToList.end());; + + // TODO: this could all be determined once at mouse press time if (allTo.count() == 0) { // dragging one end of the wire @@ -684,9 +693,12 @@ void Wire::mouseMoveEventAux(QPointF eventPos, Qt::KeyboardModifiers modifiers) } else { // dragging a bendpoint + DebugDialog::debug("dragging a bendpoint"); + DebugDialog::debug(QString("CON0 %1 CON1 %2").arg(this->connector0()->connectedToItems().count()).arg(this->connector0()->connectedToItems().count())); foreach (ConnectorItem * toConnectorItem, allTo) { Wire * chained = qobject_cast(toConnectorItem->attachedTo()); if (chained) { + DebugDialog::debug("dragging a bendpoint123"); chained->simpleConnectedMoved(whichConnectorItem, toConnectorItem); } } From 580a8c4d02f88783f3a8636e22bf49d9d295c4d2 Mon Sep 17 00:00:00 2001 From: afaina Date: Sun, 27 Mar 2022 22:15:48 +0200 Subject: [PATCH 2/4] Improvements to the connectors status color (red=unconnected, green=connected). Fixes #3933 and #3827 Now, when an item is connected to the breadboard, only the holes of the breadboard that are connected are in green; a wire connecting two holes of the breadboard has both ends in green. --- src/connectors/connectoritem.cpp | 11 ++++++----- src/connectors/connectoritem.h | 2 +- src/items/wire.cpp | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/connectors/connectoritem.cpp b/src/connectors/connectoritem.cpp index 7494ebb5a..be192d92a 100644 --- a/src/connectors/connectoritem.cpp +++ b/src/connectors/connectoritem.cpp @@ -523,13 +523,14 @@ void ConnectorItem::restoreColor(QList & visited) QList connectorItems; connectorItems.append(this); - collectEqualPotential(connectorItems, true, getSkipFlags()); + collectEqualPotential(connectorItems, true, getSkipFlags(), false); visited.append(connectorItems); - QSet attachedTo; + + QSet attachedTo; foreach (ConnectorItem * connectorItem, connectorItems) { if (connectorItem->isEverVisible()) { if (connectorItem->attachedToItemType() != ModelPart::Wire) { - attachedTo.insert(connectorItem->attachedTo()->layerKinChief()); + attachedTo.insert(connectorItem); } } } @@ -1315,7 +1316,7 @@ bool ConnectorItem::isConnectedToPart() { * @param[in] skipFlags filter for the types of wires that are not to be included */ void ConnectorItem::collectEqualPotential(QList &connectorItems, - bool crossLayers, ViewGeometry::WireFlags skipFlags) + bool crossLayers, ViewGeometry::WireFlags skipFlags, bool followBuses) { // take a local (temporary working) copy of the supplied list, and wipe the original QList tempItems = connectorItems; @@ -1365,7 +1366,7 @@ void ConnectorItem::collectEqualPotential(QList &connectorItems // When the kept connector item is part of a bus, include all of the other // connectors on the bus in the list being processed Bus *bus = connectorItem->bus(); - if (bus) { + if (bus && (followBuses||fromWire)) { QList busConnectedItems; connectorItem->attachedTo()->busConnectorItems(bus, connectorItem, busConnectedItems); #ifndef QT_NO_DEBUG diff --git a/src/connectors/connectoritem.h b/src/connectors/connectoritem.h index 04faad5b3..4b5fdef27 100644 --- a/src/connectors/connectoritem.h +++ b/src/connectors/connectoritem.h @@ -235,7 +235,7 @@ class ConnectorItem : public NonConnectorItem, public CursorKeyListener static void collectPart(ConnectorItem * connectorItem, QList & partsConnectors, ViewLayer::ViewLayerPlacement); public: - static void collectEqualPotential(QList & connectorItems, bool crossLayers, ViewGeometry::WireFlags skipFlags); + static void collectEqualPotential(QList & connectorItems, bool crossLayers, ViewGeometry::WireFlags skipFlags, bool followBuses = true); static void collectParts(QList & connectorItems, QList & partsConnectors, bool includeSymbols, ViewLayer::ViewLayerPlacement); static void clearEqualPotentialDisplay(); static bool isGrounded(ConnectorItem * c1, ConnectorItem * c2); diff --git a/src/items/wire.cpp b/src/items/wire.cpp index c18c53883..4a51ea956 100644 --- a/src/items/wire.cpp +++ b/src/items/wire.cpp @@ -622,7 +622,7 @@ void Wire::mouseMoveEventAux(QPointF eventPos, Qt::KeyboardModifiers modifiers) } } - QSet allTo(allToList.begin(), allToList.end());; + QSet allTo(allToList.begin(), allToList.end()); // TODO: this could all be determined once at mouse press time if (allTo.count() == 0) { From 955c1d314f80adc2c989c9f66189c40055390334 Mon Sep 17 00:00:00 2001 From: afaina Date: Fri, 19 May 2023 19:24:06 +0200 Subject: [PATCH 3/4] fixed problem in PCB view. There are two connectors on top of each other in the PCB. Thus, we need to remove the opposite connector. --- src/connectors/connectoritem.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/connectors/connectoritem.cpp b/src/connectors/connectoritem.cpp index be192d92a..9989d4c3a 100644 --- a/src/connectors/connectoritem.cpp +++ b/src/connectors/connectoritem.cpp @@ -535,6 +535,10 @@ void ConnectorItem::restoreColor(QList & visited) } } + //In PCB view, there are two connectors on top of each other. + //This line removes the other one which is in the opposite layer. + attachedTo.remove(this->getCrossLayerConnectorItem()); + foreach (ConnectorItem * connectorItem, connectorItems) { if (connectorItem->isEverVisible()) { //QString how; From 9f99984db54c204e1988a322677b2229735a4d3e Mon Sep 17 00:00:00 2001 From: afaina Date: Sat, 20 May 2023 01:21:48 +0200 Subject: [PATCH 4/4] fixes issue with previous commit. We only add one connector from the pad stack (top or bottom) to the list of connected connectors. The previous commit only worked if the function was called from a connector in a pad stack. If the connector was from a trace, then we were still adding the two connectors of the pad stack. --- src/connectors/connectoritem.cpp | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/src/connectors/connectoritem.cpp b/src/connectors/connectoritem.cpp index 9989d4c3a..aff72a1c4 100644 --- a/src/connectors/connectoritem.cpp +++ b/src/connectors/connectoritem.cpp @@ -530,15 +530,14 @@ void ConnectorItem::restoreColor(QList & visited) foreach (ConnectorItem * connectorItem, connectorItems) { if (connectorItem->isEverVisible()) { if (connectorItem->attachedToItemType() != ModelPart::Wire) { - attachedTo.insert(connectorItem); + //For PCB pad stacks: Only add one connector to the attachedTo list (top or bottom copper) + if(!attachedTo.contains(connectorItem->getCrossLayerConnectorItem())) { + attachedTo.insert(connectorItem); + } } } } - //In PCB view, there are two connectors on top of each other. - //This line removes the other one which is in the opposite layer. - attachedTo.remove(this->getCrossLayerConnectorItem()); - foreach (ConnectorItem * connectorItem, connectorItems) { if (connectorItem->isEverVisible()) { //QString how; @@ -559,7 +558,24 @@ void ConnectorItem::restoreColor(QList & visited) } } } - + if (this->attachedToViewID() == 3) { + DebugDialog::debug(QString("FAI restore color PCB equalPotential: %1 attachedTo: %2") + .arg(connectorItems.count()) + .arg(attachedTo.count()) + ); + for(ConnectorItem * c : connectorItems) + DebugDialog::debug(QString("equalPotential conn, title: %1 %2 %3") + .arg(c->attachedToTitle()) + .arg(c->attachedTo()->label()) + .arg(c->attachedTo()->viewLayerID()) + ); + for(ConnectorItem * c : attachedTo) + DebugDialog::debug(QString("attachedTo conn, title: %1 %2 %3") + .arg(c->attachedToTitle()) + .arg(c->attachedTo()->label()) + .arg(c->attachedTo()->viewLayerID()) + ); + } /* DebugDialog::debug(QString("restore color dobus:%1 bccount:%2 docross:%3 cid:'%4' '%5' id:%6 '%7' vid:%8 vlid:%9 %10")