• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ createExpressionContext函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: createExpressionContext

void QgsComposerItem::setBlendMode( const QPainter::CompositionMode blendMode )
{
  mBlendMode = blendMode;
  // Update the composer effect to use the new blend mode
  QgsExpressionContext context = createExpressionContext();
  refreshBlendMode( context );
}
开发者ID:exlimit,项目名称:QGIS,代码行数:7,代码来源:qgscomposeritem.cpp


示例2: createExpressionContext

void QgsLayoutItemPicture::refreshPicture( const QgsExpressionContext *context )
{
  QgsExpressionContext scopedContext = createExpressionContext();
  const QgsExpressionContext *evalContext = context ? context : &scopedContext;

  QString source = mSourcePath;

  //data defined source set?
  mHasExpressionError = false;
  if ( mDataDefinedProperties.isActive( QgsLayoutObject::PictureSource ) )
  {
    bool ok = false;
    source = mDataDefinedProperties.valueAsString( QgsLayoutObject::PictureSource, *evalContext, source, &ok );
    if ( ok )
    {
      source = source.trimmed();
      QgsDebugMsg( QString( "exprVal PictureSource:%1" ).arg( source ) );
    }
    else
    {
      mHasExpressionError = true;
      source = QString();
      QgsMessageLog::logMessage( tr( "Picture expression eval error" ) );
    }
  }

  loadPicture( source );
}
开发者ID:cz172638,项目名称:QGIS,代码行数:28,代码来源:qgslayoutitempicture.cpp


示例3: horizontalViewScaleFactor

void QgsComposerNodesItem::drawSelectedNode( QPainter *painter ) const
{
  double rectSize = 3.0 / horizontalViewScaleFactor();

  QgsStringMap properties;
  properties.insert( "name", "square" );
  properties.insert( "color", "0, 0, 0, 0" );
  properties.insert( "color_border", "blue" );
  properties.insert( "width_border", "4" );

  QScopedPointer<QgsMarkerSymbolV2> symbol;
  symbol.reset( QgsMarkerSymbolV2::createSimple( properties ) );
  symbol.data()->setSize( rectSize );

  QgsMapSettings ms = mComposition->mapSettings();
  ms.setOutputDpi( painter->device()->logicalDpiX() );

  QgsRenderContext context = QgsRenderContext::fromMapSettings( ms );
  context.setPainter( painter );
  context.setForceVectorOutput( true );

  QScopedPointer<QgsExpressionContext> expressionContext;
  expressionContext.reset( createExpressionContext() );
  context.setExpressionContext( *expressionContext.data() );

  symbol.data()->startRender( context );
  symbol.data()->renderPoint( mPolygon.at( mSelectedNode ), nullptr, context );
  symbol.data()->stopRender( context );
}
开发者ID:AM7000000,项目名称:QGIS,代码行数:29,代码来源:qgscomposernodesitem.cpp


示例4: context

void QgsComposerItem::setBlendMode( const QPainter::CompositionMode blendMode )
{
  mBlendMode = blendMode;
  // Update the composer effect to use the new blend mode
  QScopedPointer< QgsExpressionContext > context( createExpressionContext() );
  refreshBlendMode( *context.data() );
}
开发者ID:NyakudyaA,项目名称:QGIS,代码行数:7,代码来源:qgscomposeritem.cpp


示例5: createExpressionContext

bool QgsLayoutAtlas::updateFilenameExpression( QString &error )
{
  if ( !mCoverageLayer )
  {
    return false;
  }

  QgsExpressionContext expressionContext = createExpressionContext();

  if ( !mFilenameExpressionString.isEmpty() )
  {
    mFilenameExpression = QgsExpression( mFilenameExpressionString );
    // expression used to evaluate each filename
    // test for evaluation errors
    if ( mFilenameExpression.hasParserError() )
    {
      error = mFilenameExpression.parserErrorString();
      return false;
    }

    // prepare the filename expression
    mFilenameExpression.prepare( &expressionContext );
  }

  // regenerate current filename
  evalFeatureFilename( expressionContext );
  return true;
}
开发者ID:AlisterH,项目名称:Quantum-GIS,代码行数:28,代码来源:qgslayoutatlas.cpp


