Skip to content

Commit

Permalink
remove vertex highlighting from editor
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Feb 25, 2019
1 parent 0da3651 commit dcb2bea
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 86 deletions.
14 changes: 1 addition & 13 deletions src/app/vertextool/qgslockedfeature.cpp
Expand Up @@ -48,10 +48,6 @@ QgsLockedFeature::QgsLockedFeature( QgsFeatureId featureId,
// rolling back
connect( mLayer, &QgsVectorLayer::beforeRollBack, this, &QgsLockedFeature::beforeRollBack );

// projection or extents changed
connect( canvas, &QgsMapCanvas::destinationCrsChanged, this, &QgsLockedFeature::updateVertexMarkersPosition );
connect( canvas, &QgsMapCanvas::extentsChanged, this, &QgsLockedFeature::updateVertexMarkersPosition );

// geometry was changed
connect( mLayer, &QgsVectorLayer::geometryChanged, this, &QgsLockedFeature::geometryChanged );

Expand Down Expand Up @@ -277,7 +273,7 @@ void QgsLockedFeature::createVertexMap()
QgsPoint pt;
while ( geom->nextVertex( vertexId, pt ) )
{
mVertexMap.append( new QgsVertexEntry( mCanvas, mLayer, pt, vertexId, tr( "ring %1, vertex %2" ).arg( vertexId.ring ).arg( vertexId.vertex ) ) );
mVertexMap.append( new QgsVertexEntry( pt, vertexId ) );
}
}

Expand Down Expand Up @@ -338,14 +334,6 @@ void QgsLockedFeature::invertVertexSelection( const QVector<int> &vertexIndices
emit selectionChanged();
}

void QgsLockedFeature::updateVertexMarkersPosition()
{
Q_FOREACH ( QgsVertexEntry *vertexEntry, mVertexMap )
{
vertexEntry->placeMarker();
}
}

QgsFeatureId QgsLockedFeature::featureId()
{
return mFeatureId;
Expand Down
7 changes: 0 additions & 7 deletions src/app/vertextool/qgslockedfeature.h
Expand Up @@ -24,10 +24,8 @@
class QgsMapCanvas;
class QgsVectorLayer;
class QgsMapLayer;
class QgsRubberBand;
class QgsGeometryValidator;
class QgsVertexMarker;

class QgsVertexEntry;

/**
Expand Down Expand Up @@ -136,11 +134,6 @@ class QgsLockedFeature: public QObject
*/
void validationFinished();

/**
* Updates vertex markers position accoording to changed feature geometry
*/
void updateVertexMarkersPosition();

/*
* a feature was removed from the layer - might be the selected
*/
Expand Down
48 changes: 1 addition & 47 deletions src/app/vertextool/qgsvertexentry.cpp
Expand Up @@ -19,65 +19,19 @@
#include "qgsmaplayer.h"
#include "qgsmapcanvas.h"

QgsVertexEntry::QgsVertexEntry( QgsMapCanvas *canvas, QgsMapLayer *layer, const QgsPoint &p, QgsVertexId vertexId, const QString &tooltip, QgsVertexMarker::IconType type, int penWidth )
QgsVertexEntry::QgsVertexEntry( const QgsPoint &p, QgsVertexId vertexId )
: mSelected( false )
, mPoint( p )
, mVertexId( vertexId )
, mPenWidth( penWidth )
, mToolTip( tooltip )
, mType( type )
, mCanvas( canvas )
, mLayer( layer )
{
placeMarker();
}

QgsVertexEntry::~QgsVertexEntry()
{
delete mMarker;
}

void QgsVertexEntry::placeMarker()
{
QgsPointXY pm = mCanvas->mapSettings().layerToMapCoordinates( mLayer, pointV1() );

if ( mCanvas->extent().contains( pm ) )
{
if ( !mMarker )
{
mMarker = new QgsVertexMarker( mCanvas );
QColor c = mSelected ? QColor( Qt::blue ) : QColor( Qt::red );
if ( mVertexId.type == QgsVertexId::CurveVertex )
{
mMarker->setIconType( QgsVertexMarker::ICON_CIRCLE );
}
else
{
mMarker->setIconType( mType );
}
mMarker->setColor( c );
mMarker->setIconSize( QgsGuiUtils::scaleIconSize( 10 ) );
mMarker->setPenWidth( QgsGuiUtils::scaleIconSize( mPenWidth ) );
mMarker->setToolTip( mToolTip );
}

mMarker->setCenter( pm );
mMarker->update();
}
else if ( mMarker )
{
delete mMarker;
mMarker = nullptr;
}
}

void QgsVertexEntry::setSelected( bool selected )
{
mSelected = selected;
if ( mMarker )
{
QColor c = mSelected ? QColor( Qt::blue ) : QColor( Qt::red );
mMarker->setColor( c );
mMarker->update();
}
}
18 changes: 2 additions & 16 deletions src/app/vertextool/qgsvertexentry.h
Expand Up @@ -17,7 +17,6 @@
#define QGSVERTEXENTRY_H

#include "qgspoint.h"
#include "qgsvertexmarker.h"

class QgsMapLayer;
class QgsMapCanvas;
Expand All @@ -27,21 +26,10 @@ class QgsVertexEntry
bool mSelected;
QgsPoint mPoint;
QgsVertexId mVertexId;
int mPenWidth;
QString mToolTip;
QgsVertexMarker::IconType mType;
QgsVertexMarker *mMarker = nullptr;
QgsMapCanvas *mCanvas = nullptr;
QgsMapLayer *mLayer = nullptr;

public:
QgsVertexEntry( QgsMapCanvas *canvas,
QgsMapLayer *layer,
const QgsPoint &p,
QgsVertexId vertexId,
const QString &tooltip = QString(),
QgsVertexMarker::IconType type = QgsVertexMarker::ICON_BOX,
int penWidth = 2 );
QgsVertexEntry( const QgsPoint &p,
QgsVertexId vertexId );
~QgsVertexEntry();

QgsVertexEntry( const QgsVertexEntry &rh ) = delete;
Expand All @@ -52,8 +40,6 @@ class QgsVertexEntry
QgsVertexId vertexId() const { return mVertexId; }
bool isSelected() const { return mSelected; }

void placeMarker();

void setSelected( bool selected = true );

};
Expand Down
9 changes: 6 additions & 3 deletions src/app/vertextool/qgsvertextool.h
Expand Up @@ -65,11 +65,10 @@ class APP_EXPORT QgsVertexTool : public QgsMapToolAdvancedDigitizing
public:

enum VertexToolMode
{
ActiveLayer,

AllLayers
};
Q_ENUM( VertexToolMode );
Q_ENUM( VertexToolMode )

QgsVertexTool( QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDock, VertexToolMode mode = QgsVertexTool::AllLayers );

Expand Down Expand Up @@ -453,7 +452,11 @@ class APP_EXPORT QgsVertexTool : public QgsMapToolAdvancedDigitizing
};

//! Keeps information about other possible features to select with right click. Null if no info is currently held.
<<<<<<< HEAD
std::unique_ptr<LockedFeatureAlternatives> mLockedFeatureAlternatives;
=======
std::unique_ptr<SelectedFeatureAlternatives> mLockedFeatureAlternatives;
>>>>>>> remove vertex highlighting from editor

// support for validation of geometries

Expand Down

0 comments on commit dcb2bea

Please sign in to comment.