@@ -77,8 +77,6 @@ QgsGrassPlugin::QgsGrassPlugin( QgisInterface * theQgisInterFace )
77
77
, mOpenMapsetAction( 0 )
78
78
, mNewMapsetAction( 0 )
79
79
, mCloseMapsetAction( 0 )
80
- , mAddVectorAction( 0 )
81
- , mAddRasterAction( 0 )
82
80
, mOpenToolsAction( 0 )
83
81
, mEditRegionAction( 0 )
84
82
, mEditAction( 0 )
@@ -162,12 +160,6 @@ void QgsGrassPlugin::initGui()
162
160
mCloseMapsetAction = new QAction ( QIcon (), tr ( " Close Mapset" ), this );
163
161
mCloseMapsetAction ->setObjectName ( " mCloseMapsetAction" );
164
162
165
- mAddVectorAction = new QAction ( QIcon (), tr ( " Add GRASS Vector Layer" ), this );
166
- mAddVectorAction ->setObjectName ( " mAddVectorAction" );
167
- mAddVectorAction ->setWhatsThis ( tr ( " Adds a GRASS vector layer to the map canvas" ) );
168
- mAddRasterAction = new QAction ( QIcon (), tr ( " Add GRASS raster layer" ), this );
169
- mAddRasterAction ->setObjectName ( " mAddRasterAction" );
170
- mAddRasterAction ->setWhatsThis ( tr ( " Adds a GRASS raster layer to the map canvas" ) );
171
163
mOpenToolsAction = new QAction ( QIcon (), tr ( " Open GRASS Tools" ), this );
172
164
mOpenToolsAction ->setObjectName ( " mOpenToolsAction" );
173
165
mOpenToolsAction ->setWhatsThis ( tr ( " Open GRASS tools" ) );
@@ -187,8 +179,6 @@ void QgsGrassPlugin::initGui()
187
179
mNewVectorAction ->setObjectName ( " mNewVectorAction" );
188
180
189
181
// Connect the action
190
- connect ( mAddVectorAction , SIGNAL ( triggered () ), this , SLOT ( addVector () ) );
191
- connect ( mAddRasterAction , SIGNAL ( triggered () ), this , SLOT ( addRaster () ) );
192
182
connect ( mOpenToolsAction , SIGNAL ( triggered () ), this , SLOT ( openTools () ) );
193
183
connect ( mEditAction , SIGNAL ( triggered () ), this , SLOT ( edit () ) );
194
184
connect ( mNewVectorAction , SIGNAL ( triggered () ), this , SLOT ( newVector () ) );
@@ -202,8 +192,6 @@ void QgsGrassPlugin::initGui()
202
192
qGisInterface->addPluginToMenu ( tr ( " &GRASS" ), mOpenMapsetAction );
203
193
qGisInterface->addPluginToMenu ( tr ( " &GRASS" ), mNewMapsetAction );
204
194
qGisInterface->addPluginToMenu ( tr ( " &GRASS" ), mCloseMapsetAction );
205
- qGisInterface->addPluginToMenu ( tr ( " &GRASS" ), mAddVectorAction );
206
- qGisInterface->addPluginToMenu ( tr ( " &GRASS" ), mAddRasterAction );
207
195
qGisInterface->addPluginToMenu ( tr ( " &GRASS" ), mNewVectorAction );
208
196
qGisInterface->addPluginToMenu ( tr ( " &GRASS" ), mEditAction );
209
197
qGisInterface->addPluginToMenu ( tr ( " &GRASS" ), mOpenToolsAction );
@@ -219,8 +207,6 @@ void QgsGrassPlugin::initGui()
219
207
mToolBarPointer ->addAction ( mNewMapsetAction );
220
208
mToolBarPointer ->addAction ( mCloseMapsetAction );
221
209
mToolBarPointer ->addSeparator ();
222
- mToolBarPointer ->addAction ( mAddVectorAction );
223
- mToolBarPointer ->addAction ( mAddRasterAction );
224
210
mToolBarPointer ->addAction ( mNewVectorAction );
225
211
mToolBarPointer ->addAction ( mEditAction );
226
212
mToolBarPointer ->addAction ( mOpenToolsAction );
@@ -312,156 +298,6 @@ void QgsGrassPlugin::saveMapset()
312
298
QgsGrass::getDefaultMapset () );
313
299
}
314
300
315
- // Slot called when the "Add GRASS vector layer" menu item is triggered
316
- void QgsGrassPlugin::addVector ()
317
- {
318
- // QgsDebugMsg("entered.");
319
- QString uri;
320
-
321
- QgsGrassSelect *sel = new QgsGrassSelect ( qGisInterface->mainWindow (), QgsGrassSelect::VECTOR );
322
- if ( sel->exec () )
323
- {
324
- uri = sel->gisdbase + " /" + sel->location + " /" + sel->mapset + " /" + sel->map + " /" + sel->layer ;
325
- }
326
- // QgsDebugMsg(QString("plugin URI: %1").arg(uri));
327
- if ( uri.length () == 0 )
328
- {
329
- // QgsDebugMsg("Nothing was selected");
330
- return ;
331
- }
332
- else
333
- {
334
- // QgsDebugMsg("Add new vector layer");
335
-
336
- // create vector name: vector layer
337
- QString name = sel->map ;
338
-
339
- QString field;
340
- QString type;
341
-
342
- if ( !sel->layer .startsWith ( " topo_" ) )
343
- {
344
- QRegExp rx ( " (\\ d+)_(.+)" );
345
- if ( rx.indexIn ( sel->layer ) != -1 )
346
- {
347
- field = rx.cap ( 1 );
348
- type = rx.cap ( 2 );
349
- }
350
- }
351
-
352
- // Set location
353
- QgsGrass::setLocation ( sel->gisdbase , sel->location );
354
-
355
- /* Open vector */
356
- try
357
- {
358
- // Vect_set_open_level( 2 );
359
- struct Map_info map;
360
- int level = Vect_open_old_head ( &map, sel->map .toUtf8 ().data (),
361
- sel->mapset .toUtf8 ().data () );
362
-
363
- if ( level == 1 )
364
- {
365
- QgsDebugMsg ( " Cannot open vector on level 2" );
366
- QMessageBox::warning ( 0 , tr ( " Warning" ), tr ( " Cannot open vector %1 in mapset %2 on level 2 (topology not available, try to rebuild topology using v.build module)." ).arg ( sel->map ).arg ( sel->mapset ) );
367
- Vect_close ( &map );
368
- return ;
369
- }
370
- else if ( level < 1 )
371
- {
372
- QgsDebugMsg ( " Cannot open vector" );
373
- QMessageBox::warning ( 0 , tr ( " Warning" ), tr ( " Cannot open vector %1 in mapset %2" ).arg ( sel->map ).arg ( sel->mapset ) );
374
- return ;
375
- }
376
-
377
- if ( level >= 2 )
378
- {
379
- if ( !sel->layer .startsWith ( " topo_" ) )
380
- {
381
- // Count layers
382
- int cnt = 0 ;
383
- int ncidx = Vect_cidx_get_num_fields ( &map );
384
-
385
- for ( int i = 0 ; i < ncidx; i++ )
386
- {
387
- int field = Vect_cidx_get_field_number ( &map, i );
388
-
389
- if ( Vect_cidx_get_type_count ( &map, field, GV_POINT | GV_LINE | GV_AREA ) > 0 ||
390
- ( field > 1 && Vect_cidx_get_type_count ( &map, field, GV_BOUNDARY ) ) )
391
- {
392
- cnt++;
393
- }
394
- }
395
-
396
- if ( cnt > 1 )
397
- {
398
- name.append ( " " + field );
399
-
400
- // No need to ad type, the type is obvious from the legend
401
- }
402
- }
403
- else
404
- {
405
- name.append ( " " + sel->layer );
406
- }
407
- }
408
-
409
- Vect_close ( &map );
410
- }
411
- catch ( QgsGrass::Exception &e )
412
- {
413
- QMessageBox::warning ( 0 , tr ( " Warning" ), tr ( " Cannot open GRASS vector:\n %1" ).arg ( e.what () ) );
414
- }
415
-
416
- qGisInterface->addVectorLayer ( uri, name, " grass" );
417
- }
418
- }
419
-
420
- // Slot called when the "Add GRASS raster layer" menu item is triggered
421
- void QgsGrassPlugin::addRaster ()
422
- {
423
- // QgsDebugMsg("entered.");
424
- QString uri;
425
-
426
- QgsGrassSelect *sel = new QgsGrassSelect ( qGisInterface->mainWindow (), QgsGrassSelect::RASTER );
427
- if ( sel->exec () )
428
- {
429
- QString element;
430
- if ( sel->selectedType == QgsGrassSelect::RASTER )
431
- {
432
- element = " cellhd" ;
433
- }
434
- else // GROUP
435
- {
436
- element = " group" ;
437
- }
438
-
439
- uri = sel->gisdbase + " /" + sel->location + " /" + sel->mapset + " /" + element + " /" + sel->map ;
440
- }
441
-
442
- // QgsDebugMsg(QString("plugin URI: %1").arg(uri));
443
-
444
- if ( uri.length () == 0 )
445
- {
446
- // QgsDebugMsg("Nothing was selected");
447
- return ;
448
- }
449
- else
450
- {
451
-
452
- // QgsDebugMsg("Add new raster layer");
453
-
454
- // create raster name
455
- int pos = uri.lastIndexOf ( ' /' );
456
- pos = uri.lastIndexOf ( ' /' , pos - 1 );
457
- QString name = uri.right ( uri.length () - pos - 1 );
458
- name.replace ( ' /' , ' ' );
459
-
460
- // qGisInterface->addRasterLayer( uri, sel->map );
461
- qGisInterface->addRasterLayer ( uri, sel->map , " grassraster" );
462
- }
463
- }
464
-
465
301
// Open tools
466
302
void QgsGrassPlugin::openTools ()
467
303
{
@@ -859,8 +695,6 @@ void QgsGrassPlugin::unload()
859
695
qGisInterface->removePluginMenu ( tr ( " &GRASS" ), mOpenMapsetAction );
860
696
qGisInterface->removePluginMenu ( tr ( " &GRASS" ), mNewMapsetAction );
861
697
qGisInterface->removePluginMenu ( tr ( " &GRASS" ), mCloseMapsetAction );
862
- qGisInterface->removePluginMenu ( tr ( " &GRASS" ), mAddVectorAction );
863
- qGisInterface->removePluginMenu ( tr ( " &GRASS" ), mAddRasterAction );
864
698
qGisInterface->removePluginMenu ( tr ( " &GRASS" ), mOpenToolsAction );
865
699
qGisInterface->removePluginMenu ( tr ( " &GRASS" ), mRegionAction );
866
700
qGisInterface->removePluginMenu ( tr ( " &GRASS" ), mEditRegionAction );
@@ -870,8 +704,6 @@ void QgsGrassPlugin::unload()
870
704
delete mOpenMapsetAction ;
871
705
delete mNewMapsetAction ;
872
706
delete mCloseMapsetAction ;
873
- delete mAddVectorAction ;
874
- delete mAddRasterAction ;
875
707
delete mOpenToolsAction ;
876
708
delete mRegionAction ;
877
709
delete mEditRegionAction ;
@@ -904,8 +736,6 @@ void QgsGrassPlugin::setCurrentTheme( QString theThemeName )
904
736
mNewMapsetAction ->setIcon ( getThemeIcon ( " grass_new_mapset.png" ) );
905
737
mCloseMapsetAction ->setIcon ( getThemeIcon ( " grass_close_mapset.png" ) );
906
738
907
- mAddVectorAction ->setIcon ( getThemeIcon ( " grass_add_vector.png" ) );
908
- mAddRasterAction ->setIcon ( getThemeIcon ( " grass_add_raster.png" ) );
909
739
mOpenToolsAction ->setIcon ( getThemeIcon ( " grass_tools.png" ) );
910
740
911
741
mRegionAction ->setIcon ( getThemeIcon ( " grass_region.png" ) );
0 commit comments