Skip to content
Permalink
Browse files
code reindented
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@8231 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Mar 16, 2008
1 parent 126bb2e commit 4424ef9e02113274f5b5d14e926860392d9ffec3
Showing with 712 additions and 712 deletions.
  1. +149 −149 src/app/qgscontinuouscolordialog.cpp
  2. +372 −372 src/app/qgsgraduatedsymboldialog.cpp
  3. +191 −191 src/app/qgsuniquevaluedialog.cpp
@@ -30,197 +30,197 @@
QgsContinuousColorDialog::QgsContinuousColorDialog(QgsVectorLayer * layer)
: QDialog(), mVectorLayer(layer)
{
setupUi(this);
setupUi(this);
#ifdef QGISDEBUG
qWarning("constructor QgsContinuousColorDialog");
qWarning("constructor QgsContinuousColorDialog");
#endif

QObject::connect(btnMinValue, SIGNAL(clicked()), this, SLOT(selectMinimumColor()));
QObject::connect(btnMaxValue, SIGNAL(clicked()), this, SLOT(selectMaximumColor()));
QObject::connect(btnMinValue, SIGNAL(clicked()), this, SLOT(selectMinimumColor()));
QObject::connect(btnMaxValue, SIGNAL(clicked()), this, SLOT(selectMaximumColor()));

//find out the numerical fields of mVectorLayer
QgsVectorDataProvider *provider = mVectorLayer->getDataProvider();
if (provider)
{
const QgsFieldMap & fields = provider->fields();
int fieldnumber(0), combonumber(0);
QString str;

for (QgsFieldMap::const_iterator it = fields.begin(); it != fields.end(); ++it)
{
QVariant::Type type = (*it).type();
if (type == QVariant::Int || type == QVariant::Double)
{
str = (*it).name();
classificationComboBox->insertItem(str);
mFieldMap.insert(std::make_pair(combonumber, fieldnumber));
combonumber++;
}
fieldnumber++;
}
}
else
//find out the numerical fields of mVectorLayer
QgsVectorDataProvider *provider = mVectorLayer->getDataProvider();
if (provider)
{
const QgsFieldMap & fields = provider->fields();
int fieldnumber(0), combonumber(0);
QString str;

for (QgsFieldMap::const_iterator it = fields.begin(); it != fields.end(); ++it)
{
qWarning("Warning, data provider is null in QgsContinuousColorDialog::QgsContinuousColorDialog(...)");
return;
QVariant::Type type = (*it).type();
if (type == QVariant::Int || type == QVariant::Double)
{
str = (*it).name();
classificationComboBox->insertItem(str);
mFieldMap.insert(std::make_pair(combonumber, fieldnumber));
combonumber++;
}
fieldnumber++;
}
}
else
{
qWarning("Warning, data provider is null in QgsContinuousColorDialog::QgsContinuousColorDialog(...)");
return;
}

//restore the correct colors for minimum and maximum values
//restore the correct colors for minimum and maximum values

const QgsContinuousColorRenderer* renderer = dynamic_cast < const QgsContinuousColorRenderer * >(layer->renderer());;
const QgsContinuousColorRenderer* renderer = dynamic_cast < const QgsContinuousColorRenderer * >(layer->renderer());;

if (renderer)
{
// Awkard - here we want to search through mFieldMap for a
// particular value, while elsewhere in this code we need to search
// for a particular key, so one or the other loses out, which is here.

std::map<int,int>::const_iterator iter = mFieldMap.begin();
while (iter != mFieldMap.end())
{
if (iter->second == renderer->classificationField())
break;
iter++;
}
if (iter != mFieldMap.end())
classificationComboBox->setCurrentItem(iter->first);
else
classificationComboBox->setCurrentItem(-1);

const QgsSymbol* minsymbol = renderer->minimumSymbol();
const QgsSymbol* maxsymbol = renderer->maximumSymbol();

if (mVectorLayer->vectorType() == QGis::Line || mVectorLayer->vectorType() == QGis::Point)
{
btnMinValue->setColor( minsymbol->pen().color() );
btnMaxValue->setColor( maxsymbol->pen().color() );
}
else
if (renderer)
{
// Awkard - here we want to search through mFieldMap for a
// particular value, while elsewhere in this code we need to search
// for a particular key, so one or the other loses out, which is here.

std::map<int,int>::const_iterator iter = mFieldMap.begin();
while (iter != mFieldMap.end())
{
btnMinValue->setColor( minsymbol->brush().color() );
btnMaxValue->setColor( maxsymbol->brush().color() );
if (iter->second == renderer->classificationField())
break;
iter++;
}
if (iter != mFieldMap.end())
classificationComboBox->setCurrentItem(iter->first);
else
classificationComboBox->setCurrentItem(-1);

outlinewidthspinbox->setMinValue(0);
outlinewidthspinbox->setValue(minsymbol->pen().width());
const QgsSymbol* minsymbol = renderer->minimumSymbol();
const QgsSymbol* maxsymbol = renderer->maximumSymbol();

if (renderer->drawPolygonOutline())
cb_polygonOutline->setCheckState(Qt::Checked);
else
cb_polygonOutline->setCheckState(Qt::Unchecked);
if (mVectorLayer->vectorType() != QGis::Polygon)
cb_polygonOutline->setVisible(false);
if (mVectorLayer->vectorType() == QGis::Line || mVectorLayer->vectorType() == QGis::Point)
{
btnMinValue->setColor( minsymbol->pen().color() );
btnMaxValue->setColor( maxsymbol->pen().color() );
}
else
{
cb_polygonOutline->setCheckState(Qt::Checked);
outlinewidthspinbox->setValue(1);
if (mVectorLayer->vectorType() != QGis::Polygon)
cb_polygonOutline->setVisible(false);
btnMinValue->setColor( minsymbol->brush().color() );
btnMaxValue->setColor( maxsymbol->brush().color() );
}

btnMinValue->setColor(Qt::black);
btnMaxValue->setColor(Qt::white);
outlinewidthspinbox->setMinValue(0);
outlinewidthspinbox->setValue(minsymbol->pen().width());

}
// Ensure that the state of other widgets is appropriate for the
// state of the polygonoutline checkbox.
on_cb_polygonOutline_clicked();
if (renderer->drawPolygonOutline())
cb_polygonOutline->setCheckState(Qt::Checked);
else
cb_polygonOutline->setCheckState(Qt::Unchecked);
if (mVectorLayer->vectorType() != QGis::Polygon)
cb_polygonOutline->setVisible(false);
}
else
{
cb_polygonOutline->setCheckState(Qt::Checked);
outlinewidthspinbox->setValue(1);
if (mVectorLayer->vectorType() != QGis::Polygon)
cb_polygonOutline->setVisible(false);

btnMinValue->setColor(Qt::black);
btnMaxValue->setColor(Qt::white);

}
// Ensure that the state of other widgets is appropriate for the
// state of the polygonoutline checkbox.
on_cb_polygonOutline_clicked();
}

