mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-06 00:03:16 -05:00
Use a clearer marker for main canvas position in view windows
This commit is contained in:
parent
f6699332a3
commit
b54fe1e3a5
@ -17,23 +17,24 @@ class QgsVertexMarker : QgsMapCanvasItem
|
|||||||
ICON_CIRCLE
|
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 setIconType( int iconType );
|
||||||
|
|
||||||
void setIconSize( int iconSize );
|
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 setPenWidth( int width );
|
||||||
|
|
||||||
void paint( QPainter* p );
|
void paint( QPainter *p );
|
||||||
|
|
||||||
QRectF boundingRect() const;
|
QRectF boundingRect() const;
|
||||||
|
|
||||||
virtual void updatePosition();
|
virtual void updatePosition();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -48,6 +48,7 @@ QgsMapCanvasDockWidget::QgsMapCanvasDockWidget( const QString &name, QWidget *pa
|
|||||||
mXyMarker->setIconType( QgsVertexMarker::ICON_CIRCLE );
|
mXyMarker->setIconType( QgsVertexMarker::ICON_CIRCLE );
|
||||||
mXyMarker->setIconSize( 6 );
|
mXyMarker->setIconSize( 6 );
|
||||||
mXyMarker->setColor( QColor( 30, 30, 30, 225 ) );
|
mXyMarker->setColor( QColor( 30, 30, 30, 225 ) );
|
||||||
|
mXyMarker->setFillColor( QColor( 255, 255, 255, 225 ) );
|
||||||
mPanTool = new QgsMapToolPan( mMapCanvas );
|
mPanTool = new QgsMapToolPan( mMapCanvas );
|
||||||
mMapCanvas->setMapTool( mPanTool );
|
mMapCanvas->setMapTool( mPanTool );
|
||||||
|
|
||||||
|
|||||||
@ -20,12 +20,7 @@
|
|||||||
|
|
||||||
QgsVertexMarker::QgsVertexMarker( QgsMapCanvas *mapCanvas )
|
QgsVertexMarker::QgsVertexMarker( QgsMapCanvas *mapCanvas )
|
||||||
: QgsMapCanvasItem( mapCanvas )
|
: QgsMapCanvasItem( mapCanvas )
|
||||||
{
|
{}
|
||||||
mIconSize = 10;
|
|
||||||
mIconType = ICON_X;
|
|
||||||
mColor = QColor( 255, 0, 0 );
|
|
||||||
mPenWidth = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void QgsVertexMarker::setIconType( int type )
|
void QgsVertexMarker::setIconType( int type )
|
||||||
{
|
{
|
||||||
@ -47,6 +42,13 @@ void QgsVertexMarker::setCenter( const QgsPoint &point )
|
|||||||
void QgsVertexMarker::setColor( const QColor &color )
|
void QgsVertexMarker::setColor( const QColor &color )
|
||||||
{
|
{
|
||||||
mColor = color;
|
mColor = color;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QgsVertexMarker::setFillColor( const QColor &color )
|
||||||
|
{
|
||||||
|
mFillColor = color;
|
||||||
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsVertexMarker::setPenWidth( int width )
|
void QgsVertexMarker::setPenWidth( int width )
|
||||||
@ -61,6 +63,8 @@ void QgsVertexMarker::paint( QPainter *p )
|
|||||||
QPen pen( mColor );
|
QPen pen( mColor );
|
||||||
pen.setWidth( mPenWidth );
|
pen.setWidth( mPenWidth );
|
||||||
p->setPen( pen );
|
p->setPen( pen );
|
||||||
|
QBrush brush( mFillColor );
|
||||||
|
p->setBrush( brush );
|
||||||
|
|
||||||
switch ( mIconType )
|
switch ( mIconType )
|
||||||
{
|
{
|
||||||
|
|||||||
@ -47,8 +47,39 @@ class GUI_EXPORT QgsVertexMarker : public QgsMapCanvasItem
|
|||||||
|
|
||||||
void setIconSize( int iconSize );
|
void setIconSize( int iconSize );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the stroke \a color for the marker.
|
||||||
|
* @see color()
|
||||||
|
* @see setFillColor()
|
||||||
|
*/
|
||||||
void setColor( const QColor &color );
|
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 setPenWidth( int width );
|
||||||
|
|
||||||
void paint( QPainter *p ) override;
|
void paint( QPainter *p ) override;
|
||||||
@ -57,22 +88,26 @@ class GUI_EXPORT QgsVertexMarker : public QgsMapCanvasItem
|
|||||||
|
|
||||||
virtual void updatePosition() override;
|
virtual void updatePosition() override;
|
||||||
|
|
||||||
protected:
|
private:
|
||||||
|
|
||||||
//! icon to be shown
|
//! icon to be shown
|
||||||
int mIconType;
|
int mIconType = ICON_X;
|
||||||
|
|
||||||
//! size
|
//! size
|
||||||
int mIconSize;
|
int mIconSize = 10;
|
||||||
|
|
||||||
//! coordinates of the point in the center
|
//! coordinates of the point in the center
|
||||||
QgsPoint mCenter;
|
QgsPoint mCenter;
|
||||||
|
|
||||||
//! color of the marker
|
//! color of the marker
|
||||||
QColor mColor;
|
QColor mColor = QColor( 255, 0, 0 );
|
||||||
|
|
||||||
//! pen width
|
//! pen width
|
||||||
int mPenWidth;
|
int mPenWidth = 1;
|
||||||
|
|
||||||
|
//! Fill color
|
||||||
|
QColor mFillColor = QColor( 0, 0, 0, 0 );
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user