GraphViewer: Fixed scale of saved PNG/SVG

This commit is contained in:
matlabbe
2017-03-05 11:55:22 -05:00
parent d927b82020
commit 867e8727c1
2 changed files with 13 additions and 2 deletions

View File

@@ -594,6 +594,7 @@ bool DatabaseViewer::openDatabase(const QString & path)
{
pathDatabase_ = UDirectory::getDir(path.toStdString()).c_str();
databaseFileName_ = UFile::getName(path.toStdString());
ui_->graphViewer->setWorkingDirectory(pathDatabase_);
// look if there are saved parameters
ParametersMap parameters = dbDriver_->getLastParameters();

View File

@@ -39,6 +39,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <QColorDialog>
#include <QtSvg/QSvgGenerator>
#include <QInputDialog>
#include <QMessageBox>
#include <QtCore/QDir>
#include <QtCore/QDateTime>
@@ -1391,7 +1392,7 @@ void GraphViewer::contextMenuEvent(QContextMenuEvent * event)
if(_gridCellSize)
{
_root->setScale(1.0f/_gridCellSize); // grid map precision (for 5cm grid cell, x20 to have 1pix/5cm)
_root->setScale(1.0f/(_gridCellSize*100.0f)); // grid map precision (for 5cm grid cell, x20 to have 1pix/5cm)
}
else
{
@@ -1409,7 +1410,16 @@ void GraphViewer::contextMenuEvent(QContextMenuEvent * event)
QPainter painter(&image);
this->scene()->render(&painter);
image.save(targetDir + name);
if(!image.isNull())
{
image.save(targetDir + name);
}
else
{
QMessageBox::warning(this,
tr("Save PNG"),
tr("Could not export in PNG (the scene may be too large %1x%2), try saving in SVG.").arg(sceneSize.width()).arg(sceneSize.height()));
}
}
else
{