void QgsQuickPrint::scaleTextLabels( int theScaleFactor, SymbolScalingType theDirection ) { if ( 0 >= theScaleFactor ) { QgsDebugMsg( "invalid scale factor" ); return; } QStringList myLayerSet = mpMapRenderer->layerSet(); QStringListIterator myLayerIterator( myLayerSet ); while ( myLayerIterator.hasNext() ) { QString myLayerId = myLayerIterator.next(); QgsDebugMsg( "Scaling text labels for print for " + myLayerId ); QgsMapLayer * mypLayer = QgsMapLayerRegistry::instance()->mapLayer( myLayerId ); if ( mypLayer ) { QgsVectorLayer *mypVectorLayer = qobject_cast<QgsVectorLayer *>( mypLayer ); if ( mypVectorLayer ) { QgsLabel * mypLabel = mypVectorLayer->label(); QgsLabelAttributes * mypLabelAttributes = mypLabel->labelAttributes(); if ( theDirection == ScaleUp ) { mypLabelAttributes->setSize( mypLabelAttributes->size() * theScaleFactor, mypLabelAttributes->sizeType() ); } else //scale down { mypLabelAttributes->setSize( mypLabelAttributes->size() / theScaleFactor, mypLabelAttributes->sizeType() ); } } //if vectorlayer } //if maplayer } //layer iterator }
void QgsLabelDialog::apply() { QgsDebugMsg( "entering." ); //set the label props that are NOT bound to a field in the attributes tbl //All of these are set in the labelAttributes member of the layer QgsLabelAttributes * myLabelAttributes = mLabel->labelAttributes(); myLabelAttributes->setText( leDefaultLabel->text() ); myLabelAttributes->setFamily( mFont.family() ); int myTypeInt = cboFontSizeUnits->currentIndex() == 0 ? QgsLabelAttributes::PointUnits : QgsLabelAttributes::MapUnits; myLabelAttributes->setSize( mFont.pointSizeF(), myTypeInt ); myLabelAttributes->setBold( mFont.bold() ); myLabelAttributes->setItalic( mFont.italic() ); myLabelAttributes->setUnderline( mFont.underline() ); myLabelAttributes->setStrikeOut( mFont.strikeOut() ); myLabelAttributes->setColor( mFontColor ); myTypeInt = cboOffsetUnits->currentIndex() == 0 ? QgsLabelAttributes::PointUnits : QgsLabelAttributes::MapUnits; myLabelAttributes->setOffset( spinXOffset->value(), spinYOffset->value(), myTypeInt ); myLabelAttributes->setAutoAngle( spinAngle->value() == -1 ); myLabelAttributes->setAngle( spinAngle->value() ); //the values here may seem a bit counterintuitive - basically everything //is the reverse of the way you think it should be... //TODO investigate in QgsLabel why this needs to be the case if ( radioAboveLeft->isChecked() ) myLabelAttributes->setAlignment( Qt::AlignRight | Qt::AlignBottom ); if ( radioBelowLeft->isChecked() ) myLabelAttributes->setAlignment( Qt::AlignRight | Qt::AlignTop ); if ( radioAboveRight->isChecked() ) myLabelAttributes->setAlignment( Qt::AlignLeft | Qt::AlignBottom ); if ( radioBelowRight->isChecked() ) myLabelAttributes->setAlignment( Qt::AlignLeft | Qt::AlignTop ); if ( radioLeft->isChecked() ) myLabelAttributes->setAlignment( Qt::AlignRight | Qt::AlignVCenter ); if ( radioRight->isChecked() ) myLabelAttributes->setAlignment( Qt::AlignLeft | Qt::AlignVCenter ); if ( radioAbove->isChecked() ) myLabelAttributes->setAlignment( Qt::AlignBottom | Qt::AlignHCenter ); if ( radioBelow->isChecked() ) myLabelAttributes->setAlignment( Qt::AlignTop | Qt::AlignHCenter ); if ( radioOver->isChecked() ) myLabelAttributes->setAlignment( Qt::AlignCenter ); myLabelAttributes->setMultilineEnabled( chkUseMultiline->isChecked() ); myLabelAttributes->setSelectedOnly( chkSelectedOnly->isChecked() ); myLabelAttributes->setBufferEnabled( chkUseBuffer->isChecked() ); myLabelAttributes->setBufferColor( mBufferColor ); myTypeInt = cboBufferSizeUnits->currentIndex() == 0 ? QgsLabelAttributes::PointUnits : QgsLabelAttributes::MapUnits; myLabelAttributes->setBufferSize( spinBufferSize->value(), myTypeInt ); //TODO - transparency attributes for buffers //set the label props that are data bound to a field in the attributes tbl mLabel->setLabelField( QgsLabel::Text, fieldIndexFromName( cboLabelField->currentText() ) ); mLabel->setLabelField( QgsLabel::Family, fieldIndexFromName( cboFontField->currentText() ) ); mLabel->setLabelField( QgsLabel::Bold, fieldIndexFromName( cboBoldField->currentText() ) ); mLabel->setLabelField( QgsLabel::Italic, fieldIndexFromName( cboItalicField->currentText() ) ); mLabel->setLabelField( QgsLabel::Underline, fieldIndexFromName( cboUnderlineField->currentText() ) ); mLabel->setLabelField( QgsLabel::StrikeOut, fieldIndexFromName( cboStrikeOutField->currentText() ) ); mLabel->setLabelField( QgsLabel::Size, fieldIndexFromName( cboFontSizeField->currentText() ) ); mLabel->setLabelField( QgsLabel::SizeType, fieldIndexFromName( cboFontSizeTypeField->currentText() ) ); mLabel->setLabelField( QgsLabel::Color, fieldIndexFromName( cboFontColorField->currentText() ) ); mLabel->setLabelField( QgsLabel::BufferSize, fieldIndexFromName( cboBufferSizeField->currentText() ) ); //mLabel->setLabelField( QgsLabel::BufferTransparency, cboBufferTransparencyField->currentText() ); mLabel->setLabelField( QgsLabel::XCoordinate, fieldIndexFromName( cboXCoordinateField->currentText() ) ); mLabel->setLabelField( QgsLabel::YCoordinate, fieldIndexFromName( cboYCoordinateField->currentText() ) ); mLabel->setLabelField( QgsLabel::XOffset, fieldIndexFromName( cboXOffsetField->currentText() ) ); mLabel->setLabelField( QgsLabel::YOffset, fieldIndexFromName( cboYOffsetField->currentText() ) ); mLabel->setLabelField( QgsLabel::Alignment, fieldIndexFromName( cboAlignmentField->currentText() ) ); mLabel->setLabelField( QgsLabel::Angle, fieldIndexFromName( cboAngleField->currentText() ) ); // set up the scale based layer visibility stuff.... mLabel->setScaleBasedVisibility( chkUseScaleDependentRendering->isChecked() ); mLabel->setMinScale( leMinimumScale->text().toFloat() ); mLabel->setMaxScale( leMaximumScale->text().toFloat() ); }