Skip to content
Permalink
Browse files

Merge branch 'master' of https://github.com/qgis/QGIS

  • Loading branch information
pcav committed May 18, 2015
2 parents 24974e0 + 0b32606 commit 3e5e2b33881d488854a4ddc14cd2dc3a4071de17
Showing with 3,343 additions and 642 deletions.
  1. +1 −0 python/core/core.sip
  2. +66 −0 python/core/qgshistogram.sip
  3. +2 −0 python/gui/gui.sip
  4. +107 −0 python/gui/qgshistogramwidget.sip
  5. +42 −0 python/gui/symbology-ng/qgsgraduatedhistogramwidget.sip
  6. +2 −0 src/core/CMakeLists.txt
  7. +29 −0 src/core/qgsfeature.cpp
  8. +10 −0 src/core/qgsfeature.h
  9. +49 −0 src/core/qgsfield.cpp
  10. +9 −0 src/core/qgsfield.h
  11. +17 −0 src/core/qgsgeometry.cpp
  12. +5 −0 src/core/qgsgeometry.h
  13. +125 −0 src/core/qgshistogram.cpp
  14. +97 −0 src/core/qgshistogram.h
  15. +31 −0 src/core/symbology-ng/qgsgraduatedsymbolrendererv2.cpp
  16. +10 −0 src/core/symbology-ng/qgsgraduatedsymbolrendererv2.h
  17. +5 −0 src/gui/CMakeLists.txt
  18. +1 −1 src/gui/qgsexpressionbuilderwidget.cpp
  19. +353 −0 src/gui/qgshistogramwidget.cpp
  20. +174 −0 src/gui/qgshistogramwidget.h
  21. +397 −0 src/gui/raster/qwt5_histogram_item.cpp
  22. +15 −325 src/gui/raster/qwt5_histogram_item.h
  23. +203 −0 src/gui/symbology-ng/qgsgraduatedhistogramwidget.cpp
  24. +114 −0 src/gui/symbology-ng/qgsgraduatedhistogramwidget.h
  25. +26 −2 src/gui/symbology-ng/qgsgraduatedsymbolrendererv2widget.cpp
  26. +2 −1 src/gui/symbology-ng/qgsgraduatedsymbolrendererv2widget.h
  27. +23 −1 src/providers/grass/CMakeLists.txt
  28. +1 −12 src/providers/grass/qgis.r.in.cpp
  29. +331 −0 src/providers/grass/qgis.v.in.cpp
  30. +124 −1 src/providers/grass/qgsgrass.cpp
  31. +10 −0 src/providers/grass/qgsgrass.h
  32. +182 −2 src/providers/grass/qgsgrassimport.cpp
  33. +23 −4 src/providers/grass/qgsgrassimport.h
  34. +2 −0 src/providers/grass/qgsgrassprovider.cpp
  35. +101 −59 src/providers/grass/qgsgrassprovidermodule.cpp
  36. +303 −221 src/ui/qgsgraduatedsymbolrendererv2widget.ui
  37. +108 −0 src/ui/qgshistogramwidgetbase.ui
  38. +1 −0 tests/src/core/CMakeLists.txt
  39. +157 −0 tests/src/core/testqgshistogram.cpp
  40. +84 −12 tests/src/providers/grass/testqgsgrassprovider.cpp
  41. +1 −1 tests/src/python/test_qgsdoccoverage.py
@@ -43,6 +43,7 @@
%Include qgsgeometry.sip
%Include qgsgeometryvalidator.sip
%Include qgsgeometrysimplifier.sip
%Include qgshistogram.sip
%Include qgsmaptopixelgeometrysimplifier.sip
%Include qgsgml.sip
%Include qgsgmlschema.sip
@@ -0,0 +1,66 @@
/** \ingroup core
* \class QgsHistogram
* \brief Calculator for a numeric histogram from a list of values.
*
* \note Added in version 2.9
*/

