fixed some problems due to changes in the vectorlayerproperties and in the renderer dialogs

git-svn-id: http://svn.osgeo.org/qgis/trunk@626 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
mhugent 2004-01-28 15:11:51 +00:00
parent 8c91ca4efb
commit 6482e1ab65
5 changed files with 94 additions and 74 deletions

View File

@ -50,7 +50,18 @@ QgsContColDialog::QgsContColDialog(QgsVectorLayer* layer): QgsContColDialogBase(
} }
//restore the correct colors for minimum and maximum values //restore the correct colors for minimum and maximum values
QgsContinuousColRenderer* renderer=dynamic_cast<QgsContinuousColRenderer*>(m_vectorlayer->renderer());
QgsContinuousColRenderer* renderer;
if(m_vectorlayer->propertiesDialog())
{
renderer=dynamic_cast<QgsContinuousColRenderer*>(layer->propertiesDialog()->getBufferRenderer());
}
else
{
renderer=dynamic_cast<QgsContinuousColRenderer*>(layer->renderer());
}
if(renderer) if(renderer)
{ {
QgsRenderItem* minitem=renderer->minimumItem(); QgsRenderItem* minitem=renderer->minimumItem();
@ -130,6 +141,7 @@ void QgsContColDialog::apply()
//set the render items to the buffer renderer of the property dialog //set the render items to the buffer renderer of the property dialog
QgsContinuousColRenderer* renderer=dynamic_cast<QgsContinuousColRenderer*>(m_vectorlayer->propertiesDialog()->getBufferRenderer()); QgsContinuousColRenderer* renderer=dynamic_cast<QgsContinuousColRenderer*>(m_vectorlayer->propertiesDialog()->getBufferRenderer());
if(renderer) if(renderer)
{ {
renderer->setMinimumItem(minimumitem); renderer->setMinimumItem(minimumitem);

View File

@ -70,10 +70,20 @@ QgsGraSyDialog::QgsGraSyDialog(QgsVectorLayer* layer): QgsGraSyDialogBase(), ext
setSizeGripEnabled(true); setSizeGripEnabled(true);
if(!m_vectorlayer->propertiesDialog()->getRendererDirty())
{
//restore the correct settings //restore the correct settings
QgsGraduatedSymRenderer* renderer=dynamic_cast<QgsGraduatedSymRenderer*>(m_vectorlayer->renderer()); QgsGraduatedSymRenderer* renderer;
//initial settings, use the buffer of the propertiesDialog if possible. If this is not possible, use the renderer of the vectorlayer directly
if(m_vectorlayer->propertiesDialog())
{
renderer=dynamic_cast<QgsGraduatedSymRenderer*>(layer->propertiesDialog()->getBufferRenderer());
}
else
{
renderer=dynamic_cast<QgsGraduatedSymRenderer*>(layer->renderer());
}
if(renderer) if(renderer)
{ {
std::list<QgsRangeRenderItem*> list=renderer->items(); std::list<QgsRangeRenderItem*> list=renderer->items();
@ -118,7 +128,7 @@ QgsGraSyDialog::QgsGraSyDialog(QgsVectorLayer* layer): QgsGraSyDialogBase(), ext
QgsGraSyDialogBaseLayout->addMultiCellWidget(scv,5,5,0,3); QgsGraSyDialogBaseLayout->addMultiCellWidget(scv,5,5,0,3);
scv->show(); scv->show();
} }
}
//do the necessary signal/slot connections //do the necessary signal/slot connections
QObject::connect(numberofclassesspinbox,SIGNAL(valueChanged(int)),this,SLOT(adjustNumberOfClasses())); QObject::connect(numberofclassesspinbox,SIGNAL(valueChanged(int)),this,SLOT(adjustNumberOfClasses()));
@ -189,7 +199,6 @@ void QgsGraSyDialog::adjustNumberOfClasses()
void QgsGraSyDialog::apply() void QgsGraSyDialog::apply()
{ {
qWarning("1");
if(ext) if(ext)
{ {
if(classificationComboBox->currentText().isEmpty())//don't do anything, it there is no classification field if(classificationComboBox->currentText().isEmpty())//don't do anything, it there is no classification field
@ -223,7 +232,6 @@ void QgsGraSyDialog::apply()
} }
} }
int labelwidth=fm.width(widestlabel); int labelwidth=fm.width(widestlabel);
qWarning("2");
//create the pixmap for the render item //create the pixmap for the render item
QPixmap* pix=m_vectorlayer->legendPixmap(); QPixmap* pix=m_vectorlayer->legendPixmap();
QString name=displaynamefield->text(); QString name=displaynamefield->text();
@ -236,7 +244,6 @@ void QgsGraSyDialog::apply()
pix->fill(); pix->fill();
QPainter p(pix); QPainter p(pix);
p.setFont(f); p.setFont(f);
qWarning("3");
//draw the layer name and the name of the classification field into the pixmap //draw the layer name and the name of the classification field into the pixmap
p.drawText(leftspace,topspace+fm.height(),name); p.drawText(leftspace,topspace+fm.height(),name);
m_vectorlayer->setLayerName(name); m_vectorlayer->setLayerName(name);
@ -253,7 +260,6 @@ void QgsGraSyDialog::apply()
int offset=topspace+2*fm.height(); int offset=topspace+2*fm.height();
int rowincrement=rowheight+rowspace; int rowincrement=rowheight+rowspace;
qWarning("4");
for(int i=0;i<numberofclassesspinbox->value();i++) for(int i=0;i<numberofclassesspinbox->value();i++)
{ {
QgsSymbol sy(QColor(255,0,0)); QgsSymbol sy(QColor(255,0,0));
@ -284,7 +290,6 @@ void QgsGraSyDialog::apply()
{ {
sy.brush().setStyle(Qt::SolidPattern); sy.brush().setStyle(Qt::SolidPattern);
} }
qWarning("5");
QString lower_bound=((QLineEdit*)(ext->getWidget(0,i)))->text(); QString lower_bound=((QLineEdit*)(ext->getWidget(0,i)))->text();
QString upper_bound=((QLineEdit*)(ext->getWidget(1,i)))->text(); QString upper_bound=((QLineEdit*)(ext->getWidget(1,i)))->text();
QString label=((QLineEdit*)(ext->getWidget(2,i)))->text(); QString label=((QLineEdit*)(ext->getWidget(2,i)))->text();
@ -308,7 +313,6 @@ void QgsGraSyDialog::apply()
ubcontainsletter=true; ubcontainsletter=true;
} }
} }
qWarning("6");
if(lbcontainsletter==false&&ubcontainsletter==false&&lower_bound.length()>0&&upper_bound.length()>0)//only add the item if the value bounds do not contain letters and are not null strings if(lbcontainsletter==false&&ubcontainsletter==false&&lower_bound.length()>0&&upper_bound.length()>0)//only add the item if the value bounds do not contain letters and are not null strings
{ {
QgsRangeRenderItem* item = new QgsRangeRenderItem(sy, lower_bound, upper_bound, ((QLineEdit*)(ext->getWidget(2,i)))->text()); QgsRangeRenderItem* item = new QgsRangeRenderItem(sy, lower_bound, upper_bound, ((QLineEdit*)(ext->getWidget(2,i)))->text());
@ -336,21 +340,16 @@ void QgsGraSyDialog::apply()
p.drawText(pixwidth-labelwidth-rightspace,offset+rowincrement*i+rowheight,label); p.drawText(pixwidth-labelwidth-rightspace,offset+rowincrement*i+rowheight,label);
} }
} }
qWarning("7");
renderer->setClassificationField(ext->classfield()); renderer->setClassificationField(ext->classfield());
if(m_vectorlayer->legendItem()) if(m_vectorlayer->legendItem())
{ {
m_vectorlayer->legendItem()->setPixmap(0,(*pix)); m_vectorlayer->legendItem()->setPixmap(0,(*pix));
} }
qWarning("8");
m_vectorlayer->setRenderer(renderer); m_vectorlayer->setRenderer(renderer);
qWarning("9");
m_vectorlayer->setRendererDialog(this); m_vectorlayer->setRendererDialog(this);
m_vectorlayer->propertiesDialog()->unsetRendererDirty(); m_vectorlayer->propertiesDialog()->unsetRendererDirty();
qWarning("10");
m_vectorlayer->triggerRepaint(); m_vectorlayer->triggerRepaint();
qWarning("11");
} }
else//number of classes is 0 else//number of classes is 0