示例6: horizontalViewScaleFactor

void QgsComposerNodesItem::drawNodes( QPainter *painter ) const
{
  double rectSize = 3.0 / horizontalViewScaleFactor();

  QgsStringMap properties;
  properties.insert( QStringLiteral( "name" ), QStringLiteral( "cross" ) );
  properties.insert( QStringLiteral( "color_border" ), QStringLiteral( "red" ) );

  std::unique_ptr<QgsMarkerSymbol> symbol;
  symbol.reset( QgsMarkerSymbol::createSimple( properties ) );
  symbol->setSize( rectSize );
  symbol->setAngle( 45 );

  QgsRenderContext context = QgsComposerUtils::createRenderContextForComposition( mComposition, painter );
  context.setForceVectorOutput( true );

  QgsExpressionContext expressionContext = createExpressionContext();
  context.setExpressionContext( expressionContext );

  symbol->startRender( context );

  Q_FOREACH ( QPointF pt, mPolygon )
    symbol->renderPoint( pt, nullptr, context );

  symbol->stopRender( context );

  if ( mSelectedNode >= 0 && mSelectedNode < mPolygon.size() )
    drawSelectedNode( painter );
}
开发者ID:wongjimsan,项目名称:QGIS,代码行数:29,代码来源:qgscomposernodesitem.cpp


示例7: createExpressionContext

bool QgsAtlasComposition::updateFilenameExpression()
{
  if ( !mCoverageLayer )
  {
    return false;
  }

  QgsExpressionContext expressionContext = createExpressionContext();

  if ( !mFilenamePattern.isEmpty() )
  {
    mFilenameExpr.reset( new QgsExpression( mFilenamePattern ) );
    // expression used to evaluate each filename
    // test for evaluation errors
    if ( mFilenameExpr->hasParserError() )
    {
      mFilenameParserError = mFilenameExpr->parserErrorString();
      return false;
    }

    // prepare the filename expression
    mFilenameExpr->prepare( &expressionContext );
  }

  //if atlas preview is currently enabled, regenerate filename for current feature
  if ( mComposition->atlasMode() == QgsComposition::PreviewAtlas )
  {
    evalFeatureFilename( expressionContext );
  }
  return true;
}
开发者ID:3liz,项目名称:Quantum-GIS,代码行数:31,代码来源:qgsatlascomposition.cpp


示例8: createExpressionContext

void QgsComposerPolygon::_draw( QPainter *painter )
{
  //setup painter scaling to dots so that raster symbology is drawn to scale
  const double dotsPerMM = painter->device()->logicalDpiX() / 25.4;

  QgsMapSettings ms = mComposition->mapSettings();
  ms.setOutputDpi( painter->device()->logicalDpiX() );

  QgsRenderContext context = QgsRenderContext::fromMapSettings( ms );
  context.setPainter( painter );
  context.setForceVectorOutput( true );

  QScopedPointer<QgsExpressionContext> expressionContext;
  expressionContext.reset( createExpressionContext() );
  context.setExpressionContext( *expressionContext.data() );

  painter->scale( 1 / dotsPerMM, 1 / dotsPerMM ); // scale painter from mm to dots
  QTransform t = QTransform::fromScale( dotsPerMM, dotsPerMM );

  QList<QPolygonF> rings; //empty
  QPainterPath polygonPath;
  polygonPath.addPolygon( mPolygon );

  mPolygonStyleSymbol->startRender( context );
  mPolygonStyleSymbol->renderPolygon( polygonPath.toFillPolygon( t ), &rings,
                                      nullptr, context );
  mPolygonStyleSymbol->stopRender( context );
  painter->scale( dotsPerMM, dotsPerMM );
}
开发者ID:akbargumbira,项目名称:QGIS,代码行数:29,代码来源:qgscomposerpolygon.cpp


