Skip to content

Commit c6c9585

Browse files

File tree

5 files changed

+62
-19
lines changed

5 files changed

+62
-19
lines changed
 

‎src/gui/qgscontinuouscolordialog.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ QgsContinuousColorDialog::QgsContinuousColorDialog(QgsVectorLayer * layer)
8787
outlinewidthspinbox->setValue(minsymbol->pen().width());
8888
outlinewidthspinbox->setMinValue(1);
8989
}
90+
91+
outlinewidthspinbox->setEnabled(true);
9092
}
9193

9294
QgsContinuousColorDialog::QgsContinuousColorDialog()
@@ -138,7 +140,7 @@ void QgsContinuousColorDialog::apply()
138140
else
139141
{
140142
minsymbol->setBrush(QBrush(lblMinValue->paletteBackgroundColor()));
141-
minsymbol->setPen(QPen(QColor(0, 0, 0), outlinewidthspinbox->value()));
143+
minsymbol->setPen(QPen(QColor(0, 0, 0), outlinewidthspinbox->value()));
142144
}
143145

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

162166
mVectorLayer->refreshLegend();
163167
}
@@ -181,3 +185,11 @@ void QgsContinuousColorDialog::selectMaximumColor()
181185
}
182186
setActiveWindow();
183187
}
188+
189+
void QgsContinuousColorDialog::on_cb_polygonOutline_clicked()
190+
{
191+
if (cb_polygonOutline->checkState() == Qt::Checked)
192+
outlinewidthspinbox->setEnabled(true);
193+
else
194+
outlinewidthspinbox->setEnabled(false);
195+
}

‎src/gui/qgscontinuouscolordialog.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class QgsContinuousColorDialog: public QDialog, private Ui::QgsContinuousColorDi
3737
protected slots:
3838
void selectMinimumColor();
3939
void selectMaximumColor();
40+
void on_cb_polygonOutline_clicked();
4041
protected:
4142
QgsVectorLayer* mVectorLayer;
4243
/**Stores the names and numbers of the fields with numeric values*/

‎src/gui/qgscontinuouscolorrenderer.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,10 @@ void QgsContinuousColorRenderer::renderFeature(QPainter * p, QgsFeature * f, QPi
151151
else
152152
{
153153
p->setBrush(QColor(red, green, blue));
154+
if (mDrawPolygonOutline)
155+
p->setPen(QColor(0, 0, 0));
156+
else
157+
p->setPen(Qt::NoPen);
154158
}
155159
if(selected)
156160
{

‎src/gui/qgscontinuouscolorrenderer.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,14 @@ class QgsContinuousColorRenderer: public QgsRenderer
4545
void setMinimumSymbol(QgsSymbol* sy);
4646
/**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*/
4747
void setMaximumSymbol(QgsSymbol* sy);
48+
/** Sets whether to draw the polygon outline*/
49+
void setDrawPolygonOutline(bool draw) { mDrawPolygonOutline = draw;}
4850
/**Returns the symbol for the minimum value*/
4951
const QgsSymbol* minimumSymbol() const;
5052
/**Returns the symbol for the maximum value*/
5153
const QgsSymbol* maximumSymbol() const;
54+
/** whether to draw a polygon outline*/
55+
bool drawPolygonOutline() { return mDrawPolygonOutline; }
5256
/**Reads the renderer configuration from an XML file
5357
@param rnode the DOM node to read
5458
@param vl the vector layer which will be associated with the renderer*/
@@ -72,6 +76,8 @@ class QgsContinuousColorRenderer: public QgsRenderer
7276
QgsSymbol* mMinimumSymbol;
7377
/**Item for the maximum value*/
7478
QgsSymbol* mMaximumSymbol;
79+
/** Whether to draw the polygon outline or not */
80+
bool mDrawPolygonOutline;
7581
};
7682

7783
inline int QgsContinuousColorRenderer::classificationField() const

‎src/ui/qgscontinuouscolordialogbase.ui

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<x>0</x>
1010
<y>0</y>
1111
<width>408</width>
12-
<height>143</height>
12+
<height>155</height>
1313
</rect>
1414
</property>
1515
<property name="windowTitle" >
@@ -22,7 +22,30 @@
2222
<property name="spacing" >
2323
<number>6</number>
2424
</property>
25-
<item row="0" column="3" >
25+
<item row="3" column="3" >
26+
<widget class="QCheckBox" name="cb_polygonOutline" >
27+
<property name="text" >
28+
<string>Draw polygon outline</string>
29+
</property>
30+
</widget>
31+
</item>
32+
<item row="3" column="4" >
33+
<spacer>
34+
<property name="orientation" >
35+
<enum>Qt::Horizontal</enum>
36+
</property>
37+
<property name="sizeType" >
38+
<enum>QSizePolicy::Expanding</enum>
39+
</property>
40+
<property name="sizeHint" >
41+
<size>
42+
<width>21</width>
43+
<height>20</height>
44+
</size>
45+
</property>
46+
</spacer>
47+
</item>
48+
<item row="0" column="3" colspan="2" >
2649
<spacer>
2750
<property name="orientation" >
2851
<enum>Qt::Horizontal</enum>
@@ -174,22 +197,6 @@
174197
</property>
175198
</widget>
176199
</item>
177-
<item row="3" column="2" colspan="2" >
178-
<spacer>
179-
<property name="orientation" >
180-
<enum>Qt::Horizontal</enum>
181-
</property>
182-
<property name="sizeType" >
183-
<enum>QSizePolicy::Expanding</enum>
184-
</property>
185-
<property name="sizeHint" >
186-
<size>
187-
<width>111</width>
188-
<height>20</height>
189-
</size>
190-
</property>
191-
</spacer>
192-
</item>
193200
<item row="3" column="1" >
194201
<widget class="QSpinBox" name="outlinewidthspinbox" />
195202
</item>
@@ -241,6 +248,19 @@
241248
</property>
242249
</widget>
243250
</item>
251+
<item row="4" column="2" >
252+
<spacer>
253+
<property name="orientation" >
254+
<enum>Qt::Vertical</enum>
255+
</property>
256+
<property name="sizeHint" >
257+
<size>
258+
<width>20</width>
259+
<height>40</height>
260+
</size>
261+
</property>
262+
</spacer>
263+
</item>
244264
</layout>
245265
</widget>
246266
<layoutdefault spacing="6" margin="11" />

0 commit comments

Comments
 (0)
Please sign in to comment.