您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ toMapCoordinates函数代码示例

51自学网 2021-06-03 08:53:06
  C++
这篇教程C++ toMapCoordinates函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中toMapCoordinates函数的典型用法代码示例。如果您正苦于以下问题:C++ toMapCoordinates函数的具体用法?C++ toMapCoordinates怎么用?C++ toMapCoordinates使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了toMapCoordinates函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: toMapCoordinates

//! mouse button releasedvoid QgsGrassRegionEdit::canvasReleaseEvent( QgsMapMouseEvent *event ){  if ( !mDraw )    return;  mEndPoint = toMapCoordinates( event->pos() );  setRegion( mStartPoint, mEndPoint );  mDraw = false;  emit captureEnded();}
开发者ID:exlimit,项目名称:QGIS,代码行数:11,


示例2: deleteRubberBands

void QgsMapToolRotateLabel::canvasPressEvent( QgsMapMouseEvent* e ){  deleteRubberBands();  QgsLabelPosition labelPos;  if ( !labelAtPosition( e, labelPos ) )  {    mCurrentLabel = LabelDetails();    return;  }  mCurrentLabel = LabelDetails( labelPos );  if ( !mCurrentLabel.valid )    return;  // only rotate non-pinned OverPoint placements until other placements are supported in pal::Feature  if ( !mCurrentLabel.pos.isPinned       && mCurrentLabel.settings.placement != QgsPalLayerSettings::OverPoint )  {    return;  }  // rotate unpinned labels (i.e. no hali/vali settings) as if hali/vali was Center/Half  if ( !currentLabelRotationPoint( mRotationPoint, false, !mCurrentLabel.pos.isPinned ) )  {    return;  }  if ( true )  {    mCurrentMouseAzimuth = azimuthToCCW( mRotationPoint.azimuth( toMapCoordinates( e->pos() ) ) );    bool hasRotationValue;    int rotationCol;    if ( currentLabelDataDefinedRotation( mCurrentRotation, hasRotationValue, rotationCol, true ) )    {      if ( !hasRotationValue )      {        mCurrentRotation = 0;      }      mStartRotation = mCurrentRotation;      createRubberBands();      mRotationPreviewBox = createRotationPreviewBox();      mRotationItem = new QgsPointRotationItem( mCanvas );      mRotationItem->setOrientation( QgsPointRotationItem::Counterclockwise );      mRotationItem->setSymbol( QgsApplication::getThemePixmap( "mActionRotatePointSymbols.svg" ).toImage() );      mRotationItem->setPointLocation( mRotationPoint );      mRotationItem->setSymbolRotation( mCurrentRotation );    }  }}
开发者ID:NyakudyaA,项目名称:QGIS,代码行数:55,


示例3: captureStarted

//! mouse pressed in map canvasvoid QgsGrassRegionEdit::canvasPressEvent( QgsMapMouseEvent * event ){  mDraw = true;  mRubberBand->reset( QgsWkbTypes::PolygonGeometry );  mSrcRubberBand->reset( QgsWkbTypes::PolygonGeometry );  emit captureStarted();  mStartPoint = toMapCoordinates( event->pos() );  mEndPoint = mStartPoint;  setRegion( mStartPoint, mEndPoint );}
开发者ID:3liz,项目名称:Quantum-GIS,代码行数:12,


示例4: setPos

void QgsAnnotationItem::updatePosition(){  if ( mMapPositionFixed )  {    setPos( toCanvasCoordinates( mMapPosition ) );  }  else  {    mMapPosition = toMapCoordinates( pos().toPoint() );  }}
开发者ID:aaronr,项目名称:Quantum-GIS,代码行数:11,


示例5: toMapCoordinates

void QgsMapToolSelectPolygon::canvasMoveEvent( QgsMapMouseEvent* e ){  if ( !mRubberBand )    return;  if ( mRubberBand->numberOfVertices() > 0 )  {    mRubberBand->removeLastPoint( 0 );    mRubberBand->addPoint( toMapCoordinates( e->pos() ) );  }}
开发者ID:Zakui,项目名称:QGIS,代码行数:11,


示例6: toMapCoordinates

QgsPoint QgsMapToolEdit::snapPointFromResults( const QList<QgsSnappingResult>& snapResults, const QPoint& screenCoords ){  if ( snapResults.size() < 1 )  {    return toMapCoordinates( screenCoords );  }  else  {    return snapResults.constBegin()->snappedVertex;  }}
开发者ID:ACorradini,项目名称:QGIS,代码行数:11,


示例7: toMapCoordinates

void QgsMapToolMoveFeature::canvasMoveEvent( QgsMapMouseEvent* e ){  if ( mRubberBand )  {    QgsPoint pointCanvasCoords = toMapCoordinates( e->pos() );    double offsetX = pointCanvasCoords.x() - mStartPointMapCoords.x();    double offsetY = pointCanvasCoords.y() - mStartPointMapCoords.y();    mRubberBand->setTranslationOffset( offsetX, offsetY );    mRubberBand->updatePosition();    mRubberBand->update();  }}
开发者ID:Antoviscomi,项目名称:QGIS,代码行数:12,


示例8: toMapCoordinates

void QgsBullsEyeTool::canvasReleaseEvent( QMouseEvent *e ){  if ( mPicking )  {    mWidget->centerPicked( toMapCoordinates( e->pos() ) );    setPicking( false );  }  else if ( e->button() == Qt::RightButton )  {    canvas()->unsetMapTool( this );  }}
开发者ID:sourcepole,项目名称:kadas-albireo,代码行数:12,


示例9: Q_FOREACH

void QgsMapToolNodeTool::createTopologyRubberBands(){  QgsVectorLayer* vlayer = mSelectedFeature->vlayer();  Q_FOREACH ( const QgsVertexEntry* vertexEntry, mSelectedFeature->vertexMap() )  {    if ( !vertexEntry->isSelected() )    {      continue;    }    // Snap vertex    QMultiMap<double, QgsSnappingResult> snapResults;    vlayer->snapWithContext( vertexEntry->pointV1(), ZERO_TOLERANCE, snapResults, QgsSnapper::SnapToVertex );    Q_FOREACH ( const QgsSnappingResult& snapResult, snapResults )    {      // Get geometry of snapped feature      QgsFeatureId snapFeatureId = snapResult.snappedAtGeometry;      QgsFeature feature;      if ( !vlayer->getFeatures( QgsFeatureRequest( snapFeatureId ).setSubsetOfAttributes( QgsAttributeList() ) ).nextFeature( feature ) )      {        continue;      }      // Get VertexId of snapped vertex      QgsVertexId vid;      if ( !feature.geometry().vertexIdFromVertexNr( snapResult.snappedVertexNr, vid ) )      {        continue;      }      // Add rubberband if not already added      if ( !mMoveRubberBands.contains( snapFeatureId ) )      {        QgsGeometryRubberBand* rb = new QgsGeometryRubberBand( mCanvas, feature.geometry().type() );        QSettings settings;        QColor color(          settings.value( QStringLiteral( "/qgis/digitizing/line_color_red" ), 255 ).toInt(),          settings.value( QStringLiteral( "/qgis/digitizing/line_color_green" ), 0 ).toInt(),          settings.value( QStringLiteral( "/qgis/digitizing/line_color_blue" ), 0 ).toInt() );        double myAlpha = settings.value( QStringLiteral( "/qgis/digitizing/line_color_alpha" ), 30 ).toInt() / 255.0 ;        color.setAlphaF( myAlpha );        rb->setOutlineColor( color );        rb->setBrushStyle( Qt::NoBrush );        rb->setOutlineWidth( settings.value( QStringLiteral( "/qgis/digitizing/line_width" ), 1 ).toInt() );        QgsAbstractGeometry* rbGeom = feature.geometry().geometry()->clone();        if ( mCanvas->mapSettings().layerTransform( vlayer ).isValid() )          rbGeom->transform( mCanvas->mapSettings().layerTransform( vlayer ) );        rb->setGeometry( rbGeom );        mMoveRubberBands.insert( snapFeatureId, rb );      }      // Add to list of vertices to be moved      mMoveVertices[snapFeatureId].append( qMakePair( vid, toMapCoordinates( vlayer, feature.geometry().geometry()->vertexAt( vid ) ) ) );    }  }
开发者ID:GrokImageCompression,项目名称:QGIS,代码行数:53,


示例10: QgsDebugMsg

//! mouse pressed in map canvasvoid QgsGrassRegionEdit::canvasPressEvent( QMouseEvent * event ){  QgsDebugMsg( "entered." );  mDraw = true;  mRubberBand->reset( true );  mSrcRubberBand->reset( true );  emit captureStarted();  mStartPoint = toMapCoordinates( event->pos() );  mEndPoint = mStartPoint;  setRegion( mStartPoint, mEndPoint );}
开发者ID:aaronr,项目名称:Quantum-GIS,代码行数:13,


示例11: t

void QgsAnnotationItem::updatePosition(){  if ( mMapPositionFixed )  {    QgsCoordinateTransform t( mMapPositionCrs, mMapCanvas->mapSettings().destinationCrs() );    setPos( toCanvasCoordinates( t.transform( mMapPosition ) ) );  }  else  {    mMapPosition = toMapCoordinates( pos().toPoint() );  }}
开发者ID:AM7000000,项目名称:QGIS,代码行数:12,


示例12: QgsRubberBand

void QgsMapToolSelectFreehand::canvasPressEvent( QMouseEvent * e ){  if ( e->button() != Qt::LeftButton )  {    return;  }  if ( mRubberBand == NULL )  {    mRubberBand = new QgsRubberBand( mCanvas, true );  }  mRubberBand->addPoint( toMapCoordinates( e->pos() ) );  mDragging = true;}
开发者ID:CzendaZdenda,项目名称:qgis,代码行数:13,


示例13: QgsRubberBand

void QgsMapToolSelectFreehand::canvasPressEvent( QgsMapMouseEvent* e ){  if ( e->button() != Qt::LeftButton )    return;  if ( !mRubberBand )  {    mRubberBand = new QgsRubberBand( mCanvas, QGis::Polygon );    mRubberBand->setFillColor( mFillColor );    mRubberBand->setBorderColor( mBorderColour );  }  mRubberBand->addPoint( toMapCoordinates( e->pos() ) );  mDragging = true;}
开发者ID:Antoviscomi,项目名称:QGIS,代码行数:14,


示例14: foreach

void QgsMapToolNodeTool::createTopologyRubberBands(){  QgsVectorLayer* vlayer = mSelectedFeature->vlayer();  foreach ( const QgsVertexEntry* vertexEntry, mSelectedFeature->vertexMap() )  {    if ( !vertexEntry->isSelected() )    {      continue;    }    // Snap vertex    QMultiMap<double, QgsSnappingResult> snapResults;    vlayer->snapWithContext( vertexEntry->pointV1(), ZERO_TOLERANCE, snapResults, QgsSnapper::SnapToVertex );    foreach ( const QgsSnappingResult& snapResult, snapResults.values() )    {      // Get geometry of snapped feature      QgsFeatureId snapFeatureId = snapResult.snappedAtGeometry;      QgsFeature feature;      if ( !vlayer->getFeatures( QgsFeatureRequest( snapFeatureId ).setSubsetOfAttributes( QgsAttributeList() ) ).nextFeature( feature ) )      {        continue;      }      // Get VertexId of snapped vertex      QgsVertexId vid;      if ( !feature.geometry()->vertexIdFromVertexNr( snapResult.snappedVertexNr, vid ) )      {        continue;      }      // Add rubberband if not already added      if ( !mMoveRubberBands.contains( snapFeatureId ) )      {        QgsGeometryRubberBand* rb = new QgsGeometryRubberBand( mCanvas, feature.geometry()->type() );        rb->setOutlineColor( Qt::blue );        rb->setBrushStyle( Qt::NoBrush );        rb->setOutlineWidth( 2 );        QgsAbstractGeometryV2* rbGeom = feature.geometry()->geometry()->clone();        if ( mCanvas->mapSettings().layerTransform( vlayer ) )          rbGeom->transform( *mCanvas->mapSettings().layerTransform( vlayer ) );        rb->setGeometry( rbGeom );        mMoveRubberBands.insert( snapFeatureId, rb );      }      // Add to list of vertices to be moved      mMoveVertices[snapFeatureId].append( qMakePair( vid, toMapCoordinates( vlayer, feature.geometry()->geometry()->vertexAt( vid ) ) ) );    }  }}
开发者ID:sourcepole,项目名称:kadas-albireo,代码行数:48,


示例15: QgsDebugMsg

void QgsGrassEditNewLine::activate(){  QgsDebugMsg( "entered." );  // Display dynamic segment  if ( e->mEditPoints->n_points > 0 )  {    Vect_reset_line( e->mPoints );    Vect_append_points( e->mPoints, e->mEditPoints, GV_FORWARD );    QgsPoint point = toMapCoordinates( e->mCanvas->mouseLastXY() );    Vect_append_point( e->mPoints, point.x(), point.y(), 0.0 );    e->displayDynamic( e->mPoints );  }  QgsGrassEditTool::activate(); // call default bahivour}
开发者ID:RealworldSystems,项目名称:Quantum-GIS,代码行数:16,


示例16: createRubberBand

void QgsMapToolCapture::cadCanvasMoveEvent( QgsMapMouseEvent *e ){  QgsMapToolAdvancedDigitizing::cadCanvasMoveEvent( e );  QgsPointXY point = e->mapPoint();  mSnapIndicator->setMatch( e->mapPointMatch() );  if ( !mTempRubberBand && mCaptureCurve.numPoints() > 0 )  {    mTempRubberBand = createRubberBand( mCaptureMode == CapturePolygon ? QgsWkbTypes::PolygonGeometry : QgsWkbTypes::LineGeometry, true );    QgsPoint pt = mCaptureCurve.endPoint();    mTempRubberBand->addPoint( QgsPointXY( pt.x(), pt.y() ) );    mTempRubberBand->addPoint( point );  }  if ( mCaptureMode != CapturePoint && mTempRubberBand && mCapturing )  {    bool hasTrace = false;    if ( tracingEnabled() && mCaptureCurve.numPoints() != 0 )    {      hasTrace = tracingMouseMove( e );    }    if ( !hasTrace )    {      if ( mCaptureCurve.numPoints() > 0 )      {        // fix temporary rubber band after tracing which may have added multiple points        mTempRubberBand->reset( mCaptureMode == CapturePolygon ? QgsWkbTypes::PolygonGeometry : QgsWkbTypes::LineGeometry );        if ( mCaptureMode == CapturePolygon )          mTempRubberBand->addPoint( *mRubberBand->getPoint( 0, 0 ), false );        QgsPoint pt = mCaptureCurve.endPoint();        QgsPointXY mapPt = toMapCoordinates( qobject_cast<QgsVectorLayer *>( mCanvas->currentLayer() ), QgsPointXY( pt.x(), pt.y() ) );        mTempRubberBand->addPoint( mapPt );        mTempRubberBand->addPoint( point );        // fix existing rubber band after tracing - the last point may have been moved if using offset        if ( mRubberBand->numberOfVertices() )          mRubberBand->movePoint( mapPt );      }      else        mTempRubberBand->movePoint( point );    }  }} // mouseMoveEvent
开发者ID:alexbruy,项目名称:QGIS,代码行数:46,


示例17: toMapCoordinates

bool QgsMapToolLabel::labelAtPosition( QMouseEvent* e, QgsLabelPosition& p ){  QgsPoint pt = toMapCoordinates( e->pos() );  const QgsLabelingResults* labelingResults = mCanvas->labelingResults();  if ( labelingResults )  {    QList<QgsLabelPosition> labelPosList = labelingResults->labelsAtPosition( pt );    QList<QgsLabelPosition>::const_iterator posIt = labelPosList.constBegin();    if ( posIt != labelPosList.constEnd() )    {      p = *posIt;      return true;    }  }  return false;}
开发者ID:AaronGaim,项目名称:QGIS,代码行数:17,


示例18: toMapCoordinates

bool QgsMapToolLabel::labelAtPosition( QMouseEvent* e, QgsLabelPosition& p ){    QgsPoint pt = toMapCoordinates( e->pos() );    QgsLabelingEngineInterface* labelingEngine = mCanvas->mapRenderer()->labelingEngine();    if ( labelingEngine )    {        QList<QgsLabelPosition> labelPosList = labelingEngine->labelsAtPosition( pt );        QList<QgsLabelPosition>::const_iterator posIt = labelPosList.constBegin();        if ( posIt != labelPosList.constEnd() )        {            p = *posIt;            return true;        }    }    return false;}
开发者ID:rukku,项目名称:Quantum-GIS,代码行数:17,


示例19: QgsRubberBand

void QgsMapToolSelectRadius::canvasMoveEvent( QgsMapMouseEvent* e ){  if ( e->buttons() != Qt::LeftButton )    return;  if ( !mDragging )  {    if ( !mRubberBand )    {      mRubberBand = new QgsRubberBand( mCanvas, QGis::Polygon );      mRubberBand->setFillColor( mFillColor );      mRubberBand->setBorderColor( mBorderColour );    }    mDragging = true;  }  QgsPoint radiusEdge = toMapCoordinates( e->pos() );  setRadiusRubberBand( radiusEdge );}
开发者ID:GavrisAS,项目名称:QGIS,代码行数:18,


示例20: QgsFormAnnotationItem

QgsAnnotationItem* QgsMapToolFormAnnotation::createItem( QMouseEvent* e ){  //try to associate the current vector layer and a feature to the form item  QgsVectorLayer* currentVectorLayer = 0;  if ( mCanvas )  {    QgsMapLayer* mLayer = mCanvas->currentLayer();    if ( mLayer )    {      currentVectorLayer = dynamic_cast<QgsVectorLayer*>( mLayer );    }  }  QgsFormAnnotationItem* formItem = new QgsFormAnnotationItem( mCanvas, currentVectorLayer );  formItem->setMapPosition( toMapCoordinates( e->pos() ) );  formItem->setSelected( true );  formItem->setFrameSize( QSizeF( 200, 100 ) );  return formItem;}
开发者ID:ACorradini,项目名称:QGIS,代码行数:19,


示例21: QgsPointXY

QgsPointXY QgsMapToolCapture::tracingStartPoint(){  try  {    QgsMapLayer *layer = mCanvas->currentLayer();    if ( !layer )      return QgsPointXY();    // if we have starting point from previous trace, then preferably use that one    // (useful when tracing with offset)    if ( mTracingStartPoint != QgsPointXY() )      return mTracingStartPoint;    QgsPoint v = mCaptureCurve.endPoint();    return toMapCoordinates( layer, QgsPointXY( v.x(), v.y() ) );  }  catch ( QgsCsException & )  {    QgsDebugMsg( QStringLiteral( "transformation to layer coordinate failed" ) );    return QgsPointXY();  }}
开发者ID:alexbruy,项目名称:QGIS,代码行数:22,


示例22: QgsRubberBand

QgsRubberBand* QgsMapToolNodeTool::createRubberBandMarker( QgsPoint center, QgsVectorLayer* vlayer ){  //create rubber band marker for moving points  QgsRubberBand* marker = new QgsRubberBand( mCanvas, true );  marker->setColor( Qt::red );  marker->setWidth( 2 );  double movement = 4;  double s = QgsTolerance::toleranceInMapUnits( movement, vlayer, mCanvas->mapRenderer(), QgsTolerance::Pixels );  QgsPoint pom = toMapCoordinates( vlayer, center );  pom.setX( pom.x() - s );  pom.setY( pom.y() - s );  marker->addPoint( pom );  pom.setX( pom.x() + 2*s );  marker->addPoint( pom );  pom.setY( pom.y() + 2*s );  marker->addPoint( pom );  pom.setX( pom.x() - 2*s );  marker->addPoint( pom );  pom.setY( pom.y() - 2*s );  marker->addPoint( pom );  return marker;}
开发者ID:cugxiangzhenwei,项目名称:QGIS_174_VS2008,代码行数:22,


示例23: toMapCoordinates

void QgsMapToolRotateLabel::canvasMoveEvent( QgsMapMouseEvent *e ){  if ( mLabelRubberBand )  {    QgsPointXY currentPoint = toMapCoordinates( e->pos() );    double azimuth = convertAzimuth( mRotationPoint.azimuth( currentPoint ) );    double azimuthDiff = azimuth - mCurrentMouseAzimuth;    azimuthDiff = azimuthDiff > 180 ? azimuthDiff - 360 : azimuthDiff;    mCurrentRotation += azimuthDiff;    if ( mCurrentRotation >= 360 || mCurrentRotation <= -360 )      mCurrentRotation = std::fmod( mCurrentRotation, 360.0 );    if ( mCurrentRotation < 0 )      mCurrentRotation += 360.0;    mCurrentMouseAzimuth = std::fmod( azimuth, 360.0 );    //if shift-modifier is pressed, round to 15 degrees    int displayValue;    if ( e->modifiers() & Qt::ControlModifier )    {      displayValue = roundTo15Degrees( mCurrentRotation );      mCtrlPressed = true;    }    else    {      displayValue = ( int )( mCurrentRotation );      mCtrlPressed = false;    }    if ( mRotationItem )    {      mRotationItem->setSymbolRotation( displayValue );      setRotationPreviewBox( displayValue - mStartRotation );      mRotationItem->update();    }  }}
开发者ID:GeoCat,项目名称:QGIS,代码行数:38,


示例24: QgsRubberBand

void QgsMapToolSelectPolygon::canvasPressEvent( QMouseEvent * e ){  if ( mRubberBand == NULL )  {    mRubberBand = new QgsRubberBand( mCanvas, true );  }  if ( e->button() == Qt::LeftButton )  {    mRubberBand->addPoint( toMapCoordinates( e->pos() ) );  }  else  {    if ( mRubberBand->numberOfVertices() > 2 )    {      QgsGeometry* polygonGeom = mRubberBand->asGeometry();      QgsMapToolSelectUtils::setSelectFeatures( mCanvas, polygonGeom, e );      delete polygonGeom;    }    mRubberBand->reset( true );    delete mRubberBand;    mRubberBand = 0;  }}
开发者ID:aaronr,项目名称:Quantum-GIS,代码行数:23,


示例25: QgsRubberBand

void QgsMapToolSelectPolygon::canvasPressEvent( QgsMapMouseEvent* e ){  if ( !mRubberBand )  {    mRubberBand = new QgsRubberBand( mCanvas, Qgis::Polygon );    mRubberBand->setFillColor( mFillColor );    mRubberBand->setBorderColor( mBorderColour );  }  if ( e->button() == Qt::LeftButton )  {    mRubberBand->addPoint( toMapCoordinates( e->pos() ) );  }  else  {    if ( mRubberBand->numberOfVertices() > 2 )    {      QgsGeometry polygonGeom = mRubberBand->asGeometry();      QgsMapToolSelectUtils::selectMultipleFeatures( mCanvas, polygonGeom, e );    }    mRubberBand->reset( Qgis::Polygon );    delete mRubberBand;    mRubberBand = nullptr;  }}
开发者ID:Zakui,项目名称:QGIS,代码行数:24,


示例26: toMapCoordinates

void QgsMapToolRotateLabel::canvasMoveEvent( QgsMapMouseEvent* e ){  if ( mLabelRubberBand )  {    QgsPoint currentPoint = toMapCoordinates( e->pos() );    double azimuth = azimuthToCCW( mRotationPoint.azimuth( currentPoint ) );    double azimuthDiff = azimuth - mCurrentMouseAzimuth;    azimuthDiff = azimuthDiff > 180 ? azimuthDiff - 360 : azimuthDiff;    mCurrentRotation += azimuthDiff;    mCurrentRotation = mCurrentRotation - static_cast<float>( static_cast<int>( mCurrentRotation / 360 ) ) * 360; //mCurrentRotation % 360;    mCurrentRotation = mCurrentRotation < 0 ? 360 - mCurrentRotation : mCurrentRotation;    mCurrentMouseAzimuth = azimuth - static_cast<float>( static_cast<int>( azimuth / 360 ) ) * 360;    //if shift-modifier is pressed, round to 15 degrees    int displayValue;    if ( e->modifiers() & Qt::ControlModifier )    {      displayValue = roundTo15Degrees( mCurrentRotation );      mCtrlPressed = true;    }    else    {      displayValue = ( int )( mCurrentRotation );      mCtrlPressed = false;    }    if ( mRotationItem )    {      mRotationItem->setSymbolRotation( displayValue );      setRotationPreviewBox( displayValue - mStartRotation );      mRotationItem->update();    }  }}
开发者ID:NyakudyaA,项目名称:QGIS,代码行数:36,


示例27: toMapCoordinates

QgsPoint QgsMapTool::toLayerCoordinates( QgsMapLayer* layer, const QPoint& point ){  QgsPoint pt = toMapCoordinates( point );  return toLayerCoordinates( layer, pt );}
开发者ID:Aladar64,项目名称:QGIS,代码行数:5,


示例28: deleteRubberBands

void QgsMapToolMoveLabel::canvasReleaseEvent( QgsMapMouseEvent* e ){  if ( !mLabelRubberBand )  {    return;  }  deleteRubberBands();  QgsMapLayer* layer = QgsMapLayerRegistry::instance()->mapLayer( mCurrentLabelPos.layerID );  if ( !layer )  {    return;  }  QgsVectorLayer* vlayer = dynamic_cast<QgsVectorLayer*>( layer );  if ( !vlayer )  {    return;  }  if ( !vlayer->isEditable() )  {    return;  }  QgsPoint releaseCoords = toMapCoordinates( e->pos() );  double xdiff = releaseCoords.x() - mStartPointMapCoords.x();  double ydiff = releaseCoords.y() - mStartPointMapCoords.y();  int xCol, yCol;  double xPosOrig, yPosOrig;  bool xSuccess, ySuccess;  if ( !dataDefinedPosition( vlayer, mCurrentLabelPos.featureId, xPosOrig, xSuccess, yPosOrig, ySuccess, xCol, yCol ) )  {    return;  }  double xPosNew, yPosNew;  if ( !xSuccess || !ySuccess )  {    xPosNew = releaseCoords.x() - mClickOffsetX;    yPosNew = releaseCoords.y() - mClickOffsetY;  }  else  {    //transform to map crs first, because xdiff,ydiff are in map coordinates    const QgsMapSettings& ms = mCanvas->mapSettings();    if ( ms.hasCrsTransformEnabled() )    {      QgsPoint transformedPoint = ms.layerToMapCoordinates( vlayer, QgsPoint( xPosOrig, yPosOrig ) );      xPosOrig = transformedPoint.x();      yPosOrig = transformedPoint.y();    }    xPosNew = xPosOrig + xdiff;    yPosNew = yPosOrig + ydiff;  }  //transform back to layer crs  if ( mCanvas )  {    const QgsMapSettings& s = mCanvas->mapSettings();    if ( s.hasCrsTransformEnabled() )    {      QgsPoint transformedPoint = s.mapToLayerCoordinates( vlayer, QgsPoint( xPosNew, yPosNew ) );      xPosNew = transformedPoint.x();      yPosNew = transformedPoint.y();    }  }  vlayer->beginEditCommand( tr( "Moved label" ) + QString( " '%1'" ).arg( currentLabelText( 24 ) ) );  vlayer->changeAttributeValue( mCurrentLabelPos.featureId, xCol, xPosNew );  vlayer->changeAttributeValue( mCurrentLabelPos.featureId, yCol, yPosNew );  // set rotation to that of label, if data-defined and no rotation set yet  // honor whether to preserve preexisting data on pin  // must come after setting x and y positions  int rCol;  if ( !mCurrentLabelPos.isDiagram       && !mCurrentLabelPos.isPinned       && !preserveRotation()       && layerIsRotatable( vlayer, rCol ) )  {    double defRot;    bool rSuccess;    if ( dataDefinedRotation( vlayer, mCurrentLabelPos.featureId, defRot, rSuccess ) )    {      double labelRot = mCurrentLabelPos.rotation * 180 / M_PI;      vlayer->changeAttributeValue( mCurrentLabelPos.featureId, rCol, labelRot );    }  }  vlayer->endEditCommand();  if ( mCanvas )    mCanvas->refresh();}
开发者ID:Antoviscomi,项目名称:QGIS,代码行数:98,


示例29: Q_ASSERT

void QgsMapToolNodeTool::createMovingRubberBands(){  int topologicalEditing = QgsProject::instance()->readNumEntry( "Digitizing", "/TopologicalEditing", 0 );  Q_ASSERT( mSelectedFeature );  QgsVectorLayer *vlayer = mSelectedFeature->vlayer();  Q_ASSERT( vlayer );  QList<QgsVertexEntry*> &vertexMap = mSelectedFeature->vertexMap();  QgsGeometry* geometry = mSelectedFeature->geometry();  int beforeVertex, afterVertex;  int lastRubberBand = 0;  int vertex;  for ( int i = 0; i < vertexMap.size(); i++ )  {    // create rubberband    if ( vertexMap[i]->isSelected() && !vertexMap[i]->isInRubberBand() )    {      geometry->adjacentVertices( i, beforeVertex, afterVertex );      vertex = i;      while ( beforeVertex !=  -1 )      {        // move forward NOTE: end if whole cycle is selected        if ( vertexMap[beforeVertex]->isSelected() && beforeVertex != i ) // and take care of cycles        {          vertex = beforeVertex;          geometry->adjacentVertices( vertex, beforeVertex, afterVertex );        }        else        {          // break if cycle is found          break;        }      }      // we have first vertex of moving part      // create rubberband and set default paramaters      QgsRubberBand* rb = new QgsRubberBand( mCanvas, QGis::Line );      rb->setWidth( 2 );      rb->setColor( Qt::blue );      int index = 0;      if ( beforeVertex != -1 ) // adding first point which is not moving      {        rb->addPoint( toMapCoordinates( vlayer, vertexMap[beforeVertex]->point() ), false );        vertexMap[beforeVertex]->setRubberBandValues( true, lastRubberBand, index );        index++;      }      while ( vertex != -1 && vertexMap[vertex]->isSelected() && !vertexMap[vertex]->isInRubberBand() )      {        // topology rubberband creation if needed        if ( topologicalEditing )        {          createTopologyRubberBands( vlayer, vertexMap, vertex );        }        // adding point which will be moved        rb->addPoint( toMapCoordinates( vlayer, vertexMap[vertex]->point() ), false );        // setting values about added vertex        vertexMap[vertex]->setRubberBandValues( true, lastRubberBand, index );        index++;        geometry->adjacentVertices( vertex, beforeVertex, vertex );      }      if ( vertex != -1 && !vertexMap[vertex]->isSelected() ) // add last point not moving if exists      {        rb->addPoint( toMapCoordinates( vlayer, vertexMap[vertex]->point() ), true );        vertexMap[vertex]->setRubberBandValues( true, lastRubberBand, index );        index++;      }      mRubberBands.append( rb );      lastRubberBand++;    }  }}
开发者ID:ColeCummins,项目名称:QGIS,代码行数:72,



注:本文中的toMapCoordinates函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ toNode函数代码示例
C++ toLocalFrame函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。