class QgsHistogram
{
%TypeHeaderCode
#include "qgshistogram.h"
%End

public:

QgsHistogram();

virtual ~QgsHistogram();

/** Assigns numeric source values for the histogram.
* @param values list of doubles
*/
void setValues( const QList<double>& values );

/** Assigns numeric source values for the histogram from a vector layer's field or as the
* result of an expression.
* @param layer vector layer
* @param fieldOrExpression field name or expression to be evaluated
* @returns true if values were successfully set
*/
bool setValues( QgsVectorLayer* layer, const QString& fieldOrExpression );

/** Calculates the optimal bin width using the Freedman-Diaconis rule. Bins widths are
* determined by the inter-quartile range of values and the number of values.
* @returns optimal width for bins
* @see optimalNumberBins
* @note values must first be specified using @link setValues @endlink
*/
double optimalBinWidth() const;

/** Returns the optimal number of bins for the source values, calculated using the
* Freedman-Diaconis rule. The number of bins are determined by the inter-quartile range
* of values and the number of values.
* @returns optimal number of bins
* @see optimalBinWidth
* @note values must first be specified using @link setValues @endlink
*/
int optimalNumberBins() const;

/** Returns a list of edges for the histogram for a specified number of bins. This list
* will be length bins + 1, as both the first and last value are also included.
* @param bins number of bins
* @return list of bin edges
* @note values must first be specified using @link setValues @endlink
*/
QList<double> binEdges( int bins ) const;

/** Returns the calculated list of the counts for the histogram bins.
* @param bins number of histogram bins
* @return list of histogram counts
* @note values must first be specified using @link setValues @endlink
*/
QList<int> counts( int bins ) const;

};

@@ -56,6 +56,7 @@
%Include qgsfilterlineedit.sip
%Include qgsformannotationitem.sip
%Include qgsgenericprojectionselector.sip
%Include qgshistogramwidget.sip
%Include qgshtmlannotationitem.sip
%Include qgsidentifymenu.sip
%Include qgslegendinterface.sip
@@ -173,6 +174,7 @@
%Include symbology-ng/qgsdatadefinedsymboldialog.sip
%Include symbology-ng/qgsstylev2exportimportdialog.sip
%Include symbology-ng/qgssvgselectorwidget.sip
%Include symbology-ng/qgsgraduatedhistogramwidget.sip

%Include effects/qgseffectdrawmodecombobox.sip
%Include effects/qgspainteffectpropertieswidget.sip
@@ -0,0 +1,107 @@

/** \ingroup gui
* \class QgsHistogramWidget
* \brief Graphical histogram for displaying distributions of field values.
*
* \note Added in version 2.9
*/

