-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/qgis/QGIS
- Loading branch information
Showing
41 changed files
with
3,343 additions
and
642 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
|
||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.