Skip to content
Permalink
Browse files
Port more scalebar functionality
  • Loading branch information
nyalldawson committed Nov 24, 2017
1 parent 7e7770b commit 5b1c690
Show file tree
Hide file tree
Showing 11 changed files with 1,680 additions and 114 deletions.
@@ -105,6 +105,20 @@ class QgsLayoutItem : QgsLayoutObject, QGraphicsRectItem, QgsLayoutUndoObjectInt
UndoLegendGroupFont,
UndoLegendLayerFont,
UndoLegendItemFont,
UndoScaleBarLineWidth,
UndoScaleBarSegmentSize,
UndoScaleBarSegmentsLeft,
UndoScaleBarSegments,
UndoScaleBarHeight,
UndoScaleBarFontColor,
UndoScaleBarFillColor,
UndoScaleBarFillColor2,
UndoScaleBarStrokeColor,
UndoScaleBarUnitText,
UndoScaleBarMapUnitsSegment,
UndoScaleBarLabelBarSize,
UndoScaleBarBoxContentSpace,

UndoCustomCommand,
};

@@ -24,7 +24,6 @@ class QgsLayoutItemScaleBar: QgsLayoutItem
%Docstring
Constructor for QgsLayoutItemScaleBar, with the specified parent ``layout``.
%End
~QgsLayoutItemScaleBar();

virtual int type() const;

@@ -38,6 +37,8 @@ class QgsLayoutItemScaleBar: QgsLayoutItem
The caller takes responsibility for deleting the returned object.
:rtype: QgsLayoutItemScaleBar
%End
virtual QgsLayoutSize minimumSize() const;


int numberOfSegments() const;
%Docstring
@@ -413,15 +414,11 @@ class QgsLayoutItemScaleBar: QgsLayoutItem
:rtype: str
%End

void adjustBoxSize();
%Docstring
Sets the scale bar box size to a size suitable for the scalebar content.
%End

void update();
%Docstring
Adjusts the scale bar box size and updates the item.
%End

virtual void refreshDataDefinedProperty( const QgsLayoutObject::DataDefinedProperty property = QgsLayoutObject::AllProperties );


@@ -193,6 +193,7 @@ SET(QGIS_APP_SRCS
layout/qgslayoutpolygonwidget.cpp
layout/qgslayoutpolylinewidget.cpp
layout/qgslayoutpropertieswidget.cpp
layout/qgslayoutscalebarwidget.cpp
layout/qgslayoutshapewidget.cpp

locator/qgsinbuiltlocatorfilters.cpp
@@ -402,6 +403,7 @@ SET (QGIS_APP_MOC_HDRS
layout/qgslayoutpolygonwidget.h
layout/qgslayoutpolylinewidget.h
layout/qgslayoutpropertieswidget.h
layout/qgslayoutscalebarwidget.h
layout/qgslayoutshapewidget.h

locator/qgsinbuiltlocatorfilters.h
@@ -37,6 +37,7 @@
#include "qgslayoutframe.h"
#include "qgslayoutitemhtml.h"
#include "qgslayouthtmlwidget.h"
#include "qgslayoutscalebarwidget.h"
#include "qgisapp.h"
#include "qgsmapcanvas.h"

@@ -143,10 +144,10 @@ void QgsLayoutAppUtils::registerGuiForKnownItemTypes()

// scalebar item

auto scalebarItemMetadata = qgis::make_unique< QgsLayoutItemGuiMetadata >( QgsLayoutItemRegistry::LayoutScaleBar, QObject::tr( "Scale Bar" ), QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddScalebar.svg" ) ),
auto scalebarItemMetadata = qgis::make_unique< QgsLayoutItemGuiMetadata >( QgsLayoutItemRegistry::LayoutScaleBar, QObject::tr( "Scale Bar" ), QgsApplication::getThemeIcon( QStringLiteral( "/mActionScaleBar.svg" ) ),
[ = ]( QgsLayoutItem * item )->QgsLayoutItemBaseWidget *
{
return nullptr;//new QgsLayoutLegendWidget( qobject_cast< QgsLayoutItemLegend * >( item ) );
return new QgsLayoutScaleBarWidget( qobject_cast< QgsLayoutItemScaleBar * >( item ) );
}, createRubberBand );
scalebarItemMetadata->setItemAddedToLayoutFunction( [ = ]( QgsLayoutItem * item )
{

0 comments on commit 5b1c690

Please sign in to comment.