本文整理汇总了C++中QgsVector::x方法的典型用法代码示例。如果您正苦于以下问题:C++ QgsVector::x方法的具体用法?C++ QgsVector::x怎么用?C++ QgsVector::x使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QgsVector
的用法示例。
在下文中一共展示了QgsVector::x方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: intersectLines
bool QgsGeometryValidator::intersectLines( const QgsPoint& p, QgsVector v, const QgsPoint& q, QgsVector w, QgsPoint &s )
{
double d = v.y() * w.x() - v.x() * w.y();
if ( qgsDoubleNear( d, 0 ) )
return false;
double dx = q.x() - p.x();
double dy = q.y() - p.y();
double k = ( dy * w.x() - dx * w.y() ) / d;
s = p + v * k;
return true;
}
示例2: lineIntersection
bool QgsGeometryUtils::lineIntersection( const QgsPointV2& p1, const QgsVector& v, const QgsPointV2& q1, const QgsVector& w, QgsPointV2& inter )
{
double d = v.y() * w.x() - v.x() * w.y();
if ( d == 0 )
return false;
double dx = q1.x() - p1.x();
double dy = q1.y() - p1.y();
double k = ( dy * w.x() - dx * w.y() ) / d;
inter = QgsPointV2( p1.x() + v.x() * k, p1.y() + v.y() * k );
return true;
}
示例3: moveSelectedVertexes
void QgsSelectedFeature::moveSelectedVertexes( QgsVector v )
{
int nUpdates = 0;
Q_FOREACH ( QgsVertexEntry *entry, mVertexMap )
{
if ( entry->isSelected() )
nUpdates++;
}
if ( nUpdates == 0 )
return;
mVlayer->beginEditCommand( QObject::tr( "Moved vertices" ) );
int topologicalEditing = QgsProject::instance()->readNumEntry( "Digitizing", "/TopologicalEditing", 0 );
beginGeometryChange();
QMultiMap<double, QgsSnappingResult> currentResultList;
for ( int i = mVertexMap.size() - 1; i > -1 && nUpdates > 0; i-- )
{
QgsVertexEntry *entry = mVertexMap.value( i, nullptr );
if ( !entry || !entry->isSelected() )
continue;
if ( topologicalEditing )
{
// snap from current vertex
currentResultList.clear();
mVlayer->snapWithContext( entry->pointV1(), ZERO_TOLERANCE, currentResultList, QgsSnapper::SnapToVertex );
}
// only last update should trigger the geometry update
// as vertex selection gets lost on the update
if ( --nUpdates == 0 )
endGeometryChange();
QgsPointV2 p = entry->point();
p.setX( p.x() + v.x() );
p.setY( p.y() + v.y() );
mVlayer->moveVertex( p, mFeatureId, i );
if ( topologicalEditing )
{
QMultiMap<double, QgsSnappingResult>::iterator resultIt = currentResultList.begin();
for ( ; resultIt != currentResultList.end(); ++resultIt )
{
// move all other
if ( mFeatureId != resultIt.value().snappedAtGeometry )
mVlayer->moveVertex( p, resultIt.value().snappedAtGeometry, resultIt.value().snappedVertexNr );
}
}
}
if ( nUpdates > 0 )
endGeometryChange();
mVlayer->endEditCommand();
}
示例4: QgsException
//
// distance of point q from line through p in direction v
// return >0 => q lies left of the line
// <0 => q lies right of the line
//
double QgsGeometryValidator::distLine2Point( const QgsPoint& p, QgsVector v, const QgsPoint& q )
{
if ( qgsDoubleNear( v.length(), 0 ) )
{
throw QgsException( QObject::tr( "invalid line" ) );
}
return ( v.x()*( q.y() - p.y() ) - v.y()*( q.x() - p.x() ) ) / v.length();
}
示例5: canvasMoveEvent
void QgsMapToolNodeTool::canvasMoveEvent( QMouseEvent * e )
{
if ( !mSelectedFeature || !mClicked )
return;
QgsVectorLayer* vlayer = mSelectedFeature->vlayer();
Q_ASSERT( vlayer );
mSelectAnother = false;
if ( mMoving )
{
// create rubberband, if none exists
if ( mRubberBands.empty() )
{
if ( mIsPoint )
{
QList<QgsVertexEntry*> &vertexMap = mSelectedFeature->vertexMap();
for ( int i = 0; i < vertexMap.size(); i++ )
{
if ( vertexMap[i]->isSelected() )
{
QgsRubberBand* rb = createRubberBandMarker( vertexMap[i]->point(), vlayer );
mRubberBands.append( rb );
}
}
}
createMovingRubberBands();
QList<QgsSnappingResult> snapResults;
QgsPoint posMapCoord = snapPointFromResults( snapResults, e->pos() );
mPosMapCoordBackup = posMapCoord;
}
else
{
// move rubberband
QList<QgsSnappingResult> snapResults;
mSnapper.snapToBackgroundLayers( e->pos(), snapResults, QList<QgsPoint>() << mClosestMapVertex );
// get correct coordinates to move to
QgsPoint posMapCoord = snapPointFromResults( snapResults, e->pos() );
QgsPoint pressMapCoords;
if ( snapResults.size() > 0 )
{
pressMapCoords = mClosestMapVertex;
}
else
{
pressMapCoords = toMapCoordinates( mPressCoordinates );
}
QgsVector offset = posMapCoord - pressMapCoords;
// handle points
if ( mIsPoint )
{
for ( int i = 0; i < mRubberBands.size(); i++ )
{
mRubberBands[i]->setTranslationOffset( offset.x(), offset.y() );
}
return;
}
// move points
QList<QgsVertexEntry*> &vertexMap = mSelectedFeature->vertexMap();
for ( int i = 0; i < vertexMap.size(); i++ )
{
if ( !vertexMap[i]->isSelected() )
continue;
QgsPoint p = toMapCoordinates( vlayer, vertexMap[i]->point() ) + offset;
mRubberBands[vertexMap[i]->rubberBandNr()]->movePoint( vertexMap[i]->rubberBandIndex(), p );
if ( vertexMap[i]->rubberBandIndex() == 0 )
{
mRubberBands[vertexMap[i]->rubberBandNr()]->movePoint( 0, p );
}
}
// topological editing
offset = posMapCoord - mPosMapCoordBackup;
for ( int i = 0; i < mTopologyRubberBand.size(); i++ )
{
for ( int pointIndex = 0; pointIndex < mTopologyRubberBand[i]->numberOfVertices(); pointIndex++ )
{
if ( mTopologyRubberBandVertexes[i]->contains( pointIndex ) )
{
const QgsPoint* point = mTopologyRubberBand[i]->getPoint( 0, pointIndex );
if ( point == 0 )
{
break;
}
mTopologyRubberBand[i]->movePoint( pointIndex, *point + offset );
}
}
}
mPosMapCoordBackup = posMapCoord;
//.........这里部分代码省略.........