From 01aca27cd1b04fbb5efae964dd97a4c95d4532b1 Mon Sep 17 00:00:00 2001 From: hagantsa Date: Mon, 25 Nov 2024 13:59:20 +0200 Subject: [PATCH] [CORRECTIVE] Fix space and map positioning, extension item dimensions --- .../MemoryDesigner/MainMemoryGraphicsItem.cpp | 48 +++++++++---------- .../MemoryDesigner/MemoryCollisionItem.cpp | 42 ++-------------- .../MemoryConnectionHandler.cpp | 17 ++++--- .../MemoryDesignerConstants.cpp | 4 +- .../MemoryDesigner/MemoryDesignerConstants.h | 2 +- version.h | 16 +++---- 6 files changed, 49 insertions(+), 80 deletions(-) diff --git a/editors/MemoryDesigner/MainMemoryGraphicsItem.cpp b/editors/MemoryDesigner/MainMemoryGraphicsItem.cpp index 714fa6385..c9c928268 100644 --- a/editors/MemoryDesigner/MainMemoryGraphicsItem.cpp +++ b/editors/MemoryDesigner/MainMemoryGraphicsItem.cpp @@ -240,34 +240,32 @@ bool MainMemoryGraphicsItem::labelCollidesWithRangeLabels(QGraphicsTextItem* lab //----------------------------------------------------------------------------- void MainMemoryGraphicsItem::createOverlappingConnectionMarkers() { - if (getMemoryConnections().size() > 1) + auto memConnections = getMemoryConnections(); + + if (memConnections.size() < 2) + return; + + for (auto const& selectedItem : memConnections) { - QMultiMapIterator connectionIterator(getMemoryConnections()); - while (connectionIterator.hasNext()) + for (auto const& comparisonItem : memConnections) { - connectionIterator.next(); - - QMultiMapIterator comparisonIterator(connectionIterator); - while (comparisonIterator.hasNext()) + if (!selectedItem || !comparisonItem || selectedItem == comparisonItem) { - comparisonIterator.next(); - - MemoryConnectionItem* selectedItem = connectionIterator.value(); - MemoryConnectionItem* comparisonItem = comparisonIterator.value(); + continue; + } - QRectF connectionRect = selectedItem->sceneBoundingRect(); - QRectF comparisonRect = comparisonItem->sceneBoundingRect(); + QRectF connectionRect = selectedItem->sceneBoundingRect(); + QRectF comparisonRect = comparisonItem->sceneBoundingRect(); - if (selectedItem && comparisonItem && selectedItem != comparisonItem && - selectedItem->getConnectionStartItem() == this && - comparisonItem->getConnectionStartItem() == this && - MemoryDesignerConstants::itemOverlapsAnotherItem(connectionRect, - selectedItem->pen().width(), comparisonRect, comparisonItem->pen().width())) - { - MemoryCollisionItem* newCollisionItem = - new MemoryCollisionItem(selectedItem, comparisonItem, scene()); - memoryCollisions_.append(newCollisionItem); - } + if (selectedItem->getConnectionStartItem() == this && + comparisonItem->getConnectionStartItem() == this && + MemoryDesignerConstants::itemOverlapsAnotherItem(connectionRect, + selectedItem->pen().width(), comparisonRect, comparisonItem->pen().width()) && + connectionRect.width() < comparisonRect.width()) + { + MemoryCollisionItem* newCollisionItem = + new MemoryCollisionItem(selectedItem, comparisonItem, scene()); + memoryCollisions_.append(newCollisionItem); } } } @@ -574,8 +572,8 @@ void MainMemoryGraphicsItem::extendMemoryItem() if (connectionsAreBeyond) { qreal positionX = itemTopLeft.x() + lineWidth; - qreal extensionWidth = itemLowRight.x() - itemTopLeft.x() - lineWidth; - qreal positionY = extensionTop; + qreal extensionWidth = itemLowRight.x() - itemTopLeft.x() - 2*lineWidth; + qreal positionY = extensionTop - lineWidth; qreal extensionHeight = extensionLow - extensionTop; auto extensionItem = new MemoryExtensionGraphicsItem(positionX, positionY, extensionWidth, extensionHeight, getContainingInstance(), this); diff --git a/editors/MemoryDesigner/MemoryCollisionItem.cpp b/editors/MemoryDesigner/MemoryCollisionItem.cpp index bf8235ab7..c72d10773 100644 --- a/editors/MemoryDesigner/MemoryCollisionItem.cpp +++ b/editors/MemoryDesigner/MemoryCollisionItem.cpp @@ -58,43 +58,9 @@ MemoryCollisionItem::~MemoryCollisionItem() //----------------------------------------------------------------------------- void MemoryCollisionItem::setCollisionBrush() { - qreal mainCollisionOpacity = 0.4; - - QVector collidingCollisionItems; - foreach (QGraphicsItem* collidingItem, collidingItems()) - { - MemoryCollisionItem* memoryCollisionItem = dynamic_cast(collidingItem); - if (memoryCollisionItem && memoryCollisionItem != this) - { - collidingCollisionItems.append(memoryCollisionItem); - } - } - - if (!collidingCollisionItems.isEmpty()) - { - collidingCollisionItems.removeFirst(); - - mainCollisionOpacity = 0.3; - qreal collisionOpacity = mainCollisionOpacity; - - int collisionMarker = collidingCollisionItems.size(); - for (int collisionIndex = collidingCollisionItems.size() - 1; collisionIndex >= 0; --collisionIndex) - { - MemoryCollisionItem* collidingItem = collidingCollisionItems.at(collisionIndex); - - if (collidingItem->boundingRect().top() == boundingRect().top() && - collidingItem->boundingRect().bottom() == boundingRect().bottom()) - { - collisionMarker = collisionMarker - 1; - collisionOpacity = collisionOpacity / (collidingCollisionItems.size() - collisionMarker); - collidingItem->setOpacity(collisionOpacity); - } - } - } - QBrush collisionBrush(KactusColors::MISSING_COMPONENT); setBrush(collisionBrush); - setOpacity(mainCollisionOpacity); + setOpacity(0.2); } //----------------------------------------------------------------------------- @@ -151,7 +117,7 @@ void MemoryCollisionItem::setLabels() QVector collidingColumns; - foreach (QGraphicsItem* collidingItem, collidingItems()) + for (QGraphicsItem* collidingItem : collidingItems()) { MemoryMapGraphicsItem* mapGraphicsItem = dynamic_cast(collidingItem); QGraphicsRectItem* extensionItem = dynamic_cast(collidingItem); @@ -207,7 +173,7 @@ void MemoryCollisionItem::reDrawCollision() setLabels(); } - +#include //----------------------------------------------------------------------------- // Function: MemoryCollisionItem::setRectangle() //----------------------------------------------------------------------------- @@ -227,6 +193,6 @@ void MemoryCollisionItem::setRectangle() qreal itemHeight = endY - startY; QPointF spaceItemStartPoint (startX, startY); - + setRect(spaceItemStartPoint.x(), spaceItemStartPoint.y(), itemWidth, itemHeight - 1); } \ No newline at end of file diff --git a/editors/MemoryDesigner/MemoryConnectionHandler.cpp b/editors/MemoryDesigner/MemoryConnectionHandler.cpp index c488ed7e2..fcadbae41 100644 --- a/editors/MemoryDesigner/MemoryConnectionHandler.cpp +++ b/editors/MemoryDesigner/MemoryConnectionHandler.cpp @@ -251,7 +251,10 @@ QVector MemoryConnectionHandler::createConnectionSet(QSha highestItemInSet = getHighestPlacedItemInSet(highestItemInSet, placedMapItems); auto yMovement = spaceYPlacement - highestItemInSet->scenePos().y(); - highestItemInSet->moveItemAndConnectedItems(yMovement); + + // Move entire group of connections to sensible vertical position. + // Round movement up to integer, but std::ceil instead of qCeil to preserve type. + highestItemInSet->moveItemAndConnectedItems(std::ceil(yMovement)); auto connections = compressConnectedMemoryItems(placedSpaceItems, placedMapItems); @@ -303,6 +306,12 @@ void MemoryConnectionHandler::createConnectionFromSet(Path const& connectionPath placedSpaceItems->prepend(connectionStartItem); } + // If end item has already been placed -> shared endpoint with other path -> set position of start item accordingly + if (placedMapItems->contains(connectionEndItem)) + { + positionSpaceItem(connectionStartItem, connectionEndItem->scenePos().y() - yTransfer); + } + if (!filterAddressSpaceChains_) { // Start placing address spaces from left to right @@ -475,11 +484,7 @@ qreal MemoryConnectionHandler::getConnectionInitialTransferY(quint64 baseAddress yTransfer += memoryMapBaseAddress; } - if (filterAddressSpaceChains_) - { - yTransfer += spaceChainConnectionBaseAddress; - } - + yTransfer += spaceChainConnectionBaseAddress; yTransfer = yTransfer * MemoryDesignerConstants::RANGEINTERVAL; return yTransfer; diff --git a/editors/MemoryDesigner/MemoryDesignerConstants.cpp b/editors/MemoryDesigner/MemoryDesignerConstants.cpp index 2397394ac..a2dcfcfc7 100644 --- a/editors/MemoryDesigner/MemoryDesignerConstants.cpp +++ b/editors/MemoryDesigner/MemoryDesignerConstants.cpp @@ -18,8 +18,8 @@ //----------------------------------------------------------------------------- // Function: MemoryDesignerConstants::itemOverlapsAnotherItem() //----------------------------------------------------------------------------- -bool MemoryDesignerConstants::itemOverlapsAnotherItem(QRectF firstRectangle, int firstLineWidth, - QRectF secondRectangle, int secondLineWidth) +bool MemoryDesignerConstants::itemOverlapsAnotherItem(QRectF const& firstRectangle, int firstLineWidth, + QRectF const& secondRectangle, int secondLineWidth) { qreal firstItemTop = firstRectangle.topLeft().y() + firstLineWidth; qreal firstItemLow = firstRectangle.bottomLeft().y() - firstLineWidth; diff --git a/editors/MemoryDesigner/MemoryDesignerConstants.h b/editors/MemoryDesigner/MemoryDesignerConstants.h index dd1b3755a..386758d62 100644 --- a/editors/MemoryDesigner/MemoryDesignerConstants.h +++ b/editors/MemoryDesigner/MemoryDesignerConstants.h @@ -70,7 +70,7 @@ namespace MemoryDesignerConstants * @param [in] secondRectangle The bounding rectangle of the comparison item. * @param [in] secondLineWidth Line width of the comparison item. */ - bool itemOverlapsAnotherItem(QRectF firstRectangle, int firstLineWidth, QRectF secondRectangle, + bool itemOverlapsAnotherItem(QRectF const& firstRectangle, int firstLineWidth, QRectF const& secondRectangle, int secondLineWidth); /*! diff --git a/version.h b/version.h index c253f8ad0..18d523561 100644 --- a/version.h +++ b/version.h @@ -10,20 +10,20 @@ #ifndef VERSIONNO__H #define VERSIONNO__H -#define VERSION_FULL 3.13.156.0 +#define VERSION_FULL 3.13.218.0 #define VERSION_BASEYEAR 0 -#define VERSION_DATE "2024-11-18" -#define VERSION_TIME "13:58:32" +#define VERSION_DATE "2024-12-03" +#define VERSION_TIME "14:02:16" #define VERSION_MAJOR 3 #define VERSION_MINOR 13 -#define VERSION_BUILDNO 156 +#define VERSION_BUILDNO 218 #define VERSION_EXTEND 0 -#define VERSION_FILE 3,13,156,0 -#define VERSION_PRODUCT 3,13,156,0 -#define VERSION_FILESTR "3,13,156,0" -#define VERSION_PRODUCTSTR "3,13,156,0" +#define VERSION_FILE 3,13,218,0 +#define VERSION_PRODUCT 3,13,218,0 +#define VERSION_FILESTR "3,13,218,0" +#define VERSION_PRODUCTSTR "3,13,218,0" #endif