Skip to content
Permalink
Browse files
Merge pull request #4389 from nyalldawson/scalebar
Refactor scalebar renderer, split from composer
  • Loading branch information
nyalldawson committed Apr 26, 2017
2 parents 16cb244 + 9e4f9d4 commit fea6bff70751f789dee210c444940db53b8b2aee
Showing with 2,270 additions and 1,254 deletions.
  1. +1 −0 doc/CMakeLists.txt
  2. +13 −0 doc/api_break.dox
  3. +1 −0 python/CMakeLists.txt
  4. +9 −50 python/core/composer/qgscomposerscalebar.sip
  5. +0 −13 python/core/composer/qgsdoubleboxscalebarstyle.sip
  6. +0 −16 python/core/composer/qgsnumericscalebarstyle.sip
  7. +0 −21 python/core/composer/qgsscalebarstyle.sip
  8. +0 −17 python/core/composer/qgssingleboxscalebarstyle.sip
  9. +0 −26 python/core/composer/qgsticksscalebarstyle.sip
  10. +8 −5 python/core/core.sip
  11. +42 −0 python/core/scalebar/qgsdoubleboxscalebarrenderer.sip
  12. +45 −0 python/core/scalebar/qgsnumericscalebarrenderer.sip
  13. +116 −0 python/core/scalebar/qgsscalebarrenderer.sip
  14. +397 −0 python/core/scalebar/qgsscalebarsettings.sip
  15. +43 −0 python/core/scalebar/qgssingleboxscalebarrenderer.sip
  16. +63 −0 python/core/scalebar/qgsticksscalebarrenderer.sip
  17. +1 −0 src/app/CMakeLists.txt
  18. +13 −13 src/app/composer/qgscomposerscalebarwidget.cpp
  19. +14 −10 src/core/CMakeLists.txt
  20. +199 −236 src/core/composer/qgscomposerscalebar.cpp
  21. +67 −124 src/core/composer/qgscomposerscalebar.h
  22. +0 −93 src/core/composer/qgsdoubleboxscalebarstyle.cpp
  23. +0 −39 src/core/composer/qgsdoubleboxscalebarstyle.h
  24. +0 −123 src/core/composer/qgsnumericscalebarstyle.cpp
  25. +0 −47 src/core/composer/qgsnumericscalebarstyle.h
  26. +0 −132 src/core/composer/qgsscalebarstyle.cpp
  27. +0 −58 src/core/composer/qgsscalebarstyle.h
  28. +0 −83 src/core/composer/qgssingleboxscalebarstyle.cpp
  29. +0 −99 src/core/composer/qgsticksscalebarstyle.cpp
  30. +81 −0 src/core/scalebar/qgsdoubleboxscalebarrenderer.cpp
  31. +21 −28 src/core/{composer/qgsticksscalebarstyle.h → scalebar/qgsdoubleboxscalebarrenderer.h}
  32. +75 −0 src/core/scalebar/qgsnumericscalebarrenderer.cpp
  33. +55 −0 src/core/scalebar/qgsnumericscalebarrenderer.h
  34. +172 −0 src/core/scalebar/qgsscalebarrenderer.cpp
  35. +116 −0 src/core/scalebar/qgsscalebarrenderer.h
  36. +456 −0 src/core/scalebar/qgsscalebarsettings.h
  37. +67 −0 src/core/scalebar/qgssingleboxscalebarrenderer.cpp
  38. +21 −18 src/core/{composer/qgssingleboxscalebarstyle.h → scalebar/qgssingleboxscalebarrenderer.h}
  39. +92 −0 src/core/scalebar/qgsticksscalebarrenderer.cpp
  40. +69 −0 src/core/scalebar/qgsticksscalebarrenderer.h
  41. +1 −0 src/gui/CMakeLists.txt
  42. +1 −1 src/gui/qgscomposerview.cpp
  43. +1 −0 tests/src/core/CMakeLists.txt
  44. +10 −2 tests/src/core/testqgscomposerscalebar.cpp
  45. BIN ..._images/composer_scalebar/expected_composerscalebar_numeric/expected_composerscalebar_numeric.png
  46. BIN ...es/composer_scalebar/expected_composerscalebar_numeric/expected_composerscalebar_numeric_mask.png
1 doc/CMakeLists.txt 100644 → 100755
@@ -66,6 +66,7 @@ IF(WITH_APIDOC)
${CMAKE_SOURCE_DIR}/src/core/pal
${CMAKE_SOURCE_DIR}/src/core/processing
${CMAKE_SOURCE_DIR}/src/core/raster
${CMAKE_SOURCE_DIR}/src/core/scalebar
${CMAKE_SOURCE_DIR}/src/core/symbology-ng
${CMAKE_SOURCE_DIR}/src/gui
${CMAKE_SOURCE_DIR}/src/gui/auth
@@ -85,6 +85,7 @@ Renamed Classes {#qgis_api_break_3_0_renamed_classes}
<tr><td>QgsCurveV2<td>QgsCurve
<tr><td>QgsDbFilterProxyModel<td>QgsDatabaseFilterProxyModel
<tr><td>QgsDiagramRendererV2<td>QgsDiagramRenderer
<tr><td>QgsDoubleBoxBarStyle<td>QgsDoubleBoxScaleBarRenderer
<tr><td>QgsEditorWidgetV2<td>QgsEditorWidget
<tr><td>QgsEllipseSymbolLayerV2<td>QgsEllipseSymbolLayer
<tr><td>QgsEllipseSymbolLayerV2Widget<td>QgsEllipseSymbolLayerWidget
@@ -115,6 +116,7 @@ Renamed Classes {#qgis_api_break_3_0_renamed_classes}
<tr><td>QgsMultiCurveV2<td>QgsMultiCurve
<tr><td>QgsMultiLineStringV2<td>QgsMultiLineString
<tr><td>QgsMultiSurfaceV2<td>QgsMultiSurface
<tr><td>QgsNumericScaleBarStyle<td>QgsNumericScaleBarRenderer
<tr><td>QgsPointSequenceV2<td>QgsPointSequence
<tr><td>QgsProperty<td>QgsProjectProperty
<tr><td>QgsPropertyKey<td>QgsProjectPropertyKey
@@ -140,6 +142,7 @@ Renamed Classes {#qgis_api_break_3_0_renamed_classes}
<tr><td>QgsRuleBasedRendererV2Count<td>QgsRuleBasedRendererCount
<tr><td>QgsRuleBasedRendererV2Model<td>QgsRuleBasedRendererModel
<tr><td>QgsRuleBasedRendererV2Widget<td>QgsRuleBasedRendererWidget
<tr><td>QgsScaleBarStyle<td>QgsScaleBarRenderer
<tr><td>QgsShapeburstFillSymbolLayerV2<td>QgsShapeburstFillSymbolLayer
<tr><td>QgsShapeburstFillSymbolLayerV2Widget<td>QgsShapeburstFillSymbolLayerWidget
<tr><td>QgsSimpleFillSymbolLayerV2<td>QgsSimpleFillSymbolLayer
@@ -148,6 +151,7 @@ Renamed Classes {#qgis_api_break_3_0_renamed_classes}
<tr><td>QgsSimpleLineSymbolLayerV2Widget<td>QgsSimpleLineSymbolLayerWidget
<tr><td>QgsSimpleMarkerSymbolLayerV2<td>QgsSimpleMarkerSymbolLayer
<tr><td>QgsSimpleMarkerSymbolLayerV2Widget<td>QgsSimpleMarkerSymbolLayerWidget
<tr><td>QgsSingleBoxScaleBarStyle<td>QgsSingleBoxScaleBarRenderer
<tr><td>QgsSingleSymbolRendererV2<td>QgsSingleSymbolRenderer
<tr><td>QgsSingleSymbolRendererV2Widget<td>QgsSingleSymbolRendererWidget
<tr><td>QgsStyleV2<td>QgsStyle
@@ -171,6 +175,7 @@ Renamed Classes {#qgis_api_break_3_0_renamed_classes}
<tr><td>QgsSymbolV2RenderContext<td>QgsSymbolRenderContext
<tr><td>QgsSymbolV2SelectorDialog<td>QgsSymbolSelectorDialog
<tr><td>QgsSymbolV2SelectorWidget<td>QgsSymbolSelectorWidget
<tr><td>QgsTicksScaleBarStyle<td>QgsTicksScaleBarRenderer
<tr><td>QgsVectorColorBrewerColorRampV2<td>QgsColorBrewerColorRamp
<tr><td>QgsVectorColorBrewerColorRampV2Dialog<td>QgsColorBrewerColorRampDialog
<tr><td>QgsVectorColorBrewerColorRampV2DialogBase<td>QgsColorBrewerColorRampDialogBase
@@ -684,9 +689,12 @@ QgsComposerObject::setDataDefinedProperty() instead.
QgsComposerScaleBar {#qgis_api_break_3_0_QgsComposerScaleBar}
-------------------

- The Alignment and SegmentSizeMode enums were moved to QgsScaleBarSettings
- The ScaleBarUnits enum was removed. Use QgsUnitTypes::DistanceUnit instead.
- setBrush() was removed. Use setFillColor() instead.
- setBrush2() was removed. Use setFillColor2() instead.
- setPen() was removed. Use setLineColor() and setLineWidth() instead.
- segmentMillimeters() and firstLabelString() were removed.


QgsComposerTable {#qgis_api_break_3_0_QgsComposerTable}
@@ -1837,6 +1845,11 @@ QgsRuntimeProfiler {#qgis_api_break_3_0_QgsRuntimeProfiler}

- This class is no longer a singleton and instance() has been removed. Instead use QgsApplication::profiler() to access an application-wide profiler.

QgsScaleBarStyle {#qgis_api_break_3_0_QgsScaleBarStyle}
----------------

- The interface for QgsScaleBarStyle has been completely rewritten - any code using QgsScaleBarStyle or subclasses will need to update
to the new draw() and calculateBoxSize() methods.

QgsServer {#qgis_api_break_3_0_QgsServer}
----------
1 python/CMakeLists.txt 100644 → 100755
@@ -107,6 +107,7 @@ INCLUDE_DIRECTORIES(
../src/core/layertree
../src/core/processing
../src/core/raster
../src/core/scalebar
../src/core/symbology-ng

../src/gui/raster
@@ -10,29 +10,6 @@ class QgsComposerScaleBar: QgsComposerItem

public:

enum Alignment
{
Left,
Middle,
Right
};

enum ScaleBarUnits
{
MapUnits,
Meters,
Feet,
NauticalMiles
};

/** Modes for setting size for scale bar segments
*/
enum SegmentSizeMode
{
SegmentSizeFixed, /*!< Scale bar segment size is fixed to a map unit*/
SegmentSizeFitWidth /*!< Scale bar segment size is calculated to fit a size range*/
};

QgsComposerScaleBar( QgsComposition* composition /TransferThis/ );
~QgsComposerScaleBar();

@@ -58,7 +35,7 @@ class QgsComposerScaleBar: QgsComposerItem
* @see maxBarWidth
* @note added in QGIS 2.9
*/
SegmentSizeMode segmentSizeMode() const;
QgsScaleBarSettings::SegmentSizeMode segmentSizeMode() const;

/** Sets the size mode for scale bar segments.
* @param mode size mode
@@ -67,7 +44,7 @@ class QgsComposerScaleBar: QgsComposerItem
* @see setMaxBarWidth
* @note added in QGIS 2.9
*/
void setSegmentSizeMode( SegmentSizeMode mode );
void setSegmentSizeMode( QgsScaleBarSettings::SegmentSizeMode mode );

/** Returns the minimum size (in millimeters) for scale bar segments. This
* property is only effective if the @link segmentSizeMode @endlink is set
@@ -212,25 +189,23 @@ class QgsComposerScaleBar: QgsComposerItem
double height() const;
void setHeight( double h );

void setComposerMap( const QgsComposerMap* map );
const QgsComposerMap* composerMap();
void setComposerMap( QgsComposerMap* map );
QgsComposerMap* composerMap();

double labelBarSpace() const;
void setLabelBarSpace( double space );

double boxContentSpace() const;
void setBoxContentSpace( double space );

double segmentMillimeters() const;

/** Left / Middle/ Right */
Alignment alignment() const;
QgsScaleBarSettings::Alignment alignment() const;

void setAlignment( Alignment a );
void setAlignment( QgsScaleBarSettings::Alignment a );

ScaleBarUnits units() const;
QgsUnitTypes::DistanceUnit units() const;

void setUnits( ScaleBarUnits u );
void setUnits( QgsUnitTypes::DistanceUnit u );

/** Returns the join style used for drawing lines in the scalebar
* @returns Join style for lines
@@ -263,7 +238,7 @@ class QgsComposerScaleBar: QgsComposerItem
/** Apply default settings*/
void applyDefaultSettings();
/** Apply default size (scale bar 1/5 of map item width) */
void applyDefaultSize( ScaleBarUnits u = Meters );
void applyDefaultSize( QgsUnitTypes::DistanceUnit u = QgsUnitTypes::DistanceMeters );

/** Sets style by name
@param styleName (untranslated) style name. Possibilities are: 'Single Box', 'Double Box', 'Line Ticks Middle', 'Line Ticks Down', 'Line Ticks Up', 'Numeric'*/
@@ -272,21 +247,12 @@ class QgsComposerScaleBar: QgsComposerItem
/** Returns style name*/
QString style() const;

/** Returns the x - positions of the segment borders (in item coordinates) and the width
* of the segment
* @note not available in Python bindings
*/
// void segmentPositions( QList<QPair<double, double> >& posWidthList ) const;

/** Sets box size suitable to content*/
void adjustBoxSize();

/** Adjusts box size and calls QgsComposerItem::update()*/
void update();

/** Returns string of first label (important for drawing, labeling, size calculation*/
QString firstLabelString() const;

/** Stores state in Dom element
* @param elem is Dom element corresponding to 'Composer' tag
* @param doc Dom document
@@ -311,11 +277,4 @@ class QgsComposerScaleBar: QgsComposerItem
void invalidateCurrentMap();
virtual void refreshDataDefinedProperty( const QgsComposerObject::DataDefinedProperty property = QgsComposerObject::AllProperties, const QgsExpressionContext* context = nullptr );

protected:
/** Calculates with of a segment in mm and stores it in mSegmentMillimeters*/
void refreshSegmentMillimeters();

/** Returns diagonal of composer map in selected units (map units / meters / feet / nautical miles)*/
double mapWidth() const;

};

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

@@ -231,13 +231,9 @@
%Include composer/qgscomposertexttable.sip
%Include composer/qgscomposerutils.sip
%Include composer/qgscomposition.sip
%Include composer/qgsdoubleboxscalebarstyle.sip
%Include composer/qgslayoutmanager.sip
%Include composer/qgsnumericscalebarstyle.sip
%Include composer/qgspaperitem.sip
%Include composer/qgsscalebarstyle.sip
%Include composer/qgssingleboxscalebarstyle.sip
%Include composer/qgsticksscalebarstyle.sip


%Include diagram/qgsdiagram.sip
%Include diagram/qgshistogramdiagram.sip
@@ -328,6 +324,13 @@
%Include raster/qgssinglebandpseudocolorrenderer.sip
%Include raster/qgshillshaderenderer.sip

%Include scalebar/qgsdoubleboxscalebarrenderer.sip
%Include scalebar/qgsnumericscalebarrenderer.sip
%Include scalebar/qgsscalebarrenderer.sip
%Include scalebar/qgsscalebarsettings.sip
%Include scalebar/qgssingleboxscalebarrenderer.sip
%Include scalebar/qgsticksscalebarrenderer.sip

%Include symbology-ng/qgscolorbrewerpalette.sip
%Include symbology-ng/qgscptcityarchive.sip
%Include symbology-ng/qgsstyle.sip
@@ -0,0 +1,42 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/scalebar/qgsdoubleboxscalebarrenderer.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/



class QgsDoubleBoxScaleBarRenderer: QgsScaleBarRenderer
{
%Docstring
Double box with alternating colors.
.. versionadded:: 3.0
%End

%TypeHeaderCode
#include "qgsdoubleboxscalebarrenderer.h"
%End
public:

QgsDoubleBoxScaleBarRenderer();
%Docstring
Constructor for QgsDoubleBoxScaleBarRenderer.
%End

virtual QString name() const;

virtual void draw( QgsRenderContext &context,
const QgsScaleBarSettings &settings,
const QgsScaleBarRenderer::ScaleBarContext &scaleContext ) const;

};

/************************************************************************
* This file has been generated automatically from *
* *
* src/core/scalebar/qgsdoubleboxscalebarrenderer.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
Loading

0 comments on commit fea6bff

Please sign in to comment.