View File

@ -41,7 +41,6 @@ void QgsSingleSymRenderer::addItem(QgsRenderItem ri)
void QgsSingleSymRenderer::renderFeature(QPainter* p, QgsFeature* f, QgsCoordinateTransform* t) void QgsSingleSymRenderer::renderFeature(QPainter* p, QgsFeature* f, QgsCoordinateTransform* t)
{ {
qWarning("rendere feature");
p->setPen(m_item.getSymbol()->pen()); p->setPen(m_item.getSymbol()->pen());
p->setBrush(m_item.getSymbol()->brush()); p->setBrush(m_item.getSymbol()->brush());
unsigned char *feature= f->getGeometry(); unsigned char *feature= f->getGeometry();

View File

@ -43,7 +43,19 @@ QgsSiSyDialog::QgsSiSyDialog(QgsVectorLayer* layer): QgsSiSyDialogBase(), m_vect
{ {
//Set the initial display name //Set the initial display name
displaynamefield->setText(m_vectorlayer->name()); displaynamefield->setText(m_vectorlayer->name());
QgsSingleSymRenderer* renderer=dynamic_cast<QgsSingleSymRenderer*>(layer->renderer());
QgsSingleSymRenderer* renderer;
//initial settings, use the buffer of the propertiesDialog if possible. If this is not possible, use the renderer of the vectorlayer directly
if(m_vectorlayer->propertiesDialog())
{
renderer=dynamic_cast<QgsSingleSymRenderer*>(layer->propertiesDialog()->getBufferRenderer());
}
else
{
renderer=dynamic_cast<QgsSingleSymRenderer*>(layer->renderer());
}
if(renderer) if(renderer)
{ {
outlinewidthspinbox->setValue(renderer->item()->getSymbol()->pen().width()); outlinewidthspinbox->setValue(renderer->item()->getSymbol()->pen().width());

View File

@ -58,7 +58,11 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(QgsVectorLayer* lyr):layer(ly
QgsVectorLayerProperties::~QgsVectorLayerProperties() QgsVectorLayerProperties::~QgsVectorLayerProperties()
{ {
if(rendererDirty)
{
delete bufferDialog;
delete bufferRenderer;
}
} }
QgsSymbol* QgsVectorLayerProperties::getSymbol() QgsSymbol* QgsVectorLayerProperties::getSymbol()
@ -124,12 +128,6 @@ void QgsVectorLayerProperties::apply()
void QgsVectorLayerProperties::cancel() void QgsVectorLayerProperties::cancel()
{ {
//todo: add code to free memory here
if(rendererDirty)
{
delete bufferDialog;
delete bufferRenderer;
}
reject(); reject();
} }