Пример #1
0
void QgsComposerItem::setItemRotation( const double r, const bool adjustPosition )
{
  mItemRotation = r;
  if ( mItemRotation >= 360.0 || mItemRotation <= -360.0 )
  {
    mItemRotation = std::fmod( mItemRotation, 360.0 );
  }

  QgsExpressionContext context = createExpressionContext();
  refreshRotation( true, adjustPosition, context );
}
Пример #2
0
void QgsComposerItem::refreshDataDefinedProperty( const QgsComposerObject::DataDefinedProperty property, const QgsExpressionContext *context )
{
  //maintain 2.10 API
  //TODO QGIS 3.0 - remove this
  const QgsExpressionContext* evalContext = context;
  QScopedPointer< QgsExpressionContext > scopedContext;
  if ( !evalContext )
  {
    scopedContext.reset( createExpressionContext() );
    evalContext = scopedContext.data();
  }

  //update data defined properties and redraw item to match
  if ( property == QgsComposerObject::PositionX || property == QgsComposerObject::PositionY ||
       property == QgsComposerObject::ItemWidth || property == QgsComposerObject::ItemHeight ||
       property == QgsComposerObject::AllProperties )
  {
    QRectF beforeRect = QRectF( pos().x(), pos().y(), rect().width(), rect().height() );
    QRectF evaluatedRect = evalItemRect( beforeRect, false, evalContext );
    if ( evaluatedRect != beforeRect )
    {
      setSceneRect( evaluatedRect );
    }
  }
  if ( property == QgsComposerObject::ItemRotation || property == QgsComposerObject::AllProperties )
  {
    refreshRotation( false, true, *evalContext );
  }
  if ( property == QgsComposerObject::Transparency || property == QgsComposerObject::AllProperties )
  {
    refreshTransparency( false, *evalContext );
  }
  if ( property == QgsComposerObject::BlendMode || property == QgsComposerObject::AllProperties )
  {
    refreshBlendMode( *evalContext );
  }
  if ( property == QgsComposerObject::ExcludeFromExports || property == QgsComposerObject::AllProperties )
  {
    bool exclude = mExcludeFromExports;
    //data defined exclude from exports set?
    QVariant exprVal;
    if ( dataDefinedEvaluate( QgsComposerObject::ExcludeFromExports, exprVal, *evalContext ) && !exprVal.isNull() )
    {
      exclude = exprVal.toBool();
    }
    mEvaluatedExcludeFromExports = exclude;
  }

  update();
}
Пример #3
0
void QgsComposerItem::setItemRotation( const double r, const bool adjustPosition )
{
  if ( r >= 360 )
  {
    mItemRotation = ( static_cast< int >( r ) ) % 360;
  }
  else
  {
    mItemRotation = r;
  }

  QScopedPointer< QgsExpressionContext > context( createExpressionContext() );
  refreshRotation( true, adjustPosition, *context.data() );
}
Пример #4
0
void QgsComposerItem::refreshDataDefinedProperty( const QgsComposerObject::DataDefinedProperty property, const QgsExpressionContext *context )
{
  //maintain 2.10 API
  //TODO QGIS 3.0 - remove this
  QgsExpressionContext scopedContext = createExpressionContext();
  const QgsExpressionContext *evalContext = context ? context : &scopedContext;

  //update data defined properties and redraw item to match
  if ( property == QgsComposerObject::PositionX || property == QgsComposerObject::PositionY ||
       property == QgsComposerObject::ItemWidth || property == QgsComposerObject::ItemHeight ||
       property == QgsComposerObject::AllProperties )
  {
    QRectF beforeRect = QRectF( pos().x(), pos().y(), rect().width(), rect().height() );
    QRectF evaluatedRect = evalItemRect( beforeRect, false, evalContext );
    if ( evaluatedRect != beforeRect )
    {
      setSceneRect( evaluatedRect );
    }
  }
  if ( property == QgsComposerObject::ItemRotation || property == QgsComposerObject::AllProperties )
  {
    refreshRotation( false, true, *evalContext );
  }
  if ( property == QgsComposerObject::Opacity || property == QgsComposerObject::AllProperties )
  {
    refreshOpacity( false, *evalContext );
  }
  if ( property == QgsComposerObject::BlendMode || property == QgsComposerObject::AllProperties )
  {
    refreshBlendMode( *evalContext );
  }
  if ( property == QgsComposerObject::FrameColor || property == QgsComposerObject::AllProperties )
  {
    refreshFrameColor( false, *evalContext );
  }
  if ( property == QgsComposerObject::BackgroundColor || property == QgsComposerObject::AllProperties )
  {
    refreshBackgroundColor( false, *evalContext );
  }
  if ( property == QgsComposerObject::ExcludeFromExports || property == QgsComposerObject::AllProperties )
  {
    bool exclude = mExcludeFromExports;
    //data defined exclude from exports set?
    exclude = mDataDefinedProperties.valueAsBool( QgsComposerObject::ExcludeFromExports, *evalContext, exclude );
    mEvaluatedExcludeFromExports = exclude;
  }

  update();
}