2025-11-14 19:31:09 +08:00
|
|
|
#include "monitorPanel.h"
|
2025-11-21 19:22:41 +08:00
|
|
|
#include <QJsonArray>
|
2025-11-14 19:31:09 +08:00
|
|
|
#include <QMessageBox>
|
|
|
|
|
#include <QCloseEvent>
|
2025-11-21 19:22:41 +08:00
|
|
|
#include <QToolBar>
|
|
|
|
|
#include <QVBoxLayout>
|
2025-11-14 19:31:09 +08:00
|
|
|
#include "graphicsDataModel/fixedPortsModel.h"
|
|
|
|
|
#include "graphicsItem/graphicsBaseItem.h"
|
|
|
|
|
#include "powerEntity.h"
|
|
|
|
|
#include "statusBar.h"
|
|
|
|
|
#include "baseProperty.h"
|
|
|
|
|
#include "graphicsItem/electricBayItem.h"
|
2025-11-21 19:22:41 +08:00
|
|
|
#include "monitorSideBarDlg.h"
|
|
|
|
|
#include "monitorSelectedItemsDlg.h"
|
|
|
|
|
#include "monitorConfigDlg.h"
|
2025-11-14 19:31:09 +08:00
|
|
|
|
|
|
|
|
MonitorPanel::MonitorPanel(PowerEntity* pEntity,QWidget *parent,DiagramMode mode)
|
|
|
|
|
: BaseDrawingPanel(pEntity,parent,mode)
|
2025-11-21 19:22:41 +08:00
|
|
|
,_toolBar(nullptr)
|
|
|
|
|
,_sideBar(nullptr)
|
|
|
|
|
,_pConfigDlg(nullptr)
|
|
|
|
|
,_itemListmodel(nullptr)
|
2025-11-14 19:31:09 +08:00
|
|
|
{
|
|
|
|
|
m_pStatusBar->setButtonVisible(false);
|
2025-11-21 19:22:41 +08:00
|
|
|
initial();
|
2025-11-14 19:31:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MonitorPanel::~MonitorPanel()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-21 19:22:41 +08:00
|
|
|
void MonitorPanel::initial()
|
|
|
|
|
{
|
|
|
|
|
_itemListmodel = new QStandardItemModel(this);
|
|
|
|
|
|
|
|
|
|
createToolBar();
|
|
|
|
|
_sideBar = new MonitorSideBarDlg(this);
|
|
|
|
|
_hSplitter->addWidget(_sideBar);
|
|
|
|
|
_sideBar->show();
|
|
|
|
|
_pConfigDlg = new MonitorConfigDlg(this);
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-14 19:31:09 +08:00
|
|
|
void MonitorPanel::closeEvent(QCloseEvent *closeEvent)
|
|
|
|
|
{
|
|
|
|
|
emit panelDelete(_name,2);
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-21 19:22:41 +08:00
|
|
|
void MonitorPanel::createToolBar()
|
|
|
|
|
{
|
|
|
|
|
_toolBar = new QToolBar(this);
|
|
|
|
|
_toolBar->setStyleSheet("QToolBar { background-color: palette(window); border: none; }");
|
|
|
|
|
|
|
|
|
|
QAction *runAction = new QAction("运行", this);
|
|
|
|
|
connect(runAction, &QAction::triggered, this, &MonitorPanel::onRunClicked);
|
|
|
|
|
_toolBar->addAction(runAction);
|
|
|
|
|
|
|
|
|
|
QAction *stopAction = new QAction("停止", this);
|
|
|
|
|
connect(stopAction, &QAction::triggered, this, &MonitorPanel::onStopClicked);
|
|
|
|
|
_toolBar->addAction(stopAction);
|
|
|
|
|
|
|
|
|
|
QAction *configAction = new QAction("参数配置", this);
|
|
|
|
|
connect(configAction, &QAction::triggered, this, &MonitorPanel::onConfigClicked);
|
|
|
|
|
_toolBar->addAction(configAction);
|
|
|
|
|
|
|
|
|
|
QAction *connectAction = new QAction("连接设置", this);
|
|
|
|
|
connect(connectAction, &QAction::triggered, this, &MonitorPanel::onConncecClicked);
|
|
|
|
|
_toolBar->addAction(connectAction);
|
|
|
|
|
|
|
|
|
|
// 设置工具栏样式
|
|
|
|
|
_toolBar->setToolButtonStyle(Qt::ToolButtonTextOnly);
|
|
|
|
|
_verticalLayout->setMenuBar(_toolBar);
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-14 19:31:09 +08:00
|
|
|
QJsonObject MonitorPanel::getMonitorInfo() const
|
|
|
|
|
{
|
|
|
|
|
QJsonObject obj;
|
|
|
|
|
QJsonArray arr;
|
|
|
|
|
if(_pModel)
|
|
|
|
|
{
|
|
|
|
|
QMap<QUuid,itemPageInfo> map = _pModel->allNodePos();
|
|
|
|
|
for(auto iter = map.begin();iter != map.end();++iter)
|
|
|
|
|
{
|
|
|
|
|
QJsonObject node;
|
|
|
|
|
node["id"] = iter.key().toString();
|
|
|
|
|
node["x"] = iter.value().pos.x();
|
|
|
|
|
node["y"] = iter.value().pos.y();
|
|
|
|
|
node["width"] = iter.value().dWidth;
|
|
|
|
|
node["height"] = iter.value().dHeight;
|
|
|
|
|
node["rotate"] = iter.value().dRotate;
|
|
|
|
|
arr.append(node);
|
|
|
|
|
}
|
|
|
|
|
obj["nodes"] = arr;
|
|
|
|
|
|
|
|
|
|
QJsonArray arrConnect;
|
|
|
|
|
QVector<ModelProperty*> vec = _pModel->allConnectionProperty();
|
|
|
|
|
for(auto& pPro:vec){
|
|
|
|
|
Connection con = pPro->getConnection();
|
|
|
|
|
QJsonObject connect;
|
|
|
|
|
connect["id"] = pPro->uuid().toString();
|
|
|
|
|
connect["SrcNodeId"] = con.nSrcNodeId.toString();
|
|
|
|
|
connect["SrcPortId"] = con.nSrcPortId.toString();
|
|
|
|
|
connect["DestNodeId"] = con.nDestNodeId.toString();
|
|
|
|
|
connect["DestPortId"] = con.nDestPortId.toString();
|
|
|
|
|
arrConnect.append(connect);
|
|
|
|
|
}
|
|
|
|
|
obj["connections"] = arrConnect;
|
|
|
|
|
|
|
|
|
|
QJsonArray arrBay;
|
|
|
|
|
QMap<QUuid,ElectricBayItem*> mapBay = _pModel->allBayItem();
|
|
|
|
|
for(auto& bayItem:mapBay){
|
|
|
|
|
AbstractProperty* pPro = bayItem->getProperty();
|
|
|
|
|
BayProperty* pBay = dynamic_cast<BayProperty*>(pPro);
|
|
|
|
|
if(pBay)
|
|
|
|
|
{
|
|
|
|
|
QJsonObject bay;
|
|
|
|
|
bay["id"] = pBay->uuid().toString();
|
|
|
|
|
arrBay.append(bay);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
obj["bays"] = arrBay;
|
|
|
|
|
}
|
|
|
|
|
return obj;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MonitorPanel::loadNodes(QJsonObject obj)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MonitorPanel::saveNodes(int pageId)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
2025-11-21 19:22:41 +08:00
|
|
|
|
|
|
|
|
void MonitorPanel::updateSelectedItems(QList<monitorRelationItem> lst,bool val)
|
|
|
|
|
{
|
|
|
|
|
if(val){
|
|
|
|
|
QStandardItem *root = _itemListmodel->invisibleRootItem();
|
|
|
|
|
|
|
|
|
|
int rowCount = root->rowCount();
|
|
|
|
|
if (rowCount > 0) {
|
|
|
|
|
_itemListmodel->removeRows(0, rowCount);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(auto &info:lst){
|
|
|
|
|
auto curItem = info.item;
|
|
|
|
|
if(curItem.nCategory == 0){
|
|
|
|
|
|
|
|
|
|
if(curItem.nEquipType == 1 || curItem.nEquipType == 15 || curItem.nEquipType == 16){ //母线与变压器等间隔外设备并列第一层
|
|
|
|
|
QStandardItem *pItem = new QStandardItem(curItem.sName);
|
|
|
|
|
pItem->setData(curItem.nCategory,Qt::UserRole+1);
|
|
|
|
|
pItem->setData(curItem.nEquipType,Qt::UserRole+2);
|
|
|
|
|
pItem->setData(curItem.uid,Qt::UserRole+3);
|
|
|
|
|
|
|
|
|
|
for(auto& subInfo:info.subList){ //母线挂接间隔,变压器挂接设备
|
|
|
|
|
QStandardItem *pSub = new QStandardItem(subInfo.sName);
|
|
|
|
|
pSub->setData(subInfo.nCategory,Qt::UserRole+1);
|
|
|
|
|
pSub->setData(subInfo.nEquipType,Qt::UserRole+2);
|
|
|
|
|
pSub->setData(subInfo.uid,Qt::UserRole+3);
|
|
|
|
|
pItem->appendRow(pSub);
|
|
|
|
|
}
|
|
|
|
|
_itemListmodel->appendRow(pItem);
|
|
|
|
|
}
|
|
|
|
|
else{ //其他设备挂接在母线下的间隔中
|
|
|
|
|
if(!info.parent.sName.isEmpty()){ //有父,在间隔内
|
|
|
|
|
QStandardItem *pItem = new QStandardItem(curItem.sName);
|
|
|
|
|
pItem->setData(curItem.nCategory,Qt::UserRole+1);
|
|
|
|
|
pItem->setData(curItem.nEquipType,Qt::UserRole+2);
|
|
|
|
|
pItem->setData(curItem.uid,Qt::UserRole+3);
|
|
|
|
|
|
|
|
|
|
auto pParent = findStandardItemAtLevel(_itemListmodel,1,info.parent.sName,nullptr,0); //查找父间隔所在item
|
|
|
|
|
if(pParent){
|
|
|
|
|
pParent->appendRow(pItem);
|
|
|
|
|
}
|
|
|
|
|
else{ //一层没找到父
|
|
|
|
|
QStandardItem *pPar = nullptr;
|
|
|
|
|
pPar = findStandardItemAtLevel(_itemListmodel,0,info.parent.sName,nullptr,0);
|
|
|
|
|
if(pPar){ //顶层中找到
|
|
|
|
|
pPar->appendRow(pItem); //将自己挂到父下
|
|
|
|
|
}
|
|
|
|
|
else{ //顶层未找到,新建
|
|
|
|
|
pPar = new QStandardItem(info.parent.sName);
|
|
|
|
|
pPar->setData(info.parent.nCategory,Qt::UserRole+1);
|
|
|
|
|
pPar->setData(info.parent.nEquipType,Qt::UserRole+2);
|
|
|
|
|
pPar->setData(info.parent.uid,Qt::UserRole+3);
|
|
|
|
|
_itemListmodel->appendRow(pPar);
|
|
|
|
|
pPar->appendRow(pItem); //将自己挂到父下
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
_sideBar->getItemsDlg()->updateItems();
|
|
|
|
|
_pConfigDlg->updateSelectedItems();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MonitorPanel::initMonitorConfig()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MonitorPanel::onRunClicked()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MonitorPanel::onStopClicked()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MonitorPanel::onConfigClicked()
|
|
|
|
|
{
|
|
|
|
|
_pConfigDlg->show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MonitorPanel::onConncecClicked()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|