コード例 #1
0
ファイル: labelposition.cpp プロジェクト: ltbam/QGIS
  bool LabelPosition::pruneCallback( LabelPosition *lp, void *ctx )
  {
    FeaturePart *feat = (( PruneCtx* ) ctx )->obstacle;

    if (( feat == lp->feature ) || ( feat->getHoleOf() && feat->getHoleOf() != lp->feature ) )
    {
      return true;
    }

    CostCalculator::addObstacleCostPenalty( lp, feat );

    return true;
  }
コード例 #2
0
ファイル: labelposition.cpp プロジェクト: 3liz/Quantum-GIS
bool LabelPosition::pruneCallback( LabelPosition *candidatePosition, void *ctx )
{
  FeaturePart *obstaclePart = ( reinterpret_cast< PruneCtx* >( ctx ) )->obstacle;

  // test whether we should ignore this obstacle for the candidate. We do this if:
  // 1. it's not a hole, and the obstacle belongs to the same label feature as the candidate (eg
  // features aren't obstacles for their own labels)
  // 2. it IS a hole, and the hole belongs to a different label feature to the candidate (eg, holes
  // are ONLY obstacles for the labels of the feature they belong to)
  if (( !obstaclePart->getHoleOf() && candidatePosition->feature->hasSameLabelFeatureAs( obstaclePart ) )
      || ( obstaclePart->getHoleOf() && !candidatePosition->feature->hasSameLabelFeatureAs( dynamic_cast< FeaturePart* >( obstaclePart->getHoleOf() ) ) ) )
  {
    return true;
  }

  CostCalculator::addObstacleCostPenalty( candidatePosition, obstaclePart );

  return true;
}