From ca00ba8ce3c94b68e55b833d75eca4c0fe513eea Mon Sep 17 00:00:00 2001 From: wandererfan Date: Thu, 13 Jun 2024 11:36:13 -0400 Subject: [PATCH] [TD]fix ActiveView image size --- src/Mod/TechDraw/Gui/Grabber3d.cpp | 8 +------- src/Mod/TechDraw/Gui/TaskActiveView.cpp | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/Mod/TechDraw/Gui/Grabber3d.cpp b/src/Mod/TechDraw/Gui/Grabber3d.cpp index 85c8139352e0..d370c70bfb25 100644 --- a/src/Mod/TechDraw/Gui/Grabber3d.cpp +++ b/src/Mod/TechDraw/Gui/Grabber3d.cpp @@ -55,14 +55,8 @@ void Grabber3d::quickView(View3DInventor* view3d, Base::Console().Warning("G3d::quickView - could not create viewer - returning\n"); return; } - //figure out the size of the active MdiView - SbViewportRegion vport(viewer->getSoRenderManager()->getViewportRegion()); - SbVec2s vpSize = vport.getViewportSizePixels(); - short width; - short height; - vpSize.getValue(width, height); int samples = 8; //magic number from Gui::View3DInventorViewer - viewer->savePicture(width, height, samples, bgColor, image); + viewer->savePicture(image.width(), image.height(), samples, bgColor, image); } diff --git a/src/Mod/TechDraw/Gui/TaskActiveView.cpp b/src/Mod/TechDraw/Gui/TaskActiveView.cpp index e0a438706e86..75147a4d1459 100644 --- a/src/Mod/TechDraw/Gui/TaskActiveView.cpp +++ b/src/Mod/TechDraw/Gui/TaskActiveView.cpp @@ -45,12 +45,16 @@ #include "ui_TaskActiveView.h" #include "Grabber3d.h" #include "ViewProviderImage.h" +#include "Rez.h" using namespace Gui; using namespace TechDraw; using namespace TechDrawGui; +constexpr int SXGAWidth{1280}; +constexpr int SXGAHeight{1024}; + //ctor for creation TaskActiveView::TaskActiveView(TechDraw::DrawPage* pageFeat) : ui(new Ui_TaskActiveView), m_pageFeat(pageFeat), m_imageFeat(nullptr), m_btnOK(nullptr), @@ -87,6 +91,9 @@ void TaskActiveView::setUiPrimary() setWindowTitle(QObject::tr("ActiveView to TD View")); ui->cbCrop->setChecked(false); enableCrop(false); + // cropping is in mm, but image size is in pixels/scene units + ui->qsbWidth->setValue(Rez::appX(SXGAWidth)); + ui->qsbHeight->setValue(Rez::appX(SXGAHeight)); } void TaskActiveView::blockButtons(bool b) { Q_UNUSED(b); } @@ -183,9 +190,15 @@ TechDraw::DrawViewImage* TaskActiveView::createActiveView() bg = QColor(Qt::transparent); } - QImage image(100, 100, - QImage::Format_RGB32); //arbitrary initial image size. quickView will use - //MdiView size in pixels + int imageWidth{SXGAWidth}; + int imageHeight{SXGAHeight}; + if (ui->cbCrop->isChecked()) { + imageWidth = Rez::guiX(ui->qsbWidth->rawValue()); + imageHeight = Rez::guiX(ui->qsbHeight->rawValue()); + } + + QImage image(imageWidth, imageHeight, + QImage::Format_RGB32); //arbitrary initial image size. image.fill(QColor(Qt::transparent)); Grabber3d::quickView(view3d, bg, image); bool success = image.save(Base::Tools::fromStdString(tempName));