Skip to content

Commit

Permalink
Use a clearer marker for main canvas position in view windows
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Mar 21, 2017
1 parent f669933 commit b54fe1e
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 17 deletions.
13 changes: 7 additions & 6 deletions python/gui/qgsvertexmarker.sip
Expand Up @@ -17,23 +17,24 @@ class QgsVertexMarker : QgsMapCanvasItem
ICON_CIRCLE
};

QgsVertexMarker( QgsMapCanvas* mapCanvas /TransferThis/ );
QgsVertexMarker( QgsMapCanvas *mapCanvas /TransferThis/ );

void setCenter( const QgsPoint& point );
void setCenter( const QgsPoint &point );

void setIconType( int iconType );

void setIconSize( int iconSize );

void setColor( const QColor& color );
void setColor( const QColor &color );
QColor color() const;
void setFillColor( const QColor &color );
QColor fillColor() const;

void setPenWidth( int width );

void paint( QPainter* p );
void paint( QPainter *p );

QRectF boundingRect() const;

virtual void updatePosition();

};

1 change: 1 addition & 0 deletions src/app/qgsmapcanvasdockwidget.cpp
Expand Up @@ -48,6 +48,7 @@ QgsMapCanvasDockWidget::QgsMapCanvasDockWidget( const QString &name, QWidget *pa
mXyMarker->setIconType( QgsVertexMarker::ICON_CIRCLE );
mXyMarker->setIconSize( 6 );
mXyMarker->setColor( QColor( 30, 30, 30, 225 ) );
mXyMarker->setFillColor( QColor( 255, 255, 255, 225 ) );
mPanTool = new QgsMapToolPan( mMapCanvas );
mMapCanvas->setMapTool( mPanTool );

Expand Down
16 changes: 10 additions & 6 deletions src/gui/qgsvertexmarker.cpp
Expand Up @@ -20,12 +20,7 @@

QgsVertexMarker::QgsVertexMarker( QgsMapCanvas *mapCanvas )
: QgsMapCanvasItem( mapCanvas )
{
mIconSize = 10;
mIconType = ICON_X;
mColor = QColor( 255, 0, 0 );
mPenWidth = 1;
}
{}

void QgsVertexMarker::setIconType( int type )
{
Expand All @@ -47,6 +42,13 @@ void QgsVertexMarker::setCenter( const QgsPoint &point )
void QgsVertexMarker::setColor( const QColor &color )
{
mColor = color;
update();
}

void QgsVertexMarker::setFillColor( const QColor &color )
{
mFillColor = color;
update();
}

void QgsVertexMarker::setPenWidth( int width )
Expand All @@ -61,6 +63,8 @@ void QgsVertexMarker::paint( QPainter *p )
QPen pen( mColor );
pen.setWidth( mPenWidth );
p->setPen( pen );
QBrush brush( mFillColor );
p->setBrush( brush );

switch ( mIconType )
{
Expand Down
45 changes: 40 additions & 5 deletions src/gui/qgsvertexmarker.h
Expand Up @@ -47,8 +47,39 @@ class GUI_EXPORT QgsVertexMarker : public QgsMapCanvasItem

void setIconSize( int iconSize );

/**
* Sets the stroke \a color for the marker.
* @see color()
* @see setFillColor()
*/
void setColor( const QColor &color );

/**
* Returns the stroke color for the marker.
* @see setColor()
* @see fillColor()
* @note added in QGIS 3.0
*/
QColor color() const { return mColor; }

/**
* Sets the fill \a color for the marker. This setting only
* applies to some icon types.
* @note added in QGIS 3.0
* @see fillColor()
* @see setColor()
*/
void setFillColor( const QColor &color );

/**
* Returns the fill \a color for the marker. This setting only
* applies to some icon types.
* @note added in QGIS 3.0
* @see setFillColor()
* @see color()
*/
QColor fillColor() const { return mFillColor; }

void setPenWidth( int width );

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

virtual void updatePosition() override;

protected:
private:

//! icon to be shown
int mIconType;
int mIconType = ICON_X;

//! size
int mIconSize;
int mIconSize = 10;

//! coordinates of the point in the center
QgsPoint mCenter;

//! color of the marker
QColor mColor;
QColor mColor = QColor( 255, 0, 0 );

//! pen width
int mPenWidth;
int mPenWidth = 1;

//! Fill color
QColor mFillColor = QColor( 0, 0, 0, 0 );

};

#endif

0 comments on commit b54fe1e

Please sign in to comment.