HMI/source/drawingPanel.cpp

77 lines
1.7 KiB
C++
Raw Normal View History

2026-07-03 11:29:21 +08:00
#include "drawingPanel.h"
#include "ui_drawingPanel.h"
#include "designerView.h"
#include "designerScene.h"
#include "util/selectorManager.h"
DrawingPanel::DrawingPanel(QWidget *parent)
: QWidget(parent)
, ui(new Ui::drawingPanel)
{
ui->setupUi(this);
2026-07-08 16:57:46 +08:00
m_pGraphicsScene = nullptr;
2026-07-03 11:29:21 +08:00
m_pGraphicsView = new DesignerView(this);
ui->mainLayout->addWidget(m_pGraphicsView);
}
DrawingPanel::~DrawingPanel()
{
delete ui;
}
QGraphicsScene* DrawingPanel::getQGraphicsScene()
{
return m_pGraphicsView->scene();
}
DesignerScene* DrawingPanel::getDesignerScene()
{
return m_pGraphicsScene;
}
void DrawingPanel::grahpicsViewZoomIn()
{
m_pGraphicsView->zoomIn();
}
void DrawingPanel::grahpicsViewZoomOut()
{
m_pGraphicsView->zoomOut();
}
void DrawingPanel::grahpicsViewZoomFit()
{
m_pGraphicsView->zoomFit();
}
GraphicsItemGroup* DrawingPanel::createItemGroup()
{
return m_pGraphicsScene->createGroup();
}
void DrawingPanel::destroyItemGroup()
{
m_pGraphicsScene->destroyGroup();
}
void DrawingPanel::onSignal_addGraphicsItem(GraphicsItemType& itemType)
{
if(SelectorManager::getInstance())
{
SelectorManager::getInstance()->setWorkingSelector(ST_cerating);
SelectorManager::getInstance()->setDrawGraphicsItem(itemType);
}
}
2026-07-08 16:57:46 +08:00
void DrawingPanel::setScene(DesignerScene* scene)
{
m_pGraphicsScene = scene;
m_pGraphicsScene->setSceneRect(-g_dGriaphicsScene_Width / 2, -g_dGriaphicsScene_Height / 2,
g_dGriaphicsScene_Width, g_dGriaphicsScene_Height);
m_pGraphicsScene->setGridVisible(true);
m_pGraphicsView->setScene(m_pGraphicsScene);
m_pGraphicsScene->setView(m_pGraphicsView);
}