Skip to content

Commit e4fb95f

Browse files
committed
[pal] Some const correctness and avoid passing large object by value
1 parent 249af5f commit e4fb95f

File tree

3 files changed

+46
-46
lines changed

3 files changed

+46
-46
lines changed

python/core/qgspallabeling.sip

+19-19
Original file line numberDiff line numberDiff line change
@@ -558,44 +558,44 @@ class QgsLabelComponent
558558

559559
// methods
560560

561-
const QString& text();
561+
const QString& text() const;
562562
void setText( const QString& text );
563563

564-
const QgsPoint& origin();
565-
void setOrigin( QgsPoint point );
564+
const QgsPoint& origin() const;
565+
void setOrigin( const QgsPoint& point );
566566

567567
bool useOrigin() const;
568-
void setUseOrigin( bool use );
568+
void setUseOrigin( const bool use );
569569

570570
double rotation() const;
571-
void setRotation( double rotation );
571+
void setRotation( const double rotation );
572572

573573
double rotationOffset() const;
574-
void setRotationOffset( double rotation );
574+
void setRotationOffset( const double rotation );
575575

576576
bool useRotation() const;
577-
void setUseRotation( bool use );
577+
void setUseRotation( const bool use );
578578

579-
const QgsPoint& center();
580-
void setCenter( QgsPoint point );
579+
const QgsPoint& center() const;
580+
void setCenter( const QgsPoint& point );
581581

582582
bool useCenter() const;
583-
void setUseCenter( bool use );
583+
void setUseCenter( const bool use );
584584

585-
const QgsPoint& size();
586-
void setSize( QgsPoint point );
585+
const QgsPoint& size() const;
586+
void setSize( const QgsPoint& point );
587587

588-
const QgsPoint& offset();
589-
void setOffset( QgsPoint point );
588+
const QgsPoint& offset() const;
589+
void setOffset( const QgsPoint& point );
590590

591-
const QPicture* picture();
591+
const QPicture* picture() const;
592592
void setPicture( QPicture* picture );
593593

594594
double pictureBuffer() const;
595-
void setPictureBuffer( double buffer );
595+
void setPictureBuffer( const double buffer );
596596

597597
double dpiRatio() const;
598-
void setDpiRatio( double ratio );
598+
void setDpiRatio( const double ratio );
599599
};
600600

601601

@@ -721,15 +721,15 @@ class QgsPalLabeling : QgsLabelingEngineInterface
721721
// void drawLabel( pal::LabelPosition* label, QgsRenderContext& context, QgsPalLayerSettings& tmpLyr, DrawLabelType drawType );
722722

723723
static void drawLabelBuffer( QgsRenderContext& context,
724-
QgsLabelComponent component,
724+
const QgsLabelComponent& component,
725725
const QgsPalLayerSettings& tmpLyr );
726726

727727
static void drawLabelBackground( QgsRenderContext& context,
728728
QgsLabelComponent component,
729729
const QgsPalLayerSettings& tmpLyr );
730730

731731
static void drawLabelShadow( QgsRenderContext& context,
732-
QgsLabelComponent component,
732+
const QgsLabelComponent& component,
733733
const QgsPalLayerSettings& tmpLyr );
734734

735735
//! load/save engine settings to project file

src/core/qgspallabeling.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -4458,7 +4458,7 @@ void QgsPalLabeling::drawLabel( pal::LabelPosition* label, QgsRenderContext& con
44584458
}
44594459

44604460
void QgsPalLabeling::drawLabelBuffer( QgsRenderContext& context,
4461-
QgsLabelComponent component,
4461+
const QgsLabelComponent& component,
44624462
const QgsPalLayerSettings& tmpLyr )
44634463
{
44644464
QPainter* p = context.painter();
@@ -4489,11 +4489,11 @@ void QgsPalLabeling::drawLabelBuffer( QgsRenderContext& context,
44894489

44904490
if ( tmpLyr.shadowDraw && tmpLyr.shadowUnder == QgsPalLayerSettings::ShadowBuffer )
44914491
{
4492-
component.setOrigin( QgsPoint( 0.0, 0.0 ) );
4493-
component.setPicture( &buffPict );
4494-
component.setPictureBuffer( penSize / 2.0 );
4495-
4496-
drawLabelShadow( context, component, tmpLyr );
4492+
QgsLabelComponent bufferComponent = component;
4493+
bufferComponent.setOrigin( QgsPoint( 0.0, 0.0 ) );
4494+
bufferComponent.setPicture( &buffPict );
4495+
bufferComponent.setPictureBuffer( penSize / 2.0 );
4496+
drawLabelShadow( context, bufferComponent, tmpLyr );
44974497
}
44984498

44994499
p->save();
@@ -4810,7 +4810,7 @@ void QgsPalLabeling::drawLabelBackground( QgsRenderContext& context,
48104810
}
48114811

48124812
void QgsPalLabeling::drawLabelShadow( QgsRenderContext& context,
4813-
QgsLabelComponent component,
4813+
const QgsLabelComponent& component,
48144814
const QgsPalLayerSettings& tmpLyr )
48154815
{
48164816
// incoming component sizes should be multiplied by rasterCompressFactor, as

src/core/qgspallabeling.h

+20-20
Original file line numberDiff line numberDiff line change
@@ -604,44 +604,44 @@ class CORE_EXPORT QgsLabelComponent
604604

605605
// methods
606606

607-
const QString& text() { return mText; }
607+
const QString& text() const { return mText; }
608608
void setText( const QString& text ) { mText = text; }
609609

610-
const QgsPoint& origin() { return mOrigin; }
611-
void setOrigin( QgsPoint point ) { mOrigin = point; }
610+
const QgsPoint& origin() const { return mOrigin; }
611+
void setOrigin( const QgsPoint& point ) { mOrigin = point; }
612612

613613
bool useOrigin() const { return mUseOrigin; }
614-
void setUseOrigin( bool use ) { mUseOrigin = use; }
614+
void setUseOrigin( const bool use ) { mUseOrigin = use; }
615615

616616
double rotation() const { return mRotation; }
617-
void setRotation( double rotation ) { mRotation = rotation; }
617+
void setRotation( const double rotation ) { mRotation = rotation; }
618618

619619
double rotationOffset() const { return mRotationOffset; }
620-
void setRotationOffset( double rotation ) { mRotationOffset = rotation; }
620+
void setRotationOffset( const double rotation ) { mRotationOffset = rotation; }
621621

622622
bool useRotation() const { return mUseRotation; }
623-
void setUseRotation( bool use ) { mUseRotation = use; }
623+
void setUseRotation( const bool use ) { mUseRotation = use; }
624624

625-
const QgsPoint& center() { return mCenter; }
626-
void setCenter( QgsPoint point ) { mCenter = point; }
625+
const QgsPoint& center() const { return mCenter; }
626+
void setCenter( const QgsPoint& point ) { mCenter = point; }
627627

628628
bool useCenter() const { return mUseCenter; }
629-
void setUseCenter( bool use ) { mUseCenter = use; }
629+
void setUseCenter( const bool use ) { mUseCenter = use; }
630630

631-
const QgsPoint& size() { return mSize; }
632-
void setSize( QgsPoint point ) { mSize = point; }
631+
const QgsPoint& size() const { return mSize; }
632+
void setSize( const QgsPoint& point ) { mSize = point; }
633633

634-
const QgsPoint& offset() { return mOffset; }
635-
void setOffset( QgsPoint point ) { mOffset = point; }
634+
const QgsPoint& offset() const { return mOffset; }
635+
void setOffset( const QgsPoint& point ) { mOffset = point; }
636636

637-
const QPicture* picture() { return mPicture; }
637+
const QPicture* picture() const { return mPicture; }
638638
void setPicture( QPicture* picture ) { mPicture = picture; }
639639

640640
double pictureBuffer() const { return mPictureBuffer; }
641-
void setPictureBuffer( double buffer ) { mPictureBuffer = buffer; }
641+
void setPictureBuffer( const double buffer ) { mPictureBuffer = buffer; }
642642

643643
double dpiRatio() const { return mDpiRatio; }
644-
void setDpiRatio( double ratio ) { mDpiRatio = ratio; }
644+
void setDpiRatio( const double ratio ) { mDpiRatio = ratio; }
645645

646646
private:
647647
// current label component text,
@@ -795,15 +795,15 @@ class CORE_EXPORT QgsPalLabeling : public QgsLabelingEngineInterface
795795
virtual void drawLabel( pal::LabelPosition* label, QgsRenderContext& context, QgsPalLayerSettings& tmpLyr, DrawLabelType drawType, double dpiRatio = 1.0 );
796796

797797
static void drawLabelBuffer( QgsRenderContext& context,
798-
QgsLabelComponent component,
798+
const QgsLabelComponent &component,
799799
const QgsPalLayerSettings& tmpLyr );
800800

801801
static void drawLabelBackground( QgsRenderContext& context,
802802
QgsLabelComponent component,
803803
const QgsPalLayerSettings& tmpLyr );
804804

805-
static void drawLabelShadow( QgsRenderContext& context,
806-
QgsLabelComponent component,
805+
static void drawLabelShadow( QgsRenderContext &context,
806+
const QgsLabelComponent &component,
807807
const QgsPalLayerSettings& tmpLyr );
808808

809809
//! load/save engine settings to project file

0 commit comments

Comments
 (0)