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
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ QgsLockedFeature::QgsLockedFeature( QgsFeatureId featureId,
// rolling back // rolling back
connect( mLayer, &QgsVectorLayer::beforeRollBack, this, &QgsLockedFeature::beforeRollBack ); 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 // geometry was changed
connect( mLayer, &QgsVectorLayer::geometryChanged, this, &QgsLockedFeature::geometryChanged ); connect( mLayer, &QgsVectorLayer::geometryChanged, this, &QgsLockedFeature::geometryChanged );


Expand Down Expand Up @@ -277,7 +273,7 @@ void QgsLockedFeature::createVertexMap()
QgsPoint pt; QgsPoint pt;
while ( geom->nextVertex( vertexId, 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(); emit selectionChanged();
} }


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

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

class QgsVertexEntry; class QgsVertexEntry;


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


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

/* /*
* a feature was removed from the layer - might be the selected * a feature was removed from the layer - might be the selected
*/ */
Expand Down
48 changes: 1 addition & 47 deletions src/app/vertextool/qgsvertexentry.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -19,65 +19,19 @@
#include "qgsmaplayer.h" #include "qgsmaplayer.h"
#include "qgsmapcanvas.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 ) : mSelected( false )
, mPoint( p ) , mPoint( p )
, mVertexId( vertexId ) , mVertexId( vertexId )
, mPenWidth( penWidth )
, mToolTip( tooltip )
, mType( type )
, mCanvas( canvas )
, mLayer( layer )
{ {
placeMarker();
} }


QgsVertexEntry::~QgsVertexEntry() 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 ) void QgsVertexEntry::setSelected( bool selected )
{ {
mSelected = 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
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#define QGSVERTEXENTRY_H #define QGSVERTEXENTRY_H


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


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


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


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


void placeMarker();

void setSelected( bool selected = true ); void setSelected( bool selected = true );


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


enum VertexToolMode enum VertexToolMode
{
ActiveLayer,
AllLayers AllLayers
}; };
Q_ENUM( VertexToolMode ); Q_ENUM( VertexToolMode )


QgsVertexTool( QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDock, VertexToolMode mode = QgsVertexTool::AllLayers ); 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. //! 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<LockedFeatureAlternatives> mLockedFeatureAlternatives;
=======
std::unique_ptr<SelectedFeatureAlternatives> mLockedFeatureAlternatives;
>>>>>>> remove vertex highlighting from editor


// support for validation of geometries // support for validation of geometries


Expand Down

0 comments on commit dcb2bea

Please sign in to comment.