#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); m_pGraphicsScene = nullptr; 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); } } 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); }