Skip to content

Commit b54fe1e

Browse files
committed
Use a clearer marker for main canvas position in view windows
1 parent f669933 commit b54fe1e

File tree

4 files changed

+58
-17
lines changed

4 files changed

+58
-17
lines changed

python/gui/qgsvertexmarker.sip

+7-6
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,24 @@ class QgsVertexMarker : QgsMapCanvasItem
1717
ICON_CIRCLE
1818
};
1919

20-
QgsVertexMarker( QgsMapCanvas* mapCanvas /TransferThis/ );
20+
QgsVertexMarker( QgsMapCanvas *mapCanvas /TransferThis/ );
2121

22-
void setCenter( const QgsPoint& point );
22+
void setCenter( const QgsPoint &point );
2323

2424
void setIconType( int iconType );
2525

2626
void setIconSize( int iconSize );
27-
28-
void setColor( const QColor& color );
27+
void setColor( const QColor &color );
28+
QColor color() const;
29+
void setFillColor( const QColor &color );
30+
QColor fillColor() const;
2931

3032
void setPenWidth( int width );
3133

32-
void paint( QPainter* p );
34+
void paint( QPainter *p );
3335

3436
QRectF boundingRect() const;
3537

3638
virtual void updatePosition();
37-
3839
};
3940

src/app/qgsmapcanvasdockwidget.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ QgsMapCanvasDockWidget::QgsMapCanvasDockWidget( const QString &name, QWidget *pa
4848
mXyMarker->setIconType( QgsVertexMarker::ICON_CIRCLE );
4949
mXyMarker->setIconSize( 6 );
5050
mXyMarker->setColor( QColor( 30, 30, 30, 225 ) );
51+
mXyMarker->setFillColor( QColor( 255, 255, 255, 225 ) );
5152
mPanTool = new QgsMapToolPan( mMapCanvas );
5253
mMapCanvas->setMapTool( mPanTool );
5354

src/gui/qgsvertexmarker.cpp

+10-6
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,7 @@
2020

2121
QgsVertexMarker::QgsVertexMarker( QgsMapCanvas *mapCanvas )
2222
: QgsMapCanvasItem( mapCanvas )
23-
{
24-
mIconSize = 10;
25-
mIconType = ICON_X;
26-
mColor = QColor( 255, 0, 0 );
27-
mPenWidth = 1;
28-
}
23+
{}
2924

3025
void QgsVertexMarker::setIconType( int type )
3126
{
@@ -47,6 +42,13 @@ void QgsVertexMarker::setCenter( const QgsPoint &point )
4742
void QgsVertexMarker::setColor( const QColor &color )
4843
{
4944
mColor = color;
45+
update();
46+
}
47+
48+
void QgsVertexMarker::setFillColor( const QColor &color )
49+
{
50+
mFillColor = color;
51+
update();
5052
}
5153

5254
void QgsVertexMarker::setPenWidth( int width )
@@ -61,6 +63,8 @@ void QgsVertexMarker::paint( QPainter *p )
6163
QPen pen( mColor );
6264
pen.setWidth( mPenWidth );
6365
p->setPen( pen );
66+
QBrush brush( mFillColor );
67+
p->setBrush( brush );
6468

6569
switch ( mIconType )
6670
{

src/gui/qgsvertexmarker.h

+40-5
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,39 @@ class GUI_EXPORT QgsVertexMarker : public QgsMapCanvasItem
4747

4848
void setIconSize( int iconSize );
4949

50+
/**
51+
* Sets the stroke \a color for the marker.
52+
* @see color()
53+
* @see setFillColor()
54+
*/
5055
void setColor( const QColor &color );
5156

57+
/**
58+
* Returns the stroke color for the marker.
59+
* @see setColor()
60+
* @see fillColor()
61+
* @note added in QGIS 3.0
62+
*/
63+
QColor color() const { return mColor; }
64+
65+
/**
66+
* Sets the fill \a color for the marker. This setting only
67+
* applies to some icon types.
68+
* @note added in QGIS 3.0
69+
* @see fillColor()
70+
* @see setColor()
71+
*/
72+
void setFillColor( const QColor &color );
73+
74+
/**
75+
* Returns the fill \a color for the marker. This setting only
76+
* applies to some icon types.
77+
* @note added in QGIS 3.0
78+
* @see setFillColor()
79+
* @see color()
80+
*/
81+
QColor fillColor() const { return mFillColor; }
82+
5283
void setPenWidth( int width );
5384

5485
void paint( QPainter *p ) override;
@@ -57,22 +88,26 @@ class GUI_EXPORT QgsVertexMarker : public QgsMapCanvasItem
5788

5889
virtual void updatePosition() override;
5990

60-
protected:
91+
private:
6192

6293
//! icon to be shown
63-
int mIconType;
94+
int mIconType = ICON_X;
6495

6596
//! size
66-
int mIconSize;
97+
int mIconSize = 10;
6798

6899
//! coordinates of the point in the center
69100
QgsPoint mCenter;
70101

71102
//! color of the marker
72-
QColor mColor;
103+
QColor mColor = QColor( 255, 0, 0 );
73104

74105
//! pen width
75-
int mPenWidth;
106+
int mPenWidth = 1;
107+
108+
//! Fill color
109+
QColor mFillColor = QColor( 0, 0, 0, 0 );
110+
76111
};
77112

78113
#endif

0 commit comments

Comments
 (0)