Skip to content

Commit

Permalink
[needs-docs][labeling] Drop setting to control label solution method
Browse files Browse the repository at this point in the history
from project labeling settings

This is an unnecessary setting, resulting in 1000's of extra, very complex
and untested lines of code. Furthermore, the differences are almost non-existant
and it's extremely unlikely end users would (or should) need to change this
setting.
  • Loading branch information
nyalldawson committed Aug 8, 2019
1 parent 6fd35f6 commit 34a2ca0
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 1,695 deletions.
12 changes: 9 additions & 3 deletions python/core/auto_generated/qgslabelingenginesettings.sip.in
Expand Up @@ -33,6 +33,7 @@ Stores global configuration for labeling engine
typedef QFlags<QgsLabelingEngineSettings::Flag> Flags;



enum Search
{
Chain,
Expand Down Expand Up @@ -75,13 +76,18 @@ Gets number of candidate positions that will be generated for each label feature
Sets number of candidate positions that will be generated for each label feature
%End

void setSearchMethod( Search s );
void setSearchMethod( Search s ) /Deprecated/;
%Docstring
Sets which search method to use for removal collisions between labels
Used to set which search method to use for removal collisions between labels

.. deprecated:: since QGIS 3.10 - Chain is always used.
%End
Search searchMethod() const;

Search searchMethod() const /Deprecated/;
%Docstring
Which search method to use for removal collisions between labels

.. deprecated:: since QGIS 3.10 - Chain is always used.
%End

void readSettingsFromProject( QgsProject *project );
Expand Down
6 changes: 0 additions & 6 deletions src/app/qgslabelengineconfigdialog.cpp
Expand Up @@ -33,9 +33,6 @@ QgsLabelEngineConfigDialog::QgsLabelEngineConfigDialog( QWidget *parent )

QgsLabelingEngineSettings engineSettings = QgsProject::instance()->labelingEngineSettings();

// search method
cboSearchMethod->setCurrentIndex( engineSettings.searchMethod() );

mTextRenderFormatComboBox->addItem( tr( "Always Render Labels as Paths (Recommended)" ), QgsRenderContext::TextFormatAlwaysOutlines );
mTextRenderFormatComboBox->addItem( tr( "Always Render Labels as Text" ), QgsRenderContext::TextFormatAlwaysText );

Expand Down Expand Up @@ -64,8 +61,6 @@ void QgsLabelEngineConfigDialog::onOK()
QgsLabelingEngineSettings engineSettings;

// save
engineSettings.setSearchMethod( static_cast< QgsLabelingEngineSettings::Search >( cboSearchMethod->currentIndex() ) );

engineSettings.setNumCandidatePositions( spinCandPoint->value(), spinCandLine->value(), spinCandPolygon->value() );

engineSettings.setFlag( QgsLabelingEngineSettings::DrawCandidates, chkShowCandidates->isChecked() );
Expand All @@ -85,7 +80,6 @@ void QgsLabelEngineConfigDialog::onOK()
void QgsLabelEngineConfigDialog::setDefaults()
{
pal::Pal p;
cboSearchMethod->setCurrentIndex( static_cast<int>( p.getSearch() ) );
spinCandPoint->setValue( p.getPointP() );
spinCandLine->setValue( p.getLineP() );
spinCandPolygon->setValue( p.getPolyP() );
Expand Down
77 changes: 1 addition & 76 deletions src/core/pal/pal.cpp
Expand Up @@ -49,28 +49,6 @@ Pal::Pal()
{
// do not init and exit GEOS - we do it inside QGIS
//initGEOS( geosNotice, geosError );

fnIsCanceled = nullptr;
fnIsCanceledContext = nullptr;

ejChainDeg = 50;
tenure = 10;
candListSize = 0.2;

tabuMinIt = 3;
tabuMaxIt = 4;
searchMethod = POPMUSIC_CHAIN;
popmusic_r = 30;

searchMethod = CHAIN;

setSearch( CHAIN );

point_p = 16;
line_p = 50;
poly_p = 30;

showPartial = true;
}

void Pal::removeLayer( Layer *layer )
Expand Down Expand Up @@ -453,12 +431,7 @@ QList<LabelPosition *> Pal::solveProblem( Problem *prob, bool displayAll, QList<

try
{
if ( searchMethod == FALP )
prob->init_sol_falp();
else if ( searchMethod == CHAIN )
prob->chain_search();
else
prob->popmusic();
prob->chain_search();
}
catch ( InternalException::Empty & )
{
Expand Down Expand Up @@ -555,51 +528,3 @@ bool Pal::getShowPartial()
{
return showPartial;
}

SearchMethod Pal::getSearch()
{
return searchMethod;
}

void Pal::setSearch( SearchMethod method )
{
switch ( method )
{
case POPMUSIC_CHAIN:
searchMethod = method;
popmusic_r = 30;
tabuMinIt = 2;
tabuMaxIt = 4;
tenure = 10;
ejChainDeg = 50;
candListSize = 0.2;
break;
case CHAIN:
searchMethod = method;
ejChainDeg = 50;
break;
case POPMUSIC_TABU:
searchMethod = method;
popmusic_r = 25;
tabuMinIt = 2;
tabuMaxIt = 4;
tenure = 10;
ejChainDeg = 50;
candListSize = 0.2;
break;
case POPMUSIC_TABU_CHAIN:
searchMethod = method;
popmusic_r = 25;
tabuMinIt = 2;
tabuMaxIt = 4;
tenure = 10;
ejChainDeg = 50;
candListSize = 0.2;
break;
case FALP:
searchMethod = method;
break;
}
}


39 changes: 11 additions & 28 deletions src/core/pal/pal.h
Expand Up @@ -208,21 +208,6 @@ namespace pal
*/
int getPolyP();

/**
* \brief Select the search method to use.
*
* For interactive mapping using CHAIN is a good
* idea because it is the fastest. Other methods, ordered by speedness, are POPMUSIC_TABU,
* POPMUSIC_CHAIN and POPMUSIC_TABU_CHAIN, defined in pal::_searchMethod enumeration
* \param method the method to use
*/
void setSearch( SearchMethod method );

/**
* Returns the search method in use.
*/
SearchMethod getSearch();

private:

QHash< QgsAbstractLabelProvider *, Layer * > mLayers;
Expand All @@ -232,39 +217,37 @@ namespace pal
/**
* \brief maximum # candidates for a point
*/
int point_p;
int point_p = 16;

/**
* \brief maximum # candidates for a line
*/
int line_p;
int line_p = 50;

/**
* \brief maximum # candidates for a polygon
*/
int poly_p;

SearchMethod searchMethod;
int poly_p = 30;

/*
* POPMUSIC Tuning
*/
int popmusic_r;
int popmusic_r = 30;

int tabuMaxIt;
int tabuMinIt;
int tabuMaxIt = 4;
int tabuMinIt = 2;

int ejChainDeg;
int tenure;
double candListSize;
int ejChainDeg = 50;
int tenure = 10;
double candListSize = 0.2;

/**
* \brief show partial labels (cut-off by the map canvas) or not
*/
bool showPartial;
bool showPartial = true;

//! Callback that may be called from PAL to check whether the job has not been canceled in meanwhile
FnIsCanceled fnIsCanceled;
FnIsCanceled fnIsCanceled = nullptr;
//! Application-specific context for the cancellation check function
void *fnIsCanceledContext = nullptr;

Expand Down

0 comments on commit 34a2ca0

Please sign in to comment.