2025-11-14 19:31:09 +08:00
|
|
|
|
#include <QJsonArray>
|
|
|
|
|
|
#include "baseDrawingPanel.h"
|
|
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
|
#include <QCloseEvent>
|
|
|
|
|
|
#include "designerView.h"
|
|
|
|
|
|
#include "graphicsDataModel/fixedPortsModel.h"
|
|
|
|
|
|
#include "graphicsItem/graphicsBaseItem.h"
|
|
|
|
|
|
#include "util/selectorManager.h"
|
|
|
|
|
|
#include "statusBar.h"
|
|
|
|
|
|
#include "powerEntity.h"
|
|
|
|
|
|
#include "topologyManager.h"
|
|
|
|
|
|
|
|
|
|
|
|
BaseDrawingPanel::BaseDrawingPanel(PowerEntity* pEntity,QWidget *parent,DiagramMode mode)
|
|
|
|
|
|
: QWidget(parent)
|
|
|
|
|
|
,_pModel(nullptr)
|
|
|
|
|
|
,_mode(mode)
|
|
|
|
|
|
,_pEntity(pEntity)
|
2025-11-21 19:22:41 +08:00
|
|
|
|
,_verticalLayout(nullptr)
|
|
|
|
|
|
,_horizontalLayout(nullptr)
|
|
|
|
|
|
,_hSplitter(nullptr)
|
2025-11-14 19:31:09 +08:00
|
|
|
|
{
|
|
|
|
|
|
_pModel = new FixedPortsModel(pEntity);
|
|
|
|
|
|
_pModel->setTopWidget(this);
|
|
|
|
|
|
m_pSelectorManager = new SelectorManager(_pModel,this);
|
|
|
|
|
|
m_pGraphicsScene = new DesignerScene(_pModel,this);
|
|
|
|
|
|
//设置场景大小.前两个参数为scene的坐标远点,设置到view的中心点后,无论view如何缩放,secne的坐标原点都不会动,方便后续的位置计算
|
|
|
|
|
|
m_pGraphicsScene->setSceneRect(0,0, g_dGriaphicsScene_Width*4, g_dGriaphicsScene_Height*4);
|
|
|
|
|
|
m_pGraphicsScene->setGridVisible(true);
|
|
|
|
|
|
|
|
|
|
|
|
m_pGraphicsView = new DesignerView(this);
|
|
|
|
|
|
m_pGraphicsView->setScene(m_pGraphicsScene);
|
|
|
|
|
|
m_pGraphicsView->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
|
|
|
|
|
|
m_pGraphicsScene->setView(m_pGraphicsView);
|
|
|
|
|
|
_pModel->setScene(m_pGraphicsScene);
|
|
|
|
|
|
|
|
|
|
|
|
m_pStatusBar = new StatusBar(this);
|
2025-11-25 20:29:32 +08:00
|
|
|
|
m_pStatusBar->setMaximumHeight(25);
|
2025-11-14 19:31:09 +08:00
|
|
|
|
connect(m_pGraphicsView,&DesignerView::onScaleChanged,m_pStatusBar,&StatusBar::onScaleLevelChanged);
|
|
|
|
|
|
|
2025-11-21 19:22:41 +08:00
|
|
|
|
_horizontalLayout = new QHBoxLayout();
|
|
|
|
|
|
//_horizontalLayout->addWidget(m_pGraphicsView);
|
|
|
|
|
|
_horizontalLayout->setContentsMargins(0, 0, 0, 0);
|
|
|
|
|
|
_horizontalLayout->setSpacing(0);
|
|
|
|
|
|
|
|
|
|
|
|
_hSplitter = new QSplitter(Qt::Horizontal);
|
|
|
|
|
|
_hSplitter->setHandleWidth(2); // 设置分割条宽度
|
|
|
|
|
|
|
|
|
|
|
|
_hSplitter->addWidget(m_pGraphicsView);
|
|
|
|
|
|
_horizontalLayout->addWidget(_hSplitter);
|
|
|
|
|
|
|
|
|
|
|
|
_verticalLayout = new QVBoxLayout(this);
|
|
|
|
|
|
_verticalLayout->addLayout(_horizontalLayout);
|
|
|
|
|
|
_verticalLayout->addWidget(m_pStatusBar);
|
|
|
|
|
|
_verticalLayout->setContentsMargins(0, 0, 0, 0);
|
|
|
|
|
|
_verticalLayout->setSpacing(0);
|
2025-11-14 19:31:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BaseDrawingPanel::~BaseDrawingPanel()
|
|
|
|
|
|
{
|
|
|
|
|
|
if(_pModel)
|
|
|
|
|
|
delete _pModel;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QGraphicsScene* BaseDrawingPanel::getQGraphicsScene()
|
|
|
|
|
|
{
|
|
|
|
|
|
return m_pGraphicsView->scene();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DesignerScene* BaseDrawingPanel::getDesignerScene()
|
|
|
|
|
|
{
|
|
|
|
|
|
return m_pGraphicsScene;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SelectorManager* BaseDrawingPanel::selectorManager() const
|
|
|
|
|
|
{
|
|
|
|
|
|
if(m_pSelectorManager)
|
|
|
|
|
|
return m_pSelectorManager;
|
|
|
|
|
|
else
|
|
|
|
|
|
return NULL;
|
|
|
|
|
|
}
|
|
|
|
|
|
|