Skip to content

Commit

Permalink
Added an option to show also colliding labels (in engine configuration)
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/branches/symbology-ng-branch@11180 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Jul 26, 2009
1 parent 3d04984 commit 6e3bafe
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/core/pal/pal.cpp
Expand Up @@ -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*>();
Expand All @@ -970,7 +970,7 @@ namespace pal
else
prob->popmusic();

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


Expand Down
2 changes: 1 addition & 1 deletion src/core/pal/pal.h
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/plugins/labeling/engineconfigdialog.cpp
Expand Up @@ -20,6 +20,8 @@ EngineConfigDialog::EngineConfigDialog(PalLabeling* lbl, QWidget* parent)
spinCandPolygon->setValue(candPolygon);

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

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


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

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

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

accept();
}
11 changes: 9 additions & 2 deletions src/plugins/labeling/engineconfigdialog.ui
Expand Up @@ -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">
Expand Down Expand Up @@ -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">
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/labeling/pallabeling.cpp
Expand Up @@ -184,6 +184,7 @@ PalLabeling::PalLabeling(QgsMapRenderer* mapRenderer)
}

mShowingCandidates = FALSE;
mShowingAllLabels = FALSE;

initPal();
}
Expand Down Expand Up @@ -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();
Expand Down
5 changes: 5 additions & 0 deletions src/plugins/labeling/pallabeling.h
Expand Up @@ -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
Expand Down Expand Up @@ -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.