mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-16 00:03:12 -04:00
QgsHighlight improvements
* Doxygen improvements * Fix unrequired casting * Remove unrequired contructor
This commit is contained in:
parent
d79ac26fda
commit
e1ffb2826b
@ -13,8 +13,17 @@ class QgsHighlight: QgsMapCanvasItem
|
|||||||
%Docstring
|
%Docstring
|
||||||
A class for highlight features on the map.
|
A class for highlight features on the map.
|
||||||
|
|
||||||
The QgsHighlight class provides a transparent overlay widget
|
The QgsHighlight class provides a transparent overlay canvas item
|
||||||
for highlighting features on the map.
|
for highlighting features or geometries on a map canvas.
|
||||||
|
|
||||||
|
\code{.py}
|
||||||
|
color = QColor(Qt.red)
|
||||||
|
highlight = QgsHighlight(mapCanvas, feature, layer)
|
||||||
|
highlight.setColor(color)
|
||||||
|
color.setAlpha(50)
|
||||||
|
highlight.setFillColor(color)
|
||||||
|
highlight.show()
|
||||||
|
\endcode
|
||||||
%End
|
%End
|
||||||
|
|
||||||
%TypeHeaderCode
|
%TypeHeaderCode
|
||||||
@ -22,13 +31,12 @@ for highlighting features on the map.
|
|||||||
%End
|
%End
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
QgsHighlight( QgsMapCanvas *mapCanvas, const QgsGeometry &geom, QgsMapLayer *layer );
|
||||||
QgsHighlight( QgsMapCanvas *mapCanvas, const QgsGeometry &geom, QgsVectorLayer *layer );
|
|
||||||
%Docstring
|
%Docstring
|
||||||
Constructor for QgsHighlight
|
Constructor for QgsHighlight
|
||||||
\param mapCanvas associated map canvas
|
\param mapCanvas associated map canvas
|
||||||
\param geom initial geometry of highlight
|
\param geom initial geometry of highlight
|
||||||
\param layer associated vector layer
|
\param layer associated map layer
|
||||||
%End
|
%End
|
||||||
|
|
||||||
QgsHighlight( QgsMapCanvas *mapCanvas, const QgsFeature &feature, QgsVectorLayer *layer );
|
QgsHighlight( QgsMapCanvas *mapCanvas, const QgsFeature &feature, QgsVectorLayer *layer );
|
||||||
@ -49,29 +57,38 @@ for highlighting features on the map.
|
|||||||
|
|
||||||
void setFillColor( const QColor &fillColor );
|
void setFillColor( const QColor &fillColor );
|
||||||
%Docstring
|
%Docstring
|
||||||
Set polygons fill color.
|
Fill color for the highlight.
|
||||||
.. versionadded:: 2.3
|
Will be used for polygons and points.
|
||||||
|
|
||||||
|
.. versionadded:: 2.4
|
||||||
%End
|
%End
|
||||||
|
|
||||||
void setWidth( int width );
|
void setWidth( int width );
|
||||||
%Docstring
|
%Docstring
|
||||||
Set stroke width. Ignored in feature mode.
|
Set stroke width.
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
|
||||||
|
Ignored in feature mode.
|
||||||
%End
|
%End
|
||||||
|
|
||||||
void setBuffer( double buffer );
|
void setBuffer( double buffer );
|
||||||
%Docstring
|
%Docstring
|
||||||
Set line / stroke buffer in millimeters.
|
Set line / stroke buffer in millimeters.
|
||||||
.. versionadded:: 2.3
|
|
||||||
|
.. versionadded:: 2.4
|
||||||
%End
|
%End
|
||||||
|
|
||||||
void setMinWidth( double width );
|
void setMinWidth( double width );
|
||||||
%Docstring
|
%Docstring
|
||||||
Set minimum line / stroke width in millimeters.
|
Set minimum line / stroke width in millimeters.
|
||||||
.. versionadded:: 2.3
|
|
||||||
|
.. versionadded:: 2.4
|
||||||
%End
|
%End
|
||||||
|
|
||||||
const QgsMapLayer *layer() const;
|
QgsMapLayer *layer() const;
|
||||||
%Docstring
|
%Docstring
|
||||||
|
Return the layer for which this highlight has been created.
|
||||||
:rtype: QgsMapLayer
|
:rtype: QgsMapLayer
|
||||||
%End
|
%End
|
||||||
|
|
||||||
|
@ -49,18 +49,6 @@
|
|||||||
QgsHighlight::QgsHighlight( QgsMapCanvas *mapCanvas, const QgsGeometry &geom, QgsMapLayer *layer )
|
QgsHighlight::QgsHighlight( QgsMapCanvas *mapCanvas, const QgsGeometry &geom, QgsMapLayer *layer )
|
||||||
: QgsMapCanvasItem( mapCanvas )
|
: QgsMapCanvasItem( mapCanvas )
|
||||||
, mLayer( layer )
|
, mLayer( layer )
|
||||||
, mBuffer( 0 )
|
|
||||||
, mMinWidth( 0 )
|
|
||||||
{
|
|
||||||
mGeometry = !geom.isNull() ? new QgsGeometry( geom ) : nullptr;
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
QgsHighlight::QgsHighlight( QgsMapCanvas *mapCanvas, const QgsGeometry &geom, QgsVectorLayer *layer )
|
|
||||||
: QgsMapCanvasItem( mapCanvas )
|
|
||||||
, mLayer( static_cast<QgsMapLayer *>( layer ) )
|
|
||||||
, mBuffer( 0 )
|
|
||||||
, mMinWidth( 0 )
|
|
||||||
{
|
{
|
||||||
mGeometry = !geom.isNull() ? new QgsGeometry( geom ) : nullptr;
|
mGeometry = !geom.isNull() ? new QgsGeometry( geom ) : nullptr;
|
||||||
init();
|
init();
|
||||||
@ -68,10 +56,8 @@ QgsHighlight::QgsHighlight( QgsMapCanvas *mapCanvas, const QgsGeometry &geom, Qg
|
|||||||
|
|
||||||
QgsHighlight::QgsHighlight( QgsMapCanvas *mapCanvas, const QgsFeature &feature, QgsVectorLayer *layer )
|
QgsHighlight::QgsHighlight( QgsMapCanvas *mapCanvas, const QgsFeature &feature, QgsVectorLayer *layer )
|
||||||
: QgsMapCanvasItem( mapCanvas )
|
: QgsMapCanvasItem( mapCanvas )
|
||||||
, mLayer( static_cast<QgsMapLayer *>( layer ) )
|
, mLayer( layer )
|
||||||
, mFeature( feature )
|
, mFeature( feature )
|
||||||
, mBuffer( 0 )
|
|
||||||
, mMinWidth( 0 )
|
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
@ -34,8 +34,17 @@ class QgsSymbol;
|
|||||||
* \ingroup gui
|
* \ingroup gui
|
||||||
* A class for highlight features on the map.
|
* A class for highlight features on the map.
|
||||||
*
|
*
|
||||||
* The QgsHighlight class provides a transparent overlay widget
|
* The QgsHighlight class provides a transparent overlay canvas item
|
||||||
for highlighting features on the map.
|
* for highlighting features or geometries on a map canvas.
|
||||||
|
*
|
||||||
|
* \code{.py}
|
||||||
|
* color = QColor(Qt.red)
|
||||||
|
* highlight = QgsHighlight(mapCanvas, feature, layer)
|
||||||
|
* highlight.setColor(color)
|
||||||
|
* color.setAlpha(50)
|
||||||
|
* highlight.setFillColor(color)
|
||||||
|
* highlight.show()
|
||||||
|
* \endcode
|
||||||
*/
|
*/
|
||||||
class GUI_EXPORT QgsHighlight: public QgsMapCanvasItem
|
class GUI_EXPORT QgsHighlight: public QgsMapCanvasItem
|
||||||
{
|
{
|
||||||
@ -46,17 +55,8 @@ class GUI_EXPORT QgsHighlight: public QgsMapCanvasItem
|
|||||||
* \param mapCanvas associated map canvas
|
* \param mapCanvas associated map canvas
|
||||||
* \param geom initial geometry of highlight
|
* \param geom initial geometry of highlight
|
||||||
* \param layer associated map layer
|
* \param layer associated map layer
|
||||||
* \note not available in Python bindings
|
|
||||||
*/
|
*/
|
||||||
QgsHighlight( QgsMapCanvas *mapCanvas, const QgsGeometry &geom, QgsMapLayer *layer ) SIP_SKIP;
|
QgsHighlight( QgsMapCanvas *mapCanvas, const QgsGeometry &geom, QgsMapLayer *layer );
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor for QgsHighlight
|
|
||||||
* \param mapCanvas associated map canvas
|
|
||||||
* \param geom initial geometry of highlight
|
|
||||||
* \param layer associated vector layer
|
|
||||||
*/
|
|
||||||
QgsHighlight( QgsMapCanvas *mapCanvas, const QgsGeometry &geom, QgsVectorLayer *layer );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for highlighting true feature shape using feature attributes
|
* Constructor for highlighting true feature shape using feature attributes
|
||||||
@ -74,24 +74,38 @@ class GUI_EXPORT QgsHighlight: public QgsMapCanvasItem
|
|||||||
void setColor( const QColor &color );
|
void setColor( const QColor &color );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set polygons fill color.
|
* Fill color for the highlight.
|
||||||
* \since QGIS 2.3 */
|
* Will be used for polygons and points.
|
||||||
|
*
|
||||||
|
* \since QGIS 2.4
|
||||||
|
*/
|
||||||
void setFillColor( const QColor &fillColor );
|
void setFillColor( const QColor &fillColor );
|
||||||
|
|
||||||
//! Set stroke width. Ignored in feature mode.
|
/**
|
||||||
|
* Set stroke width.
|
||||||
|
*
|
||||||
|
* \note Ignored in feature mode.
|
||||||
|
*/
|
||||||
void setWidth( int width );
|
void setWidth( int width );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set line / stroke buffer in millimeters.
|
* Set line / stroke buffer in millimeters.
|
||||||
* \since QGIS 2.3 */
|
*
|
||||||
|
* \since QGIS 2.4
|
||||||
|
*/
|
||||||
void setBuffer( double buffer ) { mBuffer = buffer; }
|
void setBuffer( double buffer ) { mBuffer = buffer; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set minimum line / stroke width in millimeters.
|
* Set minimum line / stroke width in millimeters.
|
||||||
* \since QGIS 2.3 */
|
*
|
||||||
|
* \since QGIS 2.4
|
||||||
|
*/
|
||||||
void setMinWidth( double width ) { mMinWidth = width; }
|
void setMinWidth( double width ) { mMinWidth = width; }
|
||||||
|
|
||||||
const QgsMapLayer *layer() const { return mLayer; }
|
/**
|
||||||
|
* Return the layer for which this highlight has been created.
|
||||||
|
*/
|
||||||
|
QgsMapLayer *layer() const { return mLayer; }
|
||||||
|
|
||||||
virtual void updatePosition() override;
|
virtual void updatePosition() override;
|
||||||
|
|
||||||
@ -116,8 +130,8 @@ class GUI_EXPORT QgsHighlight: public QgsMapCanvasItem
|
|||||||
QgsGeometry *mGeometry = nullptr;
|
QgsGeometry *mGeometry = nullptr;
|
||||||
QgsMapLayer *mLayer = nullptr;
|
QgsMapLayer *mLayer = nullptr;
|
||||||
QgsFeature mFeature;
|
QgsFeature mFeature;
|
||||||
double mBuffer; // line / stroke buffer in pixels
|
double mBuffer = 0; // line / stroke buffer in pixels
|
||||||
double mMinWidth; // line / stroke minimum width in pixels
|
double mMinWidth = 0; // line / stroke minimum width in pixels
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user