Skip to content

Commit

Permalink
integrate 'Avoid intersections of new polygons' into snapping dialog
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@14797 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Nov 29, 2010
1 parent f06859e commit 978cc79
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 211 deletions.
2 changes: 0 additions & 2 deletions src/app/CMakeLists.txt
Expand Up @@ -9,7 +9,6 @@ SET(QGIS_APP_SRCS
qgsattributedialog.cpp
qgsattributetypedialog.cpp
qgsattributetypeloaddialog.cpp
qgsavoidintersectionsdialog.cpp
qgsbookmarkitem.cpp
qgsbookmarks.cpp
qgsclipboard.cpp
Expand Down Expand Up @@ -163,7 +162,6 @@ SET (QGIS_APP_MOC_HDRS
qgsattributedialog.h
qgsattributetypedialog.h
qgsattributetypeloaddialog.h
qgsavoidintersectionsdialog.h
qgsbookmarks.h
qgscontinuouscolordialog.h
qgsconfigureshortcutsdialog.h
Expand Down
51 changes: 0 additions & 51 deletions src/app/qgsavoidintersectionsdialog.cpp

This file was deleted.

21 changes: 0 additions & 21 deletions src/app/qgsavoidintersectionsdialog.h

This file was deleted.

1 change: 0 additions & 1 deletion src/app/qgsprojectproperties.cpp
Expand Up @@ -20,7 +20,6 @@
#include "qgsprojectproperties.h"

//qgis includes
#include "qgsavoidintersectionsdialog.h"
#include "qgscontexthelp.h"
#include "qgscoordinatetransform.h"
#include "qgslogger.h"
Expand Down
61 changes: 29 additions & 32 deletions src/app/qgssnappingdialog.cpp
Expand Up @@ -16,14 +16,14 @@
***************************************************************************/

#include "qgssnappingdialog.h"
#include "qgsavoidintersectionsdialog.h"
#include "qgsmapcanvas.h"
#include "qgsmaplayer.h"
#include "qgsvectorlayer.h"
#include "qgsmaplayerregistry.h"
#include "qgisapp.h"
#include "qgsproject.h"
#include "qgslogger.h"

#include <QCheckBox>
#include <QDoubleValidator>
#include <QComboBox>
Expand Down Expand Up @@ -96,23 +96,6 @@ void QgsSnappingDialog::on_cbxEnableTopologicalEditingCheckBox_stateChanged( int
QgsProject::instance()->writeEntry( "Digitizing", "/TopologicalEditing", topologicalEditingEnabled );
}

void QgsSnappingDialog::on_mAvoidIntersectionsPushButton_clicked()
{
QgsAvoidIntersectionsDialog d( mMapCanvas, mAvoidIntersectionsSettings );
if ( d.exec() == QDialog::Accepted )
{
d.enabledLayers( mAvoidIntersectionsSettings );
//store avoid intersection layers
QStringList avoidIntersectionList;
QSet<QString>::const_iterator avoidIt = mAvoidIntersectionsSettings.constBegin();
for ( ; avoidIt != mAvoidIntersectionsSettings.constEnd(); ++avoidIt )
{
avoidIntersectionList.append( *avoidIt );
}
QgsProject::instance()->writeEntry( "Digitizing", "/AvoidIntersectionsList", avoidIntersectionList );
}
}

void QgsSnappingDialog::closeEvent( QCloseEvent* event )
{
QDialog::closeEvent( event );
Expand Down Expand Up @@ -151,12 +134,13 @@ void QgsSnappingDialog::update()
defaultSnappingStringIdx = 2;
}

bool layerIdListOk, enabledListOk, toleranceListOk, toleranceUnitListOk, snapToListOk;
bool layerIdListOk, enabledListOk, toleranceListOk, toleranceUnitListOk, snapToListOk, avoidIntersectionListOk;
QStringList layerIdList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingList", &layerIdListOk );
QStringList enabledList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingEnabledList", &enabledListOk );
QStringList toleranceList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingToleranceList", & toleranceListOk );
QStringList toleranceUnitList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingToleranceUnitList", & toleranceUnitListOk );
QStringList snapToList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnapToList", &snapToListOk );
QStringList avoidIntersectionsList = QgsProject::instance()->readListEntry( "Digitizing", "/AvoidIntersectionsList", &avoidIntersectionListOk );

mLayerTreeWidget->clear();

Expand All @@ -165,7 +149,7 @@ void QgsSnappingDialog::update()
for ( it = mapLayers.begin(); it != mapLayers.end() ; ++it )
{
QgsVectorLayer *currentVectorLayer = qobject_cast<QgsVectorLayer *>( it.value() );
if ( !currentVectorLayer )
if ( !currentVectorLayer || currentVectorLayer->geometryType() == QGis::NoGeometry )
continue;

//snap to layer yes/no
Expand Down Expand Up @@ -200,6 +184,13 @@ void QgsSnappingDialog::update()
cbxUnits->setCurrentIndex( defaultSnappingUnit );
mLayerTreeWidget->setItemWidget( item, 4, cbxUnits );

QCheckBox *cbxAvoidIntersection = 0;
if ( currentVectorLayer->geometryType() == QGis::Polygon )
{
cbxAvoidIntersection = new QCheckBox( mLayerTreeWidget );
mLayerTreeWidget->setItemWidget( item, 5, cbxAvoidIntersection );
}

int idx = layerIdList.indexOf( currentVectorLayer->getLayerID() );
if ( idx < 0 )
{
Expand All @@ -225,6 +216,10 @@ void QgsSnappingDialog::update()
cbxSnapTo->setCurrentIndex( snappingStringIdx );
leTolerance->setText( QString::number( toleranceList[idx].toDouble(), 'f' ) );
cbxUnits->setCurrentIndex( toleranceUnitList[idx].toInt() );
if ( cbxAvoidIntersection )
{
cbxAvoidIntersection->setChecked( avoidIntersectionsList.contains( currentVectorLayer->getLayerID() ) );
}
}

// read the digitizing settings
Expand All @@ -238,18 +233,6 @@ void QgsSnappingDialog::update()
cbxEnableTopologicalEditingCheckBox->setCheckState( Qt::Unchecked );
}

bool avoidIntersectionListOk;
mAvoidIntersectionsSettings.clear();
QStringList avoidIntersectionsList = QgsProject::instance()->readListEntry( "Digitizing", "/AvoidIntersectionsList", &avoidIntersectionListOk );
if ( avoidIntersectionListOk )
{
QStringList::const_iterator avoidIt = avoidIntersectionsList.constBegin();
for ( ; avoidIt != avoidIntersectionsList.constEnd(); ++avoidIt )
{
mAvoidIntersectionsSettings.insert( *avoidIt );
}
}

if ( myDockFlag )
{
for ( int i = 0; i < mLayerTreeWidget->topLevelItemCount(); ++i )
Expand All @@ -259,6 +242,12 @@ void QgsSnappingDialog::update()
connect( mLayerTreeWidget->itemWidget( item, 2 ), SIGNAL( currentIndexChanged( int ) ), this, SLOT( apply() ) );
connect( mLayerTreeWidget->itemWidget( item, 3 ), SIGNAL( textEdited( const QString ) ), this, SLOT( apply() ) );
connect( mLayerTreeWidget->itemWidget( item, 4 ), SIGNAL( currentIndexChanged( int ) ), this, SLOT( apply() ) );

QCheckBox *cbxAvoidIntersection = qobject_cast<QCheckBox*>( mLayerTreeWidget->itemWidget( item, 5 ) );
if ( cbxAvoidIntersection )
{
connect( cbxAvoidIntersection, SIGNAL( stateChanged( int ) ), this, SLOT( apply() ) );
}
}
}
}
Expand All @@ -270,6 +259,7 @@ void QgsSnappingDialog::apply()
QStringList toleranceList;
QStringList enabledList;
QStringList toleranceUnitList;
QStringList avoidIntersectionList;

for ( int i = 0; i < mLayerTreeWidget->topLevelItemCount(); ++i )
{
Expand Down Expand Up @@ -298,13 +288,20 @@ void QgsSnappingDialog::apply()

toleranceList << QString::number( qobject_cast<QLineEdit*>( mLayerTreeWidget->itemWidget( currentItem, 3 ) )->text().toDouble(), 'f' );
toleranceUnitList << QString::number( qobject_cast<QComboBox*>( mLayerTreeWidget->itemWidget( currentItem, 4 ) )->currentIndex() );

QCheckBox *cbxAvoidIntersection = qobject_cast<QCheckBox*>( mLayerTreeWidget->itemWidget( currentItem, 5 ) );
if ( cbxAvoidIntersection && cbxAvoidIntersection->isChecked() )
{
avoidIntersectionList << currentItem->data( 0, Qt::UserRole ).toString();
}
}

QgsProject::instance()->writeEntry( "Digitizing", "/LayerSnappingList", layerIdList );
QgsProject::instance()->writeEntry( "Digitizing", "/LayerSnapToList", snapToList );
QgsProject::instance()->writeEntry( "Digitizing", "/LayerSnappingToleranceList", toleranceList );
QgsProject::instance()->writeEntry( "Digitizing", "/LayerSnappingToleranceUnitList", toleranceUnitList );
QgsProject::instance()->writeEntry( "Digitizing", "/LayerSnappingEnabledList", enabledList );
QgsProject::instance()->writeEntry( "Digitizing", "/AvoidIntersectionsList", avoidIntersectionList );
}

void QgsSnappingDialog::show()
Expand Down
1 change: 0 additions & 1 deletion src/app/qgssnappingdialog.h
Expand Up @@ -49,7 +49,6 @@ class QgsSnappingDialog: public QDialog, private Ui::QgsSnappingDialogBase
void connectUpdate( QgsMapLayer* theMapLayer );

void on_cbxEnableTopologicalEditingCheckBox_stateChanged( int );
void on_mAvoidIntersectionsPushButton_clicked();

protected:
/**Constructor
Expand Down
66 changes: 0 additions & 66 deletions src/ui/qgsavoidintersectionsdialogbase.ui

This file was deleted.

0 comments on commit 978cc79

Please sign in to comment.