mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
[FEATURE][composer] Data defined scalebar colors and line width
This commit is contained in:
parent
ec9ba9c2a2
commit
6c53ba25e3
@ -610,6 +610,13 @@ QgsComposerObject::dataDefinedProperty instead.
|
||||
QgsComposerObject::setDataDefinedProperty() instead.
|
||||
- updatePictureExpression() was removed.
|
||||
|
||||
QgsComposerScaleBar {#qgis_api_break_3_0_QgsComposerScaleBar}
|
||||
-------------------
|
||||
|
||||
- setBrush() was removed. Use setFillColor() instead.
|
||||
- setBrush2() was removed. Use setFillColor2() instead.
|
||||
- setPen() was removed. Use setLineColor() and setLineWidth() instead.
|
||||
|
||||
|
||||
QgsComposerTable {#qgis_api_break_3_0_QgsComposerTable}
|
||||
----------------
|
||||
|
@ -134,6 +134,58 @@ class QgsComposerScaleBar: QgsComposerItem
|
||||
*/
|
||||
void setFontColor( const QColor& c );
|
||||
|
||||
/** Returns the color used for fills in the scalebar.
|
||||
* @see setFillColor()
|
||||
* @see fillColor2()
|
||||
* @note added in QGIS 3.0
|
||||
*/
|
||||
QColor fillColor() const;
|
||||
|
||||
/** Sets the color used for fills in the scalebar.
|
||||
* @see fillColor()
|
||||
* @see setFillColor2()
|
||||
* @note added in QGIS 3.0
|
||||
*/
|
||||
void setFillColor( const QColor& color );
|
||||
|
||||
/** Returns the secondary color used for fills in the scalebar.
|
||||
* @see setFillColor2()
|
||||
* @see fillColor()
|
||||
* @note added in QGIS 3.0
|
||||
*/
|
||||
QColor fillColor2() const;
|
||||
|
||||
/** Sets the secondary color used for fills in the scalebar.
|
||||
* @see fillColor2()
|
||||
* @see setFillColor2()
|
||||
* @note added in QGIS 3.0
|
||||
*/
|
||||
void setFillColor2( const QColor& color );
|
||||
|
||||
/** Returns the color used for lines in the scalebar.
|
||||
* @see setLineColor()
|
||||
* @note added in QGIS 3.0
|
||||
*/
|
||||
QColor lineColor() const;
|
||||
|
||||
/** Sets the color used for lines in the scalebar.
|
||||
* @see lineColor()
|
||||
* @note added in QGIS 3.0
|
||||
*/
|
||||
void setLineColor( const QColor& color );
|
||||
|
||||
/** Returns the line width in millimeters for lines in the scalebar.
|
||||
* @see setLineWidth()
|
||||
* @note added in QGIS 3.0
|
||||
*/
|
||||
double lineWidth() const;
|
||||
|
||||
/** Sets the line width in millimeters for lines in the scalebar.
|
||||
* @see lineWidth()
|
||||
* @note added in QGIS 3.0
|
||||
*/
|
||||
void setLineWidth( double width );
|
||||
|
||||
/** Returns the pen used for drawing the scalebar.
|
||||
* @returns QPen used for drawing the scalebar outlines.
|
||||
* @see setPen
|
||||
@ -141,13 +193,6 @@ class QgsComposerScaleBar: QgsComposerItem
|
||||
*/
|
||||
QPen pen() const;
|
||||
|
||||
/** Sets the pen used for drawing the scalebar.
|
||||
* @param pen QPen to use for drawing the scalebar outlines.
|
||||
* @see pen
|
||||
* @see setBrush
|
||||
*/
|
||||
void setPen( const QPen& pen );
|
||||
|
||||
/** Returns the primary brush for the scalebar.
|
||||
* @returns QBrush used for filling the scalebar
|
||||
* @see setBrush
|
||||
@ -156,14 +201,6 @@ class QgsComposerScaleBar: QgsComposerItem
|
||||
*/
|
||||
QBrush brush() const;
|
||||
|
||||
/** Sets primary brush for the scalebar.
|
||||
* @param brush QBrush to use for filling the scalebar
|
||||
* @see brush
|
||||
* @see setBrush2
|
||||
* @see setPen
|
||||
*/
|
||||
void setBrush( const QBrush& brush );
|
||||
|
||||
/** Returns the secondary brush for the scalebar. This is used for alternating color style scalebars, such
|
||||
* as single and double box styles.
|
||||
* @returns QBrush used for secondary color areas
|
||||
@ -172,14 +209,6 @@ class QgsComposerScaleBar: QgsComposerItem
|
||||
*/
|
||||
QBrush brush2() const;
|
||||
|
||||
/** Sets secondary brush for the scalebar. This is used for alternating color style scalebars, such
|
||||
* as single and double box styles.
|
||||
* @param brush QBrush to use for secondary color areas
|
||||
* @see brush2
|
||||
* @see setBrush
|
||||
*/
|
||||
void setBrush2( const QBrush& brush );
|
||||
|
||||
double height() const;
|
||||
void setHeight( double h );
|
||||
|
||||
|
@ -91,6 +91,15 @@ QgsComposerScaleBarWidget::QgsComposerScaleBarWidget( QgsComposerScaleBar* scale
|
||||
|
||||
connect( mMapItemComboBox, SIGNAL( itemChanged( QgsComposerItem* ) ), this, SLOT( composerMapChanged( QgsComposerItem* ) ) );
|
||||
|
||||
registerDataDefinedButton( mFillColorDDBtn, QgsComposerObject::ScalebarFillColor,
|
||||
QgsDataDefinedButtonV2::AnyType, QgsDataDefinedButtonV2::colorAlphaDesc() );
|
||||
registerDataDefinedButton( mFillColor2DDBtn, QgsComposerObject::ScalebarFillColor2,
|
||||
QgsDataDefinedButtonV2::AnyType, QgsDataDefinedButtonV2::colorAlphaDesc() );
|
||||
registerDataDefinedButton( mLineColorDDBtn, QgsComposerObject::ScalebarLineColor,
|
||||
QgsDataDefinedButtonV2::AnyType, QgsDataDefinedButtonV2::colorAlphaDesc() );
|
||||
registerDataDefinedButton( mLineWidthDDBtn, QgsComposerObject::ScalebarLineWidth,
|
||||
QgsDataDefinedButtonV2::AnyType, QgsDataDefinedButtonV2::doublePosDesc() );
|
||||
|
||||
blockMemberSignals( false );
|
||||
setGuiElements(); //set the GUI elements to the state of scaleBar
|
||||
}
|
||||
@ -111,7 +120,7 @@ void QgsComposerScaleBarWidget::setGuiElements()
|
||||
mNumberOfSegmentsSpinBox->setValue( mComposerScaleBar->numSegments() );
|
||||
mSegmentsLeftSpinBox->setValue( mComposerScaleBar->numSegmentsLeft() );
|
||||
mSegmentSizeSpinBox->setValue( mComposerScaleBar->numUnitsPerSegment() );
|
||||
mLineWidthSpinBox->setValue( mComposerScaleBar->pen().widthF() );
|
||||
mLineWidthSpinBox->setValue( mComposerScaleBar->lineWidth() );
|
||||
mHeightSpinBox->setValue( mComposerScaleBar->height() );
|
||||
mMapUnitsPerBarUnitSpinBox->setValue( mComposerScaleBar->numMapUnitsPerScaleBarUnit() );
|
||||
mLabelBarSpaceSpinBox->setValue( mComposerScaleBar->labelBarSpace() );
|
||||
@ -120,9 +129,9 @@ void QgsComposerScaleBarWidget::setGuiElements()
|
||||
mLineJoinStyleCombo->setPenJoinStyle( mComposerScaleBar->lineJoinStyle() );
|
||||
mLineCapStyleCombo->setPenCapStyle( mComposerScaleBar->lineCapStyle() );
|
||||
mFontColorButton->setColor( mComposerScaleBar->fontColor() );
|
||||
mFillColorButton->setColor( mComposerScaleBar->brush().color() );
|
||||
mFillColor2Button->setColor( mComposerScaleBar->brush2().color() );
|
||||
mStrokeColorButton->setColor( mComposerScaleBar->pen().color() );
|
||||
mFillColorButton->setColor( mComposerScaleBar->fillColor() );
|
||||
mFillColor2Button->setColor( mComposerScaleBar->fillColor2() );
|
||||
mStrokeColorButton->setColor( mComposerScaleBar->lineColor() );
|
||||
|
||||
//map combo box
|
||||
mMapItemComboBox->setItem( mComposerScaleBar->composerMap() );
|
||||
@ -154,7 +163,10 @@ void QgsComposerScaleBarWidget::setGuiElements()
|
||||
}
|
||||
mMinWidthSpinBox->setValue( mComposerScaleBar->minBarWidth() );
|
||||
mMaxWidthSpinBox->setValue( mComposerScaleBar->maxBarWidth() );
|
||||
|
||||
updateDataDefinedButton( mFillColorDDBtn );
|
||||
updateDataDefinedButton( mFillColor2DDBtn );
|
||||
updateDataDefinedButton( mLineColorDDBtn );
|
||||
updateDataDefinedButton( mLineWidthDDBtn );
|
||||
blockMemberSignals( false );
|
||||
}
|
||||
|
||||
@ -169,9 +181,7 @@ void QgsComposerScaleBarWidget::on_mLineWidthSpinBox_valueChanged( double d )
|
||||
|
||||
mComposerScaleBar->beginCommand( tr( "Scalebar line width" ), QgsComposerMergeCommand::ScaleBarLineWidth );
|
||||
disconnectUpdateSignal();
|
||||
QPen newPen = mComposerScaleBar->pen();
|
||||
newPen.setWidthF( d );
|
||||
mComposerScaleBar->setPen( newPen );
|
||||
mComposerScaleBar->setLineWidth( d );
|
||||
mComposerScaleBar->update();
|
||||
connectUpdateSignal();
|
||||
mComposerScaleBar->endCommand();
|
||||
@ -280,9 +290,7 @@ void QgsComposerScaleBarWidget::on_mFillColorButton_colorChanged( const QColor&
|
||||
|
||||
mComposerScaleBar->beginCommand( tr( "Scalebar color changed" ), QgsComposerMergeCommand::ScaleBarFillColor );
|
||||
disconnectUpdateSignal();
|
||||
QBrush newBrush = mComposerScaleBar->brush();
|
||||
newBrush.setColor( newColor );
|
||||
mComposerScaleBar->setBrush( newBrush );
|
||||
mComposerScaleBar->setFillColor( newColor );
|
||||
mComposerScaleBar->update();
|
||||
connectUpdateSignal();
|
||||
mComposerScaleBar->endCommand();
|
||||
@ -297,9 +305,7 @@ void QgsComposerScaleBarWidget::on_mFillColor2Button_colorChanged( const QColor
|
||||
|
||||
mComposerScaleBar->beginCommand( tr( "Scalebar secondary color changed" ), QgsComposerMergeCommand::ScaleBarFill2Color );
|
||||
disconnectUpdateSignal();
|
||||
QBrush newBrush = mComposerScaleBar->brush2();
|
||||
newBrush.setColor( newColor );
|
||||
mComposerScaleBar->setBrush2( newBrush );
|
||||
mComposerScaleBar->setFillColor2( newColor );
|
||||
mComposerScaleBar->update();
|
||||
connectUpdateSignal();
|
||||
mComposerScaleBar->endCommand();
|
||||
@ -314,9 +320,7 @@ void QgsComposerScaleBarWidget::on_mStrokeColorButton_colorChanged( const QColor
|
||||
|
||||
mComposerScaleBar->beginCommand( tr( "Scalebar line color changed" ), QgsComposerMergeCommand::ScaleBarStrokeColor );
|
||||
disconnectUpdateSignal();
|
||||
QPen newPen = mComposerScaleBar->pen();
|
||||
newPen.setColor( newColor );
|
||||
mComposerScaleBar->setPen( newPen );
|
||||
mComposerScaleBar->setLineColor( newColor );
|
||||
mComposerScaleBar->update();
|
||||
connectUpdateSignal();
|
||||
mComposerScaleBar->endCommand();
|
||||
|
@ -63,6 +63,10 @@ const QgsPropertyDefinition QgsComposerObject::sPropertyNameMap
|
||||
{ QgsComposerObject::PictureSvgOutlineWidth, "dataDefinedSvgOutlineWidth" },
|
||||
{ QgsComposerObject::LegendTitle, "dataDefinedLegendTitle" },
|
||||
{ QgsComposerObject::LegendColumnCount, "dataDefinedLegendColumns" },
|
||||
{ QgsComposerObject::ScalebarFillColor, "dataDefinedScalebarFill" },
|
||||
{ QgsComposerObject::ScalebarFillColor2, "dataDefinedScalebarFill2" },
|
||||
{ QgsComposerObject::ScalebarLineColor, "dataDefinedScalebarLineColor" },
|
||||
{ QgsComposerObject::ScalebarLineWidth, "dataDefinedScalebarLineWidth" },
|
||||
};
|
||||
|
||||
|
||||
|
@ -81,6 +81,11 @@ class CORE_EXPORT QgsComposerObject: public QObject, public QgsExpressionContext
|
||||
//legend item
|
||||
LegendTitle, //!< Legend title
|
||||
LegendColumnCount, //!< Legend column count
|
||||
//scalebar item
|
||||
ScalebarFillColor, //!< Scalebar fill color
|
||||
ScalebarFillColor2, //!< Scalebar secondary fill color
|
||||
ScalebarLineColor, //!< Scalebar line color
|
||||
ScalebarLineWidth, //!< Scalebar line width
|
||||
};
|
||||
|
||||
static const QgsPropertyDefinition sPropertyNameMap;
|
||||
|
@ -225,6 +225,41 @@ void QgsComposerScaleBar::invalidateCurrentMap()
|
||||
mComposerMap = nullptr;
|
||||
}
|
||||
|
||||
void QgsComposerScaleBar::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::ScalebarFillColor || property == QgsComposerObject::AllProperties )
|
||||
{
|
||||
mBrush.setColor( mProperties.valueAsColor( QgsComposerObject::ScalebarFillColor, *evalContext, mFillColor ) );
|
||||
forceUpdate = true;
|
||||
}
|
||||
if ( property == QgsComposerObject::ScalebarFillColor2 || property == QgsComposerObject::AllProperties )
|
||||
{
|
||||
mBrush2.setColor( mProperties.valueAsColor( QgsComposerObject::ScalebarFillColor2, *evalContext, mFillColor2 ) );
|
||||
forceUpdate = true;
|
||||
}
|
||||
if ( property == QgsComposerObject::ScalebarLineColor || property == QgsComposerObject::AllProperties )
|
||||
{
|
||||
mPen.setColor( mProperties.valueAsColor( QgsComposerObject::ScalebarLineColor, *evalContext, mLineColor ) );
|
||||
forceUpdate = true;
|
||||
}
|
||||
if ( property == QgsComposerObject::ScalebarLineWidth || property == QgsComposerObject::AllProperties )
|
||||
{
|
||||
mPen.setWidthF( mProperties.valueAsDouble( QgsComposerObject::ScalebarLineWidth, *evalContext, mLineWidth ) );
|
||||
forceUpdate = true;
|
||||
}
|
||||
if ( forceUpdate )
|
||||
{
|
||||
update();
|
||||
}
|
||||
|
||||
QgsComposerObject::refreshDataDefinedProperty( property, context );
|
||||
}
|
||||
|
||||
// nextNiceNumber(4573.23, d) = 5000 (d=1) -> 4600 (d=10) -> 4580 (d=100) -> 4574 (d=1000) -> etc
|
||||
inline double nextNiceNumber( double a, double d = 1 )
|
||||
{
|
||||
@ -385,15 +420,15 @@ void QgsComposerScaleBar::applyDefaultSettings()
|
||||
//default to no background
|
||||
setBackgroundEnabled( false );
|
||||
|
||||
mPen = QPen( Qt::black );
|
||||
mPen = QPen( mLineColor );
|
||||
mPen.setJoinStyle( mLineJoinStyle );
|
||||
mPen.setCapStyle( mLineCapStyle );
|
||||
mPen.setWidthF( 0.3 );
|
||||
mPen.setWidthF( mLineWidth );
|
||||
|
||||
mBrush.setColor( Qt::black );
|
||||
mBrush.setColor( mFillColor );
|
||||
mBrush.setStyle( Qt::SolidPattern );
|
||||
|
||||
mBrush2.setColor( Qt::white );
|
||||
mBrush2.setColor( mFillColor2 );
|
||||
mBrush2.setStyle( Qt::SolidPattern );
|
||||
|
||||
//get default composer font from settings
|
||||
@ -681,7 +716,7 @@ bool QgsComposerScaleBar::writeXml( QDomElement& elem, QDomDocument & doc ) cons
|
||||
composerScaleBarElem.setAttribute( QStringLiteral( "segmentMillimeters" ), QString::number( mSegmentMillimeters ) );
|
||||
composerScaleBarElem.setAttribute( QStringLiteral( "numMapUnitsPerScaleBarUnit" ), QString::number( mNumMapUnitsPerScaleBarUnit ) );
|
||||
composerScaleBarElem.appendChild( QgsFontUtils::toXmlElement( mFont, doc, QStringLiteral( "scaleBarFont" ) ) );
|
||||
composerScaleBarElem.setAttribute( QStringLiteral( "outlineWidth" ), QString::number( mPen.widthF() ) );
|
||||
composerScaleBarElem.setAttribute( QStringLiteral( "outlineWidth" ), QString::number( mLineWidth ) );
|
||||
composerScaleBarElem.setAttribute( QStringLiteral( "unitLabel" ), mUnitLabeling );
|
||||
composerScaleBarElem.setAttribute( QStringLiteral( "units" ), mUnits );
|
||||
composerScaleBarElem.setAttribute( QStringLiteral( "lineJoinStyle" ), QgsSymbolLayerUtils::encodePenJoinStyle( mLineJoinStyle ) );
|
||||
@ -703,29 +738,26 @@ bool QgsComposerScaleBar::writeXml( QDomElement& elem, QDomDocument & doc ) cons
|
||||
|
||||
//fill color
|
||||
QDomElement fillColorElem = doc.createElement( QStringLiteral( "fillColor" ) );
|
||||
QColor fillColor = mBrush.color();
|
||||
fillColorElem.setAttribute( QStringLiteral( "red" ), QString::number( fillColor.red() ) );
|
||||
fillColorElem.setAttribute( QStringLiteral( "green" ), QString::number( fillColor.green() ) );
|
||||
fillColorElem.setAttribute( QStringLiteral( "blue" ), QString::number( fillColor.blue() ) );
|
||||
fillColorElem.setAttribute( QStringLiteral( "alpha" ), QString::number( fillColor.alpha() ) );
|
||||
fillColorElem.setAttribute( QStringLiteral( "red" ), QString::number( mFillColor.red() ) );
|
||||
fillColorElem.setAttribute( QStringLiteral( "green" ), QString::number( mFillColor.green() ) );
|
||||
fillColorElem.setAttribute( QStringLiteral( "blue" ), QString::number( mFillColor.blue() ) );
|
||||
fillColorElem.setAttribute( QStringLiteral( "alpha" ), QString::number( mFillColor.alpha() ) );
|
||||
composerScaleBarElem.appendChild( fillColorElem );
|
||||
|
||||
//fill color 2
|
||||
QDomElement fillColor2Elem = doc.createElement( QStringLiteral( "fillColor2" ) );
|
||||
QColor fillColor2 = mBrush2.color();
|
||||
fillColor2Elem.setAttribute( QStringLiteral( "red" ), QString::number( fillColor2.red() ) );
|
||||
fillColor2Elem.setAttribute( QStringLiteral( "green" ), QString::number( fillColor2.green() ) );
|
||||
fillColor2Elem.setAttribute( QStringLiteral( "blue" ), QString::number( fillColor2.blue() ) );
|
||||
fillColor2Elem.setAttribute( QStringLiteral( "alpha" ), QString::number( fillColor2.alpha() ) );
|
||||
fillColor2Elem.setAttribute( QStringLiteral( "red" ), QString::number( mFillColor2.red() ) );
|
||||
fillColor2Elem.setAttribute( QStringLiteral( "green" ), QString::number( mFillColor2.green() ) );
|
||||
fillColor2Elem.setAttribute( QStringLiteral( "blue" ), QString::number( mFillColor2.blue() ) );
|
||||
fillColor2Elem.setAttribute( QStringLiteral( "alpha" ), QString::number( mFillColor2.alpha() ) );
|
||||
composerScaleBarElem.appendChild( fillColor2Elem );
|
||||
|
||||
//pen color
|
||||
QDomElement strokeColorElem = doc.createElement( QStringLiteral( "strokeColor" ) );
|
||||
QColor strokeColor = mPen.color();
|
||||
strokeColorElem.setAttribute( QStringLiteral( "red" ), QString::number( strokeColor.red() ) );
|
||||
strokeColorElem.setAttribute( QStringLiteral( "green" ), QString::number( strokeColor.green() ) );
|
||||
strokeColorElem.setAttribute( QStringLiteral( "blue" ), QString::number( strokeColor.blue() ) );
|
||||
strokeColorElem.setAttribute( QStringLiteral( "alpha" ), QString::number( strokeColor.alpha() ) );
|
||||
strokeColorElem.setAttribute( QStringLiteral( "red" ), QString::number( mLineColor.red() ) );
|
||||
strokeColorElem.setAttribute( QStringLiteral( "green" ), QString::number( mLineColor.green() ) );
|
||||
strokeColorElem.setAttribute( QStringLiteral( "blue" ), QString::number( mLineColor.blue() ) );
|
||||
strokeColorElem.setAttribute( QStringLiteral( "alpha" ), QString::number( mLineColor.alpha() ) );
|
||||
composerScaleBarElem.appendChild( strokeColorElem );
|
||||
|
||||
//font color
|
||||
@ -761,7 +793,8 @@ bool QgsComposerScaleBar::readXml( const QDomElement& itemElem, const QDomDocume
|
||||
mMaxBarWidth = itemElem.attribute( QStringLiteral( "maxBarWidth" ), QStringLiteral( "150" ) ).toInt();
|
||||
mSegmentMillimeters = itemElem.attribute( QStringLiteral( "segmentMillimeters" ), QStringLiteral( "0.0" ) ).toDouble();
|
||||
mNumMapUnitsPerScaleBarUnit = itemElem.attribute( QStringLiteral( "numMapUnitsPerScaleBarUnit" ), QStringLiteral( "1.0" ) ).toDouble();
|
||||
mPen.setWidthF( itemElem.attribute( QStringLiteral( "outlineWidth" ), QStringLiteral( "0.3" ) ).toDouble() );
|
||||
mLineWidth = itemElem.attribute( QStringLiteral( "outlineWidth" ), QStringLiteral( "0.3" ) ).toDouble();
|
||||
mPen.setWidthF( mLineWidth );
|
||||
mUnitLabeling = itemElem.attribute( QStringLiteral( "unitLabel" ) );
|
||||
mLineJoinStyle = QgsSymbolLayerUtils::decodePenJoinStyle( itemElem.attribute( QStringLiteral( "lineJoinStyle" ), QStringLiteral( "miter" ) ) );
|
||||
mPen.setJoinStyle( mLineJoinStyle );
|
||||
@ -788,12 +821,14 @@ bool QgsComposerScaleBar::readXml( const QDomElement& itemElem, const QDomDocume
|
||||
|
||||
if ( redOk && greenOk && blueOk && alphaOk )
|
||||
{
|
||||
mBrush.setColor( QColor( fillRed, fillGreen, fillBlue, fillAlpha ) );
|
||||
mFillColor = QColor( fillRed, fillGreen, fillBlue, fillAlpha );
|
||||
mBrush.setColor( mFillColor );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mBrush.setColor( QColor( itemElem.attribute( QStringLiteral( "brushColor" ), QStringLiteral( "#000000" ) ) ) );
|
||||
mFillColor = QColor( itemElem.attribute( QStringLiteral( "brushColor" ), QStringLiteral( "#000000" ) ) );
|
||||
mBrush.setColor( mFillColor );
|
||||
}
|
||||
|
||||
//fill color 2
|
||||
@ -811,12 +846,14 @@ bool QgsComposerScaleBar::readXml( const QDomElement& itemElem, const QDomDocume
|
||||
|
||||
if ( redOk && greenOk && blueOk && alphaOk )
|
||||
{
|
||||
mBrush2.setColor( QColor( fillRed, fillGreen, fillBlue, fillAlpha ) );
|
||||
mFillColor2 = QColor( fillRed, fillGreen, fillBlue, fillAlpha );
|
||||
mBrush2.setColor( mFillColor2 );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mBrush2.setColor( QColor( itemElem.attribute( QStringLiteral( "brush2Color" ), QStringLiteral( "#ffffff" ) ) ) );
|
||||
mFillColor2 = QColor( itemElem.attribute( QStringLiteral( "brush2Color" ), QStringLiteral( "#ffffff" ) ) );
|
||||
mBrush2.setColor( mFillColor2 );
|
||||
}
|
||||
|
||||
//stroke color
|
||||
@ -834,12 +871,14 @@ bool QgsComposerScaleBar::readXml( const QDomElement& itemElem, const QDomDocume
|
||||
|
||||
if ( redOk && greenOk && blueOk && alphaOk )
|
||||
{
|
||||
mPen.setColor( QColor( strokeRed, strokeGreen, strokeBlue, strokeAlpha ) );
|
||||
mLineColor = QColor( strokeRed, strokeGreen, strokeBlue, strokeAlpha );
|
||||
mPen.setColor( mLineColor );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mPen.setColor( QColor( itemElem.attribute( QStringLiteral( "penColor" ), QStringLiteral( "#000000" ) ) ) );
|
||||
mLineColor = QColor( itemElem.attribute( QStringLiteral( "penColor" ), QStringLiteral( "#000000" ) ) );
|
||||
mPen.setColor( mLineColor );
|
||||
}
|
||||
|
||||
//font color
|
||||
|
@ -159,6 +159,58 @@ class CORE_EXPORT QgsComposerScaleBar: public QgsComposerItem
|
||||
*/
|
||||
void setFontColor( const QColor& c ) {mFontColor = c;}
|
||||
|
||||
/** Returns the color used for fills in the scalebar.
|
||||
* @see setFillColor()
|
||||
* @see fillColor2()
|
||||
* @note added in QGIS 3.0
|
||||
*/
|
||||
QColor fillColor() const {return mFillColor;}
|
||||
|
||||
/** Sets the color used for fills in the scalebar.
|
||||
* @see fillColor()
|
||||
* @see setFillColor2()
|
||||
* @note added in QGIS 3.0
|
||||
*/
|
||||
void setFillColor( const QColor& color ) {mFillColor = color; mBrush.setColor( color ); }
|
||||
|
||||
/** Returns the secondary color used for fills in the scalebar.
|
||||
* @see setFillColor2()
|
||||
* @see fillColor()
|
||||
* @note added in QGIS 3.0
|
||||
*/
|
||||
QColor fillColor2() const {return mFillColor2;}
|
||||
|
||||
/** Sets the secondary color used for fills in the scalebar.
|
||||
* @see fillColor2()
|
||||
* @see setFillColor2()
|
||||
* @note added in QGIS 3.0
|
||||
*/
|
||||
void setFillColor2( const QColor& color ) {mFillColor2 = color; mBrush2.setColor( color ); }
|
||||
|
||||
/** Returns the color used for lines in the scalebar.
|
||||
* @see setLineColor()
|
||||
* @note added in QGIS 3.0
|
||||
*/
|
||||
QColor lineColor() const {return mLineColor;}
|
||||
|
||||
/** Sets the color used for lines in the scalebar.
|
||||
* @see lineColor()
|
||||
* @note added in QGIS 3.0
|
||||
*/
|
||||
void setLineColor( const QColor& color ) { mLineColor = color; mPen.setColor( mLineColor ); }
|
||||
|
||||
/** Returns the line width in millimeters for lines in the scalebar.
|
||||
* @see setLineWidth()
|
||||
* @note added in QGIS 3.0
|
||||
*/
|
||||
double lineWidth() const {return mLineWidth;}
|
||||
|
||||
/** Sets the line width in millimeters for lines in the scalebar.
|
||||
* @see lineWidth()
|
||||
* @note added in QGIS 3.0
|
||||
*/
|
||||
void setLineWidth( double width ) { mLineWidth = width; mPen.setWidthF( width ); }
|
||||
|
||||
/** Returns the pen used for drawing the scalebar.
|
||||
* @returns QPen used for drawing the scalebar outlines.
|
||||
* @see setPen
|
||||
@ -166,13 +218,6 @@ class CORE_EXPORT QgsComposerScaleBar: public QgsComposerItem
|
||||
*/
|
||||
QPen pen() const {return mPen;}
|
||||
|
||||
/** Sets the pen used for drawing the scalebar.
|
||||
* @param pen QPen to use for drawing the scalebar outlines.
|
||||
* @see pen
|
||||
* @see setBrush
|
||||
*/
|
||||
void setPen( const QPen& pen ) {mPen = pen;}
|
||||
|
||||
/** Returns the primary brush for the scalebar.
|
||||
* @returns QBrush used for filling the scalebar
|
||||
* @see setBrush
|
||||
@ -181,14 +226,6 @@ class CORE_EXPORT QgsComposerScaleBar: public QgsComposerItem
|
||||
*/
|
||||
QBrush brush() const {return mBrush;}
|
||||
|
||||
/** Sets primary brush for the scalebar.
|
||||
* @param brush QBrush to use for filling the scalebar
|
||||
* @see brush
|
||||
* @see setBrush2
|
||||
* @see setPen
|
||||
*/
|
||||
void setBrush( const QBrush& brush ) {mBrush = brush;}
|
||||
|
||||
/** Returns the secondary brush for the scalebar. This is used for alternating color style scalebars, such
|
||||
* as single and double box styles.
|
||||
* @returns QBrush used for secondary color areas
|
||||
@ -197,14 +234,6 @@ class CORE_EXPORT QgsComposerScaleBar: public QgsComposerItem
|
||||
*/
|
||||
QBrush brush2() const {return mBrush2;}
|
||||
|
||||
/** Sets secondary brush for the scalebar. This is used for alternating color style scalebars, such
|
||||
* as single and double box styles.
|
||||
* @param brush QBrush to use for secondary color areas
|
||||
* @see brush2
|
||||
* @see setBrush
|
||||
*/
|
||||
void setBrush2( const QBrush& brush ) {mBrush2 = brush;}
|
||||
|
||||
double height() const {return mHeight;}
|
||||
void setHeight( double h ) {mHeight = h;}
|
||||
|
||||
@ -307,6 +336,7 @@ class CORE_EXPORT QgsComposerScaleBar: public QgsComposerItem
|
||||
void updateSegmentSize();
|
||||
//! Sets mCompositionMap to 0 if the map is deleted
|
||||
void invalidateCurrentMap();
|
||||
virtual void refreshDataDefinedProperty( const QgsComposerObject::DataDefinedProperty property = QgsComposerObject::AllProperties, const QgsExpressionContext* context = nullptr ) override;
|
||||
|
||||
protected:
|
||||
|
||||
@ -332,6 +362,14 @@ class CORE_EXPORT QgsComposerScaleBar: public QgsComposerItem
|
||||
//! Font
|
||||
QFont mFont;
|
||||
QColor mFontColor;
|
||||
//! Fill color
|
||||
QColor mFillColor = QColor( 0, 0, 0 );
|
||||
//! Secondary fill color
|
||||
QColor mFillColor2 = QColor( 255, 255, 255 );
|
||||
//! Line color
|
||||
QColor mLineColor = QColor( 0, 0, 0 );
|
||||
//! Line width
|
||||
double mLineWidth = 0.3;
|
||||
//! Outline
|
||||
QPen mPen;
|
||||
//! Fill
|
||||
|
@ -60,9 +60,9 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>437</width>
|
||||
<height>768</height>
|
||||
<y>-213</y>
|
||||
<width>440</width>
|
||||
<height>855</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="mainLayout">
|
||||
@ -350,48 +350,7 @@
|
||||
<property name="collapsed" stdset="0">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4" columnstretch="0,1">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Box margin</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QgsDoubleSpinBox" name="mBoxSizeSpinBox">
|
||||
<property name="prefix">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string> mm</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Labels margin</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QgsDoubleSpinBox" name="mLabelBarSpaceSpinBox">
|
||||
<property name="prefix">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string> mm</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Line width</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<layout class="QGridLayout" name="gridLayout_4" columnstretch="0,1,0">
|
||||
<item row="2" column="1">
|
||||
<widget class="QgsDoubleSpinBox" name="mLineWidthSpinBox">
|
||||
<property name="sizePolicy">
|
||||
@ -420,26 +379,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Join style</string>
|
||||
<string>Box margin</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QgsPenJoinStyleComboBox" name="mLineJoinStyleCombo"/>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Cap style</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QgsPenCapStyleComboBox" name="mLineCapStyleCombo"/>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="mAlignmentLabel">
|
||||
<property name="text">
|
||||
@ -447,7 +393,68 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Labels margin</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Line width</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Cap style</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>Join style</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QgsDataDefinedButtonV2" name="mLineWidthDDBtn">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="2">
|
||||
<widget class="QgsDoubleSpinBox" name="mLabelBarSpaceSpinBox">
|
||||
<property name="prefix">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string> mm</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="2">
|
||||
<widget class="QgsDoubleSpinBox" name="mBoxSizeSpinBox">
|
||||
<property name="prefix">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string> mm</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" colspan="2">
|
||||
<widget class="QgsPenJoinStyleComboBox" name="mLineJoinStyleCombo"/>
|
||||
</item>
|
||||
<item row="4" column="1" colspan="2">
|
||||
<widget class="QgsPenCapStyleComboBox" name="mLineCapStyleCombo"/>
|
||||
</item>
|
||||
<item row="5" column="1" colspan="2">
|
||||
<widget class="QComboBox" name="mAlignmentComboBox"/>
|
||||
</item>
|
||||
</layout>
|
||||
@ -467,14 +474,7 @@
|
||||
<property name="collapsed" stdset="0">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_5" columnstretch="0,1">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Font color</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<layout class="QGridLayout" name="gridLayout_5" columnstretch="0,0">
|
||||
<item row="1" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
@ -511,96 +511,23 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_9">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="mFontButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Fill color</string>
|
||||
<string>Font...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QgsColorButton" name="mFillColorButton">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>120</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>120</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_10">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Secondary fill color</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QgsColorButton" name="mFillColor2Button">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>120</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>120</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_11">
|
||||
<property name="text">
|
||||
<string>Line color</string>
|
||||
<string>Font color</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -625,6 +552,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QgsDataDefinedButtonV2" name="mLineColorDDBtn">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
@ -640,19 +574,113 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="mFontButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="text">
|
||||
<string>Font...</string>
|
||||
<string>Secondary fill color</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="text">
|
||||
<string>Fill color</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QgsColorButton" name="mFillColor2Button">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>120</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>120</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QgsDataDefinedButtonV2" name="mFillColor2DDBtn">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_11">
|
||||
<property name="text">
|
||||
<string>Line color</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QgsColorButton" name="mFillColorButton">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>120</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>120</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QgsDataDefinedButtonV2" name="mFillColorDDBtn">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@ -670,26 +698,26 @@
|
||||
<header>qgscolorbutton.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>QgsDataDefinedButtonV2</class>
|
||||
<extends>QToolButton</extends>
|
||||
<header>qgsdatadefinedbuttonv2.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>QgsDoubleSpinBox</class>
|
||||
<extends>QDoubleSpinBox</extends>
|
||||
<header>qgsdoublespinbox.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>QgsPenJoinStyleComboBox</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>qgspenstylecombobox.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>QgsPenCapStyleComboBox</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>qgspenstylecombobox.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>QgsSpinBox</class>
|
||||
<extends>QSpinBox</extends>
|
||||
<header>qgsspinbox.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>QgsPenJoinStyleComboBox</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>qgspenstylecombobox.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>QgsCollapsibleGroupBoxBasic</class>
|
||||
<extends>QGroupBox</extends>
|
||||
@ -701,6 +729,11 @@
|
||||
<extends>QComboBox</extends>
|
||||
<header>qgscomposeritemcombobox.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>QgsPenCapStyleComboBox</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>qgspenstylecombobox.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>scrollArea</tabstop>
|
||||
@ -724,6 +757,7 @@
|
||||
<tabstop>mBoxSizeSpinBox</tabstop>
|
||||
<tabstop>mLabelBarSpaceSpinBox</tabstop>
|
||||
<tabstop>mLineWidthSpinBox</tabstop>
|
||||
<tabstop>mLineWidthDDBtn</tabstop>
|
||||
<tabstop>mLineJoinStyleCombo</tabstop>
|
||||
<tabstop>mLineCapStyleCombo</tabstop>
|
||||
<tabstop>mAlignmentComboBox</tabstop>
|
||||
@ -731,8 +765,11 @@
|
||||
<tabstop>mFontButton</tabstop>
|
||||
<tabstop>mFontColorButton</tabstop>
|
||||
<tabstop>mFillColorButton</tabstop>
|
||||
<tabstop>mFillColorDDBtn</tabstop>
|
||||
<tabstop>mFillColor2Button</tabstop>
|
||||
<tabstop>mFillColor2DDBtn</tabstop>
|
||||
<tabstop>mStrokeColorButton</tabstop>
|
||||
<tabstop>mLineColorDDBtn</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "qgsrasterlayer.h"
|
||||
#include "qgsrasterdataprovider.h"
|
||||
#include "qgsfontutils.h"
|
||||
#include "qgsproperty.h"
|
||||
#include "qgsproject.h"
|
||||
|
||||
#include <QLocale>
|
||||
@ -53,6 +54,7 @@ class TestQgsComposerScaleBar : public QObject
|
||||
void doubleBox();
|
||||
void numeric();
|
||||
void tick();
|
||||
void dataDefined();
|
||||
|
||||
private:
|
||||
QgsComposition* mComposition;
|
||||
@ -61,7 +63,6 @@ class TestQgsComposerScaleBar : public QObject
|
||||
QgsRasterLayer* mRasterLayer;
|
||||
QgsMapSettings *mMapSettings;
|
||||
QString mReport;
|
||||
QPen mPrevPen;
|
||||
};
|
||||
|
||||
void TestQgsComposerScaleBar::initTestCase()
|
||||
@ -110,9 +111,7 @@ void TestQgsComposerScaleBar::initTestCase()
|
||||
mComposerScaleBar->setNumSegmentsLeft( 0 );
|
||||
mComposerScaleBar->setNumSegments( 2 );
|
||||
mComposerScaleBar->setHeight( 5 );
|
||||
QPen scalePen = mComposerScaleBar->pen();
|
||||
scalePen.setWidthF( 1.0 );
|
||||
mComposerScaleBar->setPen( scalePen );
|
||||
mComposerScaleBar->setLineWidth( 1.0 );
|
||||
|
||||
qWarning() << "scalebar font: " << mComposerScaleBar->font().toString() << " exactMatch:" << mComposerScaleBar->font().exactMatch();
|
||||
|
||||
@ -158,12 +157,9 @@ void TestQgsComposerScaleBar::singleBox()
|
||||
void TestQgsComposerScaleBar::singleBoxAlpha()
|
||||
{
|
||||
mComposerScaleBar->setStyle( QStringLiteral( "Single Box" ) );
|
||||
mComposerScaleBar->setBrush( QBrush( QColor( 255, 0, 0, 100 ) ) );
|
||||
mComposerScaleBar->setBrush2( QBrush( QColor( 0, 255, 0, 50 ) ) );
|
||||
mPrevPen = mComposerScaleBar->pen();
|
||||
QPen newPen = mPrevPen;
|
||||
newPen.setColor( QColor( 0, 0, 255, 150 ) );
|
||||
mComposerScaleBar->setPen( newPen );
|
||||
mComposerScaleBar->setFillColor( QColor( 255, 0, 0, 100 ) );
|
||||
mComposerScaleBar->setFillColor2( QColor( 0, 255, 0, 50 ) );
|
||||
mComposerScaleBar->setLineColor( QColor( 0, 0, 255, 150 ) );
|
||||
mComposerScaleBar->setFontColor( QColor( 255, 0, 255, 100 ) );
|
||||
QgsCompositionChecker checker( QStringLiteral( "composerscalebar_singlebox_alpha" ), mComposition );
|
||||
checker.setControlPathPrefix( QStringLiteral( "composer_scalebar" ) );
|
||||
@ -173,9 +169,10 @@ void TestQgsComposerScaleBar::singleBoxAlpha()
|
||||
void TestQgsComposerScaleBar::doubleBox()
|
||||
{
|
||||
// cleanup singleBoxAlpha
|
||||
mComposerScaleBar->setBrush( QBrush( Qt::black ) );
|
||||
mComposerScaleBar->setBrush2( QBrush( Qt::white ) );
|
||||
mComposerScaleBar->setPen( mPrevPen );
|
||||
mComposerScaleBar->setFillColor( Qt::black );
|
||||
mComposerScaleBar->setFillColor2( Qt::white );
|
||||
mComposerScaleBar->setLineColor( Qt::black );
|
||||
mComposerScaleBar->setLineWidth( 0.3 );
|
||||
mComposerScaleBar->setFontColor( Qt::black );
|
||||
mComposerScaleBar->setStyle( QStringLiteral( "Double Box" ) );
|
||||
|
||||
@ -201,5 +198,19 @@ void TestQgsComposerScaleBar::tick()
|
||||
QVERIFY( checker.testComposition( mReport, 0, 0 ) );
|
||||
}
|
||||
|
||||
void TestQgsComposerScaleBar::dataDefined()
|
||||
{
|
||||
mComposerScaleBar->dataDefinedProperties().setProperty( QgsComposerObject::ScalebarFillColor, new QgsExpressionBasedProperty( "'red'" ) );
|
||||
mComposerScaleBar->dataDefinedProperties().setProperty( QgsComposerObject::ScalebarFillColor2, new QgsExpressionBasedProperty( "'blue'" ) );
|
||||
mComposerScaleBar->dataDefinedProperties().setProperty( QgsComposerObject::ScalebarLineColor, new QgsExpressionBasedProperty( "'yellow'" ) );
|
||||
mComposerScaleBar->dataDefinedProperties().setProperty( QgsComposerObject::ScalebarLineWidth, new QgsExpressionBasedProperty( "1.2" ) );
|
||||
mComposerScaleBar->refreshDataDefinedProperty();
|
||||
QCOMPARE( mComposerScaleBar->brush().color().name(), QColor( 255, 0, 0 ).name() );
|
||||
QCOMPARE( mComposerScaleBar->brush2().color().name(), QColor( 0, 0, 255 ).name() );
|
||||
QCOMPARE( mComposerScaleBar->pen().color().name(), QColor( 255, 255, 0 ).name() );
|
||||
QCOMPARE( mComposerScaleBar->pen().widthF(), 1.2 );
|
||||
mComposerScaleBar->setDataDefinedProperties( QgsPropertyCollection() );
|
||||
}
|
||||
|
||||
QGSTEST_MAIN( TestQgsComposerScaleBar )
|
||||
#include "testqgscomposerscalebar.moc"
|
||||
|
Loading…
x
Reference in New Issue
Block a user