Skip to content

Commit

Permalink
fix docs for streamlines (#33054)
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterPetrik committed Nov 25, 2019
1 parent 938aa58 commit 23ae038
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 47 deletions.
24 changes: 20 additions & 4 deletions python/core/auto_generated/mesh/qgsmeshrenderersettings.sip.in
Expand Up @@ -158,7 +158,7 @@ Represents a mesh renderer settings for vector datasets displayed with arrows

The API is considered EXPERIMENTAL and can be changed without a notice

.. versionadded:: 3.2
.. versionadded:: 3.12
%End

%TypeHeaderCode
Expand Down Expand Up @@ -332,18 +332,19 @@ Represents a streamline renderer settings for vector datasets

The API is considered EXPERIMENTAL and can be changed without a notice

.. versionadded:: 3.12
.. versionadded:: 3.2
%End

%TypeHeaderCode
#include "qgsmeshrenderersettings.h"
%End
public:

enum Symbology
{
//!Displying vctor dataset with arrows
//! Displying vector dataset with arrows
Arrows,
//!Displying vctor dataset with streamlines
//! Displying vector dataset with streamlines
Streamlines
};

Expand Down Expand Up @@ -424,28 +425,43 @@ Sets height of user grid cell (in pixels)
Symbology symbology() const;
%Docstring
Returns the displaying method used to render vector datasets

.. versionadded:: 3.12
%End

void setSymbology( const Symbology &symbology );
%Docstring
Sets the displaying method used to render vector datasets

.. versionadded:: 3.12
%End

QgsMeshRendererVectorArrowSettings arrowSettings() const;
%Docstring
Returns settings for vector rendered with arrows

.. versionadded:: 3.12
%End

void setArrowsSettings( const QgsMeshRendererVectorArrowSettings &arrowSettings );
%Docstring
Sets settings for vector rendered with arrows

.. versionadded:: 3.12
%End

QgsMeshRendererVectorStreamlineSettings streamLinesSettings() const;
%Docstring
Returns settings for vector rednered with streamlines

.. versionadded:: 3.12
%End

void setStreamLinesSettings( const QgsMeshRendererVectorStreamlineSettings &streamLinesSettings );
%Docstring
Sets settings for vector rednered with streamlines

.. versionadded:: 3.12
%End


Expand Down
4 changes: 4 additions & 0 deletions src/core/mesh/qgsmeshlayerutils.h
Expand Up @@ -95,6 +95,8 @@ class CORE_EXPORT QgsMeshLayerUtils
* \param vect3 value on p3 of the triangle
* \param pt point where to calculate value
* \returns vector on the point pt or NaN in case the point is outside the triangle
*
* \since QGIS 3.12
*/
static QgsVector interpolateVectorFromVerticesData(
const QgsPointXY &p1, const QgsPointXY &p2, const QgsPointXY &p3,
Expand Down Expand Up @@ -122,6 +124,8 @@ class CORE_EXPORT QgsMeshLayerUtils
* \param vect face vector
* \param pt point where to calculate value
* \returns vector on the point pt or NaN in case the point is outside the triangle
*
* \since QGIS 3.12
*/
static QgsVector interpolateVectorFromFacesData(
const QgsPointXY &p1, const QgsPointXY &p2, const QgsPointXY &p3,
Expand Down
47 changes: 36 additions & 11 deletions src/core/mesh/qgsmeshrenderersettings.h
Expand Up @@ -146,7 +146,7 @@ class CORE_EXPORT QgsMeshRendererScalarSettings
*
* \note The API is considered EXPERIMENTAL and can be changed without a notice
*
* \since QGIS 3.2
* \since QGIS 3.12
*/
class CORE_EXPORT QgsMeshRendererVectorArrowSettings
{
Expand Down Expand Up @@ -311,17 +311,21 @@ class CORE_EXPORT QgsMeshRendererVectorStreamlineSettings
*
* \note The API is considered EXPERIMENTAL and can be changed without a notice
*
* \since QGIS 3.12
* \since QGIS 3.2
*/
class CORE_EXPORT QgsMeshRendererVectorSettings
{
public:
//! enumaraton used to define the symbology of vector rendering

/**
* Defines the symbology of vector rendering
* \since QGIS 3.12
*/
enum Symbology
{
//!Displying vctor dataset with arrows
//! Displying vector dataset with arrows
Arrows = 0,
//!Displying vctor dataset with streamlines
//! Displying vector dataset with streamlines
Streamlines
};

Expand Down Expand Up @@ -377,19 +381,40 @@ class CORE_EXPORT QgsMeshRendererVectorSettings
//! Sets height of user grid cell (in pixels)
void setUserGridCellHeight( int height );

//! Returns the displaying method used to render vector datasets
/**
* Returns the displaying method used to render vector datasets
* \since QGIS 3.12
*/
Symbology symbology() const;
//! Sets the displaying method used to render vector datasets

/**
* Sets the displaying method used to render vector datasets
* \since QGIS 3.12
*/
void setSymbology( const Symbology &symbology );

//! Returns settings for vector rendered with arrows
/**
* Returns settings for vector rendered with arrows
* \since QGIS 3.12
*/
QgsMeshRendererVectorArrowSettings arrowSettings() const;
//! Sets settings for vector rendered with arrows

/**
* Sets settings for vector rendered with arrows
* \since QGIS 3.12
*/
void setArrowsSettings( const QgsMeshRendererVectorArrowSettings &arrowSettings );

//! Returns settings for vector rednered with streamlines
/**
* Returns settings for vector rednered with streamlines
* \since QGIS 3.12
*/
QgsMeshRendererVectorStreamlineSettings streamLinesSettings() const;
//! Sets settings for vector rednered with streamlines

/**
* Sets settings for vector rednered with streamlines
* \since QGIS 3.12
*/
void setStreamLinesSettings( const QgsMeshRendererVectorStreamlineSettings &streamLinesSettings );


Expand Down
7 changes: 3 additions & 4 deletions src/core/mesh/qgsmeshtracerenderer.h
Expand Up @@ -85,7 +85,7 @@ class QgsMeshVectorValueInterpolator
* \note not available in Python bindings
* \since QGIS 3.12
*/
class QgsMeshVectorValueInterpolatorFromVertex: public QgsMeshVectorValueInterpolator //CORE_EXPORT needed to no have v-table error ????
class QgsMeshVectorValueInterpolatorFromVertex: public QgsMeshVectorValueInterpolator
{
public:
//! Constructor
Expand All @@ -109,7 +109,7 @@ class QgsMeshVectorValueInterpolatorFromVertex: public QgsMeshVectorValueInterp
* \note not available in Python bindings
* \since QGIS 3.12
*/
class QgsMeshVectorValueInterpolatorFromFace: public QgsMeshVectorValueInterpolator //CORE_EXPORT needed to no have v-table error ????
class QgsMeshVectorValueInterpolatorFromFace: public QgsMeshVectorValueInterpolator
{
public:
//! Constructor
Expand Down Expand Up @@ -195,7 +195,7 @@ class QgsMeshStreamField
//! Sets the resolution of the field
void setResolution( int width );

//!Return the width of particle
//! Returns the width of particle
int resolution() const;

//! Returns the size of the image that represents the trace field
Expand Down Expand Up @@ -232,7 +232,6 @@ class QgsMeshStreamField

bool filterMag( double value ) const;

//attribute
QSize mFieldSize;
QRect mLayerPixelExtent;
int mFieldResolution = 1;
Expand Down
19 changes: 8 additions & 11 deletions src/core/mesh/qgstriangularmesh.cpp
Expand Up @@ -254,19 +254,16 @@ QList<int> QgsMeshUtils::nativeFacesFromTriangles( const QList<int> &triangleInd
return nativeFaces.toList();
}

bool QgsMeshUtils::isInTriangle2D( const QgsPoint &p, const QVector<QgsMeshVertex> &triangle )
static double _isLeft2D( const QgsPoint &p1, const QgsPoint &p2, const QgsPoint &p )
{
if ( triangle.count() != 3 )
return false;

return ( ( IsLeft2D( triangle[2], triangle[0], p ) * IsLeft2D( triangle[2], triangle[0], triangle[1] ) >= 0 )
&& ( IsLeft2D( triangle[0], triangle[1], p ) * IsLeft2D( triangle[0], triangle[1], triangle[2] ) >= 0 )
&& ( IsLeft2D( triangle[2], triangle[1], p ) * IsLeft2D( triangle[2], triangle[1], triangle[0] ) >= 0 ) );
return ( p2.x() - p1.x() ) * ( p.y() - p1.y() ) - ( p.x() - p1.x() ) * ( p2.y() - p1.y() );
}

double QgsMeshUtils::IsLeft2D( const QgsPoint &p1, const QgsPoint &p2, const QgsPoint &p )
static bool _isInTriangle2D( const QgsPoint &p, const QVector<QgsMeshVertex> &triangle )
{
return ( p2.x() - p1.x() ) * ( p.y() - p1.y() ) - ( p.x() - p1.x() ) * ( p2.y() - p1.y() );
return ( ( _isLeft2D( triangle[2], triangle[0], p ) * _isLeft2D( triangle[2], triangle[0], triangle[1] ) >= 0 )
&& ( _isLeft2D( triangle[0], triangle[1], p ) * _isLeft2D( triangle[0], triangle[1], triangle[2] ) >= 0 )
&& ( _isLeft2D( triangle[2], triangle[1], p ) * _isLeft2D( triangle[2], triangle[1], triangle[0] ) >= 0 ) );
}

bool QgsMeshUtils::isInTriangleFace( const QgsPointXY point, const QgsMeshFace &face, const QVector<QgsMeshVertex> &vertices )
Expand All @@ -282,7 +279,7 @@ bool QgsMeshUtils::isInTriangleFace( const QgsPointXY point, const QgsMeshFace &
triangle[i] = vertices[face[i]];
}

QgsPoint p( point.x(), point.y() );
const QgsPoint p( point.x(), point.y() );

return isInTriangle2D( p, triangle );
return _isInTriangle2D( p, triangle );
}
18 changes: 1 addition & 17 deletions src/core/mesh/qgstriangularmesh.h
Expand Up @@ -150,23 +150,7 @@ namespace QgsMeshUtils
CORE_EXPORT QList<int> nativeFacesFromTriangles( const QList<int> &triangleIndexes, const QVector<int> &trianglesToNativeFaces );

/**
* Test if point p is : on the left, on, or on the right of the line(p1p2).
* Result: > 0 if on the left
* = 0 if on the line
* < 0 if on the right
* NB : triangle surface = Isleft / 2
* \since QGIS 3.12
*/
double IsLeft2D( const QgsPoint &p1, const QgsPoint &p2, const QgsPoint &p );

/**
* Test if point p is on the 2D triangle
* \since QGIS 3.12
*/
bool isInTriangle2D( const QgsPoint &p, const QVector<QgsMeshVertex> &triangle );

/**
* Test if point p is on the face defined with vertices
* Tests if point p is on the face defined with vertices
* \since QGIS 3.12
*/
bool isInTriangleFace( const QgsPointXY point, const QgsMeshFace &face, const QVector<QgsMeshVertex> &vertices )
Expand Down

0 comments on commit 23ae038

Please sign in to comment.