diff --git a/src/app/tablewindow.cpp b/src/app/tablewindow.cpp index 1c7dc0b36..90394f4fe 100644 --- a/src/app/tablewindow.cpp +++ b/src/app/tablewindow.cpp @@ -56,26 +56,27 @@ TableWindow::TableWindow(QWidget *parent) ui->statusBar->addWidget(numberDetal); ui->statusBar->addWidget(colission); outItems = collidingItems = false; - //sceneRect = QRectF(0, 0, qApp->toPixel(203), qApp->toPixel(287)); sceneRect = QRectF(0, 0, qApp->toPixel(823, Unit::Mm), qApp->toPixel(1171, Unit::Mm)); tableScene = new QGraphicsScene(sceneRect); QBrush brush; brush.setStyle( Qt::SolidPattern ); brush.setColor( QColor( Qt::gray ) ); tableScene->setBackgroundBrush( brush ); - VTableGraphicsView* view = new VTableGraphicsView(tableScene); - view->fitInView(view->scene()->sceneRect(), Qt::KeepAspectRatio); - ui->horizontalLayout->addWidget(view); - connect(ui->actionTurn, &QAction::triggered, view, &VTableGraphicsView::rotateItems); - connect(ui->actionMirror, &QAction::triggered, view, &VTableGraphicsView::MirrorItem); - connect(ui->actionZoomIn, &QAction::triggered, view, &VTableGraphicsView::ZoomIn); - connect(ui->actionZoomOut, &QAction::triggered, view, &VTableGraphicsView::ZoomOut); + + ui->view->setScene(tableScene); + ui->view->fitInView(ui->view->scene()->sceneRect(), Qt::KeepAspectRatio); + ui->horizontalLayout->addWidget(ui->view); + connect(tableScene, &QGraphicsScene::selectionChanged, ui->view, &VTableGraphicsView::selectionChanged); + connect(ui->actionTurn, &QAction::triggered, ui->view, &VTableGraphicsView::rotateItems); + connect(ui->actionMirror, &QAction::triggered, ui->view, &VTableGraphicsView::MirrorItem); + connect(ui->actionZoomIn, &QAction::triggered, ui->view, &VTableGraphicsView::ZoomIn); + connect(ui->actionZoomOut, &QAction::triggered, ui->view, &VTableGraphicsView::ZoomOut); connect(ui->actionStop, &QAction::triggered, this, &TableWindow::StopTable); connect(ui->actionSave, &QAction::triggered, this, &TableWindow::saveScene); connect(ui->actionNext, &QAction::triggered, this, &TableWindow::GetNextDetail); connect(ui->actionAdd, &QAction::triggered, this, &TableWindow::AddLength); connect(ui->actionRemove, &QAction::triggered, this, &TableWindow::RemoveLength); - connect(view, &VTableGraphicsView::itemChect, this, &TableWindow::itemChect); + connect(ui->view, &VTableGraphicsView::itemChect, this, &TableWindow::itemChect); } //--------------------------------------------------------------------------------------------------------------------- @@ -199,6 +200,7 @@ void TableWindow::showEvent ( QShowEvent * event ) { QMainWindow::showEvent(event); moveToCenter(); + ui->view->fitInView(ui->view->scene()->sceneRect(), Qt::KeepAspectRatio); } //--------------------------------------------------------------------------------------------------------------------- @@ -211,8 +213,8 @@ void TableWindow::StopTable() tableScene->clear(); delete listOutItems; listDetails.clear(); - //sceneRect = QRectF(0, 0, 230*resol/25.9, 327*resol/25.9); sceneRect = QRectF(0, 0, qApp->toPixel(823, Unit::Mm), qApp->toPixel(1171, Unit::Mm)); + tableScene->setSceneRect(sceneRect); emit closed(); } diff --git a/src/app/tablewindow.ui b/src/app/tablewindow.ui index 5d5814fcf..8f237a1d5 100644 --- a/src/app/tablewindow.ui +++ b/src/app/tablewindow.ui @@ -37,6 +37,9 @@ 9 + + + @@ -198,6 +201,13 @@ + + + VTableGraphicsView + QGraphicsView +
vtablegraphicsview.h
+
+
diff --git a/src/app/widgets/vtablegraphicsview.cpp b/src/app/widgets/vtablegraphicsview.cpp index 5d21f03eb..e2028e54a 100644 --- a/src/app/widgets/vtablegraphicsview.cpp +++ b/src/app/widgets/vtablegraphicsview.cpp @@ -36,11 +36,10 @@ #include "../options.h" //--------------------------------------------------------------------------------------------------------------------- -VTableGraphicsView::VTableGraphicsView(QGraphicsScene* pScene, QWidget *parent) - :QGraphicsView(pScene, parent) +VTableGraphicsView::VTableGraphicsView(QWidget *parent) + :QGraphicsView(parent) { QGraphicsView::setResizeAnchor(QGraphicsView::AnchorUnderMouse); - connect(pScene, &QGraphicsScene::selectionChanged, this, &VTableGraphicsView::selectionChanged); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/widgets/vtablegraphicsview.h b/src/app/widgets/vtablegraphicsview.h index a627d2e31..6b523c71f 100644 --- a/src/app/widgets/vtablegraphicsview.h +++ b/src/app/widgets/vtablegraphicsview.h @@ -43,7 +43,7 @@ public: */ enum typeMove_e { Left, Right, Up, Down }; - VTableGraphicsView(QGraphicsScene* pScene, QWidget *parent = nullptr); + VTableGraphicsView(QWidget *parent = nullptr); signals: /** * @brief itemChect emit after change selection state detail.