Skip to content

Commit 4424ef9

Browse files
author
jef
committed
code reindented
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@8231 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 126bb2e commit 4424ef9

File tree

3 files changed

+712
-712
lines changed

3 files changed

+712
-712
lines changed

src/app/qgscontinuouscolordialog.cpp

Lines changed: 149 additions & 149 deletions
Original file line numberDiff line numberDiff line change
@@ -30,197 +30,197 @@
3030
QgsContinuousColorDialog::QgsContinuousColorDialog(QgsVectorLayer * layer)
3131
: QDialog(), mVectorLayer(layer)
3232
{
33-
setupUi(this);
33+
setupUi(this);
3434
#ifdef QGISDEBUG
35-
qWarning("constructor QgsContinuousColorDialog");
35+
qWarning("constructor QgsContinuousColorDialog");
3636
#endif
3737

38-
QObject::connect(btnMinValue, SIGNAL(clicked()), this, SLOT(selectMinimumColor()));
39-
QObject::connect(btnMaxValue, SIGNAL(clicked()), this, SLOT(selectMaximumColor()));
38+
QObject::connect(btnMinValue, SIGNAL(clicked()), this, SLOT(selectMinimumColor()));
39+
QObject::connect(btnMaxValue, SIGNAL(clicked()), this, SLOT(selectMaximumColor()));
4040

41-
//find out the numerical fields of mVectorLayer
42-
QgsVectorDataProvider *provider = mVectorLayer->getDataProvider();
43-
if (provider)
44-
{
45-
const QgsFieldMap & fields = provider->fields();
46-
int fieldnumber(0), combonumber(0);
47-
QString str;
48-
49-
for (QgsFieldMap::const_iterator it = fields.begin(); it != fields.end(); ++it)
50-
{
51-
QVariant::Type type = (*it).type();
52-
if (type == QVariant::Int || type == QVariant::Double)
53-
{
54-
str = (*it).name();
55-
classificationComboBox->insertItem(str);
56-
mFieldMap.insert(std::make_pair(combonumber, fieldnumber));
57-
combonumber++;
58-
}
59-
fieldnumber++;
60-
}
61-
}
62-
else
41+
//find out the numerical fields of mVectorLayer
42+
QgsVectorDataProvider *provider = mVectorLayer->getDataProvider();
43+
if (provider)
44+
{
45+
const QgsFieldMap & fields = provider->fields();
46+
int fieldnumber(0), combonumber(0);
47+
QString str;
48+
49+
for (QgsFieldMap::const_iterator it = fields.begin(); it != fields.end(); ++it)
6350
{
64-
qWarning("Warning, data provider is null in QgsContinuousColorDialog::QgsContinuousColorDialog(...)");
65-
return;
51+
QVariant::Type type = (*it).type();
52+
if (type == QVariant::Int || type == QVariant::Double)
53+
{
54+
str = (*it).name();
55+
classificationComboBox->insertItem(str);
56+
mFieldMap.insert(std::make_pair(combonumber, fieldnumber));
57+
combonumber++;
58+
}
59+
fieldnumber++;
6660
}
61+
}
62+
else
63+
{
64+
qWarning("Warning, data provider is null in QgsContinuousColorDialog::QgsContinuousColorDialog(...)");
65+
return;
66+
}
6767

68-
//restore the correct colors for minimum and maximum values
68+
//restore the correct colors for minimum and maximum values
6969

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

72-
if (renderer)
73-
{
74-
// Awkard - here we want to search through mFieldMap for a
75-
// particular value, while elsewhere in this code we need to search
76-
// for a particular key, so one or the other loses out, which is here.
77-
78-
std::map<int,int>::const_iterator iter = mFieldMap.begin();
79-
while (iter != mFieldMap.end())
80-
{
81-
if (iter->second == renderer->classificationField())
82-
break;
83-
iter++;
84-
}
85-
if (iter != mFieldMap.end())
86-
classificationComboBox->setCurrentItem(iter->first);
87-
else
88-
classificationComboBox->setCurrentItem(-1);
89-
90-
const QgsSymbol* minsymbol = renderer->minimumSymbol();
91-
const QgsSymbol* maxsymbol = renderer->maximumSymbol();
92-
93-
if (mVectorLayer->vectorType() == QGis::Line || mVectorLayer->vectorType() == QGis::Point)
94-
{
95-
btnMinValue->setColor( minsymbol->pen().color() );
96-
btnMaxValue->setColor( maxsymbol->pen().color() );
97-
}
98-
else
72+
if (renderer)
73+
{
74+
// Awkard - here we want to search through mFieldMap for a
75+
// particular value, while elsewhere in this code we need to search
76+
// for a particular key, so one or the other loses out, which is here.
77+
78+
std::map<int,int>::const_iterator iter = mFieldMap.begin();
79+
while (iter != mFieldMap.end())
9980
{
100-
btnMinValue->setColor( minsymbol->brush().color() );
101-
btnMaxValue->setColor( maxsymbol->brush().color() );
81+
if (iter->second == renderer->classificationField())
82+
break;
83+
iter++;
10284
}
85+
if (iter != mFieldMap.end())
86+
classificationComboBox->setCurrentItem(iter->first);
87+
else
88+
classificationComboBox->setCurrentItem(-1);
10389

104-
outlinewidthspinbox->setMinValue(0);
105-
outlinewidthspinbox->setValue(minsymbol->pen().width());
90+
const QgsSymbol* minsymbol = renderer->minimumSymbol();
91+
const QgsSymbol* maxsymbol = renderer->maximumSymbol();
10692

107-
if (renderer->drawPolygonOutline())
108-
cb_polygonOutline->setCheckState(Qt::Checked);
109-
else
110-
cb_polygonOutline->setCheckState(Qt::Unchecked);
111-
if (mVectorLayer->vectorType() != QGis::Polygon)
112-
cb_polygonOutline->setVisible(false);
93+
if (mVectorLayer->vectorType() == QGis::Line || mVectorLayer->vectorType() == QGis::Point)
94+
{
95+
btnMinValue->setColor( minsymbol->pen().color() );
96+
btnMaxValue->setColor( maxsymbol->pen().color() );
11397
}
11498
else
11599
{
116-
cb_polygonOutline->setCheckState(Qt::Checked);
117-
outlinewidthspinbox->setValue(1);
118-
if (mVectorLayer->vectorType() != QGis::Polygon)
119-
cb_polygonOutline->setVisible(false);
100+
btnMinValue->setColor( minsymbol->brush().color() );
101+
btnMaxValue->setColor( maxsymbol->brush().color() );
102+
}
120103

121-
btnMinValue->setColor(Qt::black);
122-
btnMaxValue->setColor(Qt::white);
104+
outlinewidthspinbox->setMinValue(0);
105+
outlinewidthspinbox->setValue(minsymbol->pen().width());
123106

124-
}
125-
// Ensure that the state of other widgets is appropriate for the
126-
// state of the polygonoutline checkbox.
127-
on_cb_polygonOutline_clicked();
107+
if (renderer->drawPolygonOutline())
108+
cb_polygonOutline->setCheckState(Qt::Checked);
109+
else
110+
cb_polygonOutline->setCheckState(Qt::Unchecked);
111+
if (mVectorLayer->vectorType() != QGis::Polygon)
112+
cb_polygonOutline->setVisible(false);
113+
}
114+
else
115+
{
116+
cb_polygonOutline->setCheckState(Qt::Checked);
117+
outlinewidthspinbox->setValue(1);
118+
if (mVectorLayer->vectorType() != QGis::Polygon)
119+
cb_polygonOutline->setVisible(false);
120+
121+
btnMinValue->setColor(Qt::black);
122+
btnMaxValue->setColor(Qt::white);
123+
124+
}
125+
// Ensure that the state of other widgets is appropriate for the
126+
// state of the polygonoutline checkbox.
127+
on_cb_polygonOutline_clicked();
128128
}
129129

130130
QgsContinuousColorDialog::QgsContinuousColorDialog()
131131
{
132-
setupUi(this);
132+
setupUi(this);
133133
#ifdef QGISDEBUG
134-
qWarning("constructor QgsContinuousColorDialog");
134+
qWarning("constructor QgsContinuousColorDialog");
135135
#endif
136136
}
137137

138138
QgsContinuousColorDialog::~QgsContinuousColorDialog()
139139
{
140140
#ifdef QGISDEBUG
141-
qWarning("destructor QgsContinuousColorDialog");
141+
qWarning("destructor QgsContinuousColorDialog");
142142
#endif
143143
}
144144

145145
void QgsContinuousColorDialog::apply()
146146
{
147-
int comboIndex = classificationComboBox->currentIndex();
148-
if (comboIndex == -1) //don't do anything, if there is no classification field
149-
{
150-
return;
151-
}
152-
std::map < int, int >::iterator iter = mFieldMap.find(comboIndex);
153-
// Should never happen...
154-
assert(iter != mFieldMap.end());
155-
156-
int classfield = iter->second;
157-
158-
//find the minimum and maximum for the classification variable
159-
double minimum, maximum;
160-
QgsVectorDataProvider *provider = dynamic_cast<QgsVectorDataProvider*>(mVectorLayer->getDataProvider());
161-
if (provider)
162-
{
163-
minimum = provider->minValue(classfield).toDouble();
164-
maximum = provider->maxValue(classfield).toDouble();
165-
}
166-
else
167-
{
168-
qWarning("Warning, provider is null in QgsGraSyExtensionWidget::QgsGraSyExtensionWidget(...)");
169-
return;
170-
}
171-
172-
173-
//create the render items for minimum and maximum value
174-
QgsSymbol* minsymbol = new QgsSymbol(mVectorLayer->vectorType(), QString::number(minimum, 'f'), "", "");
175-
if (mVectorLayer->vectorType() == QGis::Line || mVectorLayer->vectorType() == QGis::Point)
176-
{
177-
minsymbol->setPen(QPen(btnMinValue->color(), outlinewidthspinbox->value()));
178-
}
179-
else
180-
{
181-
minsymbol->setBrush(QBrush(btnMinValue->color()));
182-
minsymbol->setPen(QPen(QColor(0, 0, 0), outlinewidthspinbox->value()));
183-
}
184-
185-
QgsSymbol* maxsymbol = new QgsSymbol(mVectorLayer->vectorType(), QString::number(maximum, 'f'), "", "");
186-
if (mVectorLayer->vectorType() == QGis::Line || mVectorLayer->vectorType() == QGis::Point)
187-
{
188-
maxsymbol->setPen(QPen(btnMaxValue->color(), outlinewidthspinbox->value()));
189-
}
190-
else
191-
{
192-
maxsymbol->setBrush(QBrush(btnMaxValue->color()));
193-
maxsymbol->setPen(QPen(QColor(0, 0, 0), outlinewidthspinbox->value()));
194-
}
195-
196-
QgsContinuousColorRenderer* renderer = new QgsContinuousColorRenderer(mVectorLayer->vectorType());
197-
mVectorLayer->setRenderer(renderer);
198-
199-
renderer->setMinimumSymbol(minsymbol);
200-
renderer->setMaximumSymbol(maxsymbol);
201-
renderer->setClassificationField(classfield);
202-
bool drawOutline = (cb_polygonOutline->checkState() == Qt::Checked) ? true:false;
203-
renderer->setDrawPolygonOutline(drawOutline);
147+
int comboIndex = classificationComboBox->currentIndex();
148+
if (comboIndex == -1) //don't do anything, if there is no classification field
149+
{
150+
return;
151+
}
152+
std::map < int, int >::iterator iter = mFieldMap.find(comboIndex);
153+
// Should never happen...
154+
assert(iter != mFieldMap.end());
155+
156+
int classfield = iter->second;
157+
158+
//find the minimum and maximum for the classification variable
159+
double minimum, maximum;
160+
QgsVectorDataProvider *provider = dynamic_cast<QgsVectorDataProvider*>(mVectorLayer->getDataProvider());
161+
if (provider)
162+
{
163+
minimum = provider->minValue(classfield).toDouble();
164+
maximum = provider->maxValue(classfield).toDouble();
165+
}
166+
else
167+
{
168+
qWarning("Warning, provider is null in QgsGraSyExtensionWidget::QgsGraSyExtensionWidget(...)");
169+
return;
170+
}
171+
172+
173+
//create the render items for minimum and maximum value
174+
QgsSymbol* minsymbol = new QgsSymbol(mVectorLayer->vectorType(), QString::number(minimum, 'f'), "", "");
175+
if (mVectorLayer->vectorType() == QGis::Line || mVectorLayer->vectorType() == QGis::Point)
176+
{
177+
minsymbol->setPen(QPen(btnMinValue->color(), outlinewidthspinbox->value()));
178+
}
179+
else
180+
{
181+
minsymbol->setBrush(QBrush(btnMinValue->color()));
182+
minsymbol->setPen(QPen(QColor(0, 0, 0), outlinewidthspinbox->value()));
183+
}
184+
185+
QgsSymbol* maxsymbol = new QgsSymbol(mVectorLayer->vectorType(), QString::number(maximum, 'f'), "", "");
186+
if (mVectorLayer->vectorType() == QGis::Line || mVectorLayer->vectorType() == QGis::Point)
187+
{
188+
maxsymbol->setPen(QPen(btnMaxValue->color(), outlinewidthspinbox->value()));
189+
}
190+
else
191+
{
192+
maxsymbol->setBrush(QBrush(btnMaxValue->color()));
193+
maxsymbol->setPen(QPen(QColor(0, 0, 0), outlinewidthspinbox->value()));
194+
}
195+
196+
QgsContinuousColorRenderer* renderer = new QgsContinuousColorRenderer(mVectorLayer->vectorType());
197+
mVectorLayer->setRenderer(renderer);
198+
199+
renderer->setMinimumSymbol(minsymbol);
200+
renderer->setMaximumSymbol(maxsymbol);
201+
renderer->setClassificationField(classfield);
202+
bool drawOutline = (cb_polygonOutline->checkState() == Qt::Checked) ? true:false;
203+
renderer->setDrawPolygonOutline(drawOutline);
204204
}
205205

206206
void QgsContinuousColorDialog::selectMinimumColor()
207207
{
208-
QColor mincolor = QColorDialog::getColor(btnMinValue->color(), this);
209-
if(mincolor.isValid())
210-
{
211-
btnMinValue->setColor(mincolor);
212-
}
213-
setActiveWindow();
208+
QColor mincolor = QColorDialog::getColor(btnMinValue->color(), this);
209+
if(mincolor.isValid())
210+
{
211+
btnMinValue->setColor(mincolor);
212+
}
213+
setActiveWindow();
214214
}
215215

216216
void QgsContinuousColorDialog::selectMaximumColor()
217217
{
218-
QColor maxcolor = QColorDialog::getColor(btnMaxValue->color(), this);
219-
if(maxcolor.isValid())
220-
{
221-
btnMaxValue->setColor(maxcolor);
222-
}
223-
setActiveWindow();
218+
QColor maxcolor = QColorDialog::getColor(btnMaxValue->color(), this);
219+
if(maxcolor.isValid())
220+
{
221+
btnMaxValue->setColor(maxcolor);
222+
}
223+
setActiveWindow();
224224
}
225225

226226
void QgsContinuousColorDialog::on_cb_polygonOutline_clicked()

0 commit comments

Comments
 (0)