void QgsSelectedFeature::setSelectedFeature( QgsFeatureId featureId, QgsVectorLayer* vlayer, QgsMapCanvas* canvas ) { mFeatureId = featureId; mVlayer = vlayer; mCanvas = canvas; delete mRubberBand; mRubberBand = 0; delete mGeometry; mGeometry = 0; // signal changing of current layer connect( QgisApp::instance()->legend(), SIGNAL( currentLayerChanged( QgsMapLayer* ) ), this, SLOT( currentLayerChanged( QgsMapLayer* ) ) ); // feature was deleted connect( mVlayer, SIGNAL( featureDeleted( QgsFeatureId ) ), this, SLOT( featureDeleted( QgsFeatureId ) ) ); // projection or extents changed connect( canvas->mapRenderer(), SIGNAL( destinationSrsChanged() ), this, SLOT( updateVertexMarkersPosition() ) ); connect( canvas, SIGNAL( extentsChanged() ), this, SLOT( updateVertexMarkersPosition() ) ); // geometry was changed connect( mVlayer, SIGNAL( geometryChanged( QgsFeatureId, QgsGeometry & ) ), this, SLOT( geometryChanged( QgsFeatureId, QgsGeometry & ) ) ); replaceVertexMap(); }
QgsMapToolMeasureAngle::QgsMapToolMeasureAngle( QgsMapCanvas* canvas ): QgsMapTool( canvas ), mRubberBand( 0 ), mResultDisplay( 0 ) { mSnapper.setMapCanvas( canvas ); connect( canvas->mapRenderer(), SIGNAL( destinationSrsChanged() ), this, SLOT( updateSettings() ) ); }
QgsMapCanvasRendererSync::QgsMapCanvasRendererSync( QgsMapCanvas* canvas, QgsMapRenderer* renderer ) : QObject( canvas ) , mCanvas( canvas ) , mRenderer( renderer ) , mSyncingExtent( false ) { connect( mCanvas, SIGNAL( extentsChanged() ), this, SLOT( onExtentC2R() ) ); connect( mRenderer, SIGNAL( extentsChanged() ), this, SLOT( onExtentR2C() ) ); connect( mCanvas, SIGNAL( mapUnitsChanged() ), this, SLOT( onMapUnitsC2R() ) ); connect( mRenderer, SIGNAL( mapUnitsChanged() ), this, SLOT( onMapUnitsR2C() ) ); connect( mCanvas, SIGNAL( rotationChanged( double ) ), this, SLOT( onMapRotationC2R() ) ); connect( mRenderer, SIGNAL( rotationChanged( double ) ), this, SLOT( onMapRotationR2C() ) ); connect( mCanvas, SIGNAL( hasCrsTransformEnabledChanged( bool ) ), this, SLOT( onCrsTransformC2R() ) ); connect( mRenderer, SIGNAL( hasCrsTransformEnabled( bool ) ), this, SLOT( onCrsTransformR2C() ) ); connect( mCanvas, SIGNAL( destinationCrsChanged() ), this, SLOT( onDestCrsC2R() ) ); connect( mRenderer, SIGNAL( destinationSrsChanged() ), this, SLOT( onDestCrsR2C() ) ); connect( mCanvas, SIGNAL( layersChanged() ), this, SLOT( onLayersC2R() ) ); // TODO: layers R2C ? (should not happen!) }
/** map tool which uses rubber band for changing grass region */ QgsGrassRegionEdit::QgsGrassRegionEdit( QgsMapCanvas* canvas ) : QgsMapTool( canvas ) { mDraw = false; mRubberBand = new QgsRubberBand( mCanvas, true ); mSrcRubberBand = new QgsRubberBand( mCanvas, true ); QString gisdbase = QgsGrass::getDefaultGisdbase(); QString location = QgsGrass::getDefaultLocation(); mCrs = QgsGrass::crs( gisdbase, location ); QgsDebugMsg( "mCrs: " + mCrs.toWkt() ); setTransform(); connect( canvas->mapRenderer(), SIGNAL( destinationSrsChanged() ), this, SLOT( setTransform() ) ); }
void QgsMapCanvas::enableOverviewMode( QgsMapOverviewCanvas* overview ) { if ( mMapOverview ) { // disconnect old map overview if exists disconnect( this, SIGNAL( hasCrsTransformEnabledChanged( bool ) ), mMapOverview, SLOT( hasCrsTransformEnabled( bool ) ) ); disconnect( this, SIGNAL( destinationCrsChanged() ), mMapOverview, SLOT( destinationSrsChanged() ) ); // map overview is not owned by map canvas so don't delete it... } mMapOverview = overview; if ( overview ) { // connect to the map render to copy its projection settings connect( this, SIGNAL( hasCrsTransformEnabledChanged( bool ) ), overview, SLOT( hasCrsTransformEnabled( bool ) ) ); connect( this, SIGNAL( destinationCrsChanged() ), overview, SLOT( destinationSrsChanged() ) ); } }
QgsMeasureTool::QgsMeasureTool( QgsMapCanvas* canvas, bool measureArea ) : QgsMapTool( canvas ) { mMeasureArea = measureArea; mRubberBand = new QgsRubberBand( canvas, mMeasureArea ); QPixmap myCrossHairQPixmap = QPixmap(( const char ** ) cross_hair_cursor ); mCursor = QCursor( myCrossHairQPixmap, 8, 8 ); mDone = true; // Append point we will move mPoints.append( QgsPoint( 0, 0 ) ); mDialog = new QgsMeasureDialog( this ); mSnapper.setMapCanvas( canvas ); connect( canvas->mapRenderer(), SIGNAL( destinationSrsChanged() ), this, SLOT( updateSettings() ) ); }
QgsMapToolNodeTool::QgsMapToolNodeTool( QgsMapCanvas* canvas ): QgsMapToolVertexEdit( canvas ) { mSelectionFeature = NULL; mQRubberBand = NULL; mSelectAnother = false; mCtrl = false; mMoving = true; mClicked = false; mChangingGeometry = false; mIsPoint = false; //signal handling change of layer structure connect( canvas, SIGNAL( layersChanged() ), this, SLOT( layersChanged() ) ); //signal when destination srs changed to repaint coordinates connect( canvas->mapRenderer(), SIGNAL( destinationSrsChanged() ), this, SLOT( coordinatesChanged() ) ); //signal changing of coordinate renderer changed to repaint markers connect( canvas->mapRenderer(), SIGNAL( hasCrsTransformEnabled( bool ) ), this, SLOT( coordinatesChanged( ) ) ); //signal changing of current layer connect( QgisApp::instance()->legend(), SIGNAL( currentLayerChanged( QgsMapLayer* ) ), this, SLOT( currentLayerChanged( QgsMapLayer* ) ) ); }
/* * Initialize the GUI interface for the plugin - this is only called once when the plugin is * added to the plugin registry in the QGIS application. */ void CoordinateCapture::initGui() { mCrs.createFromSrsId( GEOCRS_ID ); // initialize the CRS object connect( mQGisIface->mapCanvas()->mapRenderer(), SIGNAL( destinationSrsChanged() ), this, SLOT( setSourceCrs() ) ); setSourceCrs(); //set up the source CRS mTransform.setDestCRS( mCrs ); // set the CRS in the transform mUserCrsDisplayPrecision = ( mCrs.mapUnits() == QGis::Degrees ) ? 8 : 3; // precision depends on CRS units // Create the action for tool mQActionPointer = new QAction( QIcon( ":/coordinatecapture/coordinate_capture.png" ), tr( "Coordinate Capture" ), this ); // Set the what's this text mQActionPointer->setWhatsThis( tr( "Click on the map to view coordinates and capture to clipboard." ) ); // Connect the action to the run connect( mQActionPointer, SIGNAL( triggered() ), this, SLOT( run() ) ); // Add the icon to the toolbar mQGisIface->addToolBarIcon( mQActionPointer ); mQGisIface->addPluginToMenu( tr( "&Coordinate Capture" ), mQActionPointer ); // create our map tool mpMapTool = new CoordinateCaptureMapTool( mQGisIface->mapCanvas() ); connect( mpMapTool, SIGNAL( mouseMoved( QgsPoint ) ), this, SLOT( mouseMoved( QgsPoint ) ) ); connect( mpMapTool, SIGNAL( mouseClicked( QgsPoint ) ), this, SLOT( mouseClicked( QgsPoint ) ) ); // create a little widget with x and y display to put into our dock widget QWidget * mypWidget = new QWidget(); QGridLayout *mypLayout = new QGridLayout( mypWidget ); mypLayout->setColumnMinimumWidth( 0, 36 ); mypWidget->setLayout( mypLayout ); QToolButton * mypUserCrsToolButton = new QToolButton( mypWidget ); mypUserCrsToolButton->setIcon( QIcon( ":/coordinatecapture/geographic.png" ) ); mypUserCrsToolButton->setToolTip( tr( "Click to select the CRS to use for coordinate display" ) ); connect( mypUserCrsToolButton, SIGNAL( clicked() ), this, SLOT( setCRS() ) ); QLabel * mypCRSLabel = new QLabel( mypWidget ); mypCRSLabel->setPixmap( QPixmap( ":/coordinatecapture/transformed.png" ) ); mypCRSLabel->setGeometry( mypUserCrsToolButton->geometry() ); mpUserCrsEdit = new QLineEdit( mypWidget ); mpUserCrsEdit->setReadOnly( true ); mpUserCrsEdit->setToolTip( tr( "Coordinate in your selected CRS" ) ); mpCanvasEdit = new QLineEdit( mypWidget ); mpCanvasEdit->setReadOnly( true ); mpCanvasEdit->setToolTip( tr( "Coordinate in map canvas coordinate reference system" ) ); QPushButton * mypCopyButton = new QPushButton( mypWidget ); mypCopyButton->setText( tr( "Copy to clipboard" ) ); connect( mypCopyButton, SIGNAL( clicked() ), this, SLOT( copy() ) ); mpTrackMouseButton = new QToolButton( mypWidget ); mpTrackMouseButton->setCheckable( true ); mpTrackMouseButton->setToolTip( tr( "Click to enable mouse tracking. Click the canvas to stop" ) ); mpTrackMouseButton->setChecked( false ); mpTrackMouseButton->setIcon( QIcon( ":/coordinatecapture/tracking.png" ) ); mypLayout->addWidget( mypUserCrsToolButton, 0, 0 ); mypLayout->addWidget( mpUserCrsEdit, 0, 1 ); mypLayout->addWidget( mypCRSLabel, 1, 0 ); mypLayout->addWidget( mpCanvasEdit, 1, 1 ); mypLayout->addWidget( mpTrackMouseButton, 2, 0 ); mypLayout->addWidget( mypCopyButton, 2, 1 ); //create the dock widget mpDockWidget = new QDockWidget( tr( "Coordinate Capture" ), mQGisIface->mainWindow() ); mpDockWidget->setObjectName( "CoordinateCapture" ); mpDockWidget->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea ); mQGisIface->addDockWidget( Qt::LeftDockWidgetArea, mpDockWidget ); // now add our custom widget to the dock - ownership of the widget is passed to the dock mpDockWidget->setWidget( mypWidget ); }
/* * Initialize the GUI interface for the plugin */ void QgsGrassPlugin::initGui() { toolBarPointer = 0; mTools = 0; mNewMapset = 0; mRegion = 0; QSettings settings; QgsGrass::init(); mCanvas = qGisInterface->mapCanvas(); QWidget* qgis = qGisInterface->mainWindow(); connect( mCanvas->mapRenderer(), SIGNAL( destinationSrsChanged() ), this, SLOT( setTransform() ) ); // Connect project connect( qgis, SIGNAL( projectRead() ), this, SLOT( projectRead() ) ); connect( qgis, SIGNAL( newProject() ), this, SLOT( newProject() ) ); // Create region rubber band mRegionBand = new QgsRubberBand( mCanvas, QGis::Polygon ); mRegionBand->setZValue( 20 ); // Create the action for tool (the icons are set later by calling setCurrentTheme) mOpenMapsetAction = new QAction( QIcon(), tr( "Open mapset" ), this ); mNewMapsetAction = new QAction( QIcon(), tr( "New mapset" ), this ); mCloseMapsetAction = new QAction( QIcon(), tr( "Close mapset" ), this ); mAddVectorAction = new QAction( QIcon(), tr( "Add GRASS vector layer" ), this ); mAddRasterAction = new QAction( QIcon(), tr( "Add GRASS raster layer" ), this ); mOpenToolsAction = new QAction( QIcon(), tr( "Open GRASS tools" ), this ); mRegionAction = new QAction( QIcon(), tr( "Display Current Grass Region" ), this ); mRegionAction->setCheckable( true ); mEditRegionAction = new QAction( QIcon(), tr( "Edit Current Grass Region" ), this ); mEditAction = new QAction( QIcon(), tr( "Edit Grass Vector layer" ), this ); mNewVectorAction = new QAction( QIcon(), tr( "Create new Grass Vector" ), this ); mAddVectorAction->setWhatsThis( tr( "Adds a GRASS vector layer to the map canvas" ) ); mAddRasterAction->setWhatsThis( tr( "Adds a GRASS raster layer to the map canvas" ) ); mOpenToolsAction->setWhatsThis( tr( "Open GRASS tools" ) ); mRegionAction->setWhatsThis( tr( "Displays the current GRASS region as a rectangle on the map canvas" ) ); mEditRegionAction->setWhatsThis( tr( "Edit the current GRASS region" ) ); mEditAction->setWhatsThis( tr( "Edit the currently selected GRASS vector layer." ) ); // Connect the action connect( mAddVectorAction, SIGNAL( triggered() ), this, SLOT( addVector() ) ); connect( mAddRasterAction, SIGNAL( triggered() ), this, SLOT( addRaster() ) ); connect( mOpenToolsAction, SIGNAL( triggered() ), this, SLOT( openTools() ) ); 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() ) ); // Add actions to a GRASS plugin menu qGisInterface->addPluginToMenu( tr( "&GRASS" ), mOpenMapsetAction ); qGisInterface->addPluginToMenu( tr( "&GRASS" ), mNewMapsetAction ); qGisInterface->addPluginToMenu( tr( "&GRASS" ), mCloseMapsetAction ); qGisInterface->addPluginToMenu( tr( "&GRASS" ), mAddVectorAction ); qGisInterface->addPluginToMenu( tr( "&GRASS" ), mAddRasterAction ); qGisInterface->addPluginToMenu( tr( "&GRASS" ), mNewVectorAction ); 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 toolBarPointer = qGisInterface->addToolBar( tr( "GRASS" ) ); toolBarPointer->setObjectName( "GRASS" ); // Add to the toolbar toolBarPointer->addAction( mOpenMapsetAction ); toolBarPointer->addAction( mNewMapsetAction ); toolBarPointer->addAction( mCloseMapsetAction ); toolBarPointer->addSeparator(); toolBarPointer->addAction( mAddVectorAction ); toolBarPointer->addAction( mAddRasterAction ); toolBarPointer->addAction( mNewVectorAction ); toolBarPointer->addAction( mEditAction ); toolBarPointer->addAction( mOpenToolsAction ); toolBarPointer->addAction( mRegionAction ); toolBarPointer->addAction( mEditRegionAction ); // Set icons to current theme setCurrentTheme( "" ); // Connect theme change signal connect( qGisInterface, SIGNAL( currentThemeChanged( QString ) ), this, SLOT( setCurrentTheme( QString ) ) ); // Connect display region connect( mCanvas, SIGNAL( renderComplete( QPainter * ) ), this, SLOT( postRender( QPainter * ) ) ); setEditAction(); connect( qGisInterface, SIGNAL( currentLayerChanged( QgsMapLayer * ) ), this, SLOT( setEditAction() ) ); // Init Region symbology mRegionPen.setColor( QColor( settings.value( "/GRASS/region/color", "#ff0000" ).toString() ) ); mRegionPen.setWidth( settings.value( "/GRASS/region/width", 0 ).toInt() ); mRegionBand->setColor( mRegionPen.color() ); mRegionBand->setWidth( mRegionPen.width() ); mapsetChanged(); }