Skip to content

Commit

Permalink
Server: apply project related labeling settings
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent committed Jul 30, 2013
1 parent 5414031 commit 34c3b44
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/mapserver/qgis_map_serv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@ int main( int argc, char * argv[] )
continue;
}

adminConfigParser->loadLabelSettings( theMapRenderer->labelingEngine() );
theServer->setAdminConfigParser( adminConfigParser );


Expand Down
4 changes: 4 additions & 0 deletions src/mapserver/qgsconfigparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class QgsComposerMap;
class QgsComposerFrame;
class QgsComposerMultiFrame;
class QgsComposerHtml;
class QgsLabelingEngineInterface;
class QDomElement;

/**Interface class for configuration parsing, e.g. SLD configuration or QGIS project file*/
Expand Down Expand Up @@ -160,6 +161,9 @@ class QgsConfigParser
@param height height of output image*/
virtual void drawOverlays( QPainter* p, int dpi, int width, int height ) const { Q_UNUSED( p ); Q_UNUSED( dpi ); Q_UNUSED( width ); Q_UNUSED( height ); }

/**Applies configuration specific label settings*/
virtual void loadLabelSettings( QgsLabelingEngineInterface* lbl ) { Q_UNUSED( lbl ); }

protected:
/**Parser to forward not resolved requests (e.g. SLD parser based on user request might have a fallback parser with admin configuration)*/
QgsConfigParser* mFallbackParser;
Expand Down
63 changes: 63 additions & 0 deletions src/mapserver/qgsprojectparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "qgsmslayercache.h"
#include "qgslogger.h"
#include "qgsmapserviceexception.h"
#include "qgspallabeling.h"
#include "qgsrasterlayer.h"
#include "qgsvectorlayer.h"
#include "qgsvectordataprovider.h"
Expand Down Expand Up @@ -3594,3 +3595,65 @@ void QgsProjectParser::addDrawingOrderEmbeddedGroup( const QDomElement& groupEle
}
}
}

void QgsProjectParser::loadLabelSettings( QgsLabelingEngineInterface* lbl )
{
//pal labeling engine?
QgsPalLabeling* pal = dynamic_cast<QgsPalLabeling*>( lbl );
if ( pal )
{
QDomElement propertiesElem = mXMLDoc->documentElement().firstChildElement( "properties" );
if ( propertiesElem.isNull() )
{
return;
}

QDomElement palElem = propertiesElem.firstChildElement( "PAL" );
if ( palElem.isNull() )
{
return;
}

//pal::Pal p;
int candPoint = 8; //p.getPointP();
int candLine = 8; //p.getLineP();
int candPoly = 8; //p.getPolyP();

//mCandPoint
QDomElement candPointElem = palElem.firstChildElement( "CandidatesPoint" );
if ( !candPointElem.isNull() )
{
candPoint = candPointElem.text().toInt();
}

//mCandLine
QDomElement candLineElem = palElem.firstChildElement( "CandidatesLine" );
if ( !candLineElem.isNull() )
{
candLine = candLineElem.text().toInt();
}

//mCandPolygon
QDomElement candPolyElem = palElem.firstChildElement( "CandidatesPolygon" );
if ( !candPolyElem.isNull() )
{
candPoly = candPolyElem.text().toInt();
}

pal->setNumCandidatePositions( candPoint, candLine, candPoly );

//mShowingCandidates
QDomElement showCandElem = palElem.firstChildElement( "ShowingCandidates" );
if ( !showCandElem.isNull() )
{
pal->setShowingCandidates( showCandElem.text().compare( "true", Qt::CaseInsensitive ) == 0 );
}

//mShowingAllLabels
QDomElement showAllLabelsElem = palElem.firstChildElement( "ShowingAllLabels" );
if ( !showAllLabelsElem.isNull() )
{
pal->setShowingAllLabels( showAllLabelsElem.text().compare( "true", Qt::CaseInsensitive ) == 0 );
}
}
}
2 changes: 2 additions & 0 deletions src/mapserver/qgsprojectparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ class QgsProjectParser: public QgsConfigParser
/**Draw text annotation items from the QGIS projectfile*/
void drawOverlays( QPainter* p, int dpi, int width, int height ) const;

void loadLabelSettings( QgsLabelingEngineInterface* lbl );

private:

//forbidden
Expand Down

0 comments on commit 34c3b44

Please sign in to comment.