-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move handling of snap indicators from map tools to a new class
- Loading branch information
Showing
10 changed files
with
202 additions
and
80 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,59 @@ | ||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/gui/qgssnapindicator.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ | ||
|
||
|
||
|
||
|
||
|
||
|
||
class QgsSnapIndicator | ||
{ | ||
%Docstring | ||
Class that shows snapping marker on map canvas for the current snapping match. | ||
.. versionadded:: 3.0 | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgssnapindicator.h" | ||
%End | ||
public: | ||
QgsSnapIndicator( QgsMapCanvas *canvas ); | ||
%Docstring | ||
Constructs an indicator for the given map canvas | ||
%End | ||
~QgsSnapIndicator(); | ||
|
||
void setMatch( const QgsPointLocator::Match &match ); | ||
%Docstring | ||
Sets snapping match that should be displayed in map canvas. Invalid match hides the indicator | ||
%End | ||
QgsPointLocator::Match match() const; | ||
%Docstring | ||
Returns currently displayed snapping match | ||
:rtype: QgsPointLocator.Match | ||
%End | ||
|
||
void setVisible( bool visible = true ); | ||
%Docstring | ||
Sets whether the snapping indicator is visible | ||
%End | ||
bool isVisible() const; | ||
%Docstring | ||
Returns whether the snapping indicator is visible | ||
:rtype: bool | ||
%End | ||
|
||
}; | ||
|
||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/gui/qgssnapindicator.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ |
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
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,59 @@ | ||
/*************************************************************************** | ||
qgssnapindicator.cpp | ||
-------------------------------------- | ||
Date : October 2017 | ||
Copyright : (C) 2017 by Martin Dobias | ||
Email : wonder dot sk at gmail dot com | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include "qgssnapindicator.h" | ||
|
||
#include "qgsvertexmarker.h" | ||
|
||
|
||
QgsSnapIndicator::QgsSnapIndicator( QgsMapCanvas *canvas ) | ||
: mCanvas( canvas ) | ||
{ | ||
} | ||
|
||
QgsSnapIndicator::~QgsSnapIndicator() | ||
{ | ||
} | ||
|
||
void QgsSnapIndicator::setMatch( const QgsPointLocator::Match &match ) | ||
{ | ||
mMatch = match; | ||
|
||
if ( !mMatch.isValid() ) | ||
{ | ||
mSnappingMarker.reset(); | ||
} | ||
else | ||
{ | ||
if ( !mSnappingMarker ) | ||
{ | ||
mSnappingMarker.reset( new QgsVertexMarker( mCanvas ) ); | ||
mSnappingMarker->setIconType( QgsVertexMarker::ICON_CROSS ); | ||
mSnappingMarker->setColor( Qt::magenta ); | ||
mSnappingMarker->setPenWidth( 3 ); | ||
} | ||
mSnappingMarker->setCenter( match.point() ); | ||
} | ||
} | ||
|
||
void QgsSnapIndicator::setVisible( bool visible ) | ||
{ | ||
mSnappingMarker->setVisible( visible ); | ||
} | ||
|
||
bool QgsSnapIndicator::isVisible() const | ||
{ | ||
return mSnappingMarker->isVisible(); | ||
} |
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,55 @@ | ||
/*************************************************************************** | ||
qgssnapindicator.h | ||
-------------------------------------- | ||
Date : October 2017 | ||
Copyright : (C) 2017 by Martin Dobias | ||
Email : wonder dot sk at gmail dot com | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#ifndef QGSSNAPINDICATOR_H | ||
#define QGSSNAPINDICATOR_H | ||
|
||
#include "qgspointlocator.h" | ||
|
||
#include "qgis_gui.h" | ||
|
||
class QgsMapCanvas; | ||
class QgsVertexMarker; | ||
|
||
|
||
/** | ||
* \ingroup gui | ||
* Class that shows snapping marker on map canvas for the current snapping match. | ||
* \since QGIS 3.0 | ||
*/ | ||
class GUI_EXPORT QgsSnapIndicator | ||
{ | ||
public: | ||
//! Constructs an indicator for the given map canvas | ||
QgsSnapIndicator( QgsMapCanvas *canvas ); | ||
~QgsSnapIndicator(); | ||
|
||
//! Sets snapping match that should be displayed in map canvas. Invalid match hides the indicator | ||
void setMatch( const QgsPointLocator::Match &match ); | ||
//! Returns currently displayed snapping match | ||
QgsPointLocator::Match match() const { return mMatch; } | ||
|
||
//! Sets whether the snapping indicator is visible | ||
void setVisible( bool visible = true ); | ||
//! Returns whether the snapping indicator is visible | ||
bool isVisible() const; | ||
|
||
private: | ||
QgsMapCanvas *mCanvas; | ||
QgsPointLocator::Match mMatch; | ||
std::unique_ptr<QgsVertexMarker> mSnappingMarker; | ||
}; | ||
|
||
#endif // QGSSNAPINDICATOR_H |
Oops, something went wrong.