Skip to content
Permalink
Browse files

Added an option to show also colliding labels (in engine configuration)

git-svn-id: http://svn.osgeo.org/qgis/branches/symbology-ng-branch@11180 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder
wonder committed Jul 26, 2009
1 parent 3d04984 commit 6e3bafea3a1372b1ffb238129615276445292e6d
@@ -956,7 +956,7 @@ namespace pal
return prob;
}

std::list<LabelPosition*>* Pal::solveProblem(Problem* prob)
std::list<LabelPosition*>* Pal::solveProblem(Problem* prob, bool displayAll )
{
if (prob == NULL)
return new std::list<LabelPosition*>();
@@ -970,7 +970,7 @@ namespace pal
else
prob->popmusic();

return prob->getSolution( false );
return prob->getSolution( displayAll );
}


@@ -340,7 +340,7 @@ namespace pal

Problem* extractProblem(double scale, double bbox[4]);

std::list<LabelPosition*>* solveProblem(Problem* prob);
std::list<LabelPosition*>* solveProblem(Problem* prob, bool displayAll);

/**
* \brief Set map resolution
@@ -20,6 +20,8 @@ EngineConfigDialog::EngineConfigDialog(PalLabeling* lbl, QWidget* parent)
spinCandPolygon->setValue(candPolygon);

chkShowCandidates->setChecked( mLBL->isShowingCandidates() );

chkShowAllLabels->setChecked( mLBL->isShowingAllLabels() );
}


@@ -34,5 +36,7 @@ void EngineConfigDialog::onOK()

mLBL->setShowingCandidates( chkShowCandidates->isChecked() );

mLBL->setShowingAllLabels( chkShowAllLabels->isChecked() );

accept();
}
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>286</width>
<height>250</height>
<width>316</width>
<height>271</height>
</rect>
</property>
<property name="windowTitle">
@@ -172,6 +172,13 @@
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="chkShowAllLabels">
<property name="text">
<string>Show all labels (i.e. including colliding labels)</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkShowCandidates">
<property name="text">
@@ -184,6 +184,7 @@ PalLabeling::PalLabeling(QgsMapRenderer* mapRenderer)
}

mShowingCandidates = FALSE;
mShowingAllLabels = FALSE;

initPal();
}
@@ -380,7 +381,7 @@ void PalLabeling::doLabeling(QPainter* painter, QgsRectangle extent)
}

// find the solution
labels = mPal->solveProblem( problem );
labels = mPal->solveProblem( problem, mShowingAllLabels );

std::cout << "LABELING work: " << t.elapsed() << "ms ... labels# " << labels->size() << std::endl;
t.restart();
@@ -116,6 +116,9 @@ class PalLabeling
void setShowingCandidates(bool showing) { mShowingCandidates = showing; }
const QList<LabelCandidate>& candidates() { return mCandidates; }

bool isShowingAllLabels() const { return mShowingAllLabels; }
void setShowingAllLabels(bool showing) { mShowingAllLabels = showing; }

//! hook called when drawing layer before issuing select()
static int prepareLayerHook(void* context, void* layerContext, int& attrIndex);
//! hook called when drawing for every feature in a layer
@@ -143,6 +146,8 @@ class PalLabeling
// list of candidates from last labeling
QList<LabelCandidate> mCandidates;
bool mShowingCandidates;

bool mShowingAllLabels; // whether to avoid collisions or not
};

#endif // PALLABELING_H

0 comments on commit 6e3bafe

Please sign in to comment.
You can’t perform that action at this time.