class QgsHistogramWidget : QWidget
{
%TypeHeaderCode
#include <qgshistogramwidget.h>
%End

public:

/** QgsHistogramWidget constructor. If layer and fieldOrExp are specified then the histogram
* will be initially populated with the corresponding values.
* @param parent parent widget
* @param layer source vector layer
* @param fieldOrExp field name or expression string
*/
QgsHistogramWidget( QWidget *parent /TransferThis/ = 0, QgsVectorLayer* layer = 0, const QString& fieldOrExp = QString() );

~QgsHistogramWidget();

/** Returns the layer currently associated with the widget.
* @see setLayer
* @see sourceFieldExp
*/
QgsVectorLayer* layer();

/** Returns the source field name or expression used to calculate values displayed
* in the histogram.
* @see setSourceFieldExp
* @see layer
*/
QString sourceFieldExp() const;

/** Sets the pen to use when drawing histogram bars. If set to Qt::NoPen then the
* pen will be automatically calculated. If ranges have been set using @link setGraduatedRanges @endlink
* then the pen and brush will have no effect.
* @param pen histogram pen
* @see pen
* @see setBrush
*/
void setPen( const QPen& pen );

/** Returns the pen used when drawing histogram bars.
* @see setPen
* @see brush
*/
QPen pen() const;

/** Sets the brush used for drawing histogram bars. If ranges have been set using @link setGraduatedRanges @endlink
* then the pen and brush will have no effect.
* @param brush histogram brush
* @see brush
* @see setPen
*/
void setBrush( const QBrush& brush );

/** Returns the brush used when drawing histogram bars.
* @see setBrush
* @see pen
*/
QBrush brush() const;

/** Sets the graduated ranges associated with the histogram. If set, the ranges will be used to colour the histogram
* bars and for showing vertical dividers at the histogram breaks.
* @param ranges graduated range list
*/
void setGraduatedRanges( const QgsRangeList& ranges );

/** Returns the graduated ranges associated with the histogram. If set, the ranges will be used to colour the histogram
* bars and for showing vertical dividers at the histogram breaks.
* @returns graduated range list
* @see setGraduatedRanges
*/
QgsRangeList graduatedRanges() const;

public slots:

/** Triggers a refresh of the histogram when the widget is next repainted.
*/
void refreshHistogram();

/** Sets the vector layer associated with the histogram.
* @param layer source vector layer
* @see setSourceFieldExp
*/
void setLayer( QgsVectorLayer* layer );

/** Sets the source field or expression to use for values in the histogram.
* @param fieldOrExp field name or expression string
* @see setLayer
*/
void setSourceFieldExp( const QString& fieldOrExp );

protected:

/** Updates and redraws the histogram.
*/
virtual void drawHistogram();

virtual void paintEvent( QPaintEvent * event );
};
@@ -0,0 +1,42 @@

/** \ingroup gui
* \class QgsGraduatedHistogramWidget
* \brief Graphical histogram for displaying distribution of field values and
* editing range breaks for a QgsGraduatedSymbolRendererV2 renderer.
*
* \note Added in version 2.9
*/

class QgsGraduatedHistogramWidget : QWidget
{
%TypeHeaderCode
#include <qgsgraduatedhistogramwidget.h>
%End

public:

/** QgsGraduatedHistogramWidget constructor
* @param parent parent widget
*/
QgsGraduatedHistogramWidget( QWidget *parent /TransferThis/ = 0 );
~QgsGraduatedHistogramWidget();

/** Sets the QgsGraduatedSymbolRendererV2 renderer associated with the histogram.
* The histogram will fetch the ranges from the renderer before every refresh.
* @param renderer associated QgsGraduatedSymbolRendererV2
*/
void setRenderer( QgsGraduatedSymbolRendererV2* renderer );

signals:

/** Emitted when the user modifies the graduated ranges using the histogram widget.
* @param rangesAdded true if the user has added ranges, false if the user has just
* modified existing range breaks
*/
void rangesModified( bool rangesAdded );

protected:

virtual void drawHistogram();

};
@@ -107,6 +107,7 @@ SET(QGIS_CORE_SRCS
qgsgeometryvalidator.cpp
qgsgml.cpp
qgsgmlschema.cpp
qgshistogram.cpp
qgslayerdefinition.cpp
qgslabel.cpp
qgslabelattributes.cpp
@@ -510,6 +511,7 @@ SET(QGIS_CORE_HDRS
qgsfontutils.h
qgsgeometry.h
qgsgeometrycache.h
qgshistogram.h
qgslayerdefinition.h
qgslabel.h
qgslabelattributes.h
@@ -252,3 +252,32 @@ int QgsFeature::fieldNameIndex( const QString& fieldName ) const
}
return -1;
}

QDataStream& operator<<( QDataStream& out, const QgsFeature& feature )
{
out << feature.id();
out << feature.attributes();
if ( feature.geometry() )
{
out << *( feature.geometry() );
}
else
{
QgsGeometry geometry;
out << geometry;
}
out << feature.isValid();
return out;
}

