Skip to content

Commit

Permalink
draw smaller diagrams on top
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Aug 9, 2012
1 parent d6f62fa commit 48bc5c5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/core/pal/problem.cpp
Expand Up @@ -2939,20 +2939,39 @@ namespace pal
//#undef _DEBUG_FULL_
#endif

bool Problem::compareLabelArea( pal::LabelPosition* l1, pal::LabelPosition* l2 )
{
return l1->getWidth() * l1->getHeight() > l2->getWidth() * l2->getHeight();
}

std::list<LabelPosition*> * Problem::getSolution( bool returnInactive )
{

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

if ( nbft == 0 )
{
return solList;
}

for ( i = 0; i < nbft; i++ )
{
if ( sol->s[i] != -1 )
{
solList->push_back( labelpositions[sol->s[i]] ); // active labels
}
else if ( returnInactive )
{
solList->push_back( labelpositions[featStartId[i]] ); // unplaced label
}
}

// if features collide, order by size, so smaller ones appear on top
if ( returnInactive )
{
solList->sort( compareLabelArea );
}

return solList;
}
Expand Down
2 changes: 2 additions & 0 deletions src/core/pal/problem.h
Expand Up @@ -225,6 +225,8 @@ namespace pal
void init_sol_empty();
void init_sol_falp();

static bool compareLabelArea( pal::LabelPosition* l1, pal::LabelPosition* l2 );

#ifdef _EXPORT_MAP_
void drawLabels( std::ofstream &svgmap );
#endif
Expand Down

0 comments on commit 48bc5c5

Please sign in to comment.