-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE]: Avoid intersections for polygons is now also possible to b…
…ackground layers git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@11839 c8812cc2-4d05-0410-92ff-de0c093fc19c
- Loading branch information
mhugent
committed
Oct 25, 2009
1 parent
cfa84cd
commit 393570b
Showing
9 changed files
with
274 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#include "qgsavoidintersectionsdialog.h" | ||
#include "qgsmapcanvas.h" | ||
#include "qgsvectorlayer.h" | ||
|
||
QgsAvoidIntersectionsDialog::QgsAvoidIntersectionsDialog( QgsMapCanvas* canvas, const QSet<QString>& enabledLayers, QWidget * parent, Qt::WindowFlags f ): \ | ||
QDialog( parent, f ), mMapCanvas( canvas ) | ||
{ | ||
setupUi( this ); | ||
|
||
int nLayers = mMapCanvas->layerCount(); | ||
QgsVectorLayer* currentLayer = 0; | ||
QListWidgetItem* newItem = 0; | ||
|
||
for ( int i = 0; i < nLayers; ++i ) | ||
{ | ||
currentLayer = dynamic_cast<QgsVectorLayer*>( mMapCanvas->layer( i ) ); | ||
if ( currentLayer ) | ||
{ | ||
//only consider polygon or multipolygon layers | ||
if ( currentLayer->geometryType() == QGis::Polygon ) | ||
{ | ||
newItem = new QListWidgetItem( mLayersListWidget ); | ||
newItem->setText( currentLayer->name() ); | ||
newItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsUserCheckable ); | ||
newItem->setData( Qt::UserRole, currentLayer->getLayerID() ); | ||
if ( enabledLayers.contains( currentLayer->getLayerID() ) ) | ||
{ | ||
newItem->setCheckState( Qt::Checked ); | ||
} | ||
else | ||
{ | ||
newItem->setCheckState( Qt::Unchecked ); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
QgsAvoidIntersectionsDialog::~QgsAvoidIntersectionsDialog() | ||
{ | ||
|
||
} | ||
|
||
void QgsAvoidIntersectionsDialog::enabledLayers( QSet<QString>& enabledLayers ) | ||
{ | ||
enabledLayers.clear(); | ||
|
||
int itemCount = mLayersListWidget->count(); | ||
QListWidgetItem* currentItem = 0; | ||
|
||
for ( int i = 0; i < itemCount; ++i ) | ||
{ | ||
currentItem = mLayersListWidget->item( i ); | ||
if ( currentItem->checkState() == Qt::Checked ) | ||
{ | ||
enabledLayers.insert( currentItem->data( Qt::UserRole ).toString() ); | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#ifndef QGSAVOIDINTERSECTIONSDIALOG_H | ||
#define QGSAVOIDINTERSECTIONSDIALOG_H | ||
|
||
#include "ui_qgsavoidintersectionsdialogbase.h" | ||
|
||
class QgsMapCanvas; | ||
|
||
class QgsAvoidIntersectionsDialog: public QDialog, private Ui::QgsAvoidIntersectionsDialogBase | ||
{ | ||
Q_OBJECT | ||
public: | ||
QgsAvoidIntersectionsDialog( QgsMapCanvas* canvas, const QSet<QString>& enabledLayers, QWidget * parent = 0, Qt::WindowFlags f = 0 ); | ||
~QgsAvoidIntersectionsDialog(); | ||
/**Returns ids of layers that are considered for the avoid intersection function*/ | ||
void enabledLayers( QSet<QString>& enabledLayers ); | ||
|
||
private: | ||
QgsMapCanvas* mMapCanvas; | ||
}; | ||
|
||
#endif // QGSAVOIDINTERSECTIONSDIALOG_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<ui version="4.0" > | ||
<class>QgsAvoidIntersectionsDialogBase</class> | ||
<widget class="QDialog" name="QgsAvoidIntersectionsDialogBase" > | ||
<property name="geometry" > | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>365</width> | ||
<height>300</height> | ||
</rect> | ||
</property> | ||
<property name="windowTitle" > | ||
<string>Dialog</string> | ||
</property> | ||
<layout class="QGridLayout" name="gridLayout" > | ||
<item row="0" column="0" > | ||
<widget class="QListWidget" name="mLayersListWidget" /> | ||
</item> | ||
<item row="1" column="0" > | ||
<widget class="QDialogButtonBox" name="mButtonBox" > | ||
<property name="orientation" > | ||
<enum>Qt::Horizontal</enum> | ||
</property> | ||
<property name="standardButtons" > | ||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> | ||
</property> | ||
</widget> | ||
</item> | ||
</layout> | ||
</widget> | ||
<resources/> | ||
<connections> | ||
<connection> | ||
<sender>mButtonBox</sender> | ||
<signal>accepted()</signal> | ||
<receiver>QgsAvoidIntersectionsDialogBase</receiver> | ||
<slot>accept()</slot> | ||
<hints> | ||
<hint type="sourcelabel" > | ||
<x>248</x> | ||
<y>254</y> | ||
</hint> | ||
<hint type="destinationlabel" > | ||
<x>157</x> | ||
<y>274</y> | ||
</hint> | ||
</hints> | ||
</connection> | ||
<connection> | ||
<sender>mButtonBox</sender> | ||
<signal>rejected()</signal> | ||
<receiver>QgsAvoidIntersectionsDialogBase</receiver> | ||
<slot>reject()</slot> | ||
<hints> | ||
<hint type="sourcelabel" > | ||
<x>316</x> | ||
<y>260</y> | ||
</hint> | ||
<hint type="destinationlabel" > | ||
<x>286</x> | ||
<y>274</y> | ||
</hint> | ||
</hints> | ||
</connection> | ||
</connections> | ||
</ui> |
Oops, something went wrong.