QDataStream& operator>>( QDataStream& in, QgsFeature& feature )
{
QgsFeatureId id;
QgsGeometry* geometry = new QgsGeometry();
bool valid;
in >> id >> feature.attributes() >> *geometry >> valid;
feature.setFeatureId( id );
feature.setGeometry( geometry );
feature.setValid( valid );
return in;
}
@@ -64,6 +64,11 @@ class QgsFeatureId
friend uint qHash( const QgsFeatureId &id );
};

/** Writes the feature id to stream out. QGIS version compatibility is not guaranteed. */
CORE_EXPORT QDataStream& operator<<( QDataStream& out, const QgsFeatureId& featureId );
/** Reads a feature id from stream in into feature id. QGIS version compatibility is not guaranteed. */
CORE_EXPORT QDataStream& operator>>( QDataStream& in, QgsFeatureId& featureId );

inline uint qHash( const QgsFeatureId &id )
{
return qHash( id.mId );
@@ -313,6 +318,11 @@ class CORE_EXPORT QgsFeature

}; // class QgsFeature

/** Writes the feature to stream out. QGIS version compatibility is not guaranteed. */
CORE_EXPORT QDataStream& operator<<( QDataStream& out, const QgsFeature& feature );
/** Reads a feature from stream in into feature. QGIS version compatibility is not guaranteed. */
CORE_EXPORT QDataStream& operator>>( QDataStream& in, QgsFeature& feature );

// key = feature id, value = changed attributes
typedef QMap<QgsFeatureId, QgsAttributeMap> QgsChangedAttributesMap;

@@ -176,6 +176,31 @@ bool QgsField::convertCompatible( QVariant& v ) const
return true;
}

QDataStream& operator<<( QDataStream& out, const QgsField& field )
{
out << field.name();
out << ( quint32 )field.type();
out << field.typeName();
out << field.length();
out << field.precision();
out << field.comment();
return out;
}

QDataStream& operator>>( QDataStream& in, QgsField& field )
{
quint32 type, length, precision;
QString name, typeName, comment;
in >> name >> type >> typeName >> length >> precision >> comment;
field.setName( name );
field.setType(( QVariant::Type )type );
field.setTypeName( typeName );
field.setLength(( int )length );
field.setPrecision(( int )precision );
field.setComment( comment );
return in;
}

////////////////////////////////////////////////////////////////////////////

QgsFields::QgsFields()
@@ -341,3 +366,27 @@ QgsAttributeList QgsFields::allAttributesList() const
lst.append( i );
return lst;
}

QDataStream& operator<<( QDataStream& out, const QgsFields& fields )
{
out << ( quint32 )fields.size();
for ( int i = 0; i < fields.size(); i++ )
{
out << fields.field( i );
}
return out;
}

QDataStream& operator>>( QDataStream& in, QgsFields& fields )
{
fields.clear();
quint32 size;
in >> size;
for ( quint32 i = 0; i < size; i++ )
{
QgsField field;
in >> field;
fields.append( field );
}
return in;
}
@@ -156,6 +156,10 @@ class CORE_EXPORT QgsField

Q_DECLARE_METATYPE( QgsField );

/** Writes the field to stream out. QGIS version compatibility is not guaranteed. */
CORE_EXPORT QDataStream& operator<<( QDataStream& out, const QgsField& field );
/** Reads a field from stream in into field. QGIS version compatibility is not guaranteed. */
CORE_EXPORT QDataStream& operator>>( QDataStream& in, QgsField& field );

/** \class QgsFields
* \ingroup core
@@ -274,4 +278,9 @@ class CORE_EXPORT QgsFields

Q_DECLARE_METATYPE( QgsFields );

/** Writes the fields to stream out. QGIS version compatibility is not guaranteed. */
CORE_EXPORT QDataStream& operator<<( QDataStream& out, const QgsFields& fields );
/** Reads fields from stream in into fields. QGIS version compatibility is not guaranteed. */
CORE_EXPORT QDataStream& operator>>( QDataStream& in, QgsFields& fields );

#endif

0 comments on commit 3e5e2b3

Please sign in to comment.
You can’t perform that action at this time.