Skip to content
Permalink
Browse files

indentation update (and minor cleanuppps ;))

  • Loading branch information
jef-n committed Oct 5, 2012
1 parent e0d4784 commit 1a1370f33def7a65a2af7adfb2c4f363fea72fb6
Showing with 51 additions and 68 deletions.
  1. +8 −24 src/app/qgssnappingdialog.cpp
  2. +1 −1 src/app/qgssnappingdialog.h
  3. +42 −43 src/gui/qgsmapcanvassnapper.cpp
@@ -114,20 +114,18 @@ void QgsSnappingDialog::reload()
}

setTopologicalEditingState();
setIntersectionSnapppingState();
setIntersectionSnappingState();
}

void QgsSnappingDialog::on_cbxEnableTopologicalEditingCheckBox_stateChanged( int state )
{
int topologicalEditingEnabled = ( state == Qt::Checked ) ? 1 : 0;
QgsProject::instance()->writeEntry( "Digitizing", "/TopologicalEditing", topologicalEditingEnabled );
QgsProject::instance()->writeEntry( "Digitizing", "/TopologicalEditing", state == Qt::Checked );
setTopologicalEditingState();
}

void QgsSnappingDialog::on_cbxEnableIntersectionSnappingCheckBox_stateChanged( int state )
{
int intersectionSnappingEnabled = ( state == Qt::Checked ) ? 1 : 0;
QgsProject::instance()->writeEntry( "Digitizing", "/IntersectionSnapping", intersectionSnappingEnabled );
QgsProject::instance()->writeEntry( "Digitizing", "/IntersectionSnapping", state == Qt::Checked );
}

void QgsSnappingDialog::closeEvent( QCloseEvent* event )
@@ -197,7 +195,7 @@ void QgsSnappingDialog::apply()
void QgsSnappingDialog::show()
{
setTopologicalEditingState();
setIntersectionSnapppingState();
setIntersectionSnappingState();
if ( mDock )
mDock->setVisible( true );
else
@@ -329,7 +327,7 @@ void QgsSnappingDialog::addLayer( QgsMapLayer * theMapLayer )
}

setTopologicalEditingState();
setIntersectionSnapppingState();
setIntersectionSnappingState();
}
}

@@ -357,29 +355,15 @@ void QgsSnappingDialog::setTopologicalEditingState()
// read the digitizing settings
int topologicalEditing = QgsProject::instance()->readNumEntry( "Digitizing", "/TopologicalEditing", 0 );
cbxEnableTopologicalEditingCheckBox->blockSignals( true );
if ( topologicalEditing != 0 )
{
cbxEnableTopologicalEditingCheckBox->setCheckState( Qt::Checked );
}
else
{
cbxEnableTopologicalEditingCheckBox->setCheckState( Qt::Unchecked );
}
cbxEnableTopologicalEditingCheckBox->setChecked( topologicalEditing );
cbxEnableTopologicalEditingCheckBox->blockSignals( false );
}

void QgsSnappingDialog::setIntersectionSnapppingState()
void QgsSnappingDialog::setIntersectionSnappingState()
{
// read the digitizing settings
int intersectionSnapping = QgsProject::instance()->readNumEntry( "Digitizing", "/IntersectionSnapping", 0 );
cbxEnableIntersectionSnappingCheckBox->blockSignals( true );
if ( intersectionSnapping != 0 )
{
cbxEnableIntersectionSnappingCheckBox->setCheckState( Qt::Checked );
}
else
{
cbxEnableIntersectionSnappingCheckBox->setCheckState( Qt::Unchecked );
}
cbxEnableIntersectionSnappingCheckBox->setChecked( intersectionSnapping );
cbxEnableIntersectionSnappingCheckBox->blockSignals( false );
}
@@ -89,7 +89,7 @@ class QgsSnappingDialog: public QDialog, private Ui::QgsSnappingDialogBase
void setTopologicalEditingState();

/**Set checkbox value based on project setting*/
void setIntersectionSnapppingState();
void setIntersectionSnappingState();
};

#endif
@@ -136,29 +136,29 @@ int QgsMapCanvasSnapper::snapToBackgroundLayers( const QPoint& p, QList<QgsSnapp
int topologicalEditing = QgsProject::instance()->readNumEntry( "Digitizing", "/TopologicalEditing", 0 );

//snapping on intersection on?
int intersectionSnapping = QgsProject::instance()->readNumEntry( "Digitizing", "/IntersectionSnapping", 0 );
int intersectionSnapping = QgsProject::instance()->readNumEntry( "Digitizing", "/IntersectionSnapping", 0 );

if ( topologicalEditing == 0 )
{
if ( intersectionSnapping == 0 )
{
mSnapper->setSnapMode( QgsSnapper::SnapWithOneResult );
}
else
{
mSnapper->setSnapMode( QgsSnapper::SnapWithResultsWithinTolerances );
}
if ( intersectionSnapping == 0 )
{
mSnapper->setSnapMode( QgsSnapper::SnapWithOneResult );
}
else
{
mSnapper->setSnapMode( QgsSnapper::SnapWithResultsWithinTolerances );
}
}
else
{
if ( intersectionSnapping == 0 )
{
mSnapper->setSnapMode( QgsSnapper::SnapWithResultsForSamePosition );
}
else
{
mSnapper->setSnapMode( QgsSnapper::SnapWithResultsWithinTolerances );
}
if ( intersectionSnapping == 0 )
{
mSnapper->setSnapMode( QgsSnapper::SnapWithResultsForSamePosition );
}
else
{
mSnapper->setSnapMode( QgsSnapper::SnapWithResultsWithinTolerances );
}
}


@@ -279,60 +279,59 @@ int QgsMapCanvasSnapper::snapToBackgroundLayers( const QPoint& p, QList<QgsSnapp
return 4;
}

if( intersectionSnapping == 1 )
if ( intersectionSnapping == 1 )
{
QList<QgsSnappingResult>::const_iterator it = results.constBegin();
QList<QgsSnappingResult> segments;
QList<QgsSnappingResult> points;
for ( ; it != results.constEnd(); ++it )
{
if(it->snappedVertexNr==-1)
if ( it->snappedVertexNr == -1 )
{
QgsDebugMsg("segment");
segments.push_back(*it);
QgsDebugMsg( "segment" );
segments.push_back( *it );
}
else
{
QgsDebugMsg("no segment");
points.push_back(*it);
QgsDebugMsg( "no segment" );
points.push_back( *it );
}
}

if(segments.length() >=2 )
if ( segments.length() >= 2 )
{

QgsGeometry* intersectionPoint;
QList<QgsSnappingResult> myResults;

QList<QgsSnappingResult>::const_iterator oSegIt = segments.constBegin();
QList<QgsSnappingResult>::iterator iSegIt;
for( ; oSegIt != segments.constEnd(); ++oSegIt)
for ( ; oSegIt != segments.constEnd(); ++oSegIt )
{
QgsDebugMsg( QString::number(oSegIt->beforeVertexNr) );
QgsDebugMsg( QString::number( oSegIt->beforeVertexNr ) );

QVector<QgsPoint> vertexPoints;
vertexPoints.append( oSegIt->beforeVertex );
vertexPoints.append( oSegIt->afterVertex );
QgsGeometry* lineA = QgsGeometry::fromPolyline( vertexPoints );

for ( iSegIt = segments.begin(); iSegIt != segments.end(); ++iSegIt )
{
QVector<QgsPoint> vertexPoints;
vertexPoints.append( oSegIt->beforeVertex );
vertexPoints.append( oSegIt->afterVertex );
QgsGeometry* lineA = QgsGeometry::fromPolyline( vertexPoints );
vertexPoints.append( iSegIt->beforeVertex );
vertexPoints.append( iSegIt->afterVertex );
QgsGeometry* lineB = QgsGeometry::fromPolyline( vertexPoints );

for( iSegIt = segments.begin(); iSegIt != segments.end(); ++iSegIt)
QgsGeometry* intersectionPoint = lineA->intersection( lineB );
if ( intersectionPoint->type() == QGis::Point )
{
QVector<QgsPoint> vertexPoints;
vertexPoints.append( iSegIt->beforeVertex );
vertexPoints.append( iSegIt->afterVertex );
QgsGeometry* lineB = QgsGeometry::fromPolyline( vertexPoints );

intersectionPoint = lineA->intersection(lineB);
if( intersectionPoint->type() == QGis::Point)
{
iSegIt->snappedVertex = intersectionPoint->asPoint();
myResults.append(*iSegIt);
}
iSegIt->snappedVertex = intersectionPoint->asPoint();
myResults.append( *iSegIt );
}
}

}

if( myResults.length() > 0 )
if ( myResults.length() > 0 )
{
results.clear();
results = myResults;

0 comments on commit 1a1370f

Please sign in to comment.
You can’t perform that action at this time.