From 7df7e29c4c36a378e6db075ea13c280ee28a1236 Mon Sep 17 00:00:00 2001 From: mhugent Date: Sun, 2 May 2004 10:15:16 +0000 Subject: [PATCH] markers sizes in graduated marker dialogs are adjusted when apply is pressed git-svn-id: http://svn.osgeo.org/qgis/trunk@1290 c8812cc2-4d05-0410-92ff-de0c093fc19c --- src/qgsgramadialog.cpp | 2 ++ src/qgsgramaextensionwidget.cpp | 30 ++++++++++++++++++++++++++++-- src/qgsgramaextensionwidget.h | 2 +- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/qgsgramadialog.cpp b/src/qgsgramadialog.cpp index 582b276cbd5..827dbff478e 100644 --- a/src/qgsgramadialog.cpp +++ b/src/qgsgramadialog.cpp @@ -138,6 +138,8 @@ void QgsGraMaDialog::apply() { if (ext) { + ext->adjustMarkers(); + if (mClassificationComboBox->currentText().isEmpty()) //don't do anything, it there is no classification field { return; diff --git a/src/qgsgramaextensionwidget.cpp b/src/qgsgramaextensionwidget.cpp index 77db1f95846..c85ff5c106a 100644 --- a/src/qgsgramaextensionwidget.cpp +++ b/src/qgsgramaextensionwidget.cpp @@ -140,7 +140,9 @@ QgsGraMaExtensionWidget::QgsGraMaExtensionWidget() void QgsGraMaExtensionWidget::selectMarker() { - QgsMarkerDialog mdialog(QDir::homeDirPath()); + //QgsMarkerDialog mdialog(QDir::homeDirPath()); + QgsMarkerDialog mdialog(QString(PKGDATAPATH)+"/svg"); + if(mdialog.exec()==QDialog::Accepted) { QString svgfile=mdialog.selectedMarker(); @@ -200,5 +202,29 @@ void QgsGraMaExtensionWidget::resizeEvent(QResizeEvent* e) void QgsGraMaExtensionWidget::adjustMarkers() { - //soon + for(int i=0;itext().toDouble(); + QPicture pic; + pic.load(((QPushButton*)mWidgetVector[i*5+3])->name(),"svg"); + int width=(int)(pic.boundingRect().width()*scalefactor); + int height=(int)(pic.boundingRect().height()*scalefactor); + + //prevent 0 width or height, which would cause a crash + if(width==0) + { + width=1; + } + if(height==0) + { + height=1; + } + + QPixmap pixmap(height,width); + pixmap.fill(); + QPainter p(&pixmap); + p.scale(scalefactor,scalefactor); + p.drawPicture(0,0,pic); + ((QPushButton *)mWidgetVector[i*5+3])->setPixmap(pixmap); + } } diff --git a/src/qgsgramaextensionwidget.h b/src/qgsgramaextensionwidget.h index 06c784cad66..82d29fe115b 100644 --- a/src/qgsgramaextensionwidget.h +++ b/src/qgsgramaextensionwidget.h @@ -43,7 +43,7 @@ class QgsGraMaExtensionWidget: public QScrollView int classfield(); /**Access to the widget objects. In QgsGraMaDialog, the widgets have to be casted to the proper subclasses to retrieve their information*/ QWidget* getWidget(int column, int row); - /**Resizes the marker images in the dialogs (in case the scale factors may have changed)*/ + /**Resizes all marker images (in case the scale factors may have changed)*/ void adjustMarkers(); protected: