JFJochMagnifierWindow: Zoom is saved ... it is not optimal (when image is first loaded, than it starts with weird zoom), but can be fixed later
This commit is contained in:
@@ -948,4 +948,17 @@ void JFJochImage::adjustForeground(bool input) {
|
||||
|
||||
void JFJochImage::beforeOverlayCleared() {}
|
||||
|
||||
double JFJochImage::GetScaleFactor() const {
|
||||
return scale_factor;
|
||||
}
|
||||
|
||||
void JFJochImage::setZoom(double input) {
|
||||
if (std::isfinite(input) && input > 0) {
|
||||
scale_factor = input;
|
||||
if (!scene())
|
||||
return;
|
||||
scale(input, input);
|
||||
updateOverlay();
|
||||
emitViewportChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,7 +131,8 @@ public slots:
|
||||
void fitToView();
|
||||
|
||||
void adjustForeground(bool input);
|
||||
|
||||
void setZoom(double input);
|
||||
public:
|
||||
explicit JFJochImage(QWidget *parent = nullptr);
|
||||
double GetScaleFactor() const;
|
||||
};
|
||||
@@ -11,6 +11,7 @@ JFJochMagnifierWindow::JFJochMagnifierWindow(QWidget *parent)
|
||||
: JFJochHelperWindow(parent) {
|
||||
setWindowTitle("Magnifier");
|
||||
m_image = new JFJochSimpleImage(this);
|
||||
m_image->setZoom(m_magnification);
|
||||
setCentralWidget(m_image);
|
||||
resize(320, 320);
|
||||
}
|
||||
@@ -25,11 +26,13 @@ void JFJochMagnifierWindow::imageLoaded(std::shared_ptr<const JFJochReaderImage>
|
||||
auto si = std::make_shared<SimpleImage>();
|
||||
si->image = CompressedImage(image->Image(), exp.GetXPixelsNum(), exp.GetYPixelsNum());
|
||||
m_image->setImage(si);
|
||||
m_image->setZoom(m_magnification);
|
||||
m_have_image = true;
|
||||
}
|
||||
|
||||
void JFJochMagnifierWindow::centerAt(QPointF scenePos) {
|
||||
if (!m_have_image || !isVisible())
|
||||
return;
|
||||
m_image->applyViewport(QTransform::fromScale(m_magnification, m_magnification), scenePos);
|
||||
double scale = m_image->GetScaleFactor();
|
||||
m_image->applyViewport(QTransform::fromScale(scale, scale), scenePos);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user