optimize editor bay layout

This commit is contained in:
baiYue 2026-06-02 11:50:45 +08:00
parent 3ee42e2eed
commit 1da45b24e6
3 changed files with 12 additions and 6 deletions

View File

@ -187,6 +187,8 @@ void DiagramLayoutEngine::layoutMainRouteInternal(
int oppositeFlag = static_cast<int>(DirectionManager::getOpposite(mainDir));
bool isHorizontal = DirectionManager::isHorizontal(mainDir);
int spacing = isHorizontal ? config.horizontalSpacing() : config.verticalSpacing();
if(components.size() == 2) //两个元件的主线拉长(特殊处理)
spacing *= 2;
// 计算分段索引
int nSeg = components.size() - 1; // 实际段数
@ -215,7 +217,11 @@ void DiagramLayoutEngine::layoutMainRouteInternal(
delta.setY(nSegIndex * spacing);
}
int rotate = DirectionManager::getRotationAngle(mainDir);
int rotate = 0;
if(i == 0 && (compo.nType == 6)) //单port元件队首反向
rotate = DirectionManager::getRotationAngle(DirectionManager::getOpposite(mainDir));
else
DirectionManager::getOpposite(mainDir);
// 更新组件
updateComponent(compo, dirMask, delta, rotate, context);

View File

@ -198,13 +198,13 @@ void FixedLayoutCalculator::calculateBlockPositionsInContainer(DiagramEditorStru
}*/
if (layer == 0) { // 上间隔
center = QPointF(currentX + rec.width() * 0.5,
center = QPointF(currentX + rec.width() * 0.5 + centerOffset.x(),
midUpY - rec.height() * 0.5 + centerOffset.y() - Constants::EDITOR_ITEM_HEIGHT * 0.5);
} else if (layer == 3) { // 下间隔
center = QPointF(currentX + rec.width() * 0.5,
center = QPointF(currentX + rec.width() * 0.5 + centerOffset.x(),
midDownY + rec.height() * 0.5 + centerOffset.y() + Constants::EDITOR_ITEM_HEIGHT * 0.5);
}
currentX += rec.width();
currentX += rec.width() + CONTAINER_H_SPACING*0.5;
}
// 变压器不在这里处理

View File

@ -201,11 +201,11 @@ void BaseModel::selectNormalDevicePort(
QMap<QString, ItemPort*> mapDest = pDest->getPorts();
for (auto& port : mapSrc)
if (port->getType() == T_lineOut)
if (port->getType() == T_lineOut || port->getType() == T_lineInOut)
pSrcPort = port;
for (auto& port : mapDest)
if (port->getType() == T_lineIn)
if (port->getType() == T_lineIn || port->getType() == T_lineInOut)
pDestPort = port;
}
}