Navigation Menu

Skip to content

Commit

Permalink
changed default color range for graduated renderer to red-green and u…
Browse files Browse the repository at this point in the history
…se random colors for the unique renderer

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@5031 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Mar 15, 2006
1 parent e8170e2 commit 275005b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
3 changes: 2 additions & 1 deletion src/gui/qgisapp.cpp
Expand Up @@ -1118,7 +1118,8 @@ void QgisApp::createOverview()
void QgisApp::createLegend()
{
//legend
mMapLegend = new QgsLegend(this,NULL, "theMapLegend");
//mMapLegend = new QgsLegend(this,NULL, "theMapLegend");
mMapLegend = new QgsLegend(this, this, "theMapLegend");
mMapLegend->setMapCanvas(mMapCanvas);
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."));
QVBoxLayout *myLegendLayout = new QVBoxLayout;
Expand Down
12 changes: 6 additions & 6 deletions src/gui/qgsgraduatedsymboldialog.cpp
Expand Up @@ -299,29 +299,29 @@ void QgsGraduatedSymbolDialog::adjustClassification()
}
//set default symbology

//apply a nice color range from blue to red as default
//apply a nice color range from red to green as default
if (i == 0)
{
if (m_type == QGis::Line)
{
pen.setColor(QColor(0, 0, 255));
pen.setColor(QColor(255, 0, 0));
}
else //point or polygon
{
brush.setColor(QColor(0, 0, 255));
brush.setColor(QColor(255, 0, 0));
pen.setColor(Qt::black);
}
}
else
{
if (m_type == QGis::Line)
{
pen.setColor(QColor(255 / numberofclassesspinbox->value() * (i+1), 0, 255 - (255 / numberofclassesspinbox->value() * (i+1))));
pen.setColor(QColor(255 - (255 / numberofclassesspinbox->value() * (i+1)), 255 / numberofclassesspinbox->value() * (i+1), 0));
}
else //point or polygon
{
brush.setColor(QColor(255 / numberofclassesspinbox->value() * (i+1), 0, 255 - (255 / numberofclassesspinbox->value() * (i+1))));
pen.setColor(Qt::black);
brush.setColor(QColor(255 - (255 / numberofclassesspinbox->value() * (i+1)), 255 / numberofclassesspinbox->value() * (i+1), 0));
pen.setColor(Qt::black);
}
}
pen.setWidth(1);
Expand Down
3 changes: 2 additions & 1 deletion src/gui/qgsproject.cpp
Expand Up @@ -776,7 +776,8 @@ static QgsLegend * _findLegend()
QWidgetList wlist = QApplication::topLevelWidgets();
foreach (QWidget *widget, QApplication::topLevelWidgets())
{
theLegend = dynamic_cast <QgsLegend *>(widget->child(canonicalLegendName.toLocal8Bit().data(), 0, true));
//theLegend = dynamic_cast <QgsLegend *>(widget->child(canonicalLegendName.toLocal8Bit().data(), 0, true));
theLegend = widget->findChild<QgsLegend*>("theMapLegend");
if(theLegend)
break;
}
Expand Down
10 changes: 5 additions & 5 deletions src/gui/qgsuniquevaluedialog.cpp
Expand Up @@ -164,15 +164,15 @@ void QgsUniqueValueDialog::changeClassificationAttribute(int nr)

//set symbology for all QgsSiSyDialogs
QColor thecolor;
double number=0;
double frac;

for(std::map<QString,QgsSymbol*>::iterator it=mValues.begin();it!=mValues.end();++it)
{
++number;
//color range from blue to red
frac=number/mValues.size();
thecolor.setRgb(int(255*frac),0,int(255-(255*frac)));
//insert a random color
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));
thecolor.setRgb(red, green, blue);
mClassBreakBox->insertItem(it->first);
QgsSymbol* sym=it->second;
QPen pen;
Expand Down

0 comments on commit 275005b

Please sign in to comment.