Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9a9cf3c
commit c66b893
Showing
8 changed files
with
257 additions
and
0 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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,70 @@ | ||
/*************************************************************************** | ||
qgsmaptoolcircle3tangents.h - map tool for adding circle | ||
from 3 tangents | ||
--------------------- | ||
begin : July 2017 | ||
copyright : (C) 2017 by Loïc Bartoletti | ||
email : lbartoletti at tuxfamily dot org | ||
*************************************************************************** | ||
* * | ||
* 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 "qgsmaptoolcircle3tangents.h" | ||
#include "qgsgeometryrubberband.h" | ||
#include "qgslinestring.h" | ||
#include "qgsmapcanvas.h" | ||
#include "qgspoint.h" | ||
#include <QMouseEvent> | ||
|
||
QgsMapToolCircle3Tangents::QgsMapToolCircle3Tangents( QgsMapToolCapture *parentTool, | ||
QgsMapCanvas *canvas, CaptureMode mode ) | ||
: QgsMapToolAddCircle( parentTool, canvas, mode ) | ||
{ | ||
} | ||
|
||
QgsMapToolCircle3Tangents::~QgsMapToolCircle3Tangents() | ||
{ | ||
} | ||
|
||
void QgsMapToolCircle3Tangents::cadCanvasReleaseEvent( QgsMapMouseEvent *e ) | ||
{ | ||
|
||
QList<QgsPointXY> segment = e->snapSegment( QgsMapMouseEvent::SnapProjectConfig ); | ||
|
||
if ( e->button() == Qt::LeftButton ) | ||
{ | ||
if ( ( mPoints.size() <= 2 * 2 ) ) | ||
{ | ||
mPoints.append( QgsPoint( segment.at( 0 ) ) ); | ||
mPoints.append( QgsPoint( segment.at( 1 ) ) ); | ||
|
||
|
||
} | ||
|
||
if ( !mPoints.isEmpty() ) | ||
{ | ||
if ( !mTempRubberBand ) | ||
{ | ||
mTempRubberBand = createGeometryRubberBand( ( mode() == CapturePolygon ) ? QgsWkbTypes::PolygonGeometry : QgsWkbTypes::LineGeometry, true ); | ||
mTempRubberBand->show(); | ||
} | ||
} | ||
} | ||
else if ( e->button() == Qt::RightButton ) | ||
{ | ||
if ( !segment.empty() && ( mPoints.size() == 6 ) ) | ||
{ | ||
mCircle = QgsCircle().from3Tangents( mPoints.at( 0 ), mPoints.at( 1 ), mPoints.at( 2 ), mPoints.at( 3 ), mPoints.at( 4 ), mPoints.at( 5 ) ); | ||
} | ||
deactivate(); | ||
if ( mParentTool ) | ||
{ | ||
mParentTool->canvasReleaseEvent( e ); | ||
} | ||
} | ||
} |
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,33 @@ | ||
/*************************************************************************** | ||
qgsmaptoolcircle3tangents.h - map tool for adding circle | ||
from 3 tangents | ||
--------------------- | ||
begin : July 2017 | ||
copyright : (C) 2017 by Loïc Bartoletti | ||
email : lbartoletti at tuxfamily dot org | ||
*************************************************************************** | ||
* * | ||
* 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 3 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#ifndef QGSMAPTOOLCIRCLE3TANGENTS_H | ||
#define QGSMAPTOOLCIRCLE3TANGENTS_H | ||
|
||
#include "qgsmaptooladdcircle.h" | ||
|
||
class QgsMapToolCircle3Tangents: public QgsMapToolAddCircle | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
QgsMapToolCircle3Tangents( QgsMapToolCapture *parentTool, QgsMapCanvas *canvas, CaptureMode mode = CaptureLine ); | ||
~QgsMapToolCircle3Tangents(); | ||
|
||
void cadCanvasReleaseEvent( QgsMapMouseEvent *e ) override; | ||
}; | ||
|
||
#endif // QGSMAPTOOLCIRCLE3TANGENTS_H |
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