fixed the bug which prevented the proper loading of graduated symbol layers from project files

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@1986 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
mhugent 2004-09-11 16:34:12 +00:00
parent d8fe1cb731
commit a09fae81f0
3 changed files with 15 additions and 65 deletions

View File

@ -8,8 +8,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>637</width>
<height>523</height>
<width>531</width>
<height>328</height>
</rect>
</property>
<property name="caption">

View File

@ -99,69 +99,7 @@ void QgsGraduatedSymRenderer::initializeSymbology(QgsVectorLayer * layer, QgsDlg
if (layer)
{
QgsSymbol* sy = new QgsSymbol();
sy->brush().setStyle(Qt::SolidPattern);
sy->pen().setStyle(Qt::SolidLine);
sy->pen().setWidth(1);//set width 1 as default instead of width 0
//random fill colors for points and polygons and pen colors for lines
int red = 1 + (int) (255.0 * rand() / (RAND_MAX + 1.0));
int green = 1 + (int) (255.0 * rand() / (RAND_MAX + 1.0));
int blue = 1 + (int) (255.0 * rand() / (RAND_MAX + 1.0));
//font tor the legend text
QFont f("arial", 10, QFont::Normal);
QFontMetrics fm(f);
QPixmap *pixmap;
if (toproperties)
{
pixmap = pr->getBufferPixmap();
}
else
{
pixmap = layer->legendPixmap();
}
QString name = layer->name();
int width = 40 + fm.width(layer->name());
int height = (fm.height() + 10 > 35) ? fm.height() + 10 : 35;
pixmap->resize(width, height);
pixmap->fill();
QPainter p(pixmap);
if (layer->vectorType() == QGis::Line)
{
sy->pen().setColor(QColor(red, green, blue));
//paint the pixmap for the legend
p.setPen(sy->pen());
p.drawLine(10, pixmap->height() - 25, 25, pixmap->height() - 10);
}
else
{
sy->brush().setColor(QColor(red, green, blue));
sy->pen().setColor(QColor(0, 0, 0));
//paint the pixmap for the legend
p.setPen(sy->pen());
p.setBrush(sy->brush());
if (layer->vectorType() == QGis::Point)
{
p.drawRect(20, pixmap->height() - 17, 5, 5);
}
else //polygon
{
p.drawRect(10, pixmap->height() - 25, 20, 15);
}
}
p.setPen(Qt::black);
p.setFont(f);
p.drawText(35, pixmap->height() - 10, name);
QgsRangeRenderItem *ri = new QgsRangeRenderItem(sy, QString::number(-DBL_MAX, 'f', 2), QString::number(DBL_MAX, 'f', 2), "");
addItem(ri);
QgsGraSyDialog *dialog = new QgsGraSyDialog(layer);
if (toproperties)

View File

@ -94,7 +94,19 @@ QgsGraSyDialog::QgsGraSyDialog(QgsVectorLayer * layer):QgsGraSyDialogBase(), mVe
classificationComboBox->setCurrentItem(renderer->classificationField());
QGis::VectorType m_type = mVectorLayer->vectorType();
numberofclassesspinbox->setValue(list.size());
//todo: fill mValue with the setting of the (single) renderitem and apply to the sisydialog
//fill the items of the renderer into mValues
for(std::list<QgsRangeRenderItem*>::iterator it=list.begin();it!=list.end();++it)
{
QgsRangeRenderItem* item=(*it);
QString classbreak=item->value()+" - "+item->upper_value();
QgsSymbol* sym=new QgsSymbol();
QgsRangeRenderItem* rritem=new QgsRangeRenderItem(sym,item->value(),item->upper_value(),item->label());
sym->setPen(item->getSymbol()->pen());
sym->setBrush(item->getSymbol()->brush());
mEntries.insert(std::make_pair(classbreak,rritem));
mClassBreakBox->insertItem(classbreak);
}
}
//do the necessary signal/slot connections