mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
Merge branch 'master' into regularShape_gui
This commit is contained in:
commit
dc0855f8f1
@ -15,5 +15,6 @@
|
||||
set -e
|
||||
|
||||
pushd build
|
||||
xvfb-run ctest -V --output-on-failure
|
||||
export CTEST_BUILD_COMMAND="/usr/bin/make -j3 -i -k"
|
||||
python ${TRAVIS_BUILD_DIR}/.ci/travis/scripts/ctest2travis.py xvfb-run ctest -V -E "sip_uptodate|spelling" --output-on-failure -S ${TRAVIS_BUILD_DIR}/.ci/travis/travis.ctest
|
||||
popd
|
||||
|
@ -7,6 +7,7 @@ qgis_composerutils
|
||||
ProcessingGrass7AlgorithmsImageryTest
|
||||
ProcessingGrass7AlgorithmsRasterTest
|
||||
PyQgsDBManagerGpkg
|
||||
PyQgsAppStartup
|
||||
|
||||
# temporary during processing refactoring
|
||||
ProcessingParametersTest
|
||||
|
@ -7,6 +7,7 @@ matrix:
|
||||
env:
|
||||
- LLVM_VERSION=3.8
|
||||
- TRAVIS_CONFIG=linux
|
||||
dist: precise
|
||||
sudo: false
|
||||
cache:
|
||||
apt: true
|
||||
@ -49,6 +50,7 @@ matrix:
|
||||
apt:
|
||||
sources:
|
||||
- sourceline: 'ppa:jonathonf/backports' # silversearcher-ag backport
|
||||
- sourceline: 'ppa:sergey-dryabzhinsky/packages' # doxygen
|
||||
packages:
|
||||
- doxygen
|
||||
- graphviz
|
||||
|
@ -303,15 +303,6 @@ EXTENSION_MAPPING =
|
||||
|
||||
MARKDOWN_SUPPORT = YES
|
||||
|
||||
# When the TOC_INCLUDE_HEADINGS tag is set to a non-zero value, all headings up
|
||||
# to that level are automatically included in the table of contents, even if
|
||||
# they do not have an id attribute.
|
||||
# Note: This feature currently applies only to Markdown headings.
|
||||
# Minimum value: 0, maximum value: 99, default value: 0.
|
||||
# This tag requires that the tag MARKDOWN_SUPPORT is set to YES.
|
||||
|
||||
TOC_INCLUDE_HEADINGS = 0
|
||||
|
||||
# When enabled doxygen tries to link words that correspond to documented
|
||||
# classes, or namespaces to their corresponding documentation. Such a link can
|
||||
# be prevented in individual cases by putting a % sign in front of the word or
|
||||
@ -2388,11 +2379,6 @@ DIAFILE_DIRS =
|
||||
|
||||
PLANTUML_JAR_PATH =
|
||||
|
||||
# When using plantuml, the PLANTUML_CFG_FILE tag can be used to specify a
|
||||
# configuration file for plantuml.
|
||||
|
||||
PLANTUML_CFG_FILE =
|
||||
|
||||
# When using plantuml, the specified paths are searched for files specified by
|
||||
# the !include statement in a plantuml block.
|
||||
|
||||
|
554
doc/INSTALL.html
554
doc/INSTALL.html
File diff suppressed because it is too large
Load Diff
@ -960,6 +960,7 @@ QgsDatumTransformStore {#qgis_api_break_3_0_QgsDatumTransformStore}
|
||||
|
||||
- transformation() now returns a QgsCoordinateTransform object, not a pointer. An invalid QgsCoordinateTransform will
|
||||
be returned in place of a null pointer.
|
||||
- transformation() also optional source and destination authid parameters
|
||||
|
||||
|
||||
QgsDiagram {#qgis_api_break_3_0_QgsDiagram}
|
||||
@ -1241,6 +1242,7 @@ empty geometry collection)
|
||||
- avoidIntersections() got an extra argument: list of layers to include in the operation (previously read from active QgsProject)
|
||||
- isGeosEmpty() was removed. Use isEmpty() instead.
|
||||
- reshapeGeometry() expects QgsLineString as a parameter instead of a list of 2D points (so that it can support 3D geometries)
|
||||
- vertexAt() now returns a QgsPoint (previously QgsPointV2) instead of a QgsPointXY (previously QgsPoint)
|
||||
|
||||
|
||||
QgsGeometryAnalyzer {#qgis_api_break_3_0_QgsGeometryAnalyzer}
|
||||
@ -2381,7 +2383,7 @@ displayExpression instead. For the map tip use mapTipTemplate() instead.
|
||||
- selectedFeaturesIds() replaced by selectedFeatureIds()
|
||||
- selectedFeaturesIterator() was replaced by getSelectedFeatures()
|
||||
- setSelectedFeatures() replaced by selectByIds()
|
||||
- applyNamedStyle() replaced by applyNamedStyle()
|
||||
- applyNamedStyle() replaced by importNamedStyle()
|
||||
- isReadOnly() use readOnly()
|
||||
- Signal changeAttributeValue()
|
||||
- Deleted GroupData (Use QgsEditFormConfig::GroupData)
|
||||
|
@ -31,10 +31,7 @@ Required build dependencies:
|
||||
|
||||
Optional dependencies:
|
||||
|
||||
- for GRASS providers and plugin - GRASS >= 6.0.0. QGIS may be compiled with GRASS 6 or GRASS 7.
|
||||
It can also be compiled with both GRASS versions in a single build but only if QGIS
|
||||
is not installed with rpath. The desired GRASS version is chosen on runtime by setting
|
||||
LD_LIBRARY_PATH or PATH.
|
||||
- for GRASS providers and plugin - GRASS >= 7.0.0.
|
||||
- for georeferencer - GSL >= 1.8
|
||||
- for PostGIS support - PostgreSQL >= 8.0.x
|
||||
- for gps plugin - gpsbabel
|
||||
|
@ -467,6 +467,7 @@
|
||||
<file>themes/default/transformed.svg</file>
|
||||
<file>themes/default/transp-background_8x8.png</file>
|
||||
<file>themes/default/unlocked.svg</file>
|
||||
<file>themes/default/unlockedGray.svg</file>
|
||||
<file>themes/default/user.svg</file>
|
||||
<file>flags/eu.png</file>
|
||||
<file>flags/bn.png</file>
|
||||
|
1
images/themes/default/unlockedGray.svg
Normal file
1
images/themes/default/unlockedGray.svg
Normal file
@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="16" viewBox="0 0 16 16" width="16"><path d="M6 3.216c.665-.947 2.307-2.405 4.562-1.01 2.37 1.637 1.974 3.68-.04 6.93" fill="none" stroke="#888a85" stroke-width="3" stroke-linecap="square" stroke-linejoin="round"/><path d="M6 3.216C7 2 8.193.57 10.562 2.206c2.37 1.637 1.974 3.68-.04 6.93" fill="none" stroke="#eeeeec" stroke-linecap="square" stroke-linejoin="round"/><rect y="8.5" x="2.5" width="11" ry="1" rx=".846" height="7" fill="#666" stroke="#666" stroke-linecap="square"/></svg>
|
After Width: | Height: | Size: 534 B |
@ -27,6 +27,7 @@ from qgis.PyQt.QtWidgets import QShortcut, QMenu, QApplication, QWidget, QGridLa
|
||||
from qgis.PyQt.Qsci import QsciScintilla, QsciLexerPython, QsciAPIs, QsciStyle
|
||||
from qgis.core import QgsApplication, QgsSettings
|
||||
from qgis.gui import QgsMessageBar
|
||||
from qgis.utils import OverrideCursor
|
||||
import sys
|
||||
import os
|
||||
import subprocess
|
||||
@ -726,10 +727,9 @@ class Editor(QsciScintilla):
|
||||
file = open(pathfile, "r")
|
||||
fileLines = file.readlines()
|
||||
file.close()
|
||||
QApplication.setOverrideCursor(Qt.WaitCursor)
|
||||
for line in reversed(fileLines):
|
||||
self.insert(line)
|
||||
QApplication.restoreOverrideCursor()
|
||||
with OverrideCursor(Qt.WaitCursor):
|
||||
for line in reversed(fileLines):
|
||||
self.insert(line)
|
||||
self.setModified(False)
|
||||
self.endUndoAction()
|
||||
|
||||
@ -785,11 +785,10 @@ class EditorTab(QWidget):
|
||||
fn = codecs.open(filename, "rb", encoding='utf-8')
|
||||
txt = fn.read()
|
||||
fn.close()
|
||||
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
|
||||
self.newEditor.setText(txt)
|
||||
if self.readOnly:
|
||||
self.newEditor.setReadOnly(self.readOnly)
|
||||
QApplication.restoreOverrideCursor()
|
||||
with OverrideCursor(Qt.WaitCursor):
|
||||
self.newEditor.setText(txt)
|
||||
if self.readOnly:
|
||||
self.newEditor.setReadOnly(self.readOnly)
|
||||
self.newEditor.setModified(modified)
|
||||
self.newEditor.recolor()
|
||||
|
||||
@ -1259,9 +1258,8 @@ class EditorTabWidget(QTabWidget):
|
||||
if objInspectorEnabled:
|
||||
cW = self.currentWidget()
|
||||
if cW and not self.parent.listClassMethod.isVisible():
|
||||
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
|
||||
self.listObject(cW)
|
||||
QApplication.restoreOverrideCursor()
|
||||
with OverrideCursor(Qt.WaitCursor):
|
||||
self.listObject(cW)
|
||||
|
||||
def changeLastDirPath(self, tab):
|
||||
tabWidget = self.widget(tab)
|
||||
|
@ -31,68 +31,87 @@ class QgsComposerItem: QgsComposerObject, QGraphicsRectItem
|
||||
#include <qgscomposerpolygon.h>
|
||||
#include <qgscomposerpolyline.h>
|
||||
#include <qgscomposertexttable.h>
|
||||
#include <qgslayoutitemshape.h>
|
||||
#include <qgslayoutitempage.h>
|
||||
%End
|
||||
|
||||
%ConvertToSubClassCode
|
||||
// the conversions have to be static, because they're using multiple inheritance
|
||||
// (seen in PyQt4 .sip files for some QGraphicsItem classes)
|
||||
switch ( sipCpp->type() )
|
||||
if ( dynamic_cast< QgsComposerItem * >( sipCpp ) )
|
||||
{
|
||||
case QgsComposerItem::ComposerItem:
|
||||
sipType = sipType_QgsComposerItem;
|
||||
*sipCppRet = static_cast<QgsComposerItem *>( sipCpp );
|
||||
break;
|
||||
case QgsComposerItem::ComposerArrow:
|
||||
sipType = sipType_QgsComposerArrow;
|
||||
*sipCppRet = static_cast<QgsComposerArrow *>( sipCpp );
|
||||
break;
|
||||
case QgsComposerItem::ComposerItemGroup:
|
||||
sipType = sipType_QgsComposerItemGroup;
|
||||
*sipCppRet = static_cast<QgsComposerItemGroup *>( sipCpp );
|
||||
break;
|
||||
case QgsComposerItem::ComposerLabel:
|
||||
sipType = sipType_QgsComposerLabel;
|
||||
*sipCppRet = static_cast<QgsComposerLabel *>( sipCpp );
|
||||
break;
|
||||
case QgsComposerItem::ComposerLegend:
|
||||
sipType = sipType_QgsComposerLegend;
|
||||
*sipCppRet = static_cast<QgsComposerLegend *>( sipCpp );
|
||||
break;
|
||||
case QgsComposerItem::ComposerMap:
|
||||
sipType = sipType_QgsComposerMap;
|
||||
*sipCppRet = static_cast<QgsComposerMap *>( sipCpp );
|
||||
break;
|
||||
case QgsComposerItem::ComposerPaper:
|
||||
sipType = sipType_QgsPaperItem;
|
||||
*sipCppRet = static_cast<QgsPaperItem *>( sipCpp );
|
||||
break;
|
||||
case QgsComposerItem::ComposerPicture:
|
||||
sipType = sipType_QgsComposerPicture;
|
||||
*sipCppRet = static_cast<QgsComposerPicture *>( sipCpp );
|
||||
break;
|
||||
case QgsComposerItem::ComposerScaleBar:
|
||||
sipType = sipType_QgsComposerScaleBar;
|
||||
*sipCppRet = static_cast<QgsComposerScaleBar *>( sipCpp );
|
||||
break;
|
||||
case QgsComposerItem::ComposerShape:
|
||||
sipType = sipType_QgsComposerShape;
|
||||
*sipCppRet = static_cast<QgsComposerShape *>( sipCpp );
|
||||
break;
|
||||
case QgsComposerItem::ComposerPolygon:
|
||||
sipType = sipType_QgsComposerPolygon;
|
||||
*sipCppRet = static_cast<QgsComposerPolygon *>( sipCpp );
|
||||
break;
|
||||
case QgsComposerItem::ComposerPolyline:
|
||||
sipType = sipType_QgsComposerPolyline;
|
||||
*sipCppRet = static_cast<QgsComposerPolyline *>( sipCpp );
|
||||
break;
|
||||
case QgsComposerItem::ComposerFrame:
|
||||
sipType = sipType_QgsComposerFrame;
|
||||
*sipCppRet = static_cast<QgsComposerFrame *>( sipCpp );
|
||||
break;
|
||||
default:
|
||||
sipType = 0;
|
||||
switch ( sipCpp->type() )
|
||||
{
|
||||
case QgsComposerItem::ComposerItem:
|
||||
sipType = sipType_QgsComposerItem;
|
||||
*sipCppRet = static_cast<QgsComposerItem *>( sipCpp );
|
||||
break;
|
||||
case QgsComposerItem::ComposerArrow:
|
||||
sipType = sipType_QgsComposerArrow;
|
||||
*sipCppRet = static_cast<QgsComposerArrow *>( sipCpp );
|
||||
break;
|
||||
case QgsComposerItem::ComposerItemGroup:
|
||||
sipType = sipType_QgsComposerItemGroup;
|
||||
*sipCppRet = static_cast<QgsComposerItemGroup *>( sipCpp );
|
||||
break;
|
||||
case QgsComposerItem::ComposerLabel:
|
||||
sipType = sipType_QgsComposerLabel;
|
||||
*sipCppRet = static_cast<QgsComposerLabel *>( sipCpp );
|
||||
break;
|
||||
case QgsComposerItem::ComposerLegend:
|
||||
sipType = sipType_QgsComposerLegend;
|
||||
*sipCppRet = static_cast<QgsComposerLegend *>( sipCpp );
|
||||
break;
|
||||
case QgsComposerItem::ComposerMap:
|
||||
sipType = sipType_QgsComposerMap;
|
||||
*sipCppRet = static_cast<QgsComposerMap *>( sipCpp );
|
||||
break;
|
||||
case QgsComposerItem::ComposerPaper:
|
||||
sipType = sipType_QgsPaperItem;
|
||||
*sipCppRet = static_cast<QgsPaperItem *>( sipCpp );
|
||||
break;
|
||||
case QgsComposerItem::ComposerPicture:
|
||||
sipType = sipType_QgsComposerPicture;
|
||||
*sipCppRet = static_cast<QgsComposerPicture *>( sipCpp );
|
||||
break;
|
||||
case QgsComposerItem::ComposerScaleBar:
|
||||
sipType = sipType_QgsComposerScaleBar;
|
||||
*sipCppRet = static_cast<QgsComposerScaleBar *>( sipCpp );
|
||||
break;
|
||||
case QgsComposerItem::ComposerShape:
|
||||
sipType = sipType_QgsComposerShape;
|
||||
*sipCppRet = static_cast<QgsComposerShape *>( sipCpp );
|
||||
break;
|
||||
case QgsComposerItem::ComposerPolygon:
|
||||
sipType = sipType_QgsComposerPolygon;
|
||||
*sipCppRet = static_cast<QgsComposerPolygon *>( sipCpp );
|
||||
break;
|
||||
case QgsComposerItem::ComposerPolyline:
|
||||
sipType = sipType_QgsComposerPolyline;
|
||||
*sipCppRet = static_cast<QgsComposerPolyline *>( sipCpp );
|
||||
break;
|
||||
case QgsComposerItem::ComposerFrame:
|
||||
sipType = sipType_QgsComposerFrame;
|
||||
*sipCppRet = static_cast<QgsComposerFrame *>( sipCpp );
|
||||
break;
|
||||
default:
|
||||
sipType = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch ( sipCpp->type() )
|
||||
{
|
||||
// really, these *should* use the constants from QgsLayoutItemRegistry, but sip doesn't like that!
|
||||
case QGraphicsItem::UserType + 101:
|
||||
sipType = sipType_QgsLayoutItemPage;
|
||||
*sipCppRet = static_cast<QgsLayoutItemPage *>( sipCpp );
|
||||
break;
|
||||
default:
|
||||
sipType = 0;
|
||||
}
|
||||
}
|
||||
|
||||
%End
|
||||
public:
|
||||
|
||||
|
@ -153,12 +153,13 @@
|
||||
%Include composer/qgscomposermultiframecommand.sip
|
||||
%Include composer/qgscomposertexttable.sip
|
||||
%Include composer/qgspaperitem.sip
|
||||
%Include layout/qgslayout.sip
|
||||
%Include layout/qgslayoutcontext.sip
|
||||
%Include layout/qgslayoutmeasurement.sip
|
||||
%Include layout/qgslayoutmeasurementconverter.sip
|
||||
%Include layout/qgspagesizeregistry.sip
|
||||
%Include layout/qgslayoutpoint.sip
|
||||
%Include layout/qgslayoutsize.sip
|
||||
%Include layout/qgslayoututils.sip
|
||||
%Include metadata/qgslayermetadata.sip
|
||||
%Include metadata/qgslayermetadatavalidator.sip
|
||||
%Include processing/qgsprocessing.sip
|
||||
@ -378,8 +379,13 @@
|
||||
%Include gps/qgsgpsdetector.sip
|
||||
%Include gps/qgsnmeaconnection.sip
|
||||
%Include gps/qgsgpsdconnection.sip
|
||||
%Include layout/qgslayout.sip
|
||||
%Include layout/qgslayoutitem.sip
|
||||
%Include layout/qgslayoutitemmap.sip
|
||||
%Include layout/qgslayoutitempage.sip
|
||||
%Include layout/qgslayoutitemregistry.sip
|
||||
%Include layout/qgslayoutitemshape.sip
|
||||
%Include layout/qgslayoutpagecollection.sip
|
||||
%Include layout/qgslayoutobject.sip
|
||||
%Include symbology-ng/qgscptcityarchive.sip
|
||||
%Include symbology-ng/qgssvgcache.sip
|
||||
@ -391,5 +397,7 @@
|
||||
%Include layertree/qgslayertreemodellegendnode.sip
|
||||
%Include layertree/qgslayertreenode.sip
|
||||
%Include layertree/qgslayertreeregistrybridge.sip
|
||||
%Include qgsuserprofilemanager.sip
|
||||
%Include symbology-ng/qgsarrowsymbollayer.sip
|
||||
%Include composer/qgscomposerutils.sip
|
||||
%Include qgsuserprofile.sip
|
||||
|
@ -326,12 +326,12 @@ Returns true if WKB of the geometry is of WKBMulti* type
|
||||
:rtype: bool
|
||||
%End
|
||||
|
||||
QgsPointXY vertexAt( int atVertex ) const;
|
||||
QgsPoint vertexAt( int atVertex ) const;
|
||||
%Docstring
|
||||
Returns coordinates of a vertex.
|
||||
\param atVertex index of the vertex
|
||||
:return: Coordinates of the vertex or QgsPointXY(0,0) on error
|
||||
:rtype: QgsPointXY
|
||||
:return: Coordinates of the vertex or QgsPoint(0,0) on error
|
||||
:rtype: QgsPoint
|
||||
%End
|
||||
|
||||
double sqrDistToVertexAt( QgsPointXY &point /In/, int atVertex ) const;
|
||||
|
@ -137,45 +137,45 @@ A regular polygon is empty if radius equal to 0 or number of sides < 3
|
||||
.. seealso:: numberSides()
|
||||
%End
|
||||
|
||||
QgsPointSequence points( ) const;
|
||||
QgsPointSequence points() const;
|
||||
%Docstring
|
||||
Returns a list including the vertices of the regular polygon.
|
||||
:rtype: QgsPointSequence
|
||||
%End
|
||||
|
||||
QgsPolygonV2 *toPolygon( ) const /Factory/;
|
||||
QgsPolygonV2 *toPolygon() const /Factory/;
|
||||
%Docstring
|
||||
Returns as a polygon.
|
||||
:rtype: QgsPolygonV2
|
||||
%End
|
||||
|
||||
QgsLineString *toLineString( ) const /Factory/;
|
||||
QgsLineString *toLineString() const /Factory/;
|
||||
%Docstring
|
||||
Returns as a linestring.
|
||||
:rtype: QgsLineString
|
||||
%End
|
||||
|
||||
QgsTriangle toTriangle( ) const;
|
||||
QgsTriangle toTriangle() const;
|
||||
%Docstring
|
||||
Returns as a triangle.
|
||||
An empty triangle is returned if the regular polygon is empty or if the number of sides is different from 3.
|
||||
:rtype: QgsTriangle
|
||||
%End
|
||||
|
||||
QList<QgsTriangle> triangulate( ) const;
|
||||
QList<QgsTriangle> triangulate() const;
|
||||
%Docstring
|
||||
Returns a triangulation (vertices from sides to the center) of the regular polygon.
|
||||
An empty list is returned if the regular polygon is empty.
|
||||
:rtype: list of QgsTriangle
|
||||
%End
|
||||
|
||||
QgsCircle inscribedCircle( ) const;
|
||||
QgsCircle inscribedCircle() const;
|
||||
%Docstring
|
||||
Returns the inscribed circle
|
||||
:rtype: QgsCircle
|
||||
%End
|
||||
|
||||
QgsCircle circumscribedCircle( ) const;
|
||||
QgsCircle circumscribedCircle() const;
|
||||
%Docstring
|
||||
Returns the circumscribed circle
|
||||
:rtype: QgsCircle
|
||||
@ -188,33 +188,33 @@ A regular polygon is empty if radius equal to 0 or number of sides < 3
|
||||
:rtype: str
|
||||
%End
|
||||
|
||||
double interiorAngle( ) const;
|
||||
double interiorAngle() const;
|
||||
%Docstring
|
||||
Returns the measure of the interior angles in degrees.
|
||||
:rtype: float
|
||||
%End
|
||||
|
||||
double centralAngle( ) const;
|
||||
double centralAngle() const;
|
||||
%Docstring
|
||||
Returns the measure of the central angle (the angle subtended at the center of the polygon by one of its sides) in degrees.
|
||||
:rtype: float
|
||||
%End
|
||||
|
||||
double area( ) const;
|
||||
double area() const;
|
||||
%Docstring
|
||||
Returns the area.
|
||||
Returns 0 if the regular polygon is empty.
|
||||
:rtype: float
|
||||
%End
|
||||
|
||||
double perimeter( ) const;
|
||||
double perimeter() const;
|
||||
%Docstring
|
||||
Returns the perimeter.
|
||||
Returns 0 if the regular polygon is empty.
|
||||
:rtype: float
|
||||
%End
|
||||
|
||||
double length( ) const;
|
||||
double length() const;
|
||||
%Docstring
|
||||
Returns the length of a side.
|
||||
Returns 0 if the regular polygon is empty.
|
||||
|
@ -201,7 +201,7 @@ Inherited method not used. You cannot delete or insert a vertex directly. Return
|
||||
:rtype: bool
|
||||
%End
|
||||
|
||||
QVector<QgsLineString> altitudes( ) const;
|
||||
QVector<QgsLineString> altitudes() const;
|
||||
%Docstring
|
||||
An altitude is a segment (defined by a QgsLineString) from a vertex to the opposite side (or, if necessary, to the extension of the opposite side).
|
||||
:return: Three altitudes from this triangle
|
||||
@ -214,7 +214,7 @@ Inherited method not used. You cannot delete or insert a vertex directly. Return
|
||||
:rtype: list of QgsLineString
|
||||
%End
|
||||
|
||||
QVector<QgsLineString> medians( ) const;
|
||||
QVector<QgsLineString> medians() const;
|
||||
%Docstring
|
||||
A median is a segment (defined by a QgsLineString) from a vertex to the midpoint of the opposite side.
|
||||
:return: Three medians from this triangle
|
||||
@ -241,7 +241,7 @@ Inherited method not used. You cannot delete or insert a vertex directly. Return
|
||||
:rtype: list of QgsLineString
|
||||
%End
|
||||
|
||||
QgsTriangle medial( ) const;
|
||||
QgsTriangle medial() const;
|
||||
%Docstring
|
||||
Medial (or midpoint) triangle of a triangle ABC is the triangle with vertices at the midpoints of the triangle's sides.
|
||||
:return: The medial from this triangle
|
||||
@ -268,7 +268,7 @@ Inherited method not used. You cannot delete or insert a vertex directly. Return
|
||||
:rtype: QgsPoint
|
||||
%End
|
||||
|
||||
QgsPoint circumscribedCenter( ) const;
|
||||
QgsPoint circumscribedCenter() const;
|
||||
%Docstring
|
||||
Center of the circumscribed circle of the triangle.
|
||||
:return: The center of the circumscribed circle of the triangle
|
||||
@ -281,7 +281,7 @@ Inherited method not used. You cannot delete or insert a vertex directly. Return
|
||||
:rtype: QgsPoint
|
||||
%End
|
||||
|
||||
double circumscribedRadius( ) const;
|
||||
double circumscribedRadius() const;
|
||||
%Docstring
|
||||
Radius of the circumscribed circle of the triangle.
|
||||
:return: The radius of the circumscribed circle of the triangle
|
||||
@ -294,7 +294,7 @@ Inherited method not used. You cannot delete or insert a vertex directly. Return
|
||||
:rtype: float
|
||||
%End
|
||||
|
||||
QgsCircle circumscribedCircle( ) const;
|
||||
QgsCircle circumscribedCircle() const;
|
||||
%Docstring
|
||||
Circumscribed circle of the triangle.
|
||||
@return The circumbscribed of the triangle with a QgsCircle.
|
||||
@ -307,7 +307,7 @@ Inherited method not used. You cannot delete or insert a vertex directly. Return
|
||||
:rtype: QgsCircle
|
||||
%End
|
||||
|
||||
QgsPoint inscribedCenter( ) const;
|
||||
QgsPoint inscribedCenter() const;
|
||||
%Docstring
|
||||
Center of the inscribed circle of the triangle.
|
||||
:return: The center of the inscribed circle of the triangle
|
||||
@ -320,7 +320,7 @@ Inherited method not used. You cannot delete or insert a vertex directly. Return
|
||||
:rtype: QgsPoint
|
||||
%End
|
||||
|
||||
double inscribedRadius( ) const;
|
||||
double inscribedRadius() const;
|
||||
%Docstring
|
||||
Radius of the inscribed circle of the triangle.
|
||||
:return: The radius of the inscribed circle of the triangle
|
||||
@ -333,7 +333,7 @@ Inherited method not used. You cannot delete or insert a vertex directly. Return
|
||||
:rtype: float
|
||||
%End
|
||||
|
||||
QgsCircle inscribedCircle( ) const;
|
||||
QgsCircle inscribedCircle() const;
|
||||
%Docstring
|
||||
Inscribed circle of the triangle.
|
||||
@return The inscribed of the triangle with a QgsCircle.
|
||||
|
@ -7,7 +7,8 @@
|
||||
************************************************************************/
|
||||
|
||||
|
||||
class QgsLayout : QGraphicsScene
|
||||
|
||||
class QgsLayout : QGraphicsScene, QgsExpressionContextGenerator
|
||||
{
|
||||
%Docstring
|
||||
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
|
||||
@ -21,10 +22,214 @@ class QgsLayout : QGraphicsScene
|
||||
|
||||
enum ZValues
|
||||
{
|
||||
ZPage,
|
||||
ZMapTool,
|
||||
};
|
||||
|
||||
QgsLayout();
|
||||
QgsLayout( QgsProject *project );
|
||||
%Docstring
|
||||
Construct a new layout linked to the specified ``project``.
|
||||
|
||||
If the layout is a "new" layout (as opposed to a layout which will
|
||||
restore a previous state from XML) then initializeDefaults() should be
|
||||
called on the new layout.
|
||||
%End
|
||||
|
||||
void initializeDefaults();
|
||||
%Docstring
|
||||
Initializes an empty layout, e.g. by adding a default page to the layout. This should be called after creating
|
||||
a new layout.
|
||||
%End
|
||||
|
||||
QgsProject *project() const;
|
||||
%Docstring
|
||||
The project associated with the layout. Used to get access to layers, map themes,
|
||||
relations and various other bits. It is never null.
|
||||
:rtype: QgsProject
|
||||
%End
|
||||
|
||||
QString name() const;
|
||||
%Docstring
|
||||
Returns the layout's name.
|
||||
.. seealso:: setName()
|
||||
:rtype: str
|
||||
%End
|
||||
|
||||
void setName( const QString &name );
|
||||
%Docstring
|
||||
Sets the layout's name.
|
||||
.. seealso:: name()
|
||||
%End
|
||||
|
||||
void setUnits( QgsUnitTypes::LayoutUnit units );
|
||||
%Docstring
|
||||
Sets the native measurement ``units`` for the layout. These also form the default unit
|
||||
for measurements for the layout.
|
||||
.. seealso:: units()
|
||||
.. seealso:: convertToLayoutUnits()
|
||||
%End
|
||||
|
||||
QgsUnitTypes::LayoutUnit units() const;
|
||||
%Docstring
|
||||
Returns the native units for the layout.
|
||||
.. seealso:: setUnits()
|
||||
.. seealso:: convertToLayoutUnits()
|
||||
:rtype: QgsUnitTypes.LayoutUnit
|
||||
%End
|
||||
|
||||
double convertToLayoutUnits( const QgsLayoutMeasurement &measurement ) const;
|
||||
%Docstring
|
||||
Converts a measurement into the layout's native units.
|
||||
:return: length of measurement in layout units
|
||||
.. seealso:: convertFromLayoutUnits()
|
||||
.. seealso:: units()
|
||||
:rtype: float
|
||||
%End
|
||||
|
||||
QSizeF convertToLayoutUnits( const QgsLayoutSize &size ) const;
|
||||
%Docstring
|
||||
Converts a size into the layout's native units.
|
||||
:return: size of measurement in layout units
|
||||
.. seealso:: convertFromLayoutUnits()
|
||||
.. seealso:: units()
|
||||
:rtype: QSizeF
|
||||
%End
|
||||
|
||||
QPointF convertToLayoutUnits( const QgsLayoutPoint &point ) const;
|
||||
%Docstring
|
||||
Converts a ``point`` into the layout's native units.
|
||||
:return: point in layout units
|
||||
.. seealso:: convertFromLayoutUnits()
|
||||
.. seealso:: units()
|
||||
:rtype: QPointF
|
||||
%End
|
||||
|
||||
QgsLayoutMeasurement convertFromLayoutUnits( const double length, const QgsUnitTypes::LayoutUnit unit ) const;
|
||||
%Docstring
|
||||
Converts a ``length`` measurement from the layout's native units to a specified target ``unit``.
|
||||
:return: length of measurement in specified units
|
||||
.. seealso:: convertToLayoutUnits()
|
||||
.. seealso:: units()
|
||||
:rtype: QgsLayoutMeasurement
|
||||
%End
|
||||
|
||||
QgsLayoutSize convertFromLayoutUnits( const QSizeF &size, const QgsUnitTypes::LayoutUnit unit ) const;
|
||||
%Docstring
|
||||
Converts a ``size`` from the layout's native units to a specified target ``unit``.
|
||||
:return: size of measurement in specified units
|
||||
.. seealso:: convertToLayoutUnits()
|
||||
.. seealso:: units()
|
||||
:rtype: QgsLayoutSize
|
||||
%End
|
||||
|
||||
QgsLayoutPoint convertFromLayoutUnits( const QPointF &point, const QgsUnitTypes::LayoutUnit unit ) const;
|
||||
%Docstring
|
||||
Converts a ``point`` from the layout's native units to a specified target ``unit``.
|
||||
:return: point in specified units
|
||||
.. seealso:: convertToLayoutUnits()
|
||||
.. seealso:: units()
|
||||
:rtype: QgsLayoutPoint
|
||||
%End
|
||||
|
||||
QgsLayoutContext &context();
|
||||
%Docstring
|
||||
Returns a reference to the layout's context, which stores information relating to the
|
||||
current context and rendering settings for the layout.
|
||||
:rtype: QgsLayoutContext
|
||||
%End
|
||||
|
||||
|
||||
virtual QgsExpressionContext createExpressionContext() const;
|
||||
|
||||
%Docstring
|
||||
Creates an expression context relating to the layout's current state. The context includes
|
||||
scopes for global, project, layout and layout context properties.
|
||||
:rtype: QgsExpressionContext
|
||||
%End
|
||||
|
||||
void setCustomProperty( const QString &key, const QVariant &value );
|
||||
%Docstring
|
||||
Set a custom property for the layout.
|
||||
\param key property key. If a property with the same key already exists it will be overwritten.
|
||||
\param value property value
|
||||
.. seealso:: customProperty()
|
||||
.. seealso:: removeCustomProperty()
|
||||
.. seealso:: customProperties()
|
||||
%End
|
||||
|
||||
QVariant customProperty( const QString &key, const QVariant &defaultValue = QVariant() ) const;
|
||||
%Docstring
|
||||
Read a custom property from the layout.
|
||||
\param key property key
|
||||
\param defaultValue default value to return if property with matching key does not exist
|
||||
:return: value of matching property
|
||||
.. seealso:: setCustomProperty()
|
||||
.. seealso:: removeCustomProperty()
|
||||
.. seealso:: customProperties()
|
||||
:rtype: QVariant
|
||||
%End
|
||||
|
||||
void removeCustomProperty( const QString &key );
|
||||
%Docstring
|
||||
Remove a custom property from the layout.
|
||||
\param key property key
|
||||
.. seealso:: setCustomProperty()
|
||||
.. seealso:: customProperty()
|
||||
.. seealso:: customProperties()
|
||||
%End
|
||||
|
||||
QStringList customProperties() const;
|
||||
%Docstring
|
||||
Return list of keys stored in custom properties for the layout.
|
||||
.. seealso:: setCustomProperty()
|
||||
.. seealso:: customProperty()
|
||||
.. seealso:: removeCustomProperty()
|
||||
:rtype: list of str
|
||||
%End
|
||||
|
||||
QgsLayoutItemMap *referenceMap() const;
|
||||
%Docstring
|
||||
:rtype: QgsLayoutItemMap
|
||||
%End
|
||||
|
||||
void setReferenceMap( QgsLayoutItemMap *map );
|
||||
|
||||
QgsLayoutPageCollection *pageCollection();
|
||||
%Docstring
|
||||
Returns a pointer to the layout's page collection, which stores and manages
|
||||
page items in the layout.
|
||||
:rtype: QgsLayoutPageCollection
|
||||
%End
|
||||
|
||||
QRectF layoutBounds( bool ignorePages = false, double margin = 0.0 ) const;
|
||||
%Docstring
|
||||
Calculates the bounds of all non-gui items in the layout. Ignores snap lines, mouse handles
|
||||
and other cosmetic items.
|
||||
\param ignorePages set to true to ignore page items
|
||||
\param margin optional marginal (in percent, e.g., 0.05 = 5% ) to add around items
|
||||
:return: layout bounds, in layout units.
|
||||
:rtype: QRectF
|
||||
%End
|
||||
|
||||
void addLayoutItem( QgsLayoutItem *item /Transfer/ );
|
||||
%Docstring
|
||||
Adds an ``item`` to the layout. This should be called instead of the base class addItem()
|
||||
method. Ownership of the item is transferred to the layout.
|
||||
%End
|
||||
|
||||
public slots:
|
||||
|
||||
void updateBounds();
|
||||
%Docstring
|
||||
Updates the scene bounds of the layout.
|
||||
%End
|
||||
|
||||
signals:
|
||||
|
||||
void variablesChanged();
|
||||
%Docstring
|
||||
Emitted whenever the expression variables stored in the layout have been changed.
|
||||
%End
|
||||
|
||||
};
|
||||
|
||||
|
139
python/core/layout/qgslayoutcontext.sip
Normal file
139
python/core/layout/qgslayoutcontext.sip
Normal file
@ -0,0 +1,139 @@
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/core/layout/qgslayoutcontext.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
||||
|
||||
|
||||
|
||||
class QgsLayoutContext
|
||||
{
|
||||
%Docstring
|
||||
Stores information relating to the current context and rendering settings for a layout.
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgslayoutcontext.h"
|
||||
%End
|
||||
public:
|
||||
|
||||
enum Flag
|
||||
{
|
||||
FlagDebug,
|
||||
FlagOutlineOnly,
|
||||
FlagAntialiasing,
|
||||
FlagUseAdvancedEffects,
|
||||
};
|
||||
typedef QFlags<QgsLayoutContext::Flag> Flags;
|
||||
|
||||
|
||||
QgsLayoutContext();
|
||||
|
||||
void setFlags( const QgsLayoutContext::Flags flags );
|
||||
%Docstring
|
||||
Sets the combination of ``flags`` that will be used for rendering the layout.
|
||||
.. seealso:: setFlag()
|
||||
.. seealso:: flags()
|
||||
.. seealso:: testFlag()
|
||||
%End
|
||||
|
||||
void setFlag( const QgsLayoutContext::Flag flag, const bool on = true );
|
||||
%Docstring
|
||||
Enables or disables a particular rendering ``flag`` for the layout. Other existing
|
||||
flags are not affected.
|
||||
.. seealso:: setFlags()
|
||||
.. seealso:: flags()
|
||||
.. seealso:: testFlag()
|
||||
%End
|
||||
|
||||
QgsLayoutContext::Flags flags() const;
|
||||
%Docstring
|
||||
Returns the current combination of flags used for rendering the layout.
|
||||
.. seealso:: setFlags()
|
||||
.. seealso:: setFlag()
|
||||
.. seealso:: testFlag()
|
||||
:rtype: QgsLayoutContext.Flags
|
||||
%End
|
||||
|
||||
bool testFlag( const Flag flag ) const;
|
||||
%Docstring
|
||||
Check whether a particular rendering ``flag`` is enabled for the layout.
|
||||
.. seealso:: setFlags()
|
||||
.. seealso:: setFlag()
|
||||
.. seealso:: flags()
|
||||
:rtype: bool
|
||||
%End
|
||||
|
||||
QgsRenderContext::Flags renderContextFlags() const;
|
||||
%Docstring
|
||||
Returns the combination of render context flags matched to the layout context's settings.
|
||||
:rtype: QgsRenderContext.Flags
|
||||
%End
|
||||
|
||||
void setFeature( const QgsFeature &feature );
|
||||
%Docstring
|
||||
Sets the current ``feature`` for evaluating the layout. This feature may
|
||||
be used for altering an item's content and appearance for a report
|
||||
or atlas layout.
|
||||
.. seealso:: feature()
|
||||
%End
|
||||
|
||||
QgsFeature feature() const;
|
||||
%Docstring
|
||||
Returns the current feature for evaluating the layout. This feature may
|
||||
be used for altering an item's content and appearance for a report
|
||||
or atlas layout.
|
||||
.. seealso:: setFeature()
|
||||
:rtype: QgsFeature
|
||||
%End
|
||||
|
||||
QgsVectorLayer *layer() const;
|
||||
%Docstring
|
||||
Returns the vector layer associated with the layout's context.
|
||||
.. seealso:: setLayer()
|
||||
:rtype: QgsVectorLayer
|
||||
%End
|
||||
|
||||
void setLayer( QgsVectorLayer *layer );
|
||||
%Docstring
|
||||
Sets the vector ``layer`` associated with the layout's context.
|
||||
.. seealso:: layer()
|
||||
%End
|
||||
|
||||
void setDpi( double dpi );
|
||||
%Docstring
|
||||
Sets the ``dpi`` for outputting the layout. This also sets the
|
||||
corresponding DPI for the context's measurementConverter().
|
||||
.. seealso:: dpi()
|
||||
%End
|
||||
|
||||
double dpi() const;
|
||||
%Docstring
|
||||
Returns the ``dpi`` for outputting the layout.
|
||||
.. seealso:: setDpi()
|
||||
:rtype: float
|
||||
%End
|
||||
|
||||
|
||||
QgsLayoutMeasurementConverter &measurementConverter();
|
||||
%Docstring
|
||||
Returns the layout measurement converter to be used in the layout. This converter is used
|
||||
for translating between other measurement units and the layout's native unit.
|
||||
:rtype: QgsLayoutMeasurementConverter
|
||||
%End
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/core/layout/qgslayoutcontext.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
@ -18,14 +18,90 @@ class QgsLayoutItem : QgsLayoutObject, QGraphicsRectItem
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgslayoutitem.h"
|
||||
|
||||
#include <qgslayoutitemshape.h>
|
||||
#include <qgslayoutitempage.h>
|
||||
%End
|
||||
|
||||
%ConvertToSubClassCode
|
||||
// the conversions have to be static, because they're using multiple inheritance
|
||||
// (seen in PyQt4 .sip files for some QGraphicsItem classes)
|
||||
switch ( sipCpp->type() )
|
||||
{
|
||||
// really, these *should* use the constants from QgsLayoutItemRegistry, but sip doesn't like that!
|
||||
case QGraphicsItem::UserType + 101:
|
||||
sipType = sipType_QgsLayoutItemPage;
|
||||
*sipCppRet = static_cast<QgsLayoutItemPage *>( sipCpp );
|
||||
break;
|
||||
default:
|
||||
sipType = 0;
|
||||
}
|
||||
%End
|
||||
public:
|
||||
|
||||
QgsLayoutItem( QgsLayout *layout );
|
||||
enum ReferencePoint
|
||||
{
|
||||
UpperLeft,
|
||||
UpperMiddle,
|
||||
UpperRight,
|
||||
MiddleLeft,
|
||||
Middle,
|
||||
MiddleRight,
|
||||
LowerLeft,
|
||||
LowerMiddle,
|
||||
LowerRight,
|
||||
};
|
||||
|
||||
explicit QgsLayoutItem( QgsLayout *layout );
|
||||
%Docstring
|
||||
Constructor for QgsLayoutItem, with the specified parent ``layout``.
|
||||
%End
|
||||
|
||||
virtual int type() const = 0;
|
||||
%Docstring
|
||||
Return correct graphics item type
|
||||
.. seealso:: stringType()
|
||||
:rtype: int
|
||||
%End
|
||||
|
||||
virtual QString stringType() const = 0;
|
||||
%Docstring
|
||||
Return the item type as a string.
|
||||
|
||||
This string must be a unique, single word, character only representation of the item type, eg "LayoutScaleBar"
|
||||
.. seealso:: type()
|
||||
:rtype: str
|
||||
%End
|
||||
|
||||
QString uuid() const;
|
||||
%Docstring
|
||||
Returns the item identification string. This is a unique random string set for the item
|
||||
upon creation.
|
||||
.. note::
|
||||
|
||||
There is no corresponding setter for the uuid - it's created automatically.
|
||||
.. seealso:: id()
|
||||
.. seealso:: setId()
|
||||
:rtype: str
|
||||
%End
|
||||
|
||||
QString id() const;
|
||||
%Docstring
|
||||
Returns the item's ID name. This is not necessarily unique, and duplicate ID names may exist
|
||||
for a layout.
|
||||
.. seealso:: setId()
|
||||
.. seealso:: uuid()
|
||||
:rtype: str
|
||||
%End
|
||||
|
||||
virtual void setId( const QString &id );
|
||||
%Docstring
|
||||
Set the item's ``id`` name. This is not necessarily unique, and duplicate ID names may exist
|
||||
for a layout.
|
||||
.. seealso:: id()
|
||||
.. seealso:: uuid()
|
||||
%End
|
||||
|
||||
virtual void paint( QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget );
|
||||
|
||||
%Docstring
|
||||
@ -34,6 +110,146 @@ class QgsLayoutItem : QgsLayoutObject, QGraphicsRectItem
|
||||
the pure virtual method QgsLayoutItem.draw.
|
||||
%End
|
||||
|
||||
void setReferencePoint( const ReferencePoint &point );
|
||||
%Docstring
|
||||
Sets the reference ``point`` for positioning of the layout item. This point is also
|
||||
fixed during resizing of the item, and any size changes will be performed
|
||||
so that the position of the reference point within the layout remains unchanged.
|
||||
.. seealso:: referencePoint()
|
||||
%End
|
||||
|
||||
ReferencePoint referencePoint() const;
|
||||
%Docstring
|
||||
Returns the reference point for positioning of the layout item. This point is also
|
||||
fixed during resizing of the item, and any size changes will be performed
|
||||
so that the position of the reference point within the layout remains unchanged.
|
||||
.. seealso:: setReferencePoint()
|
||||
:rtype: ReferencePoint
|
||||
%End
|
||||
|
||||
QgsLayoutSize fixedSize() const;
|
||||
%Docstring
|
||||
Returns the fixed size of the item, if applicable, or an empty size if item can be freely
|
||||
resized.
|
||||
.. seealso:: setFixedSize()
|
||||
.. seealso:: minimumSize()
|
||||
:rtype: QgsLayoutSize
|
||||
%End
|
||||
|
||||
virtual QgsLayoutSize minimumSize() const;
|
||||
%Docstring
|
||||
Returns the minimum allowed size of the item, if applicable, or an empty size if item can be freely
|
||||
resized.
|
||||
.. seealso:: setMinimumSize()
|
||||
.. seealso:: fixedSize()
|
||||
:rtype: QgsLayoutSize
|
||||
%End
|
||||
|
||||
virtual void attemptResize( const QgsLayoutSize &size );
|
||||
%Docstring
|
||||
Attempts to resize the item to a specified target ``size``. Note that the final size of the
|
||||
item may not match the specified target size, as items with a fixed or minimum
|
||||
size will place restrictions on the allowed item size. Data defined item size overrides
|
||||
will also override the specified target size.
|
||||
.. seealso:: minimumSize()
|
||||
.. seealso:: fixedSize()
|
||||
.. seealso:: attemptMove()
|
||||
.. seealso:: sizeWithUnits()
|
||||
%End
|
||||
|
||||
virtual void attemptMove( const QgsLayoutPoint &point );
|
||||
%Docstring
|
||||
Attempts to move the item to a specified ``point``. This method respects the item's
|
||||
reference point, in that the item will be moved so that its current reference
|
||||
point is placed at the specified target point.
|
||||
Note that the final position of the item may not match the specified target position,
|
||||
as data defined item position may override the specified value.
|
||||
.. seealso:: attemptResize()
|
||||
.. seealso:: referencePoint()
|
||||
.. seealso:: positionWithUnits()
|
||||
%End
|
||||
|
||||
QgsLayoutPoint positionWithUnits() const;
|
||||
%Docstring
|
||||
Returns the item's current position, including units. The position returned
|
||||
is the position of the item's reference point, which may not necessarily be the top
|
||||
left corner of the item.
|
||||
.. seealso:: attemptMove()
|
||||
.. seealso:: referencePoint()
|
||||
.. seealso:: sizeWithUnits()
|
||||
:rtype: QgsLayoutPoint
|
||||
%End
|
||||
|
||||
QgsLayoutSize sizeWithUnits() const;
|
||||
%Docstring
|
||||
Returns the item's current size, including units.
|
||||
.. seealso:: attemptResize()
|
||||
.. seealso:: positionWithUnits()
|
||||
:rtype: QgsLayoutSize
|
||||
%End
|
||||
|
||||
double itemRotation() const;
|
||||
%Docstring
|
||||
:rtype: float
|
||||
%End
|
||||
|
||||
virtual bool writeXml( QDomElement &parentElement, QDomDocument &document, const QgsReadWriteContext &context ) const;
|
||||
%Docstring
|
||||
Stores the item state in a DOM element.
|
||||
\param parentElement parent DOM element (e.g. 'Layout' element)
|
||||
\param document DOM document
|
||||
\param context read write context
|
||||
.. seealso:: readXml()
|
||||
.. note::
|
||||
|
||||
Subclasses should ensure that they call writePropertiesToElement() in their implementation.
|
||||
:rtype: bool
|
||||
%End
|
||||
|
||||
virtual bool readXml( const QDomElement &itemElement, const QDomDocument &document, const QgsReadWriteContext &context );
|
||||
%Docstring
|
||||
Sets the item state from a DOM element.
|
||||
\param itemElement is the DOM node corresponding to item (e.g. 'LayoutItem' element)
|
||||
\param document DOM document
|
||||
\param context read write context
|
||||
.. seealso:: writeXml()
|
||||
.. note::
|
||||
|
||||
Subclasses should ensure that they call readPropertiesFromElement() in their implementation.
|
||||
:rtype: bool
|
||||
%End
|
||||
|
||||
public slots:
|
||||
|
||||
virtual void refresh();
|
||||
|
||||
%Docstring
|
||||
Refreshes the item, causing a recalculation of any property overrides and
|
||||
recalculation of its position and size.
|
||||
%End
|
||||
|
||||
virtual void refreshDataDefinedProperty( const QgsLayoutObject::DataDefinedProperty property = QgsLayoutObject::AllProperties );
|
||||
%Docstring
|
||||
Refreshes a data defined ``property`` for the item by reevaluating the property's value
|
||||
and redrawing the item with this new value. If ``property`` is set to
|
||||
QgsLayoutObject.AllProperties then all data defined properties for the item will be
|
||||
refreshed.
|
||||
%End
|
||||
|
||||
virtual void setItemRotation( const double rotation );
|
||||
%Docstring
|
||||
Sets the layout item's ``rotation``, in degrees clockwise. This rotation occurs around the center of the item.
|
||||
.. seealso:: itemRotation()
|
||||
.. seealso:: rotateItem()
|
||||
%End
|
||||
|
||||
virtual void rotateItem( const double angle, const QPointF &transformOrigin );
|
||||
%Docstring
|
||||
Rotates the item by a specified ``angle`` in degrees clockwise around a specified reference point.
|
||||
.. seealso:: setItemRotation()
|
||||
.. seealso:: itemRotation()
|
||||
%End
|
||||
|
||||
protected:
|
||||
|
||||
virtual void drawDebugRect( QPainter *painter );
|
||||
@ -43,9 +259,92 @@ class QgsLayoutItem : QgsLayoutObject, QGraphicsRectItem
|
||||
@param painter destination QPainter
|
||||
%End
|
||||
|
||||
virtual void draw( QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget ) = 0;
|
||||
virtual void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = 0 ) = 0;
|
||||
%Docstring
|
||||
Draws the item's contents on a specified ``painter``.
|
||||
Draws the item's contents using the specified render ``context``.
|
||||
Note that the context's painter has been scaled so that painter units are pixels.
|
||||
Use the QgsRenderContext methods to convert from millimeters or other units to the painter's units.
|
||||
%End
|
||||
|
||||
virtual void setFixedSize( const QgsLayoutSize &size );
|
||||
%Docstring
|
||||
Sets a fixed ``size`` for the layout item, which prevents it from being freely
|
||||
resized. Set an empty size if item can be freely resized.
|
||||
.. seealso:: fixedSize()
|
||||
.. seealso:: setMinimumSize()
|
||||
%End
|
||||
|
||||
virtual void setMinimumSize( const QgsLayoutSize &size );
|
||||
%Docstring
|
||||
Sets the minimum allowed ``size`` for the layout item. Set an empty size if item can be freely
|
||||
resized.
|
||||
.. seealso:: minimumSize()
|
||||
.. seealso:: setFixedSize()
|
||||
%End
|
||||
|
||||
void refreshItemSize();
|
||||
%Docstring
|
||||
Refreshes an item's size by rechecking it against any possible item fixed
|
||||
or minimum sizes.
|
||||
.. seealso:: setFixedSize()
|
||||
.. seealso:: setMinimumSize()
|
||||
.. seealso:: refreshItemPosition()
|
||||
%End
|
||||
|
||||
void refreshItemPosition();
|
||||
%Docstring
|
||||
Refreshes an item's position by rechecking it against any possible overrides
|
||||
such as data defined positioning.
|
||||
.. seealso:: refreshItemSize()
|
||||
%End
|
||||
|
||||
void refreshItemRotation();
|
||||
%Docstring
|
||||
Refreshes an item's rotation by rechecking it against any possible overrides
|
||||
such as data defined rotation.
|
||||
.. seealso:: refreshItemSize()
|
||||
.. seealso:: refreshItemPosition()
|
||||
%End
|
||||
|
||||
QPointF adjustPointForReferencePosition( const QPointF &point, const QSizeF &size, const ReferencePoint &reference ) const;
|
||||
%Docstring
|
||||
Adjusts the specified ``point`` at which a ``reference`` position of the item
|
||||
sits and returns the top left corner of the item, if reference point where placed at the specified position.
|
||||
:rtype: QPointF
|
||||
%End
|
||||
|
||||
QPointF positionAtReferencePoint( const ReferencePoint &reference ) const;
|
||||
%Docstring
|
||||
Returns the current position (in layout units) of a ``reference`` point for the item.
|
||||
:rtype: QPointF
|
||||
%End
|
||||
|
||||
virtual bool writePropertiesToElement( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const;
|
||||
%Docstring
|
||||
Stores item state within an XML DOM element.
|
||||
\param element is the DOM element to store the item's properties in
|
||||
\param document DOM document
|
||||
\param context read write context
|
||||
.. seealso:: writeXml()
|
||||
.. seealso:: readPropertiesFromElement()
|
||||
.. note::
|
||||
|
||||
derived classes must call this base implementation when overriding this method
|
||||
:rtype: bool
|
||||
%End
|
||||
|
||||
virtual bool readPropertiesFromElement( const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context );
|
||||
%Docstring
|
||||
Sets item state from a DOM element.
|
||||
\param element is the DOM element for the item
|
||||
\param document DOM document
|
||||
\param context read write context
|
||||
.. seealso:: writePropertiesToElement()
|
||||
.. seealso:: readXml()
|
||||
.. note::
|
||||
|
||||
derived classes must call this base implementation when overriding this method
|
||||
:rtype: bool
|
||||
%End
|
||||
|
||||
};
|
||||
|
42
python/core/layout/qgslayoutitemmap.sip
Normal file
42
python/core/layout/qgslayoutitemmap.sip
Normal file
@ -0,0 +1,42 @@
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/core/layout/qgslayoutitemmap.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
||||
|
||||
|
||||
|
||||
class QgsLayoutItemMap : QgsLayoutItem
|
||||
{
|
||||
%Docstring
|
||||
Layout graphical items for displaying a map.
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgslayoutitemmap.h"
|
||||
%End
|
||||
public:
|
||||
|
||||
explicit QgsLayoutItemMap( QgsLayout *layout );
|
||||
%Docstring
|
||||
Constructor for QgsLayoutItemMap, with the specified parent ``layout``.
|
||||
%End
|
||||
virtual int type() const;
|
||||
virtual QString stringType() const;
|
||||
|
||||
protected:
|
||||
|
||||
virtual void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = 0 );
|
||||
|
||||
};
|
||||
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/core/layout/qgslayoutitemmap.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
91
python/core/layout/qgslayoutitempage.sip
Normal file
91
python/core/layout/qgslayoutitempage.sip
Normal file
@ -0,0 +1,91 @@
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/core/layout/qgslayoutitempage.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
||||
|
||||
|
||||
|
||||
class QgsLayoutItemPage : QgsLayoutItem
|
||||
{
|
||||
%Docstring
|
||||
Item representing the paper in a layout.
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgslayoutitempage.h"
|
||||
%End
|
||||
public:
|
||||
|
||||
enum Orientation
|
||||
{
|
||||
Portrait,
|
||||
Landscape
|
||||
};
|
||||
|
||||
explicit QgsLayoutItemPage( QgsLayout *layout /TransferThis/ );
|
||||
%Docstring
|
||||
Constructor for QgsLayoutItemPage, with the specified parent ``layout``.
|
||||
%End
|
||||
virtual int type() const;
|
||||
virtual QString stringType() const;
|
||||
|
||||
void setPageSize( const QgsLayoutSize &size );
|
||||
%Docstring
|
||||
Sets the ``size`` of the page.
|
||||
.. seealso:: pageSize()
|
||||
%End
|
||||
|
||||
bool setPageSize( const QString &size, Orientation orientation = Portrait );
|
||||
%Docstring
|
||||
Sets the page size to a known page ``size``, e.g. "A4" and ``orientation``.
|
||||
The known page sizes are managed by QgsPageSizeRegistry. Valid page sizes
|
||||
can be retrieved via QgsPageSizeRegistry.entries().
|
||||
The function returns true if ``size`` was a valid page size and the page
|
||||
size was changed. If false is returned then ``size`` could not be matched
|
||||
to a known page size.
|
||||
.. seealso:: pageSize()
|
||||
:rtype: bool
|
||||
%End
|
||||
|
||||
QgsLayoutSize pageSize() const;
|
||||
%Docstring
|
||||
Returns the size of the page.
|
||||
.. seealso:: setPageSize()
|
||||
:rtype: QgsLayoutSize
|
||||
%End
|
||||
|
||||
Orientation orientation() const;
|
||||
%Docstring
|
||||
Returns the page orientiation.
|
||||
.. note::
|
||||
|
||||
There is no direct setter for page orientation - use setPageSize() instead.
|
||||
:rtype: Orientation
|
||||
%End
|
||||
|
||||
static QgsLayoutItemPage::Orientation decodePageOrientation( const QString &string, bool *ok /Out/ = 0 );
|
||||
%Docstring
|
||||
Decodes a ``string`` representing a page orientation. If specified, ``ok``
|
||||
will be set to true if string could be successfully interpreted as a
|
||||
page orientation.
|
||||
:rtype: QgsLayoutItemPage.Orientation
|
||||
%End
|
||||
|
||||
protected:
|
||||
|
||||
virtual void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = 0 );
|
||||
|
||||
|
||||
};
|
||||
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/core/layout/qgslayoutitempage.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
@ -101,6 +101,10 @@ class QgsLayoutItemRegistry : QObject
|
||||
|
||||
// known
|
||||
LayoutPage,
|
||||
LayoutMap,
|
||||
LayoutRectangle,
|
||||
LayoutEllipse,
|
||||
LayoutTriangle,
|
||||
|
||||
// item
|
||||
PluginItem,
|
||||
|
168
python/core/layout/qgslayoutitemshape.sip
Normal file
168
python/core/layout/qgslayoutitemshape.sip
Normal file
@ -0,0 +1,168 @@
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/core/layout/qgslayoutitemshape.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
||||
|
||||
|
||||
|
||||
class QgsLayoutItemShape : QgsLayoutItem
|
||||
{
|
||||
%Docstring
|
||||
Base class for layout items which are basic shapes (e.g. rectangles, ellipses).
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgslayoutitemshape.h"
|
||||
%End
|
||||
public:
|
||||
|
||||
void setSymbol( QgsFillSymbol *symbol );
|
||||
%Docstring
|
||||
Sets the fill ``symbol`` used to draw the shape. Ownership is not transferred
|
||||
and a clone of the symbol is made.
|
||||
.. seealso:: symbol()
|
||||
%End
|
||||
|
||||
QgsFillSymbol *symbol();
|
||||
%Docstring
|
||||
Returns the fill symbol used to draw the shape.
|
||||
.. seealso:: setSymbol()
|
||||
:rtype: QgsFillSymbol
|
||||
%End
|
||||
|
||||
protected:
|
||||
|
||||
explicit QgsLayoutItemShape( QgsLayout *layout );
|
||||
%Docstring
|
||||
Constructor for QgsLayoutItemShape, with the specified parent ``layout``.
|
||||
%End
|
||||
|
||||
};
|
||||
|
||||
|
||||
class QgsLayoutItemRectangularShape : QgsLayoutItemShape
|
||||
{
|
||||
%Docstring
|
||||
A rectangular shape item for layouts.
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgslayoutitemshape.h"
|
||||
%End
|
||||
public:
|
||||
|
||||
explicit QgsLayoutItemRectangularShape( QgsLayout *layout );
|
||||
%Docstring
|
||||
Constructor for QgsLayoutItemRectangularShape, with the specified parent ``layout``.
|
||||
%End
|
||||
virtual int type() const;
|
||||
virtual QString stringType() const;
|
||||
|
||||
static QgsLayoutItemRectangularShape *create( QgsLayout *layout, const QVariantMap &settings ) /Factory/;
|
||||
%Docstring
|
||||
Returns a new rectangular item for the specified ``layout``.
|
||||
|
||||
The caller takes responsibility for deleting the returned object.
|
||||
:rtype: QgsLayoutItemRectangularShape
|
||||
%End
|
||||
|
||||
void setCornerRadius( QgsLayoutMeasurement radius );
|
||||
%Docstring
|
||||
Sets the corner ``radius`` for rounded rectangle corners.
|
||||
.. seealso:: cornerRadius()
|
||||
%End
|
||||
|
||||
QgsLayoutMeasurement cornerRadius() const;
|
||||
%Docstring
|
||||
Returns the corner radius for rounded rectangle corners.
|
||||
.. seealso:: setCornerRadius()
|
||||
:rtype: QgsLayoutMeasurement
|
||||
%End
|
||||
|
||||
protected:
|
||||
|
||||
virtual void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = 0 );
|
||||
|
||||
|
||||
};
|
||||
|
||||
class QgsLayoutItemEllipseShape : QgsLayoutItemShape
|
||||
{
|
||||
%Docstring
|
||||
A ellipse shape item for layouts.
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgslayoutitemshape.h"
|
||||
%End
|
||||
public:
|
||||
|
||||
explicit QgsLayoutItemEllipseShape( QgsLayout *layout );
|
||||
%Docstring
|
||||
Constructor for QgsLayoutItemEllipseShape, with the specified parent ``layout``.
|
||||
%End
|
||||
virtual int type() const;
|
||||
virtual QString stringType() const;
|
||||
|
||||
static QgsLayoutItemEllipseShape *create( QgsLayout *layout, const QVariantMap &settings ) /Factory/;
|
||||
%Docstring
|
||||
Returns a new ellipse item for the specified ``layout``.
|
||||
|
||||
The caller takes responsibility for deleting the returned object.
|
||||
:rtype: QgsLayoutItemEllipseShape
|
||||
%End
|
||||
|
||||
protected:
|
||||
|
||||
virtual void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = 0 );
|
||||
|
||||
|
||||
};
|
||||
|
||||
class QgsLayoutItemTriangleShape : QgsLayoutItemShape
|
||||
{
|
||||
%Docstring
|
||||
A triangle shape item for layouts.
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgslayoutitemshape.h"
|
||||
%End
|
||||
public:
|
||||
|
||||
explicit QgsLayoutItemTriangleShape( QgsLayout *layout );
|
||||
%Docstring
|
||||
Constructor for QgsLayoutItemTriangleShape, with the specified parent ``layout``.
|
||||
%End
|
||||
virtual int type() const;
|
||||
virtual QString stringType() const;
|
||||
|
||||
static QgsLayoutItemTriangleShape *create( QgsLayout *layout, const QVariantMap &settings ) /Factory/;
|
||||
%Docstring
|
||||
Returns a new triangle item for the specified ``layout``.
|
||||
|
||||
The caller takes responsibility for deleting the returned object.
|
||||
:rtype: QgsLayoutItemTriangleShape
|
||||
%End
|
||||
|
||||
protected:
|
||||
|
||||
virtual void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = 0 );
|
||||
|
||||
|
||||
};
|
||||
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/core/layout/qgslayoutitemshape.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
@ -9,7 +9,7 @@
|
||||
|
||||
|
||||
|
||||
class QgsLayoutObject: QObject
|
||||
class QgsLayoutObject: QObject, QgsExpressionContextGenerator
|
||||
{
|
||||
%Docstring
|
||||
A base class for objects which belong to a layout.
|
||||
@ -21,7 +21,64 @@ class QgsLayoutObject: QObject
|
||||
%End
|
||||
public:
|
||||
|
||||
QgsLayoutObject( QgsLayout *layout );
|
||||
enum DataDefinedProperty
|
||||
{
|
||||
NoProperty,
|
||||
AllProperties,
|
||||
TestProperty,
|
||||
//composer
|
||||
PresetPaperSize,
|
||||
PaperWidth,
|
||||
PaperHeight,
|
||||
NumPages,
|
||||
PaperOrientation,
|
||||
//general
|
||||
PageNumber,
|
||||
PositionX,
|
||||
PositionY,
|
||||
ItemWidth,
|
||||
ItemHeight,
|
||||
ItemRotation,
|
||||
Transparency,
|
||||
Opacity,
|
||||
BlendMode,
|
||||
ExcludeFromExports,
|
||||
FrameColor,
|
||||
BackgroundColor,
|
||||
//composer
|
||||
MapRotation,
|
||||
MapScale,
|
||||
MapXMin,
|
||||
MapYMin,
|
||||
MapXMax,
|
||||
MapYMax,
|
||||
MapAtlasMargin,
|
||||
MapLayers,
|
||||
MapStylePreset,
|
||||
//composer
|
||||
PictureSource,
|
||||
PictureSvgBackgroundColor,
|
||||
PictureSvgStrokeColor,
|
||||
PictureSvgStrokeWidth,
|
||||
//html
|
||||
SourceUrl,
|
||||
//legend
|
||||
LegendTitle,
|
||||
LegendColumnCount,
|
||||
//scalebar
|
||||
ScalebarFillColor,
|
||||
ScalebarFillColor2,
|
||||
ScalebarLineColor,
|
||||
ScalebarLineWidth,
|
||||
};
|
||||
|
||||
static const QgsPropertiesDefinition &propertyDefinitions();
|
||||
%Docstring
|
||||
Returns the layout object property definitions.
|
||||
:rtype: QgsPropertiesDefinition
|
||||
%End
|
||||
|
||||
explicit QgsLayoutObject( QgsLayout *layout );
|
||||
%Docstring
|
||||
Constructor for QgsLayoutObject, with the specified parent ``layout``.
|
||||
.. note::
|
||||
@ -38,8 +95,103 @@ class QgsLayoutObject: QObject
|
||||
:rtype: QgsLayout
|
||||
%End
|
||||
|
||||
QgsPropertyCollection &dataDefinedProperties();
|
||||
%Docstring
|
||||
Returns a reference to the object's property collection, used for data defined overrides.
|
||||
.. seealso:: setDataDefinedProperties()
|
||||
:rtype: QgsPropertyCollection
|
||||
%End
|
||||
|
||||
|
||||
void setDataDefinedProperties( const QgsPropertyCollection &collection );
|
||||
%Docstring
|
||||
Sets the objects's property collection, used for data defined overrides.
|
||||
\param collection property collection. Existing properties will be replaced.
|
||||
.. seealso:: dataDefinedProperties()
|
||||
%End
|
||||
|
||||
|
||||
void setCustomProperty( const QString &key, const QVariant &value );
|
||||
%Docstring
|
||||
Set a custom property for the object.
|
||||
\param key property key. If a property with the same key already exists it will be overwritten.
|
||||
\param value property value
|
||||
.. seealso:: customProperty()
|
||||
.. seealso:: removeCustomProperty()
|
||||
.. seealso:: customProperties()
|
||||
%End
|
||||
|
||||
QVariant customProperty( const QString &key, const QVariant &defaultValue = QVariant() ) const;
|
||||
%Docstring
|
||||
Read a custom property from the object.
|
||||
\param key property key
|
||||
\param defaultValue default value to return if property with matching key does not exist
|
||||
:return: value of matching property
|
||||
.. seealso:: setCustomProperty()
|
||||
.. seealso:: removeCustomProperty()
|
||||
.. seealso:: customProperties()
|
||||
:rtype: QVariant
|
||||
%End
|
||||
|
||||
void removeCustomProperty( const QString &key );
|
||||
%Docstring
|
||||
Remove a custom property from the object.
|
||||
\param key property key
|
||||
.. seealso:: setCustomProperty()
|
||||
.. seealso:: customProperty()
|
||||
.. seealso:: customProperties()
|
||||
%End
|
||||
|
||||
QStringList customProperties() const;
|
||||
%Docstring
|
||||
Return list of keys stored in custom properties for the object.
|
||||
.. seealso:: setCustomProperty()
|
||||
.. seealso:: customProperty()
|
||||
.. seealso:: removeCustomProperty()
|
||||
:rtype: list of str
|
||||
%End
|
||||
|
||||
virtual QgsExpressionContext createExpressionContext() const;
|
||||
|
||||
%Docstring
|
||||
Creates an expression context relating to the objects' current state. The context includes
|
||||
scopes for global, project and layout properties.
|
||||
:rtype: QgsExpressionContext
|
||||
%End
|
||||
|
||||
public slots:
|
||||
|
||||
virtual void refresh();
|
||||
%Docstring
|
||||
Refreshes the object, causing a recalculation of any property overrides.
|
||||
%End
|
||||
|
||||
protected:
|
||||
|
||||
bool writeObjectPropertiesToElement( QDomElement &parentElement, QDomDocument &document, const QgsReadWriteContext &context ) const;
|
||||
%Docstring
|
||||
Stores object properties within an XML DOM element.
|
||||
\param parentElement is the parent DOM element to store the object's properties in
|
||||
\param document DOM document
|
||||
\param context read write context
|
||||
:return: true if write was successful
|
||||
.. seealso:: readObjectPropertiesFromElement()
|
||||
:rtype: bool
|
||||
%End
|
||||
|
||||
bool readObjectPropertiesFromElement( const QDomElement &parentElement, const QDomDocument &document, const QgsReadWriteContext &context );
|
||||
%Docstring
|
||||
Sets object properties from a DOM element
|
||||
\param parentElement is the parent DOM element for the object
|
||||
\param document DOM document
|
||||
\param context read write context
|
||||
:return: true if read was successful
|
||||
.. seealso:: writeObjectPropertiesToElement()
|
||||
:rtype: bool
|
||||
%End
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
206
python/core/layout/qgslayoutpagecollection.sip
Normal file
206
python/core/layout/qgslayoutpagecollection.sip
Normal file
@ -0,0 +1,206 @@
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/core/layout/qgslayoutpagecollection.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
||||
|
||||
|
||||
|
||||
|
||||
class QgsLayoutPageCollection : QObject
|
||||
{
|
||||
%Docstring
|
||||
A manager for a collection of pages in a layout.
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgslayoutpagecollection.h"
|
||||
%End
|
||||
public:
|
||||
|
||||
explicit QgsLayoutPageCollection( QgsLayout *layout /TransferThis/ );
|
||||
%Docstring
|
||||
Constructor for QgsLayoutItemPage, with the specified parent ``layout``.
|
||||
%End
|
||||
|
||||
~QgsLayoutPageCollection();
|
||||
|
||||
QgsLayout *layout() const;
|
||||
%Docstring
|
||||
Returns the layout this collection belongs to.
|
||||
:rtype: QgsLayout
|
||||
%End
|
||||
|
||||
QList< QgsLayoutItemPage * > pages();
|
||||
%Docstring
|
||||
Returns a list of pages in the collection.
|
||||
.. seealso:: page()
|
||||
.. seealso:: pageCount()
|
||||
:rtype: list of QgsLayoutItemPage
|
||||
%End
|
||||
|
||||
int pageCount() const;
|
||||
%Docstring
|
||||
Returns the number of pages in the collection.
|
||||
.. seealso:: pages()
|
||||
:rtype: int
|
||||
%End
|
||||
|
||||
QgsLayoutItemPage *page( int pageNumber );
|
||||
%Docstring
|
||||
Returns a specific page (by ``pageNumber``) from the collection.
|
||||
Internal page numbering starts at 0 - so a ``pageNumber`` of 0
|
||||
corresponds to the first page in the collection.
|
||||
A None is returned if an invalid page number is specified.
|
||||
.. seealso:: pages()
|
||||
:rtype: QgsLayoutItemPage
|
||||
%End
|
||||
|
||||
void addPage( QgsLayoutItemPage *page /Transfer/ );
|
||||
%Docstring
|
||||
Adds a ``page`` to the collection. Ownership of the ``page`` is transferred
|
||||
to the collection, and the page will automatically be added to the collection's
|
||||
layout() (there is no need to manually add the page item to the layout).
|
||||
The page will be added after all pages currently contained in the collection.
|
||||
|
||||
Calling addPage() automatically triggers a reflow() of pages.
|
||||
|
||||
.. seealso:: insertPage()
|
||||
%End
|
||||
|
||||
void insertPage( QgsLayoutItemPage *page /Transfer/, int beforePage );
|
||||
%Docstring
|
||||
Inserts a ``page`` into a specific position in the collection.
|
||||
|
||||
Ownership of the ``page`` is transferred
|
||||
to the collection, and the page will automatically be added to the collection's
|
||||
layout() (there is no need to manually add the page item to the layout).
|
||||
|
||||
The page will be added after before the page number specified by ``beforePage``.
|
||||
(Page numbers in collections begin at 0 - so a ``beforePage`` of 0 will insert
|
||||
the page before all existing pages).
|
||||
|
||||
Calling insertPage() automatically triggers a reflow() of pages.
|
||||
|
||||
.. seealso:: addPage()
|
||||
%End
|
||||
|
||||
void deletePage( int pageNumber );
|
||||
%Docstring
|
||||
Deletes a page from the collection. The page will automatically be removed
|
||||
from the collection's layout().
|
||||
|
||||
Page numbers in collections begin at 0 - so a ``pageNumber`` of 0 will delete
|
||||
the first page in the collection.
|
||||
|
||||
Calling deletePage() automatically triggers a reflow() of pages.
|
||||
%End
|
||||
|
||||
void deletePage( QgsLayoutItemPage *page );
|
||||
%Docstring
|
||||
Deletes a page from the collection. The page will automatically be removed
|
||||
from the collection's layout().
|
||||
|
||||
Calling deletePage() automatically triggers a reflow() of pages.
|
||||
%End
|
||||
|
||||
void setPageStyleSymbol( QgsFillSymbol *symbol );
|
||||
%Docstring
|
||||
Sets the ``symbol`` to use for drawing pages in the collection.
|
||||
|
||||
Ownership is not transferred, and a copy of the symbol is created internally.
|
||||
.. seealso:: pageStyleSymbol()
|
||||
%End
|
||||
|
||||
const QgsFillSymbol *pageStyleSymbol() const;
|
||||
%Docstring
|
||||
Returns the symbol to use for drawing pages in the collection.
|
||||
.. seealso:: setPageStyleSymbol()
|
||||
:rtype: QgsFillSymbol
|
||||
%End
|
||||
|
||||
void reflow();
|
||||
%Docstring
|
||||
Forces the page collection to reflow the arrangement of pages, e.g. to account
|
||||
for page size/orientation change.
|
||||
%End
|
||||
|
||||
double maximumPageWidth() const;
|
||||
%Docstring
|
||||
Returns the maximum width of pages in the collection. The returned value is
|
||||
in layout units.
|
||||
:rtype: float
|
||||
%End
|
||||
|
||||
int pageNumberForPoint( QPointF point ) const;
|
||||
%Docstring
|
||||
Returns the page number corresponding to a ``point`` in the layout (in layout units).
|
||||
|
||||
Page numbers in collections begin at 0 - so a page number of 0 indicates the
|
||||
first page.
|
||||
|
||||
.. note::
|
||||
|
||||
This is a relaxed check, which will always return a page number. For instance,
|
||||
it does not consider x coordinates and vertical coordinates before the first page or
|
||||
after the last page will still return the nearest page.
|
||||
|
||||
.. seealso:: pageAtPoint()
|
||||
.. seealso:: positionOnPage()
|
||||
:rtype: int
|
||||
%End
|
||||
|
||||
QgsLayoutItemPage *pageAtPoint( QPointF point ) const;
|
||||
%Docstring
|
||||
Returns the page at a specified ``point`` (in layout coordinates).
|
||||
|
||||
If no page exists at ``point``, None will be returned.
|
||||
|
||||
.. note::
|
||||
|
||||
Unlike pageNumberForPoint(), this method only returns pages which
|
||||
directly intersect with the specified point.
|
||||
|
||||
.. seealso:: pageNumberForPoint()
|
||||
:rtype: QgsLayoutItemPage
|
||||
%End
|
||||
|
||||
QPointF positionOnPage( QPointF point ) const;
|
||||
%Docstring
|
||||
Returns the position within a page of a ``point`` in the layout (in layout units).
|
||||
|
||||
.. seealso:: pageNumberForPoint()
|
||||
:rtype: QPointF
|
||||
%End
|
||||
|
||||
double spaceBetweenPages() const;
|
||||
%Docstring
|
||||
Returns the space between pages, in layout units.
|
||||
:rtype: float
|
||||
%End
|
||||
|
||||
double pageShadowWidth() const;
|
||||
%Docstring
|
||||
Returns the size of the page shadow, in layout units.
|
||||
:rtype: float
|
||||
%End
|
||||
|
||||
signals:
|
||||
|
||||
void changed();
|
||||
%Docstring
|
||||
Emitted when pages are added or removed from the collection.
|
||||
%End
|
||||
|
||||
};
|
||||
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/core/layout/qgslayoutpagecollection.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
@ -36,6 +36,11 @@ class QgsLayoutPoint
|
||||
Constructor for QgsLayoutPoint.
|
||||
%End
|
||||
|
||||
explicit QgsLayoutPoint( const QPointF point, const QgsUnitTypes::LayoutUnit units = QgsUnitTypes::LayoutMillimeters );
|
||||
%Docstring
|
||||
Constructor for QgsLayoutPoint.
|
||||
%End
|
||||
|
||||
explicit QgsLayoutPoint( const QgsUnitTypes::LayoutUnit units = QgsUnitTypes::LayoutMillimeters );
|
||||
%Docstring
|
||||
Constructor for an empty point, where both x and y are set to 0.
|
||||
|
@ -40,6 +40,11 @@ class QgsLayoutSize
|
||||
\param units units for width and height
|
||||
%End
|
||||
|
||||
explicit QgsLayoutSize( const QSizeF size, const QgsUnitTypes::LayoutUnit units = QgsUnitTypes::LayoutMillimeters );
|
||||
%Docstring
|
||||
Constructor for QgsLayoutSize.
|
||||
%End
|
||||
|
||||
explicit QgsLayoutSize( const QgsUnitTypes::LayoutUnit units = QgsUnitTypes::LayoutMillimeters );
|
||||
%Docstring
|
||||
Constructor for an empty layout size
|
||||
|
61
python/core/layout/qgslayoututils.sip
Normal file
61
python/core/layout/qgslayoututils.sip
Normal file
@ -0,0 +1,61 @@
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/core/layout/qgslayoututils.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
||||
|
||||
|
||||
|
||||
|
||||
class QgsLayoutUtils
|
||||
{
|
||||
%Docstring
|
||||
Utilities for layouts.
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgslayoututils.h"
|
||||
%End
|
||||
public:
|
||||
|
||||
static double normalizedAngle( const double angle, const bool allowNegative = false );
|
||||
%Docstring
|
||||
Ensures that an ``angle`` (in degrees) is in the range 0 <= angle < 360.
|
||||
If ``allowNegative`` is true then angles between (-360, 360) are allowed. If false,
|
||||
angles are converted to positive angles in the range [0, 360).
|
||||
:rtype: float
|
||||
%End
|
||||
|
||||
static QgsRenderContext createRenderContextForMap( QgsLayoutItemMap *map, QPainter *painter, double dpi = -1 );
|
||||
%Docstring
|
||||
Creates a render context suitable for the specified layout ``map`` and ``painter`` destination.
|
||||
This method returns a new QgsRenderContext which matches the scale and settings of the
|
||||
target map. If the ``dpi`` argument is not specified then the dpi will be taken from the destination
|
||||
painter device.
|
||||
.. seealso:: createRenderContextForLayout()
|
||||
:rtype: QgsRenderContext
|
||||
%End
|
||||
|
||||
static QgsRenderContext createRenderContextForLayout( QgsLayout *layout, QPainter *painter, double dpi = -1 );
|
||||
%Docstring
|
||||
Creates a render context suitable for the specified ``layout`` and ``painter`` destination.
|
||||
This method returns a new QgsRenderContext which matches the scale and settings from the layout's
|
||||
QgsLayout.referenceMap().
|
||||
If the ``dpi`` argument is not specified then the dpi will be taken from the destination
|
||||
painter device.
|
||||
.. seealso:: createRenderContextForMap()
|
||||
:rtype: QgsRenderContext
|
||||
%End
|
||||
|
||||
};
|
||||
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/core/layout/qgslayoututils.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
@ -23,7 +23,7 @@ class QgsPageSize
|
||||
|
||||
QgsPageSize();
|
||||
|
||||
QgsPageSize( const QString &name, const QgsLayoutSize &size );
|
||||
QgsPageSize( const QString &name, const QgsLayoutSize &size, const QString &displayName = QString() );
|
||||
%Docstring
|
||||
Constructor for QgsPageSize, accepting the ``name`` of the page size and
|
||||
page ``size``.
|
||||
@ -42,6 +42,11 @@ Name of page size
|
||||
QgsLayoutSize size;
|
||||
%Docstring
|
||||
Page size
|
||||
%End
|
||||
|
||||
QString displayName;
|
||||
%Docstring
|
||||
Translated page name
|
||||
%End
|
||||
|
||||
bool operator==( const QgsPageSize &other ) const;
|
||||
@ -90,6 +95,16 @@ class QgsPageSizeRegistry
|
||||
:rtype: list of QgsPageSize
|
||||
%End
|
||||
|
||||
QString find( const QgsLayoutSize &size ) const;
|
||||
%Docstring
|
||||
Finds a matching page ``size`` from the registry. Returns the page size name,
|
||||
or an empty string if no matching size could be found.
|
||||
|
||||
Orientation is ignored when matching page sizes, so a landscape A4 page will
|
||||
match to the portrait A4 size in the registry.
|
||||
:rtype: str
|
||||
%End
|
||||
|
||||
bool decodePageSize( const QString &string, QgsPageSize &size );
|
||||
%Docstring
|
||||
Decodes a ``string`` representing a preset page size.
|
||||
|
@ -30,6 +30,8 @@ class QgsProcessingAlgorithm
|
||||
%ConvertToSubClassCode
|
||||
if ( dynamic_cast< QgsProcessingModelAlgorithm * >( sipCpp ) != NULL )
|
||||
sipType = sipType_QgsProcessingModelAlgorithm;
|
||||
else if ( dynamic_cast< QgsProcessingFeatureBasedAlgorithm * >( sipCpp ) != NULL )
|
||||
sipType = sipType_QgsProcessingFeatureBasedAlgorithm;
|
||||
else
|
||||
sipType = sipType_QgsProcessingAlgorithm;
|
||||
%End
|
||||
@ -59,7 +61,8 @@ class QgsProcessingAlgorithm
|
||||
virtual ~QgsProcessingAlgorithm();
|
||||
|
||||
|
||||
QgsProcessingAlgorithm *create( const QVariantMap &configuration = QVariantMap() ) const /Factory/;
|
||||
|
||||
QgsProcessingAlgorithm *create( const QVariantMap &configuration = QVariantMap() ) const /TransferBack/;
|
||||
%Docstring
|
||||
Creates a copy of the algorithm, ready for execution.
|
||||
|
||||
@ -358,19 +361,13 @@ class QgsProcessingAlgorithm
|
||||
|
||||
protected:
|
||||
|
||||
virtual QgsProcessingAlgorithm *createInstance() const = 0;
|
||||
virtual QgsProcessingAlgorithm *createInstance() const = 0 /Factory/;
|
||||
%Docstring
|
||||
Creates a new instance of the algorithm class.
|
||||
|
||||
This method should return a 'pristine' instance of the algorithm class.
|
||||
:rtype: QgsProcessingAlgorithm
|
||||
%End
|
||||
%VirtualCatcherCode
|
||||
PyObject *resObj = sipCallMethod( 0, sipMethod, "" );
|
||||
sipIsErr = !resObj || sipParseResult( 0, sipMethod, resObj, "H2", sipType_QgsProcessingAlgorithm, &sipRes ) < 0;
|
||||
if ( !sipIsErr )
|
||||
sipTransferTo( resObj, Py_None );
|
||||
%End
|
||||
|
||||
virtual void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) = 0;
|
||||
%Docstring
|
||||
@ -717,6 +714,136 @@ QFlags<QgsProcessingAlgorithm::Flag> operator|(QgsProcessingAlgorithm::Flag f1,
|
||||
|
||||
|
||||
|
||||
class QgsProcessingFeatureBasedAlgorithm : QgsProcessingAlgorithm
|
||||
{
|
||||
%Docstring
|
||||
An abstract QgsProcessingAlgorithm base class for processing algorithms which operate "feature-by-feature".
|
||||
|
||||
Feature based algorithms are algorithms which operate on individual features in isolation. These
|
||||
are algorithms where one feature is output for each input feature, and the output feature result
|
||||
for each input feature is not dependent on any other features present in the source.
|
||||
|
||||
For instance, algorithms like "centroids" and "buffers" are feature based algorithms since the centroid
|
||||
or buffer of a feature is calculated for each feature in isolation. An algorithm like "dissolve"
|
||||
is NOT suitable for a feature based algorithm as the dissolved output depends on multiple input features
|
||||
and these features cannot be processed in isolation.
|
||||
|
||||
Using QgsProcessingFeatureBasedAlgorithm as the base class for feature based algorithms allows
|
||||
shortcutting much of the common algorithm code for handling iterating over sources and pushing
|
||||
features to output sinks. It also allows the algorithm execution to be optimised in future
|
||||
(for instance allowing automatic multi-thread processing of the algorithm, or use of the
|
||||
algorithm in "chains", avoiding the need for temporary outputs in multi-step models).
|
||||
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgsprocessingalgorithm.h"
|
||||
%End
|
||||
public:
|
||||
|
||||
QgsProcessingFeatureBasedAlgorithm();
|
||||
%Docstring
|
||||
Constructor for QgsProcessingFeatureBasedAlgorithm.
|
||||
%End
|
||||
|
||||
protected:
|
||||
|
||||
virtual void initAlgorithm( const QVariantMap &configuration = QVariantMap() );
|
||||
|
||||
|
||||
virtual QString outputName() const = 0;
|
||||
%Docstring
|
||||
Returns the translated, user visible name for any layers created by this algorithm.
|
||||
This name will be used as the default name when loading the resultant layer into a
|
||||
QGIS project.
|
||||
:rtype: str
|
||||
%End
|
||||
|
||||
virtual QgsProcessing::LayerType outputLayerType() const;
|
||||
%Docstring
|
||||
Returns the layer type for layers generated by this algorithm, if
|
||||
this is possible to determine in advance.
|
||||
:rtype: QgsProcessing.LayerType
|
||||
%End
|
||||
|
||||
virtual QgsWkbTypes::Type outputWkbType( QgsWkbTypes::Type inputWkbType ) const;
|
||||
%Docstring
|
||||
Maps the input WKB geometry type (``inputWkbType``) to the corresponding
|
||||
output WKB type generated by the algorithm. The default behavior is that the algorithm maintains
|
||||
the same WKB type.
|
||||
This is called once by the base class when creating the output sink for the algorithm (i.e. it is
|
||||
not called once per feature processed).
|
||||
:rtype: QgsWkbTypes.Type
|
||||
%End
|
||||
|
||||
virtual QgsFields outputFields( const QgsFields &inputFields ) const;
|
||||
%Docstring
|
||||
Maps the input source fields (``inputFields``) to corresponding
|
||||
output fields generated by the algorithm. The default behavior is that the algorithm maintains
|
||||
the same fields as are input.
|
||||
Algorithms which add, remove or modify existing fields should override this method and
|
||||
implement logic here to indicate which fields are output by the algorithm.
|
||||
|
||||
This is called once by the base class when creating the output sink for the algorithm (i.e. it is
|
||||
not called once per feature processed).
|
||||
:rtype: QgsFields
|
||||
%End
|
||||
|
||||
virtual QgsCoordinateReferenceSystem outputCrs( const QgsCoordinateReferenceSystem &inputCrs ) const;
|
||||
%Docstring
|
||||
Maps the input source coordinate reference system (``inputCrs``) to a corresponding
|
||||
output CRS generated by the algorithm. The default behavior is that the algorithm maintains
|
||||
the same CRS as the input source.
|
||||
|
||||
This is called once by the base class when creating the output sink for the algorithm (i.e. it is
|
||||
not called once per feature processed).
|
||||
:rtype: QgsCoordinateReferenceSystem
|
||||
%End
|
||||
|
||||
virtual void initParameters( const QVariantMap &configuration = QVariantMap() );
|
||||
%Docstring
|
||||
Initializes any extra parameters added by the algorithm subclass. There is no need
|
||||
to declare the input source or output sink, as these are automatically created by
|
||||
QgsProcessingFeatureBasedAlgorithm.
|
||||
%End
|
||||
|
||||
QgsCoordinateReferenceSystem sourceCrs() const;
|
||||
%Docstring
|
||||
Returns the source's coordinate reference system. This will only return a valid CRS when
|
||||
called from a subclasses' processFeature() implementation.
|
||||
:rtype: QgsCoordinateReferenceSystem
|
||||
%End
|
||||
|
||||
virtual QgsFeature processFeature( const QgsFeature &feature, QgsProcessingFeedback *feedback ) = 0;
|
||||
%Docstring
|
||||
Processes an individual input ``feature`` from the source. Algorithms should implement their
|
||||
logic in this method for performing the algorithm's operation (e.g. replacing the feature's
|
||||
geometry with the centroid of the original feature geometry for a 'centroid' type
|
||||
algorithm).
|
||||
|
||||
Implementations should return the modified feature. Returning an invalid feature (e.g.
|
||||
a default constructed QgsFeature) will indicate that this feature should be 'skipped',
|
||||
and will not be added to the algorithm's output. Subclasses can use this approach to
|
||||
filter the incoming features as desired.
|
||||
|
||||
The provided ``feedback`` object can be used to push messages to the log and for giving feedback
|
||||
to users. Note that handling of progress reports and algorithm cancelation is handled by
|
||||
the base class and subclasses do not need to reimplement this logic.
|
||||
|
||||
Algorithms can throw a QgsProcessingException if a fatal error occurred which should
|
||||
prevent the algorithm execution from continuing. This can be annoying for users though as it
|
||||
can break valid model execution - so use with extreme caution, and consider using
|
||||
``feedback`` to instead report non-fatal processing failures for features instead.
|
||||
:rtype: QgsFeature
|
||||
%End
|
||||
|
||||
virtual QVariantMap processAlgorithm( const QVariantMap ¶meters,
|
||||
QgsProcessingContext &context, QgsProcessingFeedback *feedback );
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
|
@ -1395,7 +1395,10 @@ class QgsProcessingParameterVectorLayer : QgsProcessingParameterDefinition
|
||||
%End
|
||||
public:
|
||||
|
||||
QgsProcessingParameterVectorLayer( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(),
|
||||
QgsProcessingParameterVectorLayer( const QString &name,
|
||||
const QString &description = QString(),
|
||||
const QList< int > &types = QList< int >(),
|
||||
const QVariant &defaultValue = QVariant(),
|
||||
bool optional = false );
|
||||
%Docstring
|
||||
Constructor for QgsProcessingParameterVectorLayer.
|
||||
@ -1412,6 +1415,24 @@ class QgsProcessingParameterVectorLayer : QgsProcessingParameterDefinition
|
||||
virtual QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const;
|
||||
|
||||
|
||||
QList< int > dataTypes() const;
|
||||
%Docstring
|
||||
Returns the geometry types for sources acceptable by the parameter.
|
||||
.. seealso:: setDataTypes()
|
||||
:rtype: list of int
|
||||
%End
|
||||
|
||||
void setDataTypes( const QList< int > &types );
|
||||
%Docstring
|
||||
Sets the geometry ``types`` for sources acceptable by the parameter.
|
||||
.. seealso:: dataTypes()
|
||||
%End
|
||||
|
||||
virtual QVariantMap toVariantMap() const;
|
||||
|
||||
virtual bool fromVariantMap( const QVariantMap &map );
|
||||
|
||||
|
||||
static QgsProcessingParameterVectorLayer *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
|
||||
%Docstring
|
||||
Creates a new parameter using the definition from a script code.
|
||||
|
@ -89,7 +89,8 @@ class QgsProcessingRegistry : QObject
|
||||
:rtype: QgsProcessingAlgorithm
|
||||
%End
|
||||
|
||||
QgsProcessingAlgorithm *createAlgorithmById( const QString &id, const QVariantMap &configuration = QVariantMap() ) const /Factory/;
|
||||
|
||||
QgsProcessingAlgorithm *createAlgorithmById( const QString &id, const QVariantMap &configuration = QVariantMap() ) const /TransferBack/;
|
||||
%Docstring
|
||||
Creates a new instance of an algorithm by its ID. If no matching algorithm is found, a None
|
||||
is returned. Callers take responsibility for deleting the returned object.
|
||||
|
@ -108,6 +108,13 @@ Default threshold between map coordinates and device coordinates for map2pixel s
|
||||
Default Z coordinate value for 2.5d geometry
|
||||
This value have to be assigned to the Z coordinate for the new 2.5d geometry vertex.
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
static const double UI_SCALE_FACTOR;
|
||||
%Docstring
|
||||
UI scaling factor. This should be applied to all widget sizes obtained from font metrics,
|
||||
to account for differences in the default font sizes across different platforms.
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
};
|
||||
|
@ -80,7 +80,7 @@ to change due to centralization.
|
||||
static const char *QGIS_ORGANIZATION_NAME;
|
||||
static const char *QGIS_ORGANIZATION_DOMAIN;
|
||||
static const char *QGIS_APPLICATION_NAME;
|
||||
QgsApplication( SIP_PYLIST argv, bool GUIenabled, QString customConfigPath = QString() ) / PostHook = __pyQtQAppHook__ / [( int &argc, char **argv, bool GUIenabled, const QString &customConfigPath = QString() )];
|
||||
QgsApplication( SIP_PYLIST argv, bool GUIenabled, QString profileFolder = QString(), QString platformName = "desktop" ) / PostHook = __pyQtQAppHook__ / [( int &argc, char **argv, bool GUIenabled, const QString &profileFolder = QString(), const QString &platformName = "desktop" )];
|
||||
%MethodCode
|
||||
// The Python interface is a list of argument strings that is modified.
|
||||
|
||||
@ -95,7 +95,7 @@ to change due to centralization.
|
||||
// Create it now the arguments are right.
|
||||
static int nargc = argc;
|
||||
|
||||
sipCpp = new sipQgsApplication( nargc, argv, a1, *a2 );
|
||||
sipCpp = new sipQgsApplication( nargc, argv, a1, *a2, *a3 );
|
||||
|
||||
// Now modify the original list.
|
||||
qtgui_UpdatePyArgv( a0, argc, argv );
|
||||
|
@ -138,6 +138,10 @@ Refresh item children
|
||||
void stateChanged( const QModelIndex &index, QgsDataItem::State oldState );
|
||||
%Docstring
|
||||
Emitted when item children fetch was finished
|
||||
%End
|
||||
void connectionsChanged();
|
||||
%Docstring
|
||||
notify the provider dialogs of a changed connection
|
||||
%End
|
||||
|
||||
public slots:
|
||||
|
@ -144,7 +144,7 @@ class QgsGradientColorRamp : QgsColorRamp
|
||||
\param stops optional list of additional color stops
|
||||
%End
|
||||
|
||||
static QgsColorRamp *create( const QgsStringMap &properties = QgsStringMap() );
|
||||
static QgsColorRamp *create( const QgsStringMap &properties = QgsStringMap() ) /Factory/;
|
||||
%Docstring
|
||||
Creates a new QgsColorRamp from a map of properties
|
||||
:rtype: QgsColorRamp
|
||||
@ -477,7 +477,7 @@ class QgsPresetSchemeColorRamp : QgsColorRamp, QgsColorScheme
|
||||
not available in Python bindings - use setColors instead
|
||||
%End
|
||||
|
||||
static QgsColorRamp *create( const QgsStringMap &properties = QgsStringMap() );
|
||||
static QgsColorRamp *create( const QgsStringMap &properties = QgsStringMap() ) /Factory/;
|
||||
%Docstring
|
||||
Returns a new QgsPresetSchemeColorRamp color ramp created using the properties encoded in a string
|
||||
map.
|
||||
@ -541,7 +541,7 @@ class QgsColorBrewerColorRamp : QgsColorRamp
|
||||
\param inverted invert ramp ordering
|
||||
%End
|
||||
|
||||
static QgsColorRamp *create( const QgsStringMap &properties = QgsStringMap() );
|
||||
static QgsColorRamp *create( const QgsStringMap &properties = QgsStringMap() ) /Factory/;
|
||||
%Docstring
|
||||
Returns a new QgsColorBrewerColorRamp color ramp created using the properties encoded in a string
|
||||
map.
|
||||
@ -647,7 +647,7 @@ class QgsCptCityColorRamp : QgsGradientColorRamp
|
||||
\param doLoadFile load cpt-city ramp from file
|
||||
%End
|
||||
|
||||
static QgsColorRamp *create( const QgsStringMap &properties = QgsStringMap() );
|
||||
static QgsColorRamp *create( const QgsStringMap &properties = QgsStringMap() ) /Factory/;
|
||||
%Docstring
|
||||
:rtype: QgsColorRamp
|
||||
%End
|
||||
|
@ -304,6 +304,11 @@ Remove children recursively and set as not populated. This is used when refreshi
|
||||
|
||||
virtual void refresh();
|
||||
|
||||
virtual void refreshConnections();
|
||||
%Docstring
|
||||
Refresh connections: update GUI and emit signal
|
||||
%End
|
||||
|
||||
virtual void childrenCreated();
|
||||
|
||||
signals:
|
||||
@ -313,6 +318,10 @@ Remove children recursively and set as not populated. This is used when refreshi
|
||||
void endRemoveItems();
|
||||
void dataChanged( QgsDataItem *item );
|
||||
void stateChanged( QgsDataItem *item, QgsDataItem::State oldState );
|
||||
void connectionsChanged();
|
||||
%Docstring
|
||||
open browsers
|
||||
%End
|
||||
|
||||
protected slots:
|
||||
|
||||
|
@ -36,12 +36,14 @@ class QgsDatumTransformStore
|
||||
:rtype: bool
|
||||
%End
|
||||
|
||||
QgsCoordinateTransform transformation( const QgsMapLayer *layer ) const;
|
||||
QgsCoordinateTransform transformation( const QgsMapLayer *layer, QString srcAuthId = QString(), QString dstAuthId = QString() ) const;
|
||||
%Docstring
|
||||
Will return transform from layer's CRS to current destination CRS.
|
||||
Will emit datumTransformInfoRequested signal if the layer has no entry.
|
||||
:return: transformation associated with layer, or an invalid QgsCoordinateTransform
|
||||
if no transform is associated with the layer
|
||||
\param layer the associated layer
|
||||
\param srcAuthId source CRS (defaults to layer crs)
|
||||
\param dstAuthId destination CRS (defaults to store's crs)
|
||||
:rtype: QgsCoordinateTransform
|
||||
%End
|
||||
|
||||
|
@ -854,6 +854,37 @@ class QgsExpressionContextUtils
|
||||
\param variables new set of layer variables
|
||||
.. seealso:: setCompositionVariable()
|
||||
.. seealso:: compositionScope()
|
||||
%End
|
||||
|
||||
static QgsExpressionContextScope *layoutScope( const QgsLayout *layout ) /Factory/;
|
||||
%Docstring
|
||||
Creates a new scope which contains variables and functions relating to a QgsLayout ``layout``.
|
||||
For instance, number of pages and page sizes.
|
||||
.. versionadded:: 3.0
|
||||
:rtype: QgsExpressionContextScope
|
||||
%End
|
||||
|
||||
static void setLayoutVariable( QgsLayout *layout, const QString &name, const QVariant &value );
|
||||
%Docstring
|
||||
Sets a layout context variable. This variable will be contained within scopes retrieved via
|
||||
layoutScope().
|
||||
\param layout target layout
|
||||
\param name variable name
|
||||
\param value variable value
|
||||
.. seealso:: setLayoutVariables()
|
||||
.. seealso:: layoutScope()
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
static void setLayoutVariables( QgsLayout *layout, const QVariantMap &variables );
|
||||
%Docstring
|
||||
Sets all layout context variables. Existing layout variables will be removed and replaced
|
||||
with the variables specified.
|
||||
\param layout target layout
|
||||
\param variables new set of layer variables
|
||||
.. seealso:: setLayoutVariable()
|
||||
.. seealso:: layoutScope()
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
static QgsExpressionContextScope *atlasScope( const QgsAtlasComposition *atlas ) /Factory/;
|
||||
|
@ -31,7 +31,8 @@ class QgsMapRendererTask : QgsTask
|
||||
|
||||
QgsMapRendererTask( const QgsMapSettings &ms,
|
||||
const QString &fileName,
|
||||
const QString &fileFormat = QString( "PNG" ) );
|
||||
const QString &fileFormat = QString( "PNG" ),
|
||||
const bool forceRaster = false );
|
||||
%Docstring
|
||||
Constructor for QgsMapRendererTask to render a map to an image file.
|
||||
%End
|
||||
@ -39,7 +40,7 @@ class QgsMapRendererTask : QgsTask
|
||||
QgsMapRendererTask( const QgsMapSettings &ms,
|
||||
QPainter *p );
|
||||
%Docstring
|
||||
Constructor for QgsMapRendererTask to render a map to a painter object.
|
||||
Constructor for QgsMapRendererTask to render a map to a QPainter object.
|
||||
%End
|
||||
|
||||
void addAnnotations( QList< QgsAnnotation * > annotations );
|
||||
|
@ -136,15 +136,6 @@ class QgsPalLayerSettings
|
||||
PolygonWhole
|
||||
};
|
||||
|
||||
|
||||
enum SizeUnit
|
||||
{
|
||||
Points,
|
||||
MM,
|
||||
MapUnits,
|
||||
Percent
|
||||
};
|
||||
|
||||
enum Property
|
||||
{
|
||||
// text
|
||||
@ -282,15 +273,21 @@ class QgsPalLayerSettings
|
||||
|
||||
|
||||
QString fieldName;
|
||||
%Docstring
|
||||
Name of field (or an expression) to use for label text.
|
||||
If fieldName is an expression, then isExpression should be set to true.
|
||||
.. seealso:: isExpression
|
||||
%End
|
||||
|
||||
bool isExpression;
|
||||
%Docstring
|
||||
Is this label made from a expression string, e.g., FieldName || 'mm'
|
||||
True if this label is made from a expression string, e.g., FieldName || 'mm'
|
||||
.. seealso:: fieldName
|
||||
%End
|
||||
|
||||
QgsExpression *getLabelExpression();
|
||||
%Docstring
|
||||
Returns the QgsExpression for this label settings.
|
||||
Returns the QgsExpression for this label settings. May be None if isExpression is false.
|
||||
:rtype: QgsExpression
|
||||
%End
|
||||
|
||||
@ -307,70 +304,228 @@ True if substitutions should be applied
|
||||
|
||||
|
||||
QString wrapChar;
|
||||
MultiLineAlign multilineAlign; // horizontal alignment of multi-line labels
|
||||
%Docstring
|
||||
Wrapping character string. If set, any occurrences of this string in the calculated
|
||||
label text will be replaced with new line characters.
|
||||
%End
|
||||
|
||||
MultiLineAlign multilineAlign;
|
||||
%Docstring
|
||||
Horizontal alignment of multi-line labels.
|
||||
%End
|
||||
|
||||
bool addDirectionSymbol;
|
||||
%Docstring
|
||||
If true, '<' or '>' (or custom strings set via leftDirectionSymbol and rightDirectionSymbol)
|
||||
will be automatically added to the label text, pointing in the
|
||||
direction of the line or polygon ring.
|
||||
This setting only affects line or perimeter based labels.
|
||||
.. seealso:: leftDirectionSymbol
|
||||
.. seealso:: rightDirectionSymbol
|
||||
.. seealso:: placeDirectionSymbol
|
||||
.. seealso:: reverseDirectionSymbol
|
||||
%End
|
||||
|
||||
QString leftDirectionSymbol;
|
||||
%Docstring
|
||||
String to use for left direction arrows.
|
||||
.. seealso:: addDirectionSymbol
|
||||
.. seealso:: rightDirectionSymbol
|
||||
%End
|
||||
|
||||
QString rightDirectionSymbol;
|
||||
DirectionSymbols placeDirectionSymbol; // whether to place left/right, above or below label
|
||||
%Docstring
|
||||
String to use for right direction arrows.
|
||||
.. seealso:: addDirectionSymbol
|
||||
.. seealso:: leftDirectionSymbol
|
||||
%End
|
||||
|
||||
DirectionSymbols placeDirectionSymbol;
|
||||
%Docstring
|
||||
Placement option for direction symbols. Controls whether to place symbols to the left/right, above or below label.
|
||||
.. seealso:: addDirectionSymbol
|
||||
%End
|
||||
|
||||
bool reverseDirectionSymbol;
|
||||
%Docstring
|
||||
True if direction symbols should be reversed
|
||||
%End
|
||||
|
||||
bool formatNumbers;
|
||||
%Docstring
|
||||
Set to true to format numeric label text as numbers (e.g. inserting thousand separators
|
||||
and fixed number of decimal places).
|
||||
.. seealso:: decimals
|
||||
.. seealso:: plusSign
|
||||
%End
|
||||
|
||||
int decimals;
|
||||
%Docstring
|
||||
Number of decimal places to show for numeric labels. formatNumbers must be true for this
|
||||
setting to have an effect.
|
||||
.. seealso:: formatNumbers
|
||||
%End
|
||||
|
||||
bool plusSign;
|
||||
%Docstring
|
||||
Whether '+' signs should be prepended to positive numeric labels. formatNumbers must be true for this
|
||||
setting to have an effect.
|
||||
.. seealso:: formatNumbers
|
||||
%End
|
||||
|
||||
|
||||
Placement placement;
|
||||
unsigned int placementFlags;
|
||||
|
||||
bool centroidWhole; // whether centroid calculated from whole or visible polygon
|
||||
bool centroidInside; // whether centroid-point calculated must be inside polygon
|
||||
bool centroidWhole;
|
||||
%Docstring
|
||||
True if feature centroid should be calculated from the whole feature, or
|
||||
false if only the visible part of the feature should be considered.
|
||||
%End
|
||||
|
||||
bool centroidInside;
|
||||
%Docstring
|
||||
True if centroid positioned labels must be placed inside their corresponding
|
||||
feature polygon, or false if centroids which fall outside the polygon
|
||||
are permitted.
|
||||
%End
|
||||
|
||||
|
||||
bool fitInPolygonOnly;
|
||||
%Docstring
|
||||
True if only labels which completely fit within a polygon are allowed.
|
||||
%End
|
||||
double dist; // distance from the feature (in mm)
|
||||
bool distInMapUnits; //true if distance is in map units (otherwise in mm)
|
||||
|
||||
double dist;
|
||||
%Docstring
|
||||
Distance from feature to the label. Units are specified via distUnits.
|
||||
.. seealso:: distUnits
|
||||
.. seealso:: distMapUnitScale
|
||||
%End
|
||||
|
||||
QgsUnitTypes::RenderUnit distUnits;
|
||||
%Docstring
|
||||
Units the distance from feature to the label.
|
||||
.. seealso:: dist
|
||||
.. seealso:: distMapUnitScale
|
||||
%End
|
||||
|
||||
QgsMapUnitScale distMapUnitScale;
|
||||
%Docstring
|
||||
Map unit scale for label feature distance.
|
||||
.. seealso:: dist
|
||||
.. seealso:: distUnits
|
||||
%End
|
||||
|
||||
OffsetType offsetType;
|
||||
%Docstring
|
||||
Offset type for layer (only applies in certain placement modes)
|
||||
%End
|
||||
|
||||
double repeatDistance;
|
||||
SizeUnit repeatDistanceUnit;
|
||||
%Docstring
|
||||
Distance for repeating labels for a single feature.
|
||||
.. seealso:: repeatDistanceUnit
|
||||
.. seealso:: repeatDistanceMapUnitScale
|
||||
%End
|
||||
|
||||
QgsUnitTypes::RenderUnit repeatDistanceUnit;
|
||||
%Docstring
|
||||
Units for repeating labels for a single feature.
|
||||
.. seealso:: repeatDistance
|
||||
.. seealso:: repeatDistanceMapUnitScale
|
||||
%End
|
||||
|
||||
QgsMapUnitScale repeatDistanceMapUnitScale;
|
||||
%Docstring
|
||||
Map unit scale for repeating labels for a single feature.
|
||||
.. seealso:: repeatDistance
|
||||
.. seealso:: repeatDistanceUnit
|
||||
%End
|
||||
|
||||
QuadrantPosition quadOffset;
|
||||
%Docstring
|
||||
Sets the quadrant in which to offset labels from feature.
|
||||
%End
|
||||
|
||||
double xOffset;
|
||||
%Docstring
|
||||
Horizontal offset of label. Units are specified via offsetUnits.
|
||||
.. seealso:: yOffset
|
||||
.. seealso:: offsetUnits
|
||||
.. seealso:: labelOffsetMapUnitScale
|
||||
%End
|
||||
|
||||
double yOffset;
|
||||
%Docstring
|
||||
Vertical offset of label. Units are specified via offsetUnits.
|
||||
.. seealso:: xOffset
|
||||
.. seealso:: offsetUnits
|
||||
.. seealso:: labelOffsetMapUnitScale
|
||||
%End
|
||||
|
||||
QgsUnitTypes::RenderUnit offsetUnits;
|
||||
%Docstring
|
||||
Units for offsets of label.
|
||||
.. seealso:: xOffset
|
||||
.. seealso:: yOffset
|
||||
.. seealso:: labelOffsetMapUnitScale
|
||||
%End
|
||||
|
||||
double xOffset; // offset from point in mm or map units
|
||||
double yOffset; // offset from point in mm or map units
|
||||
bool labelOffsetInMapUnits; //true if label offset is in map units (otherwise in mm)
|
||||
QgsMapUnitScale labelOffsetMapUnitScale;
|
||||
%Docstring
|
||||
Map unit scale for label offset.
|
||||
.. seealso:: xOffset
|
||||
.. seealso:: yOffset
|
||||
.. seealso:: offsetUnits
|
||||
%End
|
||||
|
||||
double angleOffset;
|
||||
%Docstring
|
||||
Label rotation, in degrees clockwise
|
||||
%End
|
||||
|
||||
bool preserveRotation; // preserve predefined rotation data during label pin/unpin operations
|
||||
bool preserveRotation;
|
||||
%Docstring
|
||||
True if label rotation should be preserved during label pin/unpin operations.
|
||||
%End
|
||||
|
||||
double maxCurvedCharAngleIn; // maximum angle between inside curved label characters (defaults to 20.0, range 20.0 to 60.0)
|
||||
double maxCurvedCharAngleOut; // maximum angle between outside curved label characters (defaults to -20.0, range -20.0 to -95.0)
|
||||
double maxCurvedCharAngleIn;
|
||||
%Docstring
|
||||
Maximum angle between inside curved label characters (valid range 20.0 to 60.0).
|
||||
.. seealso:: maxCurvedCharAngleOut
|
||||
%End
|
||||
|
||||
int priority; // 0 = low, 10 = high
|
||||
double maxCurvedCharAngleOut;
|
||||
%Docstring
|
||||
Maximum angle between outside curved label characters (valid range -20.0 to -95.0)
|
||||
.. seealso:: maxCurvedCharAngleIn
|
||||
%End
|
||||
|
||||
int priority;
|
||||
%Docstring
|
||||
Label priority. Valid ranges are from 0 to 10, where 0 = lowest priority
|
||||
and 10 = highest priority.
|
||||
%End
|
||||
|
||||
|
||||
bool scaleVisibility;
|
||||
%Docstring
|
||||
Set to true to limit label visibility to a range of scales.
|
||||
.. seealso:: maximumScale
|
||||
.. seealso:: minimumScale
|
||||
%End
|
||||
|
||||
double maximumScale;
|
||||
%Docstring
|
||||
The maximum map scale (i.e. most "zoomed in" scale) at which the labels will be visible.
|
||||
The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
|
||||
A scale of 0 indicates no maximum scale visibility.
|
||||
|
||||
This setting is only considered if scaleVisibility is true.
|
||||
|
||||
.. seealso:: minimumScale
|
||||
.. seealso:: scaleVisibility
|
||||
%End
|
||||
|
||||
double minimumScale;
|
||||
@ -378,34 +533,94 @@ Label rotation, in degrees clockwise
|
||||
The minimum map scale (i.e. most "zoomed out" scale) at which the labels will be visible.
|
||||
The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
|
||||
A scale of 0 indicates no minimum scale visibility.
|
||||
|
||||
This setting is only considered if scaleVisibility is true.
|
||||
|
||||
.. seealso:: maximumScale
|
||||
.. seealso:: scaleVisibility
|
||||
%End
|
||||
|
||||
bool fontLimitPixelSize; // true is label should be limited by fontMinPixelSize/fontMaxPixelSize
|
||||
int fontMinPixelSize; // minimum pixel size for showing rendered map unit labels (1 - 1000)
|
||||
int fontMaxPixelSize; // maximum pixel size for showing rendered map unit labels (1 - 10000)
|
||||
bool fontLimitPixelSize;
|
||||
%Docstring
|
||||
True if label sizes should be limited by pixel size.
|
||||
.. seealso:: fontMinPixelSize
|
||||
.. seealso:: fontMaxPixelSize
|
||||
%End
|
||||
|
||||
bool displayAll; // if true, all features will be labelled even though overlaps occur
|
||||
UpsideDownLabels upsidedownLabels; // whether, or how, to show upsidedown labels
|
||||
int fontMinPixelSize;
|
||||
%Docstring
|
||||
Minimum pixel size for showing rendered map unit labels (1 - 1000).
|
||||
.. seealso:: fontLimitPixelSize
|
||||
.. seealso:: fontMaxPixelSize
|
||||
%End
|
||||
|
||||
int fontMaxPixelSize;
|
||||
%Docstring
|
||||
Maximum pixel size for showing rendered map unit labels (1 - 10000).
|
||||
.. seealso:: fontLimitPixelSize
|
||||
.. seealso:: fontMinPixelSize
|
||||
%End
|
||||
|
||||
bool displayAll;
|
||||
%Docstring
|
||||
If true, all features will be labelled even when overlaps occur.
|
||||
%End
|
||||
|
||||
UpsideDownLabels upsidedownLabels;
|
||||
%Docstring
|
||||
Controls whether upside down labels are displayed and how they are handled.
|
||||
%End
|
||||
|
||||
bool labelPerPart;
|
||||
%Docstring
|
||||
True if every part of a multi-part feature should be labeled. If false,
|
||||
only the largest part will be labeled.
|
||||
%End
|
||||
|
||||
bool labelPerPart; // whether to label every feature's part or only the biggest one
|
||||
bool mergeLines;
|
||||
%Docstring
|
||||
True if connected line features with identical label text should be merged
|
||||
prior to generating label positions.
|
||||
%End
|
||||
|
||||
bool limitNumLabels; // whether to limit the number of labels to be drawn
|
||||
int maxNumLabels; // maximum number of labels to be drawn
|
||||
bool limitNumLabels;
|
||||
%Docstring
|
||||
True if the number of labels drawn should be limited.
|
||||
.. seealso:: maxNumLabels
|
||||
%End
|
||||
|
||||
double minFeatureSize; // minimum feature size to be labelled (in mm)
|
||||
bool obstacle; // whether features for layer are obstacles to labels of other layers
|
||||
int maxNumLabels;
|
||||
%Docstring
|
||||
The maximum number of labels which should be drawn for this layer.
|
||||
This only has an effect if limitNumLabels is true.
|
||||
.. seealso:: limitNumLabels
|
||||
%End
|
||||
|
||||
double minFeatureSize;
|
||||
%Docstring
|
||||
Minimum feature size (in millimeters) for a feature to be labelled.
|
||||
%End
|
||||
|
||||
bool obstacle;
|
||||
%Docstring
|
||||
True if features for layer are obstacles to labels of other layers.
|
||||
.. seealso:: obstacleFactor
|
||||
.. seealso:: obstacleType
|
||||
%End
|
||||
|
||||
double obstacleFactor;
|
||||
%Docstring
|
||||
Obstacle factor, where 1.0 = default, < 1.0 more likely to be covered by labels,
|
||||
> 1.0 less likely to be covered
|
||||
.. seealso:: obstacle
|
||||
.. seealso:: obstacleType
|
||||
%End
|
||||
|
||||
ObstacleType obstacleType;
|
||||
%Docstring
|
||||
Controls how features act as obstacles for labels
|
||||
Controls how features act as obstacles for labels.
|
||||
.. seealso:: obstacle
|
||||
.. seealso:: obstacleFactor
|
||||
%End
|
||||
|
||||
double zIndex;
|
||||
|
@ -396,6 +396,7 @@ class QgsUnitTypes
|
||||
\param unit unit to encode
|
||||
:return: encoded string
|
||||
.. seealso:: decodeLayoutUnit()
|
||||
.. versionadded:: 3.0
|
||||
:rtype: str
|
||||
%End
|
||||
|
||||
@ -406,15 +407,34 @@ class QgsUnitTypes
|
||||
\param ok optional boolean, will be set to true if string was converted successfully
|
||||
:return: decoded units
|
||||
.. seealso:: encodeUnit()
|
||||
.. versionadded:: 3.0
|
||||
:rtype: LayoutUnit
|
||||
%End
|
||||
|
||||
static LayoutUnitType unitType( const LayoutUnit units );
|
||||
%Docstring
|
||||
Returns the type for a unit of measurement.
|
||||
|
||||
.. versionadded:: 3.0
|
||||
:rtype: LayoutUnitType
|
||||
%End
|
||||
|
||||
static QString toAbbreviatedString( LayoutUnit unit );
|
||||
%Docstring
|
||||
Returns a translated abbreviation representing a layout ``unit`` (e.g. "mm").
|
||||
|
||||
.. versionadded:: 3.0
|
||||
:rtype: str
|
||||
%End
|
||||
|
||||
static QString toString( LayoutUnit unit );
|
||||
%Docstring
|
||||
Returns a translated string representing a layout ``unit``.
|
||||
|
||||
.. versionadded:: 3.0
|
||||
:rtype: str
|
||||
%End
|
||||
|
||||
};
|
||||
|
||||
/************************************************************************
|
||||
|
89
python/core/qgsuserprofile.sip
Normal file
89
python/core/qgsuserprofile.sip
Normal file
@ -0,0 +1,89 @@
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/core/qgsuserprofile.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
||||
|
||||
|
||||
|
||||
class QgsUserProfile
|
||||
{
|
||||
%Docstring
|
||||
User profile contains information about the user profile folders on the machine.
|
||||
In QGIS 3 all settings, plugins, etc were moved into a %APPDATA%/profiles folder for each platform.
|
||||
This allows for manage different user profiles per machine vs the single default one that was allowed in the
|
||||
past.
|
||||
|
||||
A user profile is all settings and anything that used to be found in .qgis3 in the users home folder.
|
||||
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgsuserprofile.h"
|
||||
%End
|
||||
public:
|
||||
|
||||
QgsUserProfile( const QString &folder );
|
||||
%Docstring
|
||||
Reference to a existing user profile folder.
|
||||
Profile folder should be created using QgsProfileManager.
|
||||
\param folder An existing profile folder as the base of the user profile.
|
||||
%End
|
||||
|
||||
const QString folder() const;
|
||||
%Docstring
|
||||
The base folder for the user profile.
|
||||
:rtype: str
|
||||
%End
|
||||
|
||||
QgsError validate() const;
|
||||
%Docstring
|
||||
Check of the profile is in a valid state.
|
||||
:rtype: QgsError
|
||||
%End
|
||||
|
||||
const QString name() const;
|
||||
%Docstring
|
||||
The name for the user profile.
|
||||
:rtype: str
|
||||
%End
|
||||
|
||||
void initSettings() const;
|
||||
%Docstring
|
||||
Init the settings from the user folder.
|
||||
%End
|
||||
|
||||
const QString alias() const;
|
||||
%Docstring
|
||||
Return the alias for the user profile.
|
||||
:return: If no alias is set name() is returned.
|
||||
:rtype: str
|
||||
%End
|
||||
|
||||
QgsError setAlias( const QString &alias );
|
||||
%Docstring
|
||||
Set the alias of the profile. The alias is a user friendly name.
|
||||
\param alias A user friendly name for the profile.
|
||||
:return: True of setting the alias was successful.
|
||||
:rtype: QgsError
|
||||
%End
|
||||
|
||||
const QIcon icon() const;
|
||||
%Docstring
|
||||
The icon for the user profile.
|
||||
:return: A QIcon for the users
|
||||
:rtype: QIcon
|
||||
%End
|
||||
|
||||
};
|
||||
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/core/qgsuserprofile.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
185
python/core/qgsuserprofilemanager.sip
Normal file
185
python/core/qgsuserprofilemanager.sip
Normal file
@ -0,0 +1,185 @@
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/core/qgsuserprofilemanager.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class QgsUserProfileManager : QObject
|
||||
{
|
||||
%Docstring
|
||||
User profile manager is used to manager list, and manage user profiles on the users machine.
|
||||
|
||||
In QGIS 3 all settings, plugins, etc were moved into a %APPDATA%/profiles folder for each platform.
|
||||
This allows for manage different user profiles per machine vs the single default one that was allowed in the
|
||||
past.
|
||||
|
||||
A user profile is all settings and anything that used to be found in .qgis3 in the users home folder.
|
||||
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgsuserprofilemanager.h"
|
||||
%End
|
||||
public:
|
||||
|
||||
QgsUserProfileManager( const QString &rootLocation = QString(), QObject *parent = 0 );
|
||||
%Docstring
|
||||
User profile manager used to manage user profiles for the instance of QGIS.
|
||||
%End
|
||||
|
||||
static QString resolveProfilesFolder( const QString &basePath = QString() );
|
||||
%Docstring
|
||||
Resolves the profiles folder for the given path. Path will have \\profiles appended to the path
|
||||
\param basePath The base path to resolve the path from to append the \\profiles folder to.
|
||||
:return: The root path to store user profiles.
|
||||
:rtype: str
|
||||
%End
|
||||
|
||||
QgsUserProfile *getProfile( const QString &defaultProfile = "default", bool createNew = true, bool initSettings = true ) /Factory/;
|
||||
%Docstring
|
||||
Return the profile from the given root profile location.
|
||||
If no name is given it returns a profile called "default".
|
||||
By default will create the profile folder if not found.
|
||||
By default will init the user settings.
|
||||
.. note::
|
||||
|
||||
Returns a new QgsUserProfile. Ownership transferred to caller.
|
||||
\param defaultProfile The profile name to find. Empty profile name will return "default" for the name.
|
||||
\param createNew Create the profile folder if it doesn't exist.
|
||||
\param initSettings if the settings should be initialized
|
||||
:return: The user profile
|
||||
:rtype: QgsUserProfile
|
||||
%End
|
||||
|
||||
void setRootLocation( QString rootProfileLocation );
|
||||
%Docstring
|
||||
Set the root profile location for the profile manager. All profiles are loaded from this
|
||||
location. Will also contain a profiles.ini for holding profile settings.
|
||||
\param rootProfileLocation Path to the top level profile folder which contains folders for each profile.
|
||||
%End
|
||||
|
||||
QString rootLocation();
|
||||
%Docstring
|
||||
Returns the path to the root profiles location.
|
||||
:return: The root path to the profiles folder.
|
||||
:rtype: str
|
||||
%End
|
||||
|
||||
bool rootLocationIsSet() const;
|
||||
%Docstring
|
||||
Check if the root location has been set for the manager.
|
||||
:return: True if the root location has been set.
|
||||
:rtype: bool
|
||||
%End
|
||||
|
||||
QStringList allProfiles() const;
|
||||
%Docstring
|
||||
A list of all found profile names.
|
||||
:return:
|
||||
:rtype: list of str
|
||||
%End
|
||||
|
||||
bool profileExists( const QString &name ) const;
|
||||
%Docstring
|
||||
Check if a profile exists.
|
||||
:return: False if the profile can't be found.
|
||||
:rtype: bool
|
||||
%End
|
||||
|
||||
QString defaultProfileName() const;
|
||||
%Docstring
|
||||
Returns the name of the default profile that has been set in .default.
|
||||
First checks profile.ini in \\profiles folder
|
||||
Then checks defaultProfile in global settings
|
||||
Finally returns "default" if all else fails
|
||||
.. note::
|
||||
|
||||
Setting overrideLocalProfile in global settings will always ignore profiles.ini
|
||||
:return: The name of the default profile.
|
||||
:rtype: str
|
||||
%End
|
||||
|
||||
void setDefaultProfileName( const QString &name );
|
||||
%Docstring
|
||||
Sets the default profile name. The default profile name is used when loading QGIS
|
||||
with no arguments.
|
||||
\param name The name of the profile to save.
|
||||
%End
|
||||
|
||||
void setDefaultFromActive();
|
||||
%Docstring
|
||||
Set the default profile name from the current active profile.
|
||||
%End
|
||||
|
||||
QgsUserProfile *profileForName( const QString name ) const;
|
||||
%Docstring
|
||||
Return the profile found for a given name.
|
||||
\param name The name of the profile to return.
|
||||
:return: A QgsUserprofile pointing to the location of the user profile.
|
||||
:rtype: QgsUserProfile
|
||||
%End
|
||||
|
||||
QgsError createUserProfile( const QString &name );
|
||||
%Docstring
|
||||
Create a user profile given by the name
|
||||
\param name
|
||||
:return: A QgsError which report if there was any error creating the user profile.
|
||||
:rtype: QgsError
|
||||
%End
|
||||
|
||||
QgsError deleteProfile( const QString name );
|
||||
%Docstring
|
||||
Deletes a profile from the root profiles folder.
|
||||
.. note::
|
||||
|
||||
There is no undo on this as it deletes the folder from the machine.
|
||||
\param name The name of the profile to delete.
|
||||
:return: A QgsError with a message if the profile failed to be deleted.
|
||||
:rtype: QgsError
|
||||
%End
|
||||
|
||||
QgsUserProfile *userProfile();
|
||||
%Docstring
|
||||
The currently active user profile.
|
||||
:return: The currently active user profile.
|
||||
:rtype: QgsUserProfile
|
||||
%End
|
||||
|
||||
void setActiveUserProfile( const QString &profile );
|
||||
%Docstring
|
||||
Sets the active profile in the manager.
|
||||
This can only be set once.
|
||||
Setting this again does nothing.
|
||||
|
||||
\param profile The name of the active profile
|
||||
%End
|
||||
|
||||
void loadUserProfile( const QString &name );
|
||||
%Docstring
|
||||
Starts a new instance of QGIS for the given profile.
|
||||
\param name The profile to start QGIS with.
|
||||
%End
|
||||
|
||||
signals:
|
||||
|
||||
void profilesChanged( );
|
||||
%Docstring
|
||||
Emitted when the list of profiles is changed.
|
||||
%End
|
||||
|
||||
};
|
||||
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/core/qgsuserprofilemanager.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
@ -76,6 +76,11 @@ Try to create instance of an implementation based on the XML data
|
||||
:rtype: QgsAbstractVectorLayerLabeling
|
||||
%End
|
||||
|
||||
virtual void toSld( QDomNode &parent, const QgsStringMap &props ) const;
|
||||
%Docstring
|
||||
Writes the SE 1.1 TextSymbolizer element based on the current layer labeling settings
|
||||
%End
|
||||
|
||||
private:
|
||||
QgsAbstractVectorLayerLabeling( const QgsAbstractVectorLayerLabeling &rhs );
|
||||
};
|
||||
@ -105,6 +110,7 @@ Constructs simple labeling configuration with given initial settings
|
||||
virtual QgsPalLayerSettings settings( const QString &providerId = QString() ) const;
|
||||
virtual bool requiresAdvancedEffects() const;
|
||||
|
||||
virtual void toSld( QDomNode &parent, const QgsStringMap &props ) const;
|
||||
|
||||
static QgsVectorLayerSimpleLabeling *create( const QDomElement &element, const QgsReadWriteContext &context );
|
||||
%Docstring
|
||||
|
@ -29,34 +29,36 @@ class QgsPointDistanceRenderer: QgsFeatureRenderer
|
||||
struct GroupedFeature
|
||||
{
|
||||
|
||||
GroupedFeature( const QgsFeature &feature, QgsMarkerSymbol *symbol, bool isSelected, const QString &label = QString() );
|
||||
GroupedFeature( const QgsFeature &feature, QgsMarkerSymbol *symbol /Transfer/, bool isSelected, const QString &label = QString() );
|
||||
%Docstring
|
||||
Constructor for GroupedFeature.
|
||||
\param feature feature
|
||||
\param symbol base symbol for rendering feature
|
||||
\param symbol base symbol for rendering feature (owned by GroupedFeature)
|
||||
\param isSelected set to true if feature is selected and should be rendered in a selected state
|
||||
\param label optional label text, or empty string for no label
|
||||
%End
|
||||
|
||||
QgsFeature feature;
|
||||
QgsFeature feature;
|
||||
%Docstring
|
||||
Feature
|
||||
%End
|
||||
|
||||
QgsMarkerSymbol *symbol;
|
||||
QgsMarkerSymbol *symbol() const;
|
||||
%Docstring
|
||||
Base symbol for rendering feature
|
||||
:rtype: QgsMarkerSymbol
|
||||
%End
|
||||
|
||||
bool isSelected;
|
||||
bool isSelected;
|
||||
%Docstring
|
||||
True if feature is selected and should be rendered in a selected state
|
||||
%End
|
||||
|
||||
QString label;
|
||||
QString label;
|
||||
%Docstring
|
||||
Optional label text
|
||||
%End
|
||||
|
||||
};
|
||||
|
||||
typedef QList< QgsPointDistanceRenderer::GroupedFeature > ClusteredGroup;
|
||||
|
@ -88,7 +88,7 @@ return new default symbol for specified geometry type
|
||||
:rtype: QgsSymbolLayer
|
||||
%End
|
||||
|
||||
int symbolLayerCount();
|
||||
int symbolLayerCount() const;
|
||||
%Docstring
|
||||
Returns total number of symbol layers contained in the symbol.
|
||||
:return: count of symbol layers
|
||||
|
@ -231,8 +231,10 @@ class QgsSymbolLayer
|
||||
|
||||
virtual QgsSymbol *subSymbol();
|
||||
%Docstring
|
||||
Returns the symbol's sub symbol, if present.
|
||||
:rtype: QgsSymbol
|
||||
%End
|
||||
|
||||
virtual bool setSubSymbol( QgsSymbol *symbol /Transfer/ );
|
||||
%Docstring
|
||||
set layer's subsymbol. takes ownership of the passed symbol
|
||||
|
@ -52,7 +52,7 @@ Create a symbol layer of this type given the map of properties.
|
||||
Create widget for symbol layer of this type. Can return NULL if there's no GUI
|
||||
:rtype: QgsSymbolLayerWidget
|
||||
%End
|
||||
virtual QgsSymbolLayer *createSymbolLayerFromSld( QDomElement & );
|
||||
virtual QgsSymbolLayer *createSymbolLayerFromSld( QDomElement & ) /Factory/;
|
||||
%Docstring
|
||||
Create a symbol layer of this type given the map of properties.
|
||||
:rtype: QgsSymbolLayer
|
||||
@ -85,9 +85,9 @@ Convenience metadata class that uses static functions to create symbol layer and
|
||||
|
||||
|
||||
|
||||
virtual QgsSymbolLayer *createSymbolLayer( const QgsStringMap &map );
|
||||
virtual QgsSymbolLayerWidget *createSymbolLayerWidget( const QgsVectorLayer *vl );
|
||||
virtual QgsSymbolLayer *createSymbolLayerFromSld( QDomElement &elem );
|
||||
virtual QgsSymbolLayer *createSymbolLayer( const QgsStringMap &map ) /Factory/;
|
||||
virtual QgsSymbolLayerWidget *createSymbolLayerWidget( const QgsVectorLayer *vl ) /Factory/;
|
||||
virtual QgsSymbolLayer *createSymbolLayerFromSld( QDomElement &elem ) /Factory/;
|
||||
virtual void resolvePaths( QgsStringMap &properties, const QgsPathResolver &pathResolver, bool saving );
|
||||
|
||||
protected:
|
||||
@ -133,7 +133,7 @@ create a new instance of symbol layer given symbol layer name and properties
|
||||
:rtype: QgsSymbolLayer
|
||||
%End
|
||||
|
||||
QgsSymbolLayer *createSymbolLayerFromSld( const QString &name, QDomElement &element ) const;
|
||||
QgsSymbolLayer *createSymbolLayerFromSld( const QString &name, QDomElement &element ) const /Factory/;
|
||||
%Docstring
|
||||
create a new instance of symbol layer given symbol layer name and SLD
|
||||
:rtype: QgsSymbolLayer
|
||||
|
@ -337,15 +337,15 @@ Writes a symbol definition to XML
|
||||
:rtype: bool
|
||||
%End
|
||||
|
||||
static QgsSymbolLayer *createFillLayerFromSld( QDomElement &element );
|
||||
static QgsSymbolLayer *createFillLayerFromSld( QDomElement &element ) /Factory/;
|
||||
%Docstring
|
||||
:rtype: QgsSymbolLayer
|
||||
%End
|
||||
static QgsSymbolLayer *createLineLayerFromSld( QDomElement &element );
|
||||
static QgsSymbolLayer *createLineLayerFromSld( QDomElement &element ) /Factory/;
|
||||
%Docstring
|
||||
:rtype: QgsSymbolLayer
|
||||
%End
|
||||
static QgsSymbolLayer *createMarkerLayerFromSld( QDomElement &element );
|
||||
static QgsSymbolLayer *createMarkerLayerFromSld( QDomElement &element ) /Factory/;
|
||||
%Docstring
|
||||
:rtype: QgsSymbolLayer
|
||||
%End
|
||||
@ -481,6 +481,14 @@ Create ogr feature style string for pen
|
||||
:rtype: bool
|
||||
%End
|
||||
|
||||
static void createAnchorPointElement( QDomDocument &doc, QDomElement &element, QPointF anchor );
|
||||
%Docstring
|
||||
Creates a SE 1.1 anchor point element as a child of the specified element
|
||||
\param doc The document
|
||||
\param element The parent element
|
||||
\param anchor An anchor specification, with values between 0 and 1
|
||||
%End
|
||||
|
||||
static void createOnlineResourceElement( QDomDocument &doc, QDomElement &element, const QString &path, const QString &format );
|
||||
static bool onlineResourceFromSldElement( QDomElement &element, QString &path, QString &format );
|
||||
%Docstring
|
||||
@ -548,6 +556,25 @@ Writes a collection of symbols to XML with specified tagName for the top-level e
|
||||
|
||||
static void clearSymbolMap( QgsSymbolMap &symbols );
|
||||
|
||||
static QMimeData *symbolToMimeData( QgsSymbol *symbol ) /Factory/;
|
||||
%Docstring
|
||||
Creates new mime data from a ``symbol``.
|
||||
This also sets the mime color data to match the symbol's color, so that copied symbols
|
||||
can be paste in places where a color is expected.
|
||||
.. seealso:: symbolFromMimeData()
|
||||
.. versionadded:: 3.0
|
||||
:rtype: QMimeData
|
||||
%End
|
||||
|
||||
static QgsSymbol *symbolFromMimeData( const QMimeData *data ) /Factory/;
|
||||
%Docstring
|
||||
Attempts to parse ``mime`` data as a symbol. A new symbol instance will be returned
|
||||
if the data was successfully converted to a symbol.
|
||||
.. seealso:: symbolToMimeData()
|
||||
.. versionadded:: 3.0
|
||||
:rtype: QgsSymbol
|
||||
%End
|
||||
|
||||
static QgsColorRamp *loadColorRamp( QDomElement &element ) /Factory/;
|
||||
%Docstring
|
||||
Creates a color ramp from the settings encoded in an XML element
|
||||
@ -577,7 +604,7 @@ Writes a collection of symbols to XML with specified tagName for the top-level e
|
||||
:rtype: QVariant
|
||||
%End
|
||||
|
||||
static QgsColorRamp *loadColorRamp( const QVariant &value );
|
||||
static QgsColorRamp *loadColorRamp( const QVariant &value ) /Factory/;
|
||||
%Docstring
|
||||
Load a color ramp from a QVariantMap, wrapped in a QVariant.
|
||||
You can use QgsXmlUtils.readVariant to load it from an XML document.
|
||||
@ -605,7 +632,7 @@ Writes a collection of symbols to XML with specified tagName for the top-level e
|
||||
:rtype: list of QColor
|
||||
%End
|
||||
|
||||
static QMimeData *colorToMimeData( const QColor &color );
|
||||
static QMimeData *colorToMimeData( const QColor &color ) /Factory/;
|
||||
%Docstring
|
||||
Creates mime data from a color. Sets both the mime data's color data, and the
|
||||
mime data's text with the color's hex code.
|
||||
@ -636,7 +663,7 @@ Writes a collection of symbols to XML with specified tagName for the top-level e
|
||||
:rtype: QgsNamedColorList
|
||||
%End
|
||||
|
||||
static QMimeData *colorListToMimeData( const QgsNamedColorList &colorList, const bool allFormats = true );
|
||||
static QMimeData *colorListToMimeData( const QgsNamedColorList &colorList, const bool allFormats = true ) /Factory/;
|
||||
%Docstring
|
||||
Creates mime data from a list of named colors
|
||||
\param colorList list of named colors
|
||||
|
@ -50,6 +50,8 @@ pluginType = MODULE
|
||||
def moduleInformation():
|
||||
try:
|
||||
import qgis.gui
|
||||
return "qgis.gui", dir(qgis.gui)
|
||||
widget_list = dir(qgis.gui)
|
||||
widget_list.remove('QgsScrollArea')
|
||||
return "qgis.gui", widget_list
|
||||
except ImportError:
|
||||
return "", []
|
||||
|
@ -104,7 +104,6 @@ class QgsEditorWidgetWrapper : QgsWidgetWrapper
|
||||
%End
|
||||
|
||||
virtual void setEnabled( bool enabled );
|
||||
|
||||
%Docstring
|
||||
Is used to enable or disable the edit functionality of the managed widget.
|
||||
By default this will enable or disable the whole widget
|
||||
@ -125,6 +124,18 @@ class QgsEditorWidgetWrapper : QgsWidgetWrapper
|
||||
\param constraintOrigin optional origin for constraints to check. This can be used to limit the constraints tested
|
||||
to only provider or layer based constraints.
|
||||
.. versionadded:: 2.16
|
||||
%End
|
||||
|
||||
void updateConstraint( const QgsVectorLayer *layer, int index, const QgsFeature &feature, QgsFieldConstraints::ConstraintOrigin constraintOrigin = QgsFieldConstraints::ConstraintOriginNotSet );
|
||||
%Docstring
|
||||
Update constraint on a feature coming from a specific layer.
|
||||
\param layer The vector layer where the feature is defined
|
||||
\param index The index of the field to check
|
||||
\param feature The feature to use to evaluate the constraint
|
||||
\param constraintOrigin Optional origin for constraints to check. This
|
||||
can be used to limit the constraints tested to only provider or layer
|
||||
based constraints.
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
bool isValidConstraint() const;
|
||||
|
@ -21,6 +21,7 @@
|
||||
%Include qgsbrowserdockwidget.sip
|
||||
%Include qgsvertexmarker.sip
|
||||
%Include qgsfiledownloader.sip
|
||||
%Include qgsabstractdatasourcewidget.sip
|
||||
%Include attributetable/qgsfeaturemodel.sip
|
||||
%Include auth/qgsauthauthoritieseditor.sip
|
||||
%Include auth/qgsauthcertificateinfo.sip
|
||||
@ -123,6 +124,7 @@
|
||||
%Include qgslistwidget.sip
|
||||
%Include qgslegendfilterbutton.sip
|
||||
%Include qgslimitedrandomcolorrampdialog.sip
|
||||
%Include qgsratiolockbutton.sip
|
||||
%Include qgslonglongvalidator.sip
|
||||
%Include qgsludialog.sip
|
||||
%Include qgsmanageconnectionsdialog.sip
|
||||
@ -137,6 +139,7 @@
|
||||
%Include qgsmaptoolcapture.sip
|
||||
%Include qgsmaptooledit.sip
|
||||
%Include qgsmaptoolemitpoint.sip
|
||||
%Include qgsmaptoolextent.sip
|
||||
%Include qgsmaptoolidentify.sip
|
||||
%Include qgsmaptoolidentifyfeature.sip
|
||||
%Include qgsmaptoolpan.sip
|
||||
@ -157,7 +160,6 @@
|
||||
%Include qgsoptionswidgetfactory.sip
|
||||
%Include qgsorderbydialog.sip
|
||||
%Include qgsowssourceselect.sip
|
||||
%Include qgssourceselectdialog.sip
|
||||
%Include qgspanelwidget.sip
|
||||
%Include qgspanelwidgetstack.sip
|
||||
%Include qgspasswordlineedit.sip
|
||||
@ -186,6 +188,7 @@
|
||||
%Include qgsstatusbar.sip
|
||||
%Include qgssublayersdialog.sip
|
||||
%Include qgssubstitutionlistwidget.sip
|
||||
%Include qgssymbolbutton.sip
|
||||
%Include qgstablewidgetbase.sip
|
||||
%Include qgstabwidget.sip
|
||||
%Include qgstaskmanagerwidget.sip
|
||||
@ -278,7 +281,10 @@
|
||||
%Include layertree/qgslayertreeviewdefaultactions.sip
|
||||
%Include layout/qgslayoutdesignerinterface.sip
|
||||
%Include layout/qgslayoutitemguiregistry.sip
|
||||
%Include layout/qgslayoutitemwidget.sip
|
||||
%Include layout/qgslayoutnewitempropertiesdialog.sip
|
||||
%Include layout/qgslayoutruler.sip
|
||||
%Include layout/qgslayoutunitscombobox.sip
|
||||
%Include layout/qgslayoutview.sip
|
||||
%Include layout/qgslayoutviewtool.sip
|
||||
%Include layout/qgslayoutviewtooladditem.sip
|
||||
|
@ -28,9 +28,18 @@ class QgsLayoutItemAbstractGuiMetadata
|
||||
%End
|
||||
public:
|
||||
|
||||
QgsLayoutItemAbstractGuiMetadata( int type );
|
||||
enum Flag
|
||||
{
|
||||
FlagNoCreationTools,
|
||||
};
|
||||
typedef QFlags<QgsLayoutItemAbstractGuiMetadata::Flag> Flags;
|
||||
|
||||
|
||||
QgsLayoutItemAbstractGuiMetadata( int type, const QString &groupId = QString(), Flags flags = 0 );
|
||||
%Docstring
|
||||
Constructor for QgsLayoutItemAbstractGuiMetadata with the specified class ``type``.
|
||||
|
||||
An optional ``groupId`` can be set, which allows grouping of related layout item classes. See QgsLayoutItemGuiMetadata for details.
|
||||
%End
|
||||
|
||||
virtual ~QgsLayoutItemAbstractGuiMetadata();
|
||||
@ -41,16 +50,28 @@ class QgsLayoutItemAbstractGuiMetadata
|
||||
:rtype: int
|
||||
%End
|
||||
|
||||
Flags flags() const;
|
||||
%Docstring
|
||||
Returns item flags.
|
||||
:rtype: Flags
|
||||
%End
|
||||
|
||||
QString groupId() const;
|
||||
%Docstring
|
||||
Returns the item group ID, if set.
|
||||
:rtype: str
|
||||
%End
|
||||
|
||||
virtual QIcon creationIcon() const;
|
||||
%Docstring
|
||||
Returns an icon representing creation of the layout item type.
|
||||
:rtype: QIcon
|
||||
%End
|
||||
|
||||
virtual QWidget *createItemWidget() /Factory/;
|
||||
virtual QgsLayoutItemBaseWidget *createItemWidget( QgsLayoutItem *item ) /Factory/;
|
||||
%Docstring
|
||||
Creates a configuration widget for layout items of this type. Can return None if no configuration GUI is required.
|
||||
:rtype: QWidget
|
||||
Creates a configuration widget for an ``item`` of this type. Can return None if no configuration GUI is required.
|
||||
:rtype: QgsLayoutItemBaseWidget
|
||||
%End
|
||||
|
||||
virtual QgsLayoutViewRubberBand *createRubberBand( QgsLayoutView *view ) /Factory/;
|
||||
@ -65,6 +86,48 @@ class QgsLayoutItemAbstractGuiMetadata
|
||||
|
||||
|
||||
|
||||
class QgsLayoutItemGuiGroup
|
||||
{
|
||||
%Docstring
|
||||
Stores GUI metadata about a group of layout item classes.
|
||||
|
||||
QgsLayoutItemGuiGroup stores settings about groups of related layout item classes
|
||||
which should be presented to users grouped together.
|
||||
|
||||
For instance, the various basic shape creation tools would use QgsLayoutItemGuiGroup
|
||||
to display grouped within designer dialogs.
|
||||
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgslayoutitemguiregistry.h"
|
||||
%End
|
||||
public:
|
||||
|
||||
QgsLayoutItemGuiGroup( const QString &id = QString(), const QString &name = QString(), const QIcon &icon = QIcon() );
|
||||
%Docstring
|
||||
Constructor for QgsLayoutItemGuiGroup.
|
||||
%End
|
||||
|
||||
QString id;
|
||||
%Docstring
|
||||
Unique (untranslated) group ID string.
|
||||
%End
|
||||
|
||||
QString name;
|
||||
%Docstring
|
||||
Translated group name.
|
||||
%End
|
||||
|
||||
QIcon icon;
|
||||
%Docstring
|
||||
Icon for group.
|
||||
%End
|
||||
|
||||
};
|
||||
|
||||
|
||||
class QgsLayoutItemGuiRegistry : QObject
|
||||
{
|
||||
%Docstring
|
||||
@ -117,10 +180,29 @@ class QgsLayoutItemGuiRegistry : QObject
|
||||
:rtype: bool
|
||||
%End
|
||||
|
||||
QWidget *createItemWidget( int type ) const /Factory/;
|
||||
bool addItemGroup( const QgsLayoutItemGuiGroup &group );
|
||||
%Docstring
|
||||
Creates a new instance of a layout item configuration widget for the specified item ``type``.
|
||||
:rtype: QWidget
|
||||
Registers a new item group with the registry. This must be done before calling
|
||||
addLayoutItemGuiMetadata() for any item types associated with the group.
|
||||
|
||||
Returns true if group was added, or false if group could not be added (e.g. due to
|
||||
duplicate id value).
|
||||
|
||||
.. seealso:: itemGroup()
|
||||
:rtype: bool
|
||||
%End
|
||||
|
||||
const QgsLayoutItemGuiGroup &itemGroup( const QString &id );
|
||||
%Docstring
|
||||
Returns a reference to the item group with matching ``id``.
|
||||
.. seealso:: addItemGroup()
|
||||
:rtype: QgsLayoutItemGuiGroup
|
||||
%End
|
||||
|
||||
QgsLayoutItemBaseWidget *createItemWidget( QgsLayoutItem *item ) const /Factory/;
|
||||
%Docstring
|
||||
Creates a new instance of a layout item configuration widget for the specified ``item``.
|
||||
:rtype: QgsLayoutItemBaseWidget
|
||||
%End
|
||||
|
||||
|
||||
|
106
python/gui/layout/qgslayoutitemwidget.sip
Normal file
106
python/gui/layout/qgslayoutitemwidget.sip
Normal file
@ -0,0 +1,106 @@
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/gui/layout/qgslayoutitemwidget.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class QgsLayoutConfigObject: QObject
|
||||
{
|
||||
%Docstring
|
||||
|
||||
An object for property widgets for layout items. All layout config type widgets should contain
|
||||
this object.
|
||||
|
||||
If you are creating a new QgsLayoutItem configuration widget, you should instead
|
||||
inherit from QgsLayoutItemBaseWidget (rather then directly working with QgsLayoutConfigObject).
|
||||
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgslayoutitemwidget.h"
|
||||
%End
|
||||
public:
|
||||
|
||||
QgsLayoutConfigObject( QWidget *parent /TransferThis/, QgsLayoutObject *layoutObject );
|
||||
%Docstring
|
||||
Constructor for QgsLayoutConfigObject, linked with the specified ``layoutObject``.
|
||||
%End
|
||||
|
||||
void initializeDataDefinedButton( QgsPropertyOverrideButton *button, QgsLayoutObject::DataDefinedProperty key );
|
||||
%Docstring
|
||||
Registers a data defined ``button``, setting up its initial value, connections and description.
|
||||
The corresponding property ``key`` must be specified.
|
||||
%End
|
||||
|
||||
void updateDataDefinedButton( QgsPropertyOverrideButton *button );
|
||||
%Docstring
|
||||
Updates a data defined button to reflect the item's current properties.
|
||||
%End
|
||||
|
||||
QgsVectorLayer *coverageLayer() const;
|
||||
%Docstring
|
||||
Returns the current layout context coverage layer (if set).
|
||||
:rtype: QgsVectorLayer
|
||||
%End
|
||||
|
||||
|
||||
};
|
||||
|
||||
class QgsLayoutItemBaseWidget: QgsPanelWidget
|
||||
{
|
||||
%Docstring
|
||||
|
||||
A base class for property widgets for layout items. All layout item widgets should inherit from
|
||||
this base class.
|
||||
|
||||
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgslayoutitemwidget.h"
|
||||
%End
|
||||
public:
|
||||
|
||||
QgsLayoutItemBaseWidget( QWidget *parent /TransferThis/, QgsLayoutObject *layoutObject );
|
||||
%Docstring
|
||||
Constructor for QgsLayoutItemBaseWidget, linked with the specified ``layoutObject``.
|
||||
%End
|
||||
|
||||
protected:
|
||||
|
||||
void registerDataDefinedButton( QgsPropertyOverrideButton *button, QgsLayoutObject::DataDefinedProperty property );
|
||||
%Docstring
|
||||
Registers a data defined ``button``, setting up its initial value, connections and description.
|
||||
The corresponding property ``key`` must be specified.
|
||||
%End
|
||||
|
||||
void updateDataDefinedButton( QgsPropertyOverrideButton *button );
|
||||
%Docstring
|
||||
Updates a previously registered data defined button to reflect the item's current properties.
|
||||
%End
|
||||
|
||||
QgsVectorLayer *coverageLayer() const;
|
||||
%Docstring
|
||||
Returns the current layout context coverage layer (if set).
|
||||
:rtype: QgsVectorLayer
|
||||
%End
|
||||
|
||||
|
||||
};
|
||||
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/gui/layout/qgslayoutitemwidget.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
87
python/gui/layout/qgslayoutnewitempropertiesdialog.sip
Normal file
87
python/gui/layout/qgslayoutnewitempropertiesdialog.sip
Normal file
@ -0,0 +1,87 @@
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/gui/layout/qgslayoutnewitempropertiesdialog.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
||||
|
||||
|
||||
|
||||
|
||||
class QgsLayoutItemPropertiesDialog : QDialog
|
||||
{
|
||||
%Docstring
|
||||
A dialog for configuring properties like the size and position of layout items.
|
||||
|
||||
This is usually used only when constructing new layout items, allowing users to precisely
|
||||
enter their sizes and positions.
|
||||
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgslayoutnewitempropertiesdialog.h"
|
||||
%End
|
||||
public:
|
||||
|
||||
QgsLayoutItemPropertiesDialog( QWidget *parent = 0, Qt::WindowFlags flags = 0 );
|
||||
%Docstring
|
||||
Constructor for QgsLayoutNewItemPropertiesDialog.
|
||||
%End
|
||||
|
||||
void setItemPosition( QgsLayoutPoint position );
|
||||
%Docstring
|
||||
Sets the item ``position`` to show in the dialog.
|
||||
.. seealso:: itemPosition()
|
||||
%End
|
||||
|
||||
QgsLayoutPoint itemPosition() const;
|
||||
%Docstring
|
||||
Returns the current item position defined by the dialog.
|
||||
.. seealso:: setItemPosition()
|
||||
:rtype: QgsLayoutPoint
|
||||
%End
|
||||
|
||||
void setItemSize( QgsLayoutSize size );
|
||||
%Docstring
|
||||
Sets the item ``size`` to show in the dialog.
|
||||
.. seealso:: itemSize()
|
||||
%End
|
||||
|
||||
QgsLayoutSize itemSize() const;
|
||||
%Docstring
|
||||
Returns the item size defined by the dialog.
|
||||
.. seealso:: setItemSize()
|
||||
:rtype: QgsLayoutSize
|
||||
%End
|
||||
|
||||
QgsLayoutItem::ReferencePoint referencePoint() const;
|
||||
%Docstring
|
||||
Returns the item reference point defined by the dialog.
|
||||
.. seealso:: setReferencePoint()
|
||||
:rtype: QgsLayoutItem.ReferencePoint
|
||||
%End
|
||||
|
||||
void setReferencePoint( QgsLayoutItem::ReferencePoint point );
|
||||
%Docstring
|
||||
Sets the item reference ``point`` defined to show in the dialog.
|
||||
.. seealso:: referencePoint()
|
||||
%End
|
||||
|
||||
void setLayout( QgsLayout *layout );
|
||||
%Docstring
|
||||
Sets the ``layout`` associated with the dialog. This allows the dialog
|
||||
to retrieve properties from the layout and perform tasks like automatic
|
||||
conversion of units.
|
||||
%End
|
||||
|
||||
};
|
||||
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/gui/layout/qgslayoutnewitempropertiesdialog.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
84
python/gui/layout/qgslayoutunitscombobox.sip
Normal file
84
python/gui/layout/qgslayoutunitscombobox.sip
Normal file
@ -0,0 +1,84 @@
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/gui/layout/qgslayoutunitscombobox.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
||||
|
||||
|
||||
|
||||
class QgsLayoutUnitsComboBox : QComboBox
|
||||
{
|
||||
%Docstring
|
||||
A custom combo box for selecting units for layout settings.
|
||||
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgslayoutunitscombobox.h"
|
||||
%End
|
||||
public:
|
||||
|
||||
QgsLayoutUnitsComboBox( QWidget *parent /TransferThis/ = 0 );
|
||||
%Docstring
|
||||
Constructor for QgsLayoutUnitsComboBox.
|
||||
%End
|
||||
|
||||
QgsUnitTypes::LayoutUnit unit() const;
|
||||
%Docstring
|
||||
Returns the unit currently selected in the combo box.
|
||||
.. seealso:: setUnit()
|
||||
:rtype: QgsUnitTypes.LayoutUnit
|
||||
%End
|
||||
|
||||
void setUnit( QgsUnitTypes::LayoutUnit unit );
|
||||
%Docstring
|
||||
Sets the ``unit`` currently selected in the combo box.
|
||||
.. seealso:: unit()
|
||||
%End
|
||||
|
||||
void linkToWidget( QDoubleSpinBox *widget );
|
||||
%Docstring
|
||||
Registers a spin box ``widget`` as linked with the combo box.
|
||||
|
||||
Registered spin boxes will automatically be upodated whenever the unit is changed. I.e. a
|
||||
spin box with a value of 100 will be set to 1 when the unit is changed from centimeters to meters.
|
||||
|
||||
A measurement converter() must be set in order for the automatic unit conversion to occur.
|
||||
|
||||
.. seealso:: setConverter()
|
||||
%End
|
||||
|
||||
QgsLayoutMeasurementConverter *converter() const;
|
||||
%Docstring
|
||||
Returns the converter used when automatically converting units for linked widgets.
|
||||
.. seealso:: setConverter()
|
||||
:rtype: QgsLayoutMeasurementConverter
|
||||
%End
|
||||
|
||||
void setConverter( QgsLayoutMeasurementConverter *converter );
|
||||
%Docstring
|
||||
Sets a ``converter`` to use when automatically converting units for linked widgets.
|
||||
The ownership of ``converter`` is not transferred, and converter must exist for the
|
||||
life of the combo box.
|
||||
.. seealso:: converter()
|
||||
%End
|
||||
|
||||
signals:
|
||||
|
||||
void changed( QgsUnitTypes::LayoutUnit unit );
|
||||
%Docstring
|
||||
Emitted when the ``unit`` is changed.
|
||||
%End
|
||||
|
||||
};
|
||||
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/gui/layout/qgslayoutunitscombobox.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
@ -90,6 +90,19 @@ class QgsLayoutView: QGraphicsView
|
||||
.. seealso:: setHorizontalRuler()
|
||||
%End
|
||||
|
||||
void setMenuProvider( QgsLayoutViewMenuProvider *provider /Transfer/ );
|
||||
%Docstring
|
||||
Sets a ``provider`` for context menus. Ownership of the provider is transferred to the view.
|
||||
.. seealso:: menuProvider()
|
||||
%End
|
||||
|
||||
QgsLayoutViewMenuProvider *menuProvider() const;
|
||||
%Docstring
|
||||
Returns the provider for context menus. Returned value may be None if no provider is set.
|
||||
.. seealso:: setMenuProvider()
|
||||
:rtype: QgsLayoutViewMenuProvider
|
||||
%End
|
||||
|
||||
public slots:
|
||||
|
||||
void zoomFull();
|
||||
@ -186,7 +199,36 @@ class QgsLayoutView: QGraphicsView
|
||||
|
||||
virtual void resizeEvent( QResizeEvent *event );
|
||||
|
||||
virtual void scrollContentsBy( int dx, int dy );
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
class QgsLayoutViewMenuProvider
|
||||
{
|
||||
%Docstring
|
||||
|
||||
Interface for a QgsLayoutView context menu.
|
||||
|
||||
Implementations of this interface can be made to allow QgsLayoutView
|
||||
instances to provide custom context menus (opened upon right-click).
|
||||
|
||||
.. seealso:: QgsLayoutView
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgslayoutview.h"
|
||||
%End
|
||||
public:
|
||||
virtual ~QgsLayoutViewMenuProvider();
|
||||
|
||||
virtual QMenu *createContextMenu( QWidget *parent /Transfer/, QgsLayout *layout, QPointF layoutPoint ) const = 0 /Factory/;
|
||||
%Docstring
|
||||
Return a newly created menu instance (or null pointer on error)
|
||||
:rtype: QMenu
|
||||
%End
|
||||
};
|
||||
|
||||
/************************************************************************
|
||||
|
@ -179,6 +179,36 @@ class QgsLayoutViewEllipticalRubberBand : QgsLayoutViewRubberBand
|
||||
virtual QRectF finish( QPointF position = QPointF(), Qt::KeyboardModifiers modifiers = 0 );
|
||||
|
||||
|
||||
};
|
||||
|
||||
class QgsLayoutViewTriangleRubberBand : QgsLayoutViewRubberBand
|
||||
{
|
||||
%Docstring
|
||||
QgsLayoutViewTriangleRubberBand is triangular rubber band for use within QgsLayoutView widgets.
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgslayoutviewrubberband.h"
|
||||
%End
|
||||
public:
|
||||
|
||||
QgsLayoutViewTriangleRubberBand( QgsLayoutView *view = 0 );
|
||||
%Docstring
|
||||
Constructor for QgsLayoutViewTriangleRubberBand.
|
||||
%End
|
||||
virtual QgsLayoutViewTriangleRubberBand *create( QgsLayoutView *view ) const /Factory/;
|
||||
|
||||
|
||||
~QgsLayoutViewTriangleRubberBand();
|
||||
|
||||
virtual void start( QPointF position, Qt::KeyboardModifiers modifiers );
|
||||
|
||||
virtual void update( QPointF position, Qt::KeyboardModifiers modifiers );
|
||||
|
||||
virtual QRectF finish( QPointF position = QPointF(), Qt::KeyboardModifiers modifiers = 0 );
|
||||
|
||||
|
||||
};
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
|
109
python/gui/qgsabstractdatasourcewidget.sip
Normal file
109
python/gui/qgsabstractdatasourcewidget.sip
Normal file
@ -0,0 +1,109 @@
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/gui/qgsabstractdatasourcewidget.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class QgsAbstractDataSourceWidget : QDialog
|
||||
{
|
||||
%Docstring
|
||||
Abstract base Data Source Widget to create connections and add layers
|
||||
This class provides common functionality and the interface for all
|
||||
source select dialogs used by data providers to configure data sources
|
||||
and add layers.
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgsabstractdatasourcewidget.h"
|
||||
%End
|
||||
public:
|
||||
|
||||
~QgsAbstractDataSourceWidget();
|
||||
%Docstring
|
||||
Destructor
|
||||
%End
|
||||
|
||||
void setMapCanvas( const QgsMapCanvas *mapCanvas );
|
||||
%Docstring
|
||||
Store a pointer to the map canvas to retrieve extent and CRS
|
||||
Used to select an appropriate CRS and possibly to retrieve data only in the current extent
|
||||
%End
|
||||
|
||||
|
||||
public slots:
|
||||
|
||||
virtual void refresh();
|
||||
%Docstring
|
||||
Triggered when the provider's connections need to be refreshed
|
||||
The default implementation does nothing
|
||||
%End
|
||||
|
||||
signals:
|
||||
|
||||
void connectionsChanged();
|
||||
%Docstring
|
||||
Emitted when the provider's connections have changed
|
||||
This signal is normally forwarded the app and used to refresh browser items
|
||||
%End
|
||||
|
||||
void addDatabaseLayers( const QStringList &paths, const QString &providerKey );
|
||||
%Docstring
|
||||
Emitted when a DB layer has been selected for addition
|
||||
%End
|
||||
|
||||
void addRasterLayer( const QString &rasterLayerPath, const QString &baseName, const QString &providerKey );
|
||||
%Docstring
|
||||
Emitted when a raster layer has been selected for addition
|
||||
%End
|
||||
|
||||
void addVectorLayer( const QString &uri, const QString &layerName );
|
||||
%Docstring
|
||||
Emitted when a vector layer has been selected for addition
|
||||
%End
|
||||
|
||||
void progress( int, int );
|
||||
%Docstring
|
||||
Emitted when a progress dialog is shown by the provider dialog
|
||||
%End
|
||||
|
||||
void progressMessage( QString message );
|
||||
%Docstring
|
||||
Emitted when a progress dialog is shown by the provider dialog
|
||||
%End
|
||||
|
||||
protected:
|
||||
|
||||
QgsAbstractDataSourceWidget( QWidget *parent /TransferThis/ = 0, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None );
|
||||
%Docstring
|
||||
Constructor
|
||||
%End
|
||||
|
||||
QgsProviderRegistry::WidgetMode widgetMode() const;
|
||||
%Docstring
|
||||
Return the widget mode
|
||||
:rtype: QgsProviderRegistry.WidgetMode
|
||||
%End
|
||||
|
||||
const QgsMapCanvas *mapCanvas() const;
|
||||
%Docstring
|
||||
Return the map canvas (can be null)
|
||||
:rtype: QgsMapCanvas
|
||||
%End
|
||||
|
||||
};
|
||||
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/gui/qgsabstractdatasourcewidget.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
@ -173,6 +173,7 @@ class QgsAttributeForm : QWidget
|
||||
|
||||
\param field The field to change
|
||||
\param value The new value
|
||||
\param hintText A hint text for non existent joined features
|
||||
%End
|
||||
|
||||
void setFeature( const QgsFeature &feature );
|
||||
|
@ -105,7 +105,7 @@ Toggle fast scan
|
||||
|
||||
void selectionChanged( const QItemSelection &selected, const QItemSelection &deselected );
|
||||
%Docstring
|
||||
Selection hass changed
|
||||
Selection has changed
|
||||
%End
|
||||
void splitterMoved();
|
||||
%Docstring
|
||||
@ -120,6 +120,10 @@ Emitted when a file needs to be opened
|
||||
void handleDropUriList( const QgsMimeDataUtils::UriList & );
|
||||
%Docstring
|
||||
Emitted when drop uri list needs to be handled
|
||||
%End
|
||||
void connectionsChanged();
|
||||
%Docstring
|
||||
Connections changed in the browser
|
||||
%End
|
||||
|
||||
protected:
|
||||
|
@ -29,7 +29,7 @@ class QgsBrowserTreeView : QTreeView
|
||||
%Docstring
|
||||
Set the browser model
|
||||
%End
|
||||
QgsBrowserModel *browserModel( );
|
||||
QgsBrowserModel *browserModel();
|
||||
%Docstring
|
||||
Return the browser model
|
||||
:rtype: QgsBrowserModel
|
||||
|
@ -10,6 +10,8 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class QgsExtentGroupBox : QgsCollapsibleGroupBox
|
||||
{
|
||||
%Docstring
|
||||
@ -34,6 +36,7 @@ class QgsExtentGroupBox : QgsCollapsibleGroupBox
|
||||
CurrentExtent,
|
||||
UserExtent,
|
||||
ProjectLayerExtent,
|
||||
DrawOnCanvas,
|
||||
};
|
||||
|
||||
explicit QgsExtentGroupBox( QWidget *parent /TransferThis/ = 0 );
|
||||
@ -124,6 +127,13 @@ class QgsExtentGroupBox : QgsCollapsibleGroupBox
|
||||
:rtype: str
|
||||
%End
|
||||
|
||||
void setMapCanvas( QgsMapCanvas *canvas );
|
||||
%Docstring
|
||||
Sets the map canvas to enable dragging of extent on a canvas.
|
||||
\param canvas the map canvas
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
public slots:
|
||||
|
||||
void setOutputExtentFromOriginal();
|
||||
@ -147,6 +157,30 @@ class QgsExtentGroupBox : QgsCollapsibleGroupBox
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
void setOutputExtentFromDrawOnCanvas();
|
||||
%Docstring
|
||||
Sets the output extent by dragging on the canvas.
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
void setRatio( QSize ratio );
|
||||
%Docstring
|
||||
Sets a fixed aspect ratio to be used when dragging extent onto the canvas.
|
||||
To unset a fixed aspect ratio, set the width and height to zero.
|
||||
\param ratio aspect ratio's width and height
|
||||
.. versionadded:: 3.0
|
||||
*
|
||||
%End
|
||||
|
||||
QSize ratio() const;
|
||||
%Docstring
|
||||
Returns the current fixed aspect ratio to be used when dragging extent onto the canvas.
|
||||
If the aspect ratio isn't fixed, the width and height will be set to zero.
|
||||
.. versionadded:: 3.0
|
||||
*
|
||||
:rtype: QSize
|
||||
%End
|
||||
|
||||
signals:
|
||||
|
||||
void extentChanged( const QgsRectangle &r );
|
||||
|
@ -853,6 +853,7 @@ called when panning is in action, reset indicates end of panning
|
||||
|
||||
|
||||
|
||||
|
||||
void updateDatumTransformEntries();
|
||||
%Docstring
|
||||
Make sure the datum transform store is properly populated
|
||||
|
75
python/gui/qgsmaptoolextent.sip
Normal file
75
python/gui/qgsmaptoolextent.sip
Normal file
@ -0,0 +1,75 @@
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/gui/qgsmaptoolextent.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class QgsMapToolExtent : QgsMapTool
|
||||
{
|
||||
%Docstring
|
||||
A map tool that emits an extent from a rectangle drawn onto the map canvas.
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgsmaptoolextent.h"
|
||||
%End
|
||||
public:
|
||||
|
||||
QgsMapToolExtent( QgsMapCanvas *canvas );
|
||||
%Docstring
|
||||
constructor
|
||||
%End
|
||||
|
||||
virtual Flags flags() const;
|
||||
virtual void canvasMoveEvent( QgsMapMouseEvent *e );
|
||||
virtual void canvasPressEvent( QgsMapMouseEvent *e );
|
||||
virtual void canvasReleaseEvent( QgsMapMouseEvent *e );
|
||||
virtual void activate();
|
||||
virtual void deactivate();
|
||||
|
||||
void setRatio( QSize ratio );
|
||||
%Docstring
|
||||
Sets a fixed aspect ratio to be used when dragging extent onto the canvas.
|
||||
To unset a fixed aspect ratio, set the width and height to zero.
|
||||
\param ratio aspect ratio's width and height
|
||||
*
|
||||
%End
|
||||
|
||||
QSize ratio() const;
|
||||
%Docstring
|
||||
Returns the current fixed aspect ratio to be used when dragging extent onto the canvas.
|
||||
If the aspect ratio isn't fixed, the width and height will be set to zero.
|
||||
*
|
||||
:rtype: QSize
|
||||
%End
|
||||
|
||||
QgsRectangle extent() const;
|
||||
%Docstring
|
||||
Returns the current extent drawn onto the canvas.
|
||||
:rtype: QgsRectangle
|
||||
%End
|
||||
|
||||
signals:
|
||||
|
||||
void extentChanged( const QgsRectangle &extent );
|
||||
%Docstring
|
||||
signal emitted on extent change
|
||||
%End
|
||||
|
||||
};
|
||||
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/gui/qgsmaptoolextent.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
@ -41,26 +41,56 @@ make out a widget containing a widget to be displayed on the bar
|
||||
:rtype: QgsMessageBarItem
|
||||
%End
|
||||
|
||||
QString text() const;
|
||||
%Docstring
|
||||
Returns the text for the message.
|
||||
:rtype: str
|
||||
%End
|
||||
|
||||
QgsMessageBarItem *setTitle( const QString &title );
|
||||
%Docstring
|
||||
:rtype: QgsMessageBarItem
|
||||
%End
|
||||
|
||||
QString title() const;
|
||||
%Docstring
|
||||
Returns the title for the message.
|
||||
:rtype: str
|
||||
%End
|
||||
|
||||
QgsMessageBarItem *setLevel( QgsMessageBar::MessageLevel level );
|
||||
%Docstring
|
||||
:rtype: QgsMessageBarItem
|
||||
%End
|
||||
|
||||
QgsMessageBar::MessageLevel level() const;
|
||||
%Docstring
|
||||
Returns the message level for the message.
|
||||
:rtype: QgsMessageBar.MessageLevel
|
||||
%End
|
||||
|
||||
QgsMessageBarItem *setWidget( QWidget *widget );
|
||||
%Docstring
|
||||
:rtype: QgsMessageBarItem
|
||||
%End
|
||||
|
||||
QWidget *widget() const;
|
||||
%Docstring
|
||||
Returns the widget for the message.
|
||||
:rtype: QWidget
|
||||
%End
|
||||
|
||||
QgsMessageBarItem *setIcon( const QIcon &icon );
|
||||
%Docstring
|
||||
:rtype: QgsMessageBarItem
|
||||
%End
|
||||
|
||||
QIcon icon() const;
|
||||
%Docstring
|
||||
Returns the icon for the message.
|
||||
:rtype: QIcon
|
||||
%End
|
||||
|
||||
QgsMessageBarItem *setDuration( int duration );
|
||||
%Docstring
|
||||
:rtype: QgsMessageBarItem
|
||||
@ -72,12 +102,6 @@ returns the duration in second of the message
|
||||
:rtype: int
|
||||
%End
|
||||
|
||||
QgsMessageBar::MessageLevel level();
|
||||
%Docstring
|
||||
returns the level
|
||||
:rtype: QgsMessageBar.MessageLevel
|
||||
%End
|
||||
|
||||
QString getStyleSheet();
|
||||
%Docstring
|
||||
returns the styleSheet
|
||||
|
@ -11,16 +11,16 @@
|
||||
|
||||
|
||||
|
||||
class QgsOWSSourceSelect : QDialog, protected Ui::QgsOWSSourceSelectBase
|
||||
class QgsOWSSourceSelect : QgsAbstractDataSourceWidget, protected Ui::QgsOWSSourceSelectBase
|
||||
{
|
||||
%Docstring
|
||||
Dialog to create connections and add layers from WMS, WFS, WCS etc.
|
||||
Dialog to create connections and add layers WCS etc.
|
||||
|
||||
This dialog allows the user to define and save connection information
|
||||
for WMS servers, etc.
|
||||
|
||||
The user can then connect and add
|
||||
layers from the WMS server to the map canvas.
|
||||
layers from the WCS server to the map canvas.
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
@ -42,6 +42,12 @@ Constructor
|
||||
|
||||
public slots:
|
||||
|
||||
virtual void refresh();
|
||||
|
||||
%Docstring
|
||||
Triggered when the provider's connections need to be refreshed
|
||||
%End
|
||||
|
||||
void on_mNewButton_clicked();
|
||||
%Docstring
|
||||
Opens the create connection dialog to build a new connection
|
||||
@ -106,14 +112,6 @@ Stores the selected datasource whenerver it is changed
|
||||
Add some default wms servers to the list
|
||||
%End
|
||||
|
||||
void on_mDialogButtonBox_helpRequested();
|
||||
|
||||
signals:
|
||||
void addRasterLayer( const QString &rasterLayerPath,
|
||||
const QString &baseName,
|
||||
const QString &providerKey );
|
||||
void connectionsChanged();
|
||||
|
||||
protected:
|
||||
|
||||
virtual QList<QgsOWSSourceSelect::SupportedFormat> providerFormats();
|
||||
@ -200,8 +198,6 @@ Add a few example servers to the list.
|
||||
%End
|
||||
|
||||
|
||||
|
||||
|
||||
virtual void populateLayerList();
|
||||
%Docstring
|
||||
Populate the layer list.
|
||||
@ -255,6 +251,7 @@ Returns currently selected cache load control
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
/************************************************************************
|
||||
|
94
python/gui/qgsratiolockbutton.sip
Normal file
94
python/gui/qgsratiolockbutton.sip
Normal file
@ -0,0 +1,94 @@
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/gui/qgsratiolockbutton.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class QgsRatioLockButton : QToolButton
|
||||
{
|
||||
%Docstring
|
||||
A cross platform button subclass used to represent a locked / unlocked ratio state.
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgsratiolockbutton.h"
|
||||
%End
|
||||
public:
|
||||
|
||||
QgsRatioLockButton( QWidget *parent /TransferThis/ = 0 );
|
||||
%Docstring
|
||||
Construct a new ratio lock button.
|
||||
Use ``parent`` to attach a parent QWidget to the button.
|
||||
%End
|
||||
|
||||
void setLocked( const bool locked );
|
||||
%Docstring
|
||||
Sets whether the button state is locked.
|
||||
\param locked locked state
|
||||
.. seealso:: locked
|
||||
%End
|
||||
|
||||
bool locked() const;
|
||||
%Docstring
|
||||
Returns whether the button state is locked.
|
||||
:return: true if the button state is locked.
|
||||
.. seealso:: setLocked
|
||||
:rtype: bool
|
||||
%End
|
||||
|
||||
void setWidthSpinBox( QDoubleSpinBox *widget );
|
||||
%Docstring
|
||||
Registers a spin box ``widget`` as the linked "width" spin box.
|
||||
|
||||
If both a width and height spin box are linked to the button, they will automatically
|
||||
have their values updates when if the other spin box value is changed. I.e. changing the
|
||||
width spin box will automatically update the height spin box to a value which keeps the
|
||||
same locked ratio.
|
||||
|
||||
.. seealso:: setHeightSpinBox()
|
||||
%End
|
||||
|
||||
void setHeightSpinBox( QDoubleSpinBox *widget );
|
||||
%Docstring
|
||||
Registers a spin box ``widget`` as the linked "height" spin box.
|
||||
|
||||
If both a width and height spin box are linked to the button, they will automatically
|
||||
have their values updates when if the other spin box value is changed. I.e. changing the
|
||||
width spin box will automatically update the height spin box to a value which keeps the
|
||||
same locked ratio.
|
||||
|
||||
.. seealso:: setWidthSpinBox()
|
||||
%End
|
||||
|
||||
signals:
|
||||
|
||||
void lockChanged( const bool locked );
|
||||
%Docstring
|
||||
Emitted whenever the lock state changes.
|
||||
%End
|
||||
|
||||
protected:
|
||||
|
||||
virtual void changeEvent( QEvent *e );
|
||||
|
||||
virtual void showEvent( QShowEvent *e );
|
||||
|
||||
virtual void resizeEvent( QResizeEvent *event );
|
||||
|
||||
|
||||
};
|
||||
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/gui/qgsratiolockbutton.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
@ -70,6 +70,12 @@ class QgsSublayersDialog : QDialog
|
||||
:rtype: bool
|
||||
%End
|
||||
|
||||
int countColumn() const;
|
||||
%Docstring
|
||||
.. versionadded:: 3.0
|
||||
:rtype: int
|
||||
%End
|
||||
|
||||
public slots:
|
||||
void on_buttonBox_helpRequested();
|
||||
int exec();
|
||||
|
188
python/gui/qgssymbolbutton.sip
Normal file
188
python/gui/qgssymbolbutton.sip
Normal file
@ -0,0 +1,188 @@
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/gui/qgssymbolbutton.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
||||
|
||||
|
||||
|
||||
class QgsSymbolButton : QToolButton
|
||||
{
|
||||
%Docstring
|
||||
A button for creating and modifying QgsSymbol settings.
|
||||
|
||||
The button shows a preview icon for the current symbol, and will open a detailed symbol editor dialog (or
|
||||
panel widget) when clicked.
|
||||
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgssymbolbutton.h"
|
||||
%End
|
||||
public:
|
||||
|
||||
QgsSymbolButton( QWidget *parent /TransferThis/ = 0, const QString &dialogTitle = QString() );
|
||||
%Docstring
|
||||
Construct a new symbol button.
|
||||
Use ``dialogTitle`` string to define the title to show in the symbol settings dialog.
|
||||
%End
|
||||
|
||||
virtual QSize minimumSizeHint() const;
|
||||
|
||||
void setSymbolType( QgsSymbol::SymbolType type );
|
||||
%Docstring
|
||||
Sets the symbol ``type`` which the button requires.
|
||||
If the type differs from the current symbol type, the symbol will be reset
|
||||
to a default symbol style of the new type.
|
||||
.. seealso:: symbolType()
|
||||
%End
|
||||
|
||||
QgsSymbol::SymbolType symbolType() const;
|
||||
%Docstring
|
||||
Returns the symbol type which the button requires.
|
||||
.. seealso:: setSymbolType()
|
||||
:rtype: QgsSymbol.SymbolType
|
||||
%End
|
||||
|
||||
void setDialogTitle( const QString &title );
|
||||
%Docstring
|
||||
Sets the ``title`` for the symbol settings dialog window.
|
||||
.. seealso:: dialogTitle()
|
||||
%End
|
||||
|
||||
QString dialogTitle() const;
|
||||
%Docstring
|
||||
Returns the title for the symbol settings dialog window.
|
||||
.. seealso:: setDialogTitle()
|
||||
:rtype: str
|
||||
%End
|
||||
|
||||
QgsSymbol *symbol();
|
||||
%Docstring
|
||||
Returns the current symbol defined by the button.
|
||||
.. seealso:: setSymbol()
|
||||
.. seealso:: changed()
|
||||
:rtype: QgsSymbol
|
||||
%End
|
||||
|
||||
|
||||
QgsMapCanvas *mapCanvas() const;
|
||||
%Docstring
|
||||
Returns the map canvas associated with the widget.
|
||||
.. seealso:: setMapCanvas()
|
||||
:rtype: QgsMapCanvas
|
||||
%End
|
||||
|
||||
void setMapCanvas( QgsMapCanvas *canvas );
|
||||
%Docstring
|
||||
Sets a map ``canvas`` to associate with the widget. This allows the
|
||||
widget to fetch current settings from the map canvas, such as current scale.
|
||||
.. seealso:: mapCanvas()
|
||||
%End
|
||||
|
||||
QgsVectorLayer *layer() const;
|
||||
%Docstring
|
||||
Returns the layer associated with the widget.
|
||||
.. seealso:: setLayer()
|
||||
:rtype: QgsVectorLayer
|
||||
%End
|
||||
|
||||
void setLayer( QgsVectorLayer *layer );
|
||||
%Docstring
|
||||
Sets a ``layer`` to associate with the widget. This allows the
|
||||
widget to setup layer related settings within the symbol settings dialog,
|
||||
such as correctly populating data defined override buttons.
|
||||
.. seealso:: layer()
|
||||
%End
|
||||
|
||||
void registerExpressionContextGenerator( QgsExpressionContextGenerator *generator );
|
||||
%Docstring
|
||||
Register an expression context generator class that will be used to retrieve
|
||||
an expression context for the button when required.
|
||||
%End
|
||||
|
||||
public slots:
|
||||
|
||||
void setSymbol( QgsSymbol *symbol /Transfer/ );
|
||||
%Docstring
|
||||
Sets the ``symbol`` for the button. Ownership of ``symbol`` is transferred to the
|
||||
button.
|
||||
.. seealso:: symbol()
|
||||
.. seealso:: changed()
|
||||
%End
|
||||
|
||||
void setColor( const QColor &color );
|
||||
%Docstring
|
||||
Sets the current ``color`` for the symbol. Will emit a changed() signal if the color is different
|
||||
to the previous symbol color.
|
||||
%End
|
||||
|
||||
void copySymbol();
|
||||
%Docstring
|
||||
Copies the current symbol to the clipboard.
|
||||
.. seealso:: pasteSymbol()
|
||||
%End
|
||||
|
||||
void pasteSymbol();
|
||||
%Docstring
|
||||
Pastes a symbol from the clipboard. If clipboard does not contain a valid
|
||||
symbol then no change is applied.
|
||||
.. seealso:: copySymbol()
|
||||
%End
|
||||
|
||||
void copyColor();
|
||||
%Docstring
|
||||
Copies the current symbol color to the clipboard.
|
||||
.. seealso:: pasteColor()
|
||||
%End
|
||||
|
||||
void pasteColor();
|
||||
%Docstring
|
||||
Pastes a color from the clipboard to the symbol. If clipboard does not contain a valid
|
||||
color or string representation of a color, then no change is applied.
|
||||
.. seealso:: copyColor()
|
||||
%End
|
||||
|
||||
signals:
|
||||
|
||||
void changed();
|
||||
%Docstring
|
||||
Emitted when the symbol's settings are changed.
|
||||
.. seealso:: symbol()
|
||||
.. seealso:: setSymbol()
|
||||
%End
|
||||
|
||||
protected:
|
||||
|
||||
virtual void changeEvent( QEvent *e );
|
||||
|
||||
virtual void showEvent( QShowEvent *e );
|
||||
|
||||
virtual void resizeEvent( QResizeEvent *event );
|
||||
|
||||
|
||||
virtual void mousePressEvent( QMouseEvent *e );
|
||||
|
||||
virtual void mouseMoveEvent( QMouseEvent *e );
|
||||
|
||||
virtual void dragEnterEvent( QDragEnterEvent *e );
|
||||
|
||||
|
||||
virtual void dragLeaveEvent( QDragLeaveEvent *e );
|
||||
|
||||
|
||||
virtual void dropEvent( QDropEvent *e );
|
||||
|
||||
|
||||
};
|
||||
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/gui/qgssymbolbutton.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
@ -11,7 +11,7 @@
|
||||
|
||||
|
||||
|
||||
class QgsPointClusterRendererWidget: QgsRendererWidget
|
||||
class QgsPointClusterRendererWidget: QgsRendererWidget, QgsExpressionContextGenerator
|
||||
{
|
||||
%Docstring
|
||||
A widget which allows configuration of the properties for a QgsPointClusterRenderer.
|
||||
@ -48,6 +48,9 @@ class QgsPointClusterRendererWidget: QgsRendererWidget
|
||||
virtual void setContext( const QgsSymbolWidgetContext &context );
|
||||
|
||||
|
||||
virtual QgsExpressionContext createExpressionContext() const;
|
||||
|
||||
|
||||
};
|
||||
|
||||
/************************************************************************
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
|
||||
|
||||
class QgsPointDisplacementRendererWidget: QgsRendererWidget
|
||||
class QgsPointDisplacementRendererWidget: QgsRendererWidget, QgsExpressionContextGenerator
|
||||
{
|
||||
|
||||
%TypeHeaderCode
|
||||
@ -29,6 +29,9 @@ class QgsPointDisplacementRendererWidget: QgsRendererWidget
|
||||
virtual void setContext( const QgsSymbolWidgetContext &context );
|
||||
|
||||
|
||||
virtual QgsExpressionContext createExpressionContext() const;
|
||||
|
||||
|
||||
};
|
||||
|
||||
/************************************************************************
|
||||
|
@ -24,18 +24,20 @@ class QgsSvgSelectorListModel : QAbstractListModel
|
||||
%End
|
||||
public:
|
||||
|
||||
QgsSvgSelectorListModel( QObject *parent /TransferThis/ );
|
||||
QgsSvgSelectorListModel( QObject *parent /TransferThis/, int iconSize = 30 );
|
||||
%Docstring
|
||||
Constructor for QgsSvgSelectorListModel. All SVGs in folders from the application SVG
|
||||
search paths will be shown.
|
||||
\param parent parent object
|
||||
\param iconSize desired size of SVG icons to create
|
||||
%End
|
||||
|
||||
QgsSvgSelectorListModel( QObject *parent /TransferThis/, const QString &path );
|
||||
QgsSvgSelectorListModel( QObject *parent /TransferThis/, const QString &path, int iconSize = 30 );
|
||||
%Docstring
|
||||
Constructor for creating a model for SVG files in a specific path.
|
||||
\param parent parent object
|
||||
\param path initial path, which is recursively searched
|
||||
\param iconSize desired size of SVG icons to create
|
||||
%End
|
||||
|
||||
virtual int rowCount( const QModelIndex &parent = QModelIndex() ) const;
|
||||
|
@ -46,6 +46,7 @@ from qgis.core import (QgsApplication, QgsCoordinateReferenceSystem,
|
||||
QgsCoordinateTransform, QgsGeometry, QgsPointXY,
|
||||
QgsProviderRegistry, QgsSettings)
|
||||
from qgis.gui import QgsRubberBand
|
||||
from qgis.utils import OverrideCursor
|
||||
|
||||
from owslib.csw import CatalogueServiceWeb # spellok
|
||||
from owslib.fes import BBox, PropertyIsLike
|
||||
@ -281,8 +282,6 @@ class MetaSearchDialog(QDialog, BASE_CLASS):
|
||||
if not self._get_csw():
|
||||
return
|
||||
|
||||
QApplication.restoreOverrideCursor()
|
||||
|
||||
if self.catalog: # display service metadata
|
||||
self.btnCapabilities.setEnabled(True)
|
||||
metadata = render_template('en', self.context,
|
||||
@ -490,25 +489,22 @@ class MetaSearchDialog(QDialog, BASE_CLASS):
|
||||
# TODO: allow users to select resources types
|
||||
# to find ('service', 'dataset', etc.)
|
||||
try:
|
||||
self.catalog.getrecords2(constraints=self.constraints,
|
||||
maxrecords=self.maxrecords, esn='full')
|
||||
with OverrideCursor(Qt.WaitCursor):
|
||||
self.catalog.getrecords2(constraints=self.constraints,
|
||||
maxrecords=self.maxrecords, esn='full')
|
||||
except ExceptionReport as err:
|
||||
QApplication.restoreOverrideCursor()
|
||||
QMessageBox.warning(self, self.tr('Search error'),
|
||||
self.tr('Search error: {0}').format(err))
|
||||
return
|
||||
except Exception as err:
|
||||
QApplication.restoreOverrideCursor()
|
||||
QMessageBox.warning(self, self.tr('Connection error'),
|
||||
self.tr('Connection error: {0}').format(err))
|
||||
return
|
||||
|
||||
if self.catalog.results['matches'] == 0:
|
||||
QApplication.restoreOverrideCursor()
|
||||
self.lblResults.setText(self.tr('0 results'))
|
||||
return
|
||||
|
||||
QApplication.restoreOverrideCursor()
|
||||
self.display_results()
|
||||
|
||||
def display_results(self):
|
||||
@ -675,25 +671,20 @@ class MetaSearchDialog(QDialog, BASE_CLASS):
|
||||
else:
|
||||
return
|
||||
|
||||
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
|
||||
|
||||
try:
|
||||
self.catalog.getrecords2(constraints=self.constraints,
|
||||
maxrecords=self.maxrecords,
|
||||
startposition=self.startfrom, esn='full')
|
||||
with OverrideCursor(Qt.WaitCursor):
|
||||
self.catalog.getrecords2(constraints=self.constraints,
|
||||
maxrecords=self.maxrecords,
|
||||
startposition=self.startfrom, esn='full')
|
||||
except ExceptionReport as err:
|
||||
QApplication.restoreOverrideCursor()
|
||||
QMessageBox.warning(self, self.tr('Search error'),
|
||||
self.tr('Search error: {0}').format(err))
|
||||
return
|
||||
except Exception as err:
|
||||
QApplication.restoreOverrideCursor()
|
||||
QMessageBox.warning(self, self.tr('Connection error'),
|
||||
self.tr('Connection error: {0}').format(err))
|
||||
return
|
||||
|
||||
QApplication.restoreOverrideCursor()
|
||||
|
||||
self.display_results()
|
||||
|
||||
def add_to_ows(self):
|
||||
@ -727,8 +718,6 @@ class MetaSearchDialog(QDialog, BASE_CLASS):
|
||||
stype = ['ESRI:ArcGIS:FeatureServer', 'afs', 'arcgisfeatureserver']
|
||||
data_url = item_data['afs'].split('FeatureServer')[0] + 'FeatureServer'
|
||||
|
||||
QApplication.restoreOverrideCursor()
|
||||
|
||||
sname = '%s from MetaSearch' % stype[1]
|
||||
|
||||
# store connection
|
||||
@ -820,14 +809,13 @@ class MetaSearchDialog(QDialog, BASE_CLASS):
|
||||
identifier = get_item_data(item, 'identifier')
|
||||
|
||||
try:
|
||||
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
|
||||
cat = CatalogueServiceWeb(self.catalog_url, timeout=self.timeout, # spellok
|
||||
username=self.catalog_username,
|
||||
password=self.catalog_password)
|
||||
cat.getrecordbyid(
|
||||
[self.catalog.records[identifier].identifier])
|
||||
with OverrideCursor(Qt.WaitCursor):
|
||||
cat = CatalogueServiceWeb(self.catalog_url, timeout=self.timeout, # spellok
|
||||
username=self.catalog_username,
|
||||
password=self.catalog_password)
|
||||
cat.getrecordbyid(
|
||||
[self.catalog.records[identifier].identifier])
|
||||
except ExceptionReport as err:
|
||||
QApplication.restoreOverrideCursor()
|
||||
QMessageBox.warning(self, self.tr('GetRecords error'),
|
||||
self.tr('Error getting response: {0}').format(err))
|
||||
return
|
||||
@ -835,11 +823,8 @@ class MetaSearchDialog(QDialog, BASE_CLASS):
|
||||
QMessageBox.warning(self,
|
||||
self.tr('Record parsing error'),
|
||||
self.tr('Unable to locate record identifier'))
|
||||
QApplication.restoreOverrideCursor()
|
||||
return
|
||||
|
||||
QApplication.restoreOverrideCursor()
|
||||
|
||||
record = cat.records[identifier]
|
||||
record.xml_url = cat.request
|
||||
|
||||
@ -902,21 +887,20 @@ class MetaSearchDialog(QDialog, BASE_CLASS):
|
||||
"""convenience function to init owslib.csw.CatalogueServiceWeb""" # spellok
|
||||
|
||||
# connect to the server
|
||||
try:
|
||||
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
|
||||
self.catalog = CatalogueServiceWeb(self.catalog_url, # spellok
|
||||
timeout=self.timeout,
|
||||
username=self.catalog_username,
|
||||
password=self.catalog_password)
|
||||
return True
|
||||
except ExceptionReport as err:
|
||||
msg = self.tr('Error connecting to service: {0}').format(err)
|
||||
except ValueError as err:
|
||||
msg = self.tr('Value Error: {0}').format(err)
|
||||
except Exception as err:
|
||||
msg = self.tr('Unknown Error: {0}').format(err)
|
||||
with OverrideCursor(Qt.WaitCursor):
|
||||
try:
|
||||
self.catalog = CatalogueServiceWeb(self.catalog_url, # spellok
|
||||
timeout=self.timeout,
|
||||
username=self.catalog_username,
|
||||
password=self.catalog_password)
|
||||
return True
|
||||
except ExceptionReport as err:
|
||||
msg = self.tr('Error connecting to service: {0}').format(err)
|
||||
except ValueError as err:
|
||||
msg = self.tr('Value Error: {0}').format(err)
|
||||
except Exception as err:
|
||||
msg = self.tr('Unknown Error: {0}').format(err)
|
||||
|
||||
QApplication.restoreOverrideCursor()
|
||||
QMessageBox.warning(self, self.tr('CSW Connection error'), msg)
|
||||
return False
|
||||
|
||||
|
@ -6,35 +6,74 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>494</width>
|
||||
<height>224</height>
|
||||
<width>585</width>
|
||||
<height>327</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Create a new Catalog connection</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="2" column="2">
|
||||
<widget class="QLineEdit" name="leURL"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>URL</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="leName"/>
|
||||
</item>
|
||||
<item row="5" column="2">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>URL</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="leURL"/>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="authenticationGroupBox">
|
||||
<property name="title">
|
||||
<string>Authentication</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout_2">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>If the service requires basic authentication, enter a user name and optional password</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>User name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="leUsername"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Password</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="lePassword"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
@ -44,85 +83,11 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QTabWidget" name="tabNewConnectionOptions">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
<string>Authentication</string>
|
||||
</attribute>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>421</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>If the service requires basic authentication, enter a user name and optional password</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>30</y>
|
||||
<width>51</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>User name</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>60</y>
|
||||
<width>46</width>
|
||||
<height>13</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Password</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="leUsername">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>80</x>
|
||||
<y>30</y>
|
||||
<width>341</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lePassword">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>80</x>
|
||||
<y>60</y>
|
||||
<width>341</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>leName</tabstop>
|
||||
<tabstop>leURL</tabstop>
|
||||
<tabstop>leUsername</tabstop>
|
||||
<tabstop>lePassword</tabstop>
|
||||
<tabstop>tabNewConnectionOptions</tabstop>
|
||||
<tabstop>buttonBox</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
|
@ -32,6 +32,8 @@ from qgis.PyQt.QtGui import QIcon, QKeySequence
|
||||
|
||||
from qgis.gui import QgsMessageBar
|
||||
from qgis.core import QgsSettings, QgsMapLayer
|
||||
from qgis.utils import OverrideCursor
|
||||
|
||||
from .info_viewer import InfoViewer
|
||||
from .table_viewer import TableViewer
|
||||
from .layer_preview import LayerPreview
|
||||
@ -72,29 +74,23 @@ class DBManager(QMainWindow):
|
||||
QMainWindow.closeEvent(self, e)
|
||||
|
||||
def refreshItem(self, item=None):
|
||||
QApplication.setOverrideCursor(Qt.WaitCursor)
|
||||
try:
|
||||
if item is None:
|
||||
item = self.tree.currentItem()
|
||||
self.tree.refreshItem(item) # refresh item children in the db tree
|
||||
except BaseError as e:
|
||||
DlgDbError.showError(e, self)
|
||||
return
|
||||
finally:
|
||||
QApplication.restoreOverrideCursor()
|
||||
with OverrideCursor(Qt.WaitCursor):
|
||||
try:
|
||||
if item is None:
|
||||
item = self.tree.currentItem()
|
||||
self.tree.refreshItem(item) # refresh item children in the db tree
|
||||
except BaseError as e:
|
||||
DlgDbError.showError(e, self)
|
||||
|
||||
def itemChanged(self, item):
|
||||
QApplication.setOverrideCursor(Qt.WaitCursor)
|
||||
try:
|
||||
self.reloadButtons()
|
||||
# clear preview, this will delete the layer in preview tab
|
||||
self.preview.loadPreview(None)
|
||||
self.refreshTabs()
|
||||
except BaseError as e:
|
||||
DlgDbError.showError(e, self)
|
||||
return
|
||||
finally:
|
||||
QApplication.restoreOverrideCursor()
|
||||
with OverrideCursor(Qt.WaitCursor):
|
||||
try:
|
||||
self.reloadButtons()
|
||||
# clear preview, this will delete the layer in preview tab
|
||||
self.preview.loadPreview(None)
|
||||
self.refreshTabs()
|
||||
except BaseError as e:
|
||||
DlgDbError.showError(e, self)
|
||||
|
||||
def reloadButtons(self):
|
||||
db = self.tree.currentDatabase()
|
||||
@ -114,14 +110,11 @@ class DBManager(QMainWindow):
|
||||
self._lastDb.registerAllActions(self)
|
||||
|
||||
def tabChanged(self, index):
|
||||
QApplication.setOverrideCursor(Qt.WaitCursor)
|
||||
try:
|
||||
self.refreshTabs()
|
||||
except BaseError as e:
|
||||
DlgDbError.showError(e, self)
|
||||
return
|
||||
finally:
|
||||
QApplication.restoreOverrideCursor()
|
||||
with OverrideCursor(Qt.WaitCursor):
|
||||
try:
|
||||
self.refreshTabs()
|
||||
except BaseError as e:
|
||||
DlgDbError.showError(e, self)
|
||||
|
||||
def refreshTabs(self):
|
||||
index = self.tabs.currentIndex()
|
||||
@ -300,17 +293,12 @@ class DBManager(QMainWindow):
|
||||
This method takes care to override and restore the cursor,
|
||||
but also catches exceptions and displays the error dialog.
|
||||
"""
|
||||
QApplication.setOverrideCursor(Qt.WaitCursor)
|
||||
try:
|
||||
callback(self.tree.currentItem(), self.sender(), self, *params)
|
||||
|
||||
except BaseError as e:
|
||||
# catch database errors and display the error dialog
|
||||
DlgDbError.showError(e, self)
|
||||
return
|
||||
|
||||
finally:
|
||||
QApplication.restoreOverrideCursor()
|
||||
with OverrideCursor(Qt.WaitCursor):
|
||||
try:
|
||||
callback(self.tree.currentItem(), self.sender(), self, *params)
|
||||
except BaseError as e:
|
||||
# catch database errors and display the error dialog
|
||||
DlgDbError.showError(e, self)
|
||||
|
||||
def unregisterAction(self, action, menuName):
|
||||
if not hasattr(self, '_registeredDbActions'):
|
||||
|
@ -32,6 +32,7 @@ from .db_plugins.plugin import BaseError, Table, Database
|
||||
from .dlg_db_error import DlgDbError
|
||||
|
||||
from qgis.core import QgsDataSourceUri, QgsVectorLayer, QgsRasterLayer, QgsMimeDataUtils
|
||||
from qgis.utils import OverrideCursor
|
||||
|
||||
from . import resources_rc # NOQA
|
||||
|
||||
@ -458,17 +459,15 @@ class DBModel(QAbstractItemModel):
|
||||
if new_value == obj.name:
|
||||
return False
|
||||
|
||||
QApplication.setOverrideCursor(Qt.WaitCursor)
|
||||
try:
|
||||
obj.rename(new_value)
|
||||
self._onDataChanged(index)
|
||||
except BaseError as e:
|
||||
DlgDbError.showError(e, self.treeView)
|
||||
return False
|
||||
finally:
|
||||
QApplication.restoreOverrideCursor()
|
||||
|
||||
return True
|
||||
with OverrideCursor(Qt.WaitCursor):
|
||||
try:
|
||||
obj.rename(new_value)
|
||||
self._onDataChanged(index)
|
||||
except BaseError as e:
|
||||
DlgDbError.showError(e, self.treeView)
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
@ -480,27 +479,23 @@ class DBModel(QAbstractItemModel):
|
||||
self.endRemoveRows()
|
||||
|
||||
def _refreshIndex(self, index, force=False):
|
||||
QApplication.setOverrideCursor(Qt.WaitCursor)
|
||||
try:
|
||||
item = index.internalPointer() if index.isValid() else self.rootItem
|
||||
prevPopulated = item.populated
|
||||
if prevPopulated:
|
||||
self.removeRows(0, self.rowCount(index), index)
|
||||
with OverrideCursor(Qt.WaitCursor):
|
||||
try:
|
||||
item = index.internalPointer() if index.isValid() else self.rootItem
|
||||
prevPopulated = item.populated
|
||||
if prevPopulated:
|
||||
self.removeRows(0, self.rowCount(index), index)
|
||||
item.populated = False
|
||||
if prevPopulated or force:
|
||||
if item.populate():
|
||||
for child in item.childItems:
|
||||
child.changed.connect(partial(self.refreshItem, child))
|
||||
self._onDataChanged(index)
|
||||
else:
|
||||
self.notPopulated.emit(index)
|
||||
|
||||
except BaseError:
|
||||
item.populated = False
|
||||
if prevPopulated or force:
|
||||
if item.populate():
|
||||
for child in item.childItems:
|
||||
child.changed.connect(partial(self.refreshItem, child))
|
||||
self._onDataChanged(index)
|
||||
else:
|
||||
self.notPopulated.emit(index)
|
||||
|
||||
except BaseError:
|
||||
item.populated = False
|
||||
return
|
||||
|
||||
finally:
|
||||
QApplication.restoreOverrideCursor()
|
||||
|
||||
def _onDataChanged(self, indexFrom, indexTo=None):
|
||||
if indexTo is None:
|
||||
|
@ -35,6 +35,7 @@ start_app()
|
||||
|
||||
from db_manager.db_plugins.postgis.plugin import PostGisDBPlugin, PGRasterTable
|
||||
from db_manager.db_plugins.postgis.plugin import PGDatabase
|
||||
from db_manager.db_plugins.postgis.data_model import PGSqlResultModel
|
||||
from db_manager.db_plugins.plugin import Table
|
||||
from db_manager.db_plugins.postgis.connector import PostGisDBConnector
|
||||
|
||||
@ -125,6 +126,23 @@ class TestDBManagerPostgisPlugin(unittest.TestCase):
|
||||
|
||||
check_rasterTableGdalURI(expected_dbname)
|
||||
|
||||
# See http://issues.qgis.org/issues/16833
|
||||
def test_unicodeInQuery(self):
|
||||
os.environ['PGDATABASE'] = self.testdb
|
||||
obj = QObject() # needs to be kept alive
|
||||
database = PGDatabase(obj, QgsDataSourceUri())
|
||||
self.assertIsInstance(database, PGDatabase)
|
||||
# SQL as string literal
|
||||
res = database.sqlResultModel("SELECT 'é'::text", obj)
|
||||
self.assertIsInstance(res, PGSqlResultModel)
|
||||
dat = res.getData(0, 0)
|
||||
self.assertEqual(dat, u"é")
|
||||
# SQL as unicode literal
|
||||
res = database.sqlResultModel(u"SELECT 'é'::text", obj)
|
||||
self.assertIsInstance(res, PGSqlResultModel)
|
||||
dat = res.getData(0, 0)
|
||||
self.assertEqual(dat, u"é")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
@ -24,6 +24,7 @@ The content of this file is based on
|
||||
|
||||
from qgis.PyQt.QtCore import Qt
|
||||
from qgis.PyQt.QtWidgets import QDialog, QMessageBox, QApplication
|
||||
from qgis.utils import OverrideCursor
|
||||
|
||||
from .db_plugins.plugin import DbError
|
||||
from .dlg_db_error import DlgDbError
|
||||
@ -59,13 +60,11 @@ class DlgAddGeometryColumn(QDialog, Ui_Dialog):
|
||||
createSpatialIndex = False
|
||||
|
||||
# now create the geometry column
|
||||
QApplication.setOverrideCursor(Qt.WaitCursor)
|
||||
try:
|
||||
self.table.addGeometryColumn(name, geom_type, srid, dim, createSpatialIndex)
|
||||
except DbError as e:
|
||||
DlgDbError.showError(e, self)
|
||||
return
|
||||
finally:
|
||||
QApplication.restoreOverrideCursor()
|
||||
with OverrideCursor(Qt.WaitCursor):
|
||||
try:
|
||||
self.table.addGeometryColumn(name, geom_type, srid, dim, createSpatialIndex)
|
||||
except DbError as e:
|
||||
DlgDbError.showError(e, self)
|
||||
return
|
||||
|
||||
self.accept()
|
||||
|
@ -24,6 +24,7 @@ The content of this file is based on
|
||||
|
||||
from qgis.PyQt.QtCore import Qt
|
||||
from qgis.PyQt.QtWidgets import QDialog, QApplication
|
||||
from qgis.utils import OverrideCursor
|
||||
|
||||
from .db_plugins.plugin import DbError
|
||||
from .dlg_db_error import DlgDbError
|
||||
@ -52,14 +53,12 @@ class DlgCreateConstraint(QDialog, Ui_Dialog):
|
||||
constr = self.getConstraint()
|
||||
|
||||
# now create the constraint
|
||||
QApplication.setOverrideCursor(Qt.WaitCursor)
|
||||
try:
|
||||
self.table.addConstraint(constr)
|
||||
except DbError as e:
|
||||
DlgDbError.showError(e, self)
|
||||
return
|
||||
finally:
|
||||
QApplication.restoreOverrideCursor()
|
||||
with OverrideCursor(Qt.WaitCursor):
|
||||
try:
|
||||
self.table.addConstraint(constr)
|
||||
except DbError as e:
|
||||
DlgDbError.showError(e, self)
|
||||
return
|
||||
|
||||
self.accept()
|
||||
|
||||
|
@ -24,6 +24,7 @@ The content of this file is based on
|
||||
|
||||
from qgis.PyQt.QtCore import Qt
|
||||
from qgis.PyQt.QtWidgets import QDialog, QMessageBox, QApplication
|
||||
from qgis.utils import OverrideCursor
|
||||
|
||||
from .db_plugins.plugin import DbError
|
||||
from .dlg_db_error import DlgDbError
|
||||
@ -60,14 +61,12 @@ class DlgCreateIndex(QDialog, Ui_Dialog):
|
||||
return
|
||||
|
||||
# now create the index
|
||||
QApplication.setOverrideCursor(Qt.WaitCursor)
|
||||
try:
|
||||
self.table.addIndex(idx)
|
||||
except DbError as e:
|
||||
DlgDbError.showError(e, self)
|
||||
return
|
||||
finally:
|
||||
QApplication.restoreOverrideCursor()
|
||||
with OverrideCursor(Qt.WaitCursor):
|
||||
try:
|
||||
self.table.addIndex(idx)
|
||||
except DbError as e:
|
||||
DlgDbError.showError(e, self)
|
||||
return
|
||||
|
||||
self.accept()
|
||||
|
||||
|
@ -28,6 +28,8 @@ from qgis.PyQt.QtCore import Qt, QModelIndex
|
||||
from qgis.PyQt.QtWidgets import QItemDelegate, QComboBox, QDialog, QPushButton, QDialogButtonBox, QMessageBox, QApplication
|
||||
from qgis.PyQt.QtCore import QItemSelectionModel, pyqtSignal
|
||||
|
||||
from qgis.utils import OverrideCursor
|
||||
|
||||
from .db_plugins.data_model import TableFieldsModel
|
||||
from .db_plugins.plugin import DbError, ConnectionError
|
||||
from .dlg_db_error import DlgDbError
|
||||
@ -297,19 +299,16 @@ class DlgCreateTable(QDialog, Ui_Dialog):
|
||||
flds[pk_index].primaryKey = True
|
||||
|
||||
# commit to DB
|
||||
QApplication.setOverrideCursor(Qt.WaitCursor)
|
||||
try:
|
||||
if not useGeomColumn:
|
||||
self.db.createTable(table, flds, schema)
|
||||
else:
|
||||
geom = geomColumn, geomType, geomSrid, geomDim, useSpatialIndex
|
||||
self.db.createVectorTable(table, flds, geom, schema)
|
||||
with OverrideCursor(Qt.WaitCursor):
|
||||
try:
|
||||
if not useGeomColumn:
|
||||
self.db.createTable(table, flds, schema)
|
||||
else:
|
||||
geom = geomColumn, geomType, geomSrid, geomDim, useSpatialIndex
|
||||
self.db.createVectorTable(table, flds, geom, schema)
|
||||
|
||||
except (ConnectionError, DbError) as e:
|
||||
DlgDbError.showError(e, self)
|
||||
except (ConnectionError, DbError) as e:
|
||||
DlgDbError.showError(e, self)
|
||||
return
|
||||
|
||||
finally:
|
||||
QApplication.restoreOverrideCursor()
|
||||
|
||||
QMessageBox.information(self, self.tr("Good"), self.tr("everything went fine"))
|
||||
|
@ -32,6 +32,7 @@ from qgis.core import (QgsVectorFileWriter,
|
||||
QgsCoordinateReferenceSystem,
|
||||
QgsVectorLayerExporter,
|
||||
QgsSettings)
|
||||
from qgis.utils import OverrideCursor
|
||||
|
||||
from .ui.ui_DlgExportVector import Ui_DbManagerDlgExportVector as Ui_Dialog
|
||||
|
||||
@ -145,51 +146,48 @@ class DlgExportVector(QDialog, Ui_Dialog):
|
||||
self.tr("Invalid target srid: must be an integer"))
|
||||
return
|
||||
|
||||
# override cursor
|
||||
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
|
||||
# store current input layer crs, so I can restore it later
|
||||
prevInCrs = self.inLayer.crs()
|
||||
try:
|
||||
uri = self.editOutputFile.text()
|
||||
providerName = "ogr"
|
||||
with OverrideCursor(Qt.WaitCursor):
|
||||
# store current input layer crs, so I can restore it later
|
||||
prevInCrs = self.inLayer.crs()
|
||||
try:
|
||||
uri = self.editOutputFile.text()
|
||||
providerName = "ogr"
|
||||
|
||||
options = {}
|
||||
options = {}
|
||||
|
||||
# set the OGR driver will be used
|
||||
driverName = self.cboFileFormat.currentData()
|
||||
options['driverName'] = driverName
|
||||
# set the OGR driver will be used
|
||||
driverName = self.cboFileFormat.currentData()
|
||||
options['driverName'] = driverName
|
||||
|
||||
# set the output file encoding
|
||||
if self.chkEncoding.isEnabled() and self.chkEncoding.isChecked():
|
||||
enc = self.cboEncoding.currentText()
|
||||
options['fileEncoding'] = enc
|
||||
# set the output file encoding
|
||||
if self.chkEncoding.isEnabled() and self.chkEncoding.isChecked():
|
||||
enc = self.cboEncoding.currentText()
|
||||
options['fileEncoding'] = enc
|
||||
|
||||
if self.chkDropTable.isChecked():
|
||||
options['overwrite'] = True
|
||||
if self.chkDropTable.isChecked():
|
||||
options['overwrite'] = True
|
||||
|
||||
outCrs = QgsCoordinateReferenceSystem()
|
||||
if self.chkTargetSrid.isEnabled() and self.chkTargetSrid.isChecked():
|
||||
targetSrid = int(self.editTargetSrid.text())
|
||||
outCrs = QgsCoordinateReferenceSystem(targetSrid)
|
||||
outCrs = QgsCoordinateReferenceSystem()
|
||||
if self.chkTargetSrid.isEnabled() and self.chkTargetSrid.isChecked():
|
||||
targetSrid = int(self.editTargetSrid.text())
|
||||
outCrs = QgsCoordinateReferenceSystem(targetSrid)
|
||||
|
||||
# update input layer crs
|
||||
if self.chkSourceSrid.isEnabled() and self.chkSourceSrid.isChecked():
|
||||
sourceSrid = int(self.editSourceSrid.text())
|
||||
inCrs = QgsCoordinateReferenceSystem(sourceSrid)
|
||||
self.inLayer.setCrs(inCrs)
|
||||
# update input layer crs
|
||||
if self.chkSourceSrid.isEnabled() and self.chkSourceSrid.isChecked():
|
||||
sourceSrid = int(self.editSourceSrid.text())
|
||||
inCrs = QgsCoordinateReferenceSystem(sourceSrid)
|
||||
self.inLayer.setCrs(inCrs)
|
||||
|
||||
# do the export!
|
||||
ret, errMsg = QgsVectorLayerExporter.exportLayer(self.inLayer, uri, providerName, outCrs,
|
||||
False, options)
|
||||
except Exception as e:
|
||||
ret = -1
|
||||
errMsg = str(e)
|
||||
# do the export!
|
||||
ret, errMsg = QgsVectorLayerExporter.exportLayer(self.inLayer, uri, providerName, outCrs,
|
||||
False, options)
|
||||
except Exception as e:
|
||||
ret = -1
|
||||
errMsg = str(e)
|
||||
|
||||
finally:
|
||||
# restore input layer crs and encoding
|
||||
self.inLayer.setCrs(prevInCrs)
|
||||
# restore cursor
|
||||
QApplication.restoreOverrideCursor()
|
||||
finally:
|
||||
# restore input layer crs and encoding
|
||||
self.inLayer.setCrs(prevInCrs)
|
||||
|
||||
if ret != 0:
|
||||
QMessageBox.warning(self, self.tr("Export to file"), self.tr("Error {0}\n{1}").format(ret, errMsg))
|
||||
|
@ -37,6 +37,7 @@ from qgis.core import (QgsDataSourceUri,
|
||||
QgsProject,
|
||||
QgsSettings)
|
||||
from qgis.gui import QgsMessageViewer
|
||||
from qgis.utils import OverrideCursor
|
||||
|
||||
from .ui.ui_DlgImportVector import Ui_DbManagerDlgImportVector as Ui_Dialog
|
||||
|
||||
@ -292,85 +293,82 @@ class DlgImportVector(QDialog, Ui_Dialog):
|
||||
self.tr("Invalid target srid: must be an integer"))
|
||||
return
|
||||
|
||||
# override cursor
|
||||
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
|
||||
# store current input layer crs and encoding, so I can restore it
|
||||
prevInCrs = self.inLayer.crs()
|
||||
prevInEncoding = self.inLayer.dataProvider().encoding()
|
||||
with OverrideCursor(Qt.WaitCursor):
|
||||
# store current input layer crs and encoding, so I can restore it
|
||||
prevInCrs = self.inLayer.crs()
|
||||
prevInEncoding = self.inLayer.dataProvider().encoding()
|
||||
|
||||
try:
|
||||
schema = self.outUri.schema() if not self.cboSchema.isEnabled() else self.cboSchema.currentText()
|
||||
table = self.cboTable.currentText()
|
||||
try:
|
||||
schema = self.outUri.schema() if not self.cboSchema.isEnabled() else self.cboSchema.currentText()
|
||||
table = self.cboTable.currentText()
|
||||
|
||||
# get pk and geom field names from the source layer or use the
|
||||
# ones defined by the user
|
||||
srcUri = QgsDataSourceUri(self.inLayer.source())
|
||||
# get pk and geom field names from the source layer or use the
|
||||
# ones defined by the user
|
||||
srcUri = QgsDataSourceUri(self.inLayer.source())
|
||||
|
||||
pk = srcUri.keyColumn() if not self.chkPrimaryKey.isChecked() else self.editPrimaryKey.text()
|
||||
if not pk:
|
||||
pk = self.default_pk
|
||||
pk = srcUri.keyColumn() if not self.chkPrimaryKey.isChecked() else self.editPrimaryKey.text()
|
||||
if not pk:
|
||||
pk = self.default_pk
|
||||
|
||||
if self.inLayer.isSpatial() and self.chkGeomColumn.isEnabled():
|
||||
geom = srcUri.geometryColumn() if not self.chkGeomColumn.isChecked() else self.editGeomColumn.text()
|
||||
if not geom:
|
||||
geom = self.default_geom
|
||||
else:
|
||||
geom = None
|
||||
if self.inLayer.isSpatial() and self.chkGeomColumn.isEnabled():
|
||||
geom = srcUri.geometryColumn() if not self.chkGeomColumn.isChecked() else self.editGeomColumn.text()
|
||||
if not geom:
|
||||
geom = self.default_geom
|
||||
else:
|
||||
geom = None
|
||||
|
||||
options = {}
|
||||
if self.chkLowercaseFieldNames.isEnabled() and self.chkLowercaseFieldNames.isChecked():
|
||||
pk = pk.lower()
|
||||
if geom:
|
||||
geom = geom.lower()
|
||||
options['lowercaseFieldNames'] = True
|
||||
options = {}
|
||||
if self.chkLowercaseFieldNames.isEnabled() and self.chkLowercaseFieldNames.isChecked():
|
||||
pk = pk.lower()
|
||||
if geom:
|
||||
geom = geom.lower()
|
||||
options['lowercaseFieldNames'] = True
|
||||
|
||||
# get output params, update output URI
|
||||
self.outUri.setDataSource(schema, table, geom, "", pk)
|
||||
typeName = self.db.dbplugin().typeName()
|
||||
providerName = self.db.dbplugin().providerName()
|
||||
if typeName == 'gpkg':
|
||||
uri = self.outUri.database()
|
||||
options['update'] = True
|
||||
options['driverName'] = 'GPKG'
|
||||
options['layerName'] = table
|
||||
else:
|
||||
uri = self.outUri.uri(False)
|
||||
# get output params, update output URI
|
||||
self.outUri.setDataSource(schema, table, geom, "", pk)
|
||||
typeName = self.db.dbplugin().typeName()
|
||||
providerName = self.db.dbplugin().providerName()
|
||||
if typeName == 'gpkg':
|
||||
uri = self.outUri.database()
|
||||
options['update'] = True
|
||||
options['driverName'] = 'GPKG'
|
||||
options['layerName'] = table
|
||||
else:
|
||||
uri = self.outUri.uri(False)
|
||||
|
||||
if self.chkDropTable.isChecked():
|
||||
options['overwrite'] = True
|
||||
if self.chkDropTable.isChecked():
|
||||
options['overwrite'] = True
|
||||
|
||||
if self.chkSinglePart.isEnabled() and self.chkSinglePart.isChecked():
|
||||
options['forceSinglePartGeometryType'] = True
|
||||
if self.chkSinglePart.isEnabled() and self.chkSinglePart.isChecked():
|
||||
options['forceSinglePartGeometryType'] = True
|
||||
|
||||
outCrs = QgsCoordinateReferenceSystem()
|
||||
if self.chkTargetSrid.isEnabled() and self.chkTargetSrid.isChecked():
|
||||
targetSrid = int(self.editTargetSrid.text())
|
||||
outCrs = QgsCoordinateReferenceSystem(targetSrid)
|
||||
outCrs = QgsCoordinateReferenceSystem()
|
||||
if self.chkTargetSrid.isEnabled() and self.chkTargetSrid.isChecked():
|
||||
targetSrid = int(self.editTargetSrid.text())
|
||||
outCrs = QgsCoordinateReferenceSystem(targetSrid)
|
||||
|
||||
# update input layer crs and encoding
|
||||
if self.chkSourceSrid.isEnabled() and self.chkSourceSrid.isChecked():
|
||||
sourceSrid = int(self.editSourceSrid.text())
|
||||
inCrs = QgsCoordinateReferenceSystem(sourceSrid)
|
||||
self.inLayer.setCrs(inCrs)
|
||||
# update input layer crs and encoding
|
||||
if self.chkSourceSrid.isEnabled() and self.chkSourceSrid.isChecked():
|
||||
sourceSrid = int(self.editSourceSrid.text())
|
||||
inCrs = QgsCoordinateReferenceSystem(sourceSrid)
|
||||
self.inLayer.setCrs(inCrs)
|
||||
|
||||
if self.chkEncoding.isEnabled() and self.chkEncoding.isChecked():
|
||||
enc = self.cboEncoding.currentText()
|
||||
self.inLayer.setProviderEncoding(enc)
|
||||
if self.chkEncoding.isEnabled() and self.chkEncoding.isChecked():
|
||||
enc = self.cboEncoding.currentText()
|
||||
self.inLayer.setProviderEncoding(enc)
|
||||
|
||||
onlySelected = self.chkSelectedFeatures.isChecked()
|
||||
onlySelected = self.chkSelectedFeatures.isChecked()
|
||||
|
||||
# do the import!
|
||||
ret, errMsg = QgsVectorLayerExporter.exportLayer(self.inLayer, uri, providerName, outCrs, onlySelected, options)
|
||||
except Exception as e:
|
||||
ret = -1
|
||||
errMsg = str(e)
|
||||
# do the import!
|
||||
ret, errMsg = QgsVectorLayerExporter.exportLayer(self.inLayer, uri, providerName, outCrs, onlySelected, options)
|
||||
except Exception as e:
|
||||
ret = -1
|
||||
errMsg = str(e)
|
||||
|
||||
finally:
|
||||
# restore input layer crs and encoding
|
||||
self.inLayer.setCrs(prevInCrs)
|
||||
self.inLayer.setProviderEncoding(prevInEncoding)
|
||||
# restore cursor
|
||||
QApplication.restoreOverrideCursor()
|
||||
finally:
|
||||
# restore input layer crs and encoding
|
||||
self.inLayer.setCrs(prevInCrs)
|
||||
self.inLayer.setProviderEncoding(prevInEncoding)
|
||||
|
||||
if ret != 0:
|
||||
output = QgsMessageViewer()
|
||||
|
@ -32,6 +32,7 @@ from qgis.PyQt.Qsci import QsciAPIs
|
||||
from qgis.PyQt.QtXml import QDomDocument
|
||||
|
||||
from qgis.core import QgsProject, QgsDataSourceUri
|
||||
from qgis.utils import OverrideCursor
|
||||
|
||||
from .db_plugins import createDbPlugin
|
||||
from .db_plugins.plugin import BaseError
|
||||
@ -223,37 +224,35 @@ class DlgSqlLayerWindow(QWidget, Ui_Dialog):
|
||||
if sql == "":
|
||||
return
|
||||
|
||||
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
|
||||
with OverrideCursor(Qt.WaitCursor):
|
||||
|
||||
# delete the old model
|
||||
old_model = self.viewResult.model()
|
||||
self.viewResult.setModel(None)
|
||||
if old_model:
|
||||
old_model.deleteLater()
|
||||
# delete the old model
|
||||
old_model = self.viewResult.model()
|
||||
self.viewResult.setModel(None)
|
||||
if old_model:
|
||||
old_model.deleteLater()
|
||||
|
||||
cols = []
|
||||
quotedCols = []
|
||||
cols = []
|
||||
quotedCols = []
|
||||
|
||||
try:
|
||||
# set the new model
|
||||
model = self.db.sqlResultModel(sql, self)
|
||||
self.viewResult.setModel(model)
|
||||
self.lblResult.setText(self.tr("{0} rows, {1:.1f} seconds").format(model.affectedRows(), model.secs()))
|
||||
cols = self.viewResult.model().columnNames()
|
||||
for col in cols:
|
||||
quotedCols.append(self.db.connector.quoteId(col))
|
||||
try:
|
||||
# set the new model
|
||||
model = self.db.sqlResultModel(sql, self)
|
||||
self.viewResult.setModel(model)
|
||||
self.lblResult.setText(self.tr("{0} rows, {1:.1f} seconds").format(model.affectedRows(), model.secs()))
|
||||
cols = self.viewResult.model().columnNames()
|
||||
for col in cols:
|
||||
quotedCols.append(self.db.connector.quoteId(col))
|
||||
|
||||
except BaseError as e:
|
||||
QApplication.restoreOverrideCursor()
|
||||
DlgDbError.showError(e, self)
|
||||
self.uniqueModel.clear()
|
||||
self.geomCombo.clear()
|
||||
return
|
||||
except BaseError as e:
|
||||
DlgDbError.showError(e, self)
|
||||
self.uniqueModel.clear()
|
||||
self.geomCombo.clear()
|
||||
return
|
||||
|
||||
self.setColumnCombos(cols, quotedCols)
|
||||
self.setColumnCombos(cols, quotedCols)
|
||||
|
||||
self.update()
|
||||
QApplication.restoreOverrideCursor()
|
||||
self.update()
|
||||
|
||||
def _getSqlLayer(self, _filter):
|
||||
hasUniqueField = self.uniqueColumnCheck.checkState() == Qt.Checked
|
||||
@ -311,19 +310,15 @@ class DlgSqlLayerWindow(QWidget, Ui_Dialog):
|
||||
return None
|
||||
|
||||
def loadSqlLayer(self):
|
||||
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
|
||||
try:
|
||||
with OverrideCursor(Qt.WaitCursor):
|
||||
layer = self._getSqlLayer(self.filter)
|
||||
if layer is None:
|
||||
return
|
||||
|
||||
QgsProject.instance().addMapLayers([layer], True)
|
||||
finally:
|
||||
QApplication.restoreOverrideCursor()
|
||||
|
||||
def updateSqlLayer(self):
|
||||
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
|
||||
try:
|
||||
with OverrideCursor(Qt.WaitCursor):
|
||||
layer = self._getSqlLayer(self.filter)
|
||||
if layer is None:
|
||||
return
|
||||
@ -341,60 +336,54 @@ class DlgSqlLayerWindow(QWidget, Ui_Dialog):
|
||||
self.layer.reload()
|
||||
self.iface.actionDraw().trigger()
|
||||
self.iface.mapCanvas().refresh()
|
||||
finally:
|
||||
QApplication.restoreOverrideCursor()
|
||||
|
||||
def fillColumnCombos(self):
|
||||
query = self._getSqlQuery()
|
||||
if query == "":
|
||||
return
|
||||
|
||||
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
|
||||
with OverrideCursor(Qt.WaitCursor):
|
||||
# remove a trailing ';' from query if present
|
||||
if query.strip().endswith(';'):
|
||||
query = query.strip()[:-1]
|
||||
|
||||
# remove a trailing ';' from query if present
|
||||
if query.strip().endswith(';'):
|
||||
query = query.strip()[:-1]
|
||||
# get all the columns
|
||||
cols = []
|
||||
quotedCols = []
|
||||
connector = self.db.connector
|
||||
if self.aliasSubQuery:
|
||||
# get a new alias
|
||||
aliasIndex = 0
|
||||
while True:
|
||||
alias = "_subQuery__%d" % aliasIndex
|
||||
escaped = re.compile('\\b("?)' + re.escape(alias) + '\\1\\b')
|
||||
if not escaped.search(query):
|
||||
break
|
||||
aliasIndex += 1
|
||||
|
||||
# get all the columns
|
||||
cols = []
|
||||
quotedCols = []
|
||||
connector = self.db.connector
|
||||
if self.aliasSubQuery:
|
||||
# get a new alias
|
||||
aliasIndex = 0
|
||||
while True:
|
||||
alias = "_subQuery__%d" % aliasIndex
|
||||
escaped = re.compile('\\b("?)' + re.escape(alias) + '\\1\\b')
|
||||
if not escaped.search(query):
|
||||
break
|
||||
aliasIndex += 1
|
||||
sql = u"SELECT * FROM (%s\n) AS %s LIMIT 0" % (str(query), connector.quoteId(alias))
|
||||
else:
|
||||
sql = u"SELECT * FROM (%s\n) WHERE 1=0" % str(query)
|
||||
|
||||
sql = u"SELECT * FROM (%s\n) AS %s LIMIT 0" % (str(query), connector.quoteId(alias))
|
||||
else:
|
||||
sql = u"SELECT * FROM (%s\n) WHERE 1=0" % str(query)
|
||||
c = None
|
||||
try:
|
||||
c = connector._execute(None, sql)
|
||||
cols = connector._get_cursor_columns(c)
|
||||
for col in cols:
|
||||
quotedCols.append(connector.quoteId(col))
|
||||
|
||||
c = None
|
||||
try:
|
||||
c = connector._execute(None, sql)
|
||||
cols = connector._get_cursor_columns(c)
|
||||
for col in cols:
|
||||
quotedCols.append(connector.quoteId(col))
|
||||
except BaseError as e:
|
||||
DlgDbError.showError(e, self)
|
||||
self.uniqueModel.clear()
|
||||
self.geomCombo.clear()
|
||||
return
|
||||
|
||||
except BaseError as e:
|
||||
QApplication.restoreOverrideCursor()
|
||||
DlgDbError.showError(e, self)
|
||||
self.uniqueModel.clear()
|
||||
self.geomCombo.clear()
|
||||
return
|
||||
finally:
|
||||
if c:
|
||||
c.close()
|
||||
del c
|
||||
|
||||
finally:
|
||||
if c:
|
||||
c.close()
|
||||
del c
|
||||
|
||||
self.setColumnCombos(cols, quotedCols)
|
||||
|
||||
QApplication.restoreOverrideCursor()
|
||||
self.setColumnCombos(cols, quotedCols)
|
||||
|
||||
def setColumnCombos(self, cols, quotedCols):
|
||||
# get sensible default columns. do this before sorting in case there's hints in the column order (e.g., id is more likely to be first)
|
||||
|
@ -31,6 +31,7 @@ from qgis.PyQt.QtGui import QKeySequence, QCursor, QClipboard, QIcon, QStandardI
|
||||
from qgis.PyQt.Qsci import QsciAPIs
|
||||
|
||||
from qgis.core import QgsProject
|
||||
from qgis.utils import OverrideCursor
|
||||
|
||||
from .db_plugins.plugin import BaseError
|
||||
from .db_plugins.postgis.plugin import PGDatabase
|
||||
@ -182,37 +183,34 @@ class DlgSqlWindow(QWidget, Ui_Dialog):
|
||||
if sql == "":
|
||||
return
|
||||
|
||||
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
|
||||
with OverrideCursor(Qt.WaitCursor):
|
||||
# delete the old model
|
||||
old_model = self.viewResult.model()
|
||||
self.viewResult.setModel(None)
|
||||
if old_model:
|
||||
old_model.deleteLater()
|
||||
|
||||
# delete the old model
|
||||
old_model = self.viewResult.model()
|
||||
self.viewResult.setModel(None)
|
||||
if old_model:
|
||||
old_model.deleteLater()
|
||||
cols = []
|
||||
quotedCols = []
|
||||
|
||||
cols = []
|
||||
quotedCols = []
|
||||
try:
|
||||
# set the new model
|
||||
model = self.db.sqlResultModel(sql, self)
|
||||
self.viewResult.setModel(model)
|
||||
self.lblResult.setText(self.tr("{0} rows, {1:.1f} seconds").format(model.affectedRows(), model.secs()))
|
||||
cols = self.viewResult.model().columnNames()
|
||||
for col in cols:
|
||||
quotedCols.append(self.db.connector.quoteId(col))
|
||||
|
||||
try:
|
||||
# set the new model
|
||||
model = self.db.sqlResultModel(sql, self)
|
||||
self.viewResult.setModel(model)
|
||||
self.lblResult.setText(self.tr("{0} rows, {1:.1f} seconds").format(model.affectedRows(), model.secs()))
|
||||
cols = self.viewResult.model().columnNames()
|
||||
for col in cols:
|
||||
quotedCols.append(self.db.connector.quoteId(col))
|
||||
except BaseError as e:
|
||||
DlgDbError.showError(e, self)
|
||||
self.uniqueModel.clear()
|
||||
self.geomCombo.clear()
|
||||
return
|
||||
|
||||
except BaseError as e:
|
||||
QApplication.restoreOverrideCursor()
|
||||
DlgDbError.showError(e, self)
|
||||
self.uniqueModel.clear()
|
||||
self.geomCombo.clear()
|
||||
return
|
||||
self.setColumnCombos(cols, quotedCols)
|
||||
|
||||
self.setColumnCombos(cols, quotedCols)
|
||||
|
||||
self.update()
|
||||
QApplication.restoreOverrideCursor()
|
||||
self.update()
|
||||
|
||||
def _getSqlLayer(self, _filter):
|
||||
hasUniqueField = self.uniqueColumnCheck.checkState() == Qt.Checked
|
||||
@ -270,67 +268,60 @@ class DlgSqlWindow(QWidget, Ui_Dialog):
|
||||
return None
|
||||
|
||||
def loadSqlLayer(self):
|
||||
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
|
||||
try:
|
||||
with OverrideCursor(Qt.WaitCursor):
|
||||
layer = self._getSqlLayer(self.filter)
|
||||
if layer is None:
|
||||
return
|
||||
|
||||
QgsProject.instance().addMapLayers([layer], True)
|
||||
finally:
|
||||
QApplication.restoreOverrideCursor()
|
||||
|
||||
def fillColumnCombos(self):
|
||||
query = self._getSqlQuery()
|
||||
if query == "":
|
||||
return
|
||||
|
||||
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
|
||||
with OverrideCursor(Qt.WaitCursor):
|
||||
# remove a trailing ';' from query if present
|
||||
if query.strip().endswith(';'):
|
||||
query = query.strip()[:-1]
|
||||
|
||||
# remove a trailing ';' from query if present
|
||||
if query.strip().endswith(';'):
|
||||
query = query.strip()[:-1]
|
||||
# get all the columns
|
||||
cols = []
|
||||
quotedCols = []
|
||||
connector = self.db.connector
|
||||
if self.aliasSubQuery:
|
||||
# get a new alias
|
||||
aliasIndex = 0
|
||||
while True:
|
||||
alias = "_subQuery__%d" % aliasIndex
|
||||
escaped = re.compile('\\b("?)' + re.escape(alias) + '\\1\\b')
|
||||
if not escaped.search(query):
|
||||
break
|
||||
aliasIndex += 1
|
||||
|
||||
# get all the columns
|
||||
cols = []
|
||||
quotedCols = []
|
||||
connector = self.db.connector
|
||||
if self.aliasSubQuery:
|
||||
# get a new alias
|
||||
aliasIndex = 0
|
||||
while True:
|
||||
alias = "_subQuery__%d" % aliasIndex
|
||||
escaped = re.compile('\\b("?)' + re.escape(alias) + '\\1\\b')
|
||||
if not escaped.search(query):
|
||||
break
|
||||
aliasIndex += 1
|
||||
sql = u"SELECT * FROM (%s\n) AS %s LIMIT 0" % (str(query), connector.quoteId(alias))
|
||||
else:
|
||||
sql = u"SELECT * FROM (%s\n) WHERE 1=0" % str(query)
|
||||
|
||||
sql = u"SELECT * FROM (%s\n) AS %s LIMIT 0" % (str(query), connector.quoteId(alias))
|
||||
else:
|
||||
sql = u"SELECT * FROM (%s\n) WHERE 1=0" % str(query)
|
||||
c = None
|
||||
try:
|
||||
c = connector._execute(None, sql)
|
||||
cols = connector._get_cursor_columns(c)
|
||||
for col in cols:
|
||||
quotedCols.append(connector.quoteId(col))
|
||||
|
||||
c = None
|
||||
try:
|
||||
c = connector._execute(None, sql)
|
||||
cols = connector._get_cursor_columns(c)
|
||||
for col in cols:
|
||||
quotedCols.append(connector.quoteId(col))
|
||||
except BaseError as e:
|
||||
DlgDbError.showError(e, self)
|
||||
self.uniqueModel.clear()
|
||||
self.geomCombo.clear()
|
||||
return
|
||||
|
||||
except BaseError as e:
|
||||
QApplication.restoreOverrideCursor()
|
||||
DlgDbError.showError(e, self)
|
||||
self.uniqueModel.clear()
|
||||
self.geomCombo.clear()
|
||||
return
|
||||
finally:
|
||||
if c:
|
||||
c.close()
|
||||
del c
|
||||
|
||||
finally:
|
||||
if c:
|
||||
c.close()
|
||||
del c
|
||||
|
||||
self.setColumnCombos(cols, quotedCols)
|
||||
|
||||
QApplication.restoreOverrideCursor()
|
||||
self.setColumnCombos(cols, quotedCols)
|
||||
|
||||
def setColumnCombos(self, cols, quotedCols):
|
||||
# get sensible default columns. do this before sorting in case there's hints in the column order (e.g., id is more likely to be first)
|
||||
|
@ -26,6 +26,8 @@ from builtins import range
|
||||
from qgis.PyQt.QtCore import Qt, pyqtSignal
|
||||
from qgis.PyQt.QtWidgets import QDialog, QMessageBox, QApplication
|
||||
|
||||
from qgis.utils import OverrideCursor
|
||||
|
||||
from .db_plugins.data_model import TableFieldsModel, TableConstraintsModel, TableIndexesModel
|
||||
from .db_plugins.plugin import BaseError
|
||||
from .dlg_db_error import DlgDbError
|
||||
@ -116,17 +118,14 @@ class DlgTableProperties(QDialog, Ui_Dialog):
|
||||
return
|
||||
fld = dlg.getField()
|
||||
|
||||
QApplication.setOverrideCursor(Qt.WaitCursor)
|
||||
self.aboutToChangeTable.emit()
|
||||
try:
|
||||
# add column to table
|
||||
self.table.addField(fld)
|
||||
self.refresh()
|
||||
except BaseError as e:
|
||||
DlgDbError.showError(e, self)
|
||||
return
|
||||
finally:
|
||||
QApplication.restoreOverrideCursor()
|
||||
with OverrideCursor(Qt.WaitCursor):
|
||||
self.aboutToChangeTable.emit()
|
||||
try:
|
||||
# add column to table
|
||||
self.table.addField(fld)
|
||||
self.refresh()
|
||||
except BaseError as e:
|
||||
DlgDbError.showError(e, self)
|
||||
|
||||
def addGeometryColumn(self):
|
||||
""" open dialog to add geometry column """
|
||||
@ -151,16 +150,13 @@ class DlgTableProperties(QDialog, Ui_Dialog):
|
||||
return
|
||||
new_fld = dlg.getField(True)
|
||||
|
||||
QApplication.setOverrideCursor(Qt.WaitCursor)
|
||||
self.aboutToChangeTable.emit()
|
||||
try:
|
||||
fld.update(new_fld.name, new_fld.type2String(), new_fld.notNull, new_fld.default2String())
|
||||
self.refresh()
|
||||
except BaseError as e:
|
||||
DlgDbError.showError(e, self)
|
||||
return
|
||||
finally:
|
||||
QApplication.restoreOverrideCursor()
|
||||
with OverrideCursor(Qt.WaitCursor):
|
||||
self.aboutToChangeTable.emit()
|
||||
try:
|
||||
fld.update(new_fld.name, new_fld.type2String(), new_fld.notNull, new_fld.default2String())
|
||||
self.refresh()
|
||||
except BaseError as e:
|
||||
DlgDbError.showError(e, self)
|
||||
|
||||
def deleteColumn(self):
|
||||
""" delete currently selected column """
|
||||
@ -176,16 +172,13 @@ class DlgTableProperties(QDialog, Ui_Dialog):
|
||||
if res != QMessageBox.Yes:
|
||||
return
|
||||
|
||||
QApplication.setOverrideCursor(Qt.WaitCursor)
|
||||
self.aboutToChangeTable.emit()
|
||||
try:
|
||||
fld.delete()
|
||||
self.refresh()
|
||||
except BaseError as e:
|
||||
DlgDbError.showError(e, self)
|
||||
return
|
||||
finally:
|
||||
QApplication.restoreOverrideCursor()
|
||||
with OverrideCursor(Qt.WaitCursor):
|
||||
self.aboutToChangeTable.emit()
|
||||
try:
|
||||
fld.delete()
|
||||
self.refresh()
|
||||
except BaseError as e:
|
||||
DlgDbError.showError(e, self)
|
||||
|
||||
def populateConstraints(self):
|
||||
constraints = self.table.constraints()
|
||||
@ -231,16 +224,13 @@ class DlgTableProperties(QDialog, Ui_Dialog):
|
||||
if res != QMessageBox.Yes:
|
||||
return
|
||||
|
||||
QApplication.setOverrideCursor(Qt.WaitCursor)
|
||||
self.aboutToChangeTable.emit()
|
||||
try:
|
||||
constr.delete()
|
||||
self.refresh()
|
||||
except BaseError as e:
|
||||
DlgDbError.showError(e, self)
|
||||
return
|
||||
finally:
|
||||
QApplication.restoreOverrideCursor()
|
||||
with OverrideCursor(Qt.WaitCursor):
|
||||
self.aboutToChangeTable.emit()
|
||||
try:
|
||||
constr.delete()
|
||||
self.refresh()
|
||||
except BaseError as e:
|
||||
DlgDbError.showError(e, self)
|
||||
|
||||
def currentConstraint(self):
|
||||
""" returns row index of selected index """
|
||||
@ -291,17 +281,14 @@ class DlgTableProperties(QDialog, Ui_Dialog):
|
||||
return
|
||||
|
||||
# TODO: first check whether the index doesn't exist already
|
||||
QApplication.setOverrideCursor(Qt.WaitCursor)
|
||||
self.aboutToChangeTable.emit()
|
||||
with OverrideCursor(Qt.WaitCursor):
|
||||
self.aboutToChangeTable.emit()
|
||||
|
||||
try:
|
||||
self.table.createSpatialIndex()
|
||||
self.refresh()
|
||||
except BaseError as e:
|
||||
DlgDbError.showError(e, self)
|
||||
return
|
||||
finally:
|
||||
QApplication.restoreOverrideCursor()
|
||||
try:
|
||||
self.table.createSpatialIndex()
|
||||
self.refresh()
|
||||
except BaseError as e:
|
||||
DlgDbError.showError(e, self)
|
||||
|
||||
def currentIndex(self):
|
||||
""" returns row index of selected index """
|
||||
@ -326,13 +313,10 @@ class DlgTableProperties(QDialog, Ui_Dialog):
|
||||
if res != QMessageBox.Yes:
|
||||
return
|
||||
|
||||
QApplication.setOverrideCursor(Qt.WaitCursor)
|
||||
self.aboutToChangeTable.emit()
|
||||
try:
|
||||
idx.delete()
|
||||
self.refresh()
|
||||
except BaseError as e:
|
||||
DlgDbError.showError(e, self)
|
||||
return
|
||||
finally:
|
||||
QApplication.restoreOverrideCursor()
|
||||
with OverrideCursor(Qt.WaitCursor):
|
||||
self.aboutToChangeTable.emit()
|
||||
try:
|
||||
idx.delete()
|
||||
self.refresh()
|
||||
except BaseError as e:
|
||||
DlgDbError.showError(e, self)
|
||||
|
@ -23,6 +23,7 @@ from builtins import str
|
||||
|
||||
from qgis.PyQt.QtCore import Qt
|
||||
from qgis.PyQt.QtWidgets import QTextBrowser, QApplication
|
||||
from qgis.utils import OverrideCursor
|
||||
|
||||
from .db_plugins.plugin import BaseError, DbError, DBPlugin, Schema, Table
|
||||
from .dlg_db_error import DlgDbError
|
||||
@ -47,15 +48,12 @@ class InfoViewer(QTextBrowser):
|
||||
return
|
||||
|
||||
if url.scheme() == "action":
|
||||
QApplication.setOverrideCursor(Qt.WaitCursor)
|
||||
try:
|
||||
if self.item.runAction(url.path()):
|
||||
self.refresh()
|
||||
except BaseError as e:
|
||||
DlgDbError.showError(e, self)
|
||||
return
|
||||
finally:
|
||||
QApplication.restoreOverrideCursor()
|
||||
with OverrideCursor(Qt.WaitCursor):
|
||||
try:
|
||||
if self.item.runAction(url.path()):
|
||||
self.refresh()
|
||||
except BaseError as e:
|
||||
DlgDbError.showError(e, self)
|
||||
|
||||
def refresh(self):
|
||||
self.setDirty(True)
|
||||
|
@ -26,6 +26,7 @@ from qgis.PyQt.QtWidgets import QApplication
|
||||
|
||||
from qgis.gui import QgsMapCanvas, QgsMessageBar
|
||||
from qgis.core import QgsVectorLayer, QgsProject, QgsSettings
|
||||
from qgis.utils import OverrideCursor
|
||||
|
||||
from .db_plugins.plugin import Table
|
||||
|
||||
@ -89,45 +90,44 @@ class LayerPreview(QgsMapCanvas):
|
||||
|
||||
def _loadTablePreview(self, table, limit=False):
|
||||
""" if has geometry column load to map canvas """
|
||||
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
|
||||
self.freeze()
|
||||
vl = None
|
||||
with OverrideCursor(Qt.WaitCursor):
|
||||
self.freeze()
|
||||
vl = None
|
||||
|
||||
if table and table.geomType:
|
||||
# limit the query result if required
|
||||
if limit and table.rowCount > 1000:
|
||||
uniqueField = table.getValidQgisUniqueFields(True)
|
||||
if uniqueField is None:
|
||||
self.parent.tabs.setCurrentWidget(self.parent.info)
|
||||
self.parent.infoBar.pushMessage(
|
||||
QApplication.translate("DBManagerPlugin", "Unable to find a valid unique field"),
|
||||
QgsMessageBar.WARNING, self.parent.iface.messageTimeout())
|
||||
return
|
||||
if table and table.geomType:
|
||||
# limit the query result if required
|
||||
if limit and table.rowCount > 1000:
|
||||
uniqueField = table.getValidQgisUniqueFields(True)
|
||||
if uniqueField is None:
|
||||
self.parent.tabs.setCurrentWidget(self.parent.info)
|
||||
self.parent.infoBar.pushMessage(
|
||||
QApplication.translate("DBManagerPlugin", "Unable to find a valid unique field"),
|
||||
QgsMessageBar.WARNING, self.parent.iface.messageTimeout())
|
||||
return
|
||||
|
||||
uri = table.database().uri()
|
||||
uri.setDataSource("", u"(SELECT * FROM %s LIMIT 1000)" % table.quotedName(), table.geomColumn, "",
|
||||
uniqueField.name)
|
||||
provider = table.database().dbplugin().providerName()
|
||||
vl = QgsVectorLayer(uri.uri(False), table.name, provider)
|
||||
uri = table.database().uri()
|
||||
uri.setDataSource("", u"(SELECT * FROM %s LIMIT 1000)" % table.quotedName(), table.geomColumn, "",
|
||||
uniqueField.name)
|
||||
provider = table.database().dbplugin().providerName()
|
||||
vl = QgsVectorLayer(uri.uri(False), table.name, provider)
|
||||
else:
|
||||
vl = table.toMapLayer()
|
||||
|
||||
if not vl.isValid():
|
||||
vl.deleteLater()
|
||||
vl = None
|
||||
|
||||
# remove old layer (if any) and set new
|
||||
if self.currentLayer:
|
||||
QgsProject.instance().removeMapLayers([self.currentLayer.id()])
|
||||
|
||||
if vl:
|
||||
self.setLayers([vl])
|
||||
QgsProject.instance().addMapLayers([vl], False)
|
||||
self.zoomToFullExtent()
|
||||
else:
|
||||
vl = table.toMapLayer()
|
||||
self.setLayers([])
|
||||
|
||||
if not vl.isValid():
|
||||
vl.deleteLater()
|
||||
vl = None
|
||||
self.currentLayer = vl
|
||||
|
||||
# remove old layer (if any) and set new
|
||||
if self.currentLayer:
|
||||
QgsProject.instance().removeMapLayers([self.currentLayer.id()])
|
||||
|
||||
if vl:
|
||||
self.setLayers([vl])
|
||||
QgsProject.instance().addMapLayers([vl], False)
|
||||
self.zoomToFullExtent()
|
||||
else:
|
||||
self.setLayers([])
|
||||
|
||||
self.currentLayer = vl
|
||||
|
||||
self.freeze(False)
|
||||
QApplication.restoreOverrideCursor()
|
||||
self.freeze(False)
|
||||
|
@ -24,6 +24,8 @@ from qgis.PyQt.QtCore import Qt
|
||||
from qgis.PyQt.QtWidgets import QTableView, QAbstractItemView, QApplication, QAction
|
||||
from qgis.PyQt.QtGui import QKeySequence, QCursor, QClipboard
|
||||
|
||||
from qgis.utils import OverrideCursor
|
||||
|
||||
from .db_plugins.plugin import DbError, Table
|
||||
from .dlg_db_error import DlgDbError
|
||||
|
||||
@ -86,20 +88,14 @@ class TableViewer(QTableView):
|
||||
model.deleteLater()
|
||||
|
||||
def _loadTableData(self, table):
|
||||
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
|
||||
try:
|
||||
# set the new model
|
||||
self.setModel(table.tableDataModel(self))
|
||||
|
||||
except DbError as e:
|
||||
DlgDbError.showError(e, self)
|
||||
return
|
||||
|
||||
else:
|
||||
self.update()
|
||||
|
||||
finally:
|
||||
QApplication.restoreOverrideCursor()
|
||||
with OverrideCursor(Qt.WaitCursor):
|
||||
try:
|
||||
# set the new model
|
||||
self.setModel(table.tableDataModel(self))
|
||||
except DbError as e:
|
||||
DlgDbError.showError(e, self)
|
||||
else:
|
||||
self.update()
|
||||
|
||||
def copySelectedResults(self):
|
||||
if len(self.selectedIndexes()) <= 0:
|
||||
|
@ -33,7 +33,8 @@ from qgis.PyQt.QtWidgets import (QWidget,
|
||||
QLineEdit,
|
||||
QComboBox,
|
||||
QCheckBox,
|
||||
QSizePolicy)
|
||||
QSizePolicy,
|
||||
QDialogButtonBox)
|
||||
|
||||
from qgis.gui import QgsMessageBar
|
||||
|
||||
@ -57,15 +58,9 @@ class GdalAlgorithmDialog(AlgorithmDialog):
|
||||
|
||||
self.setMainWidget(GdalParametersPanel(self, alg))
|
||||
|
||||
cornerWidget = QWidget()
|
||||
layout = QVBoxLayout()
|
||||
layout.setContentsMargins(0, 0, 0, 5)
|
||||
self.tabWidget.setStyleSheet("QTabBar::tab { height: 30px; }")
|
||||
runAsBatchButton = QPushButton(self.tr("Run as batch process..."))
|
||||
runAsBatchButton.clicked.connect(self.runAsBatch)
|
||||
layout.addWidget(runAsBatchButton)
|
||||
cornerWidget.setLayout(layout)
|
||||
self.tabWidget.setCornerWidget(cornerWidget)
|
||||
self.runAsBatchButton = QPushButton(self.tr("Run as Batch Process…"))
|
||||
self.runAsBatchButton.clicked.connect(self.runAsBatch)
|
||||
self.buttonBox.addButton(self.runAsBatchButton, QDialogButtonBox.ResetRole) # reset role to ensure left alignment
|
||||
|
||||
self.mainWidget.parametersHaveChanged()
|
||||
|
||||
|
12
python/plugins/processing/algs/gdal/GdalUtils.py
Normal file → Executable file
12
python/plugins/processing/algs/gdal/GdalUtils.py
Normal file → Executable file
@ -45,13 +45,13 @@ from processing.tools.system import isWindows, isMac
|
||||
|
||||
try:
|
||||
from osgeo import gdal # NOQA
|
||||
|
||||
gdalAvailable = True
|
||||
except:
|
||||
gdalAvailable = False
|
||||
|
||||
|
||||
class GdalUtils(object):
|
||||
|
||||
GDAL_HELP_PATH = 'GDAL_HELP_PATH'
|
||||
|
||||
supportedRasters = None
|
||||
@ -106,7 +106,9 @@ class GdalUtils(object):
|
||||
if retry_count < 5:
|
||||
retry_count += 1
|
||||
else:
|
||||
raise IOError(e.message + u'\nTried 5 times without success. Last iteration stopped after reading {} line(s).\nLast line(s):\n{}'.format(len(loglines), u'\n'.join(loglines[-10:])))
|
||||
raise IOError(
|
||||
e.message + u'\nTried 5 times without success. Last iteration stopped after reading {} line(s).\nLast line(s):\n{}'.format(
|
||||
len(loglines), u'\n'.join(loglines[-10:])))
|
||||
|
||||
QgsMessageLog.logMessage('\n'.join(loglines), 'Processing', QgsMessageLog.INFO)
|
||||
GdalUtils.consoleOutput = loglines
|
||||
@ -134,6 +136,10 @@ class GdalUtils(object):
|
||||
continue
|
||||
shortName = driver.ShortName
|
||||
metadata = driver.GetMetadata()
|
||||
if gdal.DCAP_RASTER not in metadata \
|
||||
or metadata[gdal.DCAP_RASTER] != 'YES':
|
||||
continue
|
||||
|
||||
# ===================================================================
|
||||
# if gdal.DCAP_CREATE not in metadata \
|
||||
# or metadata[gdal.DCAP_CREATE] != 'YES':
|
||||
@ -183,7 +189,7 @@ class GdalUtils(object):
|
||||
for s in strList:
|
||||
if s and s[0] != '-' and ' ' in s:
|
||||
escaped = '"' + s.replace('\\', '\\\\').replace('"', '\\"') \
|
||||
+ '"'
|
||||
+ '"'
|
||||
else:
|
||||
escaped = s
|
||||
joined += escaped + ' '
|
||||
|
@ -160,6 +160,9 @@ qgis:distancetonearesthub: >
|
||||
qgis:dropgeometries: >
|
||||
This algorithm removes any geometries from an input layer and returns a layer containing only the feature attributes.
|
||||
|
||||
qgis:dropmzvalues: >
|
||||
This algorithm can remove any measure (M) or Z values from input geometries.
|
||||
|
||||
qgis:eliminateselectedpolygons: >
|
||||
This algorithm combines selected polygons of the input layer with certain adjacent polygons by erasing their common boundary. The adjacent polygon can be either the one with the largest or smallest area or the one sharing the largest common boundary with the polygon to be eliminated. The selected features will always be eliminated whether the option "Use only selected features" is set or not.
|
||||
Eliminate is normally used to get rid of sliver polygons, i.e. tiny polygons that are a result of polygon intersection processes where boundaries of the inputs are similar but not identical.
|
||||
@ -503,6 +506,10 @@ qgis:selectbyexpression: >
|
||||
qgis:selectbylocation: >
|
||||
This algorithm creates a selection in a vector layer. The criteria for selecting features is based on the spatial relationship between each feature and the features in an additional layer.
|
||||
|
||||
qgis:setmvalue: >
|
||||
This algorithm sets the M value for geometries in a layer.
|
||||
|
||||
If M values already exist in the layer, they will be overwritten with the new value. If no M values exist, the geometry will be upgraded to include M values and the specified value used as the initial M value for all geometries.
|
||||
|
||||
qgis:setstyleforrasterlayer: >
|
||||
This algorithm sets the style of a raster layer. The style must be defined in a QML file.
|
||||
@ -510,6 +517,11 @@ qgis:setstyleforrasterlayer: >
|
||||
qgis:setstyleforvectorlayer: >
|
||||
This algorithm sets the style of a vector layer. The style must be defined in a QML file.
|
||||
|
||||
qgis:setzvalue: >
|
||||
This algorithm sets the Z value for geometries in a layer.
|
||||
|
||||
If Z values already exist in the layer, they will be overwritten with the new value. If no Z values exist, the geometry will be upgraded to include Z values and the specified value used as the initial Z value for all geometries.
|
||||
|
||||
qgis:simplifygeometries: >
|
||||
This algorithm simplifies the geometries in a line or polygon layer. It creates a new layer with the same features as the ones in the input layer, but with geometries containing a lower number of vertices.
|
||||
|
||||
|
@ -27,19 +27,14 @@ __revision__ = '$Format:%H$'
|
||||
|
||||
from qgis.PyQt.QtCore import QVariant
|
||||
from qgis.core import (QgsField,
|
||||
QgsFeatureSink,
|
||||
QgsProcessingParameterFeatureSource,
|
||||
QgsProcessingParameterString,
|
||||
QgsProcessingParameterNumber,
|
||||
QgsProcessingParameterEnum,
|
||||
QgsProcessingParameterFeatureSink)
|
||||
from processing.algs.qgis.QgisAlgorithm import QgisAlgorithm
|
||||
QgsProcessingParameterEnum)
|
||||
from processing.algs.qgis.QgisAlgorithm import QgisFeatureBasedAlgorithm
|
||||
|
||||
|
||||
class AddTableField(QgisAlgorithm):
|
||||
class AddTableField(QgisFeatureBasedAlgorithm):
|
||||
|
||||
OUTPUT_LAYER = 'OUTPUT_LAYER'
|
||||
INPUT_LAYER = 'INPUT_LAYER'
|
||||
FIELD_NAME = 'FIELD_NAME'
|
||||
FIELD_TYPE = 'FIELD_TYPE'
|
||||
FIELD_LENGTH = 'FIELD_LENGTH'
|
||||
@ -55,10 +50,9 @@ class AddTableField(QgisAlgorithm):
|
||||
self.type_names = [self.tr('Integer'),
|
||||
self.tr('Float'),
|
||||
self.tr('String')]
|
||||
self.field = None
|
||||
|
||||
def initAlgorithm(self, config=None):
|
||||
self.addParameter(QgsProcessingParameterFeatureSource(self.INPUT_LAYER,
|
||||
self.tr('Input layer')))
|
||||
def initParameters(self, config=None):
|
||||
self.addParameter(QgsProcessingParameterString(self.FIELD_NAME,
|
||||
self.tr('Field name')))
|
||||
self.addParameter(QgsProcessingParameterEnum(self.FIELD_TYPE,
|
||||
@ -68,7 +62,6 @@ class AddTableField(QgisAlgorithm):
|
||||
10, False, 1, 255))
|
||||
self.addParameter(QgsProcessingParameterNumber(self.FIELD_PRECISION,
|
||||
self.tr('Field precision'), QgsProcessingParameterNumber.Integer, 0, False, 0, 10))
|
||||
self.addParameter(QgsProcessingParameterFeatureSink(self.OUTPUT_LAYER, self.tr('Added')))
|
||||
|
||||
def name(self):
|
||||
return 'addfieldtoattributestable'
|
||||
@ -76,33 +69,25 @@ class AddTableField(QgisAlgorithm):
|
||||
def displayName(self):
|
||||
return self.tr('Add field to attributes table')
|
||||
|
||||
def processAlgorithm(self, parameters, context, feedback):
|
||||
source = self.parameterAsSource(parameters, self.INPUT_LAYER, context)
|
||||
def outputName(self):
|
||||
return self.tr('Added')
|
||||
|
||||
fieldType = self.parameterAsEnum(parameters, self.FIELD_TYPE, context)
|
||||
fieldName = self.parameterAsString(parameters, self.FIELD_NAME, context)
|
||||
fieldLength = self.parameterAsInt(parameters, self.FIELD_LENGTH, context)
|
||||
fieldPrecision = self.parameterAsInt(parameters, self.FIELD_PRECISION, context)
|
||||
def prepareAlgorithm(self, parameters, context, feedback):
|
||||
field_type = self.parameterAsEnum(parameters, self.FIELD_TYPE, context)
|
||||
field_name = self.parameterAsString(parameters, self.FIELD_NAME, context)
|
||||
field_length = self.parameterAsInt(parameters, self.FIELD_LENGTH, context)
|
||||
field_precision = self.parameterAsInt(parameters, self.FIELD_PRECISION, context)
|
||||
|
||||
fields = source.fields()
|
||||
fields.append(QgsField(fieldName, self.TYPES[fieldType], '',
|
||||
fieldLength, fieldPrecision))
|
||||
(sink, dest_id) = self.parameterAsSink(parameters, self.OUTPUT_LAYER, context,
|
||||
fields, source.wkbType(), source.sourceCrs())
|
||||
self.field = QgsField(field_name, self.TYPES[field_type], '',
|
||||
field_length, field_precision)
|
||||
return True
|
||||
|
||||
features = source.getFeatures()
|
||||
total = 100.0 / source.featureCount() if source.featureCount() else 0
|
||||
def outputFields(self, inputFields):
|
||||
inputFields.append(self.field)
|
||||
return inputFields
|
||||
|
||||
for current, input_feature in enumerate(features):
|
||||
if feedback.isCanceled():
|
||||
break
|
||||
|
||||
output_feature = input_feature
|
||||
attributes = input_feature.attributes()
|
||||
attributes.append(None)
|
||||
output_feature.setAttributes(attributes)
|
||||
|
||||
sink.addFeature(output_feature, QgsFeatureSink.FastInsert)
|
||||
feedback.setProgress(int(current * total))
|
||||
|
||||
return {self.OUTPUT_LAYER: dest_id}
|
||||
def processFeature(self, feature, feedback):
|
||||
attributes = feature.attributes()
|
||||
attributes.append(None)
|
||||
feature.setAttributes(attributes)
|
||||
return feature
|
||||
|
@ -26,26 +26,15 @@ __copyright__ = '(C) 2012, Victor Olaya'
|
||||
__revision__ = '$Format:%H$'
|
||||
|
||||
from qgis.PyQt.QtCore import QVariant
|
||||
from qgis.core import (QgsField,
|
||||
QgsFeatureSink,
|
||||
QgsProcessingParameterFeatureSource,
|
||||
QgsProcessingParameterFeatureSink)
|
||||
from processing.algs.qgis.QgisAlgorithm import QgisAlgorithm
|
||||
from qgis.core import (QgsField)
|
||||
from processing.algs.qgis.QgisAlgorithm import QgisFeatureBasedAlgorithm
|
||||
|
||||
|
||||
class AutoincrementalField(QgisAlgorithm):
|
||||
|
||||
INPUT = 'INPUT'
|
||||
OUTPUT = 'OUTPUT'
|
||||
class AutoincrementalField(QgisFeatureBasedAlgorithm):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
def initAlgorithm(self, config=None):
|
||||
self.addParameter(QgsProcessingParameterFeatureSource(self.INPUT,
|
||||
self.tr('Input layer')))
|
||||
|
||||
self.addParameter(QgsProcessingParameterFeatureSink(self.OUTPUT, self.tr('Incremented')))
|
||||
self.current = 0
|
||||
|
||||
def group(self):
|
||||
return self.tr('Vector table tools')
|
||||
@ -56,26 +45,16 @@ class AutoincrementalField(QgisAlgorithm):
|
||||
def displayName(self):
|
||||
return self.tr('Add autoincremental field')
|
||||
|
||||
def processAlgorithm(self, parameters, context, feedback):
|
||||
source = self.parameterAsSource(parameters, self.INPUT, context)
|
||||
fields = source.fields()
|
||||
fields.append(QgsField('AUTO', QVariant.Int))
|
||||
def outputName(self):
|
||||
return self.tr('Incremented')
|
||||
|
||||
(sink, dest_id) = self.parameterAsSink(parameters, self.OUTPUT, context,
|
||||
fields, source.wkbType(), source.sourceCrs())
|
||||
def outputFields(self, inputFields):
|
||||
inputFields.append(QgsField('AUTO', QVariant.Int))
|
||||
return inputFields
|
||||
|
||||
features = source.getFeatures()
|
||||
total = 100.0 / source.featureCount() if source.featureCount() else 0
|
||||
for current, input_feature in enumerate(features):
|
||||
if feedback.isCanceled():
|
||||
break
|
||||
|
||||
output_feature = input_feature
|
||||
attributes = input_feature.attributes()
|
||||
attributes.append(current)
|
||||
output_feature.setAttributes(attributes)
|
||||
|
||||
sink.addFeature(output_feature, QgsFeatureSink.FastInsert)
|
||||
feedback.setProgress(int(current * total))
|
||||
|
||||
return {self.OUTPUT: dest_id}
|
||||
def processFeature(self, feature, feedback):
|
||||
attributes = feature.attributes()
|
||||
attributes.append(self.current)
|
||||
self.current += 1
|
||||
feature.setAttributes(attributes)
|
||||
return feature
|
||||
|
@ -28,31 +28,20 @@ __revision__ = '$Format:%H$'
|
||||
import os
|
||||
|
||||
from qgis.core import (QgsGeometry,
|
||||
QgsWkbTypes,
|
||||
QgsFeatureSink,
|
||||
QgsProcessing,
|
||||
QgsProcessingParameterFeatureSource,
|
||||
QgsProcessingParameterFeatureSink)
|
||||
QgsWkbTypes)
|
||||
|
||||
from qgis.PyQt.QtGui import QIcon
|
||||
|
||||
from processing.algs.qgis.QgisAlgorithm import QgisAlgorithm
|
||||
from processing.algs.qgis.QgisAlgorithm import QgisFeatureBasedAlgorithm
|
||||
|
||||
pluginPath = os.path.split(os.path.split(os.path.dirname(__file__))[0])[0]
|
||||
|
||||
|
||||
class Boundary(QgisAlgorithm):
|
||||
|
||||
INPUT_LAYER = 'INPUT_LAYER'
|
||||
OUTPUT_LAYER = 'OUTPUT_LAYER'
|
||||
class Boundary(QgisFeatureBasedAlgorithm):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
def initAlgorithm(self, config=None):
|
||||
self.addParameter(QgsProcessingParameterFeatureSource(self.INPUT_LAYER, self.tr('Input layer'), [QgsProcessing.TypeVectorLine, QgsProcessing.TypeVectorPolygon]))
|
||||
self.addParameter(QgsProcessingParameterFeatureSink(self.OUTPUT_LAYER, self.tr('Boundary')))
|
||||
|
||||
def icon(self):
|
||||
return QIcon(os.path.join(pluginPath, 'images', 'ftools', 'convex_hull.png'))
|
||||
|
||||
@ -65,10 +54,10 @@ class Boundary(QgisAlgorithm):
|
||||
def displayName(self):
|
||||
return self.tr('Boundary')
|
||||
|
||||
def processAlgorithm(self, parameters, context, feedback):
|
||||
source = self.parameterAsSource(parameters, self.INPUT_LAYER, context)
|
||||
def outputName(self):
|
||||
return self.tr('Boundary')
|
||||
|
||||
input_wkb = source.wkbType()
|
||||
def outputWkbType(self, input_wkb):
|
||||
if QgsWkbTypes.geometryType(input_wkb) == QgsWkbTypes.LineGeometry:
|
||||
output_wkb = QgsWkbTypes.MultiPoint
|
||||
elif QgsWkbTypes.geometryType(input_wkb) == QgsWkbTypes.PolygonGeometry:
|
||||
@ -78,26 +67,15 @@ class Boundary(QgisAlgorithm):
|
||||
if QgsWkbTypes.hasM(input_wkb):
|
||||
output_wkb = QgsWkbTypes.addM(output_wkb)
|
||||
|
||||
(sink, dest_id) = self.parameterAsSink(parameters, self.OUTPUT_LAYER, context,
|
||||
source.fields(), output_wkb, source.sourceCrs())
|
||||
return output_wkb
|
||||
|
||||
features = source.getFeatures()
|
||||
total = 100.0 / source.featureCount() if source.featureCount() else 0
|
||||
|
||||
for current, input_feature in enumerate(features):
|
||||
if feedback.isCanceled():
|
||||
break
|
||||
output_feature = input_feature
|
||||
input_geometry = input_feature.geometry()
|
||||
if input_geometry:
|
||||
output_geometry = QgsGeometry(input_geometry.geometry().boundary())
|
||||
if not output_geometry:
|
||||
feedback.reportError(self.tr('No boundary for feature {} (possibly a closed linestring?)').format(input_feature.id()))
|
||||
output_feature.clearGeometry()
|
||||
else:
|
||||
output_feature.setGeometry(output_geometry)
|
||||
|
||||
sink.addFeature(output_feature, QgsFeatureSink.FastInsert)
|
||||
feedback.setProgress(int(current * total))
|
||||
|
||||
return {self.OUTPUT_LAYER: dest_id}
|
||||
def processFeature(self, feature, feedback):
|
||||
input_geometry = feature.geometry()
|
||||
if input_geometry:
|
||||
output_geometry = QgsGeometry(input_geometry.geometry().boundary())
|
||||
if not output_geometry:
|
||||
feedback.reportError(self.tr('No boundary for feature {} (possibly a closed linestring?)').format(feature.id()))
|
||||
feature.clearGeometry()
|
||||
else:
|
||||
feature.setGeometry(output_geometry)
|
||||
return feature
|
||||
|
@ -29,24 +29,17 @@ import os
|
||||
|
||||
from qgis.core import (QgsGeometry,
|
||||
QgsWkbTypes,
|
||||
QgsFeatureSink,
|
||||
QgsProcessing,
|
||||
QgsProcessingException,
|
||||
QgsProcessingParameterFeatureSource,
|
||||
QgsProcessingParameterFeatureSink)
|
||||
QgsProcessingException)
|
||||
|
||||
|
||||
from qgis.PyQt.QtGui import QIcon
|
||||
|
||||
from processing.algs.qgis.QgisAlgorithm import QgisAlgorithm
|
||||
from processing.algs.qgis.QgisAlgorithm import QgisFeatureBasedAlgorithm
|
||||
|
||||
pluginPath = os.path.split(os.path.split(os.path.dirname(__file__))[0])[0]
|
||||
|
||||
|
||||
class BoundingBox(QgisAlgorithm):
|
||||
|
||||
INPUT_LAYER = 'INPUT_LAYER'
|
||||
OUTPUT_LAYER = 'OUTPUT_LAYER'
|
||||
class BoundingBox(QgisFeatureBasedAlgorithm):
|
||||
|
||||
def icon(self):
|
||||
return QIcon(os.path.join(pluginPath, 'images', 'ftools', 'matrix.png'))
|
||||
@ -57,39 +50,26 @@ class BoundingBox(QgisAlgorithm):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
def initAlgorithm(self, config=None):
|
||||
self.addParameter(QgsProcessingParameterFeatureSource(self.INPUT_LAYER, self.tr('Input layer')))
|
||||
self.addParameter(QgsProcessingParameterFeatureSink(self.OUTPUT_LAYER, self.tr('Bounds'), QgsProcessing.TypeVectorPolygon))
|
||||
|
||||
def name(self):
|
||||
return 'boundingboxes'
|
||||
|
||||
def displayName(self):
|
||||
return self.tr('Bounding boxes')
|
||||
|
||||
def processAlgorithm(self, parameters, context, feedback):
|
||||
source = self.parameterAsSource(parameters, self.INPUT_LAYER, context)
|
||||
def outputName(self):
|
||||
return self.tr('Bounds')
|
||||
|
||||
(sink, dest_id) = self.parameterAsSink(parameters, self.OUTPUT_LAYER, context,
|
||||
source.fields(), QgsWkbTypes.Polygon, source.sourceCrs())
|
||||
def outputWkbType(self, inputWkb):
|
||||
return QgsWkbTypes.Polygon
|
||||
|
||||
features = source.getFeatures()
|
||||
total = 100.0 / source.featureCount() if source.featureCount() else 0
|
||||
def processFeature(self, feature, feedback):
|
||||
input_geometry = feature.geometry()
|
||||
if input_geometry:
|
||||
output_geometry = QgsGeometry.fromRect(input_geometry.boundingBox())
|
||||
if not output_geometry:
|
||||
raise QgsProcessingException(
|
||||
self.tr('Error calculating bounding box'))
|
||||
|
||||
for current, input_feature in enumerate(features):
|
||||
if feedback.isCanceled():
|
||||
break
|
||||
output_feature = input_feature
|
||||
input_geometry = input_feature.geometry()
|
||||
if input_geometry:
|
||||
output_geometry = QgsGeometry.fromRect(input_geometry.boundingBox())
|
||||
if not output_geometry:
|
||||
raise QgsProcessingException(
|
||||
self.tr('Error calculating bounding box'))
|
||||
feature.setGeometry(output_geometry)
|
||||
|
||||
output_feature.setGeometry(output_geometry)
|
||||
|
||||
sink.addFeature(output_feature, QgsFeatureSink.FastInsert)
|
||||
feedback.setProgress(int(current * total))
|
||||
|
||||
return {self.OUTPUT_LAYER: dest_id}
|
||||
return feature
|
||||
|
@ -25,25 +25,35 @@ __copyright__ = '(C) 2012, Victor Olaya'
|
||||
|
||||
__revision__ = '$Format:%H$'
|
||||
|
||||
from qgis.core import QgsFeature, QgsGeometry, QgsProcessingUtils
|
||||
from qgis.core import (QgsFeature,
|
||||
QgsGeometry,
|
||||
QgsFeatureRequest,
|
||||
QgsFeatureSink)
|
||||
|
||||
|
||||
def buffering(feedback, context, writer, distance, field, useField, layer, dissolve, segments, endCapStyle=1,
|
||||
def buffering(feedback, context, sink, distance, field, useField, source, dissolve, segments, endCapStyle=1,
|
||||
joinStyle=1, mitreLimit=2):
|
||||
|
||||
if useField:
|
||||
field = layer.fields().lookupField(field)
|
||||
field = source.fields().lookupField(field)
|
||||
|
||||
outFeat = QgsFeature()
|
||||
|
||||
current = 0
|
||||
features = QgsProcessingUtils.getFeatures(layer, context)
|
||||
total = 100.0 / layer.featureCount() if layer.featureCount() else 0
|
||||
total = 100.0 / source.featureCount() if source.featureCount() else 0
|
||||
|
||||
# With dissolve
|
||||
if dissolve:
|
||||
attributes_to_fetch = []
|
||||
if useField:
|
||||
attributes_to_fetch.append(field)
|
||||
|
||||
features = source.getFeatures(QgsFeatureRequest().setSubsetOfAttributes(attributes_to_fetch))
|
||||
buffered_geometries = []
|
||||
for inFeat in features:
|
||||
if feedback.isCanceled():
|
||||
break
|
||||
|
||||
attrs = inFeat.attributes()
|
||||
if useField:
|
||||
value = attrs[field]
|
||||
@ -60,10 +70,15 @@ def buffering(feedback, context, writer, distance, field, useField, layer, disso
|
||||
final_geometry = QgsGeometry.unaryUnion(buffered_geometries)
|
||||
outFeat.setGeometry(final_geometry)
|
||||
outFeat.setAttributes(attrs)
|
||||
writer.addFeature(outFeat, QgsFeatureSink.FastInsert)
|
||||
sink.addFeature(outFeat, QgsFeatureSink.FastInsert)
|
||||
else:
|
||||
|
||||
features = source.getFeatures()
|
||||
|
||||
# Without dissolve
|
||||
for inFeat in features:
|
||||
if feedback.isCanceled():
|
||||
break
|
||||
attrs = inFeat.attributes()
|
||||
if useField:
|
||||
value = attrs[field]
|
||||
@ -74,8 +89,6 @@ def buffering(feedback, context, writer, distance, field, useField, layer, disso
|
||||
outGeom = inGeom.buffer(float(value), segments, endCapStyle, joinStyle, mitreLimit)
|
||||
outFeat.setGeometry(outGeom)
|
||||
outFeat.setAttributes(attrs)
|
||||
writer.addFeature(outFeat, QgsFeatureSink.FastInsert)
|
||||
sink.addFeature(outFeat, QgsFeatureSink.FastInsert)
|
||||
current += 1
|
||||
feedback.setProgress(int(current * total))
|
||||
|
||||
del writer
|
||||
|
@ -36,15 +36,16 @@ from qgis.core import (QgsField,
|
||||
QgsFeatureSink,
|
||||
QgsGeometry,
|
||||
QgsWkbTypes,
|
||||
QgsProcessingUtils,
|
||||
QgsFields)
|
||||
QgsFeatureRequest,
|
||||
QgsFields,
|
||||
NULL,
|
||||
QgsProcessingParameterFeatureSource,
|
||||
QgsProcessingParameterField,
|
||||
QgsProcessingParameterFeatureSink,
|
||||
QgsProcessing,
|
||||
QgsProcessingException)
|
||||
|
||||
from processing.algs.qgis.QgisAlgorithm import QgisAlgorithm
|
||||
from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
|
||||
from processing.core.parameters import ParameterVector
|
||||
from processing.core.parameters import ParameterTableField
|
||||
from processing.core.parameters import ParameterSelection
|
||||
from processing.core.outputs import OutputVector
|
||||
from processing.tools import dataobjects, vector
|
||||
|
||||
pluginPath = os.path.split(os.path.split(os.path.dirname(__file__))[0])[0]
|
||||
@ -55,7 +56,6 @@ class ConvexHull(QgisAlgorithm):
|
||||
INPUT = 'INPUT'
|
||||
OUTPUT = 'OUTPUT'
|
||||
FIELD = 'FIELD'
|
||||
METHOD = 'METHOD'
|
||||
|
||||
def icon(self):
|
||||
return QIcon(os.path.join(pluginPath, 'images', 'ftools', 'convex_hull.png'))
|
||||
@ -67,17 +67,12 @@ class ConvexHull(QgisAlgorithm):
|
||||
super().__init__()
|
||||
|
||||
def initAlgorithm(self, config=None):
|
||||
self.methods = [self.tr('Create single minimum convex hull'),
|
||||
self.tr('Create convex hulls based on field')]
|
||||
|
||||
self.addParameter(ParameterVector(self.INPUT,
|
||||
self.tr('Input layer')))
|
||||
self.addParameter(ParameterTableField(self.FIELD,
|
||||
self.tr('Field (optional, only used if creating convex hulls by classes)'),
|
||||
self.INPUT, optional=True))
|
||||
self.addParameter(ParameterSelection(self.METHOD,
|
||||
self.tr('Method'), self.methods))
|
||||
self.addOutput(OutputVector(self.OUTPUT, self.tr('Convex hull'), datatype=[dataobjects.TYPE_VECTOR_POLYGON]))
|
||||
self.addParameter(QgsProcessingParameterFeatureSource(self.INPUT,
|
||||
self.tr('Input layer')))
|
||||
self.addParameter(QgsProcessingParameterField(self.FIELD,
|
||||
self.tr('Field (optional, set if creating convex hulls by classes)'),
|
||||
parentLayerParameterName=self.INPUT, optional=True))
|
||||
self.addParameter(QgsProcessingParameterFeatureSink(self.OUTPUT, self.tr('Convex hull'), QgsProcessing.TypeVectorPolygon))
|
||||
|
||||
def name(self):
|
||||
return 'convexhull'
|
||||
@ -86,14 +81,15 @@ class ConvexHull(QgisAlgorithm):
|
||||
return self.tr('Convex hull')
|
||||
|
||||
def processAlgorithm(self, parameters, context, feedback):
|
||||
layer = QgsProcessingUtils.mapLayerFromString(self.getParameterValue(self.INPUT), context)
|
||||
useField = self.getParameterValue(self.METHOD) == 1
|
||||
fieldName = self.getParameterValue(self.FIELD)
|
||||
source = self.parameterAsSource(parameters, self.INPUT, context)
|
||||
fieldName = self.parameterAsString(parameters, self.FIELD, context)
|
||||
useField = bool(fieldName)
|
||||
|
||||
field_index = None
|
||||
f = QgsField('value', QVariant.String, '', 255)
|
||||
if useField:
|
||||
index = layer.fields().lookupField(fieldName)
|
||||
fType = layer.fields()[index].type()
|
||||
field_index = source.fields().lookupField(fieldName)
|
||||
fType = source.fields()[field_index].type()
|
||||
if fType in [QVariant.Int, QVariant.UInt, QVariant.LongLong, QVariant.ULongLong]:
|
||||
f.setType(fType)
|
||||
f.setLength(20)
|
||||
@ -111,25 +107,30 @@ class ConvexHull(QgisAlgorithm):
|
||||
fields.append(QgsField('area', QVariant.Double, '', 20, 6))
|
||||
fields.append(QgsField('perim', QVariant.Double, '', 20, 6))
|
||||
|
||||
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(fields, QgsWkbTypes.Polygon, layer.crs(), context)
|
||||
(sink, dest_id) = self.parameterAsSink(parameters, self.OUTPUT, context,
|
||||
fields, QgsWkbTypes.Polygon, source.sourceCrs())
|
||||
|
||||
outFeat = QgsFeature()
|
||||
inGeom = QgsGeometry()
|
||||
outGeom = QgsGeometry()
|
||||
|
||||
fid = 0
|
||||
val = None
|
||||
features = QgsProcessingUtils.getFeatures(layer, context)
|
||||
if useField:
|
||||
unique = layer.uniqueValues(index)
|
||||
unique = source.uniqueValues(field_index)
|
||||
current = 0
|
||||
total = 100.0 / (layer.featureCount() * len(unique)) if layer.featureCount() else 1
|
||||
total = 100.0 / (source.featureCount() * len(unique)) if source.featureCount() else 1
|
||||
for i in unique:
|
||||
if feedback.isCanceled():
|
||||
break
|
||||
|
||||
first = True
|
||||
hull = []
|
||||
features = QgsProcessingUtils.getFeatures(layer, context)
|
||||
features = source.getFeatures(QgsFeatureRequest().setSubsetOfAttributes([field_index]))
|
||||
for f in features:
|
||||
idVar = f[fieldName]
|
||||
if feedback.isCanceled():
|
||||
break
|
||||
|
||||
idVar = f.attributes()[field_index]
|
||||
if str(idVar).strip() == str(i).strip():
|
||||
if first:
|
||||
val = idVar
|
||||
@ -145,19 +146,27 @@ class ConvexHull(QgisAlgorithm):
|
||||
tmpGeom = QgsGeometry(outGeom.fromMultiPoint(hull))
|
||||
try:
|
||||
outGeom = tmpGeom.convexHull()
|
||||
(area, perim) = vector.simpleMeasure(outGeom)
|
||||
if outGeom:
|
||||
area = outGeom.geometry().area()
|
||||
perim = outGeom.geometry().perimeter()
|
||||
else:
|
||||
area = NULL
|
||||
perim = NULL
|
||||
outFeat.setGeometry(outGeom)
|
||||
outFeat.setAttributes([fid, val, area, perim])
|
||||
writer.addFeature(outFeat, QgsFeatureSink.FastInsert)
|
||||
sink.addFeature(outFeat, QgsFeatureSink.FastInsert)
|
||||
except:
|
||||
raise GeoAlgorithmExecutionException(
|
||||
raise QgsProcessingException(
|
||||
self.tr('Exception while computing convex hull'))
|
||||
fid += 1
|
||||
else:
|
||||
hull = []
|
||||
total = 100.0 / layer.featureCount() if layer.featureCount() else 1
|
||||
features = QgsProcessingUtils.getFeatures(layer, context)
|
||||
total = 100.0 / source.featureCount() if source.featureCount() else 1
|
||||
features = source.getFeatures(QgsFeatureRequest().setSubsetOfAttributes([]))
|
||||
for current, f in enumerate(features):
|
||||
if feedback.isCanceled():
|
||||
break
|
||||
|
||||
inGeom = f.geometry()
|
||||
points = vector.extractPoints(inGeom)
|
||||
hull.extend(points)
|
||||
@ -166,12 +175,17 @@ class ConvexHull(QgisAlgorithm):
|
||||
tmpGeom = QgsGeometry(outGeom.fromMultiPoint(hull))
|
||||
try:
|
||||
outGeom = tmpGeom.convexHull()
|
||||
(area, perim) = vector.simpleMeasure(outGeom)
|
||||
if outGeom:
|
||||
area = outGeom.geometry().area()
|
||||
perim = outGeom.geometry().perimeter()
|
||||
else:
|
||||
area = NULL
|
||||
perim = NULL
|
||||
outFeat.setGeometry(outGeom)
|
||||
outFeat.setAttributes([0, 'all', area, perim])
|
||||
writer.addFeature(outFeat, QgsFeatureSink.FastInsert)
|
||||
sink.addFeature(outFeat, QgsFeatureSink.FastInsert)
|
||||
except:
|
||||
raise GeoAlgorithmExecutionException(
|
||||
raise QgsProcessingException(
|
||||
self.tr('Exception while computing convex hull'))
|
||||
|
||||
del writer
|
||||
return {self.OUTPUT: dest_id}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user