mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-16 00:05:45 -04:00
spatial query plugin: fix warnings, reindent, include in debian package
git-svn-id: http://svn.osgeo.org/qgis/trunk@13360 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
e0ec67b2fe
commit
3d2b177143
3
debian/changelog
vendored
3
debian/changelog
vendored
@ -5,8 +5,9 @@ qgis (1.5.0) UNRELEASED; urgency=low
|
||||
* require CMake >2.6 and Qt 4.4 for sid
|
||||
* remove circular dependencies
|
||||
* integrate new GRASS raster provider
|
||||
* add spatialquery plugin
|
||||
|
||||
-- Jürgen E. Fischer <jef@norbit.de> Thu, 04 Feb 2010 23:20:29 +0100
|
||||
-- Jürgen E. Fischer <jef@norbit.de> Sat, 24 Apr 2010 10:57:21 +0200
|
||||
|
||||
qgis (1.4.0) UNRELEASED; urgency=low
|
||||
|
||||
|
1
debian/qgis.install
vendored
1
debian/qgis.install
vendored
@ -26,6 +26,7 @@ usr/lib/qgis/libevis.so
|
||||
usr/lib/qgis/libosmprovider.so
|
||||
usr/lib/qgis/librasterterrainplugin.so
|
||||
usr/lib/qgis/liblabelingplugin.so
|
||||
usr/lib/qgis/libspatialqueryplugin.so
|
||||
usr/share/pixmaps/qgis-icon.xpm
|
||||
usr/share/pixmaps/qgis-mime-icon.png
|
||||
usr/share/pixmaps/qgis-mime-icon.png usr/share/icons/crystalsvg/128x128/mimetypes
|
||||
|
2
debian/rules
vendored
2
debian/rules
vendored
@ -10,7 +10,7 @@ DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
|
||||
DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
|
||||
|
||||
DISTRIBUTION := $(shell dpkg-parsechangelog --format rfc822 | sed -ne "s/^Distribution: //p")
|
||||
ifneq ($(DISTRIBUTION),$(findstring $(DISTRIBUTION),"lenny hardy intrepid jaunty karmic"))
|
||||
ifneq ($(DISTRIBUTION),$(findstring $(DISTRIBUTION),"lenny hardy intrepid jaunty karmic lucid"))
|
||||
DISTRIBUTION := sid
|
||||
endif
|
||||
|
||||
|
@ -14,11 +14,6 @@ SET (SPATIALQUERY_SRCS
|
||||
SET (SPATIALQUERY_MOC_HDRS
|
||||
qgsspatialqueryplugin.h
|
||||
qgsspatialquerydialog.h
|
||||
qgsspatialquery.h
|
||||
qgsreaderfeatures.h
|
||||
qgsrubberselectid.h
|
||||
qgsgeometrycoordinatetransform.h
|
||||
qgsmngprogressbar.h
|
||||
)
|
||||
|
||||
SET( SPATIALQUERY_UIS qgsspatialquerydialogbase.ui)
|
||||
|
@ -27,29 +27,29 @@ QgsGeometryCoordinateTransform::~QgsGeometryCoordinateTransform()
|
||||
|
||||
} // QgsGeometryCoordinateTransform::~QgsGeometryCoordinateTransform()
|
||||
|
||||
void QgsGeometryCoordinateTransform::setCoordinateTransform(QgsVectorLayer* lyrTarget, QgsVectorLayer* lyrReference)
|
||||
void QgsGeometryCoordinateTransform::setCoordinateTransform( QgsVectorLayer* lyrTarget, QgsVectorLayer* lyrReference )
|
||||
{
|
||||
// Transform Forward: Target to Reference
|
||||
// * Use srs() to use old versions QGis - will be deprecited in 2.0 (after use crs())
|
||||
QgsCoordinateReferenceSystem srsTarget = lyrTarget->srs();
|
||||
QgsCoordinateReferenceSystem srsReference = lyrReference->srs();
|
||||
|
||||
mCoordTransform = new QgsCoordinateTransform(srsTarget, srsReference);
|
||||
mCoordTransform = new QgsCoordinateTransform( srsTarget, srsReference );
|
||||
|
||||
mFuncTransform = ( srsTarget != srsReference)
|
||||
mFuncTransform = ( srsTarget != srsReference )
|
||||
? &QgsGeometryCoordinateTransform::setGeomTransform
|
||||
: &QgsGeometryCoordinateTransform::setNoneGeomTransform;
|
||||
|
||||
} // void QgsGeometryCoordinateTransform::setCoordinateTransform(QgsVectorLayer* lyrTarget, QgsVectorLayer* lyrReference)
|
||||
|
||||
void QgsGeometryCoordinateTransform::transform(QgsGeometry *geom)
|
||||
void QgsGeometryCoordinateTransform::transform( QgsGeometry *geom )
|
||||
{
|
||||
(this->*mFuncTransform)(geom);
|
||||
( this->*mFuncTransform )( geom );
|
||||
|
||||
} // void QgsGeometryCoordinateTransform::transformCoordenate()
|
||||
|
||||
void QgsGeometryCoordinateTransform::setGeomTransform(QgsGeometry *geom)
|
||||
void QgsGeometryCoordinateTransform::setGeomTransform( QgsGeometry *geom )
|
||||
{
|
||||
geom->transform(*mCoordTransform);
|
||||
geom->transform( *mCoordTransform );
|
||||
|
||||
} // void QgsGeometryCoordinateTransform::setGeomTransform(QgsGeometry *geom)
|
||||
|
@ -29,44 +29,44 @@
|
||||
*/
|
||||
class QgsGeometryCoordinateTransform
|
||||
{
|
||||
public:
|
||||
public:
|
||||
/**
|
||||
* \brief Constructor for a Geometry Coordinate Transform.
|
||||
*
|
||||
*/
|
||||
QgsGeometryCoordinateTransform () {};
|
||||
QgsGeometryCoordinateTransform() {};
|
||||
|
||||
/**
|
||||
* \brief Destructor
|
||||
*/
|
||||
~QgsGeometryCoordinateTransform ();
|
||||
~QgsGeometryCoordinateTransform();
|
||||
|
||||
/**
|
||||
* \brief Sets the coordinate reference system the target and reference layer
|
||||
* \param lyrTarget target layer.
|
||||
* \param lyrReference reference layer.
|
||||
*/
|
||||
void setCoordinateTransform(QgsVectorLayer* lyrTarget, QgsVectorLayer* lyrReference);
|
||||
void setCoordinateTransform( QgsVectorLayer* lyrTarget, QgsVectorLayer* lyrReference );
|
||||
|
||||
/**
|
||||
* \brief Transform the coordinates reference system of the geometry, if target have the different system of reference
|
||||
* \param geom Geometry
|
||||
*/
|
||||
void transform(QgsGeometry *geom);
|
||||
private:
|
||||
void transform( QgsGeometry *geom );
|
||||
private:
|
||||
/**
|
||||
* \brief Transform the coordinates reference system of the geometry (use by transform)
|
||||
* \param geom Geometry
|
||||
*/
|
||||
void setGeomTransform(QgsGeometry *geom);
|
||||
void setGeomTransform( QgsGeometry *geom );
|
||||
/**
|
||||
* \brief None transform the coordinates reference system of the geometry (use by transform)
|
||||
* \param geom Geometry
|
||||
*/
|
||||
void setNoneGeomTransform(QgsGeometry *geom) {};
|
||||
void setNoneGeomTransform( QgsGeometry *geom ) {};
|
||||
|
||||
QgsCoordinateTransform * mCoordTransform;
|
||||
void (QgsGeometryCoordinateTransform::* mFuncTransform)(QgsGeometry *);
|
||||
void ( QgsGeometryCoordinateTransform::* mFuncTransform )( QgsGeometry * );
|
||||
};
|
||||
|
||||
#endif // GEOMETRYCOORDINATETRANSFORM_H
|
||||
|
@ -19,32 +19,32 @@
|
||||
|
||||
#include "qgsmngprogressbar.h"
|
||||
|
||||
MngProgressBar::MngProgressBar(QProgressBar *pb)
|
||||
MngProgressBar::MngProgressBar( QProgressBar *pb )
|
||||
{
|
||||
mPb = pb;
|
||||
mPb->reset();
|
||||
} // MngProgressBar::MngProgressBar(QProgressBar *pb)
|
||||
|
||||
void MngProgressBar::init(int minimum, int maximum)
|
||||
void MngProgressBar::init( int minimum, int maximum )
|
||||
{
|
||||
mPb->reset();
|
||||
mPb->setRange(minimum, maximum);
|
||||
mPb->setRange( minimum, maximum );
|
||||
|
||||
} // void MngProgressBar::init(int minimum, int maximum)
|
||||
|
||||
void MngProgressBar::setFormat(QString format)
|
||||
void MngProgressBar::setFormat( QString format )
|
||||
{
|
||||
// special caracters:
|
||||
// %p - is replaced by the percentage completed.
|
||||
// %v - is replaced by the current value.
|
||||
// %m - is replaced by the total number of steps.
|
||||
mPb->setFormat(format);
|
||||
mPb->setFormat( format );
|
||||
|
||||
} // void MngProgressBar::setFormat(QString format)
|
||||
|
||||
void MngProgressBar::step(int step)
|
||||
void MngProgressBar::step( int step )
|
||||
{
|
||||
mPb->setValue(step);
|
||||
mPb->setValue( step );
|
||||
mPb->repaint();
|
||||
|
||||
} // void MngProgressBar::step()
|
||||
|
@ -27,12 +27,12 @@
|
||||
*/
|
||||
class MngProgressBar
|
||||
{
|
||||
public:
|
||||
public:
|
||||
/**
|
||||
* \brief Constructor for a MngProgressBar.
|
||||
* \param pb Pointer to the MngProgressBar object.
|
||||
*/
|
||||
MngProgressBar(QProgressBar *pb);
|
||||
MngProgressBar( QProgressBar *pb );
|
||||
/**
|
||||
* \brief Destructor
|
||||
*/
|
||||
@ -43,21 +43,21 @@ public:
|
||||
* \param minimum minimun value.
|
||||
* \param maximum maximum value.
|
||||
*/
|
||||
void init(int minimum, int maximum);
|
||||
void init( int minimum, int maximum );
|
||||
|
||||
/**
|
||||
* \brief Sets the format the current text.
|
||||
* \param format This property holds the string used to generate the current text.
|
||||
*/
|
||||
void setFormat(QString format);
|
||||
void setFormat( QString format );
|
||||
|
||||
/**
|
||||
* \brief Sets current value progress bar's
|
||||
* \param step current value
|
||||
*/
|
||||
void step(int step );
|
||||
void step( int step );
|
||||
|
||||
private:
|
||||
private:
|
||||
QProgressBar * mPb;
|
||||
|
||||
};
|
||||
|
@ -21,11 +21,11 @@
|
||||
|
||||
#include "qgsreaderfeatures.h"
|
||||
|
||||
QgsReaderFeatures::QgsReaderFeatures(QgsVectorLayer *layer, bool useSelection)
|
||||
QgsReaderFeatures::QgsReaderFeatures( QgsVectorLayer *layer, bool useSelection )
|
||||
{
|
||||
mLayer = layer;
|
||||
|
||||
initReader(useSelection);
|
||||
initReader( useSelection );
|
||||
|
||||
} // QgsReaderFeatures::QgsReaderFeatures(QgsVectorLayer *layer, bool useSelection)
|
||||
|
||||
@ -38,13 +38,13 @@ QgsReaderFeatures::~QgsReaderFeatures()
|
||||
|
||||
} // QgsReaderFeatures::~QgsReaderFeatures()
|
||||
|
||||
bool QgsReaderFeatures::nextFeature(QgsFeature & feature)
|
||||
bool QgsReaderFeatures::nextFeature( QgsFeature & feature )
|
||||
{
|
||||
return (this->*mFuncNextFeature)(feature);
|
||||
return ( this->*mFuncNextFeature )( feature );
|
||||
|
||||
} // bool QgsReaderFeatures::nextFeature(QgsFeature & feature)
|
||||
|
||||
void QgsReaderFeatures::initReader(bool useSelection)
|
||||
void QgsReaderFeatures::initReader( bool useSelection )
|
||||
{
|
||||
if ( useSelection )
|
||||
{
|
||||
@ -56,20 +56,20 @@ void QgsReaderFeatures::initReader(bool useSelection)
|
||||
{
|
||||
QgsAttributeList attListGeom;
|
||||
int idGeom = 0;
|
||||
attListGeom.append(idGeom);
|
||||
mLayer->select(attListGeom, mLayer->extent(), true, false);
|
||||
attListGeom.append( idGeom );
|
||||
mLayer->select( attListGeom, mLayer->extent(), true, false );
|
||||
mFuncNextFeature = &QgsReaderFeatures::nextFeatureTotal;
|
||||
}
|
||||
|
||||
} // void QgsReaderFeatures::initReader()
|
||||
|
||||
bool QgsReaderFeatures::nextFeatureTotal ( QgsFeature & feature )
|
||||
bool QgsReaderFeatures::nextFeatureTotal( QgsFeature & feature )
|
||||
{
|
||||
return mLayer->dataProvider()->nextFeature(feature);
|
||||
return mLayer->dataProvider()->nextFeature( feature );
|
||||
|
||||
} // bool QgsReaderFeatures::nextFeatureTotal ( QgsFeature & feature )
|
||||
|
||||
bool QgsReaderFeatures::nextFeatureSelected ( QgsFeature & feature )
|
||||
bool QgsReaderFeatures::nextFeatureSelected( QgsFeature & feature )
|
||||
{
|
||||
bool bReturn = true;
|
||||
if ( mIterSelectedFeature == mListSelectedFeature.end() )
|
||||
|
@ -28,13 +28,13 @@
|
||||
*/
|
||||
class QgsReaderFeatures
|
||||
{
|
||||
public:
|
||||
public:
|
||||
/**
|
||||
* \brief Constructor for a Reader Features.
|
||||
* \param layer Pointer to the layer.
|
||||
* \param useSelection Use or not use the features selected
|
||||
*/
|
||||
QgsReaderFeatures(QgsVectorLayer *layer, bool useSelection);
|
||||
QgsReaderFeatures( QgsVectorLayer *layer, bool useSelection );
|
||||
|
||||
/**
|
||||
* \brief Destructor
|
||||
@ -46,33 +46,33 @@ public:
|
||||
* \param feature reference to next Feature.
|
||||
* \returns True if has next feature.
|
||||
*/
|
||||
bool nextFeature(QgsFeature & feature);
|
||||
bool nextFeature( QgsFeature & feature );
|
||||
|
||||
private:
|
||||
private:
|
||||
/**
|
||||
* \brief init Reader
|
||||
* \param useSelection Use or not use the features selected
|
||||
*/
|
||||
void initReader(bool useSelection);
|
||||
void initReader( bool useSelection );
|
||||
|
||||
/**
|
||||
* \brief Next feature, not using the features selected
|
||||
* \param feature reference to next Feature.
|
||||
* \returns True if has next feature.
|
||||
*/
|
||||
bool nextFeatureTotal(QgsFeature & feature);
|
||||
bool nextFeatureTotal( QgsFeature & feature );
|
||||
|
||||
/**
|
||||
* \brief Next feature, using the features selected
|
||||
* \param feature reference to next Feature.
|
||||
* \returns True if has next feature.
|
||||
*/
|
||||
bool nextFeatureSelected(QgsFeature & feature);
|
||||
bool nextFeatureSelected( QgsFeature & feature );
|
||||
|
||||
QgsVectorLayer * mLayer;
|
||||
QgsFeatureList mListSelectedFeature;
|
||||
QList<QgsFeature>::iterator mIterSelectedFeature;
|
||||
bool (QgsReaderFeatures::* mFuncNextFeature) ( QgsFeature &);
|
||||
bool ( QgsReaderFeatures::* mFuncNextFeature )( QgsFeature & );
|
||||
};
|
||||
|
||||
#endif // READERFEATURES_H
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
#include "qgsfeature.h"
|
||||
|
||||
QgsRubberSelectId::QgsRubberSelectId( QgsMapCanvas* mapCanvas)
|
||||
QgsRubberSelectId::QgsRubberSelectId( QgsMapCanvas* mapCanvas )
|
||||
{
|
||||
mIsPolygon = true;
|
||||
mMapCanvas = mapCanvas;
|
||||
@ -37,7 +37,7 @@ QgsRubberSelectId::~QgsRubberSelectId()
|
||||
|
||||
} // QgsRubberSelectId::~QgsRubberSelectId()
|
||||
|
||||
void QgsRubberSelectId::isGeometryNotPolygon(bool isPolygon = false)
|
||||
void QgsRubberSelectId::isGeometryNotPolygon( bool isPolygon = false )
|
||||
{
|
||||
reset();
|
||||
delete mRubberBand;
|
||||
@ -52,7 +52,7 @@ void QgsRubberSelectId::reset()
|
||||
|
||||
} // void QgsRubberSelectId::reset()
|
||||
|
||||
void QgsRubberSelectId::setColor(int colorRed, int colorGreen, int colorBlue, int width, float alfa = 0)
|
||||
void QgsRubberSelectId::setColor( int colorRed, int colorGreen, int colorBlue, int width, float alfa = 0 )
|
||||
{
|
||||
QColor color = QColor( colorRed, colorGreen, colorBlue );
|
||||
color.setAlpha( alfa );
|
||||
|
@ -30,12 +30,12 @@
|
||||
*/
|
||||
class QgsRubberSelectId
|
||||
{
|
||||
public:
|
||||
public:
|
||||
/**
|
||||
* Constructor for a class RubberSelectedId.
|
||||
* @param mapCanvas Pointer to the iface.mapCanvas().
|
||||
*/
|
||||
QgsRubberSelectId( QgsMapCanvas* mapCanvas);
|
||||
QgsRubberSelectId( QgsMapCanvas* mapCanvas );
|
||||
/**
|
||||
* \brief Destructor
|
||||
*/
|
||||
@ -45,7 +45,7 @@ public:
|
||||
* \brief Set if is geometry polygon for rubber band
|
||||
* \param isPolygon boolean for type geometry is polygon
|
||||
*/
|
||||
void isGeometryNotPolygon(bool isPolygon);
|
||||
void isGeometryNotPolygon( bool isPolygon );
|
||||
|
||||
/**
|
||||
* \brief Reset rubber band
|
||||
@ -72,7 +72,7 @@ public:
|
||||
* \brief Show rubber band
|
||||
*/
|
||||
void show();
|
||||
private:
|
||||
private:
|
||||
//! RubberBand
|
||||
QgsRubberBand* mRubberBand;
|
||||
bool mIsPolygon;
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include "qgsgeometrycoordinatetransform.h"
|
||||
#include "qgsspatialquery.h"
|
||||
|
||||
QgsSpatialQuery::QgsSpatialQuery(MngProgressBar *pb)
|
||||
QgsSpatialQuery::QgsSpatialQuery( MngProgressBar *pb )
|
||||
{
|
||||
mPb = pb;
|
||||
mUseTargetSelection = mUseReferenceSelection = false;
|
||||
@ -38,13 +38,13 @@ QgsSpatialQuery::~QgsSpatialQuery()
|
||||
|
||||
} // QgsSpatialQuery::~QgsSpatialQuery()
|
||||
|
||||
void QgsSpatialQuery::setSelectedFeaturesTarget(bool useSelected)
|
||||
void QgsSpatialQuery::setSelectedFeaturesTarget( bool useSelected )
|
||||
{
|
||||
mUseTargetSelection = useSelected;
|
||||
|
||||
} // void QgsSpatialQuery::setSelectedFeaturesTarget(bool useSelected)
|
||||
|
||||
void QgsSpatialQuery::setSelectedFeaturesReference(bool useSelected)
|
||||
void QgsSpatialQuery::setSelectedFeaturesReference( bool useSelected )
|
||||
{
|
||||
mUseReferenceSelection = useSelected;
|
||||
|
||||
@ -52,28 +52,28 @@ void QgsSpatialQuery::setSelectedFeaturesReference(bool useSelected)
|
||||
|
||||
void QgsSpatialQuery::runQuery( QSet<int> & qsetIndexResult, int relation, QgsVectorLayer* lyrTarget, QgsVectorLayer* lyrReference )
|
||||
{
|
||||
setQuery(lyrTarget, lyrReference);
|
||||
setQuery( lyrTarget, lyrReference );
|
||||
|
||||
// Create Spatial index for Reference - Set mIndexReference
|
||||
mPb->setFormat("Processing 1/2 - %p%");
|
||||
mPb->setFormat( "Processing 1/2 - %p%" );
|
||||
int totalStep = mUseReferenceSelection
|
||||
? mLayerReference->selectedFeatureCount()
|
||||
: (int) (mLayerReference->featureCount());
|
||||
mPb->init(1, totalStep);
|
||||
: ( int )( mLayerReference->featureCount() );
|
||||
mPb->init( 1, totalStep );
|
||||
setSpatialIndexReference(); // Need set mLayerReference before
|
||||
|
||||
// Make Query
|
||||
mPb->setFormat("Processing 2/2 - %p%");
|
||||
mPb->setFormat( "Processing 2/2 - %p%" );
|
||||
totalStep = mUseTargetSelection
|
||||
? mLayerTarget->selectedFeatureCount()
|
||||
: (int) (mLayerTarget->featureCount());
|
||||
mPb->init(1, totalStep);
|
||||
: ( int )( mLayerTarget->featureCount() );
|
||||
mPb->init( 1, totalStep );
|
||||
|
||||
execQuery(qsetIndexResult, relation);
|
||||
execQuery( qsetIndexResult, relation );
|
||||
|
||||
} // QSet<int> QgsSpatialQuery::runQuery( int relation)
|
||||
|
||||
QMap<QString, int>* QgsSpatialQuery::getTypesOperations(QgsVectorLayer* lyrTarget, QgsVectorLayer* lyrReference)
|
||||
QMap<QString, int>* QgsSpatialQuery::getTypesOperations( QgsVectorLayer* lyrTarget, QgsVectorLayer* lyrReference )
|
||||
{
|
||||
/* Relations from OGC document (obtain in February 2010)
|
||||
06-103r3_Candidate_Implementation_Specification_for_Geographic_Information_-_Simple_feature_access_-_Part_1_Common_Architecture_v1.2.0.pdf
|
||||
@ -98,49 +98,49 @@ QMap<QString, int>* QgsSpatialQuery::getTypesOperations(QgsVectorLayer* lyrTarge
|
||||
*/
|
||||
|
||||
QMap<QString, int> * operations = new QMap<QString, int>;
|
||||
operations->insert(QObject::tr("Intersects"), Intersects);
|
||||
operations->insert(QObject::tr("Disjoint"), Disjoint);
|
||||
operations->insert( QObject::tr( "Intersects" ), Intersects );
|
||||
operations->insert( QObject::tr( "Disjoint" ), Disjoint );
|
||||
|
||||
short int dimTarget=0, dimReference=0;
|
||||
dimTarget = dimensionGeometry(lyrTarget->geometryType());
|
||||
dimReference = dimensionGeometry(lyrReference->geometryType());
|
||||
short int dimTarget = 0, dimReference = 0;
|
||||
dimTarget = dimensionGeometry( lyrTarget->geometryType() );
|
||||
dimReference = dimensionGeometry( lyrReference->geometryType() );
|
||||
|
||||
if (dimReference > dimTarget)
|
||||
if ( dimReference > dimTarget )
|
||||
{
|
||||
operations->insert(QObject::tr("Touches"), Touches);
|
||||
operations->insert(QObject::tr("Crosses"), Crosses);
|
||||
operations->insert(QObject::tr("Within"), Within);
|
||||
operations->insert( QObject::tr( "Touches" ), Touches );
|
||||
operations->insert( QObject::tr( "Crosses" ), Crosses );
|
||||
operations->insert( QObject::tr( "Within" ), Within );
|
||||
}
|
||||
else if (dimReference < dimTarget)
|
||||
else if ( dimReference < dimTarget )
|
||||
{
|
||||
operations->insert(QObject::tr("Contains"), Contains);
|
||||
operations->insert( QObject::tr( "Contains" ), Contains );
|
||||
}
|
||||
else // dimReference == dimTarget
|
||||
{
|
||||
operations->insert(QObject::tr("Equals"), Equals);
|
||||
operations->insert(QObject::tr("Overlaps"), Overlaps);
|
||||
switch (dimReference)
|
||||
operations->insert( QObject::tr( "Equals" ), Equals );
|
||||
operations->insert( QObject::tr( "Overlaps" ), Overlaps );
|
||||
switch ( dimReference )
|
||||
{
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
operations->insert(QObject::tr("Touches"), Touches);
|
||||
operations->insert(QObject::tr("Crosses"), Crosses);
|
||||
operations->insert( QObject::tr( "Touches" ), Touches );
|
||||
operations->insert( QObject::tr( "Crosses" ), Crosses );
|
||||
break;
|
||||
case 2:
|
||||
operations->insert(QObject::tr("Touches"), Touches);
|
||||
operations->insert(QObject::tr("Within"), Within);
|
||||
operations->insert(QObject::tr("Contains"), Contains);
|
||||
operations->insert( QObject::tr( "Touches" ), Touches );
|
||||
operations->insert( QObject::tr( "Within" ), Within );
|
||||
operations->insert( QObject::tr( "Contains" ), Contains );
|
||||
}
|
||||
}
|
||||
return operations;
|
||||
|
||||
} // QMap<QString, int>* QgsSpatialQuery::getTypesOperators(QgsVectorLayer* lyrTarget, QgsVectorLayer* lyrReference)
|
||||
|
||||
short int QgsSpatialQuery::dimensionGeometry(QGis::GeometryType geomType)
|
||||
short int QgsSpatialQuery::dimensionGeometry( QGis::GeometryType geomType )
|
||||
{
|
||||
int dimGeom = 0;
|
||||
switch (geomType)
|
||||
switch ( geomType )
|
||||
{
|
||||
case QGis::Point:
|
||||
dimGeom = 0;
|
||||
@ -150,20 +150,23 @@ short int QgsSpatialQuery::dimensionGeometry(QGis::GeometryType geomType)
|
||||
break;
|
||||
case QGis::Polygon:
|
||||
dimGeom = 2;
|
||||
default:
|
||||
Q_ASSERT( 0 );
|
||||
dimGeom = 0;
|
||||
}
|
||||
return dimGeom;
|
||||
|
||||
} // int QgsSpatialQuery::dimensionGeometry(QGis::GeometryType geomType)
|
||||
|
||||
void QgsSpatialQuery::setQuery (QgsVectorLayer *layerTarget, QgsVectorLayer *layerReference)
|
||||
void QgsSpatialQuery::setQuery( QgsVectorLayer *layerTarget, QgsVectorLayer *layerReference )
|
||||
{
|
||||
mLayerTarget = layerTarget;
|
||||
mReaderFeaturesTarget = new QgsReaderFeatures(mLayerTarget, mUseTargetSelection);
|
||||
mReaderFeaturesTarget = new QgsReaderFeatures( mLayerTarget, mUseTargetSelection );
|
||||
mLayerReference = layerReference;
|
||||
|
||||
} // void QgsSpatialQuery::setQuery (QgsVectorLayer *layerTarget, QgsVectorLayer *layerReference)
|
||||
|
||||
bool QgsSpatialQuery::hasValidGeometry(QgsFeature &feature)
|
||||
bool QgsSpatialQuery::hasValidGeometry( QgsFeature &feature )
|
||||
{
|
||||
if ( ! feature.isValid() )
|
||||
{
|
||||
@ -179,7 +182,7 @@ bool QgsSpatialQuery::hasValidGeometry(QgsFeature &feature)
|
||||
|
||||
GEOSGeometry *geomGeos = geom->asGeos();
|
||||
|
||||
if ( GEOSisEmpty(geomGeos) || 1 != GEOSisValid(geomGeos))
|
||||
if ( GEOSisEmpty( geomGeos ) || 1 != GEOSisValid( geomGeos ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -190,33 +193,33 @@ bool QgsSpatialQuery::hasValidGeometry(QgsFeature &feature)
|
||||
|
||||
void QgsSpatialQuery::setSpatialIndexReference()
|
||||
{
|
||||
QgsReaderFeatures * readerFeaturesReference = new QgsReaderFeatures(mLayerReference, mUseReferenceSelection);
|
||||
QgsReaderFeatures * readerFeaturesReference = new QgsReaderFeatures( mLayerReference, mUseReferenceSelection );
|
||||
QgsFeature feature;
|
||||
int step = 1;
|
||||
while ( true )
|
||||
{
|
||||
if ( ! readerFeaturesReference->nextFeature(feature) )
|
||||
if ( ! readerFeaturesReference->nextFeature( feature ) )
|
||||
{
|
||||
break;
|
||||
}
|
||||
mPb->step(step++);
|
||||
mPb->step( step++ );
|
||||
|
||||
if ( ! hasValidGeometry(feature) )
|
||||
if ( ! hasValidGeometry( feature ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
mIndexReference.insertFeature(feature);
|
||||
mIndexReference.insertFeature( feature );
|
||||
}
|
||||
delete readerFeaturesReference;
|
||||
|
||||
} // void QgsSpatialQuery::setSpatialIndexReference()
|
||||
|
||||
void QgsSpatialQuery::execQuery( QSet<int> & qsetIndexResult, int relation)
|
||||
void QgsSpatialQuery::execQuery( QSet<int> & qsetIndexResult, int relation )
|
||||
{
|
||||
// Set function GEOS
|
||||
char(*operation)(const GEOSGeometry *, const GEOSGeometry*);
|
||||
switch (relation)
|
||||
char( *operation )( const GEOSGeometry *, const GEOSGeometry* );
|
||||
switch ( relation )
|
||||
{
|
||||
case Disjoint:
|
||||
operation = &GEOSDisjoint;
|
||||
@ -246,12 +249,12 @@ void QgsSpatialQuery::execQuery( QSet<int> & qsetIndexResult, int relation)
|
||||
|
||||
// Transform referencer Target = Reference
|
||||
QgsGeometryCoordinateTransform *coordinateTransform = new QgsGeometryCoordinateTransform();
|
||||
coordinateTransform->setCoordinateTransform(mLayerTarget, mLayerReference);
|
||||
coordinateTransform->setCoordinateTransform( mLayerTarget, mLayerReference );
|
||||
|
||||
// Set function for populate result
|
||||
void (QgsSpatialQuery::* funcPopulateIndexResult)
|
||||
(QSet<int> &, int, QgsGeometry *,
|
||||
char(*)(const GEOSGeometry *, const GEOSGeometry *) );
|
||||
void ( QgsSpatialQuery::* funcPopulateIndexResult )
|
||||
( QSet<int> &, int, QgsGeometry *,
|
||||
char( * )( const GEOSGeometry *, const GEOSGeometry * ) );
|
||||
funcPopulateIndexResult = ( relation == Disjoint )
|
||||
? &QgsSpatialQuery::populateIndexResultDisjoint
|
||||
: &QgsSpatialQuery::populateIndexResult;
|
||||
@ -259,22 +262,22 @@ void QgsSpatialQuery::execQuery( QSet<int> & qsetIndexResult, int relation)
|
||||
QgsFeature featureTarget;
|
||||
QgsGeometry * geomTarget;
|
||||
int step = 1;
|
||||
while( true )
|
||||
while ( true )
|
||||
{
|
||||
if ( ! mReaderFeaturesTarget->nextFeature(featureTarget) ) break;
|
||||
if ( ! mReaderFeaturesTarget->nextFeature( featureTarget ) ) break;
|
||||
|
||||
mPb->step(step++);
|
||||
mPb->step( step++ );
|
||||
|
||||
if ( ! hasValidGeometry(featureTarget) )
|
||||
if ( ! hasValidGeometry( featureTarget ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
geomTarget = featureTarget.geometry();
|
||||
coordinateTransform->transform(geomTarget);
|
||||
coordinateTransform->transform( geomTarget );
|
||||
|
||||
(this->*funcPopulateIndexResult)
|
||||
(qsetIndexResult, featureTarget.id(), geomTarget, operation);
|
||||
( this->*funcPopulateIndexResult )
|
||||
( qsetIndexResult, featureTarget.id(), geomTarget, operation );
|
||||
}
|
||||
delete coordinateTransform;
|
||||
|
||||
@ -282,10 +285,10 @@ void QgsSpatialQuery::execQuery( QSet<int> & qsetIndexResult, int relation)
|
||||
|
||||
void QgsSpatialQuery::populateIndexResult(
|
||||
QSet<int> &qsetIndexResult, int idTarget, QgsGeometry * geomTarget,
|
||||
char(*operation)(const GEOSGeometry *, const GEOSGeometry *) )
|
||||
char( *operation )( const GEOSGeometry *, const GEOSGeometry * ) )
|
||||
{
|
||||
QList<int> listIdReference;
|
||||
listIdReference = mIndexReference.intersects(geomTarget->boundingBox());
|
||||
listIdReference = mIndexReference.intersects( geomTarget->boundingBox() );
|
||||
if ( listIdReference.count() == 0 )
|
||||
{
|
||||
return;
|
||||
@ -294,13 +297,13 @@ void QgsSpatialQuery::populateIndexResult(
|
||||
QgsFeature featureReference;
|
||||
QgsGeometry * geomReference;
|
||||
QList<int>::iterator iterIdReference = listIdReference.begin();
|
||||
for( ; iterIdReference != listIdReference.end(); iterIdReference++ )
|
||||
for ( ; iterIdReference != listIdReference.end(); iterIdReference++ )
|
||||
{
|
||||
mLayerReference->featureAtId(*iterIdReference, featureReference);
|
||||
mLayerReference->featureAtId( *iterIdReference, featureReference );
|
||||
geomReference = featureReference.geometry();
|
||||
if( (*operation)(geosTarget, geomReference->asGeos()) == 1 )
|
||||
if (( *operation )( geosTarget, geomReference->asGeos() ) == 1 )
|
||||
{
|
||||
qsetIndexResult.insert(idTarget);
|
||||
qsetIndexResult.insert( idTarget );
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -309,13 +312,13 @@ void QgsSpatialQuery::populateIndexResult(
|
||||
|
||||
void QgsSpatialQuery::populateIndexResultDisjoint(
|
||||
QSet<int> &qsetIndexResult, int idTarget, QgsGeometry * geomTarget,
|
||||
char(*operation)(const GEOSGeometry *, const GEOSGeometry *) )
|
||||
char( *operation )( const GEOSGeometry *, const GEOSGeometry * ) )
|
||||
{
|
||||
QList<int> listIdReference;
|
||||
listIdReference = mIndexReference.intersects(geomTarget->boundingBox());
|
||||
listIdReference = mIndexReference.intersects( geomTarget->boundingBox() );
|
||||
if ( listIdReference.count() == 0 )
|
||||
{
|
||||
qsetIndexResult.insert(idTarget);
|
||||
qsetIndexResult.insert( idTarget );
|
||||
return;
|
||||
}
|
||||
GEOSGeometry * geosTarget = geomTarget->asGeos();
|
||||
@ -323,11 +326,11 @@ void QgsSpatialQuery::populateIndexResultDisjoint(
|
||||
QgsGeometry * geomReference;
|
||||
QList<int>::iterator iterIdReference = listIdReference.begin();
|
||||
bool addIndex = true;
|
||||
for( ; iterIdReference != listIdReference.end(); iterIdReference++ )
|
||||
for ( ; iterIdReference != listIdReference.end(); iterIdReference++ )
|
||||
{
|
||||
mLayerReference->featureAtId(*iterIdReference, featureReference);
|
||||
mLayerReference->featureAtId( *iterIdReference, featureReference );
|
||||
geomReference = featureReference.geometry();
|
||||
if( (*operation)(geosTarget, geomReference->asGeos()) == 0 )
|
||||
if (( *operation )( geosTarget, geomReference->asGeos() ) == 0 )
|
||||
{
|
||||
addIndex = false;
|
||||
break;
|
||||
@ -335,7 +338,7 @@ void QgsSpatialQuery::populateIndexResultDisjoint(
|
||||
}
|
||||
if ( addIndex )
|
||||
{
|
||||
qsetIndexResult.insert(idTarget);
|
||||
qsetIndexResult.insert( idTarget );
|
||||
}
|
||||
|
||||
} // void QgsSpatialQuery::populateIndexResultDisjoint( ...
|
||||
|
@ -53,12 +53,12 @@ enum Topologic_Relation
|
||||
*/
|
||||
class QgsSpatialQuery
|
||||
{
|
||||
public:
|
||||
public:
|
||||
/**
|
||||
* \brief Constructor for a Spatial query.
|
||||
* \param pb Pointer to the MngProgressBar object.
|
||||
*/
|
||||
QgsSpatialQuery(MngProgressBar *pb);
|
||||
QgsSpatialQuery( MngProgressBar *pb );
|
||||
|
||||
/**
|
||||
* \brief Destructor
|
||||
@ -69,13 +69,13 @@ public:
|
||||
* \brief Sets if using selected features in Target layer
|
||||
* \param useSelected TRUE if use selected.
|
||||
*/
|
||||
void setSelectedFeaturesTarget(bool useSelected);
|
||||
void setSelectedFeaturesTarget( bool useSelected );
|
||||
|
||||
/**
|
||||
* \brief Sets if using selected features in Reference layer
|
||||
* \param useSelected TRUE if use selected.
|
||||
*/
|
||||
void setSelectedFeaturesReference(bool useSelected);
|
||||
void setSelectedFeaturesReference( bool useSelected );
|
||||
|
||||
/**
|
||||
* \brief Execute the query
|
||||
@ -99,9 +99,9 @@ public:
|
||||
* \param geomType Geometry Type
|
||||
* \returns short int Topologic Dimension
|
||||
*/
|
||||
static short int dimensionGeometry(QGis::GeometryType geomType);
|
||||
static short int dimensionGeometry( QGis::GeometryType geomType );
|
||||
|
||||
private:
|
||||
private:
|
||||
|
||||
/**
|
||||
* \brief Sets the target layer and reference layer
|
||||
@ -114,7 +114,7 @@ private:
|
||||
* \brief Verify has valid Geometry in feature
|
||||
* \param QgsFeature Feature
|
||||
*/
|
||||
bool hasValidGeometry(QgsFeature &feature);
|
||||
bool hasValidGeometry( QgsFeature &feature );
|
||||
|
||||
/**
|
||||
* \brief Build the Spatial Index
|
||||
@ -126,7 +126,7 @@ private:
|
||||
* \param qsetIndexResult Reference to QSet contains the result query
|
||||
* \param relation Enum Topologic Relation
|
||||
*/
|
||||
void execQuery(QSet<int> & qsetIndexResult, int relation);
|
||||
void execQuery( QSet<int> & qsetIndexResult, int relation );
|
||||
|
||||
/**
|
||||
* \brief Populate index Result
|
||||
@ -137,7 +137,7 @@ private:
|
||||
*/
|
||||
void populateIndexResult(
|
||||
QSet<int> & qsetIndexResult, int idTarget, QgsGeometry * geomTarget,
|
||||
char(*operation)(const GEOSGeometry *, const GEOSGeometry *) );
|
||||
char( *operation )( const GEOSGeometry *, const GEOSGeometry * ) );
|
||||
/**
|
||||
* \brief Populate index Result Disjoint
|
||||
* \param qsetIndexResult Reference to QSet contains the result query
|
||||
@ -147,7 +147,7 @@ private:
|
||||
*/
|
||||
void populateIndexResultDisjoint(
|
||||
QSet<int> & qsetIndexResult, int idTarget, QgsGeometry * geomTarget,
|
||||
char(*operation)(const GEOSGeometry *, const GEOSGeometry *) );
|
||||
char( *operation )( const GEOSGeometry *, const GEOSGeometry * ) );
|
||||
|
||||
MngProgressBar *mPb;
|
||||
bool mUseReferenceSelection;
|
||||
|
@ -46,7 +46,7 @@ QgsSpatialQueryDialog::QgsSpatialQueryDialog( QWidget* parent, QgisInterface* if
|
||||
initGui();
|
||||
connectAll();
|
||||
|
||||
mMsgLayersLessTwo = tr("The spatial query requires at least two layers");
|
||||
mMsgLayersLessTwo = tr( "The spatial query requires at least two layers" );
|
||||
|
||||
} // QgsSpatialQueryDialog::QgsSpatialQueryDialog( QWidget* parent, QgisInterface* iface )
|
||||
|
||||
@ -61,8 +61,8 @@ QgsSpatialQueryDialog::~QgsSpatialQueryDialog()
|
||||
|
||||
void QgsSpatialQueryDialog::messageLayersLessTwo()
|
||||
{
|
||||
QString msgLayersLessTwo = tr("The spatial query requires at least two layers");
|
||||
QMessageBox::warning(0, tr("Insufficient number of layers"), msgLayersLessTwo, QMessageBox::Ok);
|
||||
QString msgLayersLessTwo = tr( "The spatial query requires at least two layers" );
|
||||
QMessageBox::warning( 0, tr( "Insufficient number of layers" ), msgLayersLessTwo, QMessageBox::Ok );
|
||||
}
|
||||
|
||||
void QgsSpatialQueryDialog::disconnectQGis()
|
||||
@ -73,24 +73,24 @@ void QgsSpatialQueryDialog::disconnectQGis()
|
||||
|
||||
void QgsSpatialQueryDialog::initGui()
|
||||
{
|
||||
showLogProcessing(false);
|
||||
showLogProcessing( false );
|
||||
grpResults->hide();
|
||||
buttonBox->button(QDialogButtonBox::Close)->hide();
|
||||
buttonBox->button( QDialogButtonBox::Close )->hide();
|
||||
|
||||
populateTargetLayerComboBox();
|
||||
if (targetLayerComboBox->count() > 1)
|
||||
if ( targetLayerComboBox->count() > 1 )
|
||||
{
|
||||
setLayer(true, 0);
|
||||
evaluateCheckBox(true);
|
||||
setLayer( true, 0 );
|
||||
evaluateCheckBox( true );
|
||||
populateReferenceLayerComboBox();
|
||||
setLayer(false, 0);
|
||||
evaluateCheckBox(false);
|
||||
setLayer( false, 0 );
|
||||
evaluateCheckBox( false );
|
||||
populateOperationComboBox();
|
||||
}
|
||||
else
|
||||
{
|
||||
buttonBox->setEnabled(false);
|
||||
textEditStatus->append(mMsgLayersLessTwo);
|
||||
buttonBox->setEnabled( false );
|
||||
textEditStatus->append( mMsgLayersLessTwo );
|
||||
}
|
||||
|
||||
} // QgsSpatialQueryDialog::initGui()
|
||||
@ -102,41 +102,42 @@ void QgsSpatialQueryDialog::setColorRubberSelectId()
|
||||
myGreenInt = QgsProject::instance()->readNumEntry( "Gui", "/SelectionColorGreenPart", 255 );
|
||||
myBlueInt = QgsProject::instance()->readNumEntry( "Gui", "/SelectionColorBluePart", 0 );
|
||||
|
||||
mRubberSelectId->setColor(255-myRedInt, 255-myGreenInt, 255-myBlueInt, 0.5, 2);
|
||||
mRubberSelectId->setColor( 255 - myRedInt, 255 - myGreenInt, 255 - myBlueInt, 0.5, 2 );
|
||||
|
||||
} // void QgsSpatialQueryDialog::setColorRubberSelectId()
|
||||
|
||||
void QgsSpatialQueryDialog::setLayer(bool isTarget, int index)
|
||||
void QgsSpatialQueryDialog::setLayer( bool isTarget, int index )
|
||||
{
|
||||
if (isTarget) {
|
||||
if (mLayerTarget)
|
||||
if ( isTarget )
|
||||
{
|
||||
disconnect(mLayerTarget, SIGNAL( selectionChanged()),
|
||||
if ( mLayerTarget )
|
||||
{
|
||||
disconnect( mLayerTarget, SIGNAL( selectionChanged() ),
|
||||
this, SLOT( signal_layerTarget_selectionFeaturesChanged() ) );
|
||||
}
|
||||
mLayerTarget = getLayerFromCombobox(isTarget, index);
|
||||
connect(mLayerTarget, SIGNAL( selectionChanged()),
|
||||
mLayerTarget = getLayerFromCombobox( isTarget, index );
|
||||
connect( mLayerTarget, SIGNAL( selectionChanged() ),
|
||||
this, SLOT( signal_layerTarget_selectionFeaturesChanged() ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mLayerReference)
|
||||
if ( mLayerReference )
|
||||
{
|
||||
disconnect(mLayerReference, SIGNAL( selectionChanged()),
|
||||
disconnect( mLayerReference, SIGNAL( selectionChanged() ),
|
||||
this, SLOT( signal_layerReference_selectionFeaturesChanged() ) );
|
||||
}
|
||||
mLayerReference = getLayerFromCombobox(isTarget, index);
|
||||
connect(mLayerReference, SIGNAL( selectionChanged()),
|
||||
mLayerReference = getLayerFromCombobox( isTarget, index );
|
||||
connect( mLayerReference, SIGNAL( selectionChanged() ),
|
||||
this, SLOT( signal_layerReference_selectionFeaturesChanged() ) );
|
||||
}
|
||||
|
||||
} // void QgsSpatialQueryDialog::setLayer(bool isTarget, int index)
|
||||
|
||||
void QgsSpatialQueryDialog::evaluateCheckBox(bool isTarget)
|
||||
void QgsSpatialQueryDialog::evaluateCheckBox( bool isTarget )
|
||||
{
|
||||
QgsVectorLayer* layer = NULL;
|
||||
QCheckBox* checkbox = NULL;
|
||||
if (isTarget)
|
||||
if ( isTarget )
|
||||
{
|
||||
layer = mLayerTarget;
|
||||
checkbox = usingSelectedTargetCheckBox;
|
||||
@ -148,50 +149,50 @@ void QgsSpatialQueryDialog::evaluateCheckBox(bool isTarget)
|
||||
}
|
||||
int selectedCount = layer->selectedFeatureCount();
|
||||
bool isCheckBoxValid = ( layer != NULL && selectedCount > 0 );
|
||||
checkbox->setChecked(isCheckBoxValid);
|
||||
checkbox->setEnabled(isCheckBoxValid);
|
||||
checkbox->setChecked( isCheckBoxValid );
|
||||
checkbox->setEnabled( isCheckBoxValid );
|
||||
QString textCheckBox = isCheckBoxValid
|
||||
? QString::number(selectedCount) + " " + tr("Selected geometries")
|
||||
: tr("Selected geometries");
|
||||
checkbox->setText(textCheckBox);
|
||||
? QString::number( selectedCount ) + " " + tr( "Selected geometries" )
|
||||
: tr( "Selected geometries" );
|
||||
checkbox->setText( textCheckBox );
|
||||
|
||||
} // void QgsSpatialQueryDialog::evaluateCheckBox(bool isTarget)
|
||||
|
||||
void QgsSpatialQueryDialog::runQuery()
|
||||
{
|
||||
buttonBox->setEnabled(false);
|
||||
MngProgressBar* pb = new MngProgressBar(progressBarStatus);
|
||||
QgsSpatialQuery* spatialQuery = new QgsSpatialQuery(pb);
|
||||
if (usingSelectedTargetCheckBox->isChecked())
|
||||
buttonBox->setEnabled( false );
|
||||
MngProgressBar* pb = new MngProgressBar( progressBarStatus );
|
||||
QgsSpatialQuery* spatialQuery = new QgsSpatialQuery( pb );
|
||||
if ( usingSelectedTargetCheckBox->isChecked() )
|
||||
{
|
||||
spatialQuery->setSelectedFeaturesTarget(true);
|
||||
spatialQuery->setSelectedFeaturesTarget( true );
|
||||
}
|
||||
if (usingSelectedReferenceCheckBox->isChecked())
|
||||
if ( usingSelectedReferenceCheckBox->isChecked() )
|
||||
{
|
||||
spatialQuery->setSelectedFeaturesReference(true);
|
||||
spatialQuery->setSelectedFeaturesReference( true );
|
||||
}
|
||||
progressBarStatus->setTextVisible(true);
|
||||
progressBarStatus->setTextVisible( true );
|
||||
mFeatureResult.clear();
|
||||
|
||||
int currentItem = operantionComboBox->currentIndex();
|
||||
bool isOk;
|
||||
int operation = operantionComboBox->itemData(currentItem).toInt(&isOk);
|
||||
spatialQuery->runQuery(mFeatureResult, operation, mLayerTarget, mLayerReference);
|
||||
int operation = operantionComboBox->itemData( currentItem ).toInt( &isOk );
|
||||
spatialQuery->runQuery( mFeatureResult, operation, mLayerTarget, mLayerReference );
|
||||
delete spatialQuery;
|
||||
delete pb;
|
||||
|
||||
progressBarStatus->setTextVisible(false);
|
||||
buttonBox->setEnabled(true);
|
||||
progressBarStatus->setTextVisible( false );
|
||||
buttonBox->setEnabled( true );
|
||||
|
||||
grpResults->show();
|
||||
grpInputs->hide();
|
||||
progressBarStatus->hide();
|
||||
buttonBox->button(QDialogButtonBox::Close)->show();
|
||||
buttonBox->button(QDialogButtonBox::Cancel)->hide();
|
||||
buttonBox->button(QDialogButtonBox::Ok)->hide();
|
||||
buttonBox->button( QDialogButtonBox::Close )->show();
|
||||
buttonBox->button( QDialogButtonBox::Cancel )->hide();
|
||||
buttonBox->button( QDialogButtonBox::Ok )->hide();
|
||||
} // void QgsSpatialQueryDialog::runQuery()
|
||||
|
||||
void QgsSpatialQueryDialog::showLogProcessing(bool hasShow)
|
||||
void QgsSpatialQueryDialog::showLogProcessing( bool hasShow )
|
||||
{
|
||||
static int heightDialogNoStatus = 0;
|
||||
|
||||
@ -206,42 +207,42 @@ void QgsSpatialQueryDialog::showLogProcessing(bool hasShow)
|
||||
}
|
||||
else
|
||||
{
|
||||
this->setGeometry(this->geometry().x(), this->geometry().y(),
|
||||
this->geometry().width(), heightDialogNoStatus);
|
||||
this->setGeometry( this->geometry().x(), this->geometry().y(),
|
||||
this->geometry().width(), heightDialogNoStatus );
|
||||
}
|
||||
}
|
||||
|
||||
} // void QgsSpatialQueryDialog::showLogProcessing(bool hasShow)
|
||||
|
||||
void QgsSpatialQueryDialog::showResultQuery(QDateTime *datetimeStart, QDateTime *datetimeEnd)
|
||||
void QgsSpatialQueryDialog::showResultQuery( QDateTime *datetimeStart, QDateTime *datetimeEnd )
|
||||
{
|
||||
selectedFeatureListWidget->clear();
|
||||
countSelectedFeats->setText(tr("Total: %1").arg(mFeatureResult.size()));
|
||||
countSelectedFeats->setText( tr( "Total: %1" ).arg( mFeatureResult.size() ) );
|
||||
|
||||
QString msg = tr("<<-- Begin at [%L1] --").arg(datetimeStart->toString());
|
||||
textEditStatus->append(msg);
|
||||
msg = tr("Query:");
|
||||
textEditStatus->append(msg);
|
||||
msg = QString("- %1").arg(getDescriptionLayerShow(true));
|
||||
textEditStatus->append(msg);
|
||||
msg = tr("< %1 >").arg(operantionComboBox->currentText());
|
||||
textEditStatus->append(msg);
|
||||
msg = QString("- %1").arg(getDescriptionLayerShow(false));
|
||||
textEditStatus->append(msg);
|
||||
msg = tr("Result: %1 features").arg(mFeatureResult.size());
|
||||
textEditStatus->append(msg);
|
||||
double timeProcess = (double)datetimeStart->secsTo(*datetimeEnd) / 60.0;
|
||||
msg = tr("-- Finish at [%L1] (processing time %L2 minutes) -->>").arg(datetimeEnd->toString()).arg(timeProcess, 0, 'f', 2);
|
||||
textEditStatus->append(msg);
|
||||
QString msg = tr( "<<-- Begin at [%L1] --" ).arg( datetimeStart->toString() );
|
||||
textEditStatus->append( msg );
|
||||
msg = tr( "Query:" );
|
||||
textEditStatus->append( msg );
|
||||
msg = QString( "- %1" ).arg( getDescriptionLayerShow( true ) );
|
||||
textEditStatus->append( msg );
|
||||
msg = tr( "< %1 >" ).arg( operantionComboBox->currentText() );
|
||||
textEditStatus->append( msg );
|
||||
msg = QString( "- %1" ).arg( getDescriptionLayerShow( false ) );
|
||||
textEditStatus->append( msg );
|
||||
msg = tr( "Result: %1 features" ).arg( mFeatureResult.size() );
|
||||
textEditStatus->append( msg );
|
||||
double timeProcess = ( double )datetimeStart->secsTo( *datetimeEnd ) / 60.0;
|
||||
msg = tr( "-- Finish at [%L1] (processing time %L2 minutes) -->>" ).arg( datetimeEnd->toString() ).arg( timeProcess, 0, 'f', 2 );
|
||||
textEditStatus->append( msg );
|
||||
|
||||
if( mFeatureResult.size() > 0 )
|
||||
if ( mFeatureResult.size() > 0 )
|
||||
{
|
||||
populateQueryResult();
|
||||
mLayerTarget->setSelectedFeatures(mFeatureResult);
|
||||
evaluateCheckBox(true);
|
||||
mLayerTarget->setSelectedFeatures( mFeatureResult );
|
||||
evaluateCheckBox( true );
|
||||
|
||||
QString sIdFeat = selectedFeatureListWidget->currentItem()->text();
|
||||
on_selectedFeatureListWidget_currentTextChanged(sIdFeat);
|
||||
on_selectedFeatureListWidget_currentTextChanged( sIdFeat );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -250,11 +251,11 @@ void QgsSpatialQueryDialog::showResultQuery(QDateTime *datetimeStart, QDateTime
|
||||
|
||||
} // void QgsSpatialQueryDialog::showResultQuery(QDateTime *datetimeStart, QDateTime *datetimeEnd)
|
||||
|
||||
QString QgsSpatialQueryDialog::getDescriptionLayerShow(bool isTarget)
|
||||
QString QgsSpatialQueryDialog::getDescriptionLayerShow( bool isTarget )
|
||||
{
|
||||
QgsVectorLayer* layer = NULL;
|
||||
QCheckBox * checkBox = NULL;
|
||||
if (isTarget)
|
||||
if ( isTarget )
|
||||
{
|
||||
layer = mLayerTarget;
|
||||
checkBox = usingSelectedTargetCheckBox;
|
||||
@ -266,40 +267,40 @@ QString QgsSpatialQueryDialog::getDescriptionLayerShow(bool isTarget)
|
||||
}
|
||||
|
||||
QString sDescFeatures = checkBox->isChecked()
|
||||
? tr("%1 of %2").arg(layer->selectedFeatureCount()).arg(layer->featureCount())
|
||||
: tr("all = %1").arg(layer->featureCount());
|
||||
? tr( "%1 of %2" ).arg( layer->selectedFeatureCount() ).arg( layer->featureCount() )
|
||||
: tr( "all = %1" ).arg( layer->featureCount() );
|
||||
|
||||
return QString("%1 (%2)").arg(layer->name()).arg(sDescFeatures);
|
||||
return QString( "%1 (%2)" ).arg( layer->name() ).arg( sDescFeatures );
|
||||
|
||||
} // QString QgsSpatialQueryDialog::getDescriptionLayerShow(bool isTarget)
|
||||
|
||||
void QgsSpatialQueryDialog::connectAll()
|
||||
{
|
||||
connect(QgsMapLayerRegistry::instance(), SIGNAL( layerWasAdded(QgsMapLayer*) ),
|
||||
this, SLOT( signal_qgis_layerWasAdded(QgsMapLayer*) )) ;
|
||||
connect(QgsMapLayerRegistry::instance(), SIGNAL( layerWillBeRemoved(QString) ),
|
||||
connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWasAdded( QgsMapLayer* ) ),
|
||||
this, SLOT( signal_qgis_layerWasAdded( QgsMapLayer* ) ) ) ;
|
||||
connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWillBeRemoved( QString ) ),
|
||||
this, SLOT( signal_qgis_layerWillBeRemoved( QString ) ) );
|
||||
connect(showLogProcessingCheckBox, SIGNAL ( clicked() ),
|
||||
this, SLOT( on_showLogProcessingCheckBox_clicked(bool) ) );
|
||||
connect( showLogProcessingCheckBox, SIGNAL( clicked() ),
|
||||
this, SLOT( on_showLogProcessingCheckBox_clicked( bool ) ) );
|
||||
|
||||
} // QgsSpatialQueryDialog::connectAll()
|
||||
|
||||
void QgsSpatialQueryDialog::disconnectAll()
|
||||
{
|
||||
disconnect(QgsMapLayerRegistry::instance(), SIGNAL( layerWasAdded(QgsMapLayer*)),
|
||||
this, SLOT( signal_qgis_layerWasAdded(QgsMapLayer*) )) ;
|
||||
disconnect(QgsMapLayerRegistry::instance(), SIGNAL( layerWillBeRemoved( QString )),
|
||||
disconnect( QgsMapLayerRegistry::instance(), SIGNAL( layerWasAdded( QgsMapLayer* ) ),
|
||||
this, SLOT( signal_qgis_layerWasAdded( QgsMapLayer* ) ) ) ;
|
||||
disconnect( QgsMapLayerRegistry::instance(), SIGNAL( layerWillBeRemoved( QString ) ),
|
||||
this, SLOT( signal_qgis_layerWillBeRemoved( QString ) ) );
|
||||
|
||||
if ( mLayerTarget )
|
||||
{
|
||||
disconnect(mLayerTarget, SIGNAL( selectionChanged()),
|
||||
disconnect( mLayerTarget, SIGNAL( selectionChanged() ),
|
||||
this, SLOT( signal_layerTarget_selectionFeaturesChanged() ) );
|
||||
|
||||
}
|
||||
if ( mLayerReference )
|
||||
{
|
||||
disconnect(mLayerReference, SIGNAL( selectionChanged()),
|
||||
disconnect( mLayerReference, SIGNAL( selectionChanged() ),
|
||||
this, SLOT( signal_layerReference_selectionFeaturesChanged() ) );
|
||||
}
|
||||
|
||||
@ -318,17 +319,17 @@ void QgsSpatialQueryDialog::reject()
|
||||
|
||||
} // QgsSpatialQueryDialog::reject()
|
||||
|
||||
QgsVectorLayer * QgsSpatialQueryDialog::getLayerFromCombobox(bool isTarget, int index)
|
||||
QgsVectorLayer * QgsSpatialQueryDialog::getLayerFromCombobox( bool isTarget, int index )
|
||||
{
|
||||
QVariant data = isTarget
|
||||
? targetLayerComboBox->itemData(index)
|
||||
: referenceLayerComboBox->itemData(index);
|
||||
? targetLayerComboBox->itemData( index )
|
||||
: referenceLayerComboBox->itemData( index );
|
||||
QgsVectorLayer* lyr = static_cast<QgsVectorLayer*>( data.value<void *>() );
|
||||
return lyr;
|
||||
|
||||
} // QgsVectorLayer * QgsSpatialQueryDialog::getLayerFromCombobox(bool isTarget, int index)
|
||||
|
||||
QIcon QgsSpatialQueryDialog::getIconTypeGeometry(QGis::GeometryType geomType)
|
||||
QIcon QgsSpatialQueryDialog::getIconTypeGeometry( QGis::GeometryType geomType )
|
||||
{
|
||||
QString theName;
|
||||
if ( geomType == QGis::Point )
|
||||
@ -363,34 +364,34 @@ QIcon QgsSpatialQueryDialog::getIconTypeGeometry(QGis::GeometryType geomType)
|
||||
|
||||
} // QIcon QgsSpatialQueryDialog::getIconTypeGeometry(int typeGeometry)
|
||||
|
||||
void QgsSpatialQueryDialog::addLayerCombobox(bool isTarget, QgsVectorLayer* vectorLayer)
|
||||
void QgsSpatialQueryDialog::addLayerCombobox( bool isTarget, QgsVectorLayer* vectorLayer )
|
||||
{
|
||||
QVariant item = QVariant::fromValue((void *)vectorLayer);
|
||||
QVariant item = QVariant::fromValue(( void * )vectorLayer );
|
||||
QComboBox * cmb = isTarget ? targetLayerComboBox : referenceLayerComboBox;
|
||||
int idNew = cmb->count();
|
||||
QIcon icon = getIconTypeGeometry(vectorLayer->geometryType());
|
||||
cmb->addItem(icon, vectorLayer->name(), item);
|
||||
cmb->setItemData(idNew, QVariant(vectorLayer->source()), Qt::ToolTipRole);
|
||||
QIcon icon = getIconTypeGeometry( vectorLayer->geometryType() );
|
||||
cmb->addItem( icon, vectorLayer->name(), item );
|
||||
cmb->setItemData( idNew, QVariant( vectorLayer->source() ), Qt::ToolTipRole );
|
||||
|
||||
} // void QgsSpatialQueryDialog::removeLayerCombobox(bool isTarget, QgsVectorLayer* vectorLayer)
|
||||
|
||||
int QgsSpatialQueryDialog::getIndexLayerCombobox(bool isTarget, QgsVectorLayer* vectorLayer)
|
||||
int QgsSpatialQueryDialog::getIndexLayerCombobox( bool isTarget, QgsVectorLayer* vectorLayer )
|
||||
{
|
||||
QVariant item = QVariant::fromValue((void *)vectorLayer);
|
||||
QVariant item = QVariant::fromValue(( void * )vectorLayer );
|
||||
QComboBox * cmb = isTarget ? targetLayerComboBox : referenceLayerComboBox;
|
||||
return cmb->findData(item);
|
||||
return cmb->findData( item );
|
||||
|
||||
} //
|
||||
|
||||
void QgsSpatialQueryDialog::removeLayer(bool isTarget, QgsVectorLayer* lyrRemove)
|
||||
void QgsSpatialQueryDialog::removeLayer( bool isTarget, QgsVectorLayer* lyrRemove )
|
||||
{
|
||||
QComboBox * cmb = isTarget ? targetLayerComboBox : referenceLayerComboBox;
|
||||
cmb->blockSignals(true);
|
||||
cmb->blockSignals( true );
|
||||
// Remove Combobox
|
||||
int index = getIndexLayerCombobox(isTarget, lyrRemove);
|
||||
if(index > -1)
|
||||
int index = getIndexLayerCombobox( isTarget, lyrRemove );
|
||||
if ( index > -1 )
|
||||
{
|
||||
cmb->removeItem(index);
|
||||
cmb->removeItem( index );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -402,34 +403,34 @@ void QgsSpatialQueryDialog::removeLayer(bool isTarget, QgsVectorLayer* lyrRemove
|
||||
{
|
||||
lyrThis = mLayerReference;
|
||||
}
|
||||
if (lyrRemove == lyrThis)
|
||||
if ( lyrRemove == lyrThis )
|
||||
{
|
||||
lyrThis = NULL;
|
||||
if( cmb->count() > 0 )
|
||||
if ( cmb->count() > 0 )
|
||||
{
|
||||
cmb->setCurrentIndex(0);
|
||||
setLayer(isTarget, 0);
|
||||
evaluateCheckBox(isTarget);
|
||||
if (isTarget)
|
||||
cmb->setCurrentIndex( 0 );
|
||||
setLayer( isTarget, 0 );
|
||||
evaluateCheckBox( isTarget );
|
||||
if ( isTarget )
|
||||
{
|
||||
selectedFeatureListWidget->blockSignals(true);
|
||||
selectedFeatureListWidget->blockSignals( true );
|
||||
selectedFeatureListWidget->clear();
|
||||
selectedFeatureListWidget->blockSignals(false);
|
||||
countSelectedFeats->setText(tr("Total") + ": 0");
|
||||
selectedFeatureListWidget->blockSignals( false );
|
||||
countSelectedFeats->setText( tr( "Total" ) + ": 0" );
|
||||
mRubberSelectId->reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
cmb->blockSignals(false);
|
||||
cmb->blockSignals( false );
|
||||
|
||||
} // void QgsSpatialQueryDialog::removeLayer(bool isTarget, QgsVectorLayer* lyrRemove)
|
||||
|
||||
void QgsSpatialQueryDialog::populateTargetLayerComboBox()
|
||||
{
|
||||
targetLayerComboBox->blockSignals(true);
|
||||
targetLayerComboBox->blockSignals( true );
|
||||
|
||||
QMap <QString, QgsMapLayer*> map = QgsMapLayerRegistry::instance()->mapLayers();
|
||||
QMapIterator <QString, QgsMapLayer*> item(map);
|
||||
QMapIterator <QString, QgsMapLayer*> item( map );
|
||||
QgsMapLayer * mapLayer = NULL;
|
||||
QgsVectorLayer * vectorLayer = NULL;
|
||||
QString layerId;
|
||||
@ -437,27 +438,27 @@ void QgsSpatialQueryDialog::populateTargetLayerComboBox()
|
||||
{
|
||||
item.next();
|
||||
mapLayer = item.value();
|
||||
if( mapLayer->type() != QgsMapLayer::VectorLayer )
|
||||
if ( mapLayer->type() != QgsMapLayer::VectorLayer )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
vectorLayer = qobject_cast<QgsVectorLayer *>(mapLayer);
|
||||
if (!vectorLayer)
|
||||
vectorLayer = qobject_cast<QgsVectorLayer *>( mapLayer );
|
||||
if ( !vectorLayer )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
addLayerCombobox(true, vectorLayer);
|
||||
mMapIdVectorLayers.insert(vectorLayer->getLayerID(), vectorLayer);
|
||||
addLayerCombobox( true, vectorLayer );
|
||||
mMapIdVectorLayers.insert( vectorLayer->getLayerID(), vectorLayer );
|
||||
}
|
||||
targetLayerComboBox->setCurrentIndex(0);
|
||||
targetLayerComboBox->blockSignals(false);
|
||||
targetLayerComboBox->setCurrentIndex( 0 );
|
||||
targetLayerComboBox->blockSignals( false );
|
||||
|
||||
} // void QgsSpatialQueryDialog::populateTargetLayerComboBox()
|
||||
|
||||
void QgsSpatialQueryDialog::populateReferenceLayerComboBox()
|
||||
{
|
||||
referenceLayerComboBox->blockSignals(true);
|
||||
referenceLayerComboBox->blockSignals( true );
|
||||
referenceLayerComboBox->clear();
|
||||
|
||||
// Populate new values and Set current item keeping the previous value
|
||||
@ -466,105 +467,105 @@ void QgsSpatialQueryDialog::populateReferenceLayerComboBox()
|
||||
QIcon itemIcon;
|
||||
QgsVectorLayer * itemLayer = NULL;
|
||||
int idNew = 0;
|
||||
for (int id = 0; id < targetLayerComboBox->count(); id++)
|
||||
for ( int id = 0; id < targetLayerComboBox->count(); id++ )
|
||||
{
|
||||
itemText = targetLayerComboBox->itemText(id);
|
||||
itemData = targetLayerComboBox->itemData(id);
|
||||
itemIcon = targetLayerComboBox->itemIcon(id);
|
||||
itemLayer = static_cast<QgsVectorLayer *>(itemData.value<void *>());
|
||||
if (itemLayer == mLayerTarget)
|
||||
itemText = targetLayerComboBox->itemText( id );
|
||||
itemData = targetLayerComboBox->itemData( id );
|
||||
itemIcon = targetLayerComboBox->itemIcon( id );
|
||||
itemLayer = static_cast<QgsVectorLayer *>( itemData.value<void *>() );
|
||||
if ( itemLayer == mLayerTarget )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
referenceLayerComboBox->addItem(itemIcon, itemText, itemData);
|
||||
referenceLayerComboBox->setItemData(idNew, QVariant(itemLayer->source()), Qt::ToolTipRole);
|
||||
referenceLayerComboBox->addItem( itemIcon, itemText, itemData );
|
||||
referenceLayerComboBox->setItemData( idNew, QVariant( itemLayer->source() ), Qt::ToolTipRole );
|
||||
idNew++;
|
||||
}
|
||||
int idCurrent = getIndexLayerCombobox(false, mLayerReference);
|
||||
if (idCurrent == -1)
|
||||
int idCurrent = getIndexLayerCombobox( false, mLayerReference );
|
||||
if ( idCurrent == -1 )
|
||||
{
|
||||
idCurrent = 0;
|
||||
}
|
||||
referenceLayerComboBox->setCurrentIndex(idCurrent);
|
||||
referenceLayerComboBox->blockSignals(false);
|
||||
referenceLayerComboBox->setCurrentIndex( idCurrent );
|
||||
referenceLayerComboBox->blockSignals( false );
|
||||
|
||||
} // QgsSpatialQueryDialog::populateReferenceLayerComboBox()
|
||||
|
||||
void QgsSpatialQueryDialog::populateOperationComboBox()
|
||||
{
|
||||
operantionComboBox->blockSignals(true);
|
||||
operantionComboBox->blockSignals( true );
|
||||
|
||||
if ( mLayerTarget == NULL || mLayerReference == NULL )
|
||||
{
|
||||
operantionComboBox->clear();
|
||||
operantionComboBox->blockSignals(true);
|
||||
operantionComboBox->blockSignals( true );
|
||||
}
|
||||
|
||||
QVariant currentValueItem;
|
||||
bool isStartEmpty = false;
|
||||
if (operantionComboBox->count() == 0)
|
||||
if ( operantionComboBox->count() == 0 )
|
||||
{
|
||||
isStartEmpty = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
currentValueItem = operantionComboBox->itemData(operantionComboBox->currentIndex());
|
||||
currentValueItem = operantionComboBox->itemData( operantionComboBox->currentIndex() );
|
||||
}
|
||||
|
||||
// Populate new values
|
||||
QMap<QString, int> * map = QgsSpatialQuery::getTypesOperations(mLayerTarget, mLayerReference);
|
||||
QMapIterator <QString, int> item(*map);
|
||||
QMap<QString, int> * map = QgsSpatialQuery::getTypesOperations( mLayerTarget, mLayerReference );
|
||||
QMapIterator <QString, int> item( *map );
|
||||
operantionComboBox->clear();
|
||||
while ( item.hasNext() )
|
||||
{
|
||||
item.next();
|
||||
operantionComboBox->addItem(item.key(), QVariant(item.value()));
|
||||
operantionComboBox->addItem( item.key(), QVariant( item.value() ) );
|
||||
}
|
||||
delete map;
|
||||
|
||||
// Set current item keeping the previous value
|
||||
int idCurrent = 0;
|
||||
if (!isStartEmpty)
|
||||
if ( !isStartEmpty )
|
||||
{
|
||||
idCurrent = operantionComboBox->findData(currentValueItem);
|
||||
if (idCurrent == -1)
|
||||
idCurrent = operantionComboBox->findData( currentValueItem );
|
||||
if ( idCurrent == -1 )
|
||||
{
|
||||
idCurrent = 0;
|
||||
}
|
||||
}
|
||||
operantionComboBox->setCurrentIndex(idCurrent);
|
||||
operantionComboBox->blockSignals(false);
|
||||
operantionComboBox->setCurrentIndex( idCurrent );
|
||||
operantionComboBox->blockSignals( false );
|
||||
|
||||
} // QgsSpatialQueryDialog::populateOperantionComboBox()
|
||||
|
||||
void QgsSpatialQueryDialog::populateQueryResult()
|
||||
{
|
||||
selectedFeatureListWidget->blockSignals(true);
|
||||
selectedFeatureListWidget->blockSignals( true );
|
||||
selectedFeatureListWidget->clear();
|
||||
selectedFeatureListWidget->setEnabled(false);
|
||||
selectedFeatureListWidget->setEnabled( false );
|
||||
|
||||
QSetIterator <int>item(mFeatureResult);
|
||||
QSetIterator <int>item( mFeatureResult );
|
||||
while ( item.hasNext() )
|
||||
{
|
||||
selectedFeatureListWidget->addItem(QString::number(item.next()));
|
||||
selectedFeatureListWidget->addItem( QString::number( item.next() ) );
|
||||
}
|
||||
selectedFeatureListWidget->setEnabled(true);
|
||||
selectedFeatureListWidget->setCurrentRow(0);
|
||||
selectedFeatureListWidget->blockSignals(false);
|
||||
selectedFeatureListWidget->setEnabled( true );
|
||||
selectedFeatureListWidget->setCurrentRow( 0 );
|
||||
selectedFeatureListWidget->blockSignals( false );
|
||||
|
||||
} // QgsSpatialQueryDialog::populateQueryResult()
|
||||
|
||||
//! Slots for signs of Dialog
|
||||
void QgsSpatialQueryDialog::on_buttonBox_accepted()
|
||||
{
|
||||
if ( ! mLayerReference )
|
||||
{
|
||||
if( ! mLayerReference )
|
||||
{
|
||||
QMessageBox::warning(0, tr("Missing reference layer"), tr("Select reference layer!"), QMessageBox::Ok);
|
||||
QMessageBox::warning( 0, tr( "Missing reference layer" ), tr( "Select reference layer!" ), QMessageBox::Ok );
|
||||
return;
|
||||
}
|
||||
if( ! mLayerTarget )
|
||||
if ( ! mLayerTarget )
|
||||
{
|
||||
QMessageBox::warning(0, tr("Missing target layer"), tr("Select target layer!"), QMessageBox::Ok);
|
||||
QMessageBox::warning( 0, tr( "Missing target layer" ), tr( "Select target layer!" ), QMessageBox::Ok );
|
||||
return;
|
||||
}
|
||||
|
||||
@ -572,7 +573,7 @@ void QgsSpatialQueryDialog::on_buttonBox_accepted()
|
||||
runQuery();
|
||||
QDateTime datetimeEnd = QDateTime::currentDateTime();
|
||||
|
||||
showResultQuery(&datetimeStart, &datetimeEnd);
|
||||
showResultQuery( &datetimeStart, &datetimeEnd );
|
||||
|
||||
} // QgsSpatialQueryDialog::on_buttonBox_accepted()
|
||||
|
||||
@ -582,84 +583,84 @@ void QgsSpatialQueryDialog::on_buttonBox_rejected()
|
||||
|
||||
} // void QgsSpatialQueryDialog::on_buttonBox_rejected()
|
||||
|
||||
void QgsSpatialQueryDialog::on_targetLayerComboBox_currentIndexChanged(int index)
|
||||
void QgsSpatialQueryDialog::on_targetLayerComboBox_currentIndexChanged( int index )
|
||||
{
|
||||
// Add old target layer in reference combobox
|
||||
addLayerCombobox(false, mLayerTarget);
|
||||
addLayerCombobox( false, mLayerTarget );
|
||||
|
||||
// Set target layer
|
||||
setLayer(true, index);
|
||||
evaluateCheckBox(true);
|
||||
setLayer( true, index );
|
||||
evaluateCheckBox( true );
|
||||
|
||||
// Remove new target layer in reference combobox
|
||||
removeLayer(false, mLayerTarget);
|
||||
removeLayer( false, mLayerTarget );
|
||||
|
||||
populateOperationComboBox();
|
||||
|
||||
} // QgsSpatialQueryDialog::on_targetLayerComboBox_currentIndexChanged(int index)
|
||||
|
||||
void QgsSpatialQueryDialog::on_referenceLayerComboBox_currentIndexChanged(int index)
|
||||
void QgsSpatialQueryDialog::on_referenceLayerComboBox_currentIndexChanged( int index )
|
||||
{
|
||||
setLayer(false, index);
|
||||
evaluateCheckBox(false);
|
||||
setLayer( false, index );
|
||||
evaluateCheckBox( false );
|
||||
|
||||
populateOperationComboBox();
|
||||
|
||||
} // QgsSpatialQueryDialog::on_referenceLayerComboBox_currentIndexChanged(int index);
|
||||
|
||||
void QgsSpatialQueryDialog::on_selectedFeatureListWidget_currentTextChanged(const QString& currentText)
|
||||
void QgsSpatialQueryDialog::on_selectedFeatureListWidget_currentTextChanged( const QString& currentText )
|
||||
{
|
||||
mRubberSelectId->reset();
|
||||
selectedFeatureListWidget->setEnabled(false);
|
||||
selectedFeatureListWidget->setEnabled( false );
|
||||
|
||||
QCursor cursor;
|
||||
cursor.setShape(Qt::WaitCursor);
|
||||
cursor.setShape( Qt::WaitCursor );
|
||||
Qt::CursorShape shapeCurrent = this->cursor().shape();
|
||||
this->setCursor(cursor);
|
||||
cursor.setShape(shapeCurrent);
|
||||
this->setCursor( cursor );
|
||||
cursor.setShape( shapeCurrent );
|
||||
|
||||
bool ok;
|
||||
int Id = currentText.toInt(&ok);
|
||||
mRubberSelectId->addFeature( mLayerTarget, Id);
|
||||
int Id = currentText.toInt( &ok );
|
||||
mRubberSelectId->addFeature( mLayerTarget, Id );
|
||||
|
||||
selectedFeatureListWidget->setEnabled(true);
|
||||
this->setCursor(cursor);
|
||||
selectedFeatureListWidget->setEnabled( true );
|
||||
this->setCursor( cursor );
|
||||
selectedFeatureListWidget->setFocus();
|
||||
mRubberSelectId->show();
|
||||
|
||||
} // QgsSpatialQueryDialog::on_selectedFeatureListWidget_currentTextChanged(const QString& currentText)
|
||||
} // QgsSpatialQueryDialog::on_selectedFeatureListWidget_currentTextChanged(const QString& currentText)
|
||||
|
||||
void QgsSpatialQueryDialog::on_showLogProcessingCheckBox_clicked(bool checked)
|
||||
void QgsSpatialQueryDialog::on_showLogProcessingCheckBox_clicked( bool checked )
|
||||
{
|
||||
showLogProcessing(checked);
|
||||
showLogProcessing( checked );
|
||||
|
||||
} // void QgsSpatialQueryDialog::on_showLogProcessingCheckBox_clicked(bool checked)
|
||||
|
||||
//! Slots for signs of QGIS
|
||||
void QgsSpatialQueryDialog::signal_qgis_layerWasAdded(QgsMapLayer* mapLayer)
|
||||
void QgsSpatialQueryDialog::signal_qgis_layerWasAdded( QgsMapLayer* mapLayer )
|
||||
{
|
||||
if( mapLayer->type() != QgsMapLayer::VectorLayer )
|
||||
if ( mapLayer->type() != QgsMapLayer::VectorLayer )
|
||||
{
|
||||
return;
|
||||
}
|
||||
QgsVectorLayer * vectorLayer = qobject_cast<QgsVectorLayer *>(mapLayer);
|
||||
if (!vectorLayer)
|
||||
QgsVectorLayer * vectorLayer = qobject_cast<QgsVectorLayer *>( mapLayer );
|
||||
if ( !vectorLayer )
|
||||
{
|
||||
return;
|
||||
}
|
||||
addLayerCombobox(true, vectorLayer);
|
||||
addLayerCombobox(false, vectorLayer);
|
||||
mMapIdVectorLayers.insert(vectorLayer->getLayerID(), vectorLayer);
|
||||
addLayerCombobox( true, vectorLayer );
|
||||
addLayerCombobox( false, vectorLayer );
|
||||
mMapIdVectorLayers.insert( vectorLayer->getLayerID(), vectorLayer );
|
||||
|
||||
// Verify is can enable buttonBox
|
||||
if( buttonBox->button(QDialogButtonBox::Ok)->isEnabled() == false && targetLayerComboBox->count() > 1)
|
||||
if ( buttonBox->button( QDialogButtonBox::Ok )->isEnabled() == false && targetLayerComboBox->count() > 1 )
|
||||
{
|
||||
buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
|
||||
buttonBox->button( QDialogButtonBox::Ok )->setEnabled( true );
|
||||
}
|
||||
|
||||
} // QgsSpatialQueryDialog::signal_qgis_layerWasAdded(QgsMapLayer* mapLayer)
|
||||
|
||||
void QgsSpatialQueryDialog::signal_qgis_layerWillBeRemoved(QString idLayer)
|
||||
void QgsSpatialQueryDialog::signal_qgis_layerWillBeRemoved( QString idLayer )
|
||||
{
|
||||
// If Frozen: the QGis can be: Exit, Add Project, New Project
|
||||
if ( mIface->mapCanvas()->isFrozen() )
|
||||
@ -668,26 +669,26 @@ void QgsSpatialQueryDialog::signal_qgis_layerWillBeRemoved(QString idLayer)
|
||||
}
|
||||
// idLayer = QgsMapLayer::getLayerID()
|
||||
// Get Pointer layer removed
|
||||
QMap<QString, QgsVectorLayer *>::const_iterator i = mMapIdVectorLayers.find(idLayer);
|
||||
if (i == mMapIdVectorLayers.end() )
|
||||
QMap<QString, QgsVectorLayer *>::const_iterator i = mMapIdVectorLayers.find( idLayer );
|
||||
if ( i == mMapIdVectorLayers.end() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
mMapIdVectorLayers.remove(idLayer);
|
||||
mMapIdVectorLayers.remove( idLayer );
|
||||
QgsVectorLayer *vectorLayer = i.value();
|
||||
removeLayer(true, vectorLayer); // set new target if need
|
||||
removeLayer(false, vectorLayer); // set new reference if need
|
||||
if ( mLayerTarget && getIndexLayerCombobox(referenceLayerComboBox, mLayerTarget) > -1)
|
||||
removeLayer( true, vectorLayer ); // set new target if need
|
||||
removeLayer( false, vectorLayer ); // set new reference if need
|
||||
if ( mLayerTarget && getIndexLayerCombobox( referenceLayerComboBox, mLayerTarget ) > -1 )
|
||||
{
|
||||
removeLayer(false, mLayerTarget);
|
||||
removeLayer( false, mLayerTarget );
|
||||
}
|
||||
|
||||
populateOperationComboBox();
|
||||
|
||||
if( targetLayerComboBox->count() < 2 )
|
||||
if ( targetLayerComboBox->count() < 2 )
|
||||
{
|
||||
buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||
textEditStatus->append(mMsgLayersLessTwo);
|
||||
buttonBox->button( QDialogButtonBox::Ok )->setEnabled( false );
|
||||
textEditStatus->append( mMsgLayersLessTwo );
|
||||
}
|
||||
|
||||
} // QgsSpatialQueryDialog::signal_qgis_layerWillBeRemoved(QString idLayer)
|
||||
@ -695,18 +696,18 @@ void QgsSpatialQueryDialog::signal_qgis_layerWillBeRemoved(QString idLayer)
|
||||
//! Slots for signals of Layers (Target or Reference)
|
||||
void QgsSpatialQueryDialog::signal_layerTarget_selectionFeaturesChanged()
|
||||
{
|
||||
evaluateCheckBox(true);
|
||||
evaluateCheckBox( true );
|
||||
|
||||
} // void QgsSpatialQueryDialog::signal_layerTarget_selectionFeaturesChanged()
|
||||
|
||||
void QgsSpatialQueryDialog::signal_layerReference_selectionFeaturesChanged()
|
||||
{
|
||||
evaluateCheckBox(false);
|
||||
evaluateCheckBox( false );
|
||||
|
||||
} // void QgsSpatialQueryDialog::signal_layerReference_selectionFeaturesChanged()
|
||||
|
||||
|
||||
void QgsSpatialQueryDialog::MsgDEBUG(QString sMSg)
|
||||
void QgsSpatialQueryDialog::MsgDEBUG( QString sMSg )
|
||||
{
|
||||
QMessageBox::warning(0, tr("DEBUG"), sMSg, QMessageBox::Ok);
|
||||
QMessageBox::warning( 0, tr( "DEBUG" ), sMSg, QMessageBox::Ok );
|
||||
}
|
||||
|
@ -34,13 +34,13 @@
|
||||
class QgsSpatialQueryDialog : public QDialog, private Ui::QgsSpatialQueryDialogBase
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
public:
|
||||
/**
|
||||
* Constructor for a dialog. The QgisInterface pointer is passed by
|
||||
* QGIS when it attempts to instantiate the plugin.
|
||||
* @param iface Pointer to the QgisInterface object.
|
||||
*/
|
||||
QgsSpatialQueryDialog(QWidget *parent = 0, QgisInterface* iface = 0);
|
||||
QgsSpatialQueryDialog( QWidget *parent = 0, QgisInterface* iface = 0 );
|
||||
//! Destructor
|
||||
~QgsSpatialQueryDialog();
|
||||
|
||||
@ -50,18 +50,18 @@ public:
|
||||
//! Unload plugins by QGIS - Disconnect signal from QGIS
|
||||
void disconnectQGis();
|
||||
|
||||
private slots:
|
||||
private slots:
|
||||
//! Slots for signs of Dialog
|
||||
void on_buttonBox_accepted();
|
||||
void on_buttonBox_rejected();
|
||||
void on_targetLayerComboBox_currentIndexChanged( int index );
|
||||
void on_referenceLayerComboBox_currentIndexChanged( int index );
|
||||
void on_selectedFeatureListWidget_currentTextChanged ( const QString& currentText );
|
||||
void on_showLogProcessingCheckBox_clicked(bool checked);
|
||||
void on_selectedFeatureListWidget_currentTextChanged( const QString& currentText );
|
||||
void on_showLogProcessingCheckBox_clicked( bool checked );
|
||||
|
||||
//! Slots for signs of QGIS
|
||||
void signal_qgis_layerWasAdded ( QgsMapLayer* mapLayer );
|
||||
void signal_qgis_layerWillBeRemoved ( QString idLayer );
|
||||
void signal_qgis_layerWasAdded( QgsMapLayer* mapLayer );
|
||||
void signal_qgis_layerWillBeRemoved( QString idLayer );
|
||||
|
||||
//! Slots for signs of Layers (Target or Reference)
|
||||
void signal_layerTarget_selectionFeaturesChanged();
|
||||
@ -79,11 +79,11 @@ private slots:
|
||||
//! Run Query
|
||||
void runQuery();
|
||||
//! Show Log Processing
|
||||
void showLogProcessing(bool hasShow);
|
||||
void showLogProcessing( bool hasShow );
|
||||
//! Show result of query
|
||||
void showResultQuery(QDateTime *datetimeStart, QDateTime *datetimeEnd);
|
||||
void showResultQuery( QDateTime *datetimeStart, QDateTime *datetimeEnd );
|
||||
//! Get Description Layer to show result
|
||||
QString getDescriptionLayerShow(bool isTarget);
|
||||
QString getDescriptionLayerShow( bool isTarget );
|
||||
//! Connect all slots
|
||||
void connectAll();
|
||||
//! Disconnect all slots
|
||||
@ -91,15 +91,15 @@ private slots:
|
||||
//! reject - override
|
||||
void reject();
|
||||
//! Get Vector layer from combobox
|
||||
QgsVectorLayer * getLayerFromCombobox(bool isTarget, int index);
|
||||
QgsVectorLayer * getLayerFromCombobox( bool isTarget, int index );
|
||||
//! Get Icon for vector layer
|
||||
QIcon getIconTypeGeometry(QGis::GeometryType geomType);
|
||||
QIcon getIconTypeGeometry( QGis::GeometryType geomType );
|
||||
//! Add layer in combobox (text, data and tooltips)
|
||||
void addLayerCombobox(bool isTarget, QgsVectorLayer* vectorLayer);
|
||||
void addLayerCombobox( bool isTarget, QgsVectorLayer* vectorLayer );
|
||||
//! Find Layer in combobox
|
||||
int getIndexLayerCombobox(bool isTarget, QgsVectorLayer* vectorLayer);
|
||||
int getIndexLayerCombobox( bool isTarget, QgsVectorLayer* vectorLayer );
|
||||
//! Remove layer in combobox and setting GUI
|
||||
void removeLayer(bool isTarget, QgsVectorLayer* lyrRemove);
|
||||
void removeLayer( bool isTarget, QgsVectorLayer* lyrRemove );
|
||||
//! Populates targetLayerComboBox with all layers
|
||||
void populateTargetLayerComboBox();
|
||||
//! Populates referenceLayerComboBox with all layers except the current target layer
|
||||
@ -125,7 +125,7 @@ private slots:
|
||||
// Menssage
|
||||
QString mMsgLayersLessTwo;
|
||||
|
||||
void MsgDEBUG(QString sMSg);
|
||||
void MsgDEBUG( QString sMSg );
|
||||
};
|
||||
|
||||
#endif // SPATIALQUERYDIALOG_H
|
||||
|
@ -57,9 +57,9 @@ static const QgisPlugin::PLUGINTYPE type_ = QgisPlugin::UI;
|
||||
* @param qgis Pointer to the QGIS main window
|
||||
* @parma mIface Pointer to the QGIS interface object
|
||||
*/
|
||||
QgsSpatialQueryPlugin::QgsSpatialQueryPlugin(QgisInterface* iface)
|
||||
:QgisPlugin( name_, description_, version_, type_ ),
|
||||
mIface(iface)
|
||||
QgsSpatialQueryPlugin::QgsSpatialQueryPlugin( QgisInterface* iface )
|
||||
: QgisPlugin( name_, description_, version_, type_ ),
|
||||
mIface( iface )
|
||||
{
|
||||
mDialog = NULL;
|
||||
}
|
||||
@ -76,18 +76,18 @@ QgsSpatialQueryPlugin::~QgsSpatialQueryPlugin()
|
||||
void QgsSpatialQueryPlugin::initGui()
|
||||
{
|
||||
// Create the action for tool
|
||||
mSpatialQueryAction = new QAction( QIcon(), tr("&Spatial Query"), this);
|
||||
mSpatialQueryAction = new QAction( QIcon(), tr( "&Spatial Query" ), this );
|
||||
|
||||
// Connect the action to the spatialQuery slot
|
||||
connect(mSpatialQueryAction, SIGNAL(activated()), this, SLOT(run()));
|
||||
connect( mSpatialQueryAction, SIGNAL( activated() ), this, SLOT( run() ) );
|
||||
|
||||
setCurrentTheme( "" );
|
||||
// this is called when the icon theme is changed
|
||||
connect( mIface, SIGNAL( currentThemeChanged( QString ) ), this, SLOT( setCurrentTheme( QString ) ) );
|
||||
|
||||
// Add the icon to the toolbar and to the plugin menu
|
||||
mIface->addToolBarIcon(mSpatialQueryAction);
|
||||
mIface->addPluginToMenu(tr("&Spatial Query"), mSpatialQueryAction);
|
||||
mIface->addToolBarIcon( mSpatialQueryAction );
|
||||
mIface->addPluginToMenu( tr( "&Spatial Query" ), mSpatialQueryAction );
|
||||
|
||||
}
|
||||
|
||||
@ -95,8 +95,8 @@ void QgsSpatialQueryPlugin::initGui()
|
||||
void QgsSpatialQueryPlugin::unload()
|
||||
{
|
||||
// remove the GUI
|
||||
mIface->removeToolBarIcon(mSpatialQueryAction);
|
||||
mIface->removePluginMenu(tr("&Spatial Query"), mSpatialQueryAction);
|
||||
mIface->removeToolBarIcon( mSpatialQueryAction );
|
||||
mIface->removePluginMenu( tr( "&Spatial Query" ), mSpatialQueryAction );
|
||||
|
||||
delete mSpatialQueryAction;
|
||||
|
||||
@ -104,14 +104,15 @@ void QgsSpatialQueryPlugin::unload()
|
||||
|
||||
void QgsSpatialQueryPlugin::run()
|
||||
{
|
||||
if (!mDialog){
|
||||
if(QgsMapLayerRegistry::instance()->mapLayers().size() < 2)
|
||||
if ( !mDialog )
|
||||
{
|
||||
if ( QgsMapLayerRegistry::instance()->mapLayers().size() < 2 )
|
||||
{
|
||||
QgsSpatialQueryDialog::messageLayersLessTwo();
|
||||
return;
|
||||
}
|
||||
mDialog = new QgsSpatialQueryDialog(mIface->mainWindow(), mIface);
|
||||
mDialog->setModal(false);
|
||||
mDialog = new QgsSpatialQueryDialog( mIface->mainWindow(), mIface );
|
||||
mDialog->setModal( false );
|
||||
mDialog->show();
|
||||
}
|
||||
else
|
||||
@ -133,7 +134,7 @@ void QgsSpatialQueryPlugin::run()
|
||||
//! Set icons to the current theme
|
||||
void QgsSpatialQueryPlugin::setCurrentTheme( QString )
|
||||
{
|
||||
mSpatialQueryAction->setIcon(getThemeIcon("/spatialquery.png"));
|
||||
mSpatialQueryAction->setIcon( getThemeIcon( "/spatialquery.png" ) );
|
||||
}
|
||||
|
||||
QIcon QgsSpatialQueryPlugin::getThemeIcon( const QString &theName )
|
||||
@ -142,19 +143,19 @@ QIcon QgsSpatialQueryPlugin::getThemeIcon( const QString &theName )
|
||||
{
|
||||
return QIcon( QgsApplication::activeThemePath() + "/plugins" + theName );
|
||||
}
|
||||
else if (QFile::exists(QgsApplication::defaultThemePath() + "/plugins" + theName ))
|
||||
else if ( QFile::exists( QgsApplication::defaultThemePath() + "/plugins" + theName ) )
|
||||
{
|
||||
return QIcon( QgsApplication::defaultThemePath() + "/plugins" + theName );
|
||||
}
|
||||
else
|
||||
{
|
||||
return QIcon(":/icons" + theName);
|
||||
return QIcon( ":/icons" + theName );
|
||||
}
|
||||
}
|
||||
|
||||
void QgsSpatialQueryPlugin::MsgDEBUG(QString sMSg)
|
||||
void QgsSpatialQueryPlugin::MsgDEBUG( QString sMSg )
|
||||
{
|
||||
QMessageBox::warning(0, tr("DEBUG"), sMSg, QMessageBox::Ok);
|
||||
QMessageBox::warning( 0, tr( "DEBUG" ), sMSg, QMessageBox::Ok );
|
||||
}
|
||||
|
||||
|
||||
@ -164,9 +165,9 @@ void QgsSpatialQueryPlugin::MsgDEBUG(QString sMSg)
|
||||
* of the plugin class
|
||||
*/
|
||||
// Class factory to return a new instance of the plugin class
|
||||
QGISEXTERN QgisPlugin* classFactory(QgisInterface* iface)
|
||||
QGISEXTERN QgisPlugin* classFactory( QgisInterface* iface )
|
||||
{
|
||||
return new QgsSpatialQueryPlugin(iface);
|
||||
return new QgsSpatialQueryPlugin( iface );
|
||||
}
|
||||
// Return the name of the plugin
|
||||
|
||||
@ -194,7 +195,7 @@ QGISEXTERN QString version()
|
||||
}
|
||||
|
||||
// Delete ourself
|
||||
QGISEXTERN void unload(QgisPlugin* theSpatialQueryPluginPointer)
|
||||
QGISEXTERN void unload( QgisPlugin* theSpatialQueryPluginPointer )
|
||||
{
|
||||
delete theSpatialQueryPluginPointer;
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ class QgsSpatialQueryPlugin: public QObject, public QgisPlugin
|
||||
* QGIS when it attempts to instantiate the plugin.
|
||||
* \param iface Pointer to the QgisInterface object.
|
||||
*/
|
||||
QgsSpatialQueryPlugin(QgisInterface* iface);
|
||||
QgsSpatialQueryPlugin( QgisInterface* iface );
|
||||
//! Destructor
|
||||
~QgsSpatialQueryPlugin();
|
||||
|
||||
@ -75,7 +75,7 @@ class QgsSpatialQueryPlugin: public QObject, public QgisPlugin
|
||||
QAction* mSpatialQueryAction;
|
||||
|
||||
|
||||
void MsgDEBUG(QString sMSg);
|
||||
void MsgDEBUG( QString sMSg );
|
||||
|
||||
};
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user