Skip to content

Commit b5bad19

Browse files
author
timlinux
committedFeb 8, 2011
Improvements to spatial select plugin from Luiz Motta (#2634)
git-svn-id: http://svn.osgeo.org/qgis/trunk@15137 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 4c53217 commit b5bad19

File tree

7 files changed

+701
-380
lines changed

7 files changed

+701
-380
lines changed
 

‎src/plugins/spatialquery/qgsspatialquery.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* (at your option) any later version. *
1616
* *
1717
***************************************************************************/
18-
/* $Id$ */
18+
/* $Id: qgsspatialquery.cpp 13447 2010-05-09 00:45:17Z jef $ */
1919

2020
#include <QMessageBox>
2121

@@ -50,7 +50,8 @@ void QgsSpatialQuery::setSelectedFeaturesReference( bool useSelected )
5050

5151
} // void QgsSpatialQuery::setSelectedFeaturesReference(bool useSelected)
5252

53-
void QgsSpatialQuery::runQuery( QSet<int> & qsetIndexResult, int relation, QgsVectorLayer* lyrTarget, QgsVectorLayer* lyrReference )
53+
void QgsSpatialQuery::runQuery( QSet<int> & qsetIndexResult, QSet<int> & qsetIndexInvalidTarget, QSet<int> & qsetIndexInvalidReference,
54+
int relation, QgsVectorLayer* lyrTarget, QgsVectorLayer* lyrReference )
5455
{
5556
setQuery( lyrTarget, lyrReference );
5657

@@ -60,7 +61,7 @@ void QgsSpatialQuery::runQuery( QSet<int> & qsetIndexResult, int relation, QgsVe
6061
? mLayerReference->selectedFeatureCount()
6162
: ( int )( mLayerReference->featureCount() );
6263
mPb->init( 1, totalStep );
63-
setSpatialIndexReference(); // Need set mLayerReference before
64+
setSpatialIndexReference( qsetIndexInvalidReference ); // Need set mLayerReference before
6465

6566
// Make Query
6667
mPb->setFormat( QObject::tr( "Processing 2/2 - %p%" ) );
@@ -69,7 +70,7 @@ void QgsSpatialQuery::runQuery( QSet<int> & qsetIndexResult, int relation, QgsVe
6970
: ( int )( mLayerTarget->featureCount() );
7071
mPb->init( 1, totalStep );
7172

72-
execQuery( qsetIndexResult, relation );
73+
execQuery( qsetIndexResult, qsetIndexInvalidTarget, relation );
7374

7475
} // QSet<int> QgsSpatialQuery::runQuery( int relation)
7576

@@ -190,7 +191,7 @@ bool QgsSpatialQuery::hasValidGeometry( QgsFeature &feature )
190191

191192
} // bool QgsSpatialQuery::hasValidGeometry(QgsFeature &feature)
192193

193-
void QgsSpatialQuery::setSpatialIndexReference()
194+
void QgsSpatialQuery::setSpatialIndexReference( QSet<int> & qsetIndexInvalidReference )
194195
{
195196
QgsReaderFeatures * readerFeaturesReference = new QgsReaderFeatures( mLayerReference, mUseReferenceSelection );
196197
QgsFeature feature;
@@ -201,6 +202,7 @@ void QgsSpatialQuery::setSpatialIndexReference()
201202

202203
if ( ! hasValidGeometry( feature ) )
203204
{
205+
qsetIndexInvalidReference.insert( feature.id() );
204206
continue;
205207
}
206208

@@ -210,7 +212,7 @@ void QgsSpatialQuery::setSpatialIndexReference()
210212

211213
} // void QgsSpatialQuery::setSpatialIndexReference()
212214

213-
void QgsSpatialQuery::execQuery( QSet<int> & qsetIndexResult, int relation )
215+
void QgsSpatialQuery::execQuery( QSet<int> & qsetIndexResult, QSet<int> & qsetIndexInvalidTarget, int relation )
214216
{
215217
bool ( QgsGeometry::* operation )( QgsGeometry * );
216218
switch ( relation )
@@ -263,6 +265,7 @@ void QgsSpatialQuery::execQuery( QSet<int> & qsetIndexResult, int relation )
263265

264266
if ( ! hasValidGeometry( featureTarget ) )
265267
{
268+
qsetIndexInvalidTarget.insert( featureTarget.id() );
266269
continue;
267270
}
268271

‎src/plugins/spatialquery/qgsspatialquery.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* (at your option) any later version. *
1616
* *
1717
***************************************************************************/
18-
/* $Id$ */
18+
/* $Id: qgsspatialquery.h 13380 2010-04-25 12:51:49Z jef $ */
1919
#ifndef SPATIALQUERY_H
2020
#define SPATIALQUERY_H
2121

@@ -82,7 +82,8 @@ class QgsSpatialQuery
8282
* \param lyrTarget Pointer to Target Layer
8383
* \param lyrReference Pointer to Reference Layer
8484
*/
85-
void runQuery( QSet<int> & qsetIndexResult, int relation, QgsVectorLayer* lyrTarget, QgsVectorLayer* lyrReference );
85+
void runQuery( QSet<int> & qsetIndexResult, QSet<int> & qsetIndexInvalidTarget, QSet<int> & qsetIndexInvalidReference,
86+
int relation, QgsVectorLayer* lyrTarget, QgsVectorLayer* lyrReference );
8687

8788
/**
8889
* \brief Gets the possible topologic relations
@@ -117,14 +118,14 @@ class QgsSpatialQuery
117118
/**
118119
* \brief Build the Spatial Index
119120
*/
120-
void setSpatialIndexReference();
121+
void setSpatialIndexReference( QSet<int> & qsetIndexInvalidReference );
121122

122123
/**
123124
* \brief Execute query
124125
* \param qsetIndexResult Reference to QSet contains the result query
125126
* \param relation Enum Topologic Relation
126127
*/
127-
void execQuery( QSet<int> & qsetIndexResult, int relation );
128+
void execQuery( QSet<int> & qsetIndexResult, QSet<int> & qsetIndexInvalidTarget, int relation );
128129

129130
/**
130131
* \brief Populate index Result

‎src/plugins/spatialquery/qgsspatialquerydialog.cpp

Lines changed: 214 additions & 87 deletions
Large diffs are not rendered by default.

‎src/plugins/spatialquery/qgsspatialquerydialog.h

Lines changed: 51 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* (at your option) any later version. *
1616
* *
1717
***************************************************************************/
18-
/* $Id$ */
18+
/* $Id: qgsspatialquerydialog.h 13377 2010-04-25 01:07:36Z jef $ */
1919

2020
#ifndef SPATIALQUERYDIALOG_H
2121
#define SPATIALQUERYDIALOG_H
@@ -26,6 +26,19 @@
2626
#include "qgisinterface.h"
2727
#include "qgsvectorlayer.h"
2828

29+
/**
30+
* \brief Enum with feature listwidget
31+
* \enum Feature_Widget
32+
*
33+
*/
34+
enum Feature_Widget
35+
{
36+
FW_Result,
37+
FW_InvalidTarget,
38+
FW_InvalidRefence
39+
};
40+
41+
2942
/**
3043
* \class QgsSpatialQueryDialog
3144
* \brief Spatial Query dialog
@@ -50,14 +63,25 @@ class QgsSpatialQueryDialog : public QDialog, private Ui::QgsSpatialQueryDialogB
5063
//! Unload plugins by QGIS - Disconnect signal from QGIS
5164
void disconnectQGis();
5265

66+
//! Override show for ajust size
67+
void show();
68+
5369
private slots:
5470
//! Slots for signs of Dialog
55-
void on_buttonBox_accepted();
56-
void on_buttonBox_rejected();
71+
void on_buttonBoxMain_accepted();
72+
void on_buttonBoxMain_rejected();
5773
void on_targetLayerComboBox_currentIndexChanged( int index );
5874
void on_referenceLayerComboBox_currentIndexChanged( int index );
59-
void on_selectedFeatureListWidget_currentTextChanged( const QString& currentText );
60-
void on_showLogProcessingCheckBox_clicked( bool checked );
75+
void on_resultFeatureTargetListWidget_itemClicked( QListWidgetItem * item );
76+
void on_resultFeatureTargetListWidget_currentItemChanged( QListWidgetItem * item );
77+
void on_invalidFeatureTargetListWidget_itemClicked( QListWidgetItem * item );
78+
void on_invalidFeatureTargetListWidget_currentItemChanged( QListWidgetItem * item );
79+
void on_invalidFeatureReferenceListWidget_itemClicked( QListWidgetItem * item );
80+
void on_invalidFeatureReferenceListWidget_currentItemChanged( QListWidgetItem * item );
81+
void on_ckboxLogProcessing_clicked( bool checked );
82+
void on_pushButtonSelectResultTarget_clicked();
83+
void on_pushButtonSelectInvalidTarget_clicked();
84+
void on_pushButtonSelectInvalidReference_clicked();
6185

6286
//! Slots for signs of QGIS
6387
void signal_qgis_layerWasAdded( QgsMapLayer* mapLayer );
@@ -70,8 +94,8 @@ class QgsSpatialQueryDialog : public QDialog, private Ui::QgsSpatialQueryDialogB
7094
private:
7195
//! Initialize the Gui
7296
void initGui();
73-
//! Set Color mRubberSelectId
74-
void setColorRubberSelectId();
97+
//! Set Color RGB for select - mRGBRubberSelect
98+
void setColorRubberSelect();
7599
//! Set Layer (Target or Reference)
76100
void setLayer( bool isTarget, int index );
77101
//! Evaluate status of selected features from layer (Target or Reference)
@@ -106,8 +130,14 @@ class QgsSpatialQueryDialog : public QDialog, private Ui::QgsSpatialQueryDialogB
106130
void populateReferenceLayerComboBox();
107131
//! Populates operationComboBox with the topological operations
108132
void populateOperationComboBox();
109-
//! Populates the result of Spatial Query (selectedFeatureListWidget and labels)
110-
void populateQueryResult();
133+
//! Populates the features in QListWidget (use by result, invalid target and reference)
134+
void populateFeatureListWidget( QListWidget *listWidget, QSet<int> & setFeatures, bool hasSetRow = true );
135+
//! Clear the features of QListWidget (use by result, invalid target and reference)
136+
void clearFeatureListWidget( QListWidget *listWidget );
137+
//! Make action when change item in ListWidget
138+
void changeFeatureListWidget( QListWidget *listWidget, QgsVectorLayer* vectorLayer, const QString& currentText );
139+
//! Show rubber from feature
140+
void showRubberFeature( QgsVectorLayer* vectorLayer, int id );
111141

112142
//! Pointer to Interface QGIS
113143
QgisInterface* mIface;
@@ -117,18 +147,28 @@ class QgsSpatialQueryDialog : public QDialog, private Ui::QgsSpatialQueryDialogB
117147
QgsVectorLayer* mLayerReference;
118148
//! Stores ID's from spatial query
119149
QSet<int> mFeatureResult;
150+
//! Stores ID's invalid of target layer
151+
QSet<int> mFeatureInvalidTarget;
152+
//! Stores ID's invalid of reference layer
153+
QSet<int> mFeatureInvalidReference;
120154
//! Map for Id name of vector layers (use in signal_qgis_layerWillBeRemoved)
121155
QMap<QString, QgsVectorLayer *> mMapIdVectorLayers;
122156
//! Rubber band for features result
123157
QgsRubberSelectId* mRubberSelectId;
158+
//! RGB select feature result
159+
int mRGBRubberSelect[3];
160+
//! Current Feature Widget
161+
Feature_Widget mCurrentFeatureWidget;
124162

125163
// Message
126164
QString mMsgLayersLessTwo;
127165

128166
void MsgDEBUG( QString sMSg );
129167

130-
//! show/hide target, reference and operation group box
131-
void setInputsVisible( bool show );
168+
//! show/hide operation inputs: target, reference and operation group box
169+
void setLayoutOperationVisible( bool show );
170+
//! show/hide result of operation: result and invalid group box
171+
void setLayoutResultInvalid( bool show );
132172
};
133173

134174
#endif // SPATIALQUERYDIALOG_H
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<RCC>
2-
<qresource prefix="/icons" >
2+
<qresource prefix="/icons">
33
<file>spatialquery.png</file>
4+
<file>selectall.png</file>
45
</qresource>
56
</RCC>

‎src/plugins/spatialquery/qgsspatialquerydialogbase.ui

Lines changed: 420 additions & 271 deletions
Large diffs are not rendered by default.
595 Bytes
Loading

0 commit comments

Comments
 (0)
Please sign in to comment.