2025-07-22 12:03:43 +08:00
|
|
|
|
#include <QMenu>
|
|
|
|
|
|
#include <QMessageBox>
|
2025-08-06 20:10:10 +08:00
|
|
|
|
#include <QUuid>
|
|
|
|
|
|
#include <QtNumeric>
|
2025-05-30 16:28:51 +08:00
|
|
|
|
#include "diagramEditor/diagramEditorWizard.h"
|
2025-07-22 12:03:43 +08:00
|
|
|
|
#include "diagramEditor/wizardBusTableDelegate.h"
|
2025-05-30 16:28:51 +08:00
|
|
|
|
#include "ui_diagramEditorWizard.h"
|
2025-07-25 19:07:14 +08:00
|
|
|
|
#include "diagramEditor/wizardBayContentDlg.h"
|
|
|
|
|
|
#include "diagramEditor/diagramEditorBaseBlock.h"
|
|
|
|
|
|
#include "diagramEditor/diagramEditorStructContainer.h"
|
2025-07-29 20:15:18 +08:00
|
|
|
|
#include "diagramEditor/diagramEditorBaySettingDlg.h"
|
2025-07-31 19:38:06 +08:00
|
|
|
|
#include "diagramEditor/diagramEditorTransSettingDlg.h"
|
2025-05-30 16:28:51 +08:00
|
|
|
|
|
|
|
|
|
|
DiagramEditorWizard::DiagramEditorWizard(QWidget *parent)
|
|
|
|
|
|
: QDialog(parent)
|
|
|
|
|
|
, ui(new Ui::diagramEditorWizard)
|
2025-07-29 20:15:18 +08:00
|
|
|
|
,_baySettingDlg(nullptr)
|
2025-07-31 19:38:06 +08:00
|
|
|
|
,_transSettingDlg(nullptr)
|
2025-05-30 16:28:51 +08:00
|
|
|
|
{
|
|
|
|
|
|
ui->setupUi(this);
|
2025-07-22 12:03:43 +08:00
|
|
|
|
_busPageChanged = false;
|
2025-05-30 16:28:51 +08:00
|
|
|
|
this->setWindowFlags(Qt::FramelessWindowHint | windowFlags());
|
2025-07-22 12:03:43 +08:00
|
|
|
|
initial();
|
2025-05-30 16:28:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DiagramEditorWizard::~DiagramEditorWizard()
|
|
|
|
|
|
{
|
|
|
|
|
|
delete ui;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-22 12:03:43 +08:00
|
|
|
|
void DiagramEditorWizard::initial()
|
|
|
|
|
|
{
|
2025-07-25 19:07:14 +08:00
|
|
|
|
_bayContentDlg = new WizardBayContentDlg(this);
|
2025-07-29 20:15:18 +08:00
|
|
|
|
_bayContentDlg->setParent(this);
|
2025-07-25 19:07:14 +08:00
|
|
|
|
ui->stackedWidget->addWidget(_bayContentDlg);
|
2025-07-22 12:03:43 +08:00
|
|
|
|
ui->tabWidget->tabBar()->setEnabled(false);
|
|
|
|
|
|
connect(ui->btn_ok,&QPushButton::clicked,this,&DiagramEditorWizard::onOkClicked);
|
|
|
|
|
|
connect(ui->btn_cancel,&QPushButton::clicked,this,&DiagramEditorWizard::onCancelClicked);
|
|
|
|
|
|
connect(ui->btn_last,&QPushButton::clicked,this,&DiagramEditorWizard::onLastClicked);
|
|
|
|
|
|
connect(ui->btn_next,&QPushButton::clicked,this,&DiagramEditorWizard::onNextClicked);
|
|
|
|
|
|
connect(ui->btn_addBus,&QPushButton::clicked,this,&DiagramEditorWizard::onAddBusClicked);
|
|
|
|
|
|
connect(ui->btn_addBay,&QPushButton::clicked,this,&DiagramEditorWizard::onAddBayClicked);
|
|
|
|
|
|
connect(ui->btn_addTrans,&QPushButton::clicked,this,&DiagramEditorWizard::onAddTransClicked);
|
|
|
|
|
|
|
|
|
|
|
|
QStringList headerText;
|
|
|
|
|
|
headerText<<"层级"<<"电压等级"<<"主接线"<<"分段方式"<<"接线方式";
|
|
|
|
|
|
ui->tableWidget_bus->setContextMenuPolicy(Qt::CustomContextMenu);
|
|
|
|
|
|
ui->tableWidget_bus->setSelectionMode(QAbstractItemView::SingleSelection);
|
|
|
|
|
|
ui->tableWidget_bus->setSelectionBehavior(QAbstractItemView::SelectRows);
|
|
|
|
|
|
ui->tableWidget_bus->setColumnCount(headerText.count());
|
|
|
|
|
|
ui->tableWidget_bus->setHorizontalHeaderLabels(headerText);
|
|
|
|
|
|
ui->tableWidget_bus->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
|
|
|
|
|
|
2025-07-31 19:38:06 +08:00
|
|
|
|
headerText.clear();
|
|
|
|
|
|
headerText<<"变压器名称"<<"变压器类型"<<"连接对象";
|
|
|
|
|
|
ui->tableWidget_trans->setContextMenuPolicy(Qt::CustomContextMenu);
|
|
|
|
|
|
ui->tableWidget_trans->setSelectionMode(QAbstractItemView::SingleSelection);
|
|
|
|
|
|
ui->tableWidget_trans->setSelectionBehavior(QAbstractItemView::SelectRows);
|
|
|
|
|
|
ui->tableWidget_trans->setColumnCount(headerText.count());
|
|
|
|
|
|
ui->tableWidget_trans->setHorizontalHeaderLabels(headerText);
|
|
|
|
|
|
ui->tableWidget_trans->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
|
|
|
|
|
|
2025-07-22 12:03:43 +08:00
|
|
|
|
WizardBusTableDelegate* delegate = new WizardBusTableDelegate(this);
|
|
|
|
|
|
ui->tableWidget_bus->setItemDelegate(delegate);
|
|
|
|
|
|
|
|
|
|
|
|
connect(delegate,&WizardBusTableDelegate::editingFinished,this,&DiagramEditorWizard::onDelegateFinishEdit);
|
|
|
|
|
|
connect(ui->tableWidget_bus, &QTableWidget::customContextMenuRequested, this, &DiagramEditorWizard::onBusIndexRbtnClicked);
|
2025-07-31 19:38:06 +08:00
|
|
|
|
connect(ui->tableWidget_trans, &QTableWidget::customContextMenuRequested, this, &DiagramEditorWizard::onTransIndexRbtnClicked);
|
2025-07-25 19:07:14 +08:00
|
|
|
|
|
2025-07-29 20:15:18 +08:00
|
|
|
|
connect(ui->listWidget_bay,&QListWidget::itemClicked,this,&DiagramEditorWizard::onBayListSelected);
|
|
|
|
|
|
|
2025-07-25 19:07:14 +08:00
|
|
|
|
_divideType.insert(1,"A段");
|
|
|
|
|
|
_divideType.insert(2,"B段");
|
|
|
|
|
|
_divideType.insert(3,"C段");
|
|
|
|
|
|
_divideType.insert(4,"D段");
|
|
|
|
|
|
_divideType.insert(5,"E段");
|
|
|
|
|
|
_divideType.insert(6,"F段");
|
|
|
|
|
|
_divideType.insert(7,"G段");
|
|
|
|
|
|
_divideType.insert(8,"H段");
|
2025-07-22 12:03:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DiagramEditorWizard::reOrderBus()
|
|
|
|
|
|
{
|
|
|
|
|
|
reindexQMap(_mapBus);
|
|
|
|
|
|
|
|
|
|
|
|
for(int row = 0 ;row < ui->tableWidget_bus->rowCount();++row)
|
|
|
|
|
|
{
|
|
|
|
|
|
QTableWidgetItem* pItem = ui->tableWidget_bus->item(row,0);
|
2025-07-24 10:01:31 +08:00
|
|
|
|
pItem->setText("第"+QString::number(row+1)+"层");
|
2025-07-22 12:03:43 +08:00
|
|
|
|
pItem->setData(Qt::UserRole,row);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-29 20:15:18 +08:00
|
|
|
|
void DiagramEditorWizard::generateBayStruct()
|
2025-07-24 10:01:31 +08:00
|
|
|
|
{
|
2025-07-25 19:07:14 +08:00
|
|
|
|
for(auto iter = _mapBus.begin();iter != _mapBus.end();++iter)
|
2025-07-24 10:01:31 +08:00
|
|
|
|
{
|
2025-07-29 20:15:18 +08:00
|
|
|
|
if(!iter->bChanged) //只生成修改过的程序
|
|
|
|
|
|
continue;
|
|
|
|
|
|
iter->bChanged = false;
|
2025-07-25 19:07:14 +08:00
|
|
|
|
QListWidgetItem* item = new QListWidgetItem("第"+QString::number(iter->nIndex+1)+"层");
|
|
|
|
|
|
item->setData(Qt::UserRole,iter->nIndex);
|
2025-07-24 10:01:31 +08:00
|
|
|
|
ui->listWidget_bay->addItem(item);
|
|
|
|
|
|
|
2025-07-25 19:07:14 +08:00
|
|
|
|
QString sVoltage; //电压前缀
|
|
|
|
|
|
sVoltage = QString::number(iter->dVoltage)+"kV";
|
|
|
|
|
|
|
|
|
|
|
|
if(iter->nLineType == 1){ //单母
|
2025-07-25 19:42:20 +08:00
|
|
|
|
int nDivide = iter->nNum1;
|
2025-07-25 19:07:14 +08:00
|
|
|
|
|
|
|
|
|
|
for(int i = 0;i < nDivide;++i){
|
|
|
|
|
|
QString sDivPre; //分段前缀
|
|
|
|
|
|
if(nDivide == 1){//不划分
|
|
|
|
|
|
}
|
|
|
|
|
|
else{
|
|
|
|
|
|
sDivPre = _divideType.value(i+1);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
auto pContainer = new DiagramEditorStructContainer(this);
|
2025-08-06 20:10:10 +08:00
|
|
|
|
pContainer->setId(QUuid::createUuid().toString());
|
2025-07-25 19:07:14 +08:00
|
|
|
|
auto pBus = new DiagramEditorBusBlock(this);
|
2025-09-05 17:30:07 +08:00
|
|
|
|
pBus->setId(QUuid::createUuid());
|
2025-07-25 19:07:14 +08:00
|
|
|
|
pBus->setBusPro(sVoltage+"母线"+sDivPre,1,iter->dVoltage,0,i+1);
|
|
|
|
|
|
pContainer->insertBlock(1,pBus);
|
|
|
|
|
|
|
|
|
|
|
|
_mapSturctContainer[iter.key()].insert(i,pContainer);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else{ //双母
|
2025-07-25 19:42:20 +08:00
|
|
|
|
int nDivide1 = iter->nNum1; // Ⅰ母
|
|
|
|
|
|
int nDivide2 = iter->nNum2; // Ⅱ母
|
2025-07-25 19:07:14 +08:00
|
|
|
|
|
|
|
|
|
|
if(nDivide1 == nDivide2){ //双母线划分相同
|
|
|
|
|
|
for(int i = 0;i < nDivide1;++i){
|
|
|
|
|
|
QString sDivPre; //分段前缀
|
|
|
|
|
|
if(nDivide1 == 1){//不划分
|
|
|
|
|
|
}
|
|
|
|
|
|
else{
|
|
|
|
|
|
sDivPre = _divideType.value(i+1);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
auto pContainer = new DiagramEditorStructContainer(this);
|
2025-08-06 20:10:10 +08:00
|
|
|
|
pContainer->setId(QUuid::createUuid().toString());
|
2025-07-25 19:07:14 +08:00
|
|
|
|
|
|
|
|
|
|
auto pBus1 = new DiagramEditorBusBlock(this);
|
2025-09-05 17:30:07 +08:00
|
|
|
|
pBus1->setId(QUuid::createUuid());
|
2025-07-25 19:07:14 +08:00
|
|
|
|
pBus1->setBusPro(sVoltage+"Ⅰ母"+sDivPre,1,iter->dVoltage,1,i+1);
|
|
|
|
|
|
pContainer->insertBlock(1,pBus1);
|
|
|
|
|
|
|
|
|
|
|
|
auto pBus2 = new DiagramEditorBusBlock(this);
|
2025-09-05 17:30:07 +08:00
|
|
|
|
pBus2->setId(QUuid::createUuid());
|
2025-07-25 19:07:14 +08:00
|
|
|
|
pBus2->setBusPro(sVoltage+"Ⅱ母"+sDivPre,1,iter->dVoltage,2,i+1);
|
|
|
|
|
|
pContainer->insertBlock(2,pBus2);
|
|
|
|
|
|
_mapSturctContainer[iter.key()].insert(i,pContainer);
|
2025-08-06 20:10:10 +08:00
|
|
|
|
|
2025-07-25 19:07:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else{ //双母线划分不同
|
|
|
|
|
|
if(nDivide1 > nDivide2){ //2母段数少于1母
|
|
|
|
|
|
for(int i = 0;i < nDivide1;++i){
|
|
|
|
|
|
QString sDivPre1 = _divideType.value(i+1); //分段前缀
|
|
|
|
|
|
|
|
|
|
|
|
auto pContainer = new DiagramEditorStructContainer(this);
|
|
|
|
|
|
|
|
|
|
|
|
auto pBus1 = new DiagramEditorBusBlock(this);
|
2025-09-05 17:30:07 +08:00
|
|
|
|
pBus1->setId(QUuid::createUuid());
|
2025-07-25 19:07:14 +08:00
|
|
|
|
pBus1->setBusPro(sVoltage+"Ⅰ母"+sDivPre1,1,iter->dVoltage,1,i+1);
|
|
|
|
|
|
pContainer->insertBlock(1,pBus1);
|
|
|
|
|
|
|
|
|
|
|
|
if(i < nDivide2){
|
|
|
|
|
|
QString sDivPre2;
|
|
|
|
|
|
if(nDivide2 == 1){//不划分
|
|
|
|
|
|
}
|
|
|
|
|
|
else{
|
|
|
|
|
|
sDivPre2 = _divideType.value(i+1);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
auto pBus2 = new DiagramEditorBusBlock(this);
|
2025-09-05 17:30:07 +08:00
|
|
|
|
pBus2->setId(QUuid::createUuid());
|
2025-07-25 19:07:14 +08:00
|
|
|
|
pBus2->setBusPro(sVoltage+"Ⅱ母"+sDivPre2,1,iter->dVoltage,2,i+1);
|
|
|
|
|
|
pContainer->insertBlock(2,pBus2);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_mapSturctContainer[iter.key()].insert(i,pContainer);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else{
|
|
|
|
|
|
for(int i = 0;i < nDivide2;++i){ //1母段数少于2母
|
|
|
|
|
|
QString sDivPre2 = _divideType.value(i+1); //分段前缀
|
|
|
|
|
|
|
|
|
|
|
|
auto pContainer = new DiagramEditorStructContainer(this);
|
|
|
|
|
|
auto pBus2 = new DiagramEditorBusBlock(this);
|
2025-09-05 17:30:07 +08:00
|
|
|
|
pBus2->setId(QUuid::createUuid());
|
2025-07-25 19:07:14 +08:00
|
|
|
|
pBus2->setBusPro(sVoltage+"Ⅱ母"+sDivPre2,1,iter->dVoltage,2,i+1);
|
|
|
|
|
|
pContainer->insertBlock(2,pBus2);
|
|
|
|
|
|
|
|
|
|
|
|
if(i < nDivide1){
|
|
|
|
|
|
QString sDivPre1;
|
|
|
|
|
|
if(nDivide1 == 1){//不划分
|
|
|
|
|
|
}
|
|
|
|
|
|
else{
|
|
|
|
|
|
sDivPre1 = _divideType.value(i+1);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
auto pBus1 = new DiagramEditorBusBlock(this);
|
2025-09-05 17:30:07 +08:00
|
|
|
|
pBus1->setId(QUuid::createUuid());
|
2025-07-25 19:07:14 +08:00
|
|
|
|
pBus1->setBusPro(sVoltage+"Ⅰ母"+sDivPre1,1,iter->dVoltage,1,i+1);
|
|
|
|
|
|
pContainer->insertBlock(1,pBus1);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_mapSturctContainer[iter.key()].insert(i,pContainer);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-07-24 10:01:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-31 19:38:06 +08:00
|
|
|
|
void DiagramEditorWizard::flushTransPage()
|
2025-07-29 20:15:18 +08:00
|
|
|
|
{
|
2025-07-31 19:38:06 +08:00
|
|
|
|
ui->tableWidget_trans->clearContents();
|
|
|
|
|
|
ui->tableWidget_trans->setRowCount(0);
|
|
|
|
|
|
QList<DiagramEditorBaseBlock*> lst = getTargetLevelBlocks(g_transformerLevel,3);
|
|
|
|
|
|
for(auto& block:lst){
|
|
|
|
|
|
auto pItem = dynamic_cast<DiagramEditorTransformerBlock*>(block);
|
|
|
|
|
|
if(pItem){
|
|
|
|
|
|
DiagramEditorWizardTransformerInfo info;
|
|
|
|
|
|
info.sName = pItem->getName();
|
|
|
|
|
|
info.nType = pItem->getTransType();
|
|
|
|
|
|
auto lstCon = pItem->getConnect(); //获取间隔所连对象的名称
|
2025-08-15 18:21:20 +08:00
|
|
|
|
/*for(auto& conId:lstCon){
|
2025-08-06 20:10:10 +08:00
|
|
|
|
if(_mapConnect.contains(conId)){
|
|
|
|
|
|
auto con = _mapConnect.value(conId);
|
|
|
|
|
|
QString sOpposite = con.getOppositeName(pItem->getName());
|
|
|
|
|
|
info.lstBindObj.append(sOpposite);
|
|
|
|
|
|
}
|
2025-08-15 18:21:20 +08:00
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
|
|
for(auto& conId:lstCon){
|
|
|
|
|
|
if(_mapConnect.contains(conId)){
|
|
|
|
|
|
auto con = _mapConnect.value(conId);
|
2025-09-12 17:28:47 +08:00
|
|
|
|
QString sOpposite = con.getOpposite(pItem->getName()).sName;
|
2025-08-15 18:21:20 +08:00
|
|
|
|
|
|
|
|
|
|
QString sPos;
|
|
|
|
|
|
if(con.nPara == 0){
|
|
|
|
|
|
sPos = "高压侧";
|
|
|
|
|
|
}
|
|
|
|
|
|
else if(con.nPara == 1){
|
|
|
|
|
|
sPos = "中压侧";
|
|
|
|
|
|
}
|
|
|
|
|
|
else if(con.nPara == 2){
|
|
|
|
|
|
sPos = "低压侧";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
EditorTransConnection editorCon;
|
|
|
|
|
|
editorCon.nPara = con.nPara;
|
|
|
|
|
|
editorCon.sName = sOpposite;
|
|
|
|
|
|
info.lstBindObj.append(editorCon);
|
|
|
|
|
|
}
|
2025-07-31 19:38:06 +08:00
|
|
|
|
}
|
2025-07-29 20:15:18 +08:00
|
|
|
|
|
2025-07-31 19:38:06 +08:00
|
|
|
|
addTransformer(info);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-06 20:10:10 +08:00
|
|
|
|
int DiagramEditorWizard::getContainerIndex(int nLevel,DiagramEditorStructContainer* pCon)
|
|
|
|
|
|
{
|
|
|
|
|
|
auto lstCon = _mapSturctContainer.value(nLevel);
|
|
|
|
|
|
if(!lstCon.empty()){
|
|
|
|
|
|
for(int i = 0;i < lstCon.size();++i){
|
|
|
|
|
|
if(lstCon[i]->getId() == pCon->getId()){
|
|
|
|
|
|
return i;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-15 18:21:20 +08:00
|
|
|
|
QUuid DiagramEditorWizard::addConnection(const QString& str1,const QString& str2,int nType1,int nType2,int nPara)
|
2025-08-06 20:10:10 +08:00
|
|
|
|
{
|
|
|
|
|
|
for(auto& con:_mapConnect){
|
|
|
|
|
|
if((con.con1.sName == str1 && con.con2.sName == str2) || (con.con1.sName == str2 && con.con2.sName == str1)){ //已存在不插入
|
|
|
|
|
|
return con.uid;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DiagramEditorBriefConnect con;
|
|
|
|
|
|
con.uid = QUuid::createUuid();
|
|
|
|
|
|
con.con1.sName = str1;
|
|
|
|
|
|
con.con1.nType = nType1;
|
|
|
|
|
|
con.con2.sName = str2;
|
|
|
|
|
|
con.con2.nType = nType2;
|
2025-08-15 18:21:20 +08:00
|
|
|
|
con.nPara = nPara;
|
2025-08-06 20:10:10 +08:00
|
|
|
|
|
|
|
|
|
|
_mapConnect.insert(con.uid,con);
|
|
|
|
|
|
return con.uid;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DiagramEditorWizard::removeConnection(QUuid uid)
|
|
|
|
|
|
{
|
|
|
|
|
|
_mapConnect.remove(uid);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-31 19:38:06 +08:00
|
|
|
|
void DiagramEditorWizard::addTransformer(DiagramEditorWizardTransformerInfo info)
|
|
|
|
|
|
{
|
|
|
|
|
|
int row = ui->tableWidget_trans->rowCount();
|
|
|
|
|
|
ui->tableWidget_trans->insertRow(row);
|
|
|
|
|
|
|
|
|
|
|
|
//名称
|
|
|
|
|
|
QTableWidgetItem* nameItem = new QTableWidgetItem(info.sName);
|
|
|
|
|
|
ui->tableWidget_trans->setItem(row, 0, nameItem);
|
|
|
|
|
|
|
|
|
|
|
|
QString sType;
|
|
|
|
|
|
switch (info.nType) {
|
|
|
|
|
|
case TransformerType::twoWinding:
|
|
|
|
|
|
sType = "两绕组变压器";
|
|
|
|
|
|
break;
|
|
|
|
|
|
case TransformerType::threeWinding:
|
|
|
|
|
|
sType = "三绕组变压器";
|
|
|
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
//类型
|
|
|
|
|
|
QTableWidgetItem* typeItem = new QTableWidgetItem(sType);
|
|
|
|
|
|
ui->tableWidget_trans->setItem(row, 1, typeItem);
|
|
|
|
|
|
|
|
|
|
|
|
//连接
|
2025-08-15 18:21:20 +08:00
|
|
|
|
QString str;
|
|
|
|
|
|
for(auto& obj:info.lstBindObj){
|
|
|
|
|
|
str += obj.sName+"、";
|
|
|
|
|
|
}
|
|
|
|
|
|
QTableWidgetItem* connectItem = new QTableWidgetItem(str);
|
2025-07-31 19:38:06 +08:00
|
|
|
|
ui->tableWidget_trans->setItem(row, 2, connectItem);
|
2025-07-29 20:15:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-22 12:03:43 +08:00
|
|
|
|
template <typename T> void DiagramEditorWizard::reindexQMap(QMap<int, T> &map) {
|
|
|
|
|
|
if (map.isEmpty())
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
// 保存原数据的值(按原键升序排列)
|
|
|
|
|
|
QVector<T> values;
|
|
|
|
|
|
values.reserve(map.size());
|
|
|
|
|
|
for (auto it = map.begin(); it != map.end(); ++it) {
|
|
|
|
|
|
values.append(std::move(it.value())); // 使用移动语义
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 清空原map并重新插入连续键
|
|
|
|
|
|
map.clear();
|
|
|
|
|
|
for (int newKey = 0; newKey < values.size(); ++newKey) {
|
|
|
|
|
|
map.insert(newKey, std::move(values[newKey])); // 再次移动
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-05-30 16:28:51 +08:00
|
|
|
|
void DiagramEditorWizard::onOkClicked()
|
|
|
|
|
|
{
|
2025-07-31 19:38:06 +08:00
|
|
|
|
emit wizardFinish();
|
2025-05-30 16:28:51 +08:00
|
|
|
|
hide();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DiagramEditorWizard::onCancelClicked()
|
|
|
|
|
|
{
|
|
|
|
|
|
hide();
|
|
|
|
|
|
}
|
2025-07-22 12:03:43 +08:00
|
|
|
|
|
|
|
|
|
|
void DiagramEditorWizard::onLastClicked()
|
|
|
|
|
|
{
|
|
|
|
|
|
if(ui->tabWidget->currentIndex() == 2){
|
|
|
|
|
|
ui->tabWidget->setCurrentIndex(1);
|
|
|
|
|
|
ui->stackedWidget_last->setCurrentIndex(1);
|
|
|
|
|
|
ui->stackedWidget_next->setCurrentIndex(0);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if(ui->tabWidget->currentIndex() == 1){
|
|
|
|
|
|
ui->tabWidget->setCurrentIndex(0);
|
|
|
|
|
|
ui->stackedWidget_last->setCurrentIndex(0);
|
|
|
|
|
|
ui->stackedWidget_next->setCurrentIndex(0);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DiagramEditorWizard::onNextClicked()
|
|
|
|
|
|
{
|
|
|
|
|
|
if(ui->tabWidget->currentIndex() == 0){
|
|
|
|
|
|
ui->tabWidget->setCurrentIndex(1);
|
|
|
|
|
|
ui->stackedWidget_last->setCurrentIndex(1);
|
|
|
|
|
|
ui->stackedWidget_next->setCurrentIndex(0);
|
|
|
|
|
|
|
2025-07-29 20:15:18 +08:00
|
|
|
|
generateBayStruct();
|
|
|
|
|
|
if(ui->listWidget_bay->count()){
|
|
|
|
|
|
QListWidgetItem* targetItem = ui->listWidget_bay->item(0);
|
|
|
|
|
|
// 确保项有效
|
|
|
|
|
|
if (targetItem) {
|
|
|
|
|
|
// 手动发射itemClicked信号
|
|
|
|
|
|
emit ui->listWidget_bay->itemClicked(targetItem);
|
|
|
|
|
|
// 如果需要同时选中该项
|
|
|
|
|
|
ui->listWidget_bay->setCurrentItem(targetItem);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-07-22 12:03:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
else if(ui->tabWidget->currentIndex() == 1){
|
|
|
|
|
|
ui->tabWidget->setCurrentIndex(2);
|
|
|
|
|
|
ui->stackedWidget_last->setCurrentIndex(1);
|
|
|
|
|
|
ui->stackedWidget_next->setCurrentIndex(1);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DiagramEditorWizard::onAddBusClicked()
|
|
|
|
|
|
{
|
|
|
|
|
|
int row = ui->tableWidget_bus->rowCount();
|
|
|
|
|
|
ui->tableWidget_bus->insertRow(row);
|
|
|
|
|
|
|
|
|
|
|
|
// 层级
|
2025-07-31 19:38:06 +08:00
|
|
|
|
QTableWidgetItem* levelItem = new QTableWidgetItem("第"+QString::number(row+1)+"层");
|
2025-07-22 12:03:43 +08:00
|
|
|
|
ui->tableWidget_bus->setItem(row, 0, levelItem);
|
|
|
|
|
|
levelItem->setData(Qt::UserRole,row);
|
|
|
|
|
|
|
|
|
|
|
|
// 电压等级
|
|
|
|
|
|
QTableWidgetItem* voltageItem = new QTableWidgetItem("未设置");
|
|
|
|
|
|
ui->tableWidget_bus->setItem(row, 1, voltageItem);
|
|
|
|
|
|
|
|
|
|
|
|
// 主接线
|
|
|
|
|
|
QTableWidgetItem* typeItem = new QTableWidgetItem("未设置");
|
|
|
|
|
|
ui->tableWidget_bus->setItem(row, 2, typeItem);
|
|
|
|
|
|
|
|
|
|
|
|
// 分段方式
|
|
|
|
|
|
QTableWidgetItem* divideItem = new QTableWidgetItem("未设置");
|
|
|
|
|
|
ui->tableWidget_bus->setItem(row, 3, divideItem);
|
|
|
|
|
|
|
|
|
|
|
|
// 接线方式
|
|
|
|
|
|
QTableWidgetItem* connectItem = new QTableWidgetItem("未选择");
|
|
|
|
|
|
ui->tableWidget_bus->setItem(row, 4, connectItem);
|
|
|
|
|
|
|
2025-07-25 19:07:14 +08:00
|
|
|
|
DiagramEditorWizardBusInfo info;
|
2025-07-22 12:03:43 +08:00
|
|
|
|
info.nIndex = row;
|
2025-07-29 20:15:18 +08:00
|
|
|
|
info.bChanged = true;
|
2025-07-22 12:03:43 +08:00
|
|
|
|
_mapBus.insert(row,info);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DiagramEditorWizard::onAddBayClicked()
|
|
|
|
|
|
{
|
2025-07-29 20:15:18 +08:00
|
|
|
|
if(_baySettingDlg == nullptr){
|
|
|
|
|
|
_baySettingDlg = new DiagramEditorBaySettingDlg(this);
|
|
|
|
|
|
_baySettingDlg->setParent(this);
|
|
|
|
|
|
}
|
|
|
|
|
|
_baySettingDlg->showDlg(ui->listWidget_bay->currentItem()->data(Qt::UserRole).toInt());
|
2025-07-22 12:03:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DiagramEditorWizard::onAddTransClicked()
|
|
|
|
|
|
{
|
2025-07-31 19:38:06 +08:00
|
|
|
|
if(_transSettingDlg == nullptr){
|
|
|
|
|
|
_transSettingDlg = new DiagramEditorTransSettingDlg(this);
|
|
|
|
|
|
_transSettingDlg->setParent(this);
|
|
|
|
|
|
}
|
|
|
|
|
|
_transSettingDlg->showDlg();
|
2025-07-22 12:03:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-29 20:15:18 +08:00
|
|
|
|
void DiagramEditorWizard::onAddBayFinished(DiagramEditorWizardBayInfo info)
|
|
|
|
|
|
{
|
|
|
|
|
|
int curIndex = ui->listWidget_bay->currentItem()->data(Qt::UserRole).toInt(); //当前层级
|
|
|
|
|
|
|
|
|
|
|
|
if(!info.lstBindObj.isEmpty()){
|
2025-08-06 20:10:10 +08:00
|
|
|
|
QList<int> lstlevel; //层级
|
|
|
|
|
|
if(info.nType == BayType::busSectionBay)
|
|
|
|
|
|
{
|
|
|
|
|
|
for(auto& sName:info.lstBindObj){
|
|
|
|
|
|
auto pBlock = getBlockByName(curIndex,1,sName);
|
|
|
|
|
|
if(pBlock){
|
|
|
|
|
|
int n = pBlock->getContainerLevel();
|
|
|
|
|
|
lstlevel.append(n);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(info.lstBindObj.size() < 2){
|
|
|
|
|
|
QMessageBox::information(NULL, QString("提示"), QString::fromWCharArray(L"分段连接1%连接对象不足").arg(info.sName));
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
else{
|
|
|
|
|
|
if(lstlevel.size() > 1){
|
|
|
|
|
|
if(lstlevel[0] != lstlevel[1]){
|
|
|
|
|
|
QMessageBox::information(NULL, QString("提示"), QString::fromWCharArray(L"分段连接1%连接母线错位").arg(info.sName));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-07-29 20:15:18 +08:00
|
|
|
|
|
|
|
|
|
|
DiagramEditorBayBlock* pBlock = new DiagramEditorBayBlock(this);
|
2025-09-26 18:50:21 +08:00
|
|
|
|
pBlock->setId(QUuid::createUuid());
|
2025-07-29 20:15:18 +08:00
|
|
|
|
pBlock->setName(info.sName);
|
|
|
|
|
|
pBlock->setType(2);
|
|
|
|
|
|
pBlock->setBayType(info.nType);
|
|
|
|
|
|
for(auto& sName:info.lstBindObj){
|
2025-08-06 20:10:10 +08:00
|
|
|
|
QUuid uid = addConnection(pBlock->getName(),sName,2,1);
|
|
|
|
|
|
pBlock->addConnect(uid);
|
2025-07-29 20:15:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-11 18:51:33 +08:00
|
|
|
|
if(info.nType == BayType::busSectionBay){ //分段间隔
|
2025-08-06 20:10:10 +08:00
|
|
|
|
|
|
|
|
|
|
auto pC1 = getContainerByBlock(curIndex,1,info.lstBindObj.first());
|
|
|
|
|
|
auto pC2 = getContainerByBlock(curIndex,1,info.lstBindObj.last());
|
|
|
|
|
|
int idx1 = getContainerIndex(curIndex,pC1);
|
|
|
|
|
|
int idx2 = getContainerIndex(curIndex,pC2);
|
|
|
|
|
|
int n = qAbs(idx1-idx2);
|
2025-07-29 20:15:18 +08:00
|
|
|
|
|
2025-08-06 20:10:10 +08:00
|
|
|
|
if(n == 1){ //两个容器相连,未插入container,新建
|
|
|
|
|
|
auto pContainer = new DiagramEditorStructContainer(this);
|
|
|
|
|
|
pContainer->setId(QUuid::createUuid().toString());
|
|
|
|
|
|
|
|
|
|
|
|
QList<int> lstIndex;
|
|
|
|
|
|
for(auto& sName:info.lstBindObj){ //寻找container所处index
|
|
|
|
|
|
auto pBlock = getBlockByName(curIndex,1,sName);
|
|
|
|
|
|
if(pBlock){
|
|
|
|
|
|
auto pCon = pBlock->getCurContainer();
|
|
|
|
|
|
if(pCon){
|
|
|
|
|
|
int nRes = getContainerIndex(curIndex,pCon);
|
|
|
|
|
|
if(nRes != -1){
|
|
|
|
|
|
lstIndex.append(nRes);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(!lstIndex.isEmpty()){
|
|
|
|
|
|
int maxIndex = lstIndex.first(); // 取第一个元素作为初始值
|
|
|
|
|
|
for (int i : lstIndex) {
|
|
|
|
|
|
if (i > maxIndex) {
|
|
|
|
|
|
maxIndex = i; // 更新最大值
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
_mapSturctContainer[curIndex].insert(maxIndex,pContainer); //将容器插入到最右的前一个
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(lstlevel.size() > 1){ //判断连接母线在container中的层级
|
|
|
|
|
|
if((lstlevel.value(0) == lstlevel.value(1))){ //加入container最上层
|
|
|
|
|
|
if((lstlevel.value(0) == 1)){
|
|
|
|
|
|
pContainer->insertBlock(0,pBlock);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if((lstlevel.value(0) == 2)){ //加入container最下层
|
|
|
|
|
|
pContainer->insertBlock(3,pBlock);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else{ //使用已有container
|
|
|
|
|
|
int nMiddle = (idx1+idx2)*0.5;
|
|
|
|
|
|
auto pContainer = _mapSturctContainer[curIndex].value(nMiddle);
|
|
|
|
|
|
if(pContainer){
|
|
|
|
|
|
if(lstlevel.size() > 1){ //判断连接母线在container中的层级
|
|
|
|
|
|
if((lstlevel.value(0) == lstlevel.value(1))){ //加入container最上层
|
|
|
|
|
|
if((lstlevel.value(0) == 1)){
|
|
|
|
|
|
pContainer->insertBlock(0,pBlock);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if((lstlevel.value(0) == 2)){ //加入container最下层
|
|
|
|
|
|
pContainer->insertBlock(3,pBlock);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-10-11 18:51:33 +08:00
|
|
|
|
else if(info.nType == BayType::incomingBay || info.nType == BayType::ptBay){ //进线间隔和pt间隔在上边
|
2025-08-08 17:47:31 +08:00
|
|
|
|
auto pContainer = getContainerByBlock(curIndex,1,info.lstBindObj.first());
|
|
|
|
|
|
pContainer->insertBlock(0,pBlock);
|
|
|
|
|
|
}
|
2025-08-06 20:10:10 +08:00
|
|
|
|
else{ //其他间隔
|
|
|
|
|
|
auto pContainer = getContainerByBlock(curIndex,1,info.lstBindObj.first());
|
|
|
|
|
|
pContainer->insertBlock(3,pBlock);
|
|
|
|
|
|
}
|
2025-07-29 20:15:18 +08:00
|
|
|
|
_bayContentDlg->flushData(curIndex);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-31 19:38:06 +08:00
|
|
|
|
void DiagramEditorWizard::onAddTransFinished(DiagramEditorWizardTransformerInfo info)
|
|
|
|
|
|
{
|
|
|
|
|
|
auto pContainer = new DiagramEditorStructContainer(this);
|
|
|
|
|
|
auto pTrans = new DiagramEditorTransformerBlock(this);
|
|
|
|
|
|
|
2025-09-05 17:30:07 +08:00
|
|
|
|
pTrans->setId(QUuid::createUuid());
|
2025-07-31 19:38:06 +08:00
|
|
|
|
pTrans->setName(info.sName);
|
|
|
|
|
|
pTrans->setType(3);
|
|
|
|
|
|
pTrans->setTransType(info.nType);
|
|
|
|
|
|
|
2025-08-15 18:21:20 +08:00
|
|
|
|
for(auto& obj:info.lstBindObj){
|
|
|
|
|
|
QUuid uid = addConnection(pTrans->getName(),obj.sName,3,2,obj.nPara);
|
2025-08-06 20:10:10 +08:00
|
|
|
|
pTrans->addConnect(uid);
|
2025-09-19 18:11:28 +08:00
|
|
|
|
auto pBlock = getBlockByName_all(obj.sName); //连接的双方都保存连接(todo:修改时删除对面保存的连接)
|
|
|
|
|
|
if(pBlock){
|
|
|
|
|
|
pBlock->addConnect(uid);
|
|
|
|
|
|
}
|
2025-07-31 19:38:06 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-09-19 18:11:28 +08:00
|
|
|
|
pContainer->insertBlock(1,pTrans); //***变压器添加到了1层***
|
2025-07-31 19:38:06 +08:00
|
|
|
|
|
|
|
|
|
|
int nIndex =_mapSturctContainer.value(g_transformerLevel).size();
|
|
|
|
|
|
_mapSturctContainer[g_transformerLevel].insert(nIndex,pContainer);
|
|
|
|
|
|
|
|
|
|
|
|
flushTransPage();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-22 12:03:43 +08:00
|
|
|
|
void DiagramEditorWizard::onDelegateFinishEdit(const QModelIndex &index, const QString &value)
|
|
|
|
|
|
{
|
|
|
|
|
|
int row = index.row();
|
|
|
|
|
|
int col = index.column();
|
|
|
|
|
|
if(_mapBus.contains(row)){
|
|
|
|
|
|
if(col == 1){
|
|
|
|
|
|
_mapBus[row].dVoltage = value.toDouble();
|
|
|
|
|
|
}
|
|
|
|
|
|
else if(col == 2){
|
|
|
|
|
|
_mapBus[row].nLineType = value.toInt();
|
|
|
|
|
|
QTableWidgetItem *divideItem = ui->tableWidget_bus->item(row, 3);
|
|
|
|
|
|
divideItem->setText("未设置");
|
|
|
|
|
|
divideItem->setData(Qt::UserRole,0);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if(col == 3){
|
|
|
|
|
|
QStringList lst = value.split(",");
|
|
|
|
|
|
if(lst.size() > 1) //双母
|
|
|
|
|
|
{
|
2025-07-25 19:42:20 +08:00
|
|
|
|
_mapBus[row].nNum1 = lst[0].toInt();
|
|
|
|
|
|
_mapBus[row].nNum2= lst[1].toInt();
|
2025-07-22 12:03:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
else{ //单母
|
2025-07-25 19:42:20 +08:00
|
|
|
|
_mapBus[row].nNum1 = lst[0].toInt();
|
2025-07-22 12:03:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else if(col == 4){
|
|
|
|
|
|
_mapBus[row].connectType = value.toInt();
|
|
|
|
|
|
}
|
|
|
|
|
|
_busPageChanged = true;
|
|
|
|
|
|
//qDebug() << row<<","<<col<<":"<<value;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DiagramEditorWizard::onBusDeleteClicked()
|
|
|
|
|
|
{
|
|
|
|
|
|
// 获取当前选中的索引
|
|
|
|
|
|
QMessageBox msgBox;
|
|
|
|
|
|
msgBox.setText(QString::fromWCharArray(L"提示"));
|
|
|
|
|
|
msgBox.setInformativeText(QString::fromWCharArray(L"确认删除?"));
|
|
|
|
|
|
msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
|
|
|
|
|
|
msgBox.setDefaultButton(QMessageBox::Cancel);
|
|
|
|
|
|
int ret = msgBox.exec();
|
|
|
|
|
|
switch (ret) {
|
|
|
|
|
|
case QMessageBox::Ok:
|
|
|
|
|
|
{
|
|
|
|
|
|
QModelIndexList selectedIndexes = ui->tableWidget_bus->selectionModel()->selectedRows();
|
|
|
|
|
|
if (selectedIndexes.isEmpty()) {
|
|
|
|
|
|
return; // 没有选中任何行
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 获取当前选中的第一项索引
|
|
|
|
|
|
QModelIndex index = selectedIndexes.first();
|
|
|
|
|
|
if (!index.isValid()) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QModelIndex indexName = index.sibling(index.row(),0);
|
|
|
|
|
|
int nIndex = indexName.data(Qt::UserRole).toInt();
|
|
|
|
|
|
if(_mapBus.contains(nIndex)){
|
2025-07-25 19:42:20 +08:00
|
|
|
|
_mapBus.remove(nIndex);
|
2025-07-22 12:03:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int currentRow = ui->tableWidget_bus->currentRow();
|
|
|
|
|
|
if (currentRow == -1) {
|
|
|
|
|
|
return; // 没有选中行
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ui->tableWidget_bus->removeRow(currentRow);
|
|
|
|
|
|
reOrderBus();
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
case QMessageBox::Cancel:
|
|
|
|
|
|
// Cancel was clicked
|
|
|
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
|
|
|
// should never be reached
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DiagramEditorWizard::onBusIndexRbtnClicked(const QPoint &pos)
|
|
|
|
|
|
{
|
|
|
|
|
|
// 获取当前点击的位置对应的索引
|
|
|
|
|
|
QModelIndex index = ui->tableWidget_bus->indexAt(pos);
|
|
|
|
|
|
if (!index.isValid()) {
|
|
|
|
|
|
return; // 如果点击的是空白区域,直接返回
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QMenu menu;
|
|
|
|
|
|
QAction *deleteAction = new QAction("删除本层", this);
|
|
|
|
|
|
menu.addAction(deleteAction);
|
|
|
|
|
|
|
|
|
|
|
|
// 连接删除菜单项的触发信号与槽函数
|
|
|
|
|
|
connect(deleteAction, &QAction::triggered, this, &DiagramEditorWizard::onBusDeleteClicked);
|
|
|
|
|
|
|
|
|
|
|
|
// 在点击位置显示菜单
|
|
|
|
|
|
menu.exec(ui->tableWidget_bus->mapToGlobal(pos));
|
|
|
|
|
|
}
|
2025-07-29 20:15:18 +08:00
|
|
|
|
|
2025-07-31 19:38:06 +08:00
|
|
|
|
void DiagramEditorWizard::onTransDeleteClicked()
|
|
|
|
|
|
{
|
|
|
|
|
|
// 获取当前选中的索引
|
|
|
|
|
|
QModelIndexList selectedIndexes = ui->tableWidget_trans->selectionModel()->selectedRows();
|
|
|
|
|
|
if (selectedIndexes.isEmpty()) {
|
|
|
|
|
|
return; // 没有选中任何行
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 获取当前选中的第一项索引
|
|
|
|
|
|
QModelIndex index = selectedIndexes.first();
|
|
|
|
|
|
if (!index.isValid()) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QModelIndex indexName = index.sibling(index.row(),0);
|
|
|
|
|
|
QString sName = indexName.data().toString();
|
|
|
|
|
|
|
|
|
|
|
|
DiagramEditorStructContainer* pCon = getContainerByBlock(g_transformerLevel,3,sName);
|
|
|
|
|
|
bool res = removeBlockByName(g_transformerLevel,3,sName);
|
|
|
|
|
|
if(pCon){ //同时删除container(一个container包含一个变压器)
|
2025-08-06 20:10:10 +08:00
|
|
|
|
/*for(auto iter = _mapSturctContainer[g_transformerLevel].begin(); iter != _mapSturctContainer[g_transformerLevel].end();++iter){
|
|
|
|
|
|
if(*iter == pCon){
|
2025-07-31 19:38:06 +08:00
|
|
|
|
delete pCon;
|
|
|
|
|
|
_mapSturctContainer[g_transformerLevel].erase(iter);
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
2025-08-06 20:10:10 +08:00
|
|
|
|
}*/
|
|
|
|
|
|
for(int i = 0;i < _mapSturctContainer[g_transformerLevel].size();++i){
|
|
|
|
|
|
if(_mapSturctContainer[g_transformerLevel][i] == pCon){
|
|
|
|
|
|
delete pCon;
|
|
|
|
|
|
_mapSturctContainer[g_transformerLevel].removeAt(i);
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
2025-07-31 19:38:06 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if(res){
|
|
|
|
|
|
flushTransPage();
|
|
|
|
|
|
}
|
|
|
|
|
|
else{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int currentRow = ui->tableWidget_trans->currentRow();
|
|
|
|
|
|
if (currentRow == -1) {
|
|
|
|
|
|
return; // 没有选中行
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ui->tableWidget_trans->removeRow(currentRow);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DiagramEditorWizard::onTransModifyClicked()
|
|
|
|
|
|
{
|
|
|
|
|
|
// 获取当前选中的索引
|
|
|
|
|
|
QModelIndexList selectedIndexes = ui->tableWidget_trans->selectionModel()->selectedRows();
|
|
|
|
|
|
if (selectedIndexes.isEmpty()) {
|
|
|
|
|
|
return; // 没有选中任何行
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 获取当前选中的第一项索引
|
|
|
|
|
|
QModelIndex index = selectedIndexes.first();
|
|
|
|
|
|
if (!index.isValid()) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QModelIndex indexName = index.sibling(index.row(),0);
|
|
|
|
|
|
QString sName = indexName.data().toString();
|
|
|
|
|
|
|
|
|
|
|
|
DiagramEditorBaseBlock* pBlock = getBlockByName(g_transformerLevel,3,sName);
|
|
|
|
|
|
if(pBlock){
|
|
|
|
|
|
auto pTran = dynamic_cast<DiagramEditorTransformerBlock*>(pBlock);
|
|
|
|
|
|
if(pTran)
|
|
|
|
|
|
_transSettingDlg->showDlg(pTran);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DiagramEditorWizard::onTransIndexRbtnClicked(const QPoint &pos)
|
|
|
|
|
|
{
|
|
|
|
|
|
// 获取当前点击的位置对应的索引
|
|
|
|
|
|
QModelIndex index = ui->tableWidget_bus->indexAt(pos);
|
|
|
|
|
|
if (!index.isValid()) {
|
|
|
|
|
|
return; // 如果点击的是空白区域,直接返回
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QMenu menu;
|
|
|
|
|
|
QAction *deleteAction = new QAction("移除变压器", this);
|
|
|
|
|
|
QAction *modifyAction = new QAction("修改变压器", this);
|
|
|
|
|
|
menu.addAction(deleteAction);
|
|
|
|
|
|
menu.addAction(modifyAction);
|
|
|
|
|
|
|
|
|
|
|
|
// 连接删除菜单项的触发信号与槽函数
|
|
|
|
|
|
connect(deleteAction, &QAction::triggered, this, &DiagramEditorWizard::onTransDeleteClicked);
|
|
|
|
|
|
connect(modifyAction, &QAction::triggered, this, &DiagramEditorWizard::onTransModifyClicked);
|
|
|
|
|
|
|
|
|
|
|
|
// 在点击位置显示菜单
|
|
|
|
|
|
menu.exec(ui->tableWidget_bus->mapToGlobal(pos));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-29 20:15:18 +08:00
|
|
|
|
void DiagramEditorWizard::onBayListSelected(QListWidgetItem* pItem)
|
|
|
|
|
|
{
|
|
|
|
|
|
int nIndex = pItem->data(Qt::UserRole).toInt();
|
|
|
|
|
|
ui->label_level->setText("第"+QString::number(nIndex+1)+"层");
|
|
|
|
|
|
_bayContentDlg->flushData(nIndex);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QList<DiagramEditorBaseBlock*> DiagramEditorWizard::getTargetLevelBlocks(int nLevel,int nType)
|
|
|
|
|
|
{
|
|
|
|
|
|
QList<DiagramEditorBaseBlock*> lstBlock;
|
|
|
|
|
|
for(auto iter = _mapSturctContainer.begin();iter != _mapSturctContainer.end();++iter){
|
|
|
|
|
|
if(iter.key() == nLevel){
|
|
|
|
|
|
for(auto& container:iter.value())
|
|
|
|
|
|
{
|
|
|
|
|
|
auto mapBlock = container->getBlockMap();
|
|
|
|
|
|
for(auto& lst:mapBlock)
|
|
|
|
|
|
{
|
|
|
|
|
|
for(auto& block:lst)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(block->getType() == nType){ //返回对应type
|
|
|
|
|
|
lstBlock.append(block);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return lstBlock;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-06 20:10:10 +08:00
|
|
|
|
QList<DiagramEditorBaseBlock*> DiagramEditorWizard::getTargetLevelBlocks_all(int nLevel)
|
|
|
|
|
|
{
|
|
|
|
|
|
QList<DiagramEditorBaseBlock*> lstBlock;
|
|
|
|
|
|
for(auto iter = _mapSturctContainer.begin();iter != _mapSturctContainer.end();++iter){
|
|
|
|
|
|
if(iter.key() == nLevel){
|
|
|
|
|
|
for(auto& container:iter.value())
|
|
|
|
|
|
{
|
|
|
|
|
|
auto mapBlock = container->getBlockMap();
|
|
|
|
|
|
for(auto& lst:mapBlock)
|
|
|
|
|
|
{
|
|
|
|
|
|
for(auto& block:lst)
|
|
|
|
|
|
{
|
|
|
|
|
|
lstBlock.append(block);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return lstBlock;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-29 20:15:18 +08:00
|
|
|
|
DiagramEditorStructContainer* DiagramEditorWizard::getContainerByBlock(int nLevel,int nType,QString sName)
|
|
|
|
|
|
{
|
|
|
|
|
|
DiagramEditorStructContainer* pContainer = nullptr;
|
|
|
|
|
|
auto lstBlock = getTargetLevelBlocks(nLevel,nType);
|
|
|
|
|
|
for(auto& block:lstBlock){
|
|
|
|
|
|
if(block->getName() == sName){
|
|
|
|
|
|
pContainer = block->getCurContainer();
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return pContainer;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-08 17:47:31 +08:00
|
|
|
|
DiagramEditorStructContainer* DiagramEditorWizard::getContainerByBlock_all(QString sName)
|
|
|
|
|
|
{
|
|
|
|
|
|
DiagramEditorStructContainer* pContainer = nullptr;
|
|
|
|
|
|
for(auto iter = _mapSturctContainer.begin(); iter != _mapSturctContainer.end();++iter){
|
|
|
|
|
|
auto lstBlock = getTargetLevelBlocks_all(iter.key());
|
|
|
|
|
|
for(auto& block:lstBlock){
|
|
|
|
|
|
if(block->getName() == sName){
|
|
|
|
|
|
pContainer = block->getCurContainer();
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return pContainer;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-29 20:15:18 +08:00
|
|
|
|
DiagramEditorBaseBlock* DiagramEditorWizard::getBlockByName(int nLevel,int nType,QString sName)
|
|
|
|
|
|
{
|
|
|
|
|
|
auto lstBlock = getTargetLevelBlocks(nLevel,nType);
|
|
|
|
|
|
for(auto& block:lstBlock){
|
|
|
|
|
|
if(block->getName() == sName){
|
|
|
|
|
|
return block;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-08-06 20:10:10 +08:00
|
|
|
|
return nullptr;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DiagramEditorBaseBlock* DiagramEditorWizard::getBlockByName_all(QString sName)
|
|
|
|
|
|
{
|
|
|
|
|
|
for(auto iter = _mapSturctContainer.begin(); iter != _mapSturctContainer.end();++iter){
|
|
|
|
|
|
auto lstBlock = getTargetLevelBlocks_all(iter.key());
|
|
|
|
|
|
for(auto& block:lstBlock){
|
|
|
|
|
|
if(block->getName() == sName){
|
|
|
|
|
|
return block;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return nullptr;
|
2025-07-29 20:15:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool DiagramEditorWizard::removeBlockByName(int nLevel,int nType,const QString& sName)
|
|
|
|
|
|
{
|
|
|
|
|
|
DiagramEditorStructContainer* pCon = getContainerByBlock(nLevel,nType,sName);
|
|
|
|
|
|
if(pCon){
|
|
|
|
|
|
auto& mapBlock = pCon->getBlockMap();
|
|
|
|
|
|
for(auto& lst:mapBlock){
|
|
|
|
|
|
|
|
|
|
|
|
for(int i = 0;i< lst.size();++i){
|
|
|
|
|
|
if(lst[i]->getName() == sName){
|
2025-08-06 20:10:10 +08:00
|
|
|
|
QList<QUuid> lstUid = lst[i]->getConnect();
|
|
|
|
|
|
for(auto uid:lstUid){ //删除对象前删除连接
|
|
|
|
|
|
auto con = _mapConnect.value(uid);
|
2025-09-12 17:28:47 +08:00
|
|
|
|
QString sOppo = con.getOpposite(sName).sName; //删除相连的对象中连接信息
|
2025-08-06 20:10:10 +08:00
|
|
|
|
auto pBlock = getBlockByName_all(sOppo);
|
|
|
|
|
|
if(pBlock){
|
|
|
|
|
|
pBlock->removeConnect(uid);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
removeConnection(uid);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-29 20:15:18 +08:00
|
|
|
|
delete lst[i];
|
|
|
|
|
|
lst.removeAt(i);
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|