@@ -86,6 +86,7 @@ QgsGeorefPluginGui::QgsGeorefPluginGui( QgisInterface* theQgisInterface, QWidget
86
86
, mLayer( 0 )
87
87
, mAgainAddRaster ( false )
88
88
, mMovingPoint( 0 )
89
+ , mMovingPointQgis ( 0 )
89
90
, mMapCoordsDialog( 0 )
90
91
, mUseZeroForTrans( false )
91
92
, mLoadInQgis( false )
@@ -153,6 +154,7 @@ QgsGeorefPluginGui::~QgsGeorefPluginGui()
153
154
delete mToolAddPoint ;
154
155
delete mToolDeletePoint ;
155
156
delete mToolMovePoint ;
157
+ delete mToolMovePointQgis ;
156
158
157
159
}
158
160
@@ -382,6 +384,7 @@ void QgsGeorefPluginGui::setDeletePointTool()
382
384
void QgsGeorefPluginGui::setMovePointTool ()
383
385
{
384
386
mCanvas ->setMapTool ( mToolMovePoint );
387
+ mIface ->mapCanvas ()->setMapTool ( mToolMovePointQgis );
385
388
}
386
389
387
390
// View slots
@@ -478,7 +481,7 @@ void QgsGeorefPluginGui::deleteDataPoint( const QPoint &coords )
478
481
for ( QgsGCPList::iterator it = mPoints .begin (); it != mPoints .end (); ++it )
479
482
{
480
483
QgsGeorefDataPoint* pt = *it;
481
- if ( /* pt->pixelCoords() == coords ||*/ pt->contains ( coords ) ) // first operand for removing from GCP table
484
+ if ( /* pt->pixelCoords() == coords ||*/ pt->contains ( coords, true ) ) // first operand for removing from GCP table
482
485
{
483
486
int row = mPoints .indexOf ( *it );
484
487
mGCPListWidget ->model ()->removeRow ( row );
@@ -507,28 +510,54 @@ void QgsGeorefPluginGui::deleteDataPoint( int index )
507
510
508
511
void QgsGeorefPluginGui::selectPoint ( const QPoint &p )
509
512
{
513
+ // Get Map Sender
514
+ QObject *tool = sender ();
515
+ if ( tool == 0 )
516
+ {
517
+ return ;
518
+ }
519
+ bool isMapPlugin = ( (void *)tool == (void *)mToolMovePoint ) ? true : false ;
520
+
510
521
for ( QgsGCPList::iterator it = mPoints .begin (); it != mPoints .end (); ++it )
511
522
{
512
- if (( *it )->contains ( p ) )
523
+ if ( ( *it )->contains ( p, isMapPlugin ) )
513
524
{
514
- mMovingPoint = *it;
525
+ isMapPlugin ? mMovingPoint = *it : mMovingPointQgis = *it;
515
526
break ;
516
527
}
517
528
}
529
+
518
530
}
519
531
520
532
void QgsGeorefPluginGui::movePoint ( const QPoint &p )
521
533
{
522
- if ( mMovingPoint )
534
+ // Get Map Sender
535
+ QObject *tool = sender ();
536
+ if ( tool == 0 )
537
+ {
538
+ return ;
539
+ }
540
+ bool isMapPlugin = ( (void *)tool == (void *)mToolMovePoint ) ? true : false ;
541
+ QgsGeorefDataPoint *mvPoint = (isMapPlugin ? mMovingPoint : mMovingPointQgis );
542
+
543
+ if ( mvPoint )
523
544
{
524
- mMovingPoint ->moveTo ( p );
545
+ mvPoint ->moveTo ( p, isMapPlugin );
525
546
mGCPListWidget ->updateGCPList ();
526
547
}
548
+
527
549
}
528
550
529
551
void QgsGeorefPluginGui::releasePoint ( const QPoint &p )
530
552
{
531
- mMovingPoint = 0 ;
553
+ // Get Map Sender
554
+ QObject *tool = sender ();
555
+ if ( tool == 0 )
556
+ {
557
+ return ;
558
+ }
559
+ bool isMapPlugin = ( (void *)tool == (void *)mToolMovePoint ) ? true : false ;
560
+ isMapPlugin ? mMovingPoint = 0 : mMovingPointQgis = 0 ;
532
561
}
533
562
534
563
void QgsGeorefPluginGui::showCoordDialog ( const QgsPoint &pixelCoords )
@@ -894,6 +923,16 @@ void QgsGeorefPluginGui::createMapCanvas()
894
923
connect ( mToolMovePoint , SIGNAL ( pointReleased ( const QPoint & ) ),
895
924
this , SLOT ( releasePoint ( const QPoint & ) ) );
896
925
926
+ // Point in Qgis Map
927
+ mToolMovePointQgis = new QgsGeorefToolMovePoint ( mIface ->mapCanvas () );
928
+ mToolMovePointQgis ->setAction ( mActionMoveGCPPoint );
929
+ connect ( mToolMovePointQgis , SIGNAL ( pointPressed ( const QPoint & ) ),
930
+ this , SLOT ( selectPoint ( const QPoint & ) ) );
931
+ connect ( mToolMovePointQgis , SIGNAL ( pointMoved ( const QPoint & ) ),
932
+ this , SLOT ( movePoint ( const QPoint & ) ) );
933
+ connect ( mToolMovePointQgis , SIGNAL ( pointReleased ( const QPoint & ) ),
934
+ this , SLOT ( releasePoint ( const QPoint & ) ) );
935
+
897
936
QSettings s;
898
937
int action = s.value ( " /qgis/wheel_action" , 0 ).toInt ();
899
938
double zoomFactor = s.value ( " /qgis/zoom_factor" , 2 ).toDouble ();
0 commit comments