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
This commit is contained in:
mhugent 2004-05-02 10:15:16 +00:00
parent 3283a2892f
commit 7df7e29c4c
3 changed files with 31 additions and 3 deletions

View File

@ -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;

View File

@ -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;i<mNumberOfClasses;++i)
{
double scalefactor=((QLineEdit*)mWidgetVector[i*5+4])->text().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);
}
}

View File

@ -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: