Skip to content

Commit

Permalink
Replace manual square by creation of a ICON_FULL_BOX icon type for
Browse files Browse the repository at this point in the history
rubber band
  • Loading branch information
leyan authored and 3nids committed Oct 29, 2013
1 parent a7409b7 commit 4d6be55
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
17 changes: 4 additions & 13 deletions src/app/nodetool/qgsmaptoolnodetool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -720,23 +720,14 @@ void QgsMapToolNodeTool::keyReleaseEvent( QKeyEvent* e )

QgsRubberBand* QgsMapToolNodeTool::createRubberBandMarker( QgsPoint center, QgsVectorLayer* vlayer )
{

// create rubberband marker for moving points
QgsRubberBand* marker = new QgsRubberBand( mCanvas, QGis::Polygon );
QgsRubberBand* marker = new QgsRubberBand( mCanvas, QGis::Point );
marker->setColor( Qt::red );
marker->setWidth( 2 );
double movement = 4;
double s = QgsTolerance::toleranceInMapUnits( movement, vlayer, mCanvas->mapRenderer(), QgsTolerance::Pixels );
marker->setIcon( QgsRubberBand::ICON_FULL_BOX );
marker->setIconSize( 8 );
QgsPoint pom = toMapCoordinates( vlayer, center );
pom.setX( pom.x() - s );
pom.setY( pom.y() - s );
marker->addPoint( pom );
pom.setX( pom.x() + 2*s );
marker->addPoint( pom );
pom.setY( pom.y() + 2*s );
marker->addPoint( pom );
pom.setX( pom.x() - 2*s );
marker->addPoint( pom );
pom.setY( pom.y() - 2*s );
marker->addPoint( pom );
return marker;
}
4 changes: 4 additions & 0 deletions src/gui/qgsrubberband.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,10 @@ void QgsRubberBand::paint( QPainter* p )
p->drawLine( QLineF( x - s, y + s, x - s, y - s ) );
break;

case ICON_FULL_BOX:
p->drawRect( x - s, y - s, mIconSize, mIconSize );
break;

case ICON_CIRCLE:
p->drawEllipse( x - s, y - s, mIconSize, mIconSize );
break;
Expand Down
4 changes: 4 additions & 0 deletions src/gui/qgsrubberband.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ class GUI_EXPORT QgsRubberBand: public QgsMapCanvasItem
* A box is used to highlight points (□)
*/
ICON_BOX,
/**
* A full box is used to highlight points (■)
*/
ICON_FULL_BOX,
/**
* A circle is used to highlight points (○)
*/
Expand Down

0 comments on commit 4d6be55

Please sign in to comment.