Skip to content
Permalink
Browse files

[GRASS] region dialog integrated to plugin dock widget

  • Loading branch information
blazek committed Aug 20, 2015
1 parent bed703e commit 71bd8b46eb7bf7cb6f9e852aa0c919caaae1fbf0
@@ -69,7 +69,6 @@ QgsGrassPlugin::QgsGrassPlugin( QgisInterface * theQgisInterFace )
, qGisInterface( theQgisInterFace )
, mCanvas( 0 )
, mRegionAction( 0 )
, mRegion( 0 )
, mRegionBand( 0 )
, mTools( 0 )
, mNewMapset( 0 )
@@ -78,7 +77,6 @@ QgsGrassPlugin::QgsGrassPlugin( QgisInterface * theQgisInterFace )
, mNewMapsetAction( 0 )
, mCloseMapsetAction( 0 )
, mOpenToolsAction( 0 )
, mEditRegionAction( 0 )
, mEditAction( 0 )
, mNewVectorAction( 0 )
{
@@ -135,7 +133,6 @@ void QgsGrassPlugin::initGui()
mToolBarPointer = 0;
mTools = 0;
mNewMapset = 0;
mRegion = 0;

QSettings settings;
QgsGrass::init();
@@ -169,9 +166,6 @@ void QgsGrassPlugin::initGui()
mRegionAction->setWhatsThis( tr( "Displays the current GRASS region as a rectangle on the map canvas" ) );
mRegionAction->setCheckable( true );

mEditRegionAction = new QAction( QIcon(), tr( "Edit Current Grass Region" ), this );
mEditRegionAction->setObjectName( "mEditRegionAction" );
mEditRegionAction->setWhatsThis( tr( "Edit the current GRASS region" ) );
mEditAction = new QAction( QIcon(), tr( "Edit Grass Vector layer" ), this );
mEditAction->setObjectName( "mEditAction" );
mEditAction->setWhatsThis( tr( "Edit the currently selected GRASS vector layer." ) );
@@ -183,7 +177,6 @@ void QgsGrassPlugin::initGui()
connect( mEditAction, SIGNAL( triggered() ), this, SLOT( edit() ) );
connect( mNewVectorAction, SIGNAL( triggered() ), this, SLOT( newVector() ) );
connect( mRegionAction, SIGNAL( toggled( bool ) ), this, SLOT( switchRegion( bool ) ) );
connect( mEditRegionAction, SIGNAL( triggered() ), this, SLOT( changeRegion() ) );
connect( mOpenMapsetAction, SIGNAL( triggered() ), this, SLOT( openMapset() ) );
connect( mNewMapsetAction, SIGNAL( triggered() ), this, SLOT( newMapset() ) );
connect( mCloseMapsetAction, SIGNAL( triggered() ), this, SLOT( closeMapset() ) );
@@ -196,7 +189,6 @@ void QgsGrassPlugin::initGui()
qGisInterface->addPluginToMenu( tr( "&GRASS" ), mEditAction );
qGisInterface->addPluginToMenu( tr( "&GRASS" ), mOpenToolsAction );
qGisInterface->addPluginToMenu( tr( "&GRASS" ), mRegionAction );
qGisInterface->addPluginToMenu( tr( "&GRASS" ), mEditRegionAction );

// Add the toolbar to the main window
mToolBarPointer = qGisInterface->addToolBar( tr( "GRASS" ) );
@@ -211,7 +203,6 @@ void QgsGrassPlugin::initGui()
mToolBarPointer->addAction( mEditAction );
mToolBarPointer->addAction( mOpenToolsAction );
mToolBarPointer->addAction( mRegionAction );
mToolBarPointer->addAction( mEditRegionAction );

// Set icons to current theme
setCurrentTheme( "" );
@@ -226,6 +217,7 @@ void QgsGrassPlugin::initGui()
this, SLOT( setEditAction() ) );

connect( QgsGrass::instance(), SIGNAL( mapsetChanged() ), SLOT( mapsetChanged() ) );
connect( QgsGrass::instance(), SIGNAL( regionChanged() ), SLOT( displayRegion() ) );
connect( QgsGrass::instance(), SIGNAL( regionPenChanged() ), SLOT( displayRegion() ) );

