Skip to content

Commit a18b4a3

Browse files
committed
highlight identified feature using real feature shape
1 parent d59ab80 commit a18b4a3

15 files changed

+294
-62
lines changed

python/core/qgsfeaturestore.sip

+6
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ class QgsFeatureStore
2828
/** Set crs */
2929
void setCrs( const QgsCoordinateReferenceSystem& crs );
3030

31+
/** Add feature. Feature's fields will be set to pointer to the store fields.
32+
* @param feature
33+
* @note added in 2.1
34+
*/
35+
void addFeature ( const QgsFeature& feature );
36+
3137
/** Get features list reference */
3238
QgsFeatureList& features();
3339

python/core/qgsrectangle.sip

+4
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ class QgsRectangle
5858
QgsPoint center() const;
5959
//! Scale the rectangle around its center point
6060
void scale( double, const QgsPoint *c = 0 );
61+
void scale( double scaleFactor, double centerX, double centerY );
62+
/** Get rectangle enlarged by buffer.
63+
* @note added in 2.1 */
64+
QgsRectangle buffer( double width );
6165
//! Expand the rectangle to support zoom out scaling
6266
//! return the intersection with the given rectangle
6367
QgsRectangle intersect( const QgsRectangle *rect ) const;

python/core/symbology-ng/qgsfillsymbollayerv2.sip

+6
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ class QgsSimpleFillSymbolLayerV2 : QgsFillSymbolLayerV2
4040
QColor borderColor() const;
4141
void setBorderColor( QColor borderColor );
4242

43+
virtual QColor outlineColor() const;
44+
virtual void setOutlineColor( const QColor& color );
45+
46+
virtual QColor fillColor() const;
47+
virtual void setFillColor( const QColor& color );
48+
4349
Qt::PenStyle borderStyle() const;
4450
void setBorderStyle( Qt::PenStyle borderStyle );
4551

python/core/symbology-ng/qgsmarkersymbollayerv2.sip

+6
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ class QgsSimpleMarkerSymbolLayerV2 : QgsMarkerSymbolLayerV2
4242
double outlineWidth() const;
4343
void setOutlineWidth( double w );
4444

45+
virtual QColor outlineColor() const;
46+
virtual void setOutlineColor( const QColor& color );
47+
48+
virtual QColor fillColor() const;
49+
virtual void setFillColor( const QColor& color );
50+
4551
QgsSymbolV2::OutputUnit outlineWidthUnit() const;
4652
void setOutlineWidthUnit( QgsSymbolV2::OutputUnit u );
4753

python/core/symbology-ng/qgssymbollayerv2.sip

+4
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ class QgsSymbolLayerV2
6363
// not necessarily supported by all symbol layers...
6464
virtual void setColor( const QColor& color );
6565
virtual QColor color() const;
66+
virtual void setOutlineColor( const QColor& color );
67+
virtual QColor outlineColor() const;
68+
virtual void setFillColor( const QColor& color );
69+
virtual QColor fillColor() const;
6670

6771
virtual ~QgsSymbolLayerV2();
6872

src/app/qgsidentifyresultsdialog.cpp

+13-3
Original file line numberDiff line numberDiff line change
@@ -1172,14 +1172,24 @@ void QgsIdentifyResultsDialog::highlightFeature( QTreeWidgetItem *item )
11721172
if ( !featItem->feature().geometry() || featItem->feature().geometry()->wkbType() == QGis::WKBUnknown )
11731173
return;
11741174

1175-
QgsHighlight *h = new QgsHighlight( mCanvas, featItem->feature().geometry(), layer );
1176-
if ( h )
1175+
if ( vlayer )
11771176
{
1178-
h->setWidth( 2 );
1177+
QgsHighlight *h = new QgsHighlight( mCanvas, featItem->feature(), vlayer );
11791178
h->setColor( Qt::red );
11801179
h->show();
11811180
mHighlights.insert( featItem, h );
11821181
}
1182+
else
1183+
{
1184+
QgsHighlight *h = new QgsHighlight( mCanvas, featItem->feature().geometry(), layer );
1185+
if ( h )
1186+
{
1187+
h->setWidth( 2 );
1188+
h->setColor( Qt::red );
1189+
h->show();
1190+
mHighlights.insert( featItem, h );
1191+
}
1192+
}
11831193
}
11841194

11851195
void QgsIdentifyResultsDialog::zoomToFeature()

src/core/qgsfeaturestore.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,18 @@ QgsFeatureStore::~QgsFeatureStore( )
3737
{
3838
}
3939

40+
void QgsFeatureStore::setFields( const QgsFields & fields )
41+
{
42+
mFields = fields;
43+
foreach ( QgsFeature feature, mFeatures )
44+
{
45+
feature.setFields( &mFields );
46+
}
47+
}
48+
49+
void QgsFeatureStore::addFeature( const QgsFeature& feature )
50+
{
51+
QgsFeature f( feature );
52+
f.setFields( &mFields );
53+
mFeatures.append( f );
54+
}

src/core/qgsfeaturestore.h

+8-2
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,21 @@ class CORE_EXPORT QgsFeatureStore
4545
/** Get fields list */
4646
QgsFields& fields() { return mFields; }
4747

48-
/** Set fields */
49-
void setFields( const QgsFields & fields ) { mFields = fields; }
48+
/** Set fields. Resets feauters fields to pointer to new internal fields. */
49+
void setFields( const QgsFields & fields );
5050

