742 changes: 742 additions & 0 deletions images/theme_originals/mActionDecreaseBrightness.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
721 changes: 721 additions & 0 deletions images/theme_originals/mActionDecreaseContrast.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
742 changes: 742 additions & 0 deletions images/theme_originals/mActionIncreaseBrightness.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
741 changes: 741 additions & 0 deletions images/theme_originals/mActionIncreaseContrast.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
742 changes: 742 additions & 0 deletions images/themes/default/mActionDecreaseBrightness.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
721 changes: 721 additions & 0 deletions images/themes/default/mActionDecreaseContrast.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
742 changes: 742 additions & 0 deletions images/themes/default/mActionIncreaseBrightness.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
741 changes: 741 additions & 0 deletions images/themes/default/mActionIncreaseContrast.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
742 changes: 742 additions & 0 deletions images/themes/gis/mActionDecreaseBrightness.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
721 changes: 721 additions & 0 deletions images/themes/gis/mActionDecreaseContrast.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
742 changes: 742 additions & 0 deletions images/themes/gis/mActionIncreaseBrightness.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
741 changes: 741 additions & 0 deletions images/themes/gis/mActionIncreaseContrast.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 8 additions & 5 deletions python/core/composer/qgscomposeritem.sip
Original file line number Diff line number Diff line change
Expand Up @@ -292,16 +292,19 @@ class QgsComposerItem: QObject, QGraphicsRectItem
/**Updates item, with the possibility to do custom update for subclasses*/
virtual void updateItem();

/**Get item identification name
/**Get item's id (which is not necessarly unique)
@note this method was added in version 1.7*/
QString id() const;

/**Set item identification name
@note this method was added in version 1.7
This method was moved from qgscomposerlabel so that every object can have a
id (NathanW)*/
/**Set item's id (which is not necessarly unique)
@note this method was added in version 1.7*/
void setId( const QString& id );

/**Get item identification name
@note this method was added in version 2.0
@note there is not setter since one can't manually set the id*/
QString uuid() const;

public slots:
virtual void setRotation( double r );
void repaint();
Expand Down
12 changes: 12 additions & 0 deletions python/core/composer/qgscomposition.sip
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,25 @@ class QgsComposition : QGraphicsScene
const QgsComposerHtml* getComposerHtmlByItem( QgsComposerItem *item ) const;

/**Returns a composer item given its text identifier.
Ids are not necessarely unique, but this function returns only one element.
@note added in 2.0
@param theId - A QString representing the identifier of the item to
retrieve.
@return QgsComposerItem pointer or 0 pointer if no such item exists.
**/
const QgsComposerItem* getComposerItemById( QString theId ) const;


/**Returns a composer item given its unique identifier.
Warning : ids are not necessarely unique, but this function returns only one element.
@note added in 2.0
@param theId - A QString representing the UUID of the item to retrieve.
@param inAllComposers - Whether the search should be done in all composers of the project
@return QgsComposerItem pointer or 0 pointer if no such item exists.
**/
//const QgsComposerItem* getComposerItemByUuid( QString theUuid, bool inAllComposers = false ) const;
const QgsComposerItem* getComposerItemByUuid( QString theUuid ) const;

int printResolution() const;
void setPrintResolution( int dpi );

Expand Down
108 changes: 50 additions & 58 deletions python/core/qgsexpression.sip
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ class QgsExpression
//! Returns parser error
QString parserErrorString() const;

//! Returns root node of the expression. Root node is null is parsing has failed
const QgsExpression::Node* rootNode() const;

//! Get the expression ready for evaluation - find out column indexes.
bool prepare( const QgsFields &fields );

Expand Down Expand Up @@ -118,9 +121,6 @@ class QgsExpression
// static const char* BinaryOperatorText[];
// static const char* UnaryOperatorText[];

// static const char* BinaryOgcOperatorText[];
// static const char* UnaryOgcOperatorText[];

class Function
{
public:
Expand Down Expand Up @@ -167,10 +167,22 @@ class QgsExpression

//////

enum NodeType
{
ntUnaryOperator,
ntBinaryOperator,
ntInOperator,
ntFunction,
ntLiteral,
ntColumnRef,
ntCondition
};

class Node
{
public:
virtual ~Node();
virtual QgsExpression::NodeType nodeType() const = 0;
// abstract virtual eval function
// errors are reported to the parent
virtual QVariant eval( QgsExpression* parent, QgsFeature* f ) = 0;
Expand All @@ -181,14 +193,11 @@ class QgsExpression

virtual QString dump() const = 0;

virtual void toOgcFilter( QDomDocument &doc, QDomElement &element ) const;
static QgsExpression::Node* createFromOgcFilter( QDomElement &element, QString &errorMessage ) /Factory/;

virtual QStringList referencedColumns() const = 0;
virtual bool needsGeometry() const = 0;

// support for visitor pattern
virtual void accept( QgsExpression::Visitor& v ) = 0;
virtual void accept( QgsExpression::Visitor& v ) const = 0;
};

class NodeList
Expand All @@ -201,7 +210,6 @@ class QgsExpression
QList<QgsExpression::Node*> list();

virtual QString dump() const;
virtual void toOgcFilter( QDomDocument &doc, QDomElement &element ) const;
};

class Interval
Expand Down Expand Up @@ -229,19 +237,17 @@ class QgsExpression
NodeUnaryOperator( QgsExpression::UnaryOperator op, QgsExpression::Node* operand );
~NodeUnaryOperator();

QgsExpression::UnaryOperator op();
QgsExpression::Node* operand();
QgsExpression::UnaryOperator op() const;
QgsExpression::Node* operand() const;

virtual QgsExpression::NodeType nodeType() const;
virtual bool prepare( QgsExpression* parent, const QgsFields &fields );
virtual QVariant eval( QgsExpression* parent, QgsFeature* f );
virtual QString dump() const;

virtual void toOgcFilter( QDomDocument &doc, QDomElement &element ) const;
static QgsExpression::Node* createFromOgcFilter( QDomElement &element, QString &errorMessage ) /Factory/;

virtual QStringList referencedColumns() const;
virtual bool needsGeometry() const;
virtual void accept( QgsExpression::Visitor& v );
virtual void accept( QgsExpression::Visitor& v ) const;
};

class NodeBinaryOperator : QgsExpression::Node
Expand All @@ -250,20 +256,18 @@ class QgsExpression
NodeBinaryOperator( QgsExpression::BinaryOperator op, QgsExpression::Node* opLeft, QgsExpression::Node* opRight );
~NodeBinaryOperator();

QgsExpression::BinaryOperator op();
QgsExpression::Node* opLeft();
QgsExpression::Node* opRight();
QgsExpression::BinaryOperator op() const;
QgsExpression::Node* opLeft() const;
QgsExpression::Node* opRight() const;

virtual QgsExpression::NodeType nodeType() const;
virtual bool prepare( QgsExpression* parent, const QgsFields &fields );
virtual QVariant eval( QgsExpression* parent, QgsFeature* f );
virtual QString dump() const;

virtual void toOgcFilter( QDomDocument &doc, QDomElement &element ) const;
static QgsExpression::Node* createFromOgcFilter( QDomElement &element, QString &errorMessage ) /Factory/;

virtual QStringList referencedColumns() const;
virtual bool needsGeometry() const;
virtual void accept( QgsExpression::Visitor& v );
virtual void accept( QgsExpression::Visitor& v ) const;
};

class NodeInOperator : QgsExpression::Node
Expand All @@ -272,19 +276,18 @@ class QgsExpression
NodeInOperator( QgsExpression::Node* node, QgsExpression::NodeList* list, bool notin = false );
~NodeInOperator();

QgsExpression::Node* node();
bool isNotIn();
QgsExpression::NodeList* list();
QgsExpression::Node* node() const;
bool isNotIn() const;
QgsExpression::NodeList* list() const;

virtual QgsExpression::NodeType nodeType() const;
virtual bool prepare( QgsExpression* parent, const QgsFields &fields );
virtual QVariant eval( QgsExpression* parent, QgsFeature* f );
virtual QString dump() const;

virtual void toOgcFilter( QDomDocument &doc, QDomElement &element ) const;

virtual QStringList referencedColumns() const;
virtual bool needsGeometry() const;
virtual void accept( QgsExpression::Visitor& v );
virtual void accept( QgsExpression::Visitor& v ) const;
};

class NodeFunction : QgsExpression::Node
Expand All @@ -294,57 +297,51 @@ class QgsExpression
//NodeFunction( QString name, QgsExpression::NodeList* args );
~NodeFunction();

int fnIndex();
QgsExpression::NodeList* args();
int fnIndex() const;
QgsExpression::NodeList* args() const;

virtual QgsExpression::NodeType nodeType() const;
virtual bool prepare( QgsExpression* parent, const QgsFields &fields );
virtual QVariant eval( QgsExpression* parent, QgsFeature* f );
virtual QString dump() const;

virtual void toOgcFilter( QDomDocument &doc, QDomElement &element ) const;
static QgsExpression::Node* createFromOgcFilter( QDomElement &element, QString &errorMessage ) /Factory/;

virtual QStringList referencedColumns() const;
virtual bool needsGeometry() const;
virtual void accept( QgsExpression::Visitor& v );
virtual void accept( QgsExpression::Visitor& v ) const;
};

class NodeLiteral : QgsExpression::Node
{
public:
NodeLiteral( QVariant value );

QVariant value();
QVariant value() const;

virtual QgsExpression::NodeType nodeType() const;
virtual bool prepare( QgsExpression* parent, const QgsFields &fields );
virtual QVariant eval( QgsExpression* parent, QgsFeature* f );
virtual QString dump() const;

virtual void toOgcFilter( QDomDocument &doc, QDomElement &element ) const;
static QgsExpression::Node* createFromOgcFilter( QDomElement &element, QString &errorMessage ) /Factory/;

virtual QStringList referencedColumns() const;
virtual bool needsGeometry() const;
virtual void accept( QgsExpression::Visitor& v );
virtual void accept( QgsExpression::Visitor& v ) const;
};

class NodeColumnRef : QgsExpression::Node
{
public:
NodeColumnRef( QString name );

QString name();
QString name() const;

virtual QgsExpression::NodeType nodeType() const;
virtual bool prepare( QgsExpression* parent, const QgsFields &fields );
virtual QVariant eval( QgsExpression* parent, QgsFeature* f );
virtual QString dump() const;

virtual void toOgcFilter( QDomDocument &doc, QDomElement &element ) const;
static QgsExpression::Node* createFromOgcFilter( QDomElement &element, QString &errorMessage ) /Factory/;

virtual QStringList referencedColumns() const;
virtual bool needsGeometry() const;
virtual void accept( QgsExpression::Visitor& v );
virtual void accept( QgsExpression::Visitor& v ) const;
};

class WhenThen
Expand All @@ -365,15 +362,14 @@ class QgsExpression
NodeCondition( QgsExpression::WhenThenList* conditions, QgsExpression::Node* elseExp = NULL );
~NodeCondition();

virtual QgsExpression::NodeType nodeType() const;
virtual QVariant eval( QgsExpression* parent, QgsFeature* f );
virtual bool prepare( QgsExpression* parent, const QgsFields &fields );
virtual QString dump() const;

virtual void toOgcFilter( QDomDocument &doc, QDomElement &element ) const;

virtual QStringList referencedColumns() const;
virtual bool needsGeometry() const;
virtual void accept( QgsExpression::Visitor& v );
virtual void accept( QgsExpression::Visitor& v ) const;
};

//////
Expand All @@ -384,21 +380,17 @@ class QgsExpression
{
public:
virtual ~Visitor();
virtual void visit( QgsExpression::NodeUnaryOperator* n ) = 0;
virtual void visit( QgsExpression::NodeBinaryOperator* n ) = 0;
virtual void visit( QgsExpression::NodeInOperator* n ) = 0;
virtual void visit( QgsExpression::NodeFunction* n ) = 0;
virtual void visit( QgsExpression::NodeLiteral* n ) = 0;
virtual void visit( QgsExpression::NodeColumnRef* n ) = 0;
virtual void visit( QgsExpression::NodeCondition* n ) = 0;
virtual void visit( const QgsExpression::NodeUnaryOperator& n ) = 0;
virtual void visit( const QgsExpression::NodeBinaryOperator& n ) = 0;
virtual void visit( const QgsExpression::NodeInOperator& n ) = 0;
virtual void visit( const QgsExpression::NodeFunction& n ) = 0;
virtual void visit( const QgsExpression::NodeLiteral& n ) = 0;
virtual void visit( const QgsExpression::NodeColumnRef& n ) = 0;
virtual void visit( const QgsExpression::NodeCondition& n ) = 0;
};

/** entry function for the visitor pattern */
void acceptVisitor( QgsExpression::Visitor& v );