示例9: createExpressionContext

void QgsComposerPicture::refreshPicture( const QgsExpressionContext *context )
{
  const QgsExpressionContext* evalContext = context;
  QScopedPointer< QgsExpressionContext > scopedContext;
  if ( !evalContext )
  {
    scopedContext.reset( createExpressionContext() );
    evalContext = scopedContext.data();
  }

  QString source = mSourcePath;

  //data defined source set?
  mHasExpressionError = false;
  QVariant exprVal;
  if ( dataDefinedProperty( QgsComposerObject::PictureSource )->isActive() )
  {
    if ( dataDefinedEvaluate( QgsComposerObject::PictureSource, exprVal, *evalContext ) )
    {
      source = exprVal.toString().trimmed();
      QgsDebugMsg( QString( "exprVal PictureSource:%1" ).arg( source ) );
    }
    else
    {
      mHasExpressionError = true;
      source = QString();
      QgsMessageLog::logMessage( tr( "Picture expression eval error" ) );
    }
  }

  loadPicture( source );
}
开发者ID:AM7000000,项目名称:QGIS,代码行数:32,代码来源:qgscomposerpicture.cpp


示例10: createExpressionContext

void QgsComposerLegend::refreshDataDefinedProperty( const QgsComposerObject::DataDefinedProperty property, const QgsExpressionContext *context )
{
  QgsExpressionContext scopedContext = createExpressionContext();
  const QgsExpressionContext *evalContext = context ? context : &scopedContext;

  bool forceUpdate = false;
  //updates data defined properties and redraws item to match
  if ( property == QgsComposerObject::LegendTitle || property == QgsComposerObject::AllProperties )
  {
    bool ok = false;
    QString t = mDataDefinedProperties.valueAsString( QgsComposerObject::LegendTitle, *evalContext, mTitle, &ok );
    if ( ok )
    {
      mSettings.setTitle( t );
      forceUpdate = true;
    }
  }
  if ( property == QgsComposerObject::LegendColumnCount || property == QgsComposerObject::AllProperties )
  {
    bool ok = false;
    int cols = mDataDefinedProperties.valueAsInt( QgsComposerObject::LegendColumnCount, *evalContext, mColumnCount, &ok );
    if ( ok && cols >= 0 )
    {
      mSettings.setColumnCount( cols );
      forceUpdate = true;
    }
  }
  if ( forceUpdate )
  {
    adjustBoxSize();
    update();
  }

  QgsComposerObject::refreshDataDefinedProperty( property, context );
}
开发者ID:GeoCat,项目名称:QGIS,代码行数:35,代码来源:qgscomposerlegend.cpp


示例11: createExpressionContext

void QgsActionManager::doAction( int index, const QgsFeature& feat, int defaultValueIndex )
{
  QgsExpressionContext context = createExpressionContext();
  QgsExpressionContextScope* actionScope = new QgsExpressionContextScope();
  actionScope->setVariable( "current_field", feat.attribute( defaultValueIndex ) );
  context << actionScope;
  doAction( index, feat, context );
}
开发者ID:AM7000000,项目名称:QGIS,代码行数:8,代码来源:qgsactionmanager.cpp


示例12: setBrush

void QgsComposerItem::setBackgroundColor( const QColor &backgroundColor )
{
  mBackgroundColor = backgroundColor;
  setBrush( QBrush( mBackgroundColor, Qt::SolidPattern ) );
  // apply any datadefined overrides
  QgsExpressionContext context = createExpressionContext();
  refreshBackgroundColor( true, context );
}
开发者ID:exlimit,项目名称:QGIS,代码行数:8,代码来源:qgscomposeritem.cpp


示例13: while

