示例#1
0
void QgsMapToolRotateFeature::canvasMoveEvent( QgsMapMouseEvent* e )
{
  if ( mRotationActive )
  {
    const double XDistance = e->pos().x() - mStPoint.x();
    const double YDistance = e->pos().y() - mStPoint.y();
    double rotation = atan2( YDistance, XDistance ) * ( 180 / PI );

    if ( mRotationWidget )
    {
      mRotationWidget->setAngle( rotation - mRotationOffset );
      mRotationWidget->setFocus( Qt::TabFocusReason );
    }
    else
    {
      updateRubberband( rotation - mRotationOffset );
    }
  }
}
void QgsMapToolRotateFeature::canvasMoveEvent( QgsMapMouseEvent *e )
{
  if ( mRotationActive )
  {
    const double XDistance = e->pos().x() - mStPoint.x();
    const double YDistance = e->pos().y() - mStPoint.y();
    double rotation = std::atan2( YDistance, XDistance ) * ( 180 / M_PI ) - mRotationOffset;

    if ( mRotationWidget )
    {
      disconnect( mRotationWidget, &QgsAngleMagnetWidget::angleChanged, this, &QgsMapToolRotateFeature::updateRubberband );
      mRotationWidget->setAngle( rotation );
      mRotationWidget->setFocus( Qt::TabFocusReason );
      mRotationWidget->editor()->selectAll();
      connect( mRotationWidget, &QgsAngleMagnetWidget::angleChanged, this, &QgsMapToolRotateFeature::updateRubberband );
      if ( mRotationWidget->magnet() )
      {
        rotation = mRotationWidget->angle();
      }
    }
    updateRubberband( rotation );
  }
}