Skip to content
Permalink
Browse files
Remove debugging output to track down travis failure
  • Loading branch information
wonder-sk committed Mar 29, 2017
1 parent 102a90a commit acebb97c4d12614434b000b57c03c7d6a4669fc0
@@ -240,8 +240,6 @@ void QgsNodeTool2::clearDragBands()

void QgsNodeTool2::cadCanvasPressEvent( QgsMapMouseEvent *e )
{
qDebug( "PRESS %d,%d", e->pos().x(), e->pos().y() );

setHighlightedNodes( QList<Vertex>() ); // reset selection

if ( e->button() == Qt::LeftButton )
@@ -266,8 +264,6 @@ void QgsNodeTool2::cadCanvasPressEvent( QgsMapMouseEvent *e )

void QgsNodeTool2::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
{
qDebug( "RELEASE %d,%d", e->pos().x(), e->pos().y() );

if ( mNewVertexFromDoubleClick )
{
QgsPointLocator::Match m( *mNewVertexFromDoubleClick );
@@ -314,25 +310,21 @@ void QgsNodeTool2::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
}
else // selection rect is not being dragged
{
qDebug( "release: no selection rect!" );
if ( e->button() == Qt::LeftButton )
{
// accepting action
if ( mDraggingVertex )
{
QgsPointLocator::Match match = e->mapPointMatch();
qDebug( "release: move vertex" );
moveVertex( e->mapPoint(), &match );
}
else if ( mDraggingEdge )
{
// do not use e.mapPoint() as it may be snapped
qDebug( "release: move edge" );
moveEdge( toMapCoordinates( e->pos() ) );
}
else
{
qDebug( "release: start dragging" );
startDragging( e );
}
}
@@ -474,14 +466,12 @@ QgsPointLocator::Match QgsNodeTool2::snapToEditableLayer( QgsMapMouseEvent *e )
{
QgsPoint mapPoint = toMapCoordinates( e->pos() );
double tol = QgsTolerance::vertexSearchRadius( canvas()->mapSettings() );
qDebug( "snap: pt %f,%f tol %f", mapPoint.x(), mapPoint.y(), tol );

QgsSnappingConfig config( QgsProject::instance() );
config.setEnabled( true );
config.setMode( QgsSnappingConfig::AdvancedConfiguration );
config.setIntersectionSnapping( false ); // only snap to layers

qDebug( "canvas layers: %d", canvas()->layers().count() );
Q_FOREACH ( QgsMapLayer *layer, canvas()->layers() )
{
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( layer );
@@ -490,7 +480,6 @@ QgsPointLocator::Match QgsNodeTool2::snapToEditableLayer( QgsMapMouseEvent *e )

config.setIndividualLayerSettings( vlayer, QgsSnappingConfig::IndividualLayerSettings(
true, QgsSnappingConfig::VertexAndSegment, tol, QgsTolerance::ProjectUnits ) );
qDebug( "will use layer %s tolerance %f", vlayer->name().toAscii().data(), tol );
}

QgsSnappingUtils *snapUtils = canvas()->snappingUtils();
@@ -736,13 +725,11 @@ void QgsNodeTool2::startDragging( QgsMapMouseEvent *e )
QgsPoint mapPoint = toMapCoordinates( e->pos() );
if ( isNearEndpointMarker( mapPoint ) )
{
qDebug( "start drag at endpoint" );
startDraggingAddVertexAtEndpoint( mapPoint );
return;
}

QgsPointLocator::Match m = snapToEditableLayer( e );
qDebug( "match type: %d", m.type() );
if ( !m.isValid() )
return;

@@ -752,7 +739,6 @@ void QgsNodeTool2::startDragging( QgsMapMouseEvent *e )
// adding a new vertex instead of moving a vertex
if ( m.hasEdge() )
{
qDebug( "dragging edge!" );
// only start dragging if we are near edge center
mapPoint = toMapCoordinates( e->pos() );
bool isNearCenter = matchEdgeCenterTest( m, mapPoint );
@@ -763,7 +749,6 @@ void QgsNodeTool2::startDragging( QgsMapMouseEvent *e )
}
else // vertex
{
qDebug( "dragging vertex!" );
startDraggingMoveVertex( e->mapPoint(), m );
}
}
@@ -1027,12 +1012,11 @@ void QgsNodeTool2::moveVertex( const QgsPoint &mapPoint, const QgsPointLocator::
stopDragging();

QgsPoint layerPoint = matchToLayerPoint( dragLayer, mapPoint, mapPointMatch );
qDebug( "layer pt: %f,%f", layerPoint.x(), layerPoint.y() );

QgsVertexId vid;
if ( !geom.vertexIdFromVertexNr( dragVertexId, vid ) )
{
qDebug( "invalid vertex index" );
QgsDebugMsg( "invalid vertex index" );
return;
}

@@ -1046,15 +1030,15 @@ void QgsNodeTool2::moveVertex( const QgsPoint &mapPoint, const QgsPointLocator::

if ( !geomTmp->insertVertex( vid, QgsPointV2( layerPoint ) ) )
{
qDebug( "append vertex failed!" );
QgsDebugMsg( "append vertex failed!" );
return;
}
}
else
{
if ( !geomTmp->moveVertex( vid, QgsPointV2( layerPoint ) ) )
{
qDebug( "move vertex failed!" );
QgsDebugMsg( "move vertex failed!" );
return;
}
}
@@ -1082,7 +1066,7 @@ void QgsNodeTool2::moveVertex( const QgsPoint &mapPoint, const QgsPointLocator::

if ( !topoGeom.moveVertex( point.x(), point.y(), topo.vertexId ) )
{
qDebug( "[topo] move vertex failed!" );
QgsDebugMsg( "[topo] move vertex failed!" );
continue;
}
edits[topo.layer][topo.fid] = topoGeom;
@@ -1092,8 +1076,6 @@ void QgsNodeTool2::moveVertex( const QgsPoint &mapPoint, const QgsPointLocator::

// TODO: add topological points: when moving vertex - if snapped to something

qDebug( "writing changes now" );

// do the changes to layers
QHash<QgsVectorLayer *, QHash<QgsFeatureId, QgsGeometry> >::iterator it = edits.begin();
for ( ; it != edits.end(); ++it )
@@ -104,29 +104,18 @@ class QgsPointLocator_VisitorNearestVertex : public IVisitor
QgsGeometry *geom = mLocator->mGeoms.value( id );
int vertexIndex, beforeVertex, afterVertex;
double sqrDist;
qDebug( "VISIT %s", geom->exportToWkt().toAscii().data() );

QgsPoint pt = geom->closestVertex( mSrcPoint, vertexIndex, beforeVertex, afterVertex, sqrDist );
if ( sqrDist < 0 )
{
qDebug( "negative res!!!! (closestVertex)" );
return; // probably empty geometry
}

QgsPointLocator::Match m( QgsPointLocator::Vertex, mLocator->mLayer, id, sqrt( sqrDist ), pt, vertexIndex );
qDebug( "closest vertex dist %f", sqrt( sqrDist ) );
// in range queries the filter may reject some matches
if ( mFilter && !mFilter->acceptMatch( m ) )
{
qDebug( "filtered out!!!!" );
return;
}

if ( !mBest.isValid() || m.distance() < mBest.distance() )
{
mBest = m;
qDebug( "is best!" );
}
}

private:
@@ -685,7 +674,6 @@ bool QgsPointLocator::hasIndex() const

bool QgsPointLocator::rebuildIndex( int maxFeaturesToIndex )
{
qDebug( "rebuild index" );
destroyIndex();

QLinkedList<RTree::Data *> dataList;
@@ -712,15 +700,12 @@ bool QgsPointLocator::rebuildIndex( int maxFeaturesToIndex )
QgsDebugMsg( QString( "could not transform bounding box to map, skipping the snap filter (%1)" ).arg( e.what() ) );
}
}
qDebug( "index extent %s", rect.toString().toAscii().data() );
request.setFilterRect( rect );
}
QgsFeatureIterator fi = mLayer->getFeatures( request );
int indexedCount = 0;
while ( fi.nextFeature( f ) )
{
qDebug( "feature %d", ( int )f.id() );

if ( !f.hasGeometry() )
continue;

@@ -741,8 +726,6 @@ bool QgsPointLocator::rebuildIndex( int maxFeaturesToIndex )
}
}

qDebug( "adding feature to index: %d %s", ( int )f.id(), f.geometry().boundingBox().toString().toAscii().data() );

SpatialIndex::Region r( rect2region( f.geometry().boundingBox() ) );
dataList << new RTree::Data( 0, nullptr, r, f.id() );

@@ -769,7 +752,6 @@ bool QgsPointLocator::rebuildIndex( int maxFeaturesToIndex )

if ( dataList.isEmpty() )
{
qDebug( "empty :(" );
mIsEmptyLayer = true;
return true; // no features
}
@@ -860,28 +842,19 @@ void QgsPointLocator::onGeometryChanged( QgsFeatureId fid, const QgsGeometry &ge

QgsPointLocator::Match QgsPointLocator::nearestVertex( const QgsPoint &point, double tolerance, MatchFilter *filter )
{
qDebug( "nearestVertex %f,%f tol %f", point.x(), point.y(), tolerance );
if ( !mRTree )
{
init();
if ( !mRTree ) // still invalid?
{
qDebug( "!!!!!" );
return Match();
}
}

Match m;
QgsPointLocator_VisitorNearestVertex visitor( this, m, point, filter );
QgsRectangle rect( point.x() - tolerance, point.y() - tolerance, point.x() + tolerance, point.y() + tolerance );
qDebug( "search rect %s", rect.toString().toAscii().data() );
mRTree->intersectsWithQuery( rect2region( rect ), visitor );
qDebug( "nearestVertex res %d..%f", m.type(), m.distance() );
if ( m.isValid() && m.distance() > tolerance )
{
qDebug( "outside!" );
return Match(); // make sure that only match strictly within the tolerance is returned
}
return m;
}

@@ -166,7 +166,6 @@ static QgsPointLocator::Match _findClosestSegmentIntersection( const QgsPoint &p

static void _replaceIfBetter( QgsPointLocator::Match &mBest, const QgsPointLocator::Match &mNew, double maxDistance )
{
qDebug( "replace: old %d..%f / new %d..%f", mBest.type(), mBest.distance(), mNew.type(), mNew.distance() );
// is other match relevant?
if ( !mNew.isValid() || mNew.distance() > maxDistance )
return;
@@ -180,7 +179,6 @@ static void _replaceIfBetter( QgsPointLocator::Match &mBest, const QgsPointLocat
return;

mBest = mNew; // the other match is better!
qDebug( "using it!" );
}


@@ -212,7 +210,6 @@ QgsPointLocator::Match QgsSnappingUtils::snapToMap( const QgsPoint &pointMap, Qg
{
if ( !mMapSettings.hasValidSettings() || !mSnappingConfig.enabled() )
{
qDebug( "snapToMap invalid" );
return QgsPointLocator::Match();
}

@@ -246,7 +243,6 @@ QgsPointLocator::Match QgsSnappingUtils::snapToMap( const QgsPoint &pointMap, Qg
}
else if ( mSnappingConfig.mode() == QgsSnappingConfig::AdvancedConfiguration )
{
qDebug( "snap to map advanced" );
QList<LayerAndAreaOfInterest> layers;
Q_FOREACH ( const LayerConfig &layerConfig, mLayers )
{
@@ -261,11 +257,9 @@ QgsPointLocator::Match QgsSnappingUtils::snapToMap( const QgsPoint &pointMap, Qg

Q_FOREACH ( const LayerConfig &layerConfig, mLayers )
{
qDebug( "snap - layer - %s", layerConfig.layer->name().toAscii().data() );
double tolerance = QgsTolerance::toleranceInProjectUnits( layerConfig.tolerance, layerConfig.layer, mMapSettings, layerConfig.unit );
if ( QgsPointLocator *loc = locatorForLayerUsingStrategy( layerConfig.layer, pointMap, tolerance ) )
{
qDebug( "got locator" );
_updateBestMatch( bestMatch, pointMap, loc, layerConfig.type, tolerance, filter );

if ( mSnappingConfig.intersectionSnapping() )
@@ -321,7 +315,6 @@ QgsPointLocator::Match QgsSnappingUtils::snapToMap( const QgsPoint &pointMap, Qg

void QgsSnappingUtils::prepareIndex( const QList<LayerAndAreaOfInterest> &layers )
{
qDebug( "prep index" );
if ( mIsIndexing )
return;
mIsIndexing = true;
@@ -337,7 +330,6 @@ void QgsSnappingUtils::prepareIndex( const QList<LayerAndAreaOfInterest> &layers
if ( !isIndexPrepared( vl, entry.second ) )
layersToIndex << entry;
}
qDebug( "layers to index: %d", layersToIndex.count() );
if ( !layersToIndex.isEmpty() )
{
// build indexes
@@ -407,11 +399,9 @@ void QgsSnappingUtils::prepareIndex( const QList<LayerAndAreaOfInterest> &layers
loc->init();

QgsDebugMsg( QString( "Index init: %1 ms (%2)" ).arg( tt.elapsed() ).arg( vl->id() ) );
qDebug( "Index init: %d ms (%s)", tt.elapsed(), vl->name().toAscii().data() );
prepareIndexProgress( ++i );
}
QgsDebugMsg( QString( "Prepare index total: %1 ms" ).arg( t.elapsed() ) );
qDebug( "Prepare index total: %d ms", t.elapsed() );
}
mIsIndexing = false;
}
@@ -61,8 +61,6 @@ class TestQgsNodeTool : public QObject
void testAddVertexAtEndpoint();
void testDeleteVertex();

void undoChanged(); // TODO

private:
QPoint mapToScreen( double mapX, double mapY )
{
@@ -127,7 +125,6 @@ void TestQgsNodeTool::initTestCase()

mCanvas = new QgsMapCanvas();

qDebug( "canvas crs %s", mCanvas->mapSettings().destinationCrs().authid().toAscii().data() );
mCanvas->setDestinationCrs( QgsCoordinateReferenceSystem( "EPSG:27700" ) );

mAdvancedDigitizingDockWidget = new QgsAdvancedDigitizingDockWidget( mCanvas );
@@ -176,8 +173,6 @@ void TestQgsNodeTool::initTestCase()
QCOMPARE( mLayerPolygon->undoStack()->index(), 1 );
QCOMPARE( mLayerPoint->undoStack()->index(), 1 );

connect( mLayerLine->undoStack(), &QUndoStack::indexChanged, this, &TestQgsNodeTool::undoChanged );

mCanvas->setFrameStyle( QFrame::NoFrame );
mCanvas->resize( 512, 512 );
mCanvas->setExtent( QgsRectangle( 0, 0, 8, 8 ) );
@@ -188,8 +183,6 @@ void TestQgsNodeTool::initTestCase()

mCanvas->setLayers( QList<QgsMapLayer *>() << mLayerLine << mLayerPolygon << mLayerPoint );

qDebug( "line layer extent: %s", mLayerLine->extent().toString().toAscii().data() );

// TODO: set up snapping

mCanvas->setSnappingUtils( new QgsMapCanvasSnappingUtils( mCanvas, this ) );
@@ -209,11 +202,6 @@ void TestQgsNodeTool::cleanupTestCase()
QgsApplication::exitQgis();
}

void TestQgsNodeTool::undoChanged()
{
qDebug( "UNDO CHANGED" );
}

void TestQgsNodeTool::testMoveVertex()
{
QCOMPARE( mCanvas->mapSettings().outputSize(), QSize( 512, 512 ) );

0 comments on commit acebb97

Please sign in to comment.