bool QgsAdvancedDigitizingDockWidget::applyConstraints( QgsMapMouseEvent *e ) { QgsCadUtils::AlignMapPointContext context; context.snappingUtils = mMapCanvas->snappingUtils(); context.mapUnitsPerPixel = mMapCanvas->mapUnitsPerPixel(); context.xConstraint = _constraint( mXConstraint.get() ); context.yConstraint = _constraint( mYConstraint.get() ); context.distanceConstraint = _constraint( mDistanceConstraint.get() ); context.angleConstraint = _constraint( mAngleConstraint.get() ); context.cadPointList = mCadPointList; context.commonAngleConstraint.locked = true; context.commonAngleConstraint.relative = context.angleConstraint.relative; context.commonAngleConstraint.value = mCommonAngleConstraint; QgsCadUtils::AlignMapPointOutput output = QgsCadUtils::alignMapPoint( e->originalMapPoint(), context ); bool res = output.valid; QgsPointXY point = output.finalMapPoint; mSnappedSegment.clear(); if ( output.edgeMatch.hasEdge() ) { QgsPointXY edgePt0, edgePt1; output.edgeMatch.edgePoints( edgePt0, edgePt1 ); mSnappedSegment << edgePt0 << edgePt1; } if ( mAngleConstraint->lockMode() != CadConstraint::HardLock ) { if ( output.softLockCommonAngle != -1 ) { mAngleConstraint->setLockMode( CadConstraint::SoftLock ); mAngleConstraint->setValue( output.softLockCommonAngle ); } else { mAngleConstraint->setLockMode( CadConstraint::NoLock ); } } // set the point coordinates in the map event e->setMapPoint( point ); // update the point list updateCurrentPoint( point ); updateUnlockedConstraintValues( point ); if ( res ) { emit popWarning(); } else { emit pushWarning( tr( "Some constraints are incompatible. Resulting point might be incorrect." ) ); } return res; }
void QgsOfflineEditingPlugin::initGui() { delete mActionConvertProject; // Create the action for tool mActionConvertProject = new QAction( QIcon( ":/offline_editing/offline_editing_copy.png" ), tr( "Convert to offline project" ), this ); mActionConvertProject->setObjectName( "mActionConvertProject" ); // Set the what's this text mActionConvertProject->setWhatsThis( tr( "Create offline copies of selected layers and save as offline project" ) ); // Connect the action to the run connect( mActionConvertProject, SIGNAL( triggered() ), this, SLOT( convertProject() ) ); // Add the icon to the toolbar mQGisIface->addDatabaseToolBarIcon( mActionConvertProject ); mQGisIface->addPluginToDatabaseMenu( tr( "&Offline Editing" ), mActionConvertProject ); mActionConvertProject->setEnabled( false ); mActionSynchronize = new QAction( QIcon( ":/offline_editing/offline_editing_sync.png" ), tr( "Synchronize" ), this ); mActionSynchronize->setObjectName( "mActionSynchronize" ); mActionSynchronize->setWhatsThis( tr( "Synchronize offline project with remote layers" ) ); connect( mActionSynchronize, SIGNAL( triggered() ), this, SLOT( synchronize() ) ); mQGisIface->addDatabaseToolBarIcon( mActionSynchronize ); mQGisIface->addPluginToDatabaseMenu( tr( "&Offline Editing" ), mActionSynchronize ); mActionSynchronize->setEnabled( false ); mOfflineEditing = new QgsOfflineEditing(); mProgressDialog = new QgsOfflineEditingProgressDialog( mQGisIface->mainWindow(), QgisGui::ModalDialogFlags ); connect( mOfflineEditing, SIGNAL( progressStarted() ), this, SLOT( showProgress() ) ); connect( mOfflineEditing, SIGNAL( layerProgressUpdated( int, int ) ), this, SLOT( setLayerProgress( int, int ) ) ); connect( mOfflineEditing, SIGNAL( progressModeSet( QgsOfflineEditing::ProgressMode, int ) ), this, SLOT( setProgressMode( QgsOfflineEditing::ProgressMode, int ) ) ); connect( mOfflineEditing, SIGNAL( progressUpdated( int ) ), this, SLOT( updateProgress( int ) ) ); connect( mOfflineEditing, SIGNAL( progressStopped() ), this, SLOT( hideProgress() ) ); connect( mOfflineEditing, SIGNAL( warning( QString, QString ) ), mQGisIface->messageBar(), SLOT( pushWarning( QString, QString ) ) ); connect( mQGisIface->mainWindow(), SIGNAL( projectRead() ), this, SLOT( updateActions() ) ); connect( mQGisIface->mainWindow(), SIGNAL( newProject() ), this, SLOT( updateActions() ) ); connect( QgsProject::instance(), SIGNAL( writeProject( QDomDocument & ) ), this, SLOT( updateActions() ) ); connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWasAdded( QgsMapLayer* ) ), this, SLOT( updateActions() ) ); connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWillBeRemoved( QString ) ), this, SLOT( updateActions() ) ); updateActions(); }