Skip to content

Commit

Permalink
Fixed some bits from the review
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed Mar 29, 2017
1 parent cabd980 commit 9b85c31
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
8 changes: 4 additions & 4 deletions src/app/nodetool/qgsnodetool2.cpp
Expand Up @@ -429,7 +429,7 @@ void QgsNodeTool2::cadCanvasReleaseEvent( QgsMapMouseEvent *e )

QgsRectangle layerRect = toLayerCoordinates( vlayer, map_rect );
QgsFeature f;
QgsFeatureIterator fi = vlayer->getFeatures( QgsFeatureRequest( layerRect ) );
QgsFeatureIterator fi = vlayer->getFeatures( QgsFeatureRequest( layerRect ).setSubsetOfAttributes( QgsAttributeList() ) );
while ( fi.nextFeature( f ) )
{
QgsGeometry g = f.geometry();
Expand Down Expand Up @@ -793,7 +793,7 @@ void QgsNodeTool2::keyPressEvent( QKeyEvent *e )
if ( !mDraggingVertex && mSelectedNodes.count() == 0 )
return;

if ( e->key() == Qt::Key_Delete )
if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace )
{
e->ignore(); // Override default shortcut management
deleteVertex();
Expand Down Expand Up @@ -826,7 +826,7 @@ QgsGeometry QgsNodeTool2::cachedGeometry( const QgsVectorLayer *layer, QgsFeatur
if ( !layerCache.contains( fid ) )
{
QgsFeature f;
layer->getFeatures( QgsFeatureRequest( fid ) ).nextFeature( f );
layer->getFeatures( QgsFeatureRequest( fid ).setSubsetOfAttributes( QgsAttributeList() ) ).nextFeature( f );
layerCache[fid] = f.geometry();
}

Expand Down Expand Up @@ -1090,7 +1090,7 @@ QgsPoint QgsNodeTool2::matchToLayerPoint( const QgsVectorLayer *destLayer, const
if ( match && match->hasVertex() && match->layer() && match->layer()->crs() == destLayer->crs() )
{
QgsFeature f;
QgsFeatureIterator fi = match->layer()->getFeatures( QgsFeatureRequest( match->featureId() ) );
QgsFeatureIterator fi = match->layer()->getFeatures( QgsFeatureRequest( match->featureId() ).setSubsetOfAttributes( QgsAttributeList() ) );
if ( fi.nextFeature( f ) )
return f.geometry().vertexAt( match->vertexIndex() );
}
Expand Down
32 changes: 17 additions & 15 deletions src/app/nodetool/qgsnodetool2.h
Expand Up @@ -16,6 +16,8 @@
#ifndef QGSNODETOOL2_H
#define QGSNODETOOL2_H

#include <memory>

#include "qgsmaptooladvanceddigitizing.h"

class QRubberBand;
Expand Down Expand Up @@ -172,20 +174,20 @@ class QgsNodeTool2 : public QgsMapToolAdvancedDigitizing
// members used for temporary highlight of stuff

//! marker of a snap match (if any) when dragging a vertex
QgsVertexMarker* mSnapMarker;
QgsVertexMarker* mSnapMarker = nullptr;
//! marker in the middle of an edge while pointer is close to a vertex and not dragging anything
//! (highlighting point that can be clicked to add a new vertex)
QgsVertexMarker* mEdgeCenterMarker;
QgsVertexMarker* mEdgeCenterMarker = nullptr;
//! rubber band for highlight of a whole feature on mouse over and not dragging anything
QgsRubberBand* mFeatureBand;
QgsRubberBand* mFeatureBand = nullptr;
//! source layer for feature_band (null if feature_band is null)
const QgsVectorLayer* mFeatureBandLayer;
const QgsVectorLayer* mFeatureBandLayer = nullptr;
//! source feature id for feature_band (zero if feature_band is null)
QgsFeatureId mFeatureBandFid;
//! highlight of a vertex while mouse pointer is close to a vertex and not dragging anything
QgsRubberBand* mVertexBand;
QgsRubberBand* mVertexBand = nullptr;
//! highlight of an edge while mouse pointer is close to an edge and not dragging anything
QgsRubberBand* mEdgeBand;
QgsRubberBand* mEdgeBand = nullptr;

// members for dragging operation

Expand All @@ -199,16 +201,16 @@ class QgsNodeTool2 : public QgsMapToolAdvancedDigitizing

//! marker for a point used only for moving standalone point geoetry
//! (there are no adjacent vertices so drag_bands is empty in that case)
QgsVertexMarker* mDragPointMarker;
QgsVertexMarker* mDragPointMarker = nullptr;
//! list of QgsRubberBand instances used when dragging
QList<QgsRubberBand*> drag_bands;
//! instance of Vertex that is being currently moved or nothing
//! (vertex_id when adding is a tuple (vid, adding_at_endpoint))
QScopedPointer<Vertex> mDraggingVertex;
std::unique_ptr<Vertex> mDraggingVertex;
//! whether moving a vertex or adding one
DraggingVertexType mDraggingVertexType = NotDragging;
//! instance of Edge that is being currently moved or nothing
QScopedPointer<Edge> mDraggingEdge;
std::unique_ptr<Edge> mDraggingEdge;
//! list of Vertex instances of other vertices that are topologically
//! connected to the vertex being currently dragged
QList<Vertex> mDraggingTopo;
Expand All @@ -223,25 +225,25 @@ class QgsNodeTool2 : public QgsMapToolAdvancedDigitizing
// members for rectangle for selection

//! QPoint if user is dragging a selection rect
QScopedPointer<QPoint> mSelectionRectStartPos;
std::unique_ptr<QPoint> mSelectionRectStartPos;
//! QRect in screen coordinates or null
QScopedPointer<QRect> mSelectionRect;
std::unique_ptr<QRect> mSelectionRect;
//! QRubberBand to show selection_rect
QRubberBand* mSelectionRectItem = nullptr;

// members for addition of vertices at the end of a curve

//! Vertex instance or None
QScopedPointer<Vertex> mMouseAtEndpoint;
std::unique_ptr<Vertex> mMouseAtEndpoint;
//! QgsPoint or None (can't get center from QgsVertexMarker)
QScopedPointer<QgsPoint> mEndpointMarkerCenter;
std::unique_ptr<QgsPoint> mEndpointMarkerCenter;
//! marker shown near the end of a curve to suggest that the user
//! may add a new vertex at the end of the curve
QgsVertexMarker* mEndpointMarker = nullptr;

//! keeps information about previously used snap match
//! to stick with the same highlighted feature next time if there are more options
QScopedPointer<QgsPointLocator::Match> mLastSnap;
std::unique_ptr<QgsPointLocator::Match> mLastSnap;

//! List of two points that will be forced into CAD dock with fake mouse events
//! to allow correct functioning of node tool with CAD dock.
Expand All @@ -250,7 +252,7 @@ class QgsNodeTool2 : public QgsMapToolAdvancedDigitizing

//! When double-clicking to add a new vertex, this member keeps the snap
//! match from "press" event used to be used in following "release" event
QScopedPointer<QgsPointLocator::Match> mNewVertexFromDoubleClick;
std::unique_ptr<QgsPointLocator::Match> mNewVertexFromDoubleClick;

//! Geometry cache for fast access to geometries
QHash<const QgsVectorLayer*, QHash<QgsFeatureId, QgsGeometry> > mCache;
Expand Down

0 comments on commit 9b85c31

Please sign in to comment.