optimize editor bay layout
This commit is contained in:
parent
3ee42e2eed
commit
1da45b24e6
|
|
@ -187,6 +187,8 @@ void DiagramLayoutEngine::layoutMainRouteInternal(
|
||||||
int oppositeFlag = static_cast<int>(DirectionManager::getOpposite(mainDir));
|
int oppositeFlag = static_cast<int>(DirectionManager::getOpposite(mainDir));
|
||||||
bool isHorizontal = DirectionManager::isHorizontal(mainDir);
|
bool isHorizontal = DirectionManager::isHorizontal(mainDir);
|
||||||
int spacing = isHorizontal ? config.horizontalSpacing() : config.verticalSpacing();
|
int spacing = isHorizontal ? config.horizontalSpacing() : config.verticalSpacing();
|
||||||
|
if(components.size() == 2) //两个元件的主线拉长(特殊处理)
|
||||||
|
spacing *= 2;
|
||||||
|
|
||||||
// 计算分段索引
|
// 计算分段索引
|
||||||
int nSeg = components.size() - 1; // 实际段数
|
int nSeg = components.size() - 1; // 实际段数
|
||||||
|
|
@ -215,7 +217,11 @@ void DiagramLayoutEngine::layoutMainRouteInternal(
|
||||||
delta.setY(nSegIndex * spacing);
|
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);
|
updateComponent(compo, dirMask, delta, rotate, context);
|
||||||
|
|
|
||||||
|
|
@ -198,13 +198,13 @@ void FixedLayoutCalculator::calculateBlockPositionsInContainer(DiagramEditorStru
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
if (layer == 0) { // 上间隔
|
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);
|
midUpY - rec.height() * 0.5 + centerOffset.y() - Constants::EDITOR_ITEM_HEIGHT * 0.5);
|
||||||
} else if (layer == 3) { // 下间隔
|
} 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);
|
midDownY + rec.height() * 0.5 + centerOffset.y() + Constants::EDITOR_ITEM_HEIGHT * 0.5);
|
||||||
}
|
}
|
||||||
currentX += rec.width();
|
currentX += rec.width() + CONTAINER_H_SPACING*0.5;
|
||||||
}
|
}
|
||||||
// 变压器不在这里处理
|
// 变压器不在这里处理
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -201,11 +201,11 @@ void BaseModel::selectNormalDevicePort(
|
||||||
QMap<QString, ItemPort*> mapDest = pDest->getPorts();
|
QMap<QString, ItemPort*> mapDest = pDest->getPorts();
|
||||||
|
|
||||||
for (auto& port : mapSrc)
|
for (auto& port : mapSrc)
|
||||||
if (port->getType() == T_lineOut)
|
if (port->getType() == T_lineOut || port->getType() == T_lineInOut)
|
||||||
pSrcPort = port;
|
pSrcPort = port;
|
||||||
|
|
||||||
for (auto& port : mapDest)
|
for (auto& port : mapDest)
|
||||||
if (port->getType() == T_lineIn)
|
if (port->getType() == T_lineIn || port->getType() == T_lineInOut)
|
||||||
pDestPort = port;
|
pDestPort = port;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue