Skip to content
Permalink
Browse files

[pal] Standardise naming

  • Loading branch information
nyalldawson committed Dec 29, 2019
1 parent 10bda51 commit 5b7decb37ac6488a3378be4228415a012ee40341
@@ -93,7 +93,7 @@ bool QgsLabelSearchTree::insertLabel( pal::LabelPosition *labelPos, QgsFeatureId
mSpatialIndex.insert( newEntry.get(), bounds );
mOwnedPositions.emplace_back( std::move( newEntry ) );

if ( pal::LabelPosition *next = labelPos->getNextPart() )
if ( pal::LabelPosition *next = labelPos->nextPart() )
{
return insertLabel( next, featureId, layerName, labeltext, labelfont, diagram, pinned, providerId, isUnplaced );
}
@@ -4161,8 +4161,8 @@ void QgsPalLabeling::drawLabelCandidateRect( pal::LabelPosition *lp, QPainter *p
candidates->append( QgsLabelCandidate( rect, lp->cost() * 1000 ) );

// show all parts of the multipart label
if ( lp->getNextPart() )
drawLabelCandidateRect( lp->getNextPart(), painter, xform, candidates );
if ( lp->nextPart() )
drawLabelCandidateRect( lp->nextPart(), painter, xform, candidates );
}

QgsLabelingResults::QgsLabelingResults()
@@ -492,8 +492,8 @@ void QgsVectorLayerLabelProvider::drawLabelPrivate( pal::LabelPosition *label, Q
painter->drawRect( rect );
painter->restore();

if ( label->getNextPart() )
drawLabelPrivate( label->getNextPart(), context, tmpLyr, drawType, dpiRatio );
if ( label->nextPart() )
drawLabelPrivate( label->nextPart(), context, tmpLyr, drawType, dpiRatio );

return;
}
@@ -616,8 +616,8 @@ void QgsVectorLayerLabelProvider::drawLabelPrivate( pal::LabelPosition *label, Q
}

// NOTE: this used to be within above multi-line loop block, at end. (a mistake since 2010? [LS])
if ( label->getNextPart() )
drawLabelPrivate( label->getNextPart(), context, tmpLyr, drawType, dpiRatio );
if ( label->nextPart() )
drawLabelPrivate( label->nextPart(), context, tmpLyr, drawType, dpiRatio );
}

const QgsPalLayerSettings &QgsVectorLayerLabelProvider::settings() const
@@ -1384,7 +1384,7 @@ std::size_t FeaturePart::createCurvedCandidatesAlongLine( std::vector< std::uniq
sin_avg += std::sin( tmp->getAlpha() );
cos_avg += std::cos( tmp->getAlpha() );
angle_last = tmp->getAlpha();
tmp = tmp->getNextPart();
tmp = tmp->nextPart();
}

double angle_diff_avg = li->char_num > 1 ? ( angle_diff / ( li->char_num - 1 ) ) : 0; // <0, pi> but pi/8 is much already
@@ -1424,7 +1424,7 @@ std::size_t FeaturePart::createCurvedCandidatesAlongLine( std::vector< std::uniq
while ( within && currentPos )
{
within = GeomFunction::containsCandidate( mLF->permissibleZonePrepared(), currentPos->getX(), currentPos->getY(), currentPos->getWidth(), currentPos->getHeight(), currentPos->getAlpha() );
currentPos = currentPos->getNextPart();
currentPos = currentPos->nextPart();
}
if ( !within )
{
@@ -152,8 +152,8 @@ LabelPosition::LabelPosition( const LabelPosition &other )
w = other.w;
h = other.h;

if ( other.nextPart )
nextPart = qgis::make_unique< LabelPosition >( *other.nextPart );
if ( other.mNextPart )
mNextPart = qgis::make_unique< LabelPosition >( *other.mNextPart );

partId = other.partId;
upsideDown = other.upsideDown;
@@ -176,8 +176,8 @@ bool LabelPosition::isIn( double *bbox )
return true;
}

if ( nextPart )
return nextPart->isIn( bbox );
if ( mNextPart )
return mNextPart->isIn( bbox );
else
return false;
}
@@ -193,8 +193,8 @@ bool LabelPosition::isIntersect( double *bbox )
return true;
}

if ( nextPart )
return nextPart->isIntersect( bbox );
if ( mNextPart )
return mNextPart->isIntersect( bbox );
else
return false;
}
@@ -210,9 +210,9 @@ bool LabelPosition::intersects( const GEOSPreparedGeometry *geometry )
{
return true;
}
else if ( nextPart )
else if ( mNextPart )
{
return nextPart->intersects( geometry );
return mNextPart->intersects( geometry );
}
}
catch ( GEOSException &e )
@@ -235,9 +235,9 @@ bool LabelPosition::within( const GEOSPreparedGeometry *geometry )
{
return false;
}
else if ( nextPart )
else if ( mNextPart )
{
return nextPart->within( geometry );
return mNextPart->within( geometry );
}
}
catch ( GEOSException &e )
@@ -258,8 +258,8 @@ bool LabelPosition::isInside( double *bbox )
return false;
}

if ( nextPart )
return nextPart->isInside( bbox );
if ( mNextPart )
return mNextPart->isInside( bbox );
else
return true;
}
@@ -269,7 +269,7 @@ bool LabelPosition::isInConflict( const LabelPosition *lp ) const
if ( this->probFeat == lp->probFeat ) // bugfix #1
return false; // always overlaping itself !

if ( !nextPart && !lp->nextPart )
if ( !nextPart() && !lp->nextPart() )
return isInConflictSinglePart( lp );
else
return isInConflictMultiPart( lp );
@@ -314,10 +314,10 @@ bool LabelPosition::isInConflictMultiPart( const LabelPosition *lp ) const
{
if ( tmp1->isInConflictSinglePart( tmp2 ) )
return true;
tmp2 = tmp2->getNextPart();
tmp2 = tmp2->nextPart();
}

tmp1 = tmp1->getNextPart();
tmp1 = tmp1->nextPart();
}
return false; // no conflict found
}
@@ -334,8 +334,8 @@ double LabelPosition::dX() const

int LabelPosition::partCount() const
{
if ( nextPart )
return nextPart->partCount() + 1;
if ( mNextPart )
return mNextPart->partCount() + 1;
else
return 1;
}
@@ -348,8 +348,8 @@ void LabelPosition::offsetPosition( double xOffset, double yOffset )
y[i] += yOffset;
}

if ( nextPart )
nextPart->offsetPosition( xOffset, yOffset );
if ( mNextPart )
mNextPart->offsetPosition( xOffset, yOffset );

invalidateGeos();
}
@@ -389,9 +389,9 @@ FeaturePart *LabelPosition::getFeaturePart() const

void LabelPosition::getBoundingBox( double amin[2], double amax[2] ) const
{
if ( nextPart )
if ( mNextPart )
{
nextPart->getBoundingBox( amin, amax );
mNextPart->getBoundingBox( amin, amax );
}
else
{
@@ -416,15 +416,15 @@ void LabelPosition::getBoundingBox( double amin[2], double amax[2] ) const
void LabelPosition::setConflictsWithObstacle( bool conflicts )
{
mHasObstacleConflict = conflicts;
if ( nextPart )
nextPart->setConflictsWithObstacle( conflicts );
if ( mNextPart )
mNextPart->setConflictsWithObstacle( conflicts );
}

void LabelPosition::setHasHardObstacleConflict( bool conflicts )
{
mHasHardConflict = conflicts;
if ( nextPart )
nextPart->setHasHardObstacleConflict( conflicts );
if ( mNextPart )
mNextPart->setHasHardObstacleConflict( conflicts );
}

void LabelPosition::removeFromIndex( PalRtree<LabelPosition> &index )
@@ -449,8 +449,8 @@ double LabelPosition::getDistanceToPoint( double xp, double yp ) const
double distance = ( containsPoint( xp, yp ) ? -1
: std::sqrt( minDistanceToPoint( xp, yp ) ) );

if ( nextPart && distance > 0 )
return std::min( distance, nextPart->getDistanceToPoint( xp, yp ) );
if ( mNextPart && distance > 0 )
return std::min( distance, mNextPart->getDistanceToPoint( xp, yp ) );

return distance;
}
@@ -470,9 +470,9 @@ bool LabelPosition::crossesLine( PointSet *line ) const
{
return true;
}
else if ( nextPart )
else if ( mNextPart )
{
return nextPart->crossesLine( line );
return mNextPart->crossesLine( line );
}
}
catch ( GEOSException &e )
@@ -500,9 +500,9 @@ bool LabelPosition::crossesBoundary( PointSet *polygon ) const
{
return true;
}
else if ( nextPart )
else if ( mNextPart )
{
return nextPart->crossesBoundary( polygon );
return mNextPart->crossesBoundary( polygon );
}
}
catch ( GEOSException &e )
@@ -543,9 +543,9 @@ bool LabelPosition::intersectsWithPolygon( PointSet *polygon ) const
QgsMessageLog::logMessage( QObject::tr( "Exception: %1" ).arg( e.what() ), QObject::tr( "GEOS" ) );
}

if ( nextPart )
if ( mNextPart )
{
return nextPart->intersectsWithPolygon( polygon );
return mNextPart->intersectsWithPolygon( polygon );
}
else
{
@@ -603,9 +603,9 @@ double LabelPosition::polygonIntersectionCostForParts( PointSet *polygon ) const
//maintain scaling from 0 -> 12
cost = 12.0 * cost / 13.0;

if ( nextPart )
if ( mNextPart )
{
cost += nextPart->polygonIntersectionCostForParts( polygon );
cost += mNextPart->polygonIntersectionCostForParts( polygon );
}

return cost;
@@ -198,7 +198,7 @@ namespace pal
{
probFeat = probFid;
id = lpId;
if ( nextPart ) nextPart->setProblemIds( probFid, lpId );
if ( mNextPart ) mNextPart->setProblemIds( probFid, lpId );
}

/**
@@ -270,8 +270,20 @@ namespace pal
bool getUpsideDown() const { return upsideDown; }

Quadrant getQuadrant() const { return quadrant; }
LabelPosition *getNextPart() const { return nextPart.get(); }
void setNextPart( std::unique_ptr< LabelPosition > next ) { nextPart = std::move( next ); }

/**
* Returns the next part of this label position (i.e. the next character for a curved label).
*
* \see setNextPart()
*/
LabelPosition *nextPart() const { return mNextPart.get(); }

/**
* Sets the \a next part of this label position (i.e. the next character for a curved label).
*
* \see nextPart()
*/
void setNextPart( std::unique_ptr< LabelPosition > next ) { mNextPart = std::move( next ); }

// -1 if not multi-part
int getPartId() const { return partId; }
@@ -335,7 +347,7 @@ namespace pal

private:

std::unique_ptr< LabelPosition > nextPart;
std::unique_ptr< LabelPosition > mNextPart;

double mCost;
bool mHasObstacleConflict;

0 comments on commit 5b7decb

Please sign in to comment.
You can’t perform that action at this time.