DiagramDesigner/diagramCavas/source/diagramEditor/editPanel.cpp

69 lines
2.1 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 <QVBoxLayout>
#include <QGraphicsWidget>
#include <QGraphicsGridLayout>
#include <QPushButton>
#include <QGraphicsProxyWidget>
#include "diagramEditor/editPanel.h"
#include "diagramEditor/editScene.h"
#include "diagramEditor/editView.h"
#include "diagramEditor/editRowData.h"
#include "diagramEditor/editMainRect.h"
#include "diagramEditor/editBlock.h"
#include "global.h"
#include <QDebug>
EditPanel::EditPanel(QWidget *parent)
: QWidget(parent)
{
_maxWidth = 0;
_maxHeight = 0;
_layout = new QVBoxLayout(this);
m_pEditScene = new EditScene(this);
//设置场景大小.前两个参数为scene的坐标远点设置到view的中心点后无论view如何缩放secne的坐标原点都不会动方便后续的位置计算
//m_pEditScene->setSceneRect(-g_dGriaphicsScene_Width / 2, -g_dGriaphicsScene_Height / 2, g_dGriaphicsScene_Width, g_dGriaphicsScene_Height);
m_pEditScene->setSceneRect(0, 0, g_dGriaphicsScene_Width*4, g_dGriaphicsScene_Height*4);
m_pEditView = new EditView(this);
m_pEditView->setScene(m_pEditScene);
_layout->addWidget(m_pEditView);
initial();
setStyleSheet("backGround-color:rgb(112,128,144);");
}
EditPanel::~EditPanel()
{
}
void EditPanel::initByWizardInfo()
{
_widgetLayout->addStretch();
}
void EditPanel::onWidthChanged(int width)
{
if(_maxWidth < width)
{
_maxWidth = width;
int x = _mainWidget->geometry().width();
int y = _mainWidget->geometry().y();
_mainWidget->setGeometry(x,y,_maxWidth,_maxHeight);
m_pEditScene->setSceneRect(x,y,_maxWidth,_maxHeight);
m_pEditView->viewport()->update();
//qDebug()<<m_pEditScene->sceneRect();
}
}
void EditPanel::initial()
{
_mainWidget = new EditMainRect;
_widgetLayout = new QGraphicsLinearLayout(Qt::Vertical);
_widgetLayout->setSpacing(6);
_mainWidget->setLayout(_widgetLayout);
m_pEditScene->addItem(_mainWidget);
_mainWidget->setGeometry(m_pEditScene->sceneRect());
_maxWidth = _mainWidget->rect().width();
_maxHeight = _mainWidget->rect().height();
m_pEditView->centerOn(0,0);
}