Skip to content
Permalink
Browse files

changed default color range for graduated renderer to red-green and u…

…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
mhugent committed Mar 15, 2006
1 parent e8170e2 commit 275005ba84c38596ff194e5feba5bb61fca83da4
Showing with 15 additions and 13 deletions.
  1. +2 −1 src/gui/qgisapp.cpp
  2. +6 −6 src/gui/qgsgraduatedsymboldialog.cpp
  3. +2 −1 src/gui/qgsproject.cpp
  4. +5 −5 src/gui/qgsuniquevaluedialog.cpp
@@ -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;
@@ -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);
@@ -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;
}
@@ -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;

0 comments on commit 275005b

Please sign in to comment.
You can’t perform that action at this time.