Skip to content

Commit

Permalink
[CORRECTIVE] Fix space and map positioning, extension item dimensions
Browse files Browse the repository at this point in the history
  • Loading branch information
hagantsa committed Dec 3, 2024
1 parent b84da94 commit 01aca27
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 80 deletions.
48 changes: 23 additions & 25 deletions editors/MemoryDesigner/MainMemoryGraphicsItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<quint64, MemoryConnectionItem*> connectionIterator(getMemoryConnections());
while (connectionIterator.hasNext())
for (auto const& comparisonItem : memConnections)
{
connectionIterator.next();

QMultiMapIterator<quint64, MemoryConnectionItem*> 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);
}
}
}
Expand Down Expand Up @@ -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);
Expand Down
42 changes: 4 additions & 38 deletions editors/MemoryDesigner/MemoryCollisionItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,43 +58,9 @@ MemoryCollisionItem::~MemoryCollisionItem()
//-----------------------------------------------------------------------------
void MemoryCollisionItem::setCollisionBrush()
{
qreal mainCollisionOpacity = 0.4;

QVector<MemoryCollisionItem*> collidingCollisionItems;
foreach (QGraphicsItem* collidingItem, collidingItems())
{
MemoryCollisionItem* memoryCollisionItem = dynamic_cast<MemoryCollisionItem*>(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);
}

//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -151,7 +117,7 @@ void MemoryCollisionItem::setLabels()

QVector<MemoryColumn*> collidingColumns;

foreach (QGraphicsItem* collidingItem, collidingItems())
for (QGraphicsItem* collidingItem : collidingItems())
{
MemoryMapGraphicsItem* mapGraphicsItem = dynamic_cast<MemoryMapGraphicsItem*>(collidingItem);
QGraphicsRectItem* extensionItem = dynamic_cast<QGraphicsRectItem*>(collidingItem);
Expand Down Expand Up @@ -207,7 +173,7 @@ void MemoryCollisionItem::reDrawCollision()

setLabels();
}

#include <QPainter>
//-----------------------------------------------------------------------------
// Function: MemoryCollisionItem::setRectangle()
//-----------------------------------------------------------------------------
Expand All @@ -227,6 +193,6 @@ void MemoryCollisionItem::setRectangle()
qreal itemHeight = endY - startY;

QPointF spaceItemStartPoint (startX, startY);

setRect(spaceItemStartPoint.x(), spaceItemStartPoint.y(), itemWidth, itemHeight - 1);
}
17 changes: 11 additions & 6 deletions editors/MemoryDesigner/MemoryConnectionHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,10 @@ QVector<MemoryConnectionItem*> 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);

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -475,11 +484,7 @@ qreal MemoryConnectionHandler::getConnectionInitialTransferY(quint64 baseAddress
yTransfer += memoryMapBaseAddress;
}

if (filterAddressSpaceChains_)
{
yTransfer += spaceChainConnectionBaseAddress;
}

yTransfer += spaceChainConnectionBaseAddress;
yTransfer = yTransfer * MemoryDesignerConstants::RANGEINTERVAL;

return yTransfer;
Expand Down
4 changes: 2 additions & 2 deletions editors/MemoryDesigner/MemoryDesignerConstants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion editors/MemoryDesigner/MemoryDesignerConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

/*!
Expand Down
16 changes: 8 additions & 8 deletions version.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 01aca27

Please sign in to comment.