Skip to content

Commit

Permalink
[TD]fix ActiveView image size
Browse files Browse the repository at this point in the history
  • Loading branch information
WandererFan committed Jun 13, 2024
1 parent b3b9614 commit ca00ba8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
8 changes: 1 addition & 7 deletions src/Mod/TechDraw/Gui/Grabber3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

19 changes: 16 additions & 3 deletions src/Mod/TechDraw/Gui/TaskActiveView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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); }
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit ca00ba8

Please sign in to comment.