QString QgsAttributeAction::expandAction( QString action, QgsFeature &feat, const QMap<QString, QVariant> *substitutionMap )
{
  // This function currently replaces each expression between [% and %]
  // in the action with the result of its evaluation on the feature
  // passed as argument.

  // Additional substitutions can be passed through the substitutionMap
  // parameter

  QString expr_action;

  int index = 0;
  while ( index < action.size() )
  {
    QRegExp rx = QRegExp( "\\[%([^\\]]+)%\\]" );

    int pos = rx.indexIn( action, index );
    if ( pos < 0 )
      break;

    int start = index;
    index = pos + rx.matchedLength();

    QString to_replace = rx.cap( 1 ).trimmed();
    QgsDebugMsg( "Found expression: " + to_replace );

    if ( substitutionMap && substitutionMap->contains( to_replace ) )
    {
      expr_action += action.mid( start, pos - start ) + substitutionMap->value( to_replace ).toString();
      continue;
    }

    QgsExpression exp( to_replace );
    if ( exp.hasParserError() )
    {
      QgsDebugMsg( "Expression parser error: " + exp.parserErrorString() );
      expr_action += action.mid( start, index - start );
      continue;
    }

    QgsExpressionContext context = createExpressionContext();
    context.setFeature( feat );

    QVariant result = exp.evaluate( &context );
    if ( exp.hasEvalError() )
    {
      QgsDebugMsg( "Expression parser eval error: " + exp.evalErrorString() );
      expr_action += action.mid( start, index - start );
      continue;
    }

    QgsDebugMsg( "Expression result is: " + result.toString() );
    expr_action += action.mid( start, pos - start ) + result.toString();
  }

  expr_action += action.mid( index );
  return expr_action;
}
开发者ID:redwoodxiao,项目名称:QGIS,代码行数:58,代码来源:qgsattributeaction.cpp


示例14: replaceDateText

QString QgsComposerLabel::displayText() const
{
  QString displayText = mText;
  replaceDateText( displayText );

  QgsExpressionContext context = createExpressionContext();

  return QgsExpression::replaceExpressionText( displayText, &context, mDistanceArea );
}
开发者ID:ndavid,项目名称:QGIS,代码行数:9,代码来源:qgscomposerlabel.cpp


示例15: replaceDateText

QString QgsLayoutItemLabel::currentText() const
{
  QString displayText = mText;
  replaceDateText( displayText );

  QgsExpressionContext context = createExpressionContext();

  return QgsExpression::replaceExpressionText( displayText, &context, mDistanceArea.get() );
}
开发者ID:digitalsatori,项目名称:QGIS,代码行数:9,代码来源:qgslayoutitemlabel.cpp


示例16: Q_UNUSED

void QgsPaperItem::paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget )
{
  Q_UNUSED( itemStyle );
  Q_UNUSED( pWidget );
  if ( !painter || !mComposition || !mComposition->pagesVisible() )
  {
    return;
  }

  //setup painter scaling to dots so that raster symbology is drawn to scale
  double dotsPerMM = painter->device()->logicalDpiX() / 25.4;

  //setup render context
  QgsMapSettings ms = mComposition->mapSettings();
  //context units should be in dots
  ms.setOutputDpi( painter->device()->logicalDpiX() );
  QgsRenderContext context = QgsRenderContext::fromMapSettings( ms );
  context.setPainter( painter );
  context.setForceVectorOutput( true );
  QgsExpressionContext* expressionContext = createExpressionContext();
  context.setExpressionContext( *expressionContext );
  delete expressionContext;

  painter->save();

  if ( mComposition->plotStyle() ==  QgsComposition::Preview )
  {
    //if in preview mode, draw page border and shadow so that it's
    //still possible to tell where pages with a transparent style begin and end
    painter->setRenderHint( QPainter::Antialiasing, false );

    //shadow
    painter->setBrush( QBrush( QColor( 150, 150, 150 ) ) );
    painter->setPen( Qt::NoPen );
    painter->drawRect( QRectF( 1, 1, rect().width() + 1, rect().height() + 1 ) );

    //page area
    painter->setBrush( QColor( 215, 215, 215 ) );
    painter->setPen( QPen( QColor( 100, 100, 100 ) ) );
    painter->drawRect( QRectF( 0, 0, rect().width(), rect().height() ) );
  }

  painter->scale( 1 / dotsPerMM, 1 / dotsPerMM ); // scale painter from mm to dots

  painter->setRenderHint( QPainter::Antialiasing );
  mComposition->pageStyleSymbol()->startRender( context );

  calculatePageMargin();
  QPolygonF pagePolygon = QPolygonF( QRectF( mPageMargin * dotsPerMM, mPageMargin * dotsPerMM,
                                     ( rect().width() - 2 * mPageMargin ) * dotsPerMM, ( rect().height() - 2 * mPageMargin ) * dotsPerMM ) );
  QList<QPolygonF> rings; //empty list

  mComposition->pageStyleSymbol()->renderPolygon( pagePolygon, &rings, nullptr, context );
  mComposition->pageStyleSymbol()->stopRender( context );
  painter->restore();
}
开发者ID:cevmartinez,项目名称:QGIS,代码行数:56,代码来源:qgspaperitem.cpp


