"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/core/pal/problem.cpp" between
QGIS-final-3_14_15.tar.gz and QGIS-final-3_14_16.tar.gz

About: QGIS (Quantum GIS) is a Geographic Information System that supports vector, raster, and database formats. Latest release (3.14.x series).

problem.cpp  (QGIS-final-3_14_15):problem.cpp  (QGIS-final-3_14_16)
skipping to change at line 654 skipping to change at line 654
delete_chain( retainedChain ); delete_chain( retainedChain );
popit++; popit++;
} }
solution_cost(); solution_cost();
delete[] ok; delete[] ok;
} }
QList<LabelPosition *> Problem::getSolution( bool returnInactive, QList<LabelPos ition *> *unlabeled ) QList<LabelPosition *> Problem::getSolution( bool returnInactive, QList<LabelPos ition *> *unlabeled )
{ {
QList<LabelPosition *> solList; QList<LabelPosition *> finalLabelPlacements;
// loop through all features to be labeled
for ( std::size_t i = 0; i < mFeatureCount; i++ ) for ( std::size_t i = 0; i < mFeatureCount; i++ )
{ {
if ( mSol.activeLabelIds[i] != -1 ) const int labelId = mSol.activeLabelIds[i];
const bool foundNonOverlappingPlacement = labelId != -1;
const int startIndexForLabelPlacements = mFeatStartId[i];
const bool foundCandidatesForFeature = startIndexForLabelPlacements < static
_cast< int >( mLabelPositions.size() );
if ( foundNonOverlappingPlacement )
{ {
solList.push_back( mLabelPositions[ mSol.activeLabelIds[i] ].get() ); // a ctive labels finalLabelPlacements.push_back( mLabelPositions[ labelId ].get() ); // act ive labels
} }
else if ( returnInactive else if ( foundCandidatesForFeature &&
|| ( mFeatStartId[i] < static_cast< int >( mLabelPositions.size() ( returnInactive // allowing any overlapping labels regardless of
) && where they are from
( mLabelPositions.at( mFeatStartId[i] )->getFeaturePart()->la || mLabelPositions.at( startIndexForLabelPlacements )->getFeatur
yer()->displayAll() ePart()->layer()->displayAll() // allowing overlapping labels for the layer
|| mLabelPositions.at( mFeatStartId[i] )->getFeaturePart()- || mLabelPositions.at( startIndexForLabelPlacements )->getFeatur
>alwaysShow() ) ) ) ePart()->alwaysShow() ) ) // allowing overlapping labels for the feature
{ {
solList.push_back( mLabelPositions[ mFeatStartId[i] ].get() ); // unplaced label finalLabelPlacements.push_back( mLabelPositions[ startIndexForLabelPlaceme nts ].get() ); // unplaced label
} }
else if ( unlabeled ) else if ( unlabeled )
{ {
const int startPos = mFeatStartId[i];
// need to be careful here -- if the next feature's start id is the same a s this one, then this feature had no candidates! // need to be careful here -- if the next feature's start id is the same a s this one, then this feature had no candidates!
if ( startPos < static_cast< int >( mLabelPositions.size() ) && ( i == mFe if ( foundCandidatesForFeature && ( i == mFeatureCount - 1 || startIndexFo
atureCount - 1 || startPos != mFeatStartId[i + 1] ) ) rLabelPlacements != mFeatStartId[i + 1] ) )
unlabeled->push_back( mLabelPositions[ startPos ].get() ); unlabeled->push_back( mLabelPositions[ startIndexForLabelPlacements ].ge
t() );
} }
} }
// unlabeled features also include those with no candidates // unlabeled features also include those with no candidates
if ( unlabeled ) if ( unlabeled )
{ {
for ( const std::unique_ptr< LabelPosition > &position : mPositionsWithNoCan didates ) for ( const std::unique_ptr< LabelPosition > &position : mPositionsWithNoCan didates )
unlabeled->append( position.get() ); unlabeled->append( position.get() );
} }
return solList; return finalLabelPlacements;
} }
void Problem::solution_cost() void Problem::solution_cost()
{ {
mSol.totalCost = 0.0; mSol.totalCost = 0.0;
LabelPosition *lp = nullptr; LabelPosition *lp = nullptr;
double amin[2]; double amin[2];
double amax[2]; double amax[2];
 End of changes. 9 change blocks. 
16 lines changed or deleted 23 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)