Skip to content

Commit 48bc5c5

Browse files
committedAug 9, 2012
draw smaller diagrams on top
1 parent d6f62fa commit 48bc5c5

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed
 

‎src/core/pal/problem.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2939,20 +2939,39 @@ namespace pal
29392939
//#undef _DEBUG_FULL_
29402940
#endif
29412941

2942+
bool Problem::compareLabelArea( pal::LabelPosition* l1, pal::LabelPosition* l2 )
2943+
{
2944+
return l1->getWidth() * l1->getHeight() > l2->getWidth() * l2->getHeight();
2945+
}
2946+
29422947
std::list<LabelPosition*> * Problem::getSolution( bool returnInactive )
29432948
{
29442949

29452950
int i;
29462951
std::list<LabelPosition*> *solList = new std::list<LabelPosition*>();
29472952

29482953
if ( nbft == 0 )
2954+
{
29492955
return solList;
2956+
}
29502957

29512958
for ( i = 0; i < nbft; i++ )
2959+
{
29522960
if ( sol->s[i] != -1 )
2961+
{
29532962
solList->push_back( labelpositions[sol->s[i]] ); // active labels
2963+
}
29542964
else if ( returnInactive )
2965+
{
29552966
solList->push_back( labelpositions[featStartId[i]] ); // unplaced label
2967+
}
2968+
}
2969+
2970+
// if features collide, order by size, so smaller ones appear on top
2971+
if ( returnInactive )
2972+
{
2973+
solList->sort( compareLabelArea );
2974+
}
29562975

29572976
return solList;
29582977
}

‎src/core/pal/problem.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@ namespace pal
225225
void init_sol_empty();
226226
void init_sol_falp();
227227

228+
static bool compareLabelArea( pal::LabelPosition* l1, pal::LabelPosition* l2 );
229+
228230
#ifdef _EXPORT_MAP_
229231
void drawLabels( std::ofstream &svgmap );
230232
#endif

0 commit comments

Comments
 (0)
Please sign in to comment.