本文整理汇总了C++中qgspointlocator::Match::hasVertex方法的典型用法代码示例。如果您正苦于以下问题:C++ Match::hasVertex方法的具体用法?C++ Match::hasVertex怎么用?C++ Match::hasVertex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qgspointlocator::Match
的用法示例。
在下文中一共展示了Match::hasVertex方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testNearestVertex
void testNearestVertex()
{
QgsPointLocator loc( mVL );
QgsPointXY pt( 2, 2 );
QgsPointLocator::Match m = loc.nearestVertex( pt, 999 );
QVERIFY( m.isValid() );
QVERIFY( m.hasVertex() );
QCOMPARE( m.layer(), mVL );
QCOMPARE( m.featureId(), ( QgsFeatureId )1 );
QCOMPARE( m.point(), QgsPointXY( 1, 1 ) );
QCOMPARE( m.distance(), std::sqrt( 2.0 ) );
QCOMPARE( m.vertexIndex(), 2 );
}
示例2: setMatch
void QgsSnapIndicator::setMatch( const QgsPointLocator::Match &match )
{
mMatch = match;
if ( !mMatch.isValid() )
{
mSnappingMarker.reset();
QToolTip::hideText();
}
else
{
if ( !mSnappingMarker )
{
mSnappingMarker.reset( new QgsVertexMarker( mCanvas ) );
mSnappingMarker->setPenWidth( 3 );
}
QgsSettings s;
QColor color = s.value( QStringLiteral( "/qgis/digitizing/snap_color" ), QColor( Qt::magenta ) ).value<QColor>();
mSnappingMarker->setColor( color );
int iconType;
if ( match.hasVertex() )
{
if ( match.layer() )
iconType = QgsVertexMarker::ICON_BOX; // vertex snap
else
iconType = QgsVertexMarker::ICON_X; // intersection snap
}
else // must be segment snap
{
iconType = QgsVertexMarker::ICON_DOUBLE_TRIANGLE;
}
mSnappingMarker->setIconType( iconType );
mSnappingMarker->setCenter( match.point() );
// tooltip
if ( s.value( QStringLiteral( "/qgis/digitizing/snap_tooltip" ), false ).toBool() )
{
QPoint ptCanvas = mSnappingMarker->toCanvasCoordinates( match.point() ).toPoint();
QPoint ptGlobal = mCanvas->mapToGlobal( ptCanvas );
QRect rect( ptCanvas.x(), ptCanvas.y(), 1, 1 ); // area where is the tooltip valid
QString layerName = match.layer() ? match.layer()->name() : QString();
QToolTip::showText( ptGlobal, layerName, mCanvas, rect );
}
}
}
示例3: testSnapModeCurrent
void testSnapModeCurrent()
{
QgsMapSettings mapSettings;
mapSettings.setOutputSize( QSize( 100, 100 ) );
mapSettings.setExtent( QgsRectangle( 0, 0, 1, 1 ) );
QVERIFY( mapSettings.hasValidSettings() );
QgsSnappingUtils u;
u.setMapSettings( mapSettings );
u.setCurrentLayer( mVL );
// first try with no snapping enabled
QgsSnappingConfig snappingConfig = u.config();
snappingConfig.setEnabled( false );
snappingConfig.setTolerance( 10 );
snappingConfig.setUnits( QgsTolerance::Pixels );
snappingConfig.setMode( QgsSnappingConfig::ActiveLayer );
u.setConfig( snappingConfig );
QgsPointLocator::Match m0 = u.snapToMap( QPoint( 100, 100 ) );
QVERIFY( !m0.isValid() );
QVERIFY( !m0.hasVertex() );
// now enable snapping
snappingConfig.setEnabled( true );
snappingConfig.setType( QgsSnappingConfig::Vertex );
u.setConfig( snappingConfig );
QgsPointLocator::Match m = u.snapToMap( QPoint( 100, 100 ) );
QVERIFY( m.isValid() );
QVERIFY( m.hasVertex() );
QCOMPARE( m.point(), QgsPoint( 1, 0 ) );
QgsPointLocator::Match m2 = u.snapToMap( QPoint( 0, 100 ) );
QVERIFY( !m2.isValid() );
QVERIFY( !m2.hasVertex() );
// do not consider edges in the following test - on 32-bit platforms
// result was an edge match very close to (1,0) instead of being exactly (1,0)
snappingConfig.setType( QgsSnappingConfig::Vertex );
u.setConfig( snappingConfig );
// test with filtering
FilterExcludePoint myFilter( QgsPoint( 1, 0 ) );
QgsPointLocator::Match m3 = u.snapToMap( QPoint( 100, 100 ), &myFilter );
QVERIFY( !m3.isValid() );
}
示例4: fetchLayerPoint
int QgsMapToolCapture::fetchLayerPoint( const QgsPointLocator::Match &match, QgsPoint &layerPoint )
{
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( mCanvas->currentLayer() );
QgsVectorLayer *sourceLayer = match.layer();
if ( match.isValid() && match.hasVertex() && sourceLayer &&
( sourceLayer->crs() == vlayer->crs() ) )
{
QgsFeature f;
QgsFeatureRequest request;
request.setFilterFid( match.featureId() );
bool fetched = match.layer()->getFeatures( request ).nextFeature( f );
if ( fetched )
{
QgsVertexId vId;
if ( !f.geometry().vertexIdFromVertexNr( match.vertexIndex(), vId ) )
return 2;
layerPoint = f.geometry().constGet()->vertexAt( vId );
// ZM support depends on the target layer
if ( !QgsWkbTypes::hasZ( vlayer->wkbType() ) )
{
layerPoint.dropZValue();
}
if ( !QgsWkbTypes::hasM( vlayer->wkbType() ) )
{
layerPoint.dropMValue();
}
return 0;
}
else
{
return 2;
}
}
else
{
return 1;
}
}
示例5: testSnapModeAdvanced
void testSnapModeAdvanced()
{
QgsMapSettings mapSettings;
mapSettings.setOutputSize( QSize( 100, 100 ) );
mapSettings.setExtent( QgsRectangle( 0, 0, 1, 1 ) );
QVERIFY( mapSettings.hasValidSettings() );
QgsSnappingUtils u;
u.setMapSettings( mapSettings );
u.setSnapToMapMode( QgsSnappingUtils::SnapAdvanced );
QList<QgsSnappingUtils::LayerConfig> layers;
layers << QgsSnappingUtils::LayerConfig( mVL, QgsPointLocator::Vertex, 10, QgsTolerance::Pixels );
u.setLayers( layers );
QgsPointLocator::Match m = u.snapToMap( QPoint( 100, 100 ) );
QVERIFY( m.isValid() );
QVERIFY( m.hasVertex() );
QCOMPARE( m.point(), QgsPoint( 1, 0 ) );
// test with filtering
FilterExcludePoint myFilter( QgsPoint( 1, 0 ) );
QgsPointLocator::Match m2 = u.snapToMap( QPoint( 100, 100 ), &myFilter );
QVERIFY( !m2.isValid() );
}
示例6: testSnapModeAdvanced
void testSnapModeAdvanced()
{
QgsMapSettings mapSettings;
mapSettings.setOutputSize( QSize( 100, 100 ) );
mapSettings.setExtent( QgsRectangle( 0, 0, 1, 1 ) );
QVERIFY( mapSettings.hasValidSettings() );
QgsSnappingUtils u;
QgsSnappingConfig snappingConfig = u.config();
u.setMapSettings( mapSettings );
snappingConfig.setMode( QgsSnappingConfig::AdvancedConfiguration );
snappingConfig.setIndividualLayerSettings( mVL, QgsSnappingConfig::IndividualLayerSettings( true, QgsSnappingConfig::Vertex, 10, QgsTolerance::Pixels ) );
u.setConfig( snappingConfig );
QgsPointLocator::Match m = u.snapToMap( QPoint( 100, 100 ) );
QVERIFY( m.isValid() );
QVERIFY( m.hasVertex() );
QCOMPARE( m.point(), QgsPoint( 1, 0 ) );
// test with filtering
FilterExcludePoint myFilter( QgsPoint( 1, 0 ) );
QgsPointLocator::Match m2 = u.snapToMap( QPoint( 100, 100 ), &myFilter );
QVERIFY( !m2.isValid() );
}