QGIS/python/core/qgsmapsettings.sip

138 lines
4.4 KiB
Plaintext
Raw Normal View History

class QgsMapSettings
{
%TypeHeaderCode
#include <qgsmapsettings.h>
%End
2014-05-27 23:22:50 +02:00
public:
QgsMapSettings();
QgsRectangle extent() const;
void setExtent( const QgsRectangle& rect );
QSize outputSize() const;
void setOutputSize( const QSize& size );
int outputDpi() const;
void setOutputDpi( int dpi );
2014-05-27 23:22:50 +02:00
QStringList layers() const;
void setLayers( const QStringList& layers );
2014-05-27 23:22:50 +02:00
//! sets whether to use projections for this layer set
void setCrsTransformEnabled( bool enabled );
//! returns true if projections are enabled for this layer set
bool hasCrsTransformEnabled() const;
2014-05-27 23:22:50 +02:00
//! sets destination coordinate reference system
void setDestinationCrs( const QgsCoordinateReferenceSystem& crs );
//! returns CRS of destination coordinate reference system
const QgsCoordinateReferenceSystem& destinationCrs() const;
2014-05-27 23:22:50 +02:00
QGis::UnitType mapUnits() const;
void setMapUnits( QGis::UnitType u );
2014-05-27 23:22:50 +02:00
void setBackgroundColor( const QColor& color );
QColor backgroundColor() const;
2014-05-27 23:22:50 +02:00
void setSelectionColor( const QColor& color );
QColor selectionColor() const;
/**Sets whether vector selections should be shown in the rendered map
* @param showSelection set to true if selections should be shown
* @see showSelection
* @see setSelectionColor
* @note Added in QGIS v2.4
*/
void setShowSelection( const bool showSelection );
/**Returns true if vector selections should be shown in the rendered map
* @returns true if selections should be shown
* @see setShowSelection
* @see selectionColor
* @note Added in QGIS v2.4
*/
bool showSelection() const;
2014-05-27 23:22:50 +02:00
enum Flag
{
Antialiasing = 0x01,
DrawEditingInfo = 0x02,
ForceVectorOutput = 0x04,
UseAdvancedEffects = 0x08,
DrawLabeling = 0x10,
UseRenderingOptimization = 0x20
2014-05-27 23:22:50 +02:00
// TODO: ignore scale-based visibility (overview)
};
typedef QFlags<QgsMapSettings::Flag> Flags;
2014-05-27 23:22:50 +02:00
void setFlags( Flags flags );
void setFlag( Flag flag, bool on = true );
Flags flags() const;
bool testFlag( Flag flag ) const;
2014-05-27 23:22:50 +02:00
bool hasValidSettings() const;
QgsRectangle visibleExtent() const;
double mapUnitsPerPixel() const;
double scale() const;
2014-05-27 23:22:50 +02:00
// -- utility functions --
2014-05-27 23:22:50 +02:00
const QgsMapToPixel& mapToPixel() const;
2014-05-27 23:22:50 +02:00
/**
* @brief transform bounding box from layer's CRS to output CRS
* @see layerToMapCoordinates( QgsMapLayer* theLayer, QgsRectangle rect ) if you want to transform a rectangle
* @return a bounding box (aligned rectangle) containing the transformed extent
*/
QgsRectangle layerExtentToOutputExtent( QgsMapLayer* theLayer, QgsRectangle extent ) const;
2014-05-27 23:22:50 +02:00
/**
* @brief transform bounding box from output CRS to layer's CRS
* @see mapToLayerCoordinates( QgsMapLayer* theLayer,QgsRectangle rect ) if you want to transform a rectangle
* @return a bounding box (aligned rectangle) containing the transformed extent
*/
QgsRectangle outputExtentToLayerExtent( QgsMapLayer* theLayer, QgsRectangle extent ) const;
2014-05-27 23:22:50 +02:00
/**
* @brief transform point coordinates from layer's CRS to output CRS
* @return the transformed point
*/
QgsPoint layerToMapCoordinates( QgsMapLayer* theLayer, QgsPoint point ) const;
2014-05-27 23:22:50 +02:00
/**
* @brief transform rectangle from layer's CRS to output CRS
* @see layerExtentToOutputExtent() if you want to transform a bounding box
* @return the transformed rectangle
*/
QgsRectangle layerToMapCoordinates( QgsMapLayer* theLayer, QgsRectangle rect ) const;
2014-05-27 23:22:50 +02:00
/**
* @brief transform point coordinates from output CRS to layer's CRS
* @return the transformed point
*/
QgsPoint mapToLayerCoordinates( QgsMapLayer* theLayer, QgsPoint point ) const;
2014-05-27 23:22:50 +02:00
/**
* @brief transform rectangle from output CRS to layer's CRS
* @see outputExtentToLayerExtent() if you want to transform a bounding box
* @return the transformed rectangle
*/
QgsRectangle mapToLayerCoordinates( QgsMapLayer* theLayer, QgsRectangle rect ) const;
2014-05-27 23:22:50 +02:00
//! returns current extent of layer set
QgsRectangle fullExtent() const;
2014-05-27 23:22:50 +02:00
/* serialization */
2014-05-27 23:22:50 +02:00
void readXML( QDomNode& theNode );
void writeXML( QDomNode& theNode, QDomDocument& theDoc );
};
QFlags<QgsMapSettings::Flag> operator|(QgsMapSettings::Flag f1, QFlags<QgsMapSettings::Flag> f2);