mapsetChanged();
@@ -241,15 +233,13 @@ void QgsGrassPlugin::mapsetChanged()
if ( !QgsGrass::activeMode() )
{
mRegionAction->setEnabled( false );
mEditRegionAction->setEnabled( false );
mRegionBand->reset();
mCloseMapsetAction->setEnabled( false );
mNewVectorAction->setEnabled( false );
}
else
{
mRegionAction->setEnabled( true );
mEditRegionAction->setEnabled( true );
mCloseMapsetAction->setEnabled( true );
mNewVectorAction->setEnabled( true );

@@ -458,15 +448,19 @@ void QgsGrassPlugin::postRender( QPainter *painter )

void QgsGrassPlugin::displayRegion()
{
// QgsDebugMsg("entered.");
QgsDebugMsg( "entered" );

mRegionBand->reset();
if ( !mRegionAction->isChecked() )
{
return;
}

// Display region of current mapset if in active mode
if ( !QgsGrass::activeMode() )
{
return;
}

struct Cell_head window;
try
@@ -512,29 +506,6 @@ void QgsGrassPlugin::redrawRegion()
displayRegion();
}

void QgsGrassPlugin::changeRegion( void )
{
// QgsDebugMsg("entered.");

if ( mRegion ) // running
{
mRegion->show();
return;
}

// Warning: don't use Qt::WType_Dialog, it would ignore restorePosition
mRegion = new QgsGrassRegion( this, qGisInterface, qGisInterface->mainWindow() );

connect( mRegion, SIGNAL( destroyed( QObject * ) ), this, SLOT( regionClosed() ) );

mRegion->show();
}

void QgsGrassPlugin::regionClosed()
{
mRegion = 0;
}

void QgsGrassPlugin::openMapset()
{
// QgsDebugMsg("entered.");
@@ -647,7 +618,6 @@ void QgsGrassPlugin::unload()
qGisInterface->removePluginMenu( tr( "&GRASS" ), mCloseMapsetAction );
qGisInterface->removePluginMenu( tr( "&GRASS" ), mOpenToolsAction );
qGisInterface->removePluginMenu( tr( "&GRASS" ), mRegionAction );
qGisInterface->removePluginMenu( tr( "&GRASS" ), mEditRegionAction );
qGisInterface->removePluginMenu( tr( "&GRASS" ), mEditAction );
qGisInterface->removePluginMenu( tr( "&GRASS" ), mNewVectorAction );

@@ -656,7 +626,6 @@ void QgsGrassPlugin::unload()
delete mCloseMapsetAction;
delete mOpenToolsAction;
delete mRegionAction;
delete mEditRegionAction;
delete mEditAction;
delete mNewVectorAction;

@@ -690,7 +659,6 @@ void QgsGrassPlugin::setCurrentTheme( QString theThemeName )

mRegionAction->setIcon( getThemeIcon( "grass_region.png" ) );

mEditRegionAction->setIcon( getThemeIcon( "grass_region_edit.png" ) );
mEditAction->setIcon( getThemeIcon( "grass_edit.png" ) );
mNewVectorAction->setIcon( getThemeIcon( "grass_new_vector_layer.png" ) );
}
@@ -89,10 +89,6 @@ class QgsGrassPlugin : public QObject, public QgisPlugin
void displayRegion();
//! Switch region on/off
void switchRegion( bool on );
//! Change region
void changeRegion( void );
//! Region dialog closed
void regionClosed();
//! Redraw region
void redrawRegion( void );
//! Post render
@@ -133,8 +129,7 @@ class QgsGrassPlugin : public QObject, public QgisPlugin

//! Pointer to Display region acction
QAction *mRegionAction;
//! Region dialog
QgsGrassRegion *mRegion;

// Region rubber band
QgsRubberBand *mRegionBand;
//! GRASS tools
@@ -151,7 +146,6 @@ class QgsGrassPlugin : public QObject, public QgisPlugin
QAction *mNewMapsetAction;
QAction *mCloseMapsetAction;
QAction *mOpenToolsAction;
QAction *mEditRegionAction;
QAction *mEditAction;
QAction *mNewVectorAction;
};

0 comments on commit 71bd8b4

Please sign in to comment.
You can’t perform that action at this time.