@@ -31,12 +31,12 @@ CoordinateCaptureMapTool::CoordinateCaptureMapTool(QgsMapCanvas* thepCanvas)
31
31
: QgsMapTool(thepCanvas)
32
32
{
33
33
// set cursor
34
- QPixmap myIdentifyCursor = QPixmap ((const char **) capture_point_cursor);
35
- mCursor = QCursor (myIdentifyCursor, 1 , 1 );
34
+ QPixmap myCursor = QPixmap ((const char **) capture_point_cursor);
35
+ mCursor = QCursor (myCursor, 8 , 8 ); // 8,8 is the point in the cursor where clicks register
36
36
mpMapCanvas = thepCanvas;
37
- mpRubberBand = new QgsRubberBand (mpMapCanvas,false ); // false - not a polygon
37
+ mpRubberBand = new QgsRubberBand (mpMapCanvas,true ); // true - its a polygon
38
38
mpRubberBand->setColor (Qt::red);
39
- mpRubberBand->setWidth (3 );
39
+ mpRubberBand->setWidth (1 );
40
40
}
41
41
42
42
CoordinateCaptureMapTool::~CoordinateCaptureMapTool ()
@@ -60,14 +60,27 @@ void CoordinateCaptureMapTool::canvasReleaseEvent(QMouseEvent * thepEvent)
60
60
return ;
61
61
}
62
62
63
- QgsPoint myPoint =
63
+ QgsPoint myOriginalPoint =
64
64
mCanvas ->getCoordinateTransform ()->toMapCoordinates (thepEvent->x (), thepEvent->y ());
65
- emit pointCaptured (myPoint);
66
- mpRubberBand->reset (false );
65
+ emit pointCaptured (myOriginalPoint);
66
+
67
+ // make a little box for display
68
+
69
+ QgsPoint myPoint1 =
70
+ mCanvas ->getCoordinateTransform ()->toMapCoordinates (thepEvent->x () - 1 , thepEvent->y ()-1 );
71
+ QgsPoint myPoint2 =
72
+ mCanvas ->getCoordinateTransform ()->toMapCoordinates (thepEvent->x () + 1 , thepEvent->y ()-1 );
73
+ QgsPoint myPoint3 =
74
+ mCanvas ->getCoordinateTransform ()->toMapCoordinates (thepEvent->x () + 1 , thepEvent->y () + 1 );
75
+ QgsPoint myPoint4 =
76
+ mCanvas ->getCoordinateTransform ()->toMapCoordinates (thepEvent->x () - 1 , thepEvent->y () + 1 );
77
+
78
+ mpRubberBand->reset (true );
67
79
// convert screen coordinates to map coordinates
68
- mpRubberBand->addPoint (myPoint,false ); // true - update canvas
69
- mpRubberBand->addPoint (myPoint,false ); // true - update canvas
70
- mpRubberBand->addPoint (myPoint,false ); // true - update canvas
80
+ mpRubberBand->addPoint (myPoint1,false ); // true - update canvas
81
+ mpRubberBand->addPoint (myPoint2,false ); // true - update canvas
82
+ mpRubberBand->addPoint (myPoint3,false ); // true - update canvas
83
+ mpRubberBand->addPoint (myPoint4,true ); // true - update canvas
71
84
mpRubberBand->show ();
72
85
}
73
86
0 commit comments