示例17: createExpressionContext

void QgsLayoutItemHtml::refreshDataDefinedProperty( const QgsLayoutObject::DataDefinedProperty property )
{
  QgsExpressionContext context = createExpressionContext();

  //updates data defined properties and redraws item to match
  if ( property == QgsLayoutObject::SourceUrl || property == QgsLayoutObject::AllProperties )
  {
    loadHtml( true, &context );
  }
}
开发者ID:minorua,项目名称:QGIS,代码行数:10,代码来源:qgslayoutitemhtml.cpp


示例18: context

void QgsComposerObject::prepareDataDefinedExpressions() const
{
  QScopedPointer< QgsExpressionContext > context( createExpressionContext() );

  //prepare all QgsDataDefineds
  QMap< DataDefinedProperty, QgsDataDefined* >::const_iterator it = mDataDefinedProperties.constBegin();
  if ( it != mDataDefinedProperties.constEnd() )
  {
    it.value()->prepareExpression( *context.data() );
  }
}
开发者ID:AM7000000,项目名称:QGIS,代码行数:11,代码来源:qgscomposerobject.cpp


示例19: createExpressionContext

void QgsActionManager::doAction( const QUuid& actionId, const QgsFeature& feature, int defaultValueIndex )
{
  QgsExpressionContext context = createExpressionContext();
  QgsExpressionContextScope* actionScope = new QgsExpressionContextScope();
  actionScope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "field_index" ), defaultValueIndex, true ) );
  if ( defaultValueIndex >= 0 && defaultValueIndex < feature.fields().size() )
    actionScope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "field_name" ), feature.fields().at( defaultValueIndex ).name(), true ) );
  actionScope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "field_value" ), feature.attribute( defaultValueIndex ), true ) );
  context << actionScope;
  doAction( actionId, feature, context );
}
开发者ID:Gustry,项目名称:QGIS,代码行数:11,代码来源:qgsactionmanager.cpp


示例20: createExpressionContext

void QgsComposerHtml::refreshDataDefinedProperty( const QgsComposerObject::DataDefinedProperty property, const QgsExpressionContext* context )
{
  QgsExpressionContext scopedContext = createExpressionContext();
  const QgsExpressionContext* evalContext = context ? context : &scopedContext;


  //updates data defined properties and redraws item to match
  if ( property == QgsComposerObject::SourceUrl || property == QgsComposerObject::AllProperties )
  {
    loadHtml( true, evalContext );
  }
  QgsComposerObject::refreshDataDefinedProperty( property, context );
}
开发者ID:mterente,项目名称:QGIS,代码行数:13,代码来源:qgscomposerhtml.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ createFile函数代码示例发布时间:2022-05-30
下一篇:
C++ createError函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap