PowerDesigner/source/drawingPanel.cpp

72 lines
1.8 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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 = new DesignerScene(this);
//设置场景大小.前两个参数为scene的坐标远点设置到view的中心点后无论view如何缩放secne的坐标原点都不会动方便后续的位置计算
m_pGraphicsScene->setSceneRect(-g_dGriaphicsScene_Width / 2, -g_dGriaphicsScene_Height / 2, g_dGriaphicsScene_Width, g_dGriaphicsScene_Height);
m_pGraphicsScene->setGridVisible(true);
m_pGraphicsView = new DesignerView(this);
m_pGraphicsView->setScene(m_pGraphicsScene);
m_pGraphicsScene->setView(m_pGraphicsView);
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);
}
}