avoidIntersectionInSnappinDialog.diff
app/qgssnappingdialog.cpp (Arbeitskopie) | ||
---|---|---|
16 | 16 |
***************************************************************************/ |
17 | 17 | |
18 | 18 |
#include "qgssnappingdialog.h" |
19 |
#include "qgsavoidintersectionsdialog.h" |
|
20 | 19 |
#include "qgsmapcanvas.h" |
21 | 20 |
#include "qgsmaplayer.h" |
22 | 21 |
#include "qgsvectorlayer.h" |
... | ... | |
96 | 95 |
QgsProject::instance()->writeEntry( "Digitizing", "/TopologicalEditing", topologicalEditingEnabled ); |
97 | 96 |
} |
98 | 97 | |
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 | 98 | |
116 | 99 |
void QgsSnappingDialog::closeEvent( QCloseEvent* event ) |
117 | 100 |
{ |
... | ... | |
151 | 134 |
defaultSnappingStringIdx = 2; |
152 | 135 |
} |
153 | 136 | |
154 |
bool layerIdListOk, enabledListOk, toleranceListOk, toleranceUnitListOk, snapToListOk; |
|
137 |
bool layerIdListOk, enabledListOk, toleranceListOk, toleranceUnitListOk, snapToListOk,avoidIntersectionListOk;
|
|
155 | 138 |
QStringList layerIdList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingList", &layerIdListOk ); |
156 | 139 |
QStringList enabledList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingEnabledList", &enabledListOk ); |
157 | 140 |
QStringList toleranceList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingToleranceList", & toleranceListOk ); |
158 | 141 |
QStringList toleranceUnitList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingToleranceUnitList", & toleranceUnitListOk ); |
159 | 142 |
QStringList snapToList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnapToList", &snapToListOk ); |
143 |
QStringList avoidIntersectionsList = QgsProject::instance()->readListEntry( "Digitizing", "/AvoidIntersectionsList", &avoidIntersectionListOk ); |
|
160 | 144 | |
145 | ||
161 | 146 |
mLayerTreeWidget->clear(); |
162 | 147 | |
163 | 148 |
QMap< QString, QgsMapLayer *> mapLayers = QgsMapLayerRegistry::instance()->mapLayers(); |
... | ... | |
200 | 185 |
cbxUnits->setCurrentIndex( defaultSnappingUnit ); |
201 | 186 |
mLayerTreeWidget->setItemWidget( item, 4, cbxUnits ); |
202 | 187 | |
188 |
QCheckBox *cbxAvoid = new QCheckBox( mLayerTreeWidget ); |
|
189 |
mLayerTreeWidget->setItemWidget( item, 5, cbxAvoid ); |
|
190 | ||
203 | 191 |
int idx = layerIdList.indexOf( currentVectorLayer->getLayerID() ); |
204 | 192 |
if ( idx < 0 ) |
205 | 193 |
{ |
... | ... | |
208 | 196 |
} |
209 | 197 | |
210 | 198 |
cbxEnable->setChecked( enabledList[ idx ] == "enabled" ); |
211 | ||
212 | 199 |
int snappingStringIdx = 0; |
213 | 200 |
if ( snapToList[idx] == "to_vertex" ) |
214 | 201 |
{ |
... | ... | |
225 | 212 |
cbxSnapTo->setCurrentIndex( snappingStringIdx ); |
226 | 213 |
leTolerance->setText( QString::number( toleranceList[idx].toDouble(), 'f' ) ); |
227 | 214 |
cbxUnits->setCurrentIndex( toleranceUnitList[idx].toInt() ); |
215 |
|
|
216 |
if ( avoidIntersectionListOk ) |
|
217 |
{ |
|
218 |
QStringList::const_iterator avoidIt = avoidIntersectionsList.constBegin(); |
|
219 |
for ( ; avoidIt != avoidIntersectionsList.constEnd(); ++avoidIt ) |
|
220 |
{ |
|
221 |
if(*avoidIt == currentVectorLayer->getLayerID()) |
|
222 |
{ |
|
223 |
cbxAvoid->setChecked( true ); |
|
224 |
} |
|
225 |
} |
|
226 |
} |
|
228 | 227 |
} |
229 | 228 | |
230 | 229 |
// read the digitizing settings |
... | ... | |
238 | 237 |
cbxEnableTopologicalEditingCheckBox->setCheckState( Qt::Unchecked ); |
239 | 238 |
} |
240 | 239 | |
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 | ||
253 | 240 |
if ( myDockFlag ) |
254 | 241 |
{ |
255 | 242 |
for ( int i = 0; i < mLayerTreeWidget->topLevelItemCount(); ++i ) |
... | ... | |
259 | 246 |
connect( mLayerTreeWidget->itemWidget( item, 2 ), SIGNAL( currentIndexChanged( int ) ), this, SLOT( apply() ) ); |
260 | 247 |
connect( mLayerTreeWidget->itemWidget( item, 3 ), SIGNAL( textEdited( const QString ) ), this, SLOT( apply() ) ); |
261 | 248 |
connect( mLayerTreeWidget->itemWidget( item, 4 ), SIGNAL( currentIndexChanged( int ) ), this, SLOT( apply() ) ); |
249 |
connect( mLayerTreeWidget->itemWidget( item, 5 ), SIGNAL( stateChanged( int ) ), this, SLOT( apply() ) ); |
|
262 | 250 |
} |
263 | 251 |
} |
264 | 252 |
} |
... | ... | |
270 | 258 |
QStringList toleranceList; |
271 | 259 |
QStringList enabledList; |
272 | 260 |
QStringList toleranceUnitList; |
261 |
QStringList avoidIntersectionsList; |
|
273 | 262 | |
274 | 263 |
for ( int i = 0; i < mLayerTreeWidget->topLevelItemCount(); ++i ) |
275 | 264 |
{ |
... | ... | |
298 | 287 | |
299 | 288 |
toleranceList << QString::number( qobject_cast<QLineEdit*>( mLayerTreeWidget->itemWidget( currentItem, 3 ) )->text().toDouble(), 'f' ); |
300 | 289 |
toleranceUnitList << QString::number( qobject_cast<QComboBox*>( mLayerTreeWidget->itemWidget( currentItem, 4 ) )->currentIndex() ); |
290 | ||
291 |
if( qobject_cast<QCheckBox*>( mLayerTreeWidget->itemWidget( currentItem, 5 ) )->isChecked() ) |
|
292 |
{ |
|
293 |
avoidIntersectionsList << currentItem->data( 0, Qt::UserRole ).toString(); |
|
294 |
} |
|
301 | 295 |
} |
302 | 296 | |
303 | 297 |
QgsProject::instance()->writeEntry( "Digitizing", "/LayerSnappingList", layerIdList ); |
... | ... | |
305 | 299 |
QgsProject::instance()->writeEntry( "Digitizing", "/LayerSnappingToleranceList", toleranceList ); |
306 | 300 |
QgsProject::instance()->writeEntry( "Digitizing", "/LayerSnappingToleranceUnitList", toleranceUnitList ); |
307 | 301 |
QgsProject::instance()->writeEntry( "Digitizing", "/LayerSnappingEnabledList", enabledList ); |
302 |
QgsProject::instance()->writeEntry( "Digitizing", "/AvoidIntersectionsList", avoidIntersectionsList ); |
|
308 | 303 |
} |
309 | 304 | |
310 | 305 |
void QgsSnappingDialog::show() |
app/qgsprojectproperties.cpp (Arbeitskopie) | ||
---|---|---|
20 | 20 |
#include "qgsprojectproperties.h" |
21 | 21 | |
22 | 22 |
//qgis includes |
23 |
#include "qgsavoidintersectionsdialog.h" |
|
24 | 23 |
#include "qgscontexthelp.h" |
25 | 24 |
#include "qgscoordinatetransform.h" |
26 | 25 |
#include "qgslogger.h" |
app/qgssnappingdialog.h (Arbeitskopie) | ||
---|---|---|
49 | 49 |
void connectUpdate( QgsMapLayer* theMapLayer ); |
50 | 50 | |
51 | 51 |
void on_cbxEnableTopologicalEditingCheckBox_stateChanged( int ); |
52 |
void on_mAvoidIntersectionsPushButton_clicked(); |
|
53 | 52 | |
54 | 53 |
protected: |
55 | 54 |
/**Constructor |
... | ... | |
68 | 67 |
/**Default constructor forbidden*/ |
69 | 68 |
QgsSnappingDialog(); |
70 | 69 | |
71 |
/**Stores ids of layers where intersections of new polygons is considered. Is passed to / read from QgsAvoidIntersectionsDialog*/ |
|
72 |
QSet<QString> mAvoidIntersectionsSettings; |
|
73 | ||
74 | 70 |
/**Used to query the loaded layers*/ |
75 | 71 |
QgsMapCanvas* mMapCanvas; |
76 | 72 |
app/qgsavoidintersectionsdialog.h (Arbeitskopie) | ||
---|---|---|
1 |
#ifndef QGSAVOIDINTERSECTIONSDIALOG_H |
|
2 |
#define QGSAVOIDINTERSECTIONSDIALOG_H |
|
3 | ||
4 |
#include "ui_qgsavoidintersectionsdialogbase.h" |
|
5 | ||
6 |
class QgsMapCanvas; |
|
7 | ||
8 |
class QgsAvoidIntersectionsDialog: public QDialog, private Ui::QgsAvoidIntersectionsDialogBase |
|
9 |
{ |
|
10 |
Q_OBJECT |
|
11 |
public: |
|
12 |
QgsAvoidIntersectionsDialog( QgsMapCanvas* canvas, const QSet<QString>& enabledLayers, QWidget * parent = 0, Qt::WindowFlags f = 0 ); |
|
13 |
~QgsAvoidIntersectionsDialog(); |
|
14 |
/**Returns ids of layers that are considered for the avoid intersection function*/ |
|
15 |
void enabledLayers( QSet<QString>& enabledLayers ); |
|
16 | ||
17 |
private: |
|
18 |
QgsMapCanvas* mMapCanvas; |
|
19 |
}; |
|
20 | ||
21 |
#endif // QGSAVOIDINTERSECTIONSDIALOG_H |
app/CMakeLists.txt (Arbeitskopie) | ||
---|---|---|
9 | 9 |
qgsattributedialog.cpp |
10 | 10 |
qgsattributetypedialog.cpp |
11 | 11 |
qgsattributetypeloaddialog.cpp |
12 |
qgsavoidintersectionsdialog.cpp |
|
13 | 12 |
qgsbookmarkitem.cpp |
14 | 13 |
qgsbookmarks.cpp |
15 | 14 |
qgsclipboard.cpp |
... | ... | |
163 | 162 |
qgsattributedialog.h |
164 | 163 |
qgsattributetypedialog.h |
165 | 164 |
qgsattributetypeloaddialog.h |
166 |
qgsavoidintersectionsdialog.h |
|
167 | 165 |
qgsbookmarks.h |
168 | 166 |
qgscontinuouscolordialog.h |
169 | 167 |
qgsconfigureshortcutsdialog.h |
app/qgsavoidintersectionsdialog.cpp (Arbeitskopie) | ||
---|---|---|
1 |
#include "qgsavoidintersectionsdialog.h" |
|
2 |
#include "qgsvectorlayer.h" |
|
3 |
#include "qgsmaplayerregistry.h" |
|
4 | ||
5 |
QgsAvoidIntersectionsDialog::QgsAvoidIntersectionsDialog( QgsMapCanvas* canvas, const QSet<QString>& enabledLayers, QWidget * parent, Qt::WindowFlags f ): |
|
6 |
QDialog( parent, f ), mMapCanvas( canvas ) |
|
7 |
{ |
|
8 |
setupUi( this ); |
|
9 | ||
10 |
const QMap<QString, QgsMapLayer*> &mapLayers = QgsMapLayerRegistry::instance()->mapLayers(); |
|
11 | ||
12 |
int i = 0; |
|
13 |
for ( QMap<QString, QgsMapLayer*>::const_iterator it = mapLayers.constBegin(); it != mapLayers.constEnd(); it++, i++ ) |
|
14 |
{ |
|
15 |
QgsVectorLayer* currentLayer = dynamic_cast<QgsVectorLayer*>( it.value() ); |
|
16 |
if ( !currentLayer || currentLayer->geometryType() != QGis::Polygon ) |
|
17 |
continue; |
|
18 | ||
19 |
QListWidgetItem *newItem = new QListWidgetItem( mLayersListWidget ); |
|
20 |
newItem->setText( currentLayer->name() ); |
|
21 |
newItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsUserCheckable ); |
|
22 |
newItem->setData( Qt::UserRole, currentLayer->getLayerID() ); |
|
23 |
if ( enabledLayers.contains( currentLayer->getLayerID() ) ) |
|
24 |
{ |
|
25 |
newItem->setCheckState( Qt::Checked ); |
|
26 |
} |
|
27 |
else |
|
28 |
{ |
|
29 |
newItem->setCheckState( Qt::Unchecked ); |
|
30 |
} |
|
31 |
} |
|
32 |
} |
|
33 | ||
34 |
QgsAvoidIntersectionsDialog::~QgsAvoidIntersectionsDialog() |
|
35 |
{ |
|
36 | ||
37 |
} |
|
38 | ||
39 |
void QgsAvoidIntersectionsDialog::enabledLayers( QSet<QString>& enabledLayers ) |
|
40 |
{ |
|
41 |
enabledLayers.clear(); |
|
42 | ||
43 |
for ( int i = 0; i < mLayersListWidget->count(); ++i ) |
|
44 |
{ |
|
45 |
QListWidgetItem *currentItem = mLayersListWidget->item( i ); |
|
46 |
if ( currentItem->checkState() == Qt::Checked ) |
|
47 |
{ |
|
48 |
enabledLayers.insert( currentItem->data( Qt::UserRole ).toString() ); |
|
49 |
} |
|
50 |
} |
|
51 |
} |
ui/qgsavoidintersectionsdialogbase.ui (Arbeitskopie) | ||
---|---|---|
1 |
<ui version="4.0" > |
|
2 |
<class>QgsAvoidIntersectionsDialogBase</class> |
|
3 |
<widget class="QDialog" name="QgsAvoidIntersectionsDialogBase" > |
|
4 |
<property name="geometry" > |
|
5 |
<rect> |
|
6 |
<x>0</x> |
|
7 |
<y>0</y> |
|
8 |
<width>365</width> |
|
9 |
<height>300</height> |
|
10 |
</rect> |
|
11 |
</property> |
|
12 |
<property name="windowTitle" > |
|
13 |
<string>Remove intersections of new polygons with layers</string> |
|
14 |
</property> |
|
15 |
<layout class="QGridLayout" name="gridLayout" > |
|
16 |
<item row="0" column="0" > |
|
17 |
<widget class="QListWidget" name="mLayersListWidget" /> |
|
18 |
</item> |
|
19 |
<item row="1" column="0" > |
|
20 |
<widget class="QDialogButtonBox" name="mButtonBox" > |
|
21 |
<property name="orientation" > |
|
22 |
<enum>Qt::Horizontal</enum> |
|
23 |
</property> |
|
24 |
<property name="standardButtons" > |
|
25 |
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> |
|
26 |
</property> |
|
27 |
</widget> |
|
28 |
</item> |
|
29 |
</layout> |
|
30 |
</widget> |
|
31 |
<resources/> |
|
32 |
<connections> |
|
33 |
<connection> |
|
34 |
<sender>mButtonBox</sender> |
|
35 |
<signal>accepted()</signal> |
|
36 |
<receiver>QgsAvoidIntersectionsDialogBase</receiver> |
|
37 |
<slot>accept()</slot> |
|
38 |
<hints> |
|
39 |
<hint type="sourcelabel" > |
|
40 |
<x>248</x> |
|
41 |
<y>254</y> |
|
42 |
</hint> |
|
43 |
<hint type="destinationlabel" > |
|
44 |
<x>157</x> |
|
45 |
<y>274</y> |
|
46 |
</hint> |
|
47 |
</hints> |
|
48 |
</connection> |
|
49 |
<connection> |
|
50 |
<sender>mButtonBox</sender> |
|
51 |
<signal>rejected()</signal> |
|
52 |
<receiver>QgsAvoidIntersectionsDialogBase</receiver> |
|
53 |
<slot>reject()</slot> |
|
54 |
<hints> |
|
55 |
<hint type="sourcelabel" > |
|
56 |
<x>316</x> |
|
57 |
<y>260</y> |
|
58 |
</hint> |
|
59 |
<hint type="destinationlabel" > |
|
60 |
<x>286</x> |
|
61 |
<y>274</y> |
|
62 |
</hint> |
|
63 |
</hints> |
|
64 |
</connection> |
|
65 |
</connections> |
|
66 |
</ui> |
ui/qgssnappingdialogbase.ui (Arbeitskopie) | ||
---|---|---|
22 | 22 |
<property name="rootIsDecorated"> |
23 | 23 |
<bool>false</bool> |
24 | 24 |
</property> |
25 |
<property name="columnCount"> |
|
26 |
<number>6</number> |
|
27 |
</property> |
|
25 | 28 |
<column> |
26 | 29 |
<property name="text"> |
27 | 30 |
<string/> |
... | ... | |
47 | 50 |
<string>Units</string> |
48 | 51 |
</property> |
49 | 52 |
</column> |
53 |
<column> |
|
54 |
<property name="text"> |
|
55 |
<string>Avoid Intersection</string> |
|
56 |
</property> |
|
57 |
</column> |
|
50 | 58 |
</widget> |
51 | 59 |
</item> |
52 | 60 |
<item> |
... | ... | |
64 | 72 |
</property> |
65 | 73 |
</widget> |
66 | 74 |
</item> |
67 |
<item> |
|
68 |
<widget class="QPushButton" name="mAvoidIntersectionsPushButton"> |
|
69 |
<property name="text"> |
|
70 |
<string>Avoid intersections of new polygons...</string> |
|
71 |
</property> |
|
72 |
</widget> |
|
73 |
</item> |
|
74 | 75 |
</layout> |
75 | 76 |
</item> |
76 | 77 |
<item> |