コード例 #1
0
QgsComposerLabel::QgsComposerLabel( QgsComposition *composition ):
    QgsComposerItem( composition ), mHtmlState( 0 ), mHtmlUnitsToMM( 1.0 ),
    mHtmlLoaded( false ), mMargin( 1.0 ), mFontColor( QColor( 0, 0, 0 ) ),
    mHAlignment( Qt::AlignLeft ), mVAlignment( Qt::AlignTop ),
    mExpressionFeature( 0 ), mExpressionLayer( 0 )
{
  mHtmlUnitsToMM = htmlUnitsToMM();

  //get default composer font from settings
  QSettings settings;
  QString defaultFontString = settings.value( "/Composer/defaultFont" ).toString();
  if ( !defaultFontString.isEmpty() )
  {
    mFont.setFamily( defaultFontString );
  }

  //default to a 10 point font size
  mFont.setPointSizeF( 10 );

  //default to no background
  setBackgroundEnabled( false );

  if ( mComposition && mComposition->atlasMode() == QgsComposition::PreviewAtlas )
  {
    //a label added while atlas preview is enabled needs to have the expression context set,
    //otherwise fields in the label aren't correctly evaluated until atlas preview feature changes (#9457)
    setExpressionContext( mComposition->atlasComposition().currentFeature(), mComposition->atlasComposition().coverageLayer() );
  }

  //connect to atlas feature changes
  //to update the expression context
  connect( &mComposition->atlasComposition(), SIGNAL( featureChanged( QgsFeature* ) ), this, SLOT( refreshExpressionContext() ) );

}
コード例 #2
0
void QgsLayoutItemScaleBar::applyDefaultSettings()
{
  //style
  mStyle = qgis::make_unique< QgsSingleBoxScaleBarRenderer >();

  //default to no background
  setBackgroundEnabled( false );

  //get default composer font from settings
  QgsSettings settings;
  QString defaultFontString = settings.value( QStringLiteral( "LayoutDesigner/defaultFont" ), QVariant(), QgsSettings::Gui ).toString();
  QgsTextFormat format;
  QFont f;
  if ( !defaultFontString.isEmpty() )
  {
    f.setFamily( defaultFontString );
  }
  format.setFont( f );
  format.setSize( 12.0 );
  format.setSizeUnit( QgsUnitTypes::RenderPoints );

  mSettings.setTextFormat( format );

  mSettings.setUnits( QgsUnitTypes::DistanceUnknownUnit );
  refreshItemSize();

  emit changed();
}
コード例 #3
0
ファイル: qgscomposerframe.cpp プロジェクト: ACorradini/QGIS
QgsComposerFrame::QgsComposerFrame()
    : QgsComposerItem( 0, 0, 0, 0, 0 )
    , mMultiFrame( 0 )
    , mHidePageIfEmpty( false )
    , mHideBackgroundIfEmpty( false )
{
  //default to no background
  setBackgroundEnabled( false );
}
コード例 #4
0
ファイル: qgscomposerlabel.cpp プロジェクト: Gustry/QGIS
QgsComposerLabel::QgsComposerLabel( QgsComposition *composition )
    : QgsComposerItem( composition )
    , mHtmlState( 0 )
    , mHtmlUnitsToMM( 1.0 )
    , mHtmlLoaded( false )
    , mMarginX( 1.0 )
    , mMarginY( 1.0 )
    , mFontColor( QColor( 0, 0, 0 ) )
    , mHAlignment( Qt::AlignLeft )
    , mVAlignment( Qt::AlignTop )
    , mExpressionLayer( nullptr )
    , mDistanceArea( nullptr )
{
  mDistanceArea = new QgsDistanceArea();
  mHtmlUnitsToMM = htmlUnitsToMM();

  //get default composer font from settings
  QSettings settings;
  QString defaultFontString = settings.value( QStringLiteral( "/Composer/defaultFont" ) ).toString();
  if ( !defaultFontString.isEmpty() )
  {
    mFont.setFamily( defaultFontString );
  }

  //default to a 10 point font size
  mFont.setPointSizeF( 10 );

  //default to no background
  setBackgroundEnabled( false );

  //a label added while atlas preview is enabled needs to have the expression context set,
  //otherwise fields in the label aren't correctly evaluated until atlas preview feature changes (#9457)
  refreshExpressionContext();

  if ( mComposition )
  {
    //connect to atlas feature changes
    //to update the expression context
    connect( &mComposition->atlasComposition(), SIGNAL( featureChanged( QgsFeature* ) ), this, SLOT( refreshExpressionContext() ) );
  }

  mWebPage = new QgsWebPage( this );
  mWebPage->setIdentifier( tr( "Composer label item" ) );
  mWebPage->setNetworkAccessManager( QgsNetworkAccessManager::instance() );

  //This makes the background transparent. Found on http://blog.qt.digia.com/blog/2009/06/30/transparent-qwebview-or-qwebpage/
  QPalette palette = mWebPage->palette();
  palette.setBrush( QPalette::Base, Qt::transparent );
  mWebPage->setPalette( palette );
  //webPage->setAttribute(Qt::WA_OpaquePaintEvent, false); //this does not compile, why ?

  mWebPage->mainFrame()->setZoomFactor( 10.0 );
  mWebPage->mainFrame()->setScrollBarPolicy( Qt::Horizontal, Qt::ScrollBarAlwaysOff );
  mWebPage->mainFrame()->setScrollBarPolicy( Qt::Vertical, Qt::ScrollBarAlwaysOff );

  connect( mWebPage, SIGNAL( loadFinished( bool ) ), SLOT( loadingHtmlFinished( bool ) ) );
}
コード例 #5
0
void QgsComposerArrow::init()
{
  setArrowHeadWidth( 4 );
  mPen.setColor( mArrowHeadOutlineColor );
  mPen.setWidthF( 1 );
  mBrush.setColor( mArrowHeadFillColor );
  createDefaultLineSymbol();

  //default to no background
  setBackgroundEnabled( false );
}
コード例 #6
0
ファイル: qgscomposerpicture.cpp プロジェクト: Asjad27/QGIS
void QgsComposerPicture::init()
{
  //default to no background
  setBackgroundEnabled( false );

  //connect some signals

  //connect to atlas feature changing
  //to update the picture source expression
  connect( &mComposition->atlasComposition(), SIGNAL( featureChanged( QgsFeature* ) ), this, SLOT( refreshPicture() ) );

  //connect to composer print resolution changing
  connect( mComposition, SIGNAL( printResolutionChanged() ), this, SLOT( recalculateSize() ) );
}
コード例 #7
0
void QgsComposerPicture::init()
{
  //default to no background
  setBackgroundEnabled( false );

  //data defined strings
  mDataDefinedNames.insert( QgsComposerObject::PictureSource, QStringLiteral( "dataDefinedSource" ) );

  //connect some signals

  //connect to atlas feature changing
  //to update the picture source expression
  connect( &mComposition->atlasComposition(), SIGNAL( featureChanged( QgsFeature* ) ), this, SLOT( refreshPicture() ) );

  //connect to composer print resolution changing
  connect( mComposition, SIGNAL( printResolutionChanged() ), this, SLOT( recalculateSize() ) );
}
コード例 #8
0
ファイル: qgscomposerframe.cpp プロジェクト: ACorradini/QGIS
QgsComposerFrame::QgsComposerFrame( QgsComposition* c, QgsComposerMultiFrame* mf, qreal x, qreal y, qreal width, qreal height )
    : QgsComposerItem( x, y, width, height, c )
    , mMultiFrame( mf )
    , mHidePageIfEmpty( false )
    , mHideBackgroundIfEmpty( false )
{

  //default to no background
  setBackgroundEnabled( false );

  //repaint frame when multiframe content changes
  connect( mf, SIGNAL( contentsChanged() ), this, SLOT( repaint() ) );
  if ( mf )
  {
    //force recalculation of rect, so that multiframe specified sizes can be applied
    setSceneRect( QRectF( pos().x(), pos().y(), rect().width(), rect().height() ) );
  }
}
コード例 #9
0
QgsLayoutItemPicture::QgsLayoutItemPicture( QgsLayout *layout )
  : QgsLayoutItem( layout )
{
  //default to no background
  setBackgroundEnabled( false );

  //connect some signals

#if 0 //TODO
  //connect to atlas feature changing
  //to update the picture source expression
  connect( &mComposition->atlasComposition(), &QgsAtlasComposition::featureChanged, this, [ = ] { refreshPicture(); } );

  //connect to layout print resolution changing
  connect( layout->context(), &QgsLayoutContext::printResolutionChanged, this, &QgsLayoutItemPicture::recalculateSize );
#endif

  connect( this, &QgsLayoutItem::sizePositionChanged, this, &QgsLayoutItemPicture::shapeChanged );
}
コード例 #10
0
void QgsComposerScaleBar::applyDefaultSettings()
{
  mNumSegments = 2;
  mNumSegmentsLeft = 0;

  mNumMapUnitsPerScaleBarUnit = 1.0;

  //style
  delete mStyle;
  mStyle = new QgsSingleBoxScaleBarStyle( this );

  mHeight = 3;

  //default to no background
  setBackgroundEnabled( false );

  mPen = QPen( Qt::black );
  mPen.setJoinStyle( mLineJoinStyle );
  mPen.setCapStyle( mLineCapStyle );
  mPen.setWidthF( 1.0 );

  mBrush.setColor( Qt::black );
  mBrush.setStyle( Qt::SolidPattern );

  mBrush2.setColor( Qt::white );
  mBrush2.setStyle( Qt::SolidPattern );

  //get default composer font from settings
  QSettings settings;
  QString defaultFontString = settings.value( "/Composer/defaultFont" ).toString();
  if ( !defaultFontString.isEmpty() )
  {
    mFont.setFamily( defaultFontString );
  }
  mFont.setPointSizeF( 12.0 );
  mFontColor = QColor( 0, 0, 0 );

  mLabelBarSpace = 3.0;
  mBoxContentSpace = 1.0;
  emit itemChanged();
}
コード例 #11
0
ファイル: qgscomposerpicture.cpp プロジェクト: AM7000000/QGIS
void QgsComposerPicture::init()
{
  //default to no background
  setBackgroundEnabled( false );

  //data defined strings
  mDataDefinedNames.insert( QgsComposerObject::PictureSource, QString( "dataDefinedSource" ) );

  //insert PictureSource data defined property (only required due to deprecated API elements,
  //remove after 3.0
  setDataDefinedProperty( QgsComposerObject::PictureSource, false, true, QString(), QString() );

  //connect some signals

  //connect to atlas feature changing
  //to update the picture source expression
  connect( &mComposition->atlasComposition(), SIGNAL( featureChanged( QgsFeature* ) ), this, SLOT( refreshPicture() ) );

  //connect to composer print resolution changing
  connect( mComposition, SIGNAL( printResolutionChanged() ), this, SLOT( recalculateSize() ) );
}
コード例 #12
0
ファイル: qgslayoutframe.cpp プロジェクト: alexbruy/QGIS
QgsLayoutFrame::QgsLayoutFrame( QgsLayout *layout, QgsLayoutMultiFrame *multiFrame )
  : QgsLayoutItem( layout )
  , mMultiFrame( multiFrame )
  , mMultiFrameUuid( multiFrame ? multiFrame->uuid() : QString() )
{

  //default to no background
  setBackgroundEnabled( false );

  if ( multiFrame )
  {
    //repaint frame when multiframe content changes
    connect( multiFrame, &QgsLayoutMultiFrame::contentsChanged, this, [ = ]
    {
      update();
    } );

    //force recalculation of rect, so that multiframe specified sizes can be applied
    refreshItemSize();
  }
}
コード例 #13
0
QgsLayoutItemShape::QgsLayoutItemShape( QgsLayout *layout )
  : QgsLayoutItem( layout )
  , mCornerRadius( 0 )
{
  setBackgroundEnabled( false );
  setFrameEnabled( false );
  QgsStringMap properties;
  properties.insert( QStringLiteral( "color" ), QStringLiteral( "white" ) );
  properties.insert( QStringLiteral( "style" ), QStringLiteral( "solid" ) );
  properties.insert( QStringLiteral( "style_border" ), QStringLiteral( "solid" ) );
  properties.insert( QStringLiteral( "color_border" ), QStringLiteral( "black" ) );
  properties.insert( QStringLiteral( "width_border" ), QStringLiteral( "0.3" ) );
  properties.insert( QStringLiteral( "joinstyle" ), QStringLiteral( "miter" ) );
  mShapeStyleSymbol.reset( QgsFillSymbol::createSimple( properties ) );
  refreshSymbol();

  connect( this, &QgsLayoutItemShape::sizePositionChanged, this, [ = ]
  {
    updateBoundingRect();
    update();
  } );
}
コード例 #14
0
QgsLayoutItemLabel::QgsLayoutItemLabel( QgsLayout *layout )
  : QgsLayoutItem( layout )
{
  mDistanceArea.reset( new QgsDistanceArea() );
  mHtmlUnitsToLayoutUnits = htmlUnitsToLayoutUnits();

  //get default layout font from settings
  QgsSettings settings;
  QString defaultFontString = settings.value( QStringLiteral( "LayoutDesigner/defaultFont" ), QVariant(), QgsSettings::Gui ).toString();
  if ( !defaultFontString.isEmpty() )
  {
    mFont.setFamily( defaultFontString );
  }

  //default to a 10 point font size
  mFont.setPointSizeF( 10 );

  //default to no background
  setBackgroundEnabled( false );

  //a label added while atlas preview is enabled needs to have the expression context set,
  //otherwise fields in the label aren't correctly evaluated until atlas preview feature changes (#9457)
  refreshExpressionContext();

  mWebPage.reset( new QgsWebPage( this ) );
  mWebPage->setIdentifier( tr( "Layout label item" ) );
  mWebPage->setNetworkAccessManager( QgsNetworkAccessManager::instance() );

  //This makes the background transparent. Found on http://blog.qt.digia.com/blog/2009/06/30/transparent-qwebview-or-qwebpage/
  QPalette palette = mWebPage->palette();
  palette.setBrush( QPalette::Base, Qt::transparent );
  mWebPage->setPalette( palette );

  mWebPage->mainFrame()->setZoomFactor( 10.0 );
  mWebPage->mainFrame()->setScrollBarPolicy( Qt::Horizontal, Qt::ScrollBarAlwaysOff );
  mWebPage->mainFrame()->setScrollBarPolicy( Qt::Vertical, Qt::ScrollBarAlwaysOff );

  connect( mWebPage.get(), &QWebPage::loadFinished, this, &QgsLayoutItemLabel::loadingHtmlFinished );
}