Skip to content

Commit e8a8c37

Browse files
committedSep 26, 2013
Merge branch 'master' of github.com:qgis/QGIS
2 parents b9b4119 + 770e52b commit e8a8c37

40 files changed

+2468
-627
lines changed
 

‎.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,6 @@ i18n/*.qm
5252
scripts/qgisstyle
5353
.kdev4/
5454
qgis.kdev4
55+
qgis.supp
5556
src/core/qgscontexthelp_texts.cpp
5657
src/core/qgsexpression_texts.cpp

‎python/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ INCLUDE_DIRECTORIES(
4444

4545
../src/gui/raster
4646
../src/gui/attributetable
47+
../src/gui/editorwidgets
48+
../src/gui/editorwidgets/core
4749

4850
${CMAKE_BINARY_DIR} # qgsconfig.h, qgsversion.h
4951
)

‎python/core/core.sip

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
%Include qgsdistancearea.sip
3030
%Include qgserror.sip
3131
%Include qgsexpression.sip
32+
%Include qgseditorwidgetconfig.sip
3233
%Include qgsfeature.sip
3334
%Include qgsfeatureiterator.sip
3435
%Include qgsfeaturerequest.sip

‎python/core/qgseditorwidgetconfig.sip

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* Holds a set of configuration parameters for a editor widget wrapper.
3+
* It's basically a set of key => value pairs.
4+
*
5+
* If you need more advanced structures than a simple key => value pair,
6+
* you can use a value to hold any structure a QVariant can handle (and that's
7+
* about anything you get through your compiler)
8+
*
9+
* These are the user configurable options in the field properties tab of the
10+
* vector layer properties. They are saved in the project file per layer and field.
11+
* You get these passed, for every new widget wrapper.
12+
*/
13+
14+
typedef QMap<QString, QVariant> QgsEditorWidgetConfig;
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/***************************************************************************
2+
qgseditorconfigwidget.sip
3+
--------------------------------------
4+
Date : 24.4.2013
5+
Copyright : (C) 2013 Matthias Kuhn
6+
Email : matthias dot kuhn at gmx dot ch
7+
***************************************************************************
8+
* *
9+
* This program is free software; you can redistribute it and/or modify *
10+
* it under the terms of the GNU General Public License as published by *
11+
* the Free Software Foundation; either version 2 of the License, or *
12+
* (at your option) any later version. *
13+
* *
14+
***************************************************************************/
15+
16+
class QgsEditorConfigWidget : QWidget
17+
{
18+
%TypeHeaderCode
19+
#include <qgseditorconfigwidget.h>
20+
%End
21+
22+
public:
23+
explicit QgsEditorConfigWidget( QgsVectorLayer* vl, int fieldIdx, QWidget* parent /TransferThis/ );
24+
int field();
25+
26+
QgsVectorLayer* layer();
27+
28+
virtual QgsEditorWidgetConfig config() = 0;
29+
virtual void setConfig( const QgsEditorWidgetConfig& config ) = 0;
30+
};
31+
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/***************************************************************************
2+
qgseditorwidgetfactory.sip
3+
--------------------------------------
4+
Date : 21.4.2013
5+
Copyright : (C) 2013 Matthias Kuhn
6+
Email : matthias dot kuhn at gmx dot ch
7+
***************************************************************************
8+
* *
9+
* This program is free software; you can redistribute it and/or modify *
10+
* it under the terms of the GNU General Public License as published by *
11+
* the Free Software Foundation; either version 2 of the License, or *
12+
* (at your option) any later version. *
13+
* *
14+
***************************************************************************/
15+
16+
/**
17+
* Every attribute editor widget needs a factory, which inherits this class
18+
*/
19+
class QgsEditorWidgetFactory
20+
{
21+
%TypeHeaderCode
22+
#include <qgseditorwidgetfactory.h>
23+
%End
24+
25+
public:
26+
QgsEditorWidgetFactory( const QString& name );
27+
virtual ~QgsEditorWidgetFactory();
28+
virtual QgsEditorWidgetWrapper* create( QgsVectorLayer* vl, int fieldIdx, QWidget* editor, QWidget* parent ) const = 0 /Factory/;
29+
virtual QgsEditorConfigWidget* configWidget( QgsVectorLayer* vl, int fieldIdx, QWidget* parent ) const = 0 /Factory/;
30+
virtual QgsEditorWidgetConfig readConfig( const QDomElement& configElement, QgsVectorLayer* layer, int fieldIdx );
31+
virtual void writeConfig( const QgsEditorWidgetConfig& config, QDomElement& configElement, const QDomDocument& doc, const QgsVectorLayer* layer, int fieldIdx );
32+
33+
virtual QString name();
34+
};
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/***************************************************************************
2+
qgseditorwidgetregistry.sip
3+
--------------------------------------
4+
Date : 21.4.2013
5+
Copyright : (C) 2013 Matthias Kuhn
6+
Email : matthias dot kuhn at gmx dot ch
7+
***************************************************************************
8+
* *
9+
* This program is free software; you can redistribute it and/or modify *
10+
* it under the terms of the GNU General Public License as published by *
11+
* the Free Software Foundation; either version 2 of the License, or *
12+
* (at your option) any later version. *
13+
* *
14+
***************************************************************************/
15+
16+
/**
17+
* This class manages all known edit widget factories
18+
*/
19+
class QgsEditorWidgetRegistry : QObject
20+
{
21+
%TypeHeaderCode
22+
#include <qgseditorwidgetregistry.h>
23+
%End
24+
25+
public:
26+
static QgsEditorWidgetRegistry* instance();
27+
void registerWidget( const QString& widgetType, QgsEditorWidgetFactory* widgetFactory /Transfer/ );
28+
QgsEditorWidgetWrapper* create( const QString& widgetType, QgsVectorLayer* vl, int fieldIdx, const QgsEditorWidgetConfig& config, QWidget* editor = NULL, QWidget* parent = NULL ) /Factory/;
29+
QgsEditorConfigWidget* createConfigWidget( const QString& widgetId, QgsVectorLayer* vl, int fieldIdx, QWidget* parent ) /Factory/;
30+
31+
const QMap<QString, QgsEditorWidgetFactory*> factories();
32+
};
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/***************************************************************************
2+
qgseditorwidgetwrapper.sip
3+
--------------------------------------
4+
Date : 20.4.2013
5+
Copyright : (C) 2013 Matthias Kuhn
6+
Email : matthias dot kuhn at gmx dot ch
7+
***************************************************************************
8+
* *
9+
* This program is free software; you can redistribute it and/or modify *
10+
* it under the terms of the GNU General Public License as published by *
11+
* the Free Software Foundation; either version 2 of the License, or *
12+
* (at your option) any later version. *
13+
* *
14+
***************************************************************************/
15+
16+
class QgsEditorWidgetWrapper : QObject
17+
{
18+
%TypeHeaderCode
19+
#include <qgseditorwidgetwrapper.h>
20+
%End
21+
22+
public:
23+
explicit QgsEditorWidgetWrapper( QgsVectorLayer* vl, int fieldIdx, QWidget* editor = 0, QWidget* parent /TransferThis/ = 0 );
24+
QWidget* widget();
25+
virtual void setConfig( QMap<QString, QVariant> config );
26+
virtual QVariant value() = 0;
27+
QVariant config( QString key );
28+
29+
QgsVectorLayer* layer();
30+
int field();
31+
32+
protected:
33+
virtual QWidget* createWidget( QWidget* parent ) = 0 /Factory/;
34+
35+
signals:
36+
void valueChanged( const QVariant& value );
37+
38+
public slots:
39+
virtual void setValue( const QVariant& value ) = 0;
40+
virtual void setEnabled( bool enabled );
41+
42+
};

‎python/gui/gui.sip

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,8 @@
127127
%Include symbology-ng/qgsdatadefinedsymboldialog.sip
128128
%Include symbology-ng/qgsstylev2exportimportdialog.sip
129129
%Include symbology-ng/qgssvgselectorwidget.sip
130+
131+
%Include editorwidgets/qgseditorconfigwidget.sip
132+
%Include editorwidgets/qgseditorwidgetfactory.sip
133+
%Include editorwidgets/qgseditorwidgetregistry.sip
134+
%Include editorwidgets/qgseditorwidgetwrapper.sip

‎python/plugins/processing/gdal/ClipByMask.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
import os
2727
from PyQt4 import QtGui
28+
from osgeo import gdal
2829
from qgis.core import *
2930

3031
from processing.core.GeoAlgorithm import GeoAlgorithm
@@ -45,6 +46,7 @@ class ClipByMask(GeoAlgorithm):
4546
NO_DATA = "NO_DATA"
4647
MASK = "MASK"
4748
ALPHA_BAND = "ALPHA_BAND"
49+
KEEP_RESOLUTION = "KEEP_RESOLUTION"
4850
EXTRA = "EXTRA"
4951

5052
def getIcon(self):
@@ -58,6 +60,7 @@ def defineCharacteristics(self):
5860
self.addParameter(ParameterVector(self.MASK, "Mask layer", [ParameterVector.VECTOR_TYPE_POLYGON]))
5961
self.addParameter(ParameterString(self.NO_DATA, "Nodata value, leave as none to take the nodata value from input", "none"))
6062
self.addParameter(ParameterBoolean(self.ALPHA_BAND, "Create and output alpha band", False))
63+
self.addParameter(ParameterBoolean(self.KEEP_RESOLUTION, "Keep resolution of output raster", False))
6164
self.addParameter(ParameterString(self.EXTRA, "Additional creation parameters", ""))
6265
self.addOutput(OutputRaster(self.OUTPUT, "Output layer"))
6366

@@ -66,6 +69,7 @@ def processAlgorithm(self, progress):
6669
mask = self.getParameterValue(self.MASK)
6770
noData = str(self.getParameterValue(self.NO_DATA))
6871
addAlphaBand = self.getParameterValue(self.ALPHA_BAND)
72+
keepResolution = self.getParameterValue(self.KEEP_RESOLUTION)
6973
extra = str(self.getParameterValue(self.EXTRA))
7074

7175
arguments = []
@@ -75,6 +79,15 @@ def processAlgorithm(self, progress):
7579
arguments.append("-dstnodata")
7680
arguments.append(noData)
7781

82+
if keepResolution:
83+
r = gdal.Open(self.getParameterValue(self.INPUT))
84+
geoTransform = r.GetGeoTransform()
85+
r = None
86+
arguments.append("-tr")
87+
arguments.append(str(geoTransform[1]))
88+
arguments.append(str(geoTransform[5]))
89+
arguments.append("-tap")
90+
7891
arguments.append("-cutline")
7992
arguments.append(mask)
8093
arguments.append("-crop_to_cutline")

‎src/app/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ INCLUDE_DIRECTORIES(
422422
../core
423423
../core/gps
424424
../core/composer ../core/raster ../core/symbology-ng
425-
../gui ../gui/symbology-ng ../gui/attributetable ../gui/raster
425+
../gui ../gui/symbology-ng ../gui/attributetable ../gui/raster ../gui/editorwidgets ../gui/editorwidgets/core
426426
../plugins
427427
../python
428428
gps

‎src/app/qgisapp.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class QgsPoint;
5757
class QgsProviderRegistry;
5858
class QgsPythonUtils;
5959
class QgsRectangle;
60+
6061
class QgsUndoWidget;
6162
class QgsVectorLayer;
6263

@@ -175,6 +176,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
175176
/** Get the mapcanvas object from the app */
176177
QgsMapCanvas *mapCanvas();
177178

179+
/** Return the messageBar object which allows to display unobtrusive messages to the user.*/
178180
QgsMessageBar* messageBar();
179181

180182
/** Get the mapcanvas object from the app */
@@ -240,7 +242,6 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
240242
/** overloaded function used to sort menu entries alphabetically */
241243
QMenu* createPopupMenu();
242244

243-
244245
//! Actions to be inserted in menus and toolbars
245246
QAction *actionNewProject() { return mActionNewProject; }
246247
QAction *actionOpenProject() { return mActionOpenProject; }

0 commit comments

Comments
 (0)
Please sign in to comment.