fix editor component route reference
This commit is contained in:
parent
01ce273d68
commit
8fa87baafc
|
|
@ -102,7 +102,7 @@ public:
|
||||||
virtual BayType getBayType() {return nBayType;}
|
virtual BayType getBayType() {return nBayType;}
|
||||||
virtual void setBayInfo(DiagramEditorBayInfo info) {bayInfo = info;}
|
virtual void setBayInfo(DiagramEditorBayInfo info) {bayInfo = info;}
|
||||||
virtual int getBayLocate() {return nBayLocate;}
|
virtual int getBayLocate() {return nBayLocate;}
|
||||||
virtual void setBayLocate(int n) {nBayLocate = n;}
|
virtual void setBayLocate(int n) {nBayLocate = n;bayInfo.nLocate = n;}
|
||||||
virtual DiagramEditorBayInfo& getBayInfo(){return bayInfo;}
|
virtual DiagramEditorBayInfo& getBayInfo(){return bayInfo;}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,8 @@ public slots:
|
||||||
void onRouteEditClicked();
|
void onRouteEditClicked();
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent *);
|
void resizeEvent(QResizeEvent *);
|
||||||
|
private:
|
||||||
|
void removeRouteUsageFromDevices(const QStringList &deviceNames, const QString &routeName); //移除设备中的线路占用
|
||||||
private:
|
private:
|
||||||
Ui::diagramEditorBayDetailSettingDlg *ui;
|
Ui::diagramEditorBayDetailSettingDlg *ui;
|
||||||
DiagramEditorBayDetailAddDlg* _pAddDlg;
|
DiagramEditorBayDetailAddDlg* _pAddDlg;
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,8 @@ public slots:
|
||||||
void onRouteEditClicked();
|
void onRouteEditClicked();
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent *);
|
void resizeEvent(QResizeEvent *);
|
||||||
|
private:
|
||||||
|
void removeRouteUsageFromDevices(const QStringList &deviceNames, const QString &routeName); //移除设备中的线路占用
|
||||||
private:
|
private:
|
||||||
Ui::diagramEditorTransDetailSettingDlg *ui;
|
Ui::diagramEditorTransDetailSettingDlg *ui;
|
||||||
DiagramEditorTransDetailAddDlg* _pAddDlg;
|
DiagramEditorTransDetailAddDlg* _pAddDlg;
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ public:
|
||||||
QMultiMap<int,QUuid> generateOutConnection(QList<DiagramEditorComponentInfo>,QList<HierarchyItem>&,int nTypeTransCon,int nPos = 0,DiagramEditorBaseBlock* pParent = nullptr); //生成外部连接(手动bind的连接)relation:层级关系引用 nTypeTransCon变压器连线类型,1中性点连接2外部连接,nPos中性点连接时的位置
|
QMultiMap<int,QUuid> generateOutConnection(QList<DiagramEditorComponentInfo>,QList<HierarchyItem>&,int nTypeTransCon,int nPos = 0,DiagramEditorBaseBlock* pParent = nullptr); //生成外部连接(手动bind的连接)relation:层级关系引用 nTypeTransCon变压器连线类型,1中性点连接2外部连接,nPos中性点连接时的位置
|
||||||
QRectF updateTarget(QMap<QString,DiagramEditorRouteInfo>&,QMap<QString,DiagramEditorComponentInfo>&,QMap<QString, QMap<int,DirectionOccupancyRecord>>& directionOccupancyMap,QMap<QString, DirectionOccupancyRouteInfo>& routeDirectionMap,int nLayout,int nSource,bool saveToModel = true); //更新位置 nLayout主次朝向:8421,8421 上下左右,上下左右 nSource:0间隔1变压器 regenerate重新生成标志 saveToModel:生成到模型或map
|
QRectF updateTarget(QMap<QString,DiagramEditorRouteInfo>&,QMap<QString,DiagramEditorComponentInfo>&,QMap<QString, QMap<int,DirectionOccupancyRecord>>& directionOccupancyMap,QMap<QString, DirectionOccupancyRouteInfo>& routeDirectionMap,int nLayout,int nSource,bool saveToModel = true); //更新位置 nLayout主次朝向:8421,8421 上下左右,上下左右 nSource:0间隔1变压器 regenerate重新生成标志 saveToModel:生成到模型或map
|
||||||
void clearCompoDir(QMap<QString,DiagramEditorRouteInfo>&,QMap<QString,DiagramEditorComponentInfo>&,QMap<QString, QMap<int,DirectionOccupancyRecord>>& directionOccupancyMap,QMap<QString, DirectionOccupancyRouteInfo>& routeDirectionMap,int nSource); //清空component中的dir(updateTarget前调用)
|
void clearCompoDir(QMap<QString,DiagramEditorRouteInfo>&,QMap<QString,DiagramEditorComponentInfo>&,QMap<QString, QMap<int,DirectionOccupancyRecord>>& directionOccupancyMap,QMap<QString, DirectionOccupancyRouteInfo>& routeDirectionMap,int nSource); //清空component中的dir(updateTarget前调用)
|
||||||
void removeRouteDir(QMap<QString,DiagramEditorRouteInfo>&,QMap<QString,DiagramEditorComponentInfo>&,QMap<QString, QMap<int,DirectionOccupancyRecord>>& directionOccupancyMap,QMap<QString, DirectionOccupancyRouteInfo>& routeDirectionMap,int nSource); //删除某条线路上的方向占用
|
void removeRouteDir(const QString&,QMap<QString,DiagramEditorComponentInfo>&,QMap<QString, QMap<int,DirectionOccupancyRecord>>& directionOccupancyMap,QMap<QString, DirectionOccupancyRouteInfo>& routeDirectionMap,int nSource); //删除某条线路上的方向占用
|
||||||
|
|
||||||
QList<DiagramEditorComponentInfo> getRouteItemInfoList(QMap<QString,DiagramEditorComponentInfo>,QMap<QString,DiagramEditorRouteInfo>); //返回线路中包含的设备信息列表
|
QList<DiagramEditorComponentInfo> getRouteItemInfoList(QMap<QString,DiagramEditorComponentInfo>,QMap<QString,DiagramEditorRouteInfo>); //返回线路中包含的设备信息列表
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -342,10 +342,17 @@ void DiagramEditorBayDetailSettingDlg::onRouteDeleteClicked()
|
||||||
}
|
}
|
||||||
|
|
||||||
onRouteModified(_curBayInfo.mapRoute,_curBayInfo.routeOrder,sName,true);
|
onRouteModified(_curBayInfo.mapRoute,_curBayInfo.routeOrder,sName,true);
|
||||||
|
auto info = _curBayInfo.mapRoute.value(sName);
|
||||||
|
QStringList lst;
|
||||||
|
for(auto &compo:info.lstCompo){
|
||||||
|
lst.append(compo.sName);
|
||||||
|
}
|
||||||
|
removeRouteUsageFromDevices(lst,sName);
|
||||||
_curBayInfo.mapRoute.remove(sName); //同步移除数据
|
_curBayInfo.mapRoute.remove(sName); //同步移除数据
|
||||||
_curBayInfo.routeOrder.removeAll(sName); //移除排序
|
_curBayInfo.routeOrder.removeAll(sName); //移除排序
|
||||||
|
|
||||||
|
_pModel->removeRouteDir(sName,_curBayInfo.mapComponent,_curBayInfo.directionOccupancyMap,_curBayInfo.routeDirectionMap,0);
|
||||||
|
|
||||||
for(int i = 0;i < _routeModel->rowCount();++i){ //重新加载所有父路线
|
for(int i = 0;i < _routeModel->rowCount();++i){ //重新加载所有父路线
|
||||||
QStandardItem *itemName = _routeModel->item(i, 0);
|
QStandardItem *itemName = _routeModel->item(i, 0);
|
||||||
for(auto& route:_curBayInfo.mapRoute){
|
for(auto& route:_curBayInfo.mapRoute){
|
||||||
|
|
@ -471,3 +478,52 @@ void DiagramEditorBayDetailSettingDlg::resizeEvent(QResizeEvent *) {
|
||||||
_pSizeGrip->move(width() - _pSizeGrip->width(),
|
_pSizeGrip->move(width() - _pSizeGrip->width(),
|
||||||
height() - _pSizeGrip->height());
|
height() - _pSizeGrip->height());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DiagramEditorBayDetailSettingDlg::removeRouteUsageFromDevices(const QStringList &deviceNames, const QString &routeName)
|
||||||
|
{
|
||||||
|
if (deviceNames.isEmpty() || routeName.isEmpty()) {
|
||||||
|
qWarning() << "设备名列表或路线名为空";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pCompoModel = _compoModel;
|
||||||
|
if (!pCompoModel) {
|
||||||
|
qWarning() << "组件模型为空";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 1. 设备名去重
|
||||||
|
QSet<QString> uniqueDeviceNames(deviceNames.begin(),deviceNames.end());
|
||||||
|
|
||||||
|
// 2. 遍历组件模型
|
||||||
|
for (int row = 0; row < pCompoModel->rowCount(); ++row) {
|
||||||
|
QStandardItem *itemName = pCompoModel->item(row, 1);
|
||||||
|
if (!itemName) continue;
|
||||||
|
|
||||||
|
QString currentDevice = itemName->text();
|
||||||
|
if (uniqueDeviceNames.contains(currentDevice)) {
|
||||||
|
// 3. 移除路线占用
|
||||||
|
QStandardItem *itemUsed = pCompoModel->item(row, 4);
|
||||||
|
if (!itemUsed) continue;
|
||||||
|
|
||||||
|
QString usageText = itemUsed->text();
|
||||||
|
QStringList routes = usageText.split(",", Qt::SkipEmptyParts);
|
||||||
|
|
||||||
|
int beforeCount = routes.count();
|
||||||
|
routes.removeAll(routeName);
|
||||||
|
|
||||||
|
// 4. 只有当有实际变化时才更新
|
||||||
|
if (routes.count() != beforeCount) {
|
||||||
|
itemUsed->setText(routes.isEmpty() ? "" : routes.join(","));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5. 从待处理集合中移除
|
||||||
|
uniqueDeviceNames.remove(currentDevice);
|
||||||
|
|
||||||
|
// 6. 如果所有设备都已处理,提前结束
|
||||||
|
if (uniqueDeviceNames.isEmpty()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ void DiagramEditorBayPreviewDlg::showDlg(int nLayout)
|
||||||
}
|
}
|
||||||
auto& bayInfo = _pParent->getBayInfo();
|
auto& bayInfo = _pParent->getBayInfo();
|
||||||
_pParent->getModel()->clearCompoDir(bayInfo.mapRoute,bayInfo.mapComponent,bayInfo.directionOccupancyMap,bayInfo.routeDirectionMap,0);
|
_pParent->getModel()->clearCompoDir(bayInfo.mapRoute,bayInfo.mapComponent,bayInfo.directionOccupancyMap,bayInfo.routeDirectionMap,0);
|
||||||
_pParent->getModel()->updateTarget(_pParent->getBayInfo().mapRoute,_pParent->getBayInfo().mapComponent,bayInfo.directionOccupancyMap,bayInfo.routeDirectionMap,nDir,0);
|
_pParent->getModel()->updateTarget(bayInfo.mapRoute,bayInfo.mapComponent,bayInfo.directionOccupancyMap,bayInfo.routeDirectionMap,nDir,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramEditorBayPreviewDlg::setSceneRect(const QRect rec)
|
void DiagramEditorBayPreviewDlg::setSceneRect(const QRect rec)
|
||||||
|
|
|
||||||
|
|
@ -363,30 +363,27 @@ void DiagramEditorTransDetailAddDlg::onAddClicked()
|
||||||
|
|
||||||
for (int col = 0; col < Col_Count; ++col)
|
for (int col = 0; col < Col_Count; ++col)
|
||||||
{
|
{
|
||||||
QStandardItem *srcItem = pMainModel->item(row, col);
|
QStandardItem *sourceItem = pMainModel->item(row, col);
|
||||||
if (!srcItem)
|
if (sourceItem) {
|
||||||
{
|
// 创建深拷贝(重要!)
|
||||||
newRow.append(new QStandardItem());
|
if(col == 4){ //线路引用,特殊处理
|
||||||
continue;
|
QString strAllRoute = sourceItem->text();
|
||||||
}
|
QString strCurRoute = ui->le_routeName->text();
|
||||||
|
|
||||||
QStandardItem *newItem = srcItem->clone();
|
if(!strAllRoute.contains(strCurRoute)){ //第一个引用不加符号
|
||||||
|
if(strAllRoute.isEmpty())
|
||||||
// ===== 5. Route 字段特殊处理 =====
|
sourceItem->setText(strCurRoute);
|
||||||
if (col == Col_Route)
|
else
|
||||||
{
|
sourceItem->setText(strAllRoute+","+strCurRoute);
|
||||||
QString routeText = newItem->text();
|
}
|
||||||
|
|
||||||
if (!routeText.contains(curRoute))
|
|
||||||
{
|
|
||||||
if (routeText.isEmpty())
|
|
||||||
newItem->setText(curRoute);
|
|
||||||
else
|
|
||||||
newItem->setText(routeText + "," + curRoute);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
newRow.append(newItem);
|
QStandardItem *newItem = sourceItem->clone();
|
||||||
|
newRow.append(newItem);
|
||||||
|
} else {
|
||||||
|
// 如果单元格为空,创建空项目
|
||||||
|
newRow.append(new QStandardItem());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_selectedModel->appendRow(newRow);
|
_selectedModel->appendRow(newRow);
|
||||||
|
|
@ -597,7 +594,7 @@ void DiagramEditorTransDetailAddDlg::onCategoryChanged(const QString& str)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(str == "连接关系"){
|
else if(str == "连接关系"){
|
||||||
ui->cb_type->addItem("连接点",1);
|
ui->cb_type->addItem("连接点",0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -346,7 +346,12 @@ void DiagramEditorTransDetailSettingDlg::onRouteDeleteClicked()
|
||||||
_routeModels.value(n)->removeRow(row);
|
_routeModels.value(n)->removeRow(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
//_mapsRouteInfo.value(n).remove(sName); //同步移除数据
|
auto info = _transInfo.mapNeutral.value(n).mapRoute.value(sName);
|
||||||
|
QStringList lst;
|
||||||
|
for(auto &compo:info.lstCompo){
|
||||||
|
lst.append(compo.sName);
|
||||||
|
}
|
||||||
|
removeRouteUsageFromDevices(lst,sName);
|
||||||
_transInfo.mapNeutral.value(n).mapRoute.remove(sName); //同步移除数据
|
_transInfo.mapNeutral.value(n).mapRoute.remove(sName); //同步移除数据
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -434,3 +439,52 @@ void DiagramEditorTransDetailSettingDlg::resizeEvent(QResizeEvent *) {
|
||||||
_pSizeGrip->move(width() - _pSizeGrip->width(),
|
_pSizeGrip->move(width() - _pSizeGrip->width(),
|
||||||
height() - _pSizeGrip->height());
|
height() - _pSizeGrip->height());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DiagramEditorTransDetailSettingDlg::removeRouteUsageFromDevices(const QStringList &deviceNames, const QString &routeName)
|
||||||
|
{
|
||||||
|
if (deviceNames.isEmpty() || routeName.isEmpty()) {
|
||||||
|
qWarning() << "设备名列表或路线名为空";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pCompoModel = _compoModel;
|
||||||
|
if (!pCompoModel) {
|
||||||
|
qWarning() << "组件模型为空";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 1. 设备名去重
|
||||||
|
QSet<QString> uniqueDeviceNames(deviceNames.begin(),deviceNames.end());
|
||||||
|
|
||||||
|
// 2. 遍历组件模型
|
||||||
|
for (int row = 0; row < pCompoModel->rowCount(); ++row) {
|
||||||
|
QStandardItem *itemName = pCompoModel->item(row, 1);
|
||||||
|
if (!itemName) continue;
|
||||||
|
|
||||||
|
QString currentDevice = itemName->text();
|
||||||
|
if (uniqueDeviceNames.contains(currentDevice)) {
|
||||||
|
// 3. 移除路线占用
|
||||||
|
QStandardItem *itemUsed = pCompoModel->item(row, 4);
|
||||||
|
if (!itemUsed) continue;
|
||||||
|
|
||||||
|
QString usageText = itemUsed->text();
|
||||||
|
QStringList routes = usageText.split(",", Qt::SkipEmptyParts);
|
||||||
|
|
||||||
|
int beforeCount = routes.count();
|
||||||
|
routes.removeAll(routeName);
|
||||||
|
|
||||||
|
// 4. 只有当有实际变化时才更新
|
||||||
|
if (routes.count() != beforeCount) {
|
||||||
|
itemUsed->setText(routes.isEmpty() ? "" : routes.join(","));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5. 从待处理集合中移除
|
||||||
|
uniqueDeviceNames.remove(currentDevice);
|
||||||
|
|
||||||
|
// 6. 如果所有设备都已处理,提前结束
|
||||||
|
if (uniqueDeviceNames.isEmpty()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,8 @@ QRectF DiagramLayoutEngine::executeLayout(
|
||||||
compo.deltaPos = mapCatch[compo.sName].deltaPos;
|
compo.deltaPos = mapCatch[compo.sName].deltaPos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
directionOccupancyMap = context.directionOccupancyMap;
|
||||||
|
routeDirectionMap = context.routeDirectionMap;
|
||||||
|
|
||||||
// 4. 计算边界
|
// 4. 计算边界
|
||||||
if (!context.saveToModel) {
|
if (!context.saveToModel) {
|
||||||
|
|
|
||||||
|
|
@ -1352,12 +1352,16 @@ void DiagramEditorModel::clearCompoDir(QMap<QString,DiagramEditorRouteInfo>& dat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramEditorModel::removeRouteDir(QMap<QString,DiagramEditorRouteInfo>&,QMap<QString,DiagramEditorComponentInfo>&,QMap<QString, QMap<int,DirectionOccupancyRecord>>& directionOccupancyMap,
|
void DiagramEditorModel::removeRouteDir(const QString& routeId,QMap<QString,DiagramEditorComponentInfo>& components,QMap<QString, QMap<int,DirectionOccupancyRecord>>& directionOccupancyMap,
|
||||||
QMap<QString, DirectionOccupancyRouteInfo>& routeDirectionMap,int nSource)
|
QMap<QString, DirectionOccupancyRouteInfo>& routeDirectionMap,int nSource)
|
||||||
{
|
{
|
||||||
DiagramLayoutEngine engine(this);
|
DiagramLayoutEngine engine(this);
|
||||||
DiagramLayoutEngine::Context context;
|
DiagramLayoutEngine::Context context;
|
||||||
//engine.clearRouteDirectionOccupancy(routeId,context);
|
context.sourceId = nSource;
|
||||||
|
context.initComponentsCache(components);
|
||||||
|
context.initDirectionOccupancyCache(directionOccupancyMap);
|
||||||
|
context.initRouteDirectionMapCache(routeDirectionMap);
|
||||||
|
engine.clearRouteDirectionOccupancy(routeId,context);
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF DiagramEditorModel::updateTarget(
|
QRectF DiagramEditorModel::updateTarget(
|
||||||
|
|
|
||||||
|
|
@ -169,6 +169,10 @@ QMap<QUuid,DiagramEditorItemProperty*> BasePropertyManager::getEditorData() cons
|
||||||
|
|
||||||
void BasePropertyManager::clearEditorData()
|
void BasePropertyManager::clearEditorData()
|
||||||
{
|
{
|
||||||
|
for(auto& pTemp:m_editorTempData){
|
||||||
|
delete pTemp;
|
||||||
|
}
|
||||||
|
m_editorTempData.clear();
|
||||||
for(auto &pPro:m_editorData){
|
for(auto &pPro:m_editorData){
|
||||||
delete pPro;
|
delete pPro;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue