mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-10 00:13:55 -04:00
Add API to pal to return unplaced labels after calculating the solution
to the labeling problem And improve dox
This commit is contained in:
parent
39d4145aae
commit
4868c266e3
@ -455,7 +455,7 @@ std::unique_ptr<Problem> Pal::extractProblem( const QgsRectangle &extent, const
|
||||
return extract( extent, mapBoundary );
|
||||
}
|
||||
|
||||
QList<LabelPosition *> Pal::solveProblem( Problem *prob, bool displayAll )
|
||||
QList<LabelPosition *> Pal::solveProblem( Problem *prob, bool displayAll, QList<LabelPosition *> *unlabeled )
|
||||
{
|
||||
if ( !prob )
|
||||
return QList<LabelPosition *>();
|
||||
@ -476,7 +476,7 @@ QList<LabelPosition *> Pal::solveProblem( Problem *prob, bool displayAll )
|
||||
return QList<LabelPosition *>();
|
||||
}
|
||||
|
||||
return prob->getSolution( displayAll );
|
||||
return prob->getSolution( displayAll, unlabeled );
|
||||
}
|
||||
|
||||
|
||||
|
@ -143,7 +143,19 @@ namespace pal
|
||||
*/
|
||||
std::unique_ptr< Problem > extractProblem( const QgsRectangle &extent, const QgsGeometry &mapBoundary );
|
||||
|
||||
QList<LabelPosition *> solveProblem( Problem *prob, bool displayAll );
|
||||
/**
|
||||
* Solves the labeling problem, selecting the best candidate locations for all labels and returns a list of these
|
||||
* calculated label positions.
|
||||
*
|
||||
* If \a displayAll is true, then the best positions for ALL labels will be returned, regardless of whether these
|
||||
* labels overlap other labels.
|
||||
*
|
||||
* If the optional \a unlabeled list is specified, it will be filled with a list of all feature labels which could
|
||||
* not be placed in the returned solution (e.g. due to overlaps or other constraints).
|
||||
*
|
||||
* Ownership of the returned labels is not transferred - it resides with the pal object.
|
||||
*/
|
||||
QList<LabelPosition *> solveProblem( Problem *prob, bool displayAll, QList<pal::LabelPosition *> *unlabeled = nullptr );
|
||||
|
||||
/**
|
||||
*\brief Set flag show partial label
|
||||
|
@ -2216,7 +2216,7 @@ bool Problem::compareLabelArea( pal::LabelPosition *l1, pal::LabelPosition *l2 )
|
||||
return l1->getWidth() * l1->getHeight() > l2->getWidth() * l2->getHeight();
|
||||
}
|
||||
|
||||
QList<LabelPosition *> Problem::getSolution( bool returnInactive )
|
||||
QList<LabelPosition *> Problem::getSolution( bool returnInactive, QList<LabelPosition *> *unlabeled )
|
||||
{
|
||||
int i;
|
||||
QList<LabelPosition *> solList;
|
||||
@ -2238,6 +2238,10 @@ QList<LabelPosition *> Problem::getSolution( bool returnInactive )
|
||||
{
|
||||
solList.push_back( mLabelPositions.at( featStartId[i] ) ); // unplaced label
|
||||
}
|
||||
else if ( unlabeled )
|
||||
{
|
||||
unlabeled->push_back( mLabelPositions.at( featStartId[i] ) );
|
||||
}
|
||||
}
|
||||
|
||||
// if features collide, order by size, so smaller ones appear on top
|
||||
|
@ -150,7 +150,19 @@ namespace pal
|
||||
*/
|
||||
void chain_search();
|
||||
|
||||
QList<LabelPosition *> getSolution( bool returnInactive );
|
||||
/**
|
||||
* Solves the labeling problem, selecting the best candidate locations for all labels and returns a list of these
|
||||
* calculated label positions.
|
||||
*
|
||||
* If \a returnInactive is true, then the best positions for ALL labels will be returned, regardless of whether these
|
||||
* labels overlap other labels.
|
||||
*
|
||||
* If the optional \a unlabeled list is specified, it will be filled with a list of all feature labels which could
|
||||
* not be placed in the returned solution (e.g. due to overlaps or other constraints).
|
||||
*
|
||||
* Ownership of the returned labels is not transferred - it resides with the pal object.
|
||||
*/
|
||||
QList<LabelPosition *> getSolution( bool returnInactive, QList<LabelPosition *> *unlabeled = nullptr );
|
||||
|
||||
PalStat *getStats();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user