QgsContinuousColorDialog::QgsContinuousColorDialog()
{
setupUi(this);
setupUi(this);
#ifdef QGISDEBUG
qWarning("constructor QgsContinuousColorDialog");
qWarning("constructor QgsContinuousColorDialog");
#endif
}

QgsContinuousColorDialog::~QgsContinuousColorDialog()
{
#ifdef QGISDEBUG
qWarning("destructor QgsContinuousColorDialog");
qWarning("destructor QgsContinuousColorDialog");
#endif
}

void QgsContinuousColorDialog::apply()
{
int comboIndex = classificationComboBox->currentIndex();
if (comboIndex == -1) //don't do anything, if there is no classification field
{
return;
}
std::map < int, int >::iterator iter = mFieldMap.find(comboIndex);
// Should never happen...
assert(iter != mFieldMap.end());

int classfield = iter->second;

//find the minimum and maximum for the classification variable
double minimum, maximum;
QgsVectorDataProvider *provider = dynamic_cast<QgsVectorDataProvider*>(mVectorLayer->getDataProvider());
if (provider)
{
minimum = provider->minValue(classfield).toDouble();
maximum = provider->maxValue(classfield).toDouble();
}
else
{
qWarning("Warning, provider is null in QgsGraSyExtensionWidget::QgsGraSyExtensionWidget(...)");
return;
}


//create the render items for minimum and maximum value
QgsSymbol* minsymbol = new QgsSymbol(mVectorLayer->vectorType(), QString::number(minimum, 'f'), "", "");
if (mVectorLayer->vectorType() == QGis::Line || mVectorLayer->vectorType() == QGis::Point)
{
minsymbol->setPen(QPen(btnMinValue->color(), outlinewidthspinbox->value()));
}
else
{
minsymbol->setBrush(QBrush(btnMinValue->color()));
minsymbol->setPen(QPen(QColor(0, 0, 0), outlinewidthspinbox->value()));
}
QgsSymbol* maxsymbol = new QgsSymbol(mVectorLayer->vectorType(), QString::number(maximum, 'f'), "", "");
if (mVectorLayer->vectorType() == QGis::Line || mVectorLayer->vectorType() == QGis::Point)
{
maxsymbol->setPen(QPen(btnMaxValue->color(), outlinewidthspinbox->value()));
}
else
{
maxsymbol->setBrush(QBrush(btnMaxValue->color()));
maxsymbol->setPen(QPen(QColor(0, 0, 0), outlinewidthspinbox->value()));
}
QgsContinuousColorRenderer* renderer = new QgsContinuousColorRenderer(mVectorLayer->vectorType());
mVectorLayer->setRenderer(renderer);
renderer->setMinimumSymbol(minsymbol);
renderer->setMaximumSymbol(maxsymbol);
renderer->setClassificationField(classfield);
bool drawOutline = (cb_polygonOutline->checkState() == Qt::Checked) ? true:false;
renderer->setDrawPolygonOutline(drawOutline);
int comboIndex = classificationComboBox->currentIndex();
if (comboIndex == -1) //don't do anything, if there is no classification field
{
return;
}
std::map < int, int >::iterator iter = mFieldMap.find(comboIndex);
// Should never happen...
assert(iter != mFieldMap.end());

int classfield = iter->second;

//find the minimum and maximum for the classification variable
double minimum, maximum;
QgsVectorDataProvider *provider = dynamic_cast<QgsVectorDataProvider*>(mVectorLayer->getDataProvider());
if (provider)
{
minimum = provider->minValue(classfield).toDouble();
maximum = provider->maxValue(classfield).toDouble();
}
else
{
qWarning("Warning, provider is null in QgsGraSyExtensionWidget::QgsGraSyExtensionWidget(...)");
return;
}


//create the render items for minimum and maximum value
QgsSymbol* minsymbol = new QgsSymbol(mVectorLayer->vectorType(), QString::number(minimum, 'f'), "", "");
if (mVectorLayer->vectorType() == QGis::Line || mVectorLayer->vectorType() == QGis::Point)
{
minsymbol->setPen(QPen(btnMinValue->color(), outlinewidthspinbox->value()));
}
else
{
minsymbol->setBrush(QBrush(btnMinValue->color()));
minsymbol->setPen(QPen(QColor(0, 0, 0), outlinewidthspinbox->value()));
}

QgsSymbol* maxsymbol = new QgsSymbol(mVectorLayer->vectorType(), QString::number(maximum, 'f'), "", "");
if (mVectorLayer->vectorType() == QGis::Line || mVectorLayer->vectorType() == QGis::Point)
{
maxsymbol->setPen(QPen(btnMaxValue->color(), outlinewidthspinbox->value()));
}
else
{
maxsymbol->setBrush(QBrush(btnMaxValue->color()));
maxsymbol->setPen(QPen(QColor(0, 0, 0), outlinewidthspinbox->value()));
}

QgsContinuousColorRenderer* renderer = new QgsContinuousColorRenderer(mVectorLayer->vectorType());
mVectorLayer->setRenderer(renderer);

renderer->setMinimumSymbol(minsymbol);
renderer->setMaximumSymbol(maxsymbol);
renderer->setClassificationField(classfield);
bool drawOutline = (cb_polygonOutline->checkState() == Qt::Checked) ? true:false;
renderer->setDrawPolygonOutline(drawOutline);
}

void QgsContinuousColorDialog::selectMinimumColor()
{
QColor mincolor = QColorDialog::getColor(btnMinValue->color(), this);
if(mincolor.isValid())
{
btnMinValue->setColor(mincolor);
}
setActiveWindow();
QColor mincolor = QColorDialog::getColor(btnMinValue->color(), this);
if(mincolor.isValid())
{
btnMinValue->setColor(mincolor);
}
setActiveWindow();
}

void QgsContinuousColorDialog::selectMaximumColor()
{
QColor maxcolor = QColorDialog::getColor(btnMaxValue->color(), this);
if(maxcolor.isValid())
{
btnMaxValue->setColor(maxcolor);
}
setActiveWindow();
QColor maxcolor = QColorDialog::getColor(btnMaxValue->color(), this);
if(maxcolor.isValid())
{
btnMaxValue->setColor(maxcolor);
}
setActiveWindow();
}

void QgsContinuousColorDialog::on_cb_polygonOutline_clicked()
Loading

0 comments on commit 4424ef9

Please sign in to comment.