5151
/** Get crs */
5252
QgsCoordinateReferenceSystem crs() const { return mCrs; }
5353

5454
/** Set crs */
5555
void setCrs( const QgsCoordinateReferenceSystem& crs ) { mCrs = crs; }
5656

57+
/** Add feature. Feature's fields will be set to pointer to the store fields.
58+
* @param feature
59+
* @note added in 2.1
60+
*/
61+
void addFeature( const QgsFeature& feature );
62+
5763
/** Get features list reference */
5864
QgsFeatureList& features() { return mFeatures; }
5965

src/core/qgsrectangle.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@ void QgsRectangle::scale( double scaleFactor, double centerX, double centerY )
122122
ymax = centerY + newHeight / 2.0;
123123
}
124124

125+
QgsRectangle QgsRectangle::buffer( double width )
126+
{
127+
return QgsRectangle( xmin - width, ymin - width, xmax + width, ymax + width );
128+
}
129+
125130
QgsRectangle QgsRectangle::intersect( const QgsRectangle * rect ) const
126131
{
127132
QgsRectangle intersection = QgsRectangle();

src/core/qgsrectangle.h

+3
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ class CORE_EXPORT QgsRectangle
8282
//! Scale the rectangle around its center point
8383
void scale( double scaleFactor, const QgsPoint *c = 0 );
8484
void scale( double scaleFactor, double centerX, double centerY );
85+
/** Get rectangle enlarged by buffer.
86+
* @note added in 2.1 */
87+
QgsRectangle buffer( double width );
8588
//! return the intersection with the given rectangle
8689
QgsRectangle intersect( const QgsRectangle *rect ) const;
8790
//! returns true when rectangle intersects with other rectangle

src/core/symbology-ng/qgsfillsymbollayerv2.h

+14
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,20 @@ class CORE_EXPORT QgsSimpleFillSymbolLayerV2 : public QgsFillSymbolLayerV2
6565
QColor borderColor() const { return mBorderColor; }
6666
void setBorderColor( QColor borderColor ) { mBorderColor = borderColor; }
6767

68+
/** Get outline color.
69+
* @note added in 2.1 */
70+
QColor outlineColor() const { return borderColor(); }
71+
/** Set outline color.
72+
* @note added in 2.1 */
73+
void setOutlineColor( const QColor& color ) { setBorderColor( color ); }
74+
75+
/** Get fill color.
76+
* @note added in 2.1 */
77+
QColor fillColor() const { return color(); }
78+
/** Set fill color.
79+
* @note added in 2.1 */
80+
void setFillColor( const QColor& color ) { setColor( color ); }
81+
6882
Qt::PenStyle borderStyle() const { return mBorderStyle; }
6983
void setBorderStyle( Qt::PenStyle borderStyle ) { mBorderStyle = borderStyle; }
7084

src/core/symbology-ng/qgsmarkersymbollayerv2.h

+16
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ class CORE_EXPORT QgsSimpleMarkerSymbolLayerV2 : public QgsMarkerSymbolLayerV2
4848

4949
// implemented from base classes
5050

51+
52+
5153
QString layerType() const;
5254

5355
void startRender( QgsSymbolV2RenderContext& context );
@@ -73,6 +75,20 @@ class CORE_EXPORT QgsSimpleMarkerSymbolLayerV2 : public QgsMarkerSymbolLayerV2
7375
Qt::PenStyle outlineStyle() const { return mOutlineStyle; }
7476
void setOutlineStyle( Qt::PenStyle outlineStyle ) { mOutlineStyle = outlineStyle; }
7577

78+
/** Get outline color.
79+
* @note added in 2.1 */
80+
QColor outlineColor() const { return borderColor(); }
81+
/** Set outline color.
82+
* @note added in 2.1 */
83+
void setOutlineColor( const QColor& color ) { setBorderColor( color ); }
84+
85+
/** Get fill color.
86+
* @note added in 2.1 */
87+
QColor fillColor() const { return color(); }
88+
/** Set fill color.
89+
* @note added in 2.1 */
90+
void setFillColor( const QColor& color ) { setColor( color ); }
91+
7692
double outlineWidth() const { return mOutlineWidth; }
7793
void setOutlineWidth( double w ) { mOutlineWidth = w; }
7894

src/core/symbology-ng/qgssymbollayerv2.h

+13-1
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,20 @@ class CORE_EXPORT QgsSymbolLayerV2
4747
public:
4848

4949
// not necessarily supported by all symbol layers...
50-
virtual void setColor( const QColor& color ) { mColor = color; }
5150
virtual QColor color() const { return mColor; }
51+
virtual void setColor( const QColor& color ) { mColor = color; }
52+
/** Set outline color. Supported by marker and fill layers.
53+
* @note added in 2.1 */
54+
virtual void setOutlineColor( const QColor& color ) { Q_UNUSED( color ); }
55+
/** Get outline color. Supported by marker and fill layers.
56+
* @note added in 2.1 */
57+
virtual QColor outlineColor() const { return QColor(); }
58+
/** Set fill color. Supported by marker and fill layers.
59+
* @note added in 2.1 */
60+
virtual void setFillColor( const QColor& color ) { Q_UNUSED( color ); }
61+
/** Get fill color. Supported by marker and fill layers.
62+
* @note added in 2.1 */
63+
virtual QColor fillColor() const { return QColor(); }
5264

5365
virtual ~QgsSymbolLayerV2() { removeDataDefinedProperties(); }
5466

0 commit comments

Comments
 (0)