Skip to content

Commit

Permalink
Move QgsSymbolV2::OutputUnit enum to QgsUnitTypes
Browse files Browse the repository at this point in the history
And rename to QgsUnitTypes::RenderUnits. This enum is used in
much more contexts than just symbols, so QgsUnitTypes is a
better fit for it.

All methods which previously accepted QgsSymbolV2::OutputUnit
parameters or QgsSymbolV2::OutputUnitList parameters now take
QgsUnitTypes::RenderUnit or QgsUnitTypes::RenderUnitList
parameters respectively.
  • Loading branch information
nyalldawson committed Jul 25, 2016
1 parent f6f5010 commit ce6bd6c
Show file tree
Hide file tree
Showing 97 changed files with 838 additions and 822 deletions.
9 changes: 9 additions & 0 deletions doc/api_break.dox
Expand Up @@ -447,6 +447,15 @@ has improved sort capabilities including the ability to set custom sort values f
and for forcing certain items to always sort on top.</li>
</ul>

\subsection qgis_api_break_3_0_QgsSymbolV2 QgsSymbolV2

<ul>
<li>The OutputUnit enum, including QgsSymbolV2::MM, QgsSymbolV2::MapUnit, QgsSymbolV2::Mixed, QgsSymbolV2::Pixel and QgsSymbolV2::Percentage has been moved to QgsUnitTypes
and renamed to RenderUnit. QgsSymbolV2::OutputUnitList was renamed to QgsUnitTypes::RenderUnitList. All methods which previously accepted QgsSymbolV2::OutputUnit
parameters or QgsSymbolV2::OutputUnitList parameters now take QgsUnitTypes::RenderUnit or QgsUnitTypes::RenderUnitList parameters respectively.</li>
<li>subsetString() was made const. This has no effect on PyQGIS code, but c++ code implementing derived layer classes will need to update the signature of this method to match.</li>
</ul>

\subsection qgis_api_break_3_0_QgsTreeWidgetItem QgsTreeWidgetItem

<ul>
Expand Down
2 changes: 1 addition & 1 deletion python/core/dxf/qgsdxfexport.sip
Expand Up @@ -327,7 +327,7 @@ class QgsDxfExport
//! @note added in 2.15
void writeMText( const QString &layer, const QString &text, const QgsPointV2 &pt, double width, double angle, const QColor& color );

static double mapUnitScaleFactor( double scaleDenominator, QgsSymbolV2::OutputUnit symbolUnits, QgsUnitTypes::DistanceUnit mapUnits );
static double mapUnitScaleFactor( double scaleDenominator, QgsUnitTypes::RenderUnit symbolUnits, QgsUnitTypes::DistanceUnit mapUnits );

//! Return cleaned layer name for use in DXF
static QString dxfLayerName( const QString &name );
Expand Down
4 changes: 2 additions & 2 deletions python/core/effects/qgsgloweffect.sip
Expand Up @@ -50,15 +50,15 @@ class QgsGlowEffect : QgsPaintEffect
* @see setSpread
* @see setSpreadMapUnitScale
*/
void setSpreadUnit( const QgsSymbolV2::OutputUnit unit );
void setSpreadUnit( const QgsUnitTypes::RenderUnit unit );

/** Returns the units used for the glow spread distance.
* @returns units for spread distance
* @see setSpreadUnit
* @see spread
* @see spreadMapUnitScale
*/
QgsSymbolV2::OutputUnit spreadUnit() const;
QgsUnitTypes::RenderUnit spreadUnit() const;

/** Sets the map unit scale used for the spread distance.
* @param scale map unit scale for spread distance
Expand Down
4 changes: 2 additions & 2 deletions python/core/effects/qgsshadoweffect.sip
Expand Up @@ -69,15 +69,15 @@ class QgsShadowEffect : QgsPaintEffect
* @see setOffsetDistance
* @see setOffsetMapUnitScale
*/
void setOffsetUnit( const QgsSymbolV2::OutputUnit unit );
void setOffsetUnit( const QgsUnitTypes::RenderUnit unit );

/** Returns the units used for the shadow offset distance.
* @returns units for offset distance
* @see setOffsetUnit
* @see offsetDistance
* @see offsetMapUnitScale
*/
QgsSymbolV2::OutputUnit offsetUnit() const;
QgsUnitTypes::RenderUnit offsetUnit() const;

/** Sets the map unit scale used for the shadow offset distance.
* @param scale map unit scale for offset distance
Expand Down
4 changes: 2 additions & 2 deletions python/core/effects/qgstransformeffect.sip
Expand Up @@ -71,7 +71,7 @@ class QgsTransformEffect : QgsPaintEffect
* @see setTranslateY
* @see setTranslateMapUnitScale
*/
void setTranslateUnit( const QgsSymbolV2::OutputUnit unit );
void setTranslateUnit( const QgsUnitTypes::RenderUnit unit );

/** Returns the units used for the transform translation.
* @returns units for translation
Expand All @@ -80,7 +80,7 @@ class QgsTransformEffect : QgsPaintEffect
* @see translateY
* @see translateMapUnitScale
*/
QgsSymbolV2::OutputUnit translateUnit() const;
QgsUnitTypes::RenderUnit translateUnit() const;

/** Sets the map unit scale used for the transform translation.
* @param scale map unit scale for translation
Expand Down
4 changes: 2 additions & 2 deletions python/core/qgsdiagramrendererv2.sip
Expand Up @@ -285,7 +285,7 @@ class QgsDiagramSettings

/** Diagram size unit
*/
QgsSymbolV2::OutputUnit sizeType;
QgsUnitTypes::RenderUnit sizeType;

/** Diagram size unit scale
* @note added in 2.16
Expand All @@ -295,7 +295,7 @@ class QgsDiagramSettings
/** Line unit index
* @note added in 2.16
*/
QgsSymbolV2::OutputUnit lineSizeUnit;
QgsUnitTypes::RenderUnit lineSizeUnit;

/** Line unit scale
* @note added in 2.16
Expand Down
31 changes: 31 additions & 0 deletions python/core/qgsunittypes.sip
Expand Up @@ -61,6 +61,19 @@ class QgsUnitTypes
UnknownAngleUnit, /*!< unknown angle unit */
};

//! List of render units
typedef QList<QgsUnitTypes::RenderUnit> RenderUnitList;

//! Rendering size units
enum RenderUnit
{
RenderMillimeters, //!< millimeters
RenderMapUnits, //!< map units
RenderPixels, //!< pixels
RenderPercentage, //!< percentage of another measurement (eg canvas size, feature size)
UnknownRenderUnit, //!< mixed or unknown units
};

/** Returns the type for a distance unit.
*/
static DistanceUnitType unitType( QgsUnitTypes::DistanceUnit unit );
Expand Down Expand Up @@ -181,5 +194,23 @@ class QgsUnitTypes
* @returns formatted angle string
*/
static QString formatAngle( double angle, int decimals, AngleUnit unit );

// RENDER UNITS

/** Encodes a render unit to a string.
* @param unit unit to encode
* @returns encoded string
* @see decodeRenderUnit()
*/
static QString encodeUnit( RenderUnit unit );

/** Decodes a render unit from a string.
* @param string string to decode
* @param ok optional boolean, will be set to true if string was converted successfully
* @returns decoded units
* @see encodeUnit()
*/
static RenderUnit decodeRenderUnit( const QString& string, bool *ok = 0 );

};

16 changes: 8 additions & 8 deletions python/core/symbology-ng/qgsarrowsymbollayer.sip
Expand Up @@ -39,9 +39,9 @@ class QgsArrowSymbolLayer : public QgsLineSymbolLayerV2
/** Set the arrow width */
void setArrowWidth( double width );
/** Get the unit for the arrow width */
QgsSymbolV2::OutputUnit arrowWidthUnit() const;
QgsUnitTypes::RenderUnit arrowWidthUnit() const;
/** Set the unit for the arrow width */
void setArrowWidthUnit( QgsSymbolV2::OutputUnit unit );
void setArrowWidthUnit( QgsUnitTypes::RenderUnit unit );
/** Get the scale for the arrow width */
QgsMapUnitScale arrowWidthUnitScale() const;
/** Set the scale for the arrow width */
Expand All @@ -52,9 +52,9 @@ class QgsArrowSymbolLayer : public QgsLineSymbolLayerV2
/** Set the arrow start width */
void setArrowStartWidth( double width );
/** Get the unit for the arrow start width */
QgsSymbolV2::OutputUnit arrowStartWidthUnit() const;
QgsUnitTypes::RenderUnit arrowStartWidthUnit() const;
/** Set the unit for the arrow start width */
void setArrowStartWidthUnit( QgsSymbolV2::OutputUnit unit );
void setArrowStartWidthUnit( QgsUnitTypes::RenderUnit unit );
/** Get the scale for the arrow start width */
QgsMapUnitScale arrowStartWidthUnitScale() const;
/** Set the scale for the arrow start width */
Expand All @@ -65,9 +65,9 @@ class QgsArrowSymbolLayer : public QgsLineSymbolLayerV2
/** Set the arrow head length */
void setHeadLength( double length );
/** Get the unit for the head length */
QgsSymbolV2::OutputUnit headLengthUnit() const;
QgsUnitTypes::RenderUnit headLengthUnit() const;
/** Set the unit for the head length */
void setHeadLengthUnit( QgsSymbolV2::OutputUnit unit );
void setHeadLengthUnit( QgsUnitTypes::RenderUnit unit );
/** Get the scale for the head length */
QgsMapUnitScale headLengthUnitScale() const;
/** Set the scale for the head length */
Expand All @@ -78,9 +78,9 @@ class QgsArrowSymbolLayer : public QgsLineSymbolLayerV2
/** Set the arrow head height */
void setHeadThickness( double thickness );
/** Get the unit for the head height */
QgsSymbolV2::OutputUnit headThicknessUnit() const;
QgsUnitTypes::RenderUnit headThicknessUnit() const;
/** Set the unit for the head height */
void setHeadThicknessUnit( QgsSymbolV2::OutputUnit unit );
void setHeadThicknessUnit( QgsUnitTypes::RenderUnit unit );
/** Get the scale for the head height */
QgsMapUnitScale headThicknessUnitScale() const;
/** Set the scale for the head height */
Expand Down
16 changes: 8 additions & 8 deletions python/core/symbology-ng/qgsellipsesymbollayerv2.sip
Expand Up @@ -51,26 +51,26 @@ class QgsEllipseSymbolLayerV2 : QgsMarkerSymbolLayerV2
void setOutlineColor( const QColor& c );
QColor outlineColor() const;

void setSymbolWidthUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit symbolWidthUnit() const;
void setSymbolWidthUnit( QgsUnitTypes::RenderUnit unit );
QgsUnitTypes::RenderUnit symbolWidthUnit() const;

void setSymbolWidthMapUnitScale( const QgsMapUnitScale& scale);
const QgsMapUnitScale& symbolWidthMapUnitScale() const;

void setSymbolHeightUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit symbolHeightUnit() const;
void setSymbolHeightUnit( QgsUnitTypes::RenderUnit unit );
QgsUnitTypes::RenderUnit symbolHeightUnit() const;

void setSymbolHeightMapUnitScale( const QgsMapUnitScale& scale);
const QgsMapUnitScale& symbolHeightMapUnitScale() const;

void setOutlineWidthUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit outlineWidthUnit() const;
void setOutlineWidthUnit( QgsUnitTypes::RenderUnit unit );
QgsUnitTypes::RenderUnit outlineWidthUnit() const;

void setOutlineWidthMapUnitScale( const QgsMapUnitScale& scale);
const QgsMapUnitScale& outlineWidthMapUnitScale() const;

void setOutputUnit( QgsSymbolV2::OutputUnit unit );
QgsSymbolV2::OutputUnit outputUnit() const;
void setOutputUnit( QgsUnitTypes::RenderUnit unit );
QgsUnitTypes::RenderUnit outputUnit() const;

void setMapUnitScale( const QgsMapUnitScale& scale );
QgsMapUnitScale mapUnitScale() const;
Expand Down

0 comments on commit ce6bd6c

Please sign in to comment.