Skip to content

Commit

Permalink
Nyall's review
Browse files Browse the repository at this point in the history
  • Loading branch information
lbartoletti committed Nov 13, 2018
1 parent abcf2aa commit a8f8659
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 22 deletions.
4 changes: 2 additions & 2 deletions python/core/auto_generated/geometry/qgsgeometryutils.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ Project the point on a segment



static int leftOfLine( double x, double y, double x1, double y1, double x2, double y2 );
static int leftOfLine( const double x, const double y, const double x1, const double y1, const double x2, const double y2 );
%Docstring
Returns a value < 0 if the point (``x``, ``y``) is left of the line from (``x1``, ``y1``) -> ( ``x2``, ``y2``).
A positive return value indicates the point is to the right of the line.
Expand All @@ -226,7 +226,7 @@ If the return value is 0, then the test was unsuccessful (e.g. due to testing a
on the line, or exactly in line with the segment) and the result is undefined.
%End

static int leftOfLine( QgsPoint point, QgsPoint p1, QgsPoint p2 );
static int leftOfLine( const QgsPoint point, const QgsPoint p1, const QgsPoint p2 );
%Docstring
Returns a value < 0 if the point ``point`` is left of the line from ``p1`` -> ``p2``.
A positive return value indicates the point is to the right of the line.
Expand Down
7 changes: 1 addition & 6 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2122,7 +2122,7 @@ void QgisApp::createActions()
connect( mActionSnappingOptions, &QAction::triggered, this, &QgisApp::snappingOptions );
connect( mActionOffsetCurve, &QAction::triggered, this, &QgisApp::offsetCurve );
connect( mActionReverseLine, &QAction::triggered, this, &QgisApp::reverseLine );
connect( mActionTrimExtendFeature, &QAction::triggered, this, &QgisApp::trimExtendFeature );
connect( mActionTrimExtendFeature, &QAction::triggered, this, [ = ] { mMapCanvas->setMapTool( mMapTools.mTrimExtendFeature ); } );

// View Menu Items
connect( mActionPan, &QAction::triggered, this, &QgisApp::pan );
Expand Down Expand Up @@ -7864,11 +7864,6 @@ void QgisApp::reverseLine()
mMapCanvas->setMapTool( mMapTools.mReverseLine );
}

void QgisApp::trimExtendFeature()
{
mMapCanvas->setMapTool( mMapTools.mTrimExtendFeature );
}

QgsGeometry QgisApp::unionGeometries( const QgsVectorLayer *vl, QgsFeatureList &featureList, bool &canceled )
{
canceled = false;
Expand Down
2 changes: 0 additions & 2 deletions src/app/qgisapp.h
Original file line number Diff line number Diff line change
Expand Up @@ -1432,8 +1432,6 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
void offsetPointSymbol();
//! activates the reverse line tool
void reverseLine();
//! activates the trim/extend feature tool
void trimExtendFeature();
//! activates the tool
void setMapTool( QgsMapTool *tool, bool clean = false );

Expand Down
14 changes: 6 additions & 8 deletions src/app/qgsmaptooltrimextendfeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ class FeatureFilter : public QgsPointLocator::MatchFilter

bool acceptMatch( const QgsPointLocator::Match &match ) override
{
if ( layer )
return match.layer() == layer && match.hasEdge();
if ( mLayer )
return match.layer() == mLayer && match.hasEdge();

return match.hasEdge();
}
// We only want to modify the current layer. When geometries are overlapped, this makes it possible to snap onto the current layer.
void setLayer( QgsVectorLayer *vlayer ) { layer = vlayer; }
void setLayer( QgsVectorLayer *vlayer ) { mLayer = vlayer; }

private:
const QgsVectorLayer *layer = nullptr;
const QgsVectorLayer *mLayer = nullptr;
};

QgsMapToolTrimExtendFeature::QgsMapToolTrimExtendFeature( QgsMapCanvas *canvas )
Expand All @@ -62,7 +62,7 @@ static void getPoints( const QgsPointLocator::Match &match, QgsPoint &p1, QgsPoi
const QgsFeatureId fid = match.featureId();
const int vertex = match.vertexIndex();

const QgsGeometry geom = match.layer()->getFeature( fid ).geometry();
const QgsGeometry geom = match.layer()->getGeometry( fid );

if ( !( geom.isNull() || geom.isEmpty() ) )
{
Expand Down Expand Up @@ -137,9 +137,7 @@ void QgsMapToolTrimExtendFeature::canvasMoveEvent( QgsMapMouseEvent *e )
if ( is3DLayer && QgsWkbTypes::hasZ( match.layer()->wkbType() ) )
{
/* Z Interpolation */
QgsLineString line( QVector<QgsPoint>()
<< pLimit1
<< pLimit2 );
QgsLineString line( pLimit1, pLimit2 );

intersection = QgsGeometryUtils::closestPoint( line, QgsPoint( intersection ) );
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/geometry/qgsgeometryutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,12 +529,12 @@ QVector<QgsGeometryUtils::SelfIntersection> QgsGeometryUtils::selfIntersections(
return intersections;
}

int QgsGeometryUtils::leftOfLine( QgsPoint point, QgsPoint p1, QgsPoint p2 )
int QgsGeometryUtils::leftOfLine( const QgsPoint point, const QgsPoint p1, const QgsPoint p2 )
{
return leftOfLine( point.x(), point.y(), p1.x(), p1.y(), p2.x(), p2.y() );
}

int QgsGeometryUtils::leftOfLine( double x, double y, double x1, double y1, double x2, double y2 )
int QgsGeometryUtils::leftOfLine( const double x, const double y, const double x1, const double y1, const double x2, const double y2 )
{
double f1 = x - x1;
double f2 = y2 - y1;
Expand Down
4 changes: 2 additions & 2 deletions src/core/geometry/qgsgeometryutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ class CORE_EXPORT QgsGeometryUtils
* If the return value is 0, then the test was unsuccessful (e.g. due to testing a point exactly
* on the line, or exactly in line with the segment) and the result is undefined.
*/
static int leftOfLine( double x, double y, double x1, double y1, double x2, double y2 );
static int leftOfLine( const double x, const double y, const double x1, const double y1, const double x2, const double y2 );

/**
* Returns a value < 0 if the point \a point is left of the line from \a p1 -> \a p2.
Expand All @@ -255,7 +255,7 @@ class CORE_EXPORT QgsGeometryUtils
*
* \since QGIS 3.6
*/
static int leftOfLine( QgsPoint point, QgsPoint p1, QgsPoint p2 );
static int leftOfLine( const QgsPoint point, const QgsPoint p1, const QgsPoint p2 );

/**
* Returns a point a specified \a distance toward a second point.
Expand Down

0 comments on commit a8f8659

Please sign in to comment.