Skip to content

Commit 275005b

Browse files
author
mhugent
committed
changed default color range for graduated renderer to red-green and use random colors for the unique renderer
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@5031 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent e8170e2 commit 275005b

4 files changed

+15
-13
lines changed

src/gui/qgisapp.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1118,7 +1118,8 @@ void QgisApp::createOverview()
11181118
void QgisApp::createLegend()
11191119
{
11201120
//legend
1121-
mMapLegend = new QgsLegend(this,NULL, "theMapLegend");
1121+
//mMapLegend = new QgsLegend(this,NULL, "theMapLegend");
1122+
mMapLegend = new QgsLegend(this, this, "theMapLegend");
11221123
mMapLegend->setMapCanvas(mMapCanvas);
11231124
QWhatsThis::add(mMapLegend, tr("Map legend that displays all the layers currently on the map canvas. Click on the check box to turn a layer on or off. Double click on a layer in the legend to customize its appearance and set other properties."));
11241125
QVBoxLayout *myLegendLayout = new QVBoxLayout;

src/gui/qgsgraduatedsymboldialog.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -299,29 +299,29 @@ void QgsGraduatedSymbolDialog::adjustClassification()
299299
}
300300
//set default symbology
301301

302-
//apply a nice color range from blue to red as default
302+
//apply a nice color range from red to green as default
303303
if (i == 0)
304304
{
305305
if (m_type == QGis::Line)
306306
{
307-
pen.setColor(QColor(0, 0, 255));
307+
pen.setColor(QColor(255, 0, 0));
308308
}
309309
else //point or polygon
310310
{
311-
brush.setColor(QColor(0, 0, 255));
311+
brush.setColor(QColor(255, 0, 0));
312312
pen.setColor(Qt::black);
313313
}
314314
}
315315
else
316316
{
317317
if (m_type == QGis::Line)
318318
{
319-
pen.setColor(QColor(255 / numberofclassesspinbox->value() * (i+1), 0, 255 - (255 / numberofclassesspinbox->value() * (i+1))));
319+
pen.setColor(QColor(255 - (255 / numberofclassesspinbox->value() * (i+1)), 255 / numberofclassesspinbox->value() * (i+1), 0));
320320
}
321321
else //point or polygon
322322
{
323-
brush.setColor(QColor(255 / numberofclassesspinbox->value() * (i+1), 0, 255 - (255 / numberofclassesspinbox->value() * (i+1))));
324-
pen.setColor(Qt::black);
323+
brush.setColor(QColor(255 - (255 / numberofclassesspinbox->value() * (i+1)), 255 / numberofclassesspinbox->value() * (i+1), 0));
324+
pen.setColor(Qt::black);
325325
}
326326
}
327327
pen.setWidth(1);

src/gui/qgsproject.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,8 @@ static QgsLegend * _findLegend()
776776
QWidgetList wlist = QApplication::topLevelWidgets();
777777
foreach (QWidget *widget, QApplication::topLevelWidgets())
778778
{
779-
theLegend = dynamic_cast <QgsLegend *>(widget->child(canonicalLegendName.toLocal8Bit().data(), 0, true));
779+
//theLegend = dynamic_cast <QgsLegend *>(widget->child(canonicalLegendName.toLocal8Bit().data(), 0, true));
780+
theLegend = widget->findChild<QgsLegend*>("theMapLegend");
780781
if(theLegend)
781782
break;
782783
}

src/gui/qgsuniquevaluedialog.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -164,15 +164,15 @@ void QgsUniqueValueDialog::changeClassificationAttribute(int nr)
164164

165165
//set symbology for all QgsSiSyDialogs
166166
QColor thecolor;
167-
double number=0;
168167
double frac;
169168

170169
for(std::map<QString,QgsSymbol*>::iterator it=mValues.begin();it!=mValues.end();++it)
171170
{
172-
++number;
173-
//color range from blue to red
174-
frac=number/mValues.size();
175-
thecolor.setRgb(int(255*frac),0,int(255-(255*frac)));
171+
//insert a random color
172+
int red = 1 + (int) (255.0 * rand() / (RAND_MAX + 1.0));
173+
int green = 1 + (int) (255.0 * rand() / (RAND_MAX + 1.0));
174+
int blue = 1 + (int) (255.0 * rand() / (RAND_MAX + 1.0));
175+
thecolor.setRgb(red, green, blue);
176176
mClassBreakBox->insertItem(it->first);
177177
QgsSymbol* sym=it->second;
178178
QPen pen;

0 commit comments

Comments
 (0)