Skip to content
Permalink
Browse files
Add border and fill colour options to bands. Different border for sel…
…ect tool
  • Loading branch information
NathanW2 committed Jul 1, 2014
1 parent 0c08029 commit 7aef54868c86b8828949b5f3eb12dcf787f0503e
@@ -32,6 +32,8 @@ QgsMapToolSelect::QgsMapToolSelect( QgsMapCanvas* canvas )
: QgsMapTool( canvas )
{
mCursor = Qt::ArrowCursor;
mFillColor = QColor( 254,178,76, 63 );
mBorderColour = QColor( 254, 58, 29, 100 );
}

void QgsMapToolSelect::canvasReleaseEvent( QMouseEvent * e )
@@ -42,9 +44,8 @@ void QgsMapToolSelect::canvasReleaseEvent( QMouseEvent * e )
return;
}
QgsRubberBand rubberBand( mCanvas, QGis::Polygon );
QColor color( 254,178,76 );
color.setAlpha( 63 );
rubberBand.setColor( color );
rubberBand.setFillColor( mFillColor );
rubberBand.setBorderColor( mBorderColour );
QRect selectRect( 0, 0, 0, 0 );
QgsMapToolSelectUtils::expandSelectRectangle( selectRect, vlayer, e->pos() );
QgsMapToolSelectUtils::setRubberBand( mCanvas, selectRect, &rubberBand );
@@ -31,6 +31,8 @@ class APP_EXPORT QgsMapToolSelect : public QgsMapTool
virtual void canvasReleaseEvent( QMouseEvent * e );

private:
QColor mFillColor;
QColor mBorderColour;
};

#endif
@@ -28,6 +28,8 @@ QgsMapToolSelectFreehand::QgsMapToolSelectFreehand( QgsMapCanvas* canvas )
{
mRubberBand = 0;
mCursor = Qt::ArrowCursor;
mFillColor = QColor( 254,178,76, 63 );
mBorderColour = QColor( 254, 58, 29, 100 );
}

QgsMapToolSelectFreehand::~QgsMapToolSelectFreehand()
@@ -44,9 +46,8 @@ void QgsMapToolSelectFreehand::canvasPressEvent( QMouseEvent * e )
if ( mRubberBand == NULL )
{
mRubberBand = new QgsRubberBand( mCanvas, QGis::Polygon );
QColor color( 254,178,76 );
color.setAlpha( 63 );
mRubberBand->setColor( color );
mRubberBand->setFillColor( mFillColor );
mRubberBand->setBorderColor( mBorderColour );
}
mRubberBand->addPoint( toMapCoordinates( e->pos() ) );
mDragging = true;
@@ -45,6 +45,9 @@ class APP_EXPORT QgsMapToolSelectFreehand : public QgsMapTool
QgsRubberBand* mRubberBand;

bool mDragging;

QColor mFillColor;
QColor mBorderColour;
};

#endif
@@ -28,6 +28,8 @@ QgsMapToolSelectPolygon::QgsMapToolSelectPolygon( QgsMapCanvas* canvas )
{
mRubberBand = 0;
mCursor = Qt::ArrowCursor;
mFillColor = QColor( 254,178,76, 63 );
mBorderColour = QColor( 254, 58, 29, 100 );
}

QgsMapToolSelectPolygon::~QgsMapToolSelectPolygon()
@@ -40,9 +42,8 @@ void QgsMapToolSelectPolygon::canvasPressEvent( QMouseEvent * e )
if ( mRubberBand == NULL )
{
mRubberBand = new QgsRubberBand( mCanvas, QGis::Polygon );
QColor color( 254,178,76 );
color.setAlpha( 63 );
mRubberBand->setColor( color );
mRubberBand->setFillColor( mFillColor );
mRubberBand->setBorderColor( mBorderColour );
}
if ( e->button() == Qt::LeftButton )
{
@@ -40,6 +40,10 @@ class APP_EXPORT QgsMapToolSelectPolygon : public QgsMapTool

//! used for storing all of the maps point for the polygon
QgsRubberBand* mRubberBand;

QColor mFillColor;

QColor mBorderColour;
};

#endif
@@ -35,6 +35,8 @@ QgsMapToolSelectRadius::QgsMapToolSelectRadius( QgsMapCanvas* canvas )
{
mRubberBand = 0;
mCursor = Qt::ArrowCursor;
mFillColor = QColor( 254,178,76, 63 );
mBorderColour = QColor( 254, 58, 29, 100 );
}

QgsMapToolSelectRadius::~QgsMapToolSelectRadius()
@@ -63,9 +65,8 @@ void QgsMapToolSelectRadius::canvasMoveEvent( QMouseEvent * e )
if ( mRubberBand == NULL )
{
mRubberBand = new QgsRubberBand( mCanvas, QGis::Polygon );
QColor color( 254,178,76 );
color.setAlpha( 63 );
mRubberBand->setColor( color );
mRubberBand->setFillColor( mFillColor );
mRubberBand->setBorderColor( mBorderColour );
}
mDragging = true;
}
@@ -85,9 +86,8 @@ void QgsMapToolSelectRadius::canvasReleaseEvent( QMouseEvent * e )
if ( mRubberBand == NULL )
{
mRubberBand = new QgsRubberBand( mCanvas, QGis::Polygon );
QColor color( 254,178,76 );
color.setAlpha( 63 );
mRubberBand->setColor( color );
mRubberBand->setFillColor( mFillColor );
mRubberBand->setBorderColor( mBorderColour );
}
mRadiusCenter = toMapCoordinates( e->pos() );
QgsPoint radiusEdge = toMapCoordinates( QPoint( e->pos().x() + 1, e->pos().y() + 1 ) );
@@ -54,6 +54,10 @@ class APP_EXPORT QgsMapToolSelectRadius : public QgsMapTool
QgsPoint mRadiusCenter;

bool mDragging;

QColor mFillColor;

QColor mBorderColour;
};

#endif
@@ -35,6 +35,8 @@ QgsMapToolSelectRectangle::QgsMapToolSelectRectangle( QgsMapCanvas* canvas )
QPixmap mySelectQPixmap = QPixmap(( const char ** ) select_cursor );
mCursor = QCursor( mySelectQPixmap, 1, 1 );
mRubberBand = 0;
mFillColor = QColor( 254,178,76, 63 );
mBorderColour = QColor( 254, 58, 29, 100 );
}


@@ -43,9 +45,8 @@ void QgsMapToolSelectRectangle::canvasPressEvent( QMouseEvent *e )
Q_UNUSED( e );
mSelectRect.setRect( 0, 0, 0, 0 );
mRubberBand = new QgsRubberBand( mCanvas, QGis::Polygon );
QColor color( 254,178,76 );
color.setAlpha( 63 );
mRubberBand->setColor( color );
mRubberBand->setFillColor( mFillColor );
mRubberBand->setBorderColor( mBorderColour );
}


@@ -52,6 +52,10 @@ class APP_EXPORT QgsMapToolSelectRectangle : public QgsMapTool
QRect mSelectRect;

QgsRubberBand* mRubberBand;

QColor mFillColor;

QColor mBorderColour;
};

#endif
@@ -73,11 +73,29 @@ QgsRubberBand::~QgsRubberBand()
*/
void QgsRubberBand::setColor( const QColor & color )
{
mPen.setColor( color );
setBorderColor( color );
setFillColor( color );
}

/*!
Set the fill color.
*/
void QgsRubberBand::setFillColor( const QColor & color )
{
QColor fillColor( color.red(), color.green(), color.blue(), color.alpha() );
mBrush.setColor( fillColor );
}

/*!
Set the outline
*/
void QgsRubberBand::setBorderColor( const QColor & color )
{
QColor penColor( color.red(), color.green(), color.blue(), color.alpha() );
mPen.setColor( penColor );
}


/*!
Set the outline width.
*/
@@ -85,6 +85,18 @@ class GUI_EXPORT QgsRubberBand: public QgsMapCanvasItem
*/
void setColor( const QColor & color );

/**
* Set the file color for the rubberband
* @param color The color used to render this rubberband
*/
void setFillColor( const QColor & color );

/**
* Set the border color for the rubberband
* @param color The color used to render this rubberband

This comment has been minimized.

Copy link
@timlinux

timlinux Oct 27, 2014

Member
*/
void setBorderColor( const QColor & color );

/**
* Set the width of the line. Outline width for polygon.
* @param width The width for any lines painted for this rubberband

This comment has been minimized.

Copy link
@timlinux

timlinux Oct 27, 2014

Member

0 comments on commit 7aef548

Please sign in to comment.