// convert from/to OGC Filter
void toOgcFilter( QDomDocument &doc, QDomElement &element ) const;
static QgsExpression* createFromOgcFilter( QDomElement &element ) /Factory/;
void acceptVisitor( QgsExpression::Visitor& v ) const;

protected:
void initGeomCalculator();
Expand Down
45 changes: 36 additions & 9 deletions python/core/qgsogcutils.sip
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,52 @@ class QgsOgcUtils

public:

/** static method that creates geometry from GML2
/** static method that creates geometry from GML
@param XML representation of the geometry. GML elements are expected to be
in default namespace (<Point>...</Point>) or in "gml" namespace (<gml:Point>...</gml:Point>)
@note added in 1.9
*/
static QgsGeometry* geometryFromGML2( const QString& xmlString ) /Factory/;
static QgsGeometry* geometryFromGML( const QString& xmlString ) /Factory/;

/** static method that creates geometry from GML2
/** static method that creates geometry from GML
@note added in 1.9
*/
static QgsGeometry* geometryFromGML2( const QDomNode& geometryNode ) /Factory/;

/** Exports the geometry to mGML2
@return true in case of success and false else
*/
static QDomElement geometryToGML2( QgsGeometry* geometry, QDomDocument& doc );
static QgsGeometry* geometryFromGML( const QDomNode& geometryNode ) /Factory/;

/** read rectangle from GML2 Box */
static QgsRectangle rectangleFromGMLBox( const QDomNode& boxNode );

/** read rectangle from GML3 Envelope */
static QgsRectangle rectangleFromGMLEnvelope( const QDomNode& envelopeNode );

/** Exports the geometry to GML2
@return QDomElement
*/
static QDomElement geometryToGML( QgsGeometry* geometry, QDomDocument& doc );

/** Exports the geometry to GML2 or GML3
@return QDomElement
*/
static QDomElement geometryToGML( QgsGeometry* geometry, QDomDocument& doc, QString Format );

/** Exports the rectangle to GML2 Box
@return QDomElement
*/
static QDomElement rectangleToGMLBox( QgsRectangle* box, QDomDocument& doc );

/** Exports the rectangle to GML2 Envelope
@return QDomElement
*/
static QDomElement rectangleToGMLEnvelope( QgsRectangle* env, QDomDocument& doc );


/** Parse XML with OGC filter into QGIS expression */
static QgsExpression* expressionFromOgcFilter( const QDomElement& element ) /Factory/;

/** Creates OGC filter XML element. Supports minimum standard filter according to the OGC filter specs (=,!=,<,>,<=,>=,AND,OR,NOT)
@return valid <Filter> QDomElement on success, otherwise null QDomElement
*/
static QDomElement expressionToOgcFilter( const QgsExpression& exp, QDomDocument& doc, QString* errorMessage /Out/ );

};

40 changes: 0 additions & 40 deletions python/core/qgsvectorlayer.sip
Original file line number Diff line number Diff line change
Expand Up @@ -89,23 +89,6 @@ class QgsVectorLayer : QgsMapLayer

public:

QgsVectorLayer* __iter__();
%MethodCode
sipRes = sipCpp;
%End

SIP_PYOBJECT __next__();
%MethodCode
QgsFeature* f = new QgsFeature;
if (sipCpp->nextFeature(*f))
sipRes = sipConvertFromInstance(f, sipClass_QgsFeature, Py_None);
else
{
delete f;
PyErr_SetString(PyExc_StopIteration,"");
}
%End

enum EditorLayout
{
GeneratedLayout,
Expand Down Expand Up @@ -382,34 +365,11 @@ class QgsVectorLayer : QgsMapLayer
*/
virtual QString subsetString();

/**
* Select features with or without attributes in a given window.
* @param fetchAttributes indizes of attributes to fetch
* @param rect window (QgsRectangle() for all)
* @param fetchGeometry fetch features with geometry
* @param useIntersect fetch only features that actually intersect the window (not just the bounding box)
*/
void select( QList<int> fetchAttributes,
QgsRectangle rect = QgsRectangle(),
bool fetchGeometry = true,
bool useIntersect = false ) /Deprecated/;

/**
* Query the provider for features specified in request.
*/
QgsFeatureIterator getFeatures( const QgsFeatureRequest& request = QgsFeatureRequest() );

/**
* fetch a feature (after select)
* @param feature buffer to read the feature into
* @return true, if a feature was fetched, false, if there are no more features
*/
bool nextFeature( QgsFeature& feature ) /Deprecated/;

/**Gets the feature at the given feature id. Considers the changed, added, deleted and permanent features
@return true in case of success*/
bool featureAtId( QgsFeatureId featureId, QgsFeature &f, bool fetchGeometries = true, bool fetchAttributes = true ) /Deprecated/;

/** Adds a feature
@param f feature to add
@param alsoUpdateExtent If True, will also go to the effort of e.g. updating the extents.
Expand Down
14 changes: 14 additions & 0 deletions python/core/raster/qgsrasterinterface.sip
Original file line number Diff line number Diff line change
Expand Up @@ -192,5 +192,19 @@ class QgsRasterInterface
const QgsRectangle & theExtent = QgsRectangle(),
int theSampleSize = 0 );

/** Switch on (and clear old statistics) or off collection of statistics */
//void setStatsOn( bool on );

/** Last total time (for allbands) consumed by this interface for call to block()
* If cumulative is true, the result includes also time spent in all preceding
* interfaces. If cumulative is false, only time consumed by this interface is
* returned. */
//double time( bool cumulative = false );

/** Write base class members to xml. */
virtual void writeXML( QDomDocument& doc, QDomElement& parentElem ) const;
/** Sets base class members from xml. Usually called from create() methods of subclasses */
virtual void readXML( const QDomElement& filterElem );

};

2 changes: 1 addition & 1 deletion python/gui/qgsfieldvalidator.sip
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class QgsFieldValidator : QValidator
%End

public:
QgsFieldValidator( QObject *parent, const QgsField &field );
QgsFieldValidator( QObject *parent, const QgsField &field, QString dateFormat = "yyyy-MM-dd" );
~QgsFieldValidator();

virtual State validate( QString &, int & ) const;
Expand Down
14 changes: 7 additions & 7 deletions python/plugins/fTools/tools/doGeometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,19 +566,19 @@ def export_geometry_info( self ):
if self.writeShape:
outFeat.setGeometry( inGeom )
atMap = inFeat.attributes()
maxIndex = index1 if index1>index2 else index2
if maxIndex>len(atMap):
atMap += [ QVariant() ] * ( index2+1 - len(atMap) )
atMap[ index1 ] = attr1
if index1!=index2:
atMap[ index2 ] = attr2
maxIndex = index1 if index1>index2 else index2
if maxIndex>len(atMap):
atMap += [ QVariant() ] * ( index2+1 - len(atMap) )
atMap[ index1 ] = attr1
if index1!=index2:
atMap[ index2 ] = attr2
outFeat.setAttributes( atMap )
writer.addFeature( outFeat )
else:
changeMap = {}
changeMap[ inFeat.id() ] = {}
changeMap[ inFeat.id() ][ index1 ] = QVariant( attr1 )
if index1!=index2:
if index1!=index2:
changeMap[ inFeat.id() ][ index2 ] = QVariant( attr2 )
vprovider.changeAttributeValues( changeMap )

Expand Down
4 changes: 2 additions & 2 deletions python/plugins/fTools/tools/doRandPoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,11 @@ def createSinglePolygon(self, vlayer):
provider = vlayer.dataProvider()
feat = QgsFeature()
geom = QgsGeometry()
#geom2 = QgsGeometry()
fit = provider.getFeatures()
fit.nextFeature(feat)
geom = QgsGeometry(feat.geometry())
count = 10.00
add = ( 40.00 - 10.00 ) / provider.featureCount()
#geom = QgsGeometry(feat.geometry())
while fit.nextFeature(feat):
geom = geom.combine(QgsGeometry( feat.geometry() ))
count = count + add
Expand Down Expand Up @@ -202,6 +200,7 @@ def vectorRandom(self, n, layer, xmin, xmax, ymin, ymax):

def randomize(self, inLayer, outPath, minimum, design, value):
outFeat = QgsFeature()
outFeat.initAttributes(1)
if design == self.tr("unstratified"):
ext = inLayer.extent()
if inLayer.type() == inLayer.RasterLayer:
Expand All @@ -215,6 +214,7 @@ def randomize(self, inLayer, outPath, minimum, design, value):
if not crs.isValid(): crs = None
fields = QgsFields()
fields.append( QgsField("ID", QVariant.Int) )
outFeat.setFields(fields)
check = QFile(self.shapefileName)
if check.exists():
if not QgsVectorFileWriter.deleteShapeFile(self.shapefileName):
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/fTools/tools/doRegPoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,15 @@ def regularize(self, bound, outPath, offset, value, gridType, inset, crs):
# Calculate grid spacing
pointSpacing = sqrt(area / value)
outFeat = QgsFeature()
outFeat.initAttributes(1)
fields = QgsFields()
fields.append( QgsField("ID", QVariant.Int) )
outFeat.setFields( fields )
check = QFile(self.shapefileName)
if check.exists():
if not QgsVectorFileWriter.deleteShapeFile(self.shapefileName):
return
writer = QgsVectorFileWriter(self.shapefileName, self.encoding, fields, QGis.WKBPoint, crs)
#writer = QgsVectorFileWriter(unicode(outPath), "CP1250", fields, QGis.WKBPoint, None)
idVar = 0
count = 10.00
add = 90.00 / (area / pointSpacing)
Expand All @@ -156,4 +157,3 @@ def regularize(self, bound, outPath, offset, value, gridType, inset, crs):
self.progressBar.setValue(count)
y = y - pointSpacing
del writer

26 changes: 15 additions & 11 deletions python/plugins/fTools/tools/doSpatialJoin.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,23 +123,23 @@ def outFile(self):
def compute(self, inName, joinName, outName, summary, sumList, keep, progressBar):
layer1 = ftools_utils.getVectorLayerByName(inName)
provider1 = layer1.dataProvider()
fieldList1 = ftools_utils.getFieldList(layer1).values()
fieldList1 = ftools_utils.getFieldList(layer1).toList()

layer2 = ftools_utils.getVectorLayerByName(joinName)
provider2 = layer2.dataProvider()

fieldList2 = ftools_utils.getFieldList(layer2)
fieldList2 = ftools_utils.getFieldList(layer2).toList()
fieldList = []
if provider1.crs() != provider2.crs():
QMessageBox.warning(self, self.tr("CRS warning!"), self.tr("Warning: Input layers have non-matching CRS.\nThis may cause unexpected results."))
if not summary:
fieldList2 = ftools_utils.testForUniqueness(fieldList1, fieldList2.values())
fieldList2 = ftools_utils.testForUniqueness(fieldList1, fieldList2)
seq = range(0, len(fieldList1) + len(fieldList2))
fieldList1.extend(fieldList2)
fieldList1 = dict(zip(seq, fieldList1))
else:
numFields = {}
for j in fieldList2.keys():
for j in xrange(len(fieldList2)):
if fieldList2[j].type() == QVariant.Int or fieldList2[j].type() == QVariant.Double:
numFields[j] = []
for i in sumList:
Expand All @@ -153,7 +153,8 @@ def compute(self, inName, joinName, outName, summary, sumList, keep, progressBar
fieldList1 = dict(zip(seq, fieldList1))

# check for correct field names
longNames = ftools_utils.checkFieldNameLength( fieldList1 )
print fieldList1
longNames = ftools_utils.checkFieldNameLength( fieldList1.values() )
if not longNames.isEmpty():
QMessageBox.warning( self, self.tr( 'Incorrect field names' ),
self.tr( 'No output will be created.\nFollowing field names are longer than 10 characters:\n%1' )
Expand All @@ -168,7 +169,10 @@ def compute(self, inName, joinName, outName, summary, sumList, keep, progressBar
QMessageBox.warning( self, self.tr( 'Error deleting shapefile' ),
self.tr( "Can't delete existing shapefile\n%1" ).arg( self.shapefileName ) )
return False
writer = QgsVectorFileWriter(self.shapefileName, self.encoding, fieldList1, provider1.geometryType(), sRs)
fields = QgsFields()
for f in fieldList1.values():
fields.append(f)
writer = QgsVectorFileWriter(self.shapefileName, self.encoding, fields, provider1.geometryType(), sRs)
#writer = QgsVectorFileWriter(outName, "UTF-8", fieldList1, provider1.geometryType(), sRs)
inFeat = QgsFeature()
outFeat = QgsFeature()
Expand All @@ -179,7 +183,7 @@ def compute(self, inName, joinName, outName, summary, sumList, keep, progressBar
add = 85.00 / provider1.featureCount()

index = ftools_utils.createIndex(provider2)
fit1 = provider1.getFeatures()
fit1 = provider1.getFeatures()
while fit1.nextFeature(inFeat):
inGeom = inFeat.geometry()
atMap1 = inFeat.attributes()
Expand Down Expand Up @@ -211,16 +215,16 @@ def compute(self, inName, joinName, outName, summary, sumList, keep, progressBar
none = False
atMap2 = inFeatB.attributes()
if not summary:
atMap = atMap1.values()
atMap2 = atMap2.values()
atMap = atMap1
atMap2 = atMap2
atMap.extend(atMap2)
atMap = dict(zip(seq, atMap))
break
else:
for j in numFields.keys():
numFields[j].append(atMap2[j].toDouble()[0])
if summary and not none:
atMap = atMap1.values()
atMap = atMap1
for j in numFields.keys():
for k in sumList:
if k == "SUM": atMap.append(QVariant(sum(numFields[j])))
Expand All @@ -234,7 +238,7 @@ def compute(self, inName, joinName, outName, summary, sumList, keep, progressBar
if none:
outFeat.setAttributes(atMap1)
else:
outFeat.setAttributes(atMap)
outFeat.setAttributes(atMap.values())
if keep: # keep all records
writer.addFeature(outFeat)
else: # keep only matching records
Expand Down
11 changes: 4 additions & 7 deletions python/plugins/fTools/tools/doSumLines.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def compute(self, inPoly, inLns, inField, outPath, progressBar):
fieldList = ftools_utils.getFieldList(polyLayer)
index = polyProvider.fieldNameIndex(unicode(inField))
if index == -1:
index = polyProvider.fieldCount()
index = polyProvider.fields().count()
fieldList.append( QgsField(unicode(inField), QVariant.Double, "real", 24, 15, self.tr("length field")) )
sRs = polyProvider.crs()
inFeat = QgsFeature()
Expand All @@ -119,17 +119,13 @@ def compute(self, inPoly, inLns, inField, outPath, progressBar):
if not QgsVectorFileWriter.deleteShapeFile(self.shapefileName):
return
writer = QgsVectorFileWriter(self.shapefileName, self.encoding, fieldList, polyProvider.geometryType(), sRs)
#writer = QgsVectorFileWriter(outPath, "UTF-8", fieldList, polyProvider.geometryType(), sRs)
spatialIndex = ftools_utils.createIndex( lineProvider )
polyFit = polyProvider.getFeatures()
polyFit = polyProvider.getFeatures()
while polyFit.nextFeature(inFeat):
inGeom = QgsGeometry(inFeat.geometry())
atMap = inFeat.attributes()
lineList = []
length = 0
#(check, lineList) = lineLayer.featuresInRectangle(inGeom.boundingBox(), True, False)
#lineLayer.select(inGeom.boundingBox(), False)
#lineList = lineLayer.selectedFeatures()
lineList = spatialIndex.intersects(inGeom.boundingBox())
if len(lineList) > 0: check = 0
else: check = 1
Expand All @@ -141,8 +137,9 @@ def compute(self, inPoly, inLns, inField, outPath, progressBar):
outGeom = inGeom.intersection(tmpGeom)
length = length + distArea.measure(outGeom)
outFeat.setGeometry(inGeom)
atMap.append(QVariant(length))
outFeat.setAttributes(atMap)
outFeat.setAttribute(index, QVariant(length))
#outFeat.setAttribute(index, QVariant(length))
writer.addFeature(outFeat)
start = start + 1
progressBar.setValue(start)
Expand Down
8 changes: 5 additions & 3 deletions python/plugins/fTools/tools/doVectorGrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ def __init__(self, iface):
self.setupUi(self)
QObject.connect(self.toolOut, SIGNAL("clicked()"), self.outFile)
QObject.connect(self.spnX, SIGNAL("valueChanged(double)"), self.offset)
#QObject.connect(self.inShape, SIGNAL("currentIndexChanged(QString)"), self.updateInput)
QObject.connect(self.btnUpdate, SIGNAL("clicked()"), self.updateLayer)
QObject.connect(self.btnCanvas, SIGNAL("clicked()"), self.updateCanvas)
QObject.connect(self.chkAlign, SIGNAL("toggled(bool)"), self.chkAlignToggled)
Expand Down Expand Up @@ -166,25 +165,30 @@ def compute( self, bound, xOffset, yOffset, polygon ):

fields = QgsFields()
fields.append( QgsField("ID", QVariant.Int) )
fieldCount = 1

if polygon:
fields.append( QgsField("XMIN", QVariant.Double) )
fields.append( QgsField("XMAX", QVariant.Double) )
fields.append( QgsField("YMIN", QVariant.Double) )
fields.append( QgsField("YMAX", QVariant.Double) )
fieldCount = 5
check = QFile(self.shapefileName)
if check.exists():
if not QgsVectorFileWriter.deleteShapeFile(self.shapefileName):
return
writer = QgsVectorFileWriter(self.shapefileName, self.encoding, fields, QGis.WKBPolygon, crs)
else:
fields.append( QgsField("COORD", QVariant.Double) )
fieldCount = 2
check = QFile(self.shapefileName)
if check.exists():
if not QgsVectorFileWriter.deleteShapeFile(self.shapefileName):
return
writer = QgsVectorFileWriter(self.shapefileName, self.encoding, fields, QGis.WKBLineString, crs)
outFeat = QgsFeature()
outFeat.initAttributes(fieldCount)
outFeat.setFields(fields)
outGeom = QgsGeometry()
idVar = 0
self.progressBar.setValue( 0 )
Expand Down Expand Up @@ -258,7 +262,6 @@ def compute( self, bound, xOffset, yOffset, polygon ):
prog = int( count / count_max * 100 )

self.progressBar.setValue( 100 )
#self.progressBar.setRange( 0, 100 )
del writer

def outFile(self):
Expand Down Expand Up @@ -302,4 +305,3 @@ def getClosestPixel(self, startVal, targetVal, step, isMin ):
foundVal = tmpVal
tmpVal += step
return foundVal

9 changes: 7 additions & 2 deletions python/plugins/sextante/gdal/scripts/sieve.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,17 @@
##[GDAL] Analysis=group
##src_filename=raster
##dst_filename=output raster
##connectedness=selection 4;8
##threshold=number 2
##connectedness=selection 4;8
from sextante.gdal.GdalUtils import GdalUtils

from osgeo import gdal, ogr
try:
from osgeo import gdal, ogr
except ImportError:
import gdal
import ogr

threshold = int(threshold)
connectedness=int(connectedness)
options = []

Expand Down
23 changes: 18 additions & 5 deletions python/plugins/sextante/gui/BatchInputSelectionPanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
__copyright__ = '(C) 2012, Victor Olaya'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

import os
from PyQt4 import QtGui, QtCore
from sextante.parameters.ParameterMultipleInput import ParameterMultipleInput

Expand All @@ -49,13 +49,26 @@ def __init__(self, param, row, col, batchDialog, parent = None):
self.horizontalLayout.addWidget(self.pushButton)
self.setLayout(self.horizontalLayout)

def showSelectionDialog(self):
ret = QtGui.QFileDialog.getOpenFileNames(self, "Open file", QtCore.QString(), "All files (*.*)")
if ret:
files = list(ret)
def showSelectionDialog(self):
settings = QtCore.QSettings()
text = str(self.text.text())
if os.path.isdir(text):
path = text
elif os.path.isdir(os.path.dirname(text)):
path = os.path.dirname(text)
elif settings.contains("/SextanteQGIS/LastInputPath"):
path = str(settings.value( "/SextanteQGIS/LastInputPath",QtCore.QVariant( "" ) ).toString())
else:
path = ""

ret = QtGui.QFileDialog.getOpenFileNames(self, "Open file", path, "All files (*.*)")
if ret:
files = list(ret)
if len(files) == 1:
settings.setValue("/SextanteQGIS/LastInputPath", os.path.dirname(str(files[0])))
self.text.setText(str(files[0]))
else:
settings.setValue("/SextanteQGIS/LastInputPath", os.path.dirname(str(files[0])))
if isinstance(self.param, ParameterMultipleInput):
self.text.setText(";".join(str(f) for f in files))
else:
Expand Down
30 changes: 20 additions & 10 deletions python/plugins/sextante/gui/BatchProcessingDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
* *
***************************************************************************
"""
from sextante.gui.SextantePostprocessing import SextantePostprocessing

__author__ = 'Victor Olaya'
__date__ = 'August 2012'
__copyright__ = '(C) 2012, Victor Olaya'
Expand All @@ -27,7 +25,9 @@
from PyQt4 import QtCore, QtGui
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from sextante.core.QGisLayers import QGisLayers
from sextante.gui.SextantePostprocessing import SextantePostprocessing
from sextante.parameters.ParameterFile import ParameterFile
from sextante.gui.FileSelectionPanel import FileSelectionPanel
from sextante.parameters.ParameterRaster import ParameterRaster
from sextante.parameters.ParameterTable import ParameterTable
from sextante.parameters.ParameterVector import ParameterVector
Expand Down Expand Up @@ -95,25 +95,30 @@ def headerDoubleClicked(self, col):
widgetValue = widget.currentIndex()
for row in range(1, self.table.rowCount()):
self.table.cellWidget(row, col).setCurrentIndex(widgetValue)

elif isinstance(widget, ExtentSelectionPanel):
widgetValue = widget.getValue()
for row in range(1, self.table.rowCount()):
if widgetValue != None:
self.table.cellWidget(row, col).text.setText(widgetValue)
else:
self.table.cellWidget(row, col).text.setText("")

elif isinstance(widget, CrsSelectionPanel):
widgetValue = widget.getValue()
for row in range(1, self.table.rowCount()):
self.table.cellWidget(row, col).epsg = widgetValue
self.table.cellWidget(row, col).setText()

self.table.cellWidget(row, col).setAuthid(widgetValue)
elif isinstance(widget, FileSelectionPanel):
widgetValue = widget.getValue()
for row in range(1, self.table.rowCount()):
self.table.cellWidget(row, col).setText(widgetValue)
elif isinstance(widget, QtGui.QLineEdit):
widgetValue = widget.text()
for row in range(1, self.table.rowCount()):
self.table.cellWidget(row, col).setText(widgetValue)
elif isinstance(widget, BatchInputSelectionPanel):
widgetValue = widget.getText()
for row in range(1, self.table.rowCount()):
self.table.cellWidget(row, col).setText(widgetValue)

else:
pass

Expand Down Expand Up @@ -264,7 +269,10 @@ def finishAll(self):

def setParameterValueFromWidget(self, param, widget, alg = None):
if isinstance(param, (ParameterRaster, ParameterVector, ParameterTable, ParameterMultipleInput)):
return param.setValue(widget.getText())
value = widget.getText()
if unicode(value.strip()) == "":
value = None
return param.setValue(value)
elif isinstance(param, ParameterBoolean):
return param.setValue(widget.currentIndex() == 0)
elif isinstance(param, ParameterSelection):
Expand All @@ -275,7 +283,7 @@ def setParameterValueFromWidget(self, param, widget, alg = None):
if alg != None:
widget.useNewAlg(alg)
return param.setValue(widget.getValue())
elif isinstance(param, ParameterCrs):
elif isinstance(param, (ParameterCrs, ParameterFile)):
return param.setValue(widget.getValue())
else:
return param.setValue(widget.text())
Expand All @@ -300,6 +308,8 @@ def getWidgetFromParameter(self, param, row, col):
item = ExtentSelectionPanel(self, self.alg, param.default)
elif isinstance(param, ParameterCrs):
item = CrsSelectionPanel(param.default)
elif isinstance(param, ParameterFile):
item = FileSelectionPanel(param.isFolder)
else:
item = QtGui.QLineEdit()
try:
Expand Down
3 changes: 3 additions & 0 deletions python/plugins/sextante/gui/FileSelectionPanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,6 @@ def getValue(self):
if SextanteUtils.isWindows():
s = s.replace("\\", "/")
return s

def setText(self, text):
self.text.setText(text)
8 changes: 4 additions & 4 deletions python/plugins/sextante/gui/SextanteToolbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def executeAlgorithm(self):
if dlg.executed:
showRecent = SextanteConfig.getSetting(SextanteConfig.SHOW_RECENT_ALGORITHMS)
if showRecent:
self.addRecentAlgorithms()
self.addRecentAlgorithms(True)
if isinstance(item, TreeActionItem):
action = item.action
action.setData(self)
Expand All @@ -147,13 +147,13 @@ def fillTree(self):
else:
self.fillTreeUsingProviders()
self.algorithmTree.sortItems(0, Qt.AscendingOrder)
self.addRecentAlgorithms()
self.addRecentAlgorithms(False)

def addRecentAlgorithms(self):
def addRecentAlgorithms(self, updating):
showRecent = SextanteConfig.getSetting(SextanteConfig.SHOW_RECENT_ALGORITHMS)
if showRecent:
first = self.algorithmTree.topLevelItem(0)
if first != None and first.text(0) == "Recently used algorithms":
if updating:
self.algorithmTree.removeItemWidget(first, 0)
recent = SextanteLog.getRecentAlgorithms()
if len(recent) != 0:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Binary Morphological Operation
otbcli_BinaryMorphologicalOperation
Binary Morphological Operation
Image Filtering
ParameterRaster|-in|Input Image|False
OutputRaster|-out|Output Image
ParameterNumber|-ram|Available RAM (Mb)|None|None|128
ParameterNumber|-channel|Selected Channel|None|None|1
ParameterSelection|-structype|Structuring Element Type|ball;cross|0
ParameterNumber|-structype.ball.xradius|The Structuring Element X Radius|None|None|5
ParameterNumber|-structype.ball.yradius|The Structuring Element Y Radius|None|None|5
ParameterSelection|-filter|Morphological Operation|dilate;erode;opening;closing|0
ParameterNumber|-filter.dilate.foreval|Dilate Foreground Value|None|None|1
ParameterNumber|-filter.dilate.backval|Dilate Background Value Value|None|None|0
ParameterNumber|-filter.erode.foreval|Erode Foreground Value|None|None|1
ParameterNumber|-filter.erode.backval|Erode Background Value|None|None|0
ParameterNumber|-filter.opening.foreval|Opening Foreground Value|None|None|1
ParameterNumber|-filter.opening.backval|Opening Background Value|None|None|0
ParameterNumber|-filter.closing.foreval|Closing Foreground Value|None|None|1
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Classification Regularization
otbcli_ClassificationMapRegularization
Classification Regularization
Learning
ParameterRaster|-io.in|Input Image|False
OutputRaster|-io.out|Output Image
ParameterNumber|-ram|Available RAM (Mb)|None|None|128
ParameterNumber|-ip.radius|Structuring Element Radius|None|None|1
ParameterBoolean|-ip.suvbool|Multiple majority|False
ParameterNumber|-ip.nodatalabel|Label for the NoData class|None|None|0
ParameterNumber|-ip.undecidedlabel|Label for the Undecided class|None|None|0
14 changes: 14 additions & 0 deletions python/plugins/sextante/otb/description/ComputeConfusionMatrix.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Compute Confusion Matrix
otbcli_ComputeConfusionMatrix
Compute Confusion Matrix
Learning
ParameterRaster|-in|Input Image|False
OutputFile|-out|Matrix Output
ParameterSelection|-ref|Ground Truth|raster;vector|1
ParameterRaster|-ref.raster.in|Input Reference Image|False
ParameterFile|-ref.vector.in|Input Vector Data|False
ParameterString|-ref.vector.field|Field name|None|None|dn
ParameterNumber|-labels|Number of labels|None|None|2
ParameterNumber|-nodata|Value for nodata pixels|None|None|0
ParameterNumber|-ram|Available RAM (Mb)|None|None|128

12 changes: 12 additions & 0 deletions python/plugins/sextante/otb/description/EdgeExtraction.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Edge Extraction
otbcli_EdgeExtraction
Edge Extraction
Feature Extraction
ParameterRaster|-in|Input Image|False
OutputRaster|-out|Output Image
ParameterNumber|-channel|Selected Channel|None|None|1
ParameterNumber|-ram|Available RAM (Mb)|None|None|128
ParameterSelection|-filter|Edge feature|gradient;sobel;touzi|0
ParameterNumber|-filter.touzi.xradius|The X Radius|None|None|1
ParameterNumber|-filter.touzi.yradius|The Y Radius|None|None|1

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Fusion of Classifications
otbcli_FusionOfClassifications
Fusion of Classifications
Learning
ParameterMultipleInput|-il|Input classifications|-1|False
ParameterNumber|-undecided|Label for the undecided class|None|None|0
OutputRaster|-out|Output Image
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Gray Scale Morphological Operation
otbcli_GrayScaleMorphologicalOperation
Gray Scale Morphological Operation
Image Filtering
ParameterRaster|-in|Input Image|False
OutputRaster|-out|Output Image
ParameterNumber|-channel|Selected Channel|None|None|1
ParameterSelection|-structype|Structuring Element Type|ball;cross|0
ParameterNumber|-structype.ball.xradius|The Structuring Element X Radius|None|None|5
ParameterNumber|-structype.ball.yradius|The Structuring Element Y Radius|None|None|5
ParameterSelection|-filter|Morphological Operation|dilate;erode;opening;closing|0
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Haralick Texture Extraction
otbcli_HaralickTextureExtraction
Haralick Texture Extraction
Feature Extraction
ParameterRaster|-in|Input Image|False
OutputRaster|-out|Output Image
ParameterNumber|-ram|Available RAM (Mb)|None|None|128
ParameterNumber|-channel|Raster Band|None|None|1
ParameterNumber|-parameters.xrad|X Radius|None|None|1
ParameterNumber|-parameters.yrad|Y Radius|None|None|1
ParameterNumber|-parameters.xoff|X Offset|None|None|1
ParameterNumber|-parameters.yoff|Y Offset|None|None|1
ParameterNumber|-parameters.min|Image Minimum|None|None|1
ParameterNumber|-parameters.max|Image Maximum|None|None|255
ParameterNumber|-parameters.nbbin|Histogram number of bin|None|None|8
ParameterSelection|-texture|Texture Set Selection|simple;advanced;higher|0
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Local Statistic Extraction
otbcli_LocalStatisticExtraction
Local Statistic Extraction
Feature Extraction
ParameterRaster|-in|Input Image|False
OutputRaster|-out|Output Image
ParameterNumber|-channel|Selected Channel|None|None|1
ParameterNumber|-ram|Available RAM (Mb)|None|None|128
ParameterNumber|-radius|Neighborhood radius|None|None|3
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
MorphologicalProfilesSegmentationRaster
otbcli_Segmentation
Morphological Profiles Based Segmentation (labeled raster output)
Segmentation
ParameterRaster|-filter mprofiles -in|Input Image|False
ParameterNumber|-filter.mprofiles.size|Profile Size|None|None|5
ParameterNumber|-filter.mprofiles.start|Initial Radius|None|None|1
ParameterNumber|-filter.mprofiles.step|Radius Step|None|None|1
ParameterNumber|-filter.mprofiles.sigma|Threshold of final decision rule|0|None|1
OutputRaster|-mode raster -mode.raster.out|Output labeled image
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MorphologicalProfilesSegmentationVector
otbcli_Segmentation
Morphological Profiles Based Segmentation (large-scale, vector output)
Segmentation
ParameterRaster|-filter mprofiles -in|Input Image|False
ParameterNumber|-filter.mprofiles.size|Profile Size|None|None|5
ParameterNumber|-filter.mprofiles.start|Initial Radius|None|None|1
ParameterNumber|-filter.mprofiles.step|Radius Step|None|None|1
ParameterNumber|-filter.mprofiles.sigma|Threshold of final decision rule|0|None|1
ParameterBoolean|-mode.vector.neighbor|8-neighbor connectivity|False
ParameterBoolean|-mode.vector.stitch|Stitch polygons|True
ParameterNumber|-mode.vector.minsize|Minimum object size|1|None|1
ParameterNumber|-mode.vector.simplify|Simplify polygons|None|None|0.0
ParameterString|-mode.vector.layername|Layer name|layer
ParemeterString|-mode.vector.fieldname|Geometry index field name|DN
ParameterNumber|-mode.vector.tilesize|Tile size|0|None|1024
ParameterNumber|-mode.vector.startlabel|Starting geometry index|1|None|1
ParameterSelection|-mode.vector.outmode|Writing mode (update file/overwrite file/overwrite layer/update layer)|ulco;ovw;ulovw;ulu|0
ParameterString|-mode.vector.ogroptions|OGR options for layer creation|
ParameterVector|-mode.vector.inmask|Mask Image|-1|True
OutputVector|-mode vector -mode.vector.out|Output vector file
12 changes: 12 additions & 0 deletions python/plugins/sextante/otb/description/Pansharpening.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Pansharpening
otbcli_Pansharpening
Pansharpening
Image Manipulation
ParameterRaster|-inp|Input PAN Image|False
ParameterRaster|-inxs|Input XS Image|False
OutputRaster|-out|Output Image
ParameterSelection|-method|Algorithm|rcs;lmvm;bayes|0
ParameterNumber|-method.lmvm.radiusx|X radius|None|None|3
ParameterNumber|-method.lmvm.radiusy|Y radius|None|None|3
ParameterNumber|-method.bayes.s|S coefficient|None|None|1
ParameterNumber|-ram|Available RAM (Mb)|None|None|128
13 changes: 13 additions & 0 deletions python/plugins/sextante/otb/description/RadiometricIndices.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Radiometric Indices
otbcli_RadiometricIndices
Radiometric Indices
Feature Extraction
ParameterRaster|-in|Input Image|False
OutputRaster|-out|Output Image
ParameterNumber|-ram|Available RAM (Mb)|None|None|128
ParameterNumber|-channels.blue|Blue Channel|None|None|1
ParameterNumber|-channels.green|Green Channel|None|None|2
ParameterNumber|-channels.red|Red Channel|None|None|3
ParameterNumber|-channels.nir|NIR Channel|None|None|4
ParameterNumber|-channels.mir|Mir Channel|None|None|5
ParameterSelection|-list|Available Radiometric Indices|Vegetation:NDVI;Vegetation:TNDVI;Vegetation:RVI;Vegetation:SAVI;Vegetation:TSAVI;Vegetation:MSAVI;Vegetation:MSAVI2;Vegetation:GEMI;Vegetation:IPVI;Vegetation:LAIFromNDVILog;Vegetation:LAIFromReflLinear;Vegetation:LAIFromNDVIFormo;Water:NDWI;Water:NDWI2;Water:MNDWI;Water:NDPI;Water:NDTI;Soil:RI;Soil:CI;Soil:BI;Soil:BI2
14 changes: 14 additions & 0 deletions python/plugins/sextante/otb/description/SFSTextureExtraction.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
SFS Texture Extraction
otbcli_SFSTextureExtraction
SFS Texture Extraction
Feature Extraction
ParameterRaster|-in|Input Image|False
OutputRaster|-out|Output Image
ParameterNumber|-channel|Selected Channel|None|None|1
ParameterNumber|-ram|Available RAM (Mb)|None|None|128
ParameterNumber|-parameters.spethre|Spectral Threshold|None|None|50
ParameterNumber|-parameters.spathre|Spatial Threshold|None|None|100
ParameterNumber|-parameters.nbdir|Number of Direction|None|None|20
ParameterNumber|-parameters.alpha|Alpha|None|None|1
ParameterNumber|-parameters.maxcons|Ratio Maximum Consideration Number |None|None|5

2 changes: 1 addition & 1 deletion python/plugins/sextante/r/RAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def processParameterLine(self,line):
self.showPlots = True
self.addOutput(OutputHTML(RAlgorithm.RPLOTS, "R Plots"));
return
if line.lower().strip().startswith("usereadgdal"):
if line.lower().strip().startswith("dontuserasterpackage"):
self.useRasterPackage = False
return
if line.lower().strip().startswith("passfilenames"):
Expand Down
9 changes: 7 additions & 2 deletions src/app/composer/qgscomposeritemwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,13 +349,15 @@ void QgsComposerItemWidget::setValuesForGuiElements()
mFrameGroupBox->blockSignals( true );
mBackgroundGroupBox->blockSignals( true );
mItemIdLineEdit->blockSignals( true );
mItemUuidLineEdit->blockSignals( true );
mTransparencySpinBox->blockSignals( true );

int alphaPercent = ( 255 - mItem->brush().color().alpha() ) / 2.55;
mTransparencySpinBox->setValue( alphaPercent );
mTransparencySlider->setValue( alphaPercent );
mOutlineWidthSpinBox->setValue( mItem->pen().widthF() );
mItemIdLineEdit->setText( mItem->id() );
mItemUuidLineEdit->setText( mItem->uuid() );
mFrameGroupBox->setChecked( mItem->hasFrame() );
mBackgroundGroupBox->setChecked( mItem->hasBackground() );

Expand All @@ -364,15 +366,18 @@ void QgsComposerItemWidget::setValuesForGuiElements()
mFrameGroupBox->blockSignals( false );
mBackgroundGroupBox->blockSignals( false );
mItemIdLineEdit->blockSignals( false );
mItemUuidLineEdit->blockSignals( false );
mTransparencySpinBox->blockSignals( false );
}

void QgsComposerItemWidget::on_mItemIdLineEdit_textChanged( const QString &text )

void QgsComposerItemWidget::on_mItemIdLineEdit_editingFinished()
{
if ( mItem )
{
mItem->beginCommand( tr( "Item id changed" ), QgsComposerMergeCommand::ComposerLabelSetId );
mItem->setId( text );
mItem->setId( mItemIdLineEdit->text() );
mItemIdLineEdit->setText( mItem->id() );
mItem->endCommand();
}
}
2 changes: 1 addition & 1 deletion src/app/composer/qgscomposeritemwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class QgsComposerItemWidget: public QWidget, private Ui::QgsComposerItemWidgetBa
void on_mOutlineWidthSpinBox_valueChanged( double d );
void on_mFrameGroupBox_toggled( bool state );
void on_mBackgroundGroupBox_toggled( bool state );
void on_mItemIdLineEdit_textChanged( const QString& text );
void on_mItemIdLineEdit_editingFinished();

//adjust coordinates in line edits
void on_mXLineEdit_editingFinished() { changeItemPosition(); }
Expand Down
10 changes: 0 additions & 10 deletions src/app/composer/qgscomposerlabelwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,16 +227,6 @@ void QgsComposerLabelWidget::on_mMiddleRadioButton_clicked()
}
}

void QgsComposerLabelWidget::on_mLabelIdLineEdit_textChanged( const QString& text )
{
if ( mComposerLabel )
{
mComposerLabel->beginCommand( tr( "Label id changed" ), QgsComposerMergeCommand::ComposerLabelSetId );
mComposerLabel->setId( text );
mComposerLabel->endCommand();
}
}

void QgsComposerLabelWidget::on_mRotationSpinBox_valueChanged( double v )
{
if ( mComposerLabel )
Expand Down
1 change: 0 additions & 1 deletion src/app/composer/qgscomposerlabelwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class QgsComposerLabelWidget: public QWidget, private Ui::QgsComposerLabelWidget
void on_mTopRadioButton_clicked();
void on_mBottomRadioButton_clicked();
void on_mMiddleRadioButton_clicked();
void on_mLabelIdLineEdit_textChanged( const QString& text );
void on_mRotationSpinBox_valueChanged( double v );

private slots:
Expand Down
5 changes: 4 additions & 1 deletion src/app/legend/qgslegend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2775,7 +2775,10 @@ void QgsLegend::legendLayerStretchUsingCurrentExtent()
layer->setContrastEnhancementAlgorithm( "StretchToMinimumMaximum" );
}

layer->setMinimumMaximumUsingLastExtent();
QgsRectangle myRectangle;
myRectangle = mMapCanvas->mapRenderer()->outputExtentToLayerExtent( layer, mMapCanvas->extent() );
layer->setContrastEnhancementAlgorithm( layer->contrastEnhancementAlgorithm(), QgsRasterLayer::ContrastEnhancementMinMax, myRectangle );

layer->setCacheImage( NULL );
refreshLayerSymbology( layer->id() );
mMapCanvas->refresh();
Expand Down
3 changes: 2 additions & 1 deletion src/app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,7 @@ int main( int argc, char *argv[] )
if ( !customizationfile.isEmpty() )
{
customizationsettings = new QSettings( customizationfile, QSettings::IniFormat );
QgsCustomization::instance()->setEnabled(true);
}

// Load and set possible default customization, must be done afterQgsApplication init and QSettings ( QCoreApplication ) init
Expand Down Expand Up @@ -696,7 +697,7 @@ int main( int argc, char *argv[] )
}

//set up splash screen
QString mySplashPath( QgsApplication::splashPath() );
QString mySplashPath( QgsCustomization::instance()->splashPath() );
QPixmap myPixmap( mySplashPath + QString( "splash.png" ) );
QSplashScreen *mypSplash = new QSplashScreen( myPixmap );
if ( mySettings.value( "/qgis/hideSplash" ).toBool() || myHideSplash )
Expand Down
66 changes: 66 additions & 0 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@
#include "qgsrasterlayer.h"
#include "qgsrasterlayerproperties.h"
#include "qgsrasternuller.h"
#include "qgsbrightnesscontrastfilter.h"
#include "qgsrasterrenderer.h"
#include "qgsrasterlayersaveasdialog.h"
#include "qgsrectangle.h"
Expand Down Expand Up @@ -1050,6 +1051,10 @@ void QgisApp::createActions()
connect( mActionFullHistogramStretch, SIGNAL( triggered() ), this, SLOT( fullHistogramStretch() ) );
connect( mActionLocalCumulativeCutStretch, SIGNAL( triggered() ), this, SLOT( localCumulativeCutStretch() ) );
connect( mActionFullCumulativeCutStretch, SIGNAL( triggered() ), this, SLOT( fullCumulativeCutStretch() ) );
connect( mActionIncreaseBrightness, SIGNAL( triggered() ), this, SLOT( increaseBrightness() ) );
connect( mActionDecreaseBrightness, SIGNAL( triggered() ), this, SLOT( decreaseBrightness() ) );
connect( mActionIncreaseContrast, SIGNAL( triggered() ), this, SLOT( increaseContrast() ) );
connect( mActionDecreaseContrast, SIGNAL( triggered() ), this, SLOT( decreaseContrast() ) );

// Vector Menu Items
connect( mActionOSMDownload, SIGNAL( triggered() ), this, SLOT( osmDownloadDialog() ) );
Expand Down Expand Up @@ -1675,6 +1680,10 @@ void QgisApp::setTheme( QString theThemeName )
mActionHelpContents->setIcon( QgsApplication::getThemeIcon( "/mActionHelpContents.png" ) );
mActionLocalHistogramStretch->setIcon( QgsApplication::getThemeIcon( "/mActionLocalHistogramStretch.png" ) );
mActionFullHistogramStretch->setIcon( QgsApplication::getThemeIcon( "/mActionFullHistogramStretch.png" ) );
mActionIncreaseBrightness->setIcon( QgsApplication::getThemeIcon( "/mActionIncreaseBrightness.svg" ) );
mActionDecreaseBrightness->setIcon( QgsApplication::getThemeIcon( "/mActionDecreaseBrightness.svg" ) );
mActionIncreaseContrast->setIcon( QgsApplication::getThemeIcon( "/mActionIncreaseContrast.svg" ) );
mActionDecreaseContrast->setIcon( QgsApplication::getThemeIcon( "/mActionDecreaseContrast.svg" ) );
mActionZoomActualSize->setIcon( QgsApplication::getThemeIcon( "/mActionZoomNative.png" ) );
mActionQgisHomePage->setIcon( QgsApplication::getThemeIcon( "/mActionQgisHomePage.png" ) );
mActionAbout->setIcon( QgsApplication::getThemeIcon( "/mActionHelpAbout.png" ) );
Expand Down Expand Up @@ -6454,6 +6463,63 @@ void QgisApp::histogramStretch( bool visibleAreaOnly, QgsRasterLayer::ContrastEn
mMapCanvas->refresh();
}

void QgisApp::increaseBrightness()
{
adjustBrightnessContrast( 1 );
}

void QgisApp::decreaseBrightness()
{
adjustBrightnessContrast( -1 );
}

void QgisApp::increaseContrast()
{
adjustBrightnessContrast( 1, false );
}

void QgisApp::decreaseContrast()
{
adjustBrightnessContrast( -1, false );
}


void QgisApp::adjustBrightnessContrast( int delta, bool updateBrightness )
{
QgsMapLayer * myLayer = mMapLegend->currentLayer();

if ( !myLayer )
{
QMessageBox::information( this,
tr( "No Layer Selected" ),
tr( "To change brightness or contrast, you need to have a raster layer selected." ) );
return;
}

QgsRasterLayer* myRasterLayer = qobject_cast<QgsRasterLayer *>( myLayer );
if ( !myRasterLayer )
{
QMessageBox::information( this,
tr( "No Raster Layer Selected" ),
tr( "To change brightness or contrast, you need to have a raster layer selected." ) );
return;
}

QgsBrightnessContrastFilter* brightnessFilter = myRasterLayer->brightnessFilter();

if ( updateBrightness )
{
brightnessFilter->setBrightness( brightnessFilter->brightness() + delta );
}
else
{
brightnessFilter->setContrast( brightnessFilter->contrast() + delta );
}

myRasterLayer->setCacheImage( NULL );
mMapCanvas->refresh();
}

void QgisApp::helpContents()
{
openURL( "index.html" );
Expand Down
20 changes: 20 additions & 0 deletions src/app/qgisapp.h
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,22 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
void localCumulativeCutStretch();
/** Perform a full extent cumulative cut stretch */
void fullCumulativeCutStretch();
/**Increase raster brightness
* Valid for non wms raster layers only.
* @note Added in QGIS 2.0 */
void increaseBrightness();
/**Decrease raster brightness
* Valid for non wms raster layers only.
* @note Added in QGIS 2.0 */
void decreaseBrightness();
/**Increase raster contrast
* Valid for non wms raster layers only.
* @note Added in QGIS 2.0 */
void increaseContrast();
/**Decrease raster contrast
* Valid for non wms raster layers only.
* @note Added in QGIS 2.0 */
void decreaseContrast();
//! plugin manager
void showPluginManager();
//! load python support if possible
Expand Down Expand Up @@ -1143,6 +1159,10 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
/**Do histogram stretch for singleband gray / multiband color rasters*/
void histogramStretch( bool visibleAreaOnly = false, QgsRasterLayer::ContrastEnhancementLimits theLimits = QgsRasterLayer::ContrastEnhancementMinMax );

/**Apply raster brightness
* @note Added in QGIS 2.0 */
void adjustBrightnessContrast( int delta, bool updateBrightness = true );

QgisAppStyleSheet* mStyleSheetBuilder;

// actions for menus and toolbars -----------------
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgisappstylesheet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ QMap<QString, QVariant> QgisAppStyleSheet::defaultOptions()
QgsDebugMsg( QString( "fontFamily: %1" ).arg( fontFamily ) );
opts.insert( "fontFamily", QVariant( fontFamily ) );

bool gbxCustom = false;
bool gbxCustom = ( mMacStyle ? true : false );
opts.insert( "groupBoxCustom", settings.value( "groupBoxCustom", QVariant( gbxCustom ) ) );

bool gbxBoldTitle = false;
Expand Down
25 changes: 18 additions & 7 deletions src/app/qgsaddattrdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,25 @@ void QgsAddAttrDialog::on_mTypeBox_currentIndexChanged( int idx )
mLength->setValue( mLength->minimum() );
if ( mLength->value() > mLength->maximum() )
mLength->setValue( mLength->maximum() );
setPrecisionMinMax();
}

void QgsAddAttrDialog::on_mLength_editingFinished()
{
setPrecisionMinMax();
}

mPrec->setMinimum( mTypeBox->itemData( idx, Qt::UserRole + 4 ).toInt() );
mPrec->setMaximum( mTypeBox->itemData( idx, Qt::UserRole + 5 ).toInt() );
mPrec->setVisible( mPrec->minimum() < mPrec->maximum() );
if ( mPrec->value() < mPrec->minimum() )
mPrec->setValue( mPrec->minimum() );
if ( mPrec->value() > mPrec->maximum() )
mPrec->setValue( mPrec->maximum() );
void QgsAddAttrDialog::setPrecisionMinMax()
{
int idx = mTypeBox->currentIndex();
int minPrecType = mTypeBox->itemData( idx, Qt::UserRole + 4 ).toInt();
int maxPrecType = mTypeBox->itemData( idx, Qt::UserRole + 5 ).toInt();
mPrec->setVisible( minPrecType < maxPrecType );
if ( mPrec->isVisible() )
{
mPrec->setMinimum( minPrecType );
mPrec->setMaximum( qMin( maxPrecType, mLength->value() ) );
}
}

void QgsAddAttrDialog::accept()
Expand Down
2 changes: 2 additions & 0 deletions src/app/qgsaddattrdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@ class QgsAddAttrDialog: public QDialog, private Ui::QgsAddAttrDialogBase

public slots:
void on_mTypeBox_currentIndexChanged( int idx );
void on_mLength_editingFinished();
void accept();

private:
QString mLayerType;

void setPrecisionMinMax();
};

#endif
4 changes: 2 additions & 2 deletions src/app/qgsattributedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ QgsAttributeDialog::QgsAttributeDialog( QgsVectorLayer *vl, QgsFeature *thepFeat

if ( vl->editType( fldIdx ) != QgsVectorLayer::Immutable )
{
myWidget->setEnabled( vl->isEditable() && vl->fieldEditable(fldIdx) );
myWidget->setEnabled( vl->isEditable() && vl->fieldEditable( fldIdx ) );
}

mypInnerLayout->addWidget( myWidget, index, 1 );
Expand Down Expand Up @@ -239,7 +239,7 @@ QgsAttributeDialog::QgsAttributeDialog( QgsVectorLayer *vl, QgsFeature *thepFeat

if ( vl->editType( fldIdx ) != QgsVectorLayer::Immutable )
{
( *itw )->setEnabled( (*itw)->isEnabled() && vl->isEditable() && vl->fieldEditable( fldIdx ) );
( *itw )->setEnabled(( *itw )->isEnabled() && vl->isEditable() && vl->fieldEditable( fldIdx ) );
}
}
}
Expand Down
20 changes: 17 additions & 3 deletions src/app/qgsattributetypedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ QgsVectorLayer::ValueRelationData QgsAttributeTypeDialog::valueRelationData()
return mValueRelationData;
}

QString QgsAttributeTypeDialog::dateFormat()
{
return mDateFormat;
}

QMap<QString, QVariant> &QgsAttributeTypeDialog::valueMap()
{
return mValueMap;
Expand All @@ -89,7 +94,7 @@ bool QgsAttributeTypeDialog::fieldEditable()
return isFieldEditableCheckBox->isChecked();
}

void QgsAttributeTypeDialog::setFieldEditable(bool editable)
void QgsAttributeTypeDialog::setFieldEditable( bool editable )
{
isFieldEditableCheckBox->setChecked( editable );
}
Expand Down Expand Up @@ -338,6 +343,11 @@ void QgsAttributeTypeDialog::setValueRelation( QgsVectorLayer::ValueRelationData
mValueRelationData = valueRelation;
}

void QgsAttributeTypeDialog::setDateFormat( QString dateFormat )
{
mDateFormat = dateFormat;
}

void QgsAttributeTypeDialog::setIndex( int index, QgsVectorLayer::EditType editType )
{
mIndex = index;
Expand Down Expand Up @@ -446,6 +456,7 @@ void QgsAttributeTypeDialog::setIndex( int index, QgsVectorLayer::EditType editT
maximumDoubleSpinBox->setValue( mRangeData.mMax.toDouble() );
stepDoubleSpinBox->setValue( mRangeData.mStep.toDouble() );
}

if ( editType == QgsVectorLayer::EditRange )
{
rangeWidget->setCurrentIndex( 0 );
Expand Down Expand Up @@ -475,6 +486,10 @@ void QgsAttributeTypeDialog::setIndex( int index, QgsVectorLayer::EditType editT
valueRelationFilterExpression->setText( mValueRelationData.mFilterExpression );
break;

case QgsVectorLayer::Calendar:
leDateFormat->setText( mDateFormat );
break;

case QgsVectorLayer::LineEdit:
case QgsVectorLayer::UniqueValues:
case QgsVectorLayer::Classification:
Expand All @@ -484,13 +499,11 @@ void QgsAttributeTypeDialog::setIndex( int index, QgsVectorLayer::EditType editT
case QgsVectorLayer::Immutable:
case QgsVectorLayer::Hidden:
case QgsVectorLayer::TextEdit:
case QgsVectorLayer::Calendar:
case QgsVectorLayer::UuidGenerator:
break;
}
}


void QgsAttributeTypeDialog::setPage( int index )
{
selectionListWidget->setCurrentRow( index );
Expand Down Expand Up @@ -639,6 +652,7 @@ void QgsAttributeTypeDialog::accept()
break;
case 11:
mEditType = QgsVectorLayer::Calendar;
mDateFormat = leDateFormat->text();
break;
case 12:
mEditType = QgsVectorLayer::ValueRelation;
Expand Down
12 changes: 12 additions & 0 deletions src/app/qgsattributetypedialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ class QgsAttributeTypeDialog: public QDialog, private Ui::QgsAttributeTypeDialog
*/
void setValueRelation( QgsVectorLayer::ValueRelationData valueRelationData );

/**
* Setter to date format
* @param dateFormat date format
*/
void setDateFormat( QString dateFormat );

/**
* Setter for checkbox for editable state of field
* @param bool editable
Expand Down Expand Up @@ -111,6 +117,11 @@ class QgsAttributeTypeDialog: public QDialog, private Ui::QgsAttributeTypeDialog
*/
QgsVectorLayer::ValueRelationData valueRelationData();

/**
* Getter for date format
*/
QString dateFormat();

/**
* Getter for checkbox for editable state of field
*/
Expand Down Expand Up @@ -181,6 +192,7 @@ class QgsAttributeTypeDialog: public QDialog, private Ui::QgsAttributeTypeDialog
QgsVectorLayer::RangeData mRangeData;
QgsVectorLayer::ValueRelationData mValueRelationData;
QgsVectorLayer::EditType mEditType;
QString mDateFormat;
};

#endif
13 changes: 13 additions & 0 deletions src/app/qgscustomization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,19 @@ void QgsCustomization::preNotify( QObject * receiver, QEvent * event, bool * don
}
}

QString QgsCustomization::splashPath()
{
if ( isEnabled() )
{
QString path = mSettings->value( "/Customization/splashpath", QgsApplication::splashPath() ).toString();
return path;
}
else
{
return QgsApplication::splashPath();
}
}

void QgsCustomization::loadDefault()
{
QSettings mySettings;
Expand Down
3 changes: 3 additions & 0 deletions src/app/qgscustomization.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ class QgsCustomization : public QObject

void setSettings( QSettings* settings ) { mSettings = settings ;}

// Return the path to the splash screen
QString splashPath();

// Load and set default customization
void loadDefault();

Expand Down
16 changes: 13 additions & 3 deletions src/app/qgsfieldsproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,8 @@ void QgsFieldsProperties::attributeTypeDialog()
QPair<QString, QString> checkStates = mCheckedStates.value( index, mLayer->checkedState( index ) );
attributeTypeDialog.setCheckedState( checkStates.first, checkStates.second );

attributeTypeDialog.setDateFormat( mLayer->dateFormat( index ) );

attributeTypeDialog.setIndex( index, mEditTypeMap.value( index, mLayer->editType( index ) ) );

attributeTypeDialog.setFieldEditable( mLayer->fieldEditable( index ) );
Expand Down Expand Up @@ -517,6 +519,9 @@ void QgsFieldsProperties::attributeTypeDialog()
case QgsVectorLayer::ValueRelation:
mValueRelationData.insert( index, attributeTypeDialog.valueRelationData() );
break;
case QgsVectorLayer::Calendar:
mDateFormat.insert( index, attributeTypeDialog.dateFormat() );
break;
case QgsVectorLayer::LineEdit:
case QgsVectorLayer::TextEdit:
case QgsVectorLayer::UniqueValues:
Expand All @@ -526,7 +531,6 @@ void QgsFieldsProperties::attributeTypeDialog()
case QgsVectorLayer::Enumeration:
case QgsVectorLayer::Immutable:
case QgsVectorLayer::Hidden:
case QgsVectorLayer::Calendar:
case QgsVectorLayer::UuidGenerator:
break;
}
Expand Down Expand Up @@ -820,7 +824,7 @@ void QgsFieldsProperties::apply()
QgsVectorLayer::EditType editType = editTypeFromButtonText( pb->text() );
mLayer->setEditType( idx, editType );

mLayer->setFieldEditable( idx, mFieldEditables.value( idx, true ));
mLayer->setFieldEditable( idx, mFieldEditables.value( idx, true ) );

switch ( editType )
{
Expand Down Expand Up @@ -856,6 +860,13 @@ void QgsFieldsProperties::apply()
}
break;

case QgsVectorLayer::Calendar:
if ( mDateFormat.contains( idx ) )
{
mLayer->dateFormat( idx ) = mDateFormat[idx];
}
break;

case QgsVectorLayer::LineEdit:
case QgsVectorLayer::UniqueValues:
case QgsVectorLayer::UniqueValuesEditable:
Expand All @@ -865,7 +876,6 @@ void QgsFieldsProperties::apply()
case QgsVectorLayer::Immutable:
case QgsVectorLayer::Hidden:
case QgsVectorLayer::TextEdit:
case QgsVectorLayer::Calendar:
case QgsVectorLayer::UuidGenerator:
break;
}
Expand Down
1 change: 1 addition & 0 deletions src/app/qgsfieldsproperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ class QgsFieldsProperties : public QWidget, private Ui_QgsFieldsPropertiesBase
QMap<int, QPair<QString, QString> > mCheckedStates;
QMap<int, QgsVectorLayer::EditType> mEditTypeMap;
QMap<int, QPushButton*> mButtonMap;
QMap<int, QString> mDateFormat;

enum attrColumns
{
Expand Down
14 changes: 10 additions & 4 deletions src/app/qgsidentifyresultsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,13 +341,13 @@ void QgsIdentifyResultsDialog::addFeature( QgsVectorLayer *vlayer, const QgsFeat
if ( i >= fields.count() )
continue;

QTreeWidgetItem *attrItem = new QTreeWidgetItem( QStringList() << QString::number( i ) << attrs[i].toString() );
QString value = fields[i].displayString( attrs[i] );
QTreeWidgetItem *attrItem = new QTreeWidgetItem( QStringList() << QString::number( i ) << value );

attrItem->setData( 0, Qt::DisplayRole, vlayer->attributeDisplayName( i ) );
attrItem->setData( 0, Qt::UserRole, fields[i].name() );
attrItem->setData( 0, Qt::UserRole + 1, i );

QVariant value = attrs[i];
attrItem->setData( 1, Qt::UserRole, value );

switch ( vlayer->editType( i ) )
Expand All @@ -358,7 +358,12 @@ void QgsIdentifyResultsDialog::addFeature( QgsVectorLayer *vlayer, const QgsFeat
continue;

case QgsVectorLayer::ValueMap:
value = vlayer->valueMap( i ).key( value.toString(), QString( "(%1)" ).arg( value.toString() ) );
value = vlayer->valueMap( i ).key( value, QString( "(%1)" ).arg( value ) );
break;

case QgsVectorLayer::Calendar:
if ( attrs[i].canConvert( QVariant::Date ) )
value = attrs[i].toDate().toString( vlayer->dateFormat( i ) );
break;

default:
Expand Down Expand Up @@ -438,7 +443,6 @@ void QgsIdentifyResultsDialog::addFeature( QgsRasterLayer *layer,
layItem = new QTreeWidgetItem( QStringList() << QString::number( lstResults->topLevelItemCount() ) << layer->name() );
layItem->setData( 0, Qt::UserRole, QVariant::fromValue( qobject_cast<QObject *>( layer ) ) );

layItem->setData( 0, GetFeatureInfoUrlRole, params.value( "getFeatureInfoUrl" ) );
lstResults->addTopLevelItem( layItem );

QComboBox *formatCombo = new QComboBox();
Expand Down Expand Up @@ -476,6 +480,8 @@ void QgsIdentifyResultsDialog::addFeature( QgsRasterLayer *layer,
connect( layer, SIGNAL( destroyed() ), this, SLOT( layerDestroyed() ) );
connect( layer, SIGNAL( layerCrsChanged() ), this, SLOT( layerDestroyed() ) );
}
// Set/reset getFeatureInfoUrl (currently only available for Feature, so it may change if format changes)
layItem->setData( 0, GetFeatureInfoUrlRole, params.value( "getFeatureInfoUrl" ) );

QgsIdentifyResultsFeatureItem *featItem = new QgsIdentifyResultsFeatureItem( fields, feature, layer->crs(), QStringList() << label << "" );
layItem->addChild( featItem );
Expand Down
7 changes: 4 additions & 3 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ SET(QGIS_CORE_SRCS
symbology-ng/qgspointdisplacementrenderer.cpp
symbology-ng/qgsvectorfieldsymbollayer.cpp
symbology-ng/qgscolorbrewerpalette.cpp

diagram/qgsdiagram.cpp
diagram/qgspiediagram.cpp
diagram/qgstextdiagram.cpp
diagram/qgshistogramdiagram.cpp

qgis.cpp
qgsapplication.cpp
qgsattributeaction.cpp
Expand Down Expand Up @@ -204,6 +204,7 @@ SET(QGIS_CORE_SRCS
raster/qgssinglebandcolordatarenderer.cpp
raster/qgssinglebandgrayrenderer.cpp
raster/qgssinglebandpseudocolorrenderer.cpp
raster/qgsbrightnesscontrastfilter.cpp

renderer/qgscontinuouscolorrenderer.cpp
renderer/qgsgraduatedsymbolrenderer.cpp
Expand Down Expand Up @@ -446,7 +447,7 @@ SET(QGIS_CORE_HDRS
diagram/qgstextdiagram.h
diagram/qgshistogramdiagram.h


composer/qgslegendmodel.h
composer/qgscomposerlegenditem.h

Expand Down
21 changes: 19 additions & 2 deletions src/core/composer/qgscomposeritem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@
#include <QGraphicsSceneMouseEvent>
#include <QGraphicsView>
#include <QPainter>
#include <QUuid>

#include "qgsproject.h"

#include "qgscomposition.h"
#include "qgscomposeritem.h"
#include "qgscomposerframe.h"


#include <limits>
#include "qgsapplication.h"
#include "qgsrectangle.h" //just for debugging
Expand All @@ -51,6 +53,8 @@ QgsComposerItem::QgsComposerItem( QgsComposition* composition, bool manageZValue
, mLastValidViewScaleFactor( -1 )
, mRotation( 0 )
, mLastUsedPositionMode( UpperLeft )
, mId( "" )
, mUuid( QUuid::createUuid().toString() )
{
init( manageZValue );
}
Expand All @@ -68,6 +72,8 @@ QgsComposerItem::QgsComposerItem( qreal x, qreal y, qreal width, qreal height, Q
, mLastValidViewScaleFactor( -1 )
, mRotation( 0 )
, mLastUsedPositionMode( UpperLeft )
, mId( "" )
, mUuid( QUuid::createUuid().toString() )
{
init( manageZValue );
QTransform t;
Expand Down Expand Up @@ -153,6 +159,7 @@ bool QgsComposerItem::_writeXML( QDomElement& itemElem, QDomDocument& doc ) cons
composerItemElem.setAttribute( "zValue", QString::number( zValue() ) );
composerItemElem.setAttribute( "outlineWidth", QString::number( pen().widthF() ) );
composerItemElem.setAttribute( "rotation", QString::number( mRotation ) );
composerItemElem.setAttribute( "uuid", mUuid );
composerItemElem.setAttribute( "id", mId );
//position lock for mouse moves/resizes
if ( mItemPositionLocked )
Expand Down Expand Up @@ -201,8 +208,12 @@ bool QgsComposerItem::_readXML( const QDomElement& itemElem, const QDomDocument&
//rotation
mRotation = itemElem.attribute( "rotation", "0" ).toDouble();

//uuid
mUuid = itemElem.attribute( "uuid", QUuid::createUuid().toString() );

//id
mId = itemElem.attribute( "id", "" );
QString id = itemElem.attribute( "id", "" );
setId(id);

//frame
QString frame = itemElem.attribute( "frame" );
Expand Down Expand Up @@ -1255,3 +1266,9 @@ void QgsComposerItem::repaint()
{
update();
}

void QgsComposerItem::setId( const QString& id )
{
setToolTip( id );
mId = id;
}
19 changes: 12 additions & 7 deletions src/core/composer/qgscomposeritem.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,15 +261,18 @@ class CORE_EXPORT QgsComposerItem: public QObject, public QGraphicsRectItem
/**Updates item, with the possibility to do custom update for subclasses*/
virtual void updateItem() { QGraphicsRectItem::update(); }

/**Get item identification name
/**Get item's id (which is not necessarly unique)
@note this method was added in version 1.7*/
QString id() const { return mId; }

/**Set item identification name
@note this method was added in version 1.7
This method was moved from qgscomposerlabel so that every object can have a
id (NathanW)*/
void setId( const QString& id ) { mId = id; }
/**Set item's id (which is not necessarly unique)
@note this method was added in version 1.7*/
virtual void setId( const QString& id );

/**Get item identification name
@note this method was added in version 2.0
@note there is not setter since one can't manually set the id*/
QString uuid() const { return mUuid; }

public slots:
virtual void setRotation( double r );
Expand Down Expand Up @@ -392,8 +395,10 @@ class CORE_EXPORT QgsComposerItem: public QObject, public QGraphicsRectItem
/**Emitted if the rectangle changes*/
void sizeChanged();
private:
// Label id (unique within the same composition)
// id (not unique)
QString mId;
// name (unique)
QString mUuid;

void init( bool manageZValue );
};
Expand Down
20 changes: 13 additions & 7 deletions src/core/composer/qgscomposerlegend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ QSizeF QgsComposerLegend::paintAndDetermineSize( QPainter* painter )
point.ry() += spaceAboveAtom( atom );
}

drawAtom( atom, painter, point );
columnWidth = qMax( atom.size.width(), columnWidth );
QSizeF atomSize = drawAtom( atom, painter, point );
columnWidth = qMax( atomSize.width(), columnWidth );

point.ry() += atom.size.height();
columnMaxHeight = qMax( point.y() - columnTop, columnMaxHeight );
Expand Down Expand Up @@ -380,7 +380,8 @@ QgsComposerLegend::Nucleon QgsComposerLegend::drawSymbolItem( QgsComposerLegendI

if ( painter ) painter->setPen( mFontColor );

double labelX = point.x() + labelXOffset; // + mIconLabelSpace;
//double labelX = point.x() + labelXOffset; // + mIconLabelSpace;
double labelX = point.x() + qMax( symbolSize.width(), labelXOffset );

// Vertical alignment of label with symbol:
// a) label height < symbol heigh: label centerd with symbol
Expand All @@ -401,7 +402,7 @@ QgsComposerLegend::Nucleon QgsComposerLegend::drawSymbolItem( QgsComposerLegendI
for ( QStringList::Iterator itemPart = lines.begin(); itemPart != lines.end(); ++itemPart )
{
if ( painter ) drawText( painter, labelX, labelY, *itemPart , mItemFont );
labelSize.rwidth() = qMax( textWidthMillimeters( mItemFont, *itemPart ), double(labelSize.width()) );
labelSize.rwidth() = qMax( textWidthMillimeters( mItemFont, *itemPart ), double( labelSize.width() ) );
if ( itemPart != lines.end() )
{
labelY += mlineSpacing + textHeight;
Expand All @@ -413,7 +414,7 @@ QgsComposerLegend::Nucleon QgsComposerLegend::drawSymbolItem( QgsComposerLegendI
nucleon.symbolSize = symbolSize;
nucleon.labelSize = labelSize;
//QgsDebugMsg( QString( "symbol height = %1 label height = %2").arg( symbolSize.height()).arg( labelSize.height() ));
double width = symbolSize.width() + labelXOffset + labelSize.width();
double width = qMax( symbolSize.width(), labelXOffset ) + labelSize.width();
double height = qMax( symbolSize.height(), labelSize.height() );
nucleon.size = QSizeF( width, height );
return nucleon;
Expand Down Expand Up @@ -941,9 +942,11 @@ QList<QgsComposerLegend::Atom> QgsComposerLegend::createAtomList( QStandardItem*
return atoms;
}

void QgsComposerLegend::drawAtom( Atom atom, QPainter* painter, QPointF point )
// Draw atom and expand its size (using actual nucleons labelXOffset)
QSizeF QgsComposerLegend::drawAtom( Atom atom, QPainter* painter, QPointF point )
{
bool first = true;
QSizeF size = QSizeF( atom.size );
foreach ( Nucleon nucleon, atom.nucleons )
{
QgsComposerLegendItem* item = nucleon.item;
Expand All @@ -970,11 +973,14 @@ void QgsComposerLegend::drawAtom( Atom atom, QPainter* painter, QPointF point )
{
if ( !first ) point.ry() += mSymbolSpace;
double labelXOffset = nucleon.labelXOffset;
drawSymbolItem( item, painter, point, labelXOffset );
Nucleon symbolNucleon = drawSymbolItem( item, painter, point, labelXOffset );
// expand width, it may be wider because of labelXOffset
size.rwidth() = qMax( symbolNucleon.size.width(), size.width() );
}
point.ry() += nucleon.size.height();
first = false;
}
return size;
}

double QgsComposerLegend::spaceAboveAtom( Atom atom )
Expand Down
3 changes: 2 additions & 1 deletion src/core/composer/qgscomposerlegend.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,8 @@ class CORE_EXPORT QgsComposerLegend : public QgsComposerItem
void drawLineSymbol( QPainter*, QgsSymbol* s, double currentYCoord, double& currentXPosition, int opacity = 255 ) const;
void drawPolygonSymbol( QPainter* p, QgsSymbol* s, double currentYCoord, double& currentXPosition, int opacity = 255 ) const;

void drawAtom( Atom atom, QPainter* painter = 0, QPointF point = QPointF() );
/** Draw atom and return its actual size */
QSizeF drawAtom( Atom atom, QPainter* painter = 0, QPointF point = QPointF() );

double spaceAboveAtom( Atom atom );

Expand Down
66 changes: 66 additions & 0 deletions src/core/composer/qgscomposition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,61 @@ const QgsComposerItem* QgsComposition::getComposerItemById( QString theId ) cons
}
return 0;
}
/*
const QgsComposerItem* QgsComposition::getComposerItemByUuid( QString theUuid, bool inAllComposers ) const
{
//This does not work since it seems impossible to get the QgisApp::instance() from here... Is there a workaround ?
QSet<QgsComposer*> composers = QSet<QgsComposer*>();

if( inAllComposers )
{
composers = QgisApp::instance()->printComposers();
}
else
{
composers.insert( this )
}

QSet<QgsComposer*>::const_iterator it = composers.constBegin();
for ( ; it != composers.constEnd(); ++it )
{
QList<QGraphicsItem *> itemList = ( *it )->items();
QList<QGraphicsItem *>::iterator itemIt = itemList.begin();
for ( ; itemIt != itemList.end(); ++itemIt )
{
const QgsComposerItem* mypItem = dynamic_cast<const QgsComposerItem *>( *itemIt );
if ( mypItem )
{
if ( mypItem->uuid() == theUuid )
{
return mypItem;
}
}
}
}

return 0;
}
*/

const QgsComposerItem* QgsComposition::getComposerItemByUuid( QString theUuid ) const
{
QList<QGraphicsItem *> itemList = items();
QList<QGraphicsItem *>::iterator itemIt = itemList.begin();
for ( ; itemIt != itemList.end(); ++itemIt )
{
const QgsComposerItem* mypItem = dynamic_cast<const QgsComposerItem *>( *itemIt );
if ( mypItem )
{
if ( mypItem->uuid() == theUuid )
{
return mypItem;
}
}
}

return 0;
}

int QgsComposition::pixelFontSize( double pointSize ) const
{
Expand Down Expand Up @@ -436,6 +491,17 @@ bool QgsComposition::loadFromTemplate( const QDomDocument& doc, QMap<QString, QS
return false;
}

// remove all uuid attributes since we don't want duplicates UUIDS
QDomNodeList composerItemsNodes = importDoc.elementsByTagName("ComposerItem");
for (int i=0; i<composerItemsNodes.count(); ++i)
{
QDomNode composerItemNode = composerItemsNodes.at(i);
if( composerItemNode.isElement() )
{
composerItemNode.toElement().removeAttribute("uuid");
}
}

//addItemsFromXML
addItemsFromXML( importDoc.documentElement(), importDoc, 0, addUndoCommands, 0 );

Expand Down
13 changes: 13 additions & 0 deletions src/core/composer/qgscomposition.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "qgscomposeritemcommand.h"
#include "qgsatlascomposition.h"

class QgisApp;
class QgsComposerFrame;
class QgsComposerItem;
class QgsComposerMap;
Expand All @@ -50,6 +51,7 @@ class QgsComposerAttributeTable;
class QgsComposerMultiFrame;
class QgsComposerMultiFrameCommand;
class QgsVectorLayer;
class QgsComposer;

/** \ingroup MapComposer
* Graphics scene for map printing. The class manages the paper item which always
Expand Down Expand Up @@ -158,13 +160,24 @@ class CORE_EXPORT QgsComposition: public QGraphicsScene
const QgsComposerHtml* getComposerHtmlByItem( QgsComposerItem *item ) const;

/**Returns a composer item given its text identifier.
Ids are not necessarely unique, but this function returns only one element.
@note added in 2.0
@param theId - A QString representing the identifier of the item to
retrieve.
@return QgsComposerItem pointer or 0 pointer if no such item exists.
**/
const QgsComposerItem* getComposerItemById( QString theId ) const;

/**Returns a composer item given its unique identifier.
@note added in 2.0
@param theId - A QString representing the UUID of the item to
@param inAllComposers - Whether the search should be done in all composers of the project
retrieve.
@return QgsComposerItem pointer or 0 pointer if no such item exists.
**/
//const QgsComposerItem* getComposerItemByUuid( QString theUuid, bool inAllComposers = false ) const;//does not work since it's impossible to get QGisApp::instance()
const QgsComposerItem* getComposerItemByUuid( QString theUuid ) const;

int printResolution() const {return mPrintResolution;}
void setPrintResolution( int dpi ) {mPrintResolution = dpi;}

Expand Down
744 changes: 5 additions & 739 deletions src/core/qgsexpression.cpp

Large diffs are not rendered by default.

118 changes: 57 additions & 61 deletions src/core/qgsexpression.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@
#include <QDomDocument>

#include "qgsfield.h"
#include "qgsvectorlayer.h"
#include "qgsdistancearea.h"
#include "qgsgeometry.h"

class QgsFeature;
class QgsGeometry;
class QgsOgcUtils;
class QgsVectorLayer;

class QDomElement;

/**
Expand Down Expand Up @@ -57,6 +58,7 @@ Possible QVariant value types:
- int
- double
- string
- geometry

Similarly to SQL, this class supports three-value logic: true/false/unknown.
Unknown value may be a result of operations with missing data (NULL). Please note
Expand Down Expand Up @@ -94,6 +96,11 @@ class CORE_EXPORT QgsExpression
//! Returns parser error
QString parserErrorString() const { return mParserErrorString; }

class Node;

//! Returns root node of the expression. Root node is null is parsing has failed
const Node* rootNode() const { return mRootNode; }

//! Get the expression ready for evaluation - find out column indexes.
bool prepare( const QgsFields& fields );

Expand Down Expand Up @@ -214,10 +221,6 @@ class CORE_EXPORT QgsExpression
static const char* BinaryOperatorText[];
static const char* UnaryOperatorText[];

static const char* BinaryOgcOperatorText[];
static const char* UnaryOgcOperatorText[];
static const char* SpatialOgcOperatorText[];

typedef QVariant( *FcnEval )( const QVariantList& values, QgsFeature* f, QgsExpression* parent );


Expand Down Expand Up @@ -307,10 +310,22 @@ class CORE_EXPORT QgsExpression

class Visitor; // visitor interface is defined below

enum NodeType
{
ntUnaryOperator,
ntBinaryOperator,
ntInOperator,
ntFunction,
ntLiteral,
ntColumnRef,
ntCondition
};

class CORE_EXPORT Node
{
public:
virtual ~Node() {}
virtual NodeType nodeType() const = 0;
// abstract virtual eval function
// errors are reported to the parent
virtual QVariant eval( QgsExpression* parent, QgsFeature* f ) = 0;
Expand All @@ -321,14 +336,11 @@ class CORE_EXPORT QgsExpression

virtual QString dump() const = 0;

virtual void toOgcFilter( QDomDocument &doc, QDomElement &element ) const { Q_UNUSED( doc ); Q_UNUSED( element ); }
static QgsExpression::Node* createFromOgcFilter( QDomElement &element, QString &errorMessage );

virtual QStringList referencedColumns() const = 0;
virtual bool needsGeometry() const = 0;

// support for visitor pattern
virtual void accept( Visitor& v ) = 0;
virtual void accept( Visitor& v ) const = 0;
};

class CORE_EXPORT NodeList
Expand All @@ -341,7 +353,6 @@ class CORE_EXPORT QgsExpression
QList<Node*> list() { return mList; }

virtual QString dump() const;
virtual void toOgcFilter( QDomDocument &doc, QDomElement &element ) const;

protected:
QList<Node*> mList;
Expand Down Expand Up @@ -383,19 +394,17 @@ class CORE_EXPORT QgsExpression
NodeUnaryOperator( UnaryOperator op, Node* operand ) : mOp( op ), mOperand( operand ) {}
~NodeUnaryOperator() { delete mOperand; }

UnaryOperator op() { return mOp; }
Node* operand() { return mOperand; }
UnaryOperator op() const { return mOp; }
Node* operand() const { return mOperand; }

virtual NodeType nodeType() const { return ntUnaryOperator; }
virtual bool prepare( QgsExpression* parent, const QgsFields& fields );
virtual QVariant eval( QgsExpression* parent, QgsFeature* f );
virtual QString dump() const;

virtual void toOgcFilter( QDomDocument &doc, QDomElement &element ) const;
static QgsExpression::Node* createFromOgcFilter( QDomElement &element, QString &errorMessage );

virtual QStringList referencedColumns() const { return mOperand->referencedColumns(); }
virtual bool needsGeometry() const { return mOperand->needsGeometry(); }
virtual void accept( Visitor& v ) { v.visit( this ); }
virtual void accept( Visitor& v ) const { v.visit( *this ); }

protected:
UnaryOperator mOp;
Expand All @@ -408,20 +417,18 @@ class CORE_EXPORT QgsExpression
NodeBinaryOperator( BinaryOperator op, Node* opLeft, Node* opRight ) : mOp( op ), mOpLeft( opLeft ), mOpRight( opRight ) {}
~NodeBinaryOperator() { delete mOpLeft; delete mOpRight; }

BinaryOperator op() { return mOp; }
Node* opLeft() { return mOpLeft; }
Node* opRight() { return mOpRight; }
BinaryOperator op() const { return mOp; }
Node* opLeft() const { return mOpLeft; }
Node* opRight() const { return mOpRight; }

virtual NodeType nodeType() const { return ntBinaryOperator; }
virtual bool prepare( QgsExpression* parent, const QgsFields& fields );
virtual QVariant eval( QgsExpression* parent, QgsFeature* f );
virtual QString dump() const;

virtual void toOgcFilter( QDomDocument &doc, QDomElement &element ) const;
static QgsExpression::Node* createFromOgcFilter( QDomElement &element, QString &errorMessage );

virtual QStringList referencedColumns() const { return mOpLeft->referencedColumns() + mOpRight->referencedColumns(); }
virtual bool needsGeometry() const { return mOpLeft->needsGeometry() || mOpRight->needsGeometry(); }
virtual void accept( Visitor& v ) { v.visit( this ); }
virtual void accept( Visitor& v ) const { v.visit( *this ); }

protected:
bool compare( double diff );
Expand All @@ -440,19 +447,18 @@ class CORE_EXPORT QgsExpression
NodeInOperator( Node* node, NodeList* list, bool notin = false ) : mNode( node ), mList( list ), mNotIn( notin ) {}
virtual ~NodeInOperator() { delete mNode; delete mList; }

Node* node() { return mNode; }
bool isNotIn() { return mNotIn; }
NodeList* list() { return mList; }
Node* node() const { return mNode; }
bool isNotIn() const { return mNotIn; }
NodeList* list() const { return mList; }

virtual NodeType nodeType() const { return ntInOperator; }
virtual bool prepare( QgsExpression* parent, const QgsFields& fields );
virtual QVariant eval( QgsExpression* parent, QgsFeature* f );
virtual QString dump() const;

virtual void toOgcFilter( QDomDocument &doc, QDomElement &element ) const;

virtual QStringList referencedColumns() const { QStringList lst( mNode->referencedColumns() ); foreach ( Node* n, mList->list() ) lst.append( n->referencedColumns() ); return lst; }
virtual bool needsGeometry() const { bool needs = false; foreach ( Node* n, mList->list() ) needs |= n->needsGeometry(); return needs; }
virtual void accept( Visitor& v ) { v.visit( this ); }
virtual void accept( Visitor& v ) const { v.visit( *this ); }

protected:
Node* mNode;
Expand All @@ -467,19 +473,17 @@ class CORE_EXPORT QgsExpression
//NodeFunction( QString name, NodeList* args ) : mName(name), mArgs(args) {}
virtual ~NodeFunction() { delete mArgs; }

int fnIndex() { return mFnIndex; }
NodeList* args() { return mArgs; }
int fnIndex() const { return mFnIndex; }
NodeList* args() const { return mArgs; }

virtual NodeType nodeType() const { return ntFunction; }
virtual bool prepare( QgsExpression* parent, const QgsFields& fields );
virtual QVariant eval( QgsExpression* parent, QgsFeature* f );
virtual QString dump() const;

virtual void toOgcFilter( QDomDocument &doc, QDomElement &element ) const;
static QgsExpression::Node* createFromOgcFilter( QDomElement &element, QString &errorMessage );

virtual QStringList referencedColumns() const { QStringList lst; if ( !mArgs ) return lst; foreach ( Node* n, mArgs->list() ) lst.append( n->referencedColumns() ); return lst; }
virtual bool needsGeometry() const { bool needs = Functions()[mFnIndex]->usesgeometry(); if ( mArgs ) { foreach ( Node* n, mArgs->list() ) needs |= n->needsGeometry(); } return needs; }
virtual void accept( Visitor& v ) { v.visit( this ); }
virtual void accept( Visitor& v ) const { v.visit( *this ); }

protected:
//QString mName;
Expand All @@ -492,18 +496,16 @@ class CORE_EXPORT QgsExpression
public:
NodeLiteral( QVariant value ) : mValue( value ) {}

QVariant value() { return mValue; }
QVariant value() const { return mValue; }

virtual NodeType nodeType() const { return ntLiteral; }
virtual bool prepare( QgsExpression* parent, const QgsFields& fields );
virtual QVariant eval( QgsExpression* parent, QgsFeature* f );
virtual QString dump() const;

virtual void toOgcFilter( QDomDocument &doc, QDomElement &element ) const;
static QgsExpression::Node* createFromOgcFilter( QDomElement &element, QString &errorMessage );

virtual QStringList referencedColumns() const { return QStringList(); }
virtual bool needsGeometry() const { return false; }
virtual void accept( Visitor& v ) { v.visit( this ); }
virtual void accept( Visitor& v ) const { v.visit( *this ); }

protected:
QVariant mValue;
Expand All @@ -514,18 +516,16 @@ class CORE_EXPORT QgsExpression
public:
NodeColumnRef( QString name ) : mName( name ), mIndex( -1 ) {}

QString name() { return mName; }
QString name() const { return mName; }

virtual NodeType nodeType() const { return ntColumnRef; }
virtual bool prepare( QgsExpression* parent, const QgsFields& fields );
virtual QVariant eval( QgsExpression* parent, QgsFeature* f );
virtual QString dump() const;

virtual void toOgcFilter( QDomDocument &doc, QDomElement &element ) const;
static QgsExpression::Node* createFromOgcFilter( QDomElement &element, QString &errorMessage );

virtual QStringList referencedColumns() const { return QStringList( mName ); }
virtual bool needsGeometry() const { return false; }
virtual void accept( Visitor& v ) { v.visit( this ); }
virtual void accept( Visitor& v ) const { v.visit( *this ); }

protected:
QString mName;
Expand All @@ -550,15 +550,14 @@ class CORE_EXPORT QgsExpression
NodeCondition( WhenThenList* conditions, Node* elseExp = NULL ) : mConditions( *conditions ), mElseExp( elseExp ) { delete conditions; }
~NodeCondition() { delete mElseExp; foreach ( WhenThen* cond, mConditions ) delete cond; }

virtual NodeType nodeType() const { return ntCondition; }
virtual QVariant eval( QgsExpression* parent, QgsFeature* f );
virtual bool prepare( QgsExpression* parent, const QgsFields& fields );
virtual QString dump() const;

virtual void toOgcFilter( QDomDocument &doc, QDomElement &element ) const;

virtual QStringList referencedColumns() const;
virtual bool needsGeometry() const;
virtual void accept( Visitor& v ) { v.visit( this ); }
virtual void accept( Visitor& v ) const { v.visit( *this ); }

protected:
WhenThenList mConditions;
Expand All @@ -573,21 +572,17 @@ class CORE_EXPORT QgsExpression
{
public:
virtual ~Visitor() {}
virtual void visit( NodeUnaryOperator* n ) = 0;
virtual void visit( NodeBinaryOperator* n ) = 0;
virtual void visit( NodeInOperator* n ) = 0;
virtual void visit( NodeFunction* n ) = 0;
virtual void visit( NodeLiteral* n ) = 0;
virtual void visit( NodeColumnRef* n ) = 0;
virtual void visit( NodeCondition* n ) = 0;
virtual void visit( const NodeUnaryOperator& n ) = 0;
virtual void visit( const NodeBinaryOperator& n ) = 0;
virtual void visit( const NodeInOperator& n ) = 0;
virtual void visit( const NodeFunction& n ) = 0;
virtual void visit( const NodeLiteral& n ) = 0;
virtual void visit( const NodeColumnRef& n ) = 0;
virtual void visit( const NodeCondition& n ) = 0;
};

/** entry function for the visitor pattern */
void acceptVisitor( Visitor& v );

// convert from/to OGC Filter
void toOgcFilter( QDomDocument &doc, QDomElement &element ) const;
static QgsExpression* createFromOgcFilter( QDomElement &element );
void acceptVisitor( Visitor& v ) const;

protected:
// internally used to create an empty expression
Expand All @@ -607,6 +602,7 @@ class CORE_EXPORT QgsExpression
static QMap<QString, QVariant> gmSpecialColumns;
QgsDistanceArea mCalc;

friend class QgsOgcUtils;
};

Q_DECLARE_METATYPE( QgsExpression::Interval );
Expand Down
14 changes: 14 additions & 0 deletions src/core/qgsfield.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,17 @@ void QgsField::setComment( const QString & comment )
{
mComment = comment;
}

QString QgsField::displayString( const QVariant& v ) const
{
switch ( mType )
{
case QVariant::Double:
if ( mPrecision > 0 )
{
return QString::number( v.toDouble(), 'f', mPrecision );
}
default:
return v.toString();
}
}
3 changes: 3 additions & 0 deletions src/core/qgsfield.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ class CORE_EXPORT QgsField
*/
void setComment( const QString & comment );

/**Formats string for display*/
QString displayString( const QVariant& v ) const;

private:

//! Name
Expand Down
Loading