From 3b093bf1292cf49616e53652ce97cda3bcea4a1d Mon Sep 17 00:00:00 2001 From: Jean-Paul Chaput Date: Sat, 18 Nov 2017 12:14:56 +0100 Subject: [PATCH] In Hurricane, make image snaphot great again. --- hurricane/src/viewer/CellImage.cpp | 37 ++++++++++++------- hurricane/src/viewer/CellPrinter.cpp | 4 +- .../src/viewer/hurricane/viewer/CellImage.h | 13 +++---- .../src/viewer/hurricane/viewer/CellPrinter.h | 8 ++-- 4 files changed, 36 insertions(+), 26 deletions(-) diff --git a/hurricane/src/viewer/CellImage.cpp b/hurricane/src/viewer/CellImage.cpp index 81556723..184e54c7 100644 --- a/hurricane/src/viewer/CellImage.cpp +++ b/hurricane/src/viewer/CellImage.cpp @@ -126,22 +126,33 @@ namespace Hurricane { _flags = flags; - int scale = 80 * Cfg::getParamEnumerate("viewer.printer.mode")->asInt(); - _drawingWidth = _cellWidget->width ()*scale; - _drawingHeight = _cellWidget->height()*scale; + //int scale = 80 * Cfg::getParamEnumerate("viewer.printer.mode")->asInt(); + int scale = (Graphics::isHighDpi()) ? 1 : 2; + _drawingWidth = _cellWidget->width () * scale; + _drawingHeight = _cellWidget->height() * scale; _image = new QImage( _drawingWidth , _drawingHeight + ((_flags&ShowScale) ? 60 : 0) , QImage::Format_RGB32 ); - // Compute the delta size between CellImage and CellWidget. - cerr << "CellImage:" << geometry().width() << "x" << geometry().height() << endl; - cerr << "CellWidget: " << _cellWidget->geometry().width() << "x" << _cellWidget->geometry().height() << endl; - cerr << "resize: " << _drawingWidth << "x" << _drawingHeight << endl; - cerr << "AbutmentBox:" << _cellWidget->getCell()->getAbutmentBox() << endl; - cerr << "visibleArea:" << _cellWidget->getVisibleArea() << endl; +// Compute the delta size between CellPrinter and CellWidget. + cerr << "Image/Screen settings:" << endl; +//cerr << " Screen Resolution (DPI): " << resolution() << endl; + cerr << " CellImage: " << geometry().width() << "x" << geometry().height() << endl; + cerr << " CellWidget: " << _cellWidget->geometry().width() << "x" << _cellWidget->geometry().height() << endl; + cerr << " ScreenCellWidget: " << _screenCellWidget->geometry().width() << "x" << _screenCellWidget->geometry().height() << endl; + cerr << " resize: " << _drawingWidth << "x" << _drawingHeight << endl; + cerr << " AbutmentBox: " << _cellWidget->getCell()->getAbutmentBox() << endl; + cerr << " visibleArea: " << _cellWidget->getVisibleArea() << endl; - resize ( _drawingWidth, _drawingHeight ); + // Compute the delta size between CellImage and CellWidget. + // cerr << "CellImage:" << geometry().width() << "x" << geometry().height() << endl; + // cerr << "CellWidget: " << _cellWidget->geometry().width() << "x" << _cellWidget->geometry().height() << endl; + // cerr << "resize: " << _drawingWidth << "x" << _drawingHeight << endl; + // cerr << "AbutmentBox:" << _cellWidget->getCell()->getAbutmentBox() << endl; + // cerr << "visibleArea:" << _cellWidget->getVisibleArea() << endl; + + resize( _drawingWidth, _drawingHeight ); Box visibleArea = _screenCellWidget->getVisibleArea(); if ( visibleArea.contains(_screenCellWidget->getCell()->getAbutmentBox()) ) { @@ -151,9 +162,9 @@ namespace Hurricane { _cellWidget->reframe( _screenCellWidget->getVisibleArea() ); } - cerr << "After resize CellWidget: " << _cellWidget->geometry().width() << "x" << _cellWidget->geometry().height() << endl; - cerr << "visibleArea(image):" << _cellWidget->getVisibleArea() << endl; - cerr << "visibleArea(screen): " << _screenCellWidget->getVisibleArea() << endl; + cerr << " After resize CellWidget: " << _cellWidget->geometry().width() << "x" << _cellWidget->geometry().height() << endl; + cerr << " VisibleArea(printer): " << _cellWidget->getVisibleArea() << endl; + cerr << " VisibleArea(screen): " << _screenCellWidget->getVisibleArea() << endl; //cerr << "(xpaper,ypaper) = (" << xpaper << "," << ypaper << ")" << endl; //cerr << "(w,h) = (" << w << "," << h << ")" << endl; diff --git a/hurricane/src/viewer/CellPrinter.cpp b/hurricane/src/viewer/CellPrinter.cpp index c741043c..9690bd7c 100644 --- a/hurricane/src/viewer/CellPrinter.cpp +++ b/hurricane/src/viewer/CellPrinter.cpp @@ -8,7 +8,7 @@ // | V L S I B a c k e n d D a t a - B a s e | // | | // | Author : Jean-Paul CHAPUT | -// | E-mail : Jean-Paul.Chaput@asim.lip6.fr | +// | E-mail : Jean-Paul.Chaput@lip6.fr | // | =============================================================== | // | C++ Module : "./CellPrinter.cpp" | // +-----------------------------------------------------------------+ @@ -330,7 +330,7 @@ namespace Hurricane { // swap( _xpaper , _ypaper ); // } - resize ( _drawingWidth, _drawingHeight ); + resize( _drawingWidth, _drawingHeight ); Box visibleArea = _screenCellWidget->getVisibleArea(); if ( visibleArea.contains(_screenCellWidget->getCell()->getAbutmentBox()) ) { diff --git a/hurricane/src/viewer/hurricane/viewer/CellImage.h b/hurricane/src/viewer/hurricane/viewer/CellImage.h index 99d9d2cf..2cd4f670 100644 --- a/hurricane/src/viewer/hurricane/viewer/CellImage.h +++ b/hurricane/src/viewer/hurricane/viewer/CellImage.h @@ -2,28 +2,27 @@ // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2012-2012, All Rights Reserved +// Copyright (c) UPMC/LIP6 2012-2016, All Rights Reserved // // +-----------------------------------------------------------------+ // | H U R R I C A N E | // | V L S I B a c k e n d D a t a - B a s e | // | | // | Author : Jean-Paul CHAPUT | -// | E-mail : Jean-Paul.Chaput@asim.lip6.fr | +// | E-mail : Jean-Paul.Chaput@lip6.fr | // | =============================================================== | // | C++ Header : "./hurricane/viewer/CellImage.h" | // +-----------------------------------------------------------------+ -#ifndef __HURRICANE_CELL_IMAGE__ -#define __HURRICANE_CELL_IMAGE__ +#ifndef HURRICANE_CELL_IMAGE_H +#define HURRICANE_CELL_IMAGE_H -#include - +#include using namespace std; -#include +#include class QEvent; class QKeyEvent; diff --git a/hurricane/src/viewer/hurricane/viewer/CellPrinter.h b/hurricane/src/viewer/hurricane/viewer/CellPrinter.h index 8749f6b4..7ceed7f8 100644 --- a/hurricane/src/viewer/hurricane/viewer/CellPrinter.h +++ b/hurricane/src/viewer/hurricane/viewer/CellPrinter.h @@ -2,21 +2,21 @@ // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2012-2012, All Rights Reserved +// Copyright (c) UPMC/LIP6 2012-2016, All Rights Reserved // // +-----------------------------------------------------------------+ // | H U R R I C A N E | // | V L S I B a c k e n d D a t a - B a s e | // | | // | Author : Jean-Paul CHAPUT | -// | E-mail : Jean-Paul.Chaput@asim.lip6.fr | +// | E-mail : Jean-Paul.Chaput@lip6.fr | // | =============================================================== | // | C++ Header : "./hurricane/viewer/CellPrinter.h" | // +-----------------------------------------------------------------+ -#ifndef __HURRICANE_CELL_PRINTER__ -#define __HURRICANE_CELL_PRINTER__ +#ifndef HURRICANE_CELL_PRINTER_H +#define HURRICANE_CELL_PRINTER_H #include