Skip to content

Commit

Permalink
Fix for ticket #264 (polygon outlines obscure continuous colours for
Browse files Browse the repository at this point in the history
small or zoomed out polygons).


git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@5815 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
g_j_m committed Sep 12, 2006
1 parent 5de35f3 commit c6c9585
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 19 deletions.
14 changes: 13 additions & 1 deletion src/gui/qgscontinuouscolordialog.cpp
Expand Up @@ -87,6 +87,8 @@ QgsContinuousColorDialog::QgsContinuousColorDialog(QgsVectorLayer * layer)
outlinewidthspinbox->setValue(minsymbol->pen().width());
outlinewidthspinbox->setMinValue(1);
}

outlinewidthspinbox->setEnabled(true);
}

QgsContinuousColorDialog::QgsContinuousColorDialog()
Expand Down Expand Up @@ -138,7 +140,7 @@ void QgsContinuousColorDialog::apply()
else
{
minsymbol->setBrush(QBrush(lblMinValue->paletteBackgroundColor()));
minsymbol->setPen(QPen(QColor(0, 0, 0), outlinewidthspinbox->value()));
minsymbol->setPen(QPen(QColor(0, 0, 0), outlinewidthspinbox->value()));
}

QgsSymbol* maxsymbol = new QgsSymbol(mVectorLayer->vectorType(), QString::number(maximum, 'f'), "", "");
Expand All @@ -158,6 +160,8 @@ void QgsContinuousColorDialog::apply()
renderer->setMinimumSymbol(minsymbol);
renderer->setMaximumSymbol(maxsymbol);
renderer->setClassificationField(classfield);
bool drawOutline = (cb_polygonOutline->checkState() == Qt::Checked) ? true:false;
renderer->setDrawPolygonOutline(drawOutline);

mVectorLayer->refreshLegend();
}
Expand All @@ -181,3 +185,11 @@ void QgsContinuousColorDialog::selectMaximumColor()
}
setActiveWindow();
}

void QgsContinuousColorDialog::on_cb_polygonOutline_clicked()
{
if (cb_polygonOutline->checkState() == Qt::Checked)
outlinewidthspinbox->setEnabled(true);
else
outlinewidthspinbox->setEnabled(false);
}
1 change: 1 addition & 0 deletions src/gui/qgscontinuouscolordialog.h
Expand Up @@ -37,6 +37,7 @@ class QgsContinuousColorDialog: public QDialog, private Ui::QgsContinuousColorDi
protected slots:
void selectMinimumColor();
void selectMaximumColor();
void on_cb_polygonOutline_clicked();
protected:
QgsVectorLayer* mVectorLayer;
/**Stores the names and numbers of the fields with numeric values*/
Expand Down
4 changes: 4 additions & 0 deletions src/gui/qgscontinuouscolorrenderer.cpp
Expand Up @@ -151,6 +151,10 @@ void QgsContinuousColorRenderer::renderFeature(QPainter * p, QgsFeature * f, QPi
else
{
p->setBrush(QColor(red, green, blue));
if (mDrawPolygonOutline)
p->setPen(QColor(0, 0, 0));
else
p->setPen(Qt::NoPen);
}
if(selected)
{
Expand Down
6 changes: 6 additions & 0 deletions src/gui/qgscontinuouscolorrenderer.h
Expand Up @@ -45,10 +45,14 @@ class QgsContinuousColorRenderer: public QgsRenderer
void setMinimumSymbol(QgsSymbol* sy);
/**Sets the symbol for the maximum value. The symbol has to be created using the new operator and is automatically deleted when inserting a new symbol or when the instance is destroyed*/
void setMaximumSymbol(QgsSymbol* sy);
/** Sets whether to draw the polygon outline*/
void setDrawPolygonOutline(bool draw) { mDrawPolygonOutline = draw;}
/**Returns the symbol for the minimum value*/
const QgsSymbol* minimumSymbol() const;
/**Returns the symbol for the maximum value*/
const QgsSymbol* maximumSymbol() const;
/** whether to draw a polygon outline*/
bool drawPolygonOutline() { return mDrawPolygonOutline; }
/**Reads the renderer configuration from an XML file
@param rnode the DOM node to read
@param vl the vector layer which will be associated with the renderer*/
Expand All @@ -72,6 +76,8 @@ class QgsContinuousColorRenderer: public QgsRenderer
QgsSymbol* mMinimumSymbol;
/**Item for the maximum value*/
QgsSymbol* mMaximumSymbol;
/** Whether to draw the polygon outline or not */
bool mDrawPolygonOutline;
};

inline int QgsContinuousColorRenderer::classificationField() const
Expand Down
56 changes: 38 additions & 18 deletions src/ui/qgscontinuouscolordialogbase.ui
Expand Up @@ -9,7 +9,7 @@
<x>0</x>
<y>0</y>
<width>408</width>
<height>143</height>
<height>155</height>
</rect>
</property>
<property name="windowTitle" >
Expand All @@ -22,7 +22,30 @@
<property name="spacing" >
<number>6</number>
</property>
<item row="0" column="3" >
<item row="3" column="3" >
<widget class="QCheckBox" name="cb_polygonOutline" >
<property name="text" >
<string>Draw polygon outline</string>
</property>
</widget>
</item>
<item row="3" column="4" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" >
<size>
<width>21</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="3" colspan="2" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
Expand Down Expand Up @@ -174,22 +197,6 @@
</property>
</widget>
</item>
<item row="3" column="2" colspan="2" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" >
<size>
<width>111</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="1" >
<widget class="QSpinBox" name="outlinewidthspinbox" />
</item>
Expand Down Expand Up @@ -241,6 +248,19 @@
</property>
</widget>
</item>
<item row="4" column="2" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11" />
Expand Down

0 comments on commit c6c9585

Please sign in to comment.