Skip to content

Commit 978cc79

Browse files
author
jef
committedNov 29, 2010
integrate 'Avoid intersections of new polygons' into snapping dialog
git-svn-id: http://svn.osgeo.org/qgis/trunk@14797 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent f06859e commit 978cc79

8 files changed

+72
-211
lines changed
 

‎src/app/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ SET(QGIS_APP_SRCS
99
qgsattributedialog.cpp
1010
qgsattributetypedialog.cpp
1111
qgsattributetypeloaddialog.cpp
12-
qgsavoidintersectionsdialog.cpp
1312
qgsbookmarkitem.cpp
1413
qgsbookmarks.cpp
1514
qgsclipboard.cpp
@@ -163,7 +162,6 @@ SET (QGIS_APP_MOC_HDRS
163162
qgsattributedialog.h
164163
qgsattributetypedialog.h
165164
qgsattributetypeloaddialog.h
166-
qgsavoidintersectionsdialog.h
167165
qgsbookmarks.h
168166
qgscontinuouscolordialog.h
169167
qgsconfigureshortcutsdialog.h

‎src/app/qgsavoidintersectionsdialog.cpp

Lines changed: 0 additions & 51 deletions
This file was deleted.

‎src/app/qgsavoidintersectionsdialog.h

Lines changed: 0 additions & 21 deletions
This file was deleted.

‎src/app/qgsprojectproperties.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include "qgsprojectproperties.h"
2121

2222
//qgis includes
23-
#include "qgsavoidintersectionsdialog.h"
2423
#include "qgscontexthelp.h"
2524
#include "qgscoordinatetransform.h"
2625
#include "qgslogger.h"

‎src/app/qgssnappingdialog.cpp

Lines changed: 29 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616
***************************************************************************/
1717

1818
#include "qgssnappingdialog.h"
19-
#include "qgsavoidintersectionsdialog.h"
2019
#include "qgsmapcanvas.h"
2120
#include "qgsmaplayer.h"
2221
#include "qgsvectorlayer.h"
2322
#include "qgsmaplayerregistry.h"
2423
#include "qgisapp.h"
2524
#include "qgsproject.h"
2625
#include "qgslogger.h"
26+
2727
#include <QCheckBox>
2828
#include <QDoubleValidator>
2929
#include <QComboBox>
@@ -96,23 +96,6 @@ void QgsSnappingDialog::on_cbxEnableTopologicalEditingCheckBox_stateChanged( int
9696
QgsProject::instance()->writeEntry( "Digitizing", "/TopologicalEditing", topologicalEditingEnabled );
9797
}
9898

99-
void QgsSnappingDialog::on_mAvoidIntersectionsPushButton_clicked()
100-
{
101-
QgsAvoidIntersectionsDialog d( mMapCanvas, mAvoidIntersectionsSettings );
102-
if ( d.exec() == QDialog::Accepted )
103-
{
104-
d.enabledLayers( mAvoidIntersectionsSettings );
105-
//store avoid intersection layers
106-
QStringList avoidIntersectionList;
107-
QSet<QString>::const_iterator avoidIt = mAvoidIntersectionsSettings.constBegin();
108-
for ( ; avoidIt != mAvoidIntersectionsSettings.constEnd(); ++avoidIt )
109-
{
110-
avoidIntersectionList.append( *avoidIt );
111-
}
112-
QgsProject::instance()->writeEntry( "Digitizing", "/AvoidIntersectionsList", avoidIntersectionList );
113-
}
114-
}
115-
11699
void QgsSnappingDialog::closeEvent( QCloseEvent* event )
117100
{
118101
QDialog::closeEvent( event );
@@ -151,12 +134,13 @@ void QgsSnappingDialog::update()
151134
defaultSnappingStringIdx = 2;
152135
}
153136

154-
bool layerIdListOk, enabledListOk, toleranceListOk, toleranceUnitListOk, snapToListOk;
137+
bool layerIdListOk, enabledListOk, toleranceListOk, toleranceUnitListOk, snapToListOk, avoidIntersectionListOk;
155138
QStringList layerIdList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingList", &layerIdListOk );
156139
QStringList enabledList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingEnabledList", &enabledListOk );
157140
QStringList toleranceList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingToleranceList", & toleranceListOk );
158141
QStringList toleranceUnitList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingToleranceUnitList", & toleranceUnitListOk );
159142
QStringList snapToList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnapToList", &snapToListOk );
143+
QStringList avoidIntersectionsList = QgsProject::instance()->readListEntry( "Digitizing", "/AvoidIntersectionsList", &avoidIntersectionListOk );
160144

161145
mLayerTreeWidget->clear();
162146

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

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

187+
QCheckBox *cbxAvoidIntersection = 0;
188+
if ( currentVectorLayer->geometryType() == QGis::Polygon )
189+
{
190+
cbxAvoidIntersection = new QCheckBox( mLayerTreeWidget );
191+
mLayerTreeWidget->setItemWidget( item, 5, cbxAvoidIntersection );
192+
}
193+
203194
int idx = layerIdList.indexOf( currentVectorLayer->getLayerID() );
204195
if ( idx < 0 )
205196
{
@@ -225,6 +216,10 @@ void QgsSnappingDialog::update()
225216
cbxSnapTo->setCurrentIndex( snappingStringIdx );
226217
leTolerance->setText( QString::number( toleranceList[idx].toDouble(), 'f' ) );
227218
cbxUnits->setCurrentIndex( toleranceUnitList[idx].toInt() );
219+
if ( cbxAvoidIntersection )
220+
{
221+
cbxAvoidIntersection->setChecked( avoidIntersectionsList.contains( currentVectorLayer->getLayerID() ) );
222+
}
228223
}
229224

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

241-
bool avoidIntersectionListOk;
242-
mAvoidIntersectionsSettings.clear();
243-
QStringList avoidIntersectionsList = QgsProject::instance()->readListEntry( "Digitizing", "/AvoidIntersectionsList", &avoidIntersectionListOk );
244-
if ( avoidIntersectionListOk )
245-
{
246-
QStringList::const_iterator avoidIt = avoidIntersectionsList.constBegin();
247-
for ( ; avoidIt != avoidIntersectionsList.constEnd(); ++avoidIt )
248-
{
249-
mAvoidIntersectionsSettings.insert( *avoidIt );
250-
}
251-
}
252-
253236
if ( myDockFlag )
254237
{
255238
for ( int i = 0; i < mLayerTreeWidget->topLevelItemCount(); ++i )
@@ -259,6 +242,12 @@ void QgsSnappingDialog::update()
259242
connect( mLayerTreeWidget->itemWidget( item, 2 ), SIGNAL( currentIndexChanged( int ) ), this, SLOT( apply() ) );
260243
connect( mLayerTreeWidget->itemWidget( item, 3 ), SIGNAL( textEdited( const QString ) ), this, SLOT( apply() ) );
261244
connect( mLayerTreeWidget->itemWidget( item, 4 ), SIGNAL( currentIndexChanged( int ) ), this, SLOT( apply() ) );
245+
246+
QCheckBox *cbxAvoidIntersection = qobject_cast<QCheckBox*>( mLayerTreeWidget->itemWidget( item, 5 ) );
247+
if ( cbxAvoidIntersection )
248+
{
249+
connect( cbxAvoidIntersection, SIGNAL( stateChanged( int ) ), this, SLOT( apply() ) );
250+
}
262251
}
263252
}
264253
}
@@ -270,6 +259,7 @@ void QgsSnappingDialog::apply()
270259
QStringList toleranceList;
271260
QStringList enabledList;
272261
QStringList toleranceUnitList;
262+
QStringList avoidIntersectionList;
273263

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

299289
toleranceList << QString::number( qobject_cast<QLineEdit*>( mLayerTreeWidget->itemWidget( currentItem, 3 ) )->text().toDouble(), 'f' );
300290
toleranceUnitList << QString::number( qobject_cast<QComboBox*>( mLayerTreeWidget->itemWidget( currentItem, 4 ) )->currentIndex() );
291+
292+
QCheckBox *cbxAvoidIntersection = qobject_cast<QCheckBox*>( mLayerTreeWidget->itemWidget( currentItem, 5 ) );
293+
if ( cbxAvoidIntersection && cbxAvoidIntersection->isChecked() )
294+
{
295+
avoidIntersectionList << currentItem->data( 0, Qt::UserRole ).toString();
296+
}
301297
}
302298

303299
QgsProject::instance()->writeEntry( "Digitizing", "/LayerSnappingList", layerIdList );
304300
QgsProject::instance()->writeEntry( "Digitizing", "/LayerSnapToList", snapToList );
305301
QgsProject::instance()->writeEntry( "Digitizing", "/LayerSnappingToleranceList", toleranceList );
306302
QgsProject::instance()->writeEntry( "Digitizing", "/LayerSnappingToleranceUnitList", toleranceUnitList );
307303
QgsProject::instance()->writeEntry( "Digitizing", "/LayerSnappingEnabledList", enabledList );
304+
QgsProject::instance()->writeEntry( "Digitizing", "/AvoidIntersectionsList", avoidIntersectionList );
308305
}
309306

310307
void QgsSnappingDialog::show()

‎src/app/qgssnappingdialog.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ class QgsSnappingDialog: public QDialog, private Ui::QgsSnappingDialogBase
4949
void connectUpdate( QgsMapLayer* theMapLayer );
5050

5151
void on_cbxEnableTopologicalEditingCheckBox_stateChanged( int );
52-
void on_mAvoidIntersectionsPushButton_clicked();
5352

5453
protected:
5554
/**Constructor

‎src/ui/qgsavoidintersectionsdialogbase.ui

Lines changed: 0 additions & 66 deletions
This file was deleted.

0 commit comments

Comments
 (0)