rule_renderer_patch_on_r15004-symbols_not_merged.diff
/hometb/mk/sig/dev/r15004-patched/qgis//src/core/qgsvectorlayer.cpp 2011-01-08 12:46:24.750864682 +0100 | ||
---|---|---|
837 | 837 |
for ( int i = 0; i < symbols.count(); i++ ) |
838 | 838 |
{ |
839 | 839 |
QgsSymbolV2* sym = symbols[i]; |
840 |
|
|
841 |
QgsDebugMsg( "num layers symbols:" + |
|
842 |
QString::number( sym->symbolLayerCount() ) ); |
|
840 | 843 |
for ( int j = 0; j < sym->symbolLayerCount(); j++ ) |
841 | 844 |
{ |
842 | 845 |
int level = sym->symbolLayer( j )->renderingPass(); |
843 |
if ( level < 0 || level >= 1000 ) // ignore invalid levels |
|
844 |
continue; |
|
846 |
|
|
847 |
QgsDebugMsg( "Level: " + QString::number(level )); |
|
848 | ||
849 |
if ( level < 0 || level >= 1000 ){ // ignore invalid levels |
|
850 |
QgsDebugMsg( "invalid levels!" );continue;} |
|
845 | 851 |
QgsSymbolV2LevelItem item( sym, j ); |
846 | 852 |
while ( level >= levels.count() ) // append new empty levels |
847 | 853 |
levels.append( QgsSymbolV2Level() ); |
... | ... | |
858 | 864 |
QgsSymbolV2LevelItem& item = level[i]; |
859 | 865 |
if ( !features.contains( item.symbol() ) ) |
860 | 866 |
{ |
861 |
QgsDebugMsg( "level item's symbol not found!" ); |
|
867 |
// QgsDebugMsg( "level item's symbol not found!" );
|
|
862 | 868 |
continue; |
863 | 869 |
} |
870 |
QgsDebugMsg( "level item's symbol found. Level " + QString::number( i ) + "/" + QString::number(level.count() ) ); |
|
871 | ||
864 | 872 |
int layer = item.layer(); |
865 | 873 |
QList<QgsFeature>& lst = features[item.symbol()]; |
866 | 874 |
QList<QgsFeature>::iterator fit; |
/hometb/mk/sig/dev/r15004-patched/qgis//src/core/symbology-ng/qgsrulebasedrendererv2.cpp 2011-01-08 12:46:24.770864038 +0100 | ||
---|---|---|
14 | 14 |
***************************************************************************/ |
15 | 15 | |
16 | 16 |
#include "qgsrulebasedrendererv2.h" |
17 | ||
17 |
#include "qgssymbollayerv2.h" |
|
18 | 18 |
#include "qgssearchtreenode.h" |
19 | 19 |
#include "qgssymbollayerv2utils.h" |
20 | 20 |
#include "qgsrendercontext.h" |
... | ... | |
28 | 28 | |
29 | 29 | |
30 | 30 | |
31 |
QgsRuleBasedRendererV2::Rule::Rule( QgsSymbolV2* symbol, int scaleMinDenom, int scaleMaxDenom, QString filterExp ) |
|
31 |
QgsRuleBasedRendererV2::Rule::Rule( QgsSymbolV2* symbol, int scaleMinDenom, int scaleMaxDenom, QString filterExp, QString label, QString description )
|
|
32 | 32 |
: mSymbol( symbol ), |
33 | 33 |
mScaleMinDenom( scaleMinDenom ), mScaleMaxDenom( scaleMaxDenom ), |
34 |
mFilterExp( filterExp ) |
|
34 |
mFilterExp( filterExp ), mLabel( label ), mDescription( description )
|
|
35 | 35 |
{ |
36 | 36 |
initFilter(); |
37 | 37 |
} |
... | ... | |
62 | 62 | |
63 | 63 |
QString QgsRuleBasedRendererV2::Rule::dump() const |
64 | 64 |
{ |
65 |
return QString( "RULE - scale [%1,%2] - filter %3 - symbol %4" )
|
|
66 |
.arg( mScaleMinDenom ).arg( mScaleMaxDenom ) |
|
65 |
return QString( "RULE %1 - scale [%2,%3] - filter %4 - symbol %5" )
|
|
66 |
.arg( mLabel ).arg( mScaleMinDenom ).arg( mScaleMaxDenom )
|
|
67 | 67 |
.arg( mFilterExp ).arg( mSymbol->dump() ); |
68 | 68 | |
69 | 69 |
} |
... | ... | |
107 | 107 |
mScaleMinDenom = other.mScaleMinDenom; |
108 | 108 |
mScaleMaxDenom = other.mScaleMaxDenom; |
109 | 109 |
mFilterExp = other.mFilterExp; |
110 |
mLabel = other.mLabel; |
|
111 |
mDescription = other.mDescription; |
|
110 | 112 |
initFilter(); |
111 | 113 |
} |
112 | 114 |
return *this; |
... | ... | |
126 | 128 | |
127 | 129 |
QgsSymbolV2* QgsRuleBasedRendererV2::symbolForFeature( QgsFeature& feature ) |
128 | 130 |
{ |
129 |
return mCurrentSymbol; |
|
131 |
QgsDebugMsg( "usingSymbolLevels:" ); |
|
132 |
QgsDebugMsg( QString(usingSymbolLevels()?"T":"F") ); |
|
133 |
QgsDebugMsg( QString(mUsingSymbolLevels?"T":"F") ); |
|
134 |
// return mCurrentSymbol; // uncomment this out to disable UsingSymbolLevels |
|
135 |
if( !usingSymbolLevels() ) return mCurrentSymbol;// comment this out to disable UsingSymbolLevels |
|
136 | ||
137 |
for ( QList<Rule*>::iterator it = mCurrentRules.begin(); it != mCurrentRules.end(); ++it ) |
|
138 |
{ |
|
139 |
Rule* rule = *it; |
|
140 | ||
141 |
if ( rule->isFilterOK( mCurrentFields, feature ) ) |
|
142 |
{ |
|
143 |
return rule->symbol(); //works with levels but takes only first rule |
|
144 |
} |
|
145 |
} |
|
130 | 146 |
} |
131 | 147 | |
132 | 148 |
void QgsRuleBasedRendererV2::renderFeature( QgsFeature& feature, |
... | ... | |
198 | 214 |
QgsSymbolV2* s = mDefaultSymbol->clone(); |
199 | 215 |
QgsRuleBasedRendererV2* r = new QgsRuleBasedRendererV2( s ); |
200 | 216 |
r->mRules = mRules; |
217 |
r->setUsingSymbolLevels( usingSymbolLevels() ); // comment this out to disable UsingSymbolLevels |
|
201 | 218 |
return r; |
202 | 219 |
} |
203 | 220 | |
... | ... | |
217 | 234 |
{ |
218 | 235 |
QDomElement rendererElem = doc.createElement( RENDERER_TAG_NAME ); |
219 | 236 |
rendererElem.setAttribute( "type", "RuleRenderer" ); |
237 |
rendererElem.setAttribute( "symbollevels", ( mUsingSymbolLevels ? "1" : "0" ) ); |
|
220 | 238 | |
221 | 239 |
QDomElement rulesElem = doc.createElement( "rules" ); |
222 | 240 | |
... | ... | |
233 | 251 |
ruleElem.setAttribute( "filter", rule.filterExpression() ); |
234 | 252 |
ruleElem.setAttribute( "scalemindenom", rule.scaleMinDenom() ); |
235 | 253 |
ruleElem.setAttribute( "scalemaxdenom", rule.scaleMaxDenom() ); |
254 |
ruleElem.setAttribute( "label", rule.label() ); |
|
255 |
ruleElem.setAttribute( "description", rule.description() ); |
|
236 | 256 |
rulesElem.appendChild( ruleElem ); |
237 | 257 |
} |
238 | 258 |
rendererElem.appendChild( rulesElem ); |
... | ... | |
250 | 270 |
for ( QList<Rule>::iterator it = mRules.begin(); it != mRules.end(); ++it ) |
251 | 271 |
{ |
252 | 272 |
QPixmap pix = QgsSymbolLayerV2Utils::symbolPreviewPixmap( it->symbol(), iconSize ); |
253 |
lst << qMakePair( it->filterExpression(), pix );
|
|
273 |
lst << qMakePair( it->label(), pix );
|
|
254 | 274 |
} |
255 | 275 |
return lst; |
256 | 276 |
} |
... | ... | |
260 | 280 |
QgsLegendSymbolList lst; |
261 | 281 |
for ( QList<Rule>::iterator it = mRules.begin(); it != mRules.end(); ++it ) |
262 | 282 |
{ |
263 |
lst << qMakePair( it->filterExpression(), it->symbol() );
|
|
283 |
lst << qMakePair( it->label(), it->symbol() );
|
|
264 | 284 |
} |
265 | 285 |
return lst; |
266 | 286 |
} |
... | ... | |
292 | 312 |
if ( symbolMap.contains( symbolIdx ) ) |
293 | 313 |
{ |
294 | 314 |
QString filterExp = ruleElem.attribute( "filter" ); |
315 |
QString label = ruleElem.attribute( "label" ); |
|
316 |
QString description = ruleElem.attribute( "description" ); |
|
295 | 317 |
int scaleMinDenom = ruleElem.attribute( "scalemindenom", "0" ).toInt(); |
296 | 318 |
int scaleMaxDenom = ruleElem.attribute( "scalemaxdenom", "0" ).toInt(); |
297 |
r->mRules.append( Rule( symbolMap.take( symbolIdx ), scaleMinDenom, scaleMaxDenom, filterExp ) ); |
|
319 |
r->mRules.append( Rule( symbolMap.take( symbolIdx ), scaleMinDenom, scaleMaxDenom, filterExp, label, description ) );
|
|
298 | 320 |
} |
299 | 321 |
else |
300 | 322 |
{ |
... | ... | |
350 | 372 |
{ |
351 | 373 |
QString newfilter = QString( "%1 = '%2'" ).arg( r->classAttribute() ).arg( cat.value().toString() ); |
352 | 374 |
QString filter = initialRule.filterExpression(); |
375 |
QString label = initialRule.label(); |
|
376 |
QString description = initialRule.description(); |
|
353 | 377 |
if ( filter.isEmpty() ) |
354 | 378 |
filter = newfilter; |
355 | 379 |
else |
356 | 380 |
filter = QString( "(%1) AND (%2)" ).arg( filter ).arg( newfilter ); |
357 |
rules.append( Rule( cat.symbol()->clone(), initialRule.scaleMinDenom(), initialRule.scaleMaxDenom(), filter ) ); |
|
381 |
rules.append( Rule( cat.symbol()->clone(), initialRule.scaleMinDenom(), initialRule.scaleMaxDenom(), filter, initialRule.label(), initialRule.description() ) );
|
|
358 | 382 |
} |
359 | 383 |
return rules; |
360 | 384 |
} |
... | ... | |
366 | 390 |
{ |
367 | 391 |
QString newfilter = QString( "%1 >= '%2' AND %1 <= '%3'" ).arg( r->classAttribute() ).arg( rng.lowerValue() ).arg( rng.upperValue() ); |
368 | 392 |
QString filter = initialRule.filterExpression(); |
393 |
QString label = initialRule.label(); |
|
394 |
QString description = initialRule.description(); |
|
369 | 395 |
if ( filter.isEmpty() ) |
370 | 396 |
filter = newfilter; |
371 | 397 |
else |
372 | 398 |
filter = QString( "(%1) AND (%2)" ).arg( filter ).arg( newfilter ); |
373 |
rules.append( Rule( rng.symbol()->clone(), initialRule.scaleMinDenom(), initialRule.scaleMaxDenom(), filter ) ); |
|
399 |
rules.append( Rule( rng.symbol()->clone(), initialRule.scaleMinDenom(), initialRule.scaleMaxDenom(), filter, initialRule.label(), initialRule.description() ) );
|
|
374 | 400 |
} |
375 | 401 |
return rules; |
376 | 402 |
} |
... | ... | |
387 | 413 |
continue; // jump over the first scales out of the interval |
388 | 414 |
if ( maxDenom != 0 && maxDenom <= scale ) |
389 | 415 |
break; // ignore the latter scales out of the interval |
390 |
rules.append( Rule( initialRule.symbol()->clone(), oldScale, scale, initialRule.filterExpression() ) ); |
|
416 |
rules.append( Rule( initialRule.symbol()->clone(), oldScale, scale, initialRule.filterExpression(), initialRule.label(), initialRule.description() ) );
|
|
391 | 417 |
oldScale = scale; |
392 | 418 |
} |
393 | 419 |
// last rule |
394 |
rules.append( Rule( initialRule.symbol()->clone(), oldScale, maxDenom, initialRule.filterExpression() ) ); |
|
420 |
rules.append( Rule( initialRule.symbol()->clone(), oldScale, maxDenom, initialRule.filterExpression(), initialRule.label(), initialRule.description() ) );
|
|
395 | 421 |
return rules; |
396 | 422 |
} |
/hometb/mk/sig/dev/r15004-patched/qgis//src/core/symbology-ng/qgsrulebasedrendererv2.h 2011-01-08 12:46:24.780863716 +0100 | ||
---|---|---|
44 | 44 |
{ |
45 | 45 |
public: |
46 | 46 |
//! Constructor takes ownership of the symbol |
47 |
Rule( QgsSymbolV2* symbol, int scaleMinDenom = 0, int scaleMaxDenom = 0, QString filterExp = QString() ); |
|
47 |
Rule( QgsSymbolV2* symbol, int scaleMinDenom = 0, int scaleMaxDenom = 0, QString filterExp = QString(), QString label = QString(), QString description = QString() );
|
|
48 | 48 |
Rule( const Rule& other ); |
49 | 49 |
~Rule(); |
50 | 50 |
QString dump() const; |
... | ... | |
57 | 57 |
int scaleMinDenom() const { return mScaleMinDenom; } |
58 | 58 |
int scaleMaxDenom() const { return mScaleMaxDenom; } |
59 | 59 |
QString filterExpression() const { return mFilterExp; } |
60 |
QString label() const { return mLabel; } |
|
61 |
QString description() const { return mDescription; } |
|
60 | 62 | |
61 | 63 |
void setScaleMinDenom( int scaleMinDenom ) { mScaleMinDenom = scaleMinDenom; } |
62 | 64 |
void setScaleMaxDenom( int scaleMaxDenom ) { mScaleMaxDenom = scaleMaxDenom; } |
63 | 65 |
void setFilterExpression( QString filterExp ) { mFilterExp = filterExp; initFilter(); } |
64 | ||
66 |
void setLabel( QString label ) { mLabel = label; } |
|
67 |
void setDescription( QString description ) { mDescription = description; } |
|
68 |
|
|
65 | 69 |
Rule& operator=( const Rule& other ); |
66 | 70 | |
67 | 71 |
protected: |
... | ... | |
70 | 74 | |
71 | 75 |
QgsSymbolV2* mSymbol; |
72 | 76 |
int mScaleMinDenom, mScaleMaxDenom; |
73 |
QString mFilterExp; |
|
77 |
QString mFilterExp, mLabel, mDescription;
|
|
74 | 78 | |
75 | 79 |
// temporary |
76 | 80 |
QgsSearchString mFilterParsed; |
... | ... | |
81 | 85 | |
82 | 86 |
static QgsFeatureRendererV2* create( QDomElement& element ); |
83 | 87 | |
84 |
//! Constructor. Takes ownership of the defult symbol. |
|
88 |
//! Constructor. Takes ownership of the default symbol.
|
|
85 | 89 |
QgsRuleBasedRendererV2( QgsSymbolV2* defaultSymbol ); |
86 | 90 | |
87 | 91 |
//! return symbol for current feature. Should not be used individually: there could be more symbols for a feature |
/hometb/mk/sig/dev/r15004-patched/qgis//src/gui/symbology-ng/qgsrulebasedrendererv2widget.cpp 2011-01-10 23:23:49.468293016 +0100 | ||
---|---|---|
27 | 27 |
#include <QTreeWidgetItem> |
28 | 28 |
#include <QVBoxLayout> |
29 | 29 |
#include <QMessageBox> |
30 |
#include <sstream> |
|
30 | 31 | |
31 | 32 |
QgsRendererV2Widget* QgsRuleBasedRendererV2Widget::create( QgsVectorLayer* layer, QgsStyleV2* style, QgsFeatureRendererV2* renderer ) |
32 | 33 |
{ |
... | ... | |
57 | 58 |
setupUi( this ); |
58 | 59 | |
59 | 60 |
treeRules->setRenderer( mRenderer ); |
60 | ||
61 |
treeRules->setColumnCount(5); // FIXME: is this necessary for all 3 types of grouping? |
|
61 | 62 |
mRefineMenu = new QMenu( btnRefineRule ); |
62 | 63 |
mRefineMenu->addAction( tr( "Add scales" ), this, SLOT( refineRuleScales() ) ); |
63 | 64 |
mRefineMenu->addAction( tr( "Add categories" ), this, SLOT( refineRuleCategories() ) ); |
... | ... | |
303 | 304 |
setupUi( this ); |
304 | 305 | |
305 | 306 |
editFilter->setText( mRule.filterExpression() ); |
306 | ||
307 |
editLabel->setText( mRule.label() ); |
|
308 |
editDescription->setText( mRule.description() ); |
|
309 |
|
|
307 | 310 |
if ( mRule.dependsOnScale() ) |
308 | 311 |
{ |
309 | 312 |
groupScale->setChecked( true ); |
... | ... | |
368 | 371 |
void QgsRendererRulePropsDialog::updateRuleFromGui() |
369 | 372 |
{ |
370 | 373 |
mRule.setFilterExpression( editFilter->text() ); |
374 |
mRule.setLabel( editLabel->text() ); |
|
375 |
mRule.setDescription( editDescription->text() ); |
|
371 | 376 |
mRule.setScaleMinDenom( groupScale->isChecked() ? spinMinScale->value() : 0 ); |
372 | 377 |
mRule.setScaleMaxDenom( groupScale->isChecked() ? spinMaxScale->value() : 0 ); |
373 | 378 |
} |
... | ... | |
400 | 405 | |
401 | 406 |
QString QgsRendererRulesTreeWidget::formatScaleRange( int minDenom, int maxDenom ) |
402 | 407 |
{ |
403 |
if ( maxDenom != 0 ) |
|
404 |
return QString( "<1:%1, 1:%2>" ).arg( minDenom ).arg( maxDenom ); |
|
408 |
// if ( maxDenom != 0 ) |
|
409 |
// return QString( "<1:%1, 1:%2>" ).arg( minDenom ).arg( maxDenom ); |
|
410 |
// else |
|
411 |
// return QString( "<1:%1, 1:inf>" ).arg( minDenom ); |
|
412 |
if ( maxDenom != 0 ){ |
|
413 |
if ( minDenom != 0 ){ |
|
414 |
return QString( "<%1, %2>" ).arg( formatScale( minDenom ) ).arg( formatScale( maxDenom ) ); |
|
415 |
} |
|
416 |
else |
|
417 |
return QString( "<1:0, %1>" ).arg( formatScale( maxDenom ) ); |
|
418 |
} |
|
405 | 419 |
else |
406 |
return QString( "<1:%1, 1:inf>" ).arg( minDenom ); |
|
420 |
return QString( "<%1, 1:inf>" ).arg( formatScale( minDenom ) ); |
|
421 |
|
|
407 | 422 |
} |
408 | 423 | |
424 |
QString QgsRendererRulesTreeWidget::formatScale( int denom ) |
|
425 |
{ |
|
426 |
if ( denom != 0 ) { |
|
427 |
QString denomString = QString( "%1" ).arg( denom ); |
|
428 | ||
429 |
// Add spaces for thousands separators |
|
430 |
// FIXME: it's not sure to work for right-to-left languages e.g. launching qgis with ./qgis --lang ar |
|
431 |
// Hence it is currently disabled for those languages. Otherwise "1:15 000" is displayed "000 15:1" |
|
432 |
// (at least running ./qgis --lang ar on French Kubuntu) |
|
433 |
// Uncomment QgsDebugMsg() lines below if you try to debug this |
|
434 | ||
435 |
if ( layoutDirection() == Qt::LeftToRight ){ |
|
436 |
int nSeps=0; |
|
437 |
for ( int i=3; i + nSeps < denomString.size() ; i+=3){ |
|
438 |
// QgsDebugMsg( "Scale before="+ QString(denomString)); |
|
439 |
// QgsDebugMsg( "sc=" + QString( "%1" ).arg( denom ) +" i=" + QString::number(i) +" denomSt sz=" |
|
440 |
// + QString::number(denomString.size()) +" nSeps=" + QString::number(nSeps)); |
|
441 |
denomString.insert(denomString.size() - i - nSeps, " " ); nSeps++; // ISO-31-0 recommands spaces rather than locale-based separator, |
|
442 |
// see http://en.wikipedia.org/wiki/ISO_31-0#Numbers |
|
443 |
// QgsDebugMsg( "Scale after="+ QString(denomString)); |
|
444 |
} |
|
445 |
} |
|
446 |
QgsDebugMsg( "Formatted scale="+ QString(denomString)); |
|
447 |
return QString( "1:%1" ).arg( denomString ); |
|
448 |
} |
|
449 |
else |
|
450 |
return QString( "" ); |
|
451 |
} |
|
452 | ||
453 | ||
454 |
int widthMinDenom = 0; // is it the best place to declare those? |
|
455 |
int widthMaxDenom = 0; |
|
409 | 456 | |
410 | 457 |
void QgsRendererRulesTreeWidget::populateRules() |
411 | 458 |
{ |
412 | 459 |
if ( !mR ) return; |
413 | 460 | |
414 | 461 |
clear(); |
462 | ||
463 | ||
464 |
for ( int i = 0; i < mR->ruleCount(); ++i ) // find longest scale string for future padding. FIXME: code already use above; avoid duplicate |
|
465 |
{ |
|
466 |
QgsRuleBasedRendererV2::Rule& rule = mR->ruleAt( i ); |
|
467 | ||
468 |
if( formatScale( rule.scaleMinDenom() ).size() > widthMinDenom ) |
|
469 |
widthMinDenom = formatScale( rule.scaleMinDenom() ).size() ; |
|
470 | ||
471 |
if( formatScale( rule.scaleMaxDenom() ).size() > widthMaxDenom ) |
|
472 |
widthMaxDenom = formatScale( rule.scaleMaxDenom() ).size() ; |
|
473 |
} |
|
474 |
|
|
475 | ||
476 | ||
415 | 477 |
if ( mGrouping == NoGrouping ) |
416 | 478 |
populateRulesNoGrouping(); |
417 | 479 |
else if ( mGrouping == GroupingByScale ) |
... | ... | |
423 | 485 |
void QgsRendererRulesTreeWidget::populateRulesNoGrouping() |
424 | 486 |
{ |
425 | 487 |
QList<QTreeWidgetItem *> lst; |
488 | ||
426 | 489 |
for ( int i = 0; i < mR->ruleCount(); ++i ) |
427 | 490 |
{ |
428 | 491 |
QgsRuleBasedRendererV2::Rule& rule = mR->ruleAt( i ); |
429 | 492 | |
430 | 493 |
QTreeWidgetItem* item = new QTreeWidgetItem; |
431 |
QString txt = rule.filterExpression(); |
|
432 |
if ( txt.isEmpty() ) txt = tr( "(no filter)" ); |
|
433 |
if ( rule.dependsOnScale() ) |
|
434 |
{ |
|
435 |
txt += tr( ", scale " ) + formatScaleRange( rule.scaleMinDenom(), rule.scaleMaxDenom() ); |
|
436 |
} |
|
437 | 494 | |
438 |
item->setText( 0, txt ); |
|
495 |
QString txtLabel = rule.label(); |
|
496 |
item->setText( 0, txtLabel ); |
|
439 | 497 |
item->setData( 0, Qt::UserRole + 1, i ); |
440 | 498 |
item->setIcon( 0, QgsSymbolLayerV2Utils::symbolPreviewIcon( rule.symbol(), QSize( 16, 16 ) ) ); |
441 | 499 | |
500 |
QString txtRule = rule.filterExpression(); |
|
501 |
if ( txtRule.isEmpty() ) txtRule = tr( "(no filter)" ); |
|
502 |
item->setText( 1, txtRule ); |
|
503 | ||
504 |
if ( rule.dependsOnScale() ) |
|
505 |
{ |
|
506 |
QString txtMinDenomScale = formatScale( rule.scaleMinDenom() ); |
|
507 |
QString txtMaxDenomScale = formatScale( rule.scaleMaxDenom() ); |
|
508 |
while( txtMinDenomScale.size() < widthMinDenom ){ txtMinDenomScale.insert( 0, " " );} // pad to left with spaces (to fix string-based sorting) |
|
509 |
while( txtMaxDenomScale.size() < widthMaxDenom ){ txtMaxDenomScale.insert( 0, " " );} |
|
510 |
item->setText( 2, txtMinDenomScale ); |
|
511 |
item->setText( 3, txtMaxDenomScale ); |
|
512 |
item->setTextAlignment (2, Qt::AlignRight); |
|
513 |
item->setTextAlignment (3, Qt::AlignRight); |
|
514 |
} |
|
515 | ||
516 |
QBrush brush( QColor( 200, 200, 200, 255 ) ); |
|
517 |
item->setBackground( 1, brush ); |
|
518 |
item->setBackground( 3, brush ); |
|
519 | ||
520 |
// Id: add 1 to rule number and convert to string |
|
521 |
std::ostringstream ioss; |
|
522 |
ioss << i+1; |
|
523 |
std::string ruleIdx = ioss.str(); |
|
524 |
while( ruleIdx.size() < 4 ){ ruleIdx.insert( 0, " " );} // pad to left with spaces (to fix string-based sorting) |
|
525 |
item->setText( 4, QString(ruleIdx.c_str()) );// Insert Id in table TODO: base it on SymbolIdx ? How to access it? |
|
526 |
item->setTextAlignment (4, Qt::AlignRight); |
|
442 | 527 |
lst << item; |
443 | 528 |
} |
444 | 529 | |
530 | ||
445 | 531 |
addTopLevelItems( lst ); |
446 | 532 |
} |
447 | 533 | |
... | ... | |
466 | 552 |
scale_item->setText( 0, txt ); |
467 | 553 |
scale_item->setData( 0, Qt::UserRole + 1, -2 ); |
468 | 554 |
scale_item->setFlags( scale_item->flags() & ~Qt::ItemIsDragEnabled ); // groups cannot be dragged |
555 |
QFont italicFont("" , -1 , -1, true ); |
|
556 |
scale_item->setFont( 0, italicFont ); |
|
469 | 557 |
scale_items[scale] = scale_item; |
558 |
// need to add the item before setFirstColumnSpanned, |
|
559 |
// see http://qt.nokia.com/developer/task-tracker/index_html?method=entry&id=214686 |
|
560 |
addTopLevelItem( scale_item ); |
|
561 |
scale_item->setFirstColumnSpanned( true ); |
|
470 | 562 |
} |
471 | 563 | |
472 | 564 |
QString filter = rule.filterExpression(); |
473 | 565 | |
474 | 566 |
QTreeWidgetItem* item = new QTreeWidgetItem( scale_items[scale] ); |
475 |
item->setText( 0, filter.isEmpty() ? tr( "(no filter)" ) : filter ); |
|
567 | ||
568 |
QString txtLabel = rule.label(); |
|
569 |
item->setText( 0, txtLabel ); |
|
476 | 570 |
item->setData( 0, Qt::UserRole + 1, i ); |
477 | 571 |
item->setIcon( 0, QgsSymbolLayerV2Utils::symbolPreviewIcon( rule.symbol(), QSize( 16, 16 ) ) ); |
572 | ||
573 |
QString txtRule = rule.filterExpression(); |
|
574 |
if ( txtRule.isEmpty() ) txtRule = tr( "(no filter)" ); |
|
575 |
item->setText( 1, txtRule ); |
|
576 | ||
577 |
if ( rule.dependsOnScale() ) |
|
578 |
{ |
|
579 |
QString txtMinDenomScale = formatScale( rule.scaleMinDenom() ); |
|
580 |
QString txtMaxDenomScale = formatScale( rule.scaleMaxDenom() ); |
|
581 |
while( txtMinDenomScale.size() < widthMinDenom ){ txtMinDenomScale.insert( 0, " " );} // pad to left with spaces (to fix string-based sorting) |
|
582 |
while( txtMaxDenomScale.size() < widthMaxDenom ){ txtMaxDenomScale.insert( 0, " " );} |
|
583 |
// Displaying scales is redundant here, but keeping them allows to keep constant the layout and width of all columns when switching to one of the two other views |
|
584 |
item->setText( 2, txtMinDenomScale ); |
|
585 |
item->setText( 3, txtMaxDenomScale ); |
|
586 |
item->setTextAlignment (2, Qt::AlignRight); |
|
587 |
item->setTextAlignment (3, Qt::AlignRight); |
|
588 |
} |
|
589 | ||
590 |
QBrush brush( QColor( 200, 200, 200, 255 ) ); |
|
591 |
item->setBackground( 1, brush ); |
|
592 |
item->setBackground( 3, brush ); |
|
593 | ||
594 |
// Id: add 1 to rule number and convert to string |
|
595 |
std::ostringstream ioss; |
|
596 |
ioss << i+1; |
|
597 |
std::string ruleIdx = ioss.str(); |
|
598 |
while( ruleIdx.size() < 4 ){ ruleIdx.insert( 0, " " );} // pad to left with spaces (to fix string-based sorting) |
|
599 |
item->setText( 4, QString(ruleIdx.c_str()) );// Insert Id in table TODO: base it on SymbolIdx ? How to access it? |
|
600 |
item->setTextAlignment (4, Qt::AlignRight); |
|
601 | ||
478 | 602 |
} |
479 | 603 |
addTopLevelItems( scale_items.values() ); |
480 | 604 |
} |
... | ... | |
494 | 618 |
filter_item->setText( 0, filter.isEmpty() ? tr( "(no filter)" ) : filter ); |
495 | 619 |
filter_item->setData( 0, Qt::UserRole + 1, -1 ); |
496 | 620 |
filter_item->setFlags( filter_item->flags() & ~Qt::ItemIsDragEnabled ); // groups cannot be dragged |
621 |
QFont italicFont("" , -1 , -1, true ); |
|
622 |
filter_item->setFont( 0, italicFont ); |
|
497 | 623 |
filter_items[filter] = filter_item; |
624 |
// need to add the item before setFirstColumnSpanned, |
|
625 |
// see http://qt.nokia.com/developer/task-tracker/index_html?method=entry&id=214686 |
|
626 |
addTopLevelItem( filter_item ); |
|
627 |
filter_item->setFirstColumnSpanned( true ); |
|
498 | 628 |
} |
499 | 629 | |
500 |
QString txt; |
|
501 |
if ( rule.dependsOnScale() ) |
|
502 |
txt = QString( "scale <1:%1, 1:%2>" ).arg( rule.scaleMinDenom() ).arg( rule.scaleMaxDenom() ); |
|
503 |
else |
|
504 |
txt = "any scale"; |
|
630 |
// Displaying scaleMinDenom and scaleMaxDenom separately allows to sort by them in the widget |
|
631 |
// QString txt; |
|
632 |
// if ( rule.dependsOnScale() ) |
|
633 |
// txt = QString( "scale <1:%1, 1:%2>" ).arg( rule.scaleMinDenom() ).arg( rule.scaleMaxDenom() ); |
|
634 |
// else |
|
635 |
// txt = "any scale"; |
|
505 | 636 | |
506 | 637 |
QTreeWidgetItem* item = new QTreeWidgetItem( filter_items[filter] ); |
507 |
item->setText( 0, txt ); |
|
638 | ||
639 |
QString txtLabel = rule.label(); |
|
640 |
item->setText( 0, txtLabel ); |
|
508 | 641 |
item->setData( 0, Qt::UserRole + 1, i ); |
509 | 642 |
item->setIcon( 0, QgsSymbolLayerV2Utils::symbolPreviewIcon( rule.symbol(), QSize( 16, 16 ) ) ); |
510 | 643 | |
644 |
// Displaying filter is redundant here, but keeping it allows to keep constant the layout and width of all columns when switching to one of the two other views |
|
645 |
item->setText( 1, filter ); |
|
646 | ||
647 |
QBrush brush( QColor( 200, 200, 200, 255 ) ); |
|
648 |
item->setBackground( 1, brush ); // Makes table layout slightly more readable when filters are long strings |
|
649 |
item->setBackground( 3, brush ); |
|
650 |
|
|
651 |
if ( rule.dependsOnScale() ) |
|
652 |
{ |
|
653 |
QString txtMinDenomScale = formatScale( rule.scaleMinDenom() ); |
|
654 |
QString txtMaxDenomScale = formatScale( rule.scaleMaxDenom() ); |
|
655 |
while( txtMinDenomScale.size() < widthMinDenom ){ txtMinDenomScale.insert( 0, " " );} // pad to left with spaces (to fix string-based sorting) |
|
656 |
while( txtMaxDenomScale.size() < widthMaxDenom ){ txtMaxDenomScale.insert( 0, " " );} |
|
657 |
item->setText( 2, txtMinDenomScale ); |
|
658 |
item->setText( 3, txtMaxDenomScale ); |
|
659 |
item->setTextAlignment (2, Qt::AlignRight); |
|
660 |
item->setTextAlignment (3, Qt::AlignRight); |
|
661 |
} |
|
662 | ||
663 |
// Id: add 1 to rule number and convert to string |
|
664 |
std::ostringstream ioss; |
|
665 |
ioss << i+1; |
|
666 |
std::string ruleIdx = ioss.str(); |
|
667 |
while( ruleIdx.size() < 4 ){ ruleIdx.insert( 0, " " );} // pad to left with spaces (to fix string-based sorting) |
|
668 |
item->setText( 4, QString(ruleIdx.c_str()) );// Insert Id in table TODO: base it on SymbolIdx ? How to access it? |
|
669 |
item->setTextAlignment (4, Qt::AlignRight); |
|
511 | 670 |
} |
671 | ||
512 | 672 |
addTopLevelItems( filter_items.values() ); |
673 | ||
674 | ||
513 | 675 |
} |
/hometb/mk/sig/dev/r15004-patched/qgis//src/gui/symbology-ng/qgsrulebasedrendererv2widget.h 2011-01-10 22:21:11.646002145 +0100 | ||
---|---|---|
47 | 47 | |
48 | 48 |
QString formatScaleRange( int minDenom, int maxDenom ); |
49 | 49 | |
50 |
QString formatScale( int denom ); |
|
51 | ||
50 | 52 |
QgsRuleBasedRendererV2* mR; |
51 | 53 |
Grouping mGrouping; |
52 | 54 |
}; |
... | ... | |
120 | 122 | |
121 | 123 | |
122 | 124 |
#endif // QGSRULEBASEDRENDERERV2WIDGET_H |
125 | ||
126 |
#include <qgslogger.h> |
/hometb/mk/sig/dev/r15004-patched/qgis//src/ui/qgsrendererrulepropsdialogbase.ui 2011-01-08 12:46:24.810862752 +0100 | ||
---|---|---|
6 | 6 |
<rect> |
7 | 7 |
<x>0</x> |
8 | 8 |
<y>0</y> |
9 |
<width>545</width>
|
|
9 |
<width>558</width>
|
|
10 | 10 |
<height>298</height> |
11 | 11 |
</rect> |
12 | 12 |
</property> |
... | ... | |
22 | 22 |
<item> |
23 | 23 |
<widget class="QLabel" name="label"> |
24 | 24 |
<property name="text"> |
25 |
<string>Legend label</string> |
|
26 |
</property> |
|
27 |
</widget> |
|
28 |
</item> |
|
29 |
<item> |
|
30 |
<widget class="QLineEdit" name="editLabel"/> |
|
31 |
</item> |
|
32 |
</layout> |
|
33 |
</item> |
|
34 |
<item> |
|
35 |
<layout class="QHBoxLayout" name="horizontalLayout"> |
|
36 |
<property name="rightMargin"> |
|
37 |
<number>0</number> |
|
38 |
</property> |
|
39 |
<item> |
|
40 |
<widget class="QLabel" name="label"> |
|
41 |
<property name="text"> |
|
25 | 42 |
<string>Filter</string> |
26 | 43 |
</property> |
27 | 44 |
</widget> |
... | ... | |
51 | 68 |
</item> |
52 | 69 |
</layout> |
53 | 70 |
</item> |
71 |
<item> |
|
72 |
<layout class="QHBoxLayout" name="horizontalLayout_3"> |
|
73 |
<item> |
|
74 |
<widget class="QLabel" name="label_4"> |
|
75 |
<property name="text"> |
|
76 |
<string>Description</string> |
|
77 |
</property> |
|
78 |
</widget> |
|
79 |
</item> |
|
80 |
<item> |
|
81 |
<widget class="QLineEdit" name="editDescription"/> |
|
82 |
</item> |
|
83 |
</layout> |
|
84 |
</item> |
|
54 | 85 |
<item> |
55 | 86 |
<widget class="QGroupBox" name="groupScale"> |
56 | 87 |
<property name="title"> |
/hometb/mk/sig/dev/r15004-patched/qgis//src/ui/qgsrulebasedrendererv2widget.ui 2011-01-11 00:05:28.209776453 +0100 | ||
---|---|---|
6 | 6 |
<rect> |
7 | 7 |
<x>0</x> |
8 | 8 |
<y>0</y> |
9 |
<width>460</width>
|
|
10 |
<height>221</height>
|
|
9 |
<width>554</width>
|
|
10 |
<height>256</height>
|
|
11 | 11 |
</rect> |
12 | 12 |
</property> |
13 | 13 |
<property name="windowTitle"> |
... | ... | |
17 | 17 |
<item row="0" column="0"> |
18 | 18 |
<widget class="QLabel" name="label"> |
19 | 19 |
<property name="text"> |
20 |
<string>Rules</string> |
|
20 |
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> |
|
21 |
<html><head><meta name="qrichtext" content="1" /><style type="text/css"> |
|
22 |
p, li { white-space: pre-wrap; } |
|
23 |
</style></head><body style=" font-family:'Arial'; font-size:12pt; font-weight:400; font-style:normal;"> |
|
24 |
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Rules</p> |
|
25 |
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-style:italic;">Note: Temporarily, for a given feature, every matched rule generates its own symbol if symbol levels are disabled;</span></p> |
|
26 |
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-style:italic;">otherwise only the first (</span><span style=" font-style:italic;">according to id</span><span style=" font-style:italic;">) matching rule is considered.</span></p> |
|
27 |
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-style:italic;">This will change soon. See </span><a href="http://trac.osgeo.org/qgis/ticket/3222#comment:11"><span style=" text-decoration: underline; color:#0057ae;">http://trac.osgeo.org/qgis/ticket/3222#comment:11</span></a><span style=" font-style:italic;">.</span></p></body></html></string> |
|
21 | 28 |
</property> |
22 | 29 |
</widget> |
23 | 30 |
</item> |
... | ... | |
26 | 33 |
<property name="rootIsDecorated"> |
27 | 34 |
<bool>false</bool> |
28 | 35 |
</property> |
29 |
<property name="headerHidden">
|
|
36 |
<property name="sortingEnabled">
|
|
30 | 37 |
<bool>true</bool> |
31 | 38 |
</property> |
39 |
<property name="headerHidden"> |
|
40 |
<bool>false</bool> |
|
41 |
</property> |
|
42 |
<column> |
|
43 |
<property name="text"> |
|
44 |
<string>Label</string> |
|
45 |
</property> |
|
46 |
</column> |
|
32 | 47 |
<column> |
33 | 48 |
<property name="text"> |
34 | 49 |
<string>Rule</string> |
35 | 50 |
</property> |
51 |
<property name="background"> |
|
52 |
<color> |
|
53 |
<red>200</red> |
|
54 |
<green>200</green> |
|
55 |
<blue>200</blue> |
|
56 |
</color> |
|
57 |
</property> |
|
58 |
</column> |
|
59 |
<column> |
|
60 |
<property name="text"> |
|
61 |
<string>Min. scale</string> |
|
62 |
</property> |
|
63 |
<property name="textAlignment"> |
|
64 |
<set>AlignHCenter|AlignVCenter|AlignCenter</set> |
|
65 |
</property> |
|
66 |
</column> |
|
67 |
<column> |
|
68 |
<property name="text"> |
|
69 |
<string>Max. scale</string> |
|
70 |
</property> |
|
71 |
<property name="textAlignment"> |
|
72 |
<set>AlignHCenter|AlignVCenter|AlignCenter</set> |
|
73 |
</property> |
|
74 |
<property name="background"> |
|
75 |
<color> |
|
76 |
<red>200</red> |
|
77 |
<green>200</green> |
|
78 |
<blue>200</blue> |
|
79 |
</color> |
|
80 |
</property> |
|
81 |
</column> |
|
82 |
<column> |
|
83 |
<property name="text"> |
|
84 |
<string>Id</string> |
|
85 |
</property> |
|
86 |
<property name="textAlignment"> |
|
87 |
<set>AlignHCenter|AlignVCenter|AlignCenter</set> |
|
88 |
</property> |
|
36 | 89 |
</column> |
37 | 90 |
</widget> |
38 | 91 |
</item> |