@@ -77,6 +77,17 @@ public:
77
77
78
78
virtual QString dump();
79
79
80
+ enum Capabilities
81
+ {
82
+ SymbolLevels = 1, // rendering with symbol levels (i.e. implements symbols(), symbolForFeature())
83
+ RotationField = 2, // rotate symbols by attribute value
84
+ MoreSymbolsPerFeature = 4 // may use more than one symbol to render a feature: symbolsForFeature() will return them
85
+ };
86
+
87
+ //! returns bitwise OR-ed capabilities of the renderer
88
+ //! \note added in 2.0
89
+ virtual int capabilities();
90
+
80
91
virtual QgsFeatureRendererV2* clone()=0 /Factory/;
81
92
82
93
virtual QgsSymbolV2List symbols()=0;
@@ -105,6 +116,18 @@ public:
105
116
//! @note added in 1.9
106
117
virtual void setRotationField( QString fieldName );
107
118
119
+ //! return whether the renderer will render a feature or not.
120
+ //! Must be called between startRender() and stopRender() calls.
121
+ //! Default implementation uses symbolForFeature().
122
+ //! @note added in 1.9
123
+ virtual bool willRenderFeature( QgsFeature& feat );
124
+
125
+ //! return list of symbols used for rendering the feature.
126
+ //! For renderers that do not support MoreSymbolsPerFeature it is more efficient
127
+ //! to use symbolForFeature()
128
+ //! @note added in 1.9
129
+ virtual QgsSymbolV2List symbolsForFeature( QgsFeature& feat );
130
+
108
131
protected:
109
132
QgsFeatureRendererV2(QString type);
110
133
@@ -154,6 +177,10 @@ public:
154
177
155
178
virtual QString dump();
156
179
180
+ //! returns bitwise OR-ed capabilities of the renderer
181
+ //! \note added in 2.0
182
+ virtual int capabilities();
183
+
157
184
virtual QgsFeatureRendererV2* clone() /Factory/;
158
185
159
186
virtual QgsSymbolV2List symbols();
@@ -221,6 +248,10 @@ public:
221
248
222
249
virtual QString dump();
223
250
251
+ //! returns bitwise OR-ed capabilities of the renderer
252
+ //! \note added in 2.0
253
+ virtual int capabilities();
254
+
224
255
virtual QgsFeatureRendererV2* clone() /Factory/;
225
256
226
257
virtual QgsSymbolV2List symbols();
@@ -320,6 +351,10 @@ public:
320
351
321
352
virtual QString dump();
322
353
354
+ //! returns bitwise OR-ed capabilities of the renderer
355
+ //! \note added in 2.0
356
+ virtual int capabilities();
357
+
323
358
virtual QgsFeatureRendererV2* clone() /Factory/;
324
359
325
360
virtual QgsSymbolV2List symbols();
@@ -410,27 +445,76 @@ class QgsRuleBasedRendererV2 : QgsFeatureRendererV2
410
445
class Rule
411
446
{
412
447
public:
413
- //! Constructor takes ownership of the symbol
414
- Rule( QgsSymbolV2* symbol /Transfer/, int scaleMinDenom = 0, int scaleMaxDenom = 0, QString filterExp = QString() );
415
- //Rule( const QgsRuleBasedRendererV2::Rule& other );
448
+
449
+ Rule( QgsSymbolV2* symbol /Transfer/, int scaleMinDenom = 0, int scaleMaxDenom = 0, QString filterExp = QString(),
450
+ QString label = QString(), QString description = QString() );
416
451
~Rule();
417
- QString dump() const;
418
- //QStringList needsFields() const;
452
+ QString dump( int offset = 0 ) const;
453
+ QSet<QString> usedAttributes();
454
+ QgsSymbolV2List symbols();
455
+ // TODO QgsLegendSymbolList legendSymbolItems();
419
456
bool isFilterOK( QgsFeature& f ) const;
420
457
bool isScaleOK( double scale ) const;
421
458
422
459
QgsSymbolV2* symbol();
460
+ QString label() const;
423
461
bool dependsOnScale() const;
424
462
int scaleMinDenom() const;
425
463
int scaleMaxDenom() const;
426
- QString filterExpression() const;
427
464
QgsExpression* filter() const;
465
+ QString filterExpression() const;
466
+ QString description() const;
428
467
468
+ //! set a new symbol (or NULL). Deletes old symbol.
469
+ void setSymbol( QgsSymbolV2* sym /Transfer/ );
470
+ void setLabel( QString label );
429
471
void setScaleMinDenom( int scaleMinDenom );
430
472
void setScaleMaxDenom( int scaleMaxDenom );
431
473
void setFilterExpression( QString filterExp );
474
+ void setDescription( QString description );
475
+
476
+ //! clone this rule, return new instance
477
+ QgsRuleBasedRendererV2::Rule* clone() const /Factory/;
478
+
479
+ QDomElement save( QDomDocument& doc, QgsSymbolV2Map& symbolMap );
480
+
481
+ //! prepare the rule for rendering and its children (build active children array)
482
+ bool startRender( QgsRenderContext& context, const QgsVectorLayer *vlayer );
483
+ //! get all used z-levels from this rule and children
484
+ QSet<int> collectZLevels();
485
+ //! assign normalized z-levels [0..N-1] for this rule's symbol for quick access during rendering
486
+ // TODO void setNormZLevels( const QMap<int, int>& zLevelsToNormLevels );
487
+
488
+ // TODO bool renderFeature( FeatureToRender& featToRender, QgsRenderContext& context, RenderQueue& renderQueue );
489
+
490
+ //! only tell whether a feature will be rendered without actually rendering it
491
+ //! @note added in 1.9
492
+ bool willRenderFeature( QgsFeature& feat );
493
+
494
+ //! tell which symbols will be used to render the feature
495
+ //! @note added in 1.9
496
+ QgsSymbolV2List symbolsForFeature( QgsFeature& feat );
497
+
498
+ void stopRender( QgsRenderContext& context );
499
+
500
+ static QgsRuleBasedRendererV2::Rule* create( QDomElement& ruleElem, QgsSymbolV2Map& symbolMap ) /Factory/;
501
+
502
+ QList<QgsRuleBasedRendererV2::Rule*>& children();
503
+ QgsRuleBasedRendererV2::Rule* parent();
504
+
505
+ //! add child rule, take ownership, sets this as parent
506
+ void appendChild( QgsRuleBasedRendererV2::Rule* rule /Transfer/ );
507
+ //! add child rule, take ownership, sets this as parent
508
+ void insertChild( int i, QgsRuleBasedRendererV2::Rule* rule /Transfer/ );
509
+ //! delete child rule
510
+ void removeChild( QgsRuleBasedRendererV2::Rule* rule );
511
+ //! delete child rule
512
+ void removeChildAt( int i );
513
+ //! take child rule out, set parent as null
514
+ void takeChild( QgsRuleBasedRendererV2::Rule* rule );
515
+ //! take child rule out, set parent as null
516
+ QgsRuleBasedRendererV2::Rule* takeChildAt( int i );
432
517
433
- //Rule& operator=( const Rule& other );
434
518
};
435
519
436
520
/////
@@ -453,6 +537,12 @@ class QgsRuleBasedRendererV2 : QgsFeatureRendererV2
453
537
454
538
virtual QList<QString> usedAttributes();
455
539
540
+ virtual QString dump();
541
+
542
+ //! returns bitwise OR-ed capabilities of the renderer
543
+ //! \note added in 2.0
544
+ virtual int capabilities();
545
+
456
546
virtual QgsFeatureRendererV2* clone() /Factory/;
457
547
458
548
virtual QgsSymbolV2List symbols();
@@ -463,6 +553,17 @@ class QgsRuleBasedRendererV2 : QgsFeatureRendererV2
463
553
//! return a list of symbology items for the legend
464
554
virtual QgsLegendSymbologyList legendSymbologyItems( QSize iconSize );
465
555
556
+ //! return whether the renderer will render a feature or not.
557
+ //! Must be called between startRender() and stopRender() calls.
558
+ //! @note added in 1.9
559
+ virtual bool willRenderFeature( QgsFeature& feat );
560
+
561
+ //! return list of symbols used for rendering the feature.
562
+ //! For renderers that do not support MoreSymbolsPerFeature it is more efficient
563
+ //! to use symbolForFeature()
564
+ //! @note added in 1.9
565
+ virtual QgsSymbolV2List symbolsForFeature( QgsFeature& feat );
566
+
466
567
/////
467
568
468
569
0 commit comments