@@ -327,7 +327,21 @@ static void setTitleBarText_( QWidget & qgisApp )
327
327
328
328
329
329
QgisApp::~QgisApp ()
330
- {}
330
+ {
331
+ delete mMapTools .mZoomIn ;
332
+ delete mMapTools .mZoomOut ;
333
+ delete mMapTools .mPan ;
334
+ delete mMapTools .mIdentify ;
335
+ delete mMapTools .mMeasureDist ;
336
+ delete mMapTools .mMeasureArea ;
337
+ delete mMapTools .mCapturePoint ;
338
+ delete mMapTools .mCaptureLine ;
339
+ delete mMapTools .mCapturePolygon ;
340
+ delete mMapTools .mSelect ;
341
+ delete mMapTools .mVertexAdd ;
342
+ delete mMapTools .mVertexMove ;
343
+ delete mMapTools .mVertexDelete ;
344
+ }
331
345
332
346
// restore any application settings stored in QSettings
333
347
void QgisApp::readSettings ()
@@ -1060,6 +1074,34 @@ void QgisApp::createCanvas()
1060
1074
tabWidget->widget (0 )->setLayout (myCanvasLayout);
1061
1075
// set the focus to the map canvas
1062
1076
mMapCanvas ->setFocus ();
1077
+
1078
+ // create tools
1079
+ mMapTools .mZoomIn = new QgsMapToolZoom (mMapCanvas , FALSE /* zoomIn */ );
1080
+ mMapTools .mZoomIn ->setAction (mActionZoomIn );
1081
+ mMapTools .mZoomOut = new QgsMapToolZoom (mMapCanvas , TRUE /* zoomOut */ );
1082
+ mMapTools .mZoomOut ->setAction (mActionZoomOut );
1083
+ mMapTools .mPan = new QgsMapToolPan (mMapCanvas );
1084
+ mMapTools .mPan ->setAction (mActionPan );
1085
+ mMapTools .mIdentify = new QgsMapToolIdentify (mMapCanvas );
1086
+ mMapTools .mIdentify ->setAction (mActionIdentify );
1087
+ mMapTools .mMeasureDist = new QgsMeasure (FALSE /* area */ , mMapCanvas );
1088
+ mMapTools .mMeasureDist ->setAction (mActionMeasure );
1089
+ mMapTools .mMeasureArea = new QgsMeasure (TRUE /* area */ , mMapCanvas );
1090
+ mMapTools .mMeasureArea ->setAction (mActionMeasureArea );
1091
+ mMapTools .mCapturePoint = new QgsMapToolCapture (mMapCanvas , QgsMapToolCapture::CapturePoint);
1092
+ mMapTools .mCapturePoint ->setAction (mActionCapturePoint );
1093
+ mMapTools .mCaptureLine = new QgsMapToolCapture (mMapCanvas , QgsMapToolCapture::CaptureLine);
1094
+ mMapTools .mCaptureLine ->setAction (mActionCaptureLine );
1095
+ mMapTools .mCapturePolygon = new QgsMapToolCapture (mMapCanvas , QgsMapToolCapture::CapturePolygon);
1096
+ mMapTools .mCapturePolygon ->setAction (mActionCapturePolygon );
1097
+ mMapTools .mSelect = new QgsMapToolSelect (mMapCanvas );
1098
+ mMapTools .mSelect ->setAction (mActionSelect );
1099
+ mMapTools .mVertexAdd = new QgsMapToolVertexEdit (mMapCanvas , QgsMapToolVertexEdit::AddVertex);
1100
+ mMapTools .mVertexAdd ->setAction (mActionAddVertex );
1101
+ mMapTools .mVertexMove = new QgsMapToolVertexEdit (mMapCanvas , QgsMapToolVertexEdit::MoveVertex);
1102
+ mMapTools .mVertexMove ->setAction (mActionMoveVertex );
1103
+ mMapTools .mVertexDelete = new QgsMapToolVertexEdit (mMapCanvas , QgsMapToolVertexEdit::DeleteVertex);
1104
+ mMapTools .mVertexDelete ->setAction (mActionDeleteVertex );
1063
1105
}
1064
1106
1065
1107
void QgisApp::createOverview ()
@@ -3192,13 +3234,14 @@ void QgisApp::exportMapServer()
3192
3234
// tr("No layers to export. You must add at least one layer to the map in order to export the view."));
3193
3235
// }
3194
3236
}
3237
+
3238
+
3239
+
3195
3240
void QgisApp::zoomIn ()
3196
3241
{
3197
3242
QgsDebugMsg (" Setting map tool to zoomIn" );
3198
3243
3199
- QgsMapTool* tool = new QgsMapToolZoom (mMapCanvas , FALSE /* zoomIn */ );
3200
- tool->setAction (mActionZoomIn );
3201
- mMapCanvas ->setMapTool (tool);
3244
+ mMapCanvas ->setMapTool (mMapTools .mZoomIn );
3202
3245
3203
3246
// notify the project we've made a change
3204
3247
QgsProject::instance ()->dirty (true );
@@ -3207,9 +3250,7 @@ void QgisApp::zoomIn()
3207
3250
3208
3251
void QgisApp::zoomOut ()
3209
3252
{
3210
- QgsMapTool* tool = new QgsMapToolZoom (mMapCanvas , TRUE /* zoomOut */ );
3211
- tool->setAction (mActionZoomOut );
3212
- mMapCanvas ->setMapTool (tool);
3253
+ mMapCanvas ->setMapTool (mMapTools .mZoomOut );
3213
3254
3214
3255
// notify the project we've made a change
3215
3256
QgsProject::instance ()->dirty (true );
@@ -3225,9 +3266,7 @@ void QgisApp::zoomToSelected()
3225
3266
3226
3267
void QgisApp::pan ()
3227
3268
{
3228
- QgsMapTool* tool = new QgsMapToolPan (mMapCanvas );
3229
- tool->setAction (mActionPan );
3230
- mMapCanvas ->setMapTool (tool);
3269
+ mMapCanvas ->setMapTool (mMapTools .mPan );
3231
3270
}
3232
3271
3233
3272
void QgisApp::zoomFull ()
@@ -3248,23 +3287,17 @@ void QgisApp::zoomPrevious()
3248
3287
3249
3288
void QgisApp::identify ()
3250
3289
{
3251
- QgsMapTool* tool = new QgsMapToolIdentify (mMapCanvas );
3252
- tool->setAction (mActionIdentify );
3253
- mMapCanvas ->setMapTool (tool);
3290
+ mMapCanvas ->setMapTool (mMapTools .mIdentify );
3254
3291
}
3255
3292
3256
3293
void QgisApp::measure ()
3257
3294
{
3258
- QgsMapTool* tool = new QgsMeasure (FALSE /* area */ , mMapCanvas );
3259
- tool->setAction (mActionMeasure );
3260
- mMapCanvas ->setMapTool (tool);
3295
+ mMapCanvas ->setMapTool (mMapTools .mMeasureDist );
3261
3296
}
3262
3297
3263
3298
void QgisApp::measureArea ()
3264
3299
{
3265
- QgsMapTool* tool = new QgsMeasure (TRUE /* area */ , mMapCanvas );
3266
- tool->setAction (mActionMeasureArea );
3267
- mMapCanvas ->setMapTool (tool);
3300
+ mMapCanvas ->setMapTool (mMapTools .mMeasureArea );
3268
3301
}
3269
3302
3270
3303
@@ -3316,72 +3349,43 @@ void QgisApp::deleteSelected()
3316
3349
void QgisApp::capturePoint ()
3317
3350
{
3318
3351
// set current map tool to select
3319
- QgsMapTool* t = new QgsMapToolCapture (mMapCanvas , QgsMapToolCapture::CapturePoint);
3320
- t->setAction (mActionCapturePoint );
3321
- mMapCanvas ->setMapTool (t);
3352
+ mMapCanvas ->setMapTool (mMapTools .mCapturePoint );
3322
3353
3323
3354
// FIXME: is this still actual or something old that's not used anymore?
3324
3355
// connect(t, SIGNAL(xyClickCoordinates(QgsPoint &)), this, SLOT(showCapturePointCoordinate(QgsPoint &)));
3325
3356
}
3326
3357
3327
3358
void QgisApp::captureLine ()
3328
3359
{
3329
- QgsMapTool* t = new QgsMapToolCapture (mMapCanvas , QgsMapToolCapture::CaptureLine);
3330
- t->setAction (mActionCaptureLine );
3331
- mMapCanvas ->setMapTool (t);
3360
+ mMapCanvas ->setMapTool (mMapTools .mCaptureLine );
3332
3361
}
3333
3362
3334
3363
void QgisApp::capturePolygon ()
3335
3364
{
3336
- QgsMapTool* t = new QgsMapToolCapture (mMapCanvas , QgsMapToolCapture::CapturePolygon);
3337
- t->setAction (mActionCapturePolygon );
3338
- mMapCanvas ->setMapTool (t);
3365
+ mMapCanvas ->setMapTool (mMapTools .mCapturePolygon );
3339
3366
}
3340
3367
3341
3368
void QgisApp::select ()
3342
3369
{
3343
- QgsMapTool* t = new QgsMapToolSelect (mMapCanvas );
3344
- t->setAction (mActionSelect );
3345
- mMapCanvas ->setMapTool (t);
3370
+ mMapCanvas ->setMapTool (mMapTools .mSelect );
3346
3371
}
3347
3372
3348
3373
3349
3374
void QgisApp::addVertex ()
3350
3375
{
3351
-
3352
- #ifdef QGISDEBUG
3353
- std::cout << " QgisApp::addVertex." << std::endl;
3354
- #endif
3355
-
3356
- QgsMapTool* t = new QgsMapToolVertexEdit (mMapCanvas , QgsMapToolVertexEdit::AddVertex);
3357
- t->setAction (mActionAddVertex );
3358
- mMapCanvas ->setMapTool (t);
3376
+ mMapCanvas ->setMapTool (mMapTools .mVertexAdd );
3359
3377
3360
3378
}
3361
3379
3362
3380
void QgisApp::moveVertex ()
3363
3381
{
3364
-
3365
- #ifdef QGISDEBUG
3366
- std::cout << " QgisApp::moveVertex." << std::endl;
3367
- #endif
3368
-
3369
- QgsMapTool* t = new QgsMapToolVertexEdit (mMapCanvas , QgsMapToolVertexEdit::MoveVertex);
3370
- t->setAction (mActionMoveVertex );
3371
- mMapCanvas ->setMapTool (t);
3382
+ mMapCanvas ->setMapTool (mMapTools .mVertexMove );
3372
3383
}
3373
3384
3374
3385
3375
3386
void QgisApp::deleteVertex ()
3376
3387
{
3377
-
3378
- #ifdef QGISDEBUG
3379
- std::cout << " QgisApp::deleteVertex." << std::endl;
3380
- #endif
3381
-
3382
- QgsMapTool* t = new QgsMapToolVertexEdit (mMapCanvas , QgsMapToolVertexEdit::DeleteVertex);
3383
- t->setAction (mActionDeleteVertex );
3384
- mMapCanvas ->setMapTool (t);
3388
+ mMapCanvas ->setMapTool (mMapTools .mVertexDelete );
3385
3389
}
3386
3390
3387
3391
0 commit comments