[needs-docs][labeling] Drop setting to control label solution method

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.
This commit is contained in:
Nyall Dawson 2019-07-29 09:55:35 +10:00
parent 6fd35f6f17
commit 34a2ca0dc0
9 changed files with 37 additions and 1658 deletions

View File

@ -33,6 +33,7 @@ Stores global configuration for labeling engine
typedef QFlags<QgsLabelingEngineSettings::Flag> Flags;
enum Search
{
Chain,
@ -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 );

View File

@ -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 );
@ -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() );
@ -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() );

View File

@ -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 )
@ -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 & )
{
@ -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;
}
}

View File

@ -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;
@ -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;

File diff suppressed because it is too large Load Diff

View File

@ -56,40 +56,6 @@ namespace pal
double cost;
};
typedef struct _subpart
{
/**
* # of features in problem
*/
int probSize;
/**
* # of features bounding the problem
*/
int borderSize;
/**
* total # features (prob + border)
*/
int subSize;
/**
* wrap bw sub feat and main feat
*/
int *sub = nullptr;
/**
* sub solution
*/
int *sol = nullptr;
/**
* first feat in sub part
*/
int seed;
} SubPart;
typedef struct _chain
{
int degree;
@ -140,11 +106,6 @@ namespace pal
void reduce();
/**
* \brief popmusic framework
*/
void popmusic();
/**
* \brief Test with very-large scale neighborhood
*/
@ -169,27 +130,6 @@ namespace pal
/* useful only for postscript post-conversion*/
//void toFile(char *label_file);
SubPart *subPart( int r, int featseed, int *isIn );
void initialization();
double compute_feature_cost( SubPart *part, int feat_id, int label_id, int *nbOverlap );
double compute_subsolution_cost( SubPart *part, int *s, int *nbOverlap );
/**
* POPMUSIC, chain
*/
double popmusic_chain( SubPart *part );
double popmusic_tabu( SubPart *part );
/**
*
* POPMUSIC, Tabu search with chain'
*
*/
double popmusic_tabu_chain( SubPart *part );
/**
* \brief Basic initial solution : every feature to -1
*/
@ -247,14 +187,10 @@ namespace pal
*/
double bbox[4];
double *labelPositionCost = nullptr;
int *nbOlap = nullptr;
QList< LabelPosition * > mLabelPositions;
RTree<LabelPosition *, double, 2, double> *candidates = nullptr; // index all candidates
RTree<LabelPosition *, double, 2, double> *candidates_sol = nullptr; // index active candidates
RTree<LabelPosition *, double, 2, double> *candidates_subsol = nullptr; // idem for subparts
QList< LabelPosition * > mPositionsWithNoCandidates;
@ -264,20 +200,13 @@ namespace pal
double *inactiveCost = nullptr; //
Sol *sol = nullptr; // [nbft]
int nbActive = 0;
double nbOverlap = 0.0;
int *featWrap = nullptr;
Chain *chain( SubPart *part, int seed );
Chain *chain( int seed );
Pal *pal = nullptr;
void solution_cost();
void check_solution();
};
} // namespace

View File

@ -190,26 +190,6 @@ void QgsLabelingEngine::run( QgsRenderContext &context )
const QgsLabelingEngineSettings &settings = mMapSettings.labelingEngineSettings();
pal::Pal p;
pal::SearchMethod s;
switch ( settings.searchMethod() )
{
case QgsLabelingEngineSettings::Chain:
s = pal::CHAIN;
break;
case QgsLabelingEngineSettings::Popmusic_Tabu:
s = pal::POPMUSIC_TABU;
break;
case QgsLabelingEngineSettings::Popmusic_Chain:
s = pal::POPMUSIC_CHAIN;
break;
case QgsLabelingEngineSettings::Popmusic_Tabu_Chain:
s = pal::POPMUSIC_TABU_CHAIN;
break;
case QgsLabelingEngineSettings::Falp:
s = pal::FALP;
break;
}
p.setSearch( s );
// set number of candidates generated per feature
int candPoint, candLine, candPolygon;

View File

@ -16,6 +16,7 @@
#define QGSLABELINGENGINESETTINGS_H
#include "qgis_core.h"
#include "qgis_sip.h"
#include "qgsrendercontext.h"
#include <QFlags>
@ -42,6 +43,8 @@ class CORE_EXPORT QgsLabelingEngineSettings
};
Q_DECLARE_FLAGS( Flags, Flag )
// TODO QGIS 4 - remove
/**
* Search methods in the PAL library to remove colliding labels
* (methods have different processing speed and number of labels placed)
@ -74,10 +77,17 @@ class CORE_EXPORT QgsLabelingEngineSettings
//! Sets number of candidate positions that will be generated for each label feature
void setNumCandidatePositions( int candPoint, int candLine, int candPolygon ) { mCandPoint = candPoint; mCandLine = candLine; mCandPolygon = candPolygon; }
//! Sets which search method to use for removal collisions between labels
void setSearchMethod( Search s ) { mSearchMethod = s; }
//! Which search method to use for removal collisions between labels
Search searchMethod() const { return mSearchMethod; }
/**
* Used to set which search method to use for removal collisions between labels
* \deprecated since QGIS 3.10 - Chain is always used.
*/
Q_DECL_DEPRECATED void setSearchMethod( Search s ) SIP_DEPRECATED { Q_UNUSED( s ) }
/**
* Which search method to use for removal collisions between labels
* \deprecated since QGIS 3.10 - Chain is always used.
*/
Q_DECL_DEPRECATED Search searchMethod() const SIP_DEPRECATED { return Chain; }
//! Read configuration of the labeling engine from a project
void readSettingsFromProject( QgsProject *project );

View File

@ -6,60 +6,14 @@
<rect>
<x>0</x>
<y>0</y>
<width>420</width>
<height>358</height>
<width>437</width>
<height>426</height>
</rect>
</property>
<property name="windowTitle">
<string>Automated Placement Engine</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Search method</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="cboSearchMethod">
<item>
<property name="text">
<string>Chain (fast)</string>
</property>
</item>
<item>
<property name="text">
<string>Popmusic Tabu</string>
</property>
</item>
<item>
<property name="text">
<string>Popmusic Chain</string>
</property>
</item>
<item>
<property name="text">
<string>Popmusic Tabu Chain</string>
</property>
</item>
<item>
<property name="text">
<string>FALP (fastest)</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
@ -328,7 +282,6 @@
</customwidget>
</customwidgets>
<tabstops>
<tabstop>cboSearchMethod</tabstop>
<tabstop>spinCandPoint</tabstop>
<tabstop>spinCandLine</tabstop>
<tabstop>spinCandPolygon</tabstop>