Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
API fixes, added missing python wrappers
- Loading branch information
Showing
10 changed files
with
299 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
|
||
/** | ||
* @brief The QgsLegendRenderer class handles automatic layout and rendering of legend. | ||
* The content is given by QgsLegendModel instance. Various layout properties can be configured | ||
* within QgsLegendRenderer. | ||
* | ||
* All spacing and sizes are in millimeters. | ||
* | ||
* @note added in 2.6 | ||
*/ | ||
class QgsLegendRenderer | ||
{ | ||
%TypeHeaderCode | ||
#include <qgslegendrenderer.h> | ||
%End | ||
|
||
public: | ||
/** Construct legend renderer. The ownership of legend model does not change */ | ||
QgsLegendRenderer( QgsLayerTreeModel* legendModel, const QgsLegendSettings& settings ); | ||
|
||
/** Run the layout algorithm and determine the size required for legend */ | ||
QSizeF minimumSize(); | ||
|
||
/** Set the preferred resulting legend size. */ | ||
void setLegendSize( QSizeF s ); | ||
|
||
/** Find out preferred legend size set by the client. If null, the legend will be drawn with the minimum size */ | ||
QSizeF legendSize() const; | ||
|
||
/** Draw the legend with given painter. It will occupy the area reported in legendSize(). | ||
* Painter should be scaled beforehand so that units correspond to millimeters. | ||
*/ | ||
void drawLegend( QPainter* painter ); | ||
|
||
|
||
static void setNodeLegendStyle( QgsLayerTreeNode* node, QgsComposerLegendStyle::Style style ); | ||
static QgsComposerLegendStyle::Style nodeLegendStyle( QgsLayerTreeNode* node, QgsLayerTreeModel* model ); | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
|
||
/** | ||
* @brief The QgsLegendSettings class stores the appearance and layout settings | ||
* for legend drawing with QgsLegendRenderer. The content of the legend is given | ||
* in QgsLegendModel class. | ||
* | ||
* @note added in 2.6 | ||
*/ | ||
class QgsLegendSettings | ||
{ | ||
%TypeHeaderCode | ||
#include <qgslegendsettings.h> | ||
%End | ||
|
||
public: | ||
QgsLegendSettings(); | ||
|
||
void setTitle( const QString& t ); | ||
QString title() const; | ||
|
||
/** Returns the alignment of the legend title | ||
* @returns Qt::AlignmentFlag for the legend title | ||
* @see setTitleAlignment | ||
*/ | ||
Qt::AlignmentFlag titleAlignment() const; | ||
/** Sets the alignment of the legend title | ||
* @param alignment Text alignment for drawing the legend title | ||
* @see titleAlignment | ||
*/ | ||
void setTitleAlignment( Qt::AlignmentFlag alignment ); | ||
|
||
/** Returns reference to modifiable style */ | ||
QgsComposerLegendStyle & rstyle( QgsComposerLegendStyle::Style s ); | ||
/** Returns style */ | ||
QgsComposerLegendStyle style( QgsComposerLegendStyle::Style s ) const; | ||
void setStyle( QgsComposerLegendStyle::Style s, const QgsComposerLegendStyle style ); | ||
|
||
double boxSpace() const; | ||
void setBoxSpace( double s ); | ||
|
||
void setWrapChar( const QString& t ); | ||
QString wrapChar() const; | ||
|
||
double columnSpace() const; | ||
void setColumnSpace( double s ); | ||
|
||
int columnCount() const; | ||
void setColumnCount( int c ); | ||
|
||
int splitLayer() const; | ||
void setSplitLayer( bool s ); | ||
|
||
int equalColumnWidth() const; | ||
void setEqualColumnWidth( bool s ); | ||
|
||
QColor fontColor() const; | ||
void setFontColor( const QColor& c ); | ||
|
||
QSizeF symbolSize() const; | ||
void setSymbolSize( QSizeF s ); | ||
|
||
QSizeF wmsLegendSize() const; | ||
void setWmsLegendSize( QSizeF s ); | ||
|
||
double lineSpacing() const; | ||
void setLineSpacing( double s ); | ||
|
||
double mmPerMapUnit() const; | ||
void setMmPerMapUnit( double mmPerMapUnit ); | ||
|
||
bool useAdvancedEffects() const; | ||
void setUseAdvancedEffects( bool use ); | ||
|
||
// utility functions | ||
|
||
/** Splits a string using the wrap char taking into account handling empty | ||
wrap char which means no wrapping */ | ||
QStringList splitStringForWrapping( QString stringToSplt ) const; | ||
|
||
/** Draws Text. Takes care about all the composer specific issues (calculation to pixel, scaling of font and painter | ||
to work around the Qt font bug)*/ | ||
void drawText( QPainter* p, double x, double y, const QString& text, const QFont& font ) const; | ||
|
||
/** Like the above, but with a rectangle for multiline text | ||
* @param p painter to use | ||
* @param rect rectangle to draw into | ||
* @param text text to draw | ||
* @param font font to use | ||
* @param halignment optional horizontal alignment | ||
* @param valignment optional vertical alignment | ||
* @param flags allows for passing Qt::TextFlags to control appearance of rendered text | ||
*/ | ||
void drawText( QPainter* p, const QRectF& rect, const QString& text, const QFont& font, Qt::AlignmentFlag halignment = Qt::AlignLeft, Qt::AlignmentFlag valignment = Qt::AlignTop, int flags = Qt::TextWordWrap ) const; | ||
|
||
/** Returns a font where size is in pixel and font size is upscaled with FONT_WORKAROUND_SCALE */ | ||
QFont scaledFontPixelSize( const QFont& font ) const; | ||
|
||
/** Calculates font to from point size to pixel size */ | ||
double pixelFontSize( double pointSize ) const; | ||
|
||
/** Returns the font width in millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCALE */ | ||
double textWidthMillimeters( const QFont& font, const QString& text ) const; | ||
|
||
/** Returns the font height of a character in millimeters */ | ||
double fontHeightCharacterMM( const QFont& font, const QChar& c ) const; | ||
|
||
/** Returns the font ascent in Millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCALE */ | ||
double fontAscentMillimeters( const QFont& font ) const; | ||
|
||
/** Returns the font descent in Millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCALE */ | ||
double fontDescentMillimeters( const QFont& font ) const; | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.