mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-15 00:02:52 -04:00
Fix for some font size problems and for loading composer scalebar from xml
git-svn-id: http://svn.osgeo.org/qgis/trunk@9237 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
0ecb47fc31
commit
d21134dc27
@ -1422,6 +1422,9 @@ void QgsComposer::readXML( const QDomDocument& doc )
|
|||||||
addComposerLabel( newLabel );
|
addComposerLabel( newLabel );
|
||||||
mComposition->addItem( newLabel );
|
mComposition->addItem( newLabel );
|
||||||
mComposition->update();
|
mComposition->update();
|
||||||
|
mComposition->clearSelection();
|
||||||
|
newLabel->setSelected(true);
|
||||||
|
showItemOptions(newLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
//composer maps
|
//composer maps
|
||||||
@ -1434,6 +1437,9 @@ void QgsComposer::readXML( const QDomDocument& doc )
|
|||||||
addComposerMap( newMap );
|
addComposerMap( newMap );
|
||||||
mComposition->addItem( newMap );
|
mComposition->addItem( newMap );
|
||||||
mComposition->update();
|
mComposition->update();
|
||||||
|
mComposition->clearSelection();
|
||||||
|
newMap->setSelected(true);
|
||||||
|
showItemOptions(newMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
//composer scalebars
|
//composer scalebars
|
||||||
@ -1446,6 +1452,9 @@ void QgsComposer::readXML( const QDomDocument& doc )
|
|||||||
addComposerScaleBar( newScaleBar );
|
addComposerScaleBar( newScaleBar );
|
||||||
mComposition->addItem( newScaleBar );
|
mComposition->addItem( newScaleBar );
|
||||||
mComposition->update();
|
mComposition->update();
|
||||||
|
mComposition->clearSelection();
|
||||||
|
newScaleBar->setSelected(true);
|
||||||
|
showItemOptions(newScaleBar);
|
||||||
}
|
}
|
||||||
|
|
||||||
//composer legends
|
//composer legends
|
||||||
@ -1458,6 +1467,9 @@ void QgsComposer::readXML( const QDomDocument& doc )
|
|||||||
addComposerLegend( newLegend );
|
addComposerLegend( newLegend );
|
||||||
mComposition->addItem( newLegend );
|
mComposition->addItem( newLegend );
|
||||||
mComposition->update();
|
mComposition->update();
|
||||||
|
mComposition->clearSelection();
|
||||||
|
newLegend->setSelected(true);
|
||||||
|
showItemOptions(newLegend);
|
||||||
}
|
}
|
||||||
|
|
||||||
//composer pictures
|
//composer pictures
|
||||||
@ -1470,6 +1482,9 @@ void QgsComposer::readXML( const QDomDocument& doc )
|
|||||||
addComposerPicture( newPicture );
|
addComposerPicture( newPicture );
|
||||||
mComposition->addItem( newPicture );
|
mComposition->addItem( newPicture );
|
||||||
mComposition->update();
|
mComposition->update();
|
||||||
|
mComposition->clearSelection();
|
||||||
|
newPicture->setSelected(true);
|
||||||
|
showItemOptions(newPicture);
|
||||||
}
|
}
|
||||||
|
|
||||||
mComposition->sortZList();
|
mComposition->sortZList();
|
||||||
|
@ -64,7 +64,6 @@ void QgsComposerLabelWidget::on_mMarginDoubleSpinBox_valueChanged( double d )
|
|||||||
if ( mComposerLabel )
|
if ( mComposerLabel )
|
||||||
{
|
{
|
||||||
mComposerLabel->setMargin( d );
|
mComposerLabel->setMargin( d );
|
||||||
mComposerLabel->adjustSizeToText();
|
|
||||||
mComposerLabel->update();
|
mComposerLabel->update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,8 +51,8 @@ void QgsComposerLabel::paint( QPainter* painter, const QStyleOptionGraphicsItem*
|
|||||||
|
|
||||||
//support multiline labels
|
//support multiline labels
|
||||||
double penWidth = pen().widthF();
|
double penWidth = pen().widthF();
|
||||||
QRectF painterRect( penWidth, penWidth, rect().width() - 2 * penWidth,
|
QRectF painterRect( penWidth + mMargin, penWidth + mMargin, rect().width() - 2 * penWidth - 2 * mMargin,
|
||||||
rect().height() - 2 * penWidth );
|
rect().height() - 2 * penWidth - 2 * mMargin);
|
||||||
painter->drawText( painterRect, Qt::AlignLeft | Qt::AlignTop | Qt::TextWordWrap, mText );
|
painter->drawText( painterRect, Qt::AlignLeft | Qt::AlignTop | Qt::TextWordWrap, mText );
|
||||||
|
|
||||||
|
|
||||||
|
@ -226,5 +226,5 @@ bool QgsComposerPicture::readXML( const QDomElement& itemElem, const QDomDocumen
|
|||||||
|
|
||||||
mRotation = itemElem.attribute( "rotation" ).toDouble();
|
mRotation = itemElem.attribute( "rotation" ).toDouble();
|
||||||
|
|
||||||
return false; //soon...
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -268,7 +268,6 @@ QString QgsComposerScaleBar::firstLabelString() const
|
|||||||
|
|
||||||
QFont QgsComposerScaleBar::font() const
|
QFont QgsComposerScaleBar::font() const
|
||||||
{
|
{
|
||||||
#if 0 //needed by scale bar style, therefore don't convert back to points
|
|
||||||
if ( mComposition ) //make pixel to point conversion to show correct point value in dialogs
|
if ( mComposition ) //make pixel to point conversion to show correct point value in dialogs
|
||||||
{
|
{
|
||||||
double pointSize = mComposition->pointFontSize( mFont.pixelSize() );
|
double pointSize = mComposition->pointFontSize( mFont.pixelSize() );
|
||||||
@ -276,7 +275,10 @@ QFont QgsComposerScaleBar::font() const
|
|||||||
returnFont.setPointSize( pointSize );
|
returnFont.setPointSize( pointSize );
|
||||||
return returnFont;
|
return returnFont;
|
||||||
}
|
}
|
||||||
#endif //0
|
}
|
||||||
|
|
||||||
|
QFont QgsComposerScaleBar::fontPixelSize() const
|
||||||
|
{
|
||||||
return mFont;
|
return mFont;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -311,6 +313,7 @@ bool QgsComposerScaleBar::writeXML( QDomElement& elem, QDomDocument & doc )
|
|||||||
composerScaleBarElem.setAttribute( "numSegments", mNumSegments );
|
composerScaleBarElem.setAttribute( "numSegments", mNumSegments );
|
||||||
composerScaleBarElem.setAttribute( "numSegmentsLeft", mNumSegmentsLeft );
|
composerScaleBarElem.setAttribute( "numSegmentsLeft", mNumSegmentsLeft );
|
||||||
composerScaleBarElem.setAttribute( "numUnitsPerSegment", mNumUnitsPerSegment );
|
composerScaleBarElem.setAttribute( "numUnitsPerSegment", mNumUnitsPerSegment );
|
||||||
|
composerScaleBarElem.setAttribute( "segmentMM", mSegmentMM );
|
||||||
composerScaleBarElem.setAttribute( "numMapUnitsPerScaleBarUnit", mNumMapUnitsPerScaleBarUnit );
|
composerScaleBarElem.setAttribute( "numMapUnitsPerScaleBarUnit", mNumMapUnitsPerScaleBarUnit );
|
||||||
composerScaleBarElem.setAttribute( "font", mFont.toString() );
|
composerScaleBarElem.setAttribute( "font", mFont.toString() );
|
||||||
composerScaleBarElem.setAttribute( "outlineWidth", mPen.widthF() );
|
composerScaleBarElem.setAttribute( "outlineWidth", mPen.widthF() );
|
||||||
@ -353,6 +356,7 @@ bool QgsComposerScaleBar::readXML( const QDomElement& itemElem, const QDomDocume
|
|||||||
mNumSegments = itemElem.attribute( "numSegments", "2" ).toInt();
|
mNumSegments = itemElem.attribute( "numSegments", "2" ).toInt();
|
||||||
mNumSegmentsLeft = itemElem.attribute( "numSegmentsLeft", "0" ).toInt();
|
mNumSegmentsLeft = itemElem.attribute( "numSegmentsLeft", "0" ).toInt();
|
||||||
mNumUnitsPerSegment = itemElem.attribute( "numUnitsPerSegment", "1.0" ).toDouble();
|
mNumUnitsPerSegment = itemElem.attribute( "numUnitsPerSegment", "1.0" ).toDouble();
|
||||||
|
mSegmentMM = itemElem.attribute("segmentMM", "0.0").toDouble();
|
||||||
mNumMapUnitsPerScaleBarUnit = itemElem.attribute( "numMapUnitsPerScaleBarUnit", "1.0" ).toDouble();
|
mNumMapUnitsPerScaleBarUnit = itemElem.attribute( "numMapUnitsPerScaleBarUnit", "1.0" ).toDouble();
|
||||||
mPen.setWidthF( itemElem.attribute( "outlineWidth", "1.0" ).toDouble() );
|
mPen.setWidthF( itemElem.attribute( "outlineWidth", "1.0" ).toDouble() );
|
||||||
mUnitLabeling = itemElem.attribute( "unitLabel" );
|
mUnitLabeling = itemElem.attribute( "unitLabel" );
|
||||||
|
@ -56,6 +56,10 @@ class CORE_EXPORT QgsComposerScaleBar: public QObject, public QgsComposerItem
|
|||||||
void setUnitLabeling( const QString& label ) {mUnitLabeling = label;}
|
void setUnitLabeling( const QString& label ) {mUnitLabeling = label;}
|
||||||
|
|
||||||
QFont font() const;
|
QFont font() const;
|
||||||
|
|
||||||
|
/**Returns font that has size set in pixels. Used from QgsComposerScaleBarStyle*/
|
||||||
|
QFont fontPixelSize() const;
|
||||||
|
|
||||||
void setFont( const QFont& font );
|
void setFont( const QFont& font );
|
||||||
|
|
||||||
QPen pen() const {return mPen;}
|
QPen pen() const {return mPen;}
|
||||||
|
@ -139,7 +139,7 @@ int QgsComposition::pixelFontSize( double pointSize ) const
|
|||||||
{
|
{
|
||||||
//in QgsComposition, one unit = one mm
|
//in QgsComposition, one unit = one mm
|
||||||
double sizeMM = pointSize * 0.3527;
|
double sizeMM = pointSize * 0.3527;
|
||||||
return sizeMM;
|
return (sizeMM + 0.5); //round to nearest mm
|
||||||
}
|
}
|
||||||
|
|
||||||
double QgsComposition::pointFontSize( int pixelSize ) const
|
double QgsComposition::pointFontSize( int pixelSize ) const
|
||||||
|
@ -43,9 +43,9 @@ void QgsScaleBarStyle::drawLabels( QPainter* p ) const
|
|||||||
|
|
||||||
p->save();
|
p->save();
|
||||||
|
|
||||||
p->setFont( mScaleBar->font() );
|
p->setFont( mScaleBar->fontPixelSize() );
|
||||||
|
|
||||||
QFontMetricsF fontMetrics( mScaleBar->font() );
|
QFontMetricsF fontMetrics( mScaleBar->fontPixelSize() );
|
||||||
QString firstLabel = mScaleBar->firstLabelString();
|
QString firstLabel = mScaleBar->firstLabelString();
|
||||||
double xOffset = fontMetrics.width( firstLabel ) / 2;
|
double xOffset = fontMetrics.width( firstLabel ) / 2;
|
||||||
|
|
||||||
@ -107,7 +107,7 @@ QRectF QgsScaleBarStyle::calculateBoxSize() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QFontMetricsF fontMetrics( mScaleBar->font() );
|
QFontMetricsF fontMetrics( mScaleBar->fontPixelSize() );
|
||||||
|
|
||||||
//consider centered first label
|
//consider centered first label
|
||||||
double firstLabelLeft = fontMetrics.width( mScaleBar->firstLabelString() ) / 2;
|
double firstLabelLeft = fontMetrics.width( mScaleBar->firstLabelString() ) / 2;
|
||||||
|
@ -86,7 +86,6 @@ void QgsComposerView::mousePressEvent( QMouseEvent* e )
|
|||||||
t.translate( scenePoint.x(), scenePoint.y() );
|
t.translate( scenePoint.x(), scenePoint.y() );
|
||||||
mRubberBandItem->setTransform( t );
|
mRubberBandItem->setTransform( t );
|
||||||
mRubberBandItem->setZValue( 100 );
|
mRubberBandItem->setZValue( 100 );
|
||||||
|
|
||||||
scene()->addItem( mRubberBandItem );
|
scene()->addItem( mRubberBandItem );
|
||||||
scene()->update();
|
scene()->update();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user