[QGIS Commit] r13360 - in trunk/qgis: debian
src/plugins/spatialquery
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Sat Apr 24 05:00:27 EDT 2010
Author: jef
Date: 2010-04-24 05:00:25 -0400 (Sat, 24 Apr 2010)
New Revision: 13360
Modified:
trunk/qgis/debian/changelog
trunk/qgis/debian/qgis.install
trunk/qgis/debian/rules
trunk/qgis/src/plugins/spatialquery/CMakeLists.txt
trunk/qgis/src/plugins/spatialquery/qgsgeometrycoordinatetransform.cpp
trunk/qgis/src/plugins/spatialquery/qgsgeometrycoordinatetransform.h
trunk/qgis/src/plugins/spatialquery/qgsmngprogressbar.cpp
trunk/qgis/src/plugins/spatialquery/qgsmngprogressbar.h
trunk/qgis/src/plugins/spatialquery/qgsreaderfeatures.cpp
trunk/qgis/src/plugins/spatialquery/qgsreaderfeatures.h
trunk/qgis/src/plugins/spatialquery/qgsrubberselectid.cpp
trunk/qgis/src/plugins/spatialquery/qgsrubberselectid.h
trunk/qgis/src/plugins/spatialquery/qgsspatialquery.cpp
trunk/qgis/src/plugins/spatialquery/qgsspatialquery.h
trunk/qgis/src/plugins/spatialquery/qgsspatialquerydialog.cpp
trunk/qgis/src/plugins/spatialquery/qgsspatialquerydialog.h
trunk/qgis/src/plugins/spatialquery/qgsspatialqueryplugin.cpp
trunk/qgis/src/plugins/spatialquery/qgsspatialqueryplugin.h
Log:
spatial query plugin: fix warnings, reindent, include in debian package
Modified: trunk/qgis/debian/changelog
===================================================================
--- trunk/qgis/debian/changelog 2010-04-24 08:28:07 UTC (rev 13359)
+++ trunk/qgis/debian/changelog 2010-04-24 09:00:25 UTC (rev 13360)
@@ -5,8 +5,9 @@
* 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 at norbit.de> Thu, 04 Feb 2010 23:20:29 +0100
+ -- Jürgen E. Fischer <jef at norbit.de> Sat, 24 Apr 2010 10:57:21 +0200
qgis (1.4.0) UNRELEASED; urgency=low
Modified: trunk/qgis/debian/qgis.install
===================================================================
--- trunk/qgis/debian/qgis.install 2010-04-24 08:28:07 UTC (rev 13359)
+++ trunk/qgis/debian/qgis.install 2010-04-24 09:00:25 UTC (rev 13360)
@@ -26,6 +26,7 @@
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
Modified: trunk/qgis/debian/rules
===================================================================
--- trunk/qgis/debian/rules 2010-04-24 08:28:07 UTC (rev 13359)
+++ trunk/qgis/debian/rules 2010-04-24 09:00:25 UTC (rev 13360)
@@ -10,7 +10,7 @@
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
Modified: trunk/qgis/src/plugins/spatialquery/CMakeLists.txt
===================================================================
--- trunk/qgis/src/plugins/spatialquery/CMakeLists.txt 2010-04-24 08:28:07 UTC (rev 13359)
+++ trunk/qgis/src/plugins/spatialquery/CMakeLists.txt 2010-04-24 09:00:25 UTC (rev 13360)
@@ -14,11 +14,6 @@
SET (SPATIALQUERY_MOC_HDRS
qgsspatialqueryplugin.h
qgsspatialquerydialog.h
- qgsspatialquery.h
- qgsreaderfeatures.h
- qgsrubberselectid.h
- qgsgeometrycoordinatetransform.h
- qgsmngprogressbar.h
)
SET( SPATIALQUERY_UIS qgsspatialquerydialogbase.ui)
Modified: trunk/qgis/src/plugins/spatialquery/qgsgeometrycoordinatetransform.cpp
===================================================================
--- trunk/qgis/src/plugins/spatialquery/qgsgeometrycoordinatetransform.cpp 2010-04-24 08:28:07 UTC (rev 13359)
+++ trunk/qgis/src/plugins/spatialquery/qgsgeometrycoordinatetransform.cpp 2010-04-24 09:00:25 UTC (rev 13360)
@@ -23,33 +23,33 @@
QgsGeometryCoordinateTransform::~QgsGeometryCoordinateTransform()
{
- delete mCoordTransform;
+ delete mCoordTransform;
} // 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();
+ // 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)
Modified: trunk/qgis/src/plugins/spatialquery/qgsgeometrycoordinatetransform.h
===================================================================
--- trunk/qgis/src/plugins/spatialquery/qgsgeometrycoordinatetransform.h 2010-04-24 08:28:07 UTC (rev 13359)
+++ trunk/qgis/src/plugins/spatialquery/qgsgeometrycoordinatetransform.h 2010-04-24 09:00:25 UTC (rev 13360)
@@ -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
Modified: trunk/qgis/src/plugins/spatialquery/qgsmngprogressbar.cpp
===================================================================
--- trunk/qgis/src/plugins/spatialquery/qgsmngprogressbar.cpp 2010-04-24 08:28:07 UTC (rev 13359)
+++ trunk/qgis/src/plugins/spatialquery/qgsmngprogressbar.cpp 2010-04-24 09:00:25 UTC (rev 13360)
@@ -19,32 +19,32 @@
#include "qgsmngprogressbar.h"
-MngProgressBar::MngProgressBar(QProgressBar *pb)
+MngProgressBar::MngProgressBar( QProgressBar *pb )
{
- mPb = pb;
- mPb->reset();
+ 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->reset();
+ 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->repaint();
+ mPb->setValue( step );
+ mPb->repaint();
} // void MngProgressBar::step()
Modified: trunk/qgis/src/plugins/spatialquery/qgsmngprogressbar.h
===================================================================
--- trunk/qgis/src/plugins/spatialquery/qgsmngprogressbar.h 2010-04-24 08:28:07 UTC (rev 13359)
+++ trunk/qgis/src/plugins/spatialquery/qgsmngprogressbar.h 2010-04-24 09:00:25 UTC (rev 13360)
@@ -27,39 +27,39 @@
*/
class MngProgressBar
{
-public:
+ public:
/**
* \brief Constructor for a MngProgressBar.
* \param pb Pointer to the MngProgressBar object.
*/
- MngProgressBar(QProgressBar *pb);
+ MngProgressBar( QProgressBar *pb );
/**
* \brief Destructor
*/
~MngProgressBar() { mPb->reset(); };
-
+
/**
* \brief Sets the progress bar's minimum and maximum values to minimum and maximum respectively
* \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;
-
+
};
#endif // QGSMNGPROGRESSBAR_H
Modified: trunk/qgis/src/plugins/spatialquery/qgsreaderfeatures.cpp
===================================================================
--- trunk/qgis/src/plugins/spatialquery/qgsreaderfeatures.cpp 2010-04-24 08:28:07 UTC (rev 13359)
+++ trunk/qgis/src/plugins/spatialquery/qgsreaderfeatures.cpp 2010-04-24 09:00:25 UTC (rev 13360)
@@ -1,88 +1,88 @@
-/***************************************************************************
- qgsreaderfeatures.cpp
- -------------------
- begin : Dec 29, 2009
- copyright : (C) 2009 by Diego Moreira And Luiz Motta
- email : moreira.geo at gmail.com And motta.luiz at gmail.com
-
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-/* $Id: $ */
-
-#include <qgsvectordataprovider.h>
-
-#include "qgsreaderfeatures.h"
-
-QgsReaderFeatures::QgsReaderFeatures(QgsVectorLayer *layer, bool useSelection)
-{
- mLayer = layer;
-
- initReader(useSelection);
-
-} // QgsReaderFeatures::QgsReaderFeatures(QgsVectorLayer *layer, bool useSelection)
-
-QgsReaderFeatures::~QgsReaderFeatures()
-{
- if ( mListSelectedFeature.count() > 0 )
- {
- mListSelectedFeature.clear();
- }
-
-} // QgsReaderFeatures::~QgsReaderFeatures()
-
-bool QgsReaderFeatures::nextFeature(QgsFeature & feature)
-{
- return (this->*mFuncNextFeature)(feature);
-
-} // bool QgsReaderFeatures::nextFeature(QgsFeature & feature)
-
-void QgsReaderFeatures::initReader(bool useSelection)
-{
- if ( useSelection )
- {
- mListSelectedFeature = mLayer->selectedFeatures();
- mIterSelectedFeature = mListSelectedFeature.begin();
- mFuncNextFeature = &QgsReaderFeatures::nextFeatureSelected;
- }
- else
- {
- QgsAttributeList attListGeom;
- int idGeom = 0;
- attListGeom.append(idGeom);
- mLayer->select(attListGeom, mLayer->extent(), true, false);
- mFuncNextFeature = &QgsReaderFeatures::nextFeatureTotal;
- }
-
-} // void QgsReaderFeatures::initReader()
-
-bool QgsReaderFeatures::nextFeatureTotal ( QgsFeature & feature )
-{
- return mLayer->dataProvider()->nextFeature(feature);
-
-} // bool QgsReaderFeatures::nextFeatureTotal ( QgsFeature & feature )
-
-bool QgsReaderFeatures::nextFeatureSelected ( QgsFeature & feature )
-{
- bool bReturn = true;
- if ( mIterSelectedFeature == mListSelectedFeature.end() )
- {
- bReturn = false;
- }
- else
- {
- feature = *mIterSelectedFeature;
- mIterSelectedFeature++;
- }
- return bReturn;
-
-} // bool QgsReaderFeatures::nextFeatureSelected( QgsFeature &feature )
-
-
+/***************************************************************************
+ qgsreaderfeatures.cpp
+ -------------------
+ begin : Dec 29, 2009
+ copyright : (C) 2009 by Diego Moreira And Luiz Motta
+ email : moreira.geo at gmail.com And motta.luiz at gmail.com
+
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+/* $Id: $ */
+
+#include <qgsvectordataprovider.h>
+
+#include "qgsreaderfeatures.h"
+
+QgsReaderFeatures::QgsReaderFeatures( QgsVectorLayer *layer, bool useSelection )
+{
+ mLayer = layer;
+
+ initReader( useSelection );
+
+} // QgsReaderFeatures::QgsReaderFeatures(QgsVectorLayer *layer, bool useSelection)
+
+QgsReaderFeatures::~QgsReaderFeatures()
+{
+ if ( mListSelectedFeature.count() > 0 )
+ {
+ mListSelectedFeature.clear();
+ }
+
+} // QgsReaderFeatures::~QgsReaderFeatures()
+
+bool QgsReaderFeatures::nextFeature( QgsFeature & feature )
+{
+ return ( this->*mFuncNextFeature )( feature );
+
+} // bool QgsReaderFeatures::nextFeature(QgsFeature & feature)
+
+void QgsReaderFeatures::initReader( bool useSelection )
+{
+ if ( useSelection )
+ {
+ mListSelectedFeature = mLayer->selectedFeatures();
+ mIterSelectedFeature = mListSelectedFeature.begin();
+ mFuncNextFeature = &QgsReaderFeatures::nextFeatureSelected;
+ }
+ else
+ {
+ QgsAttributeList attListGeom;
+ int idGeom = 0;
+ attListGeom.append( idGeom );
+ mLayer->select( attListGeom, mLayer->extent(), true, false );
+ mFuncNextFeature = &QgsReaderFeatures::nextFeatureTotal;
+ }
+
+} // void QgsReaderFeatures::initReader()
+
+bool QgsReaderFeatures::nextFeatureTotal( QgsFeature & feature )
+{
+ return mLayer->dataProvider()->nextFeature( feature );
+
+} // bool QgsReaderFeatures::nextFeatureTotal ( QgsFeature & feature )
+
+bool QgsReaderFeatures::nextFeatureSelected( QgsFeature & feature )
+{
+ bool bReturn = true;
+ if ( mIterSelectedFeature == mListSelectedFeature.end() )
+ {
+ bReturn = false;
+ }
+ else
+ {
+ feature = *mIterSelectedFeature;
+ mIterSelectedFeature++;
+ }
+ return bReturn;
+
+} // bool QgsReaderFeatures::nextFeatureSelected( QgsFeature &feature )
+
+
Modified: trunk/qgis/src/plugins/spatialquery/qgsreaderfeatures.h
===================================================================
--- trunk/qgis/src/plugins/spatialquery/qgsreaderfeatures.h 2010-04-24 08:28:07 UTC (rev 13359)
+++ trunk/qgis/src/plugins/spatialquery/qgsreaderfeatures.h 2010-04-24 09:00:25 UTC (rev 13360)
@@ -1,78 +1,78 @@
-/***************************************************************************
- qgsreaderfeatures.h
- -------------------
- begin : Dec 29, 2009
- copyright : (C) 2009 by Diego Moreira And Luiz Motta
- email : moreira.geo at gmail.com And motta.luiz at gmail.com
-
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-/* $Id: $ */
-#ifndef READERFEATURES_H
-#define READERFEATURES_H
-
-#include <qgsvectorlayer.h>
-#include <qgsfeature.h>
-
-/**
-* \class QgsReaderFeatures
-* \brief Reader Features
-*/
-class QgsReaderFeatures
-{
-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);
-
- /**
- * \brief Destructor
- */
- ~QgsReaderFeatures();
-
- /**
- * \brief Next feature
- * \param feature reference to next Feature.
- * \returns True if has next feature.
- */
- bool nextFeature(QgsFeature & feature);
-
-private:
- /**
- * \brief init Reader
- * \param useSelection Use or not use the features selected
- */
- 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);
-
- /**
- * \brief Next feature, using the features selected
- * \param feature reference to next Feature.
- * \returns True if has next feature.
- */
- bool nextFeatureSelected(QgsFeature & feature);
-
- QgsVectorLayer * mLayer;
- QgsFeatureList mListSelectedFeature;
- QList<QgsFeature>::iterator mIterSelectedFeature;
- bool (QgsReaderFeatures::* mFuncNextFeature) ( QgsFeature &);
-};
-
-#endif // READERFEATURES_H
+/***************************************************************************
+ qgsreaderfeatures.h
+ -------------------
+ begin : Dec 29, 2009
+ copyright : (C) 2009 by Diego Moreira And Luiz Motta
+ email : moreira.geo at gmail.com And motta.luiz at gmail.com
+
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+/* $Id: $ */
+#ifndef READERFEATURES_H
+#define READERFEATURES_H
+
+#include <qgsvectorlayer.h>
+#include <qgsfeature.h>
+
+/**
+* \class QgsReaderFeatures
+* \brief Reader Features
+*/
+class QgsReaderFeatures
+{
+ 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 );
+
+ /**
+ * \brief Destructor
+ */
+ ~QgsReaderFeatures();
+
+ /**
+ * \brief Next feature
+ * \param feature reference to next Feature.
+ * \returns True if has next feature.
+ */
+ bool nextFeature( QgsFeature & feature );
+
+ private:
+ /**
+ * \brief init Reader
+ * \param useSelection Use or not use the features selected
+ */
+ 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 );
+
+ /**
+ * \brief Next feature, using the features selected
+ * \param feature reference to next Feature.
+ * \returns True if has next feature.
+ */
+ bool nextFeatureSelected( QgsFeature & feature );
+
+ QgsVectorLayer * mLayer;
+ QgsFeatureList mListSelectedFeature;
+ QList<QgsFeature>::iterator mIterSelectedFeature;
+ bool ( QgsReaderFeatures::* mFuncNextFeature )( QgsFeature & );
+};
+
+#endif // READERFEATURES_H
Modified: trunk/qgis/src/plugins/spatialquery/qgsrubberselectid.cpp
===================================================================
--- trunk/qgis/src/plugins/spatialquery/qgsrubberselectid.cpp 2010-04-24 08:28:07 UTC (rev 13359)
+++ trunk/qgis/src/plugins/spatialquery/qgsrubberselectid.cpp 2010-04-24 09:00:25 UTC (rev 13360)
@@ -22,62 +22,62 @@
#include "qgsfeature.h"
-QgsRubberSelectId::QgsRubberSelectId( QgsMapCanvas* mapCanvas)
+QgsRubberSelectId::QgsRubberSelectId( QgsMapCanvas* mapCanvas )
{
- mIsPolygon = true;
- mMapCanvas = mapCanvas;
- mRubberBand = new QgsRubberBand( mMapCanvas, mIsPolygon );
+ mIsPolygon = true;
+ mMapCanvas = mapCanvas;
+ mRubberBand = new QgsRubberBand( mMapCanvas, mIsPolygon );
} // QgsRubberSelectId::QgsRubberSelectId( QgsMapCanvas* mapCanvas, bool isPolygon = true )
QgsRubberSelectId::~QgsRubberSelectId()
{
- reset();
- delete mRubberBand;
+ reset();
+ delete mRubberBand;
} // QgsRubberSelectId::~QgsRubberSelectId()
-void QgsRubberSelectId::isGeometryNotPolygon(bool isPolygon = false)
+void QgsRubberSelectId::isGeometryNotPolygon( bool isPolygon = false )
{
- reset();
- delete mRubberBand;
- mIsPolygon = isPolygon;
- mRubberBand = new QgsRubberBand( mMapCanvas, mIsPolygon );
+ reset();
+ delete mRubberBand;
+ mIsPolygon = isPolygon;
+ mRubberBand = new QgsRubberBand( mMapCanvas, mIsPolygon );
} // void QgsRubberSelectId::isGeometryNotPolygon(bool isPolygon)
void QgsRubberSelectId::reset()
{
- mRubberBand->reset( mIsPolygon );
+ mRubberBand->reset( mIsPolygon );
} // 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 );
- mRubberBand->setColor( color );
- mRubberBand->setWidth( width );
+ QColor color = QColor( colorRed, colorGreen, colorBlue );
+ color.setAlpha( alfa );
+ mRubberBand->setColor( color );
+ mRubberBand->setWidth( width );
} // void QgsRubberSelectId::setColor(int colorRed, int colorGreen, int colorBlue, float alfa, width)
void QgsRubberSelectId::addFeature( QgsVectorLayer* mLayer, int fid )
{
- QgsFeature feat;
- if ( !mLayer->featureAtId( fid, feat, true, false ) )
- {
- return;
- }
- if ( !feat.geometry() )
- {
- return;
- }
+ QgsFeature feat;
+ if ( !mLayer->featureAtId( fid, feat, true, false ) )
+ {
+ return;
+ }
+ if ( !feat.geometry() )
+ {
+ return;
+ }
- mRubberBand->setToGeometry( feat.geometry(), mLayer );
+ mRubberBand->setToGeometry( feat.geometry(), mLayer );
} // void QgsRubberSelectId::addFeature( QgsVectorLayer* mLayer, int Id )
void QgsRubberSelectId::show()
{
- mRubberBand->show();
+ mRubberBand->show();
} // QgsRubberSelectId::show()
Modified: trunk/qgis/src/plugins/spatialquery/qgsrubberselectid.h
===================================================================
--- trunk/qgis/src/plugins/spatialquery/qgsrubberselectid.h 2010-04-24 08:28:07 UTC (rev 13359)
+++ trunk/qgis/src/plugins/spatialquery/qgsrubberselectid.h 2010-04-24 09:00:25 UTC (rev 13360)
@@ -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 @@
* \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 @@
* \brief Show rubber band
*/
void show();
-private:
+ private:
//! RubberBand
QgsRubberBand* mRubberBand;
bool mIsPolygon;
Modified: trunk/qgis/src/plugins/spatialquery/qgsspatialquery.cpp
===================================================================
--- trunk/qgis/src/plugins/spatialquery/qgsspatialquery.cpp 2010-04-24 08:28:07 UTC (rev 13359)
+++ trunk/qgis/src/plugins/spatialquery/qgsspatialquery.cpp 2010-04-24 09:00:25 UTC (rev 13360)
@@ -25,163 +25,166 @@
#include "qgsgeometrycoordinatetransform.h"
#include "qgsspatialquery.h"
-QgsSpatialQuery::QgsSpatialQuery(MngProgressBar *pb)
+QgsSpatialQuery::QgsSpatialQuery( MngProgressBar *pb )
{
- mPb = pb;
- mUseTargetSelection = mUseReferenceSelection = false;
+ mPb = pb;
+ mUseTargetSelection = mUseReferenceSelection = false;
} // QgsSpatialQuery::QgsSpatialQuery(MngProgressBar *pb)
QgsSpatialQuery::~QgsSpatialQuery()
{
- delete mReaderFeaturesTarget;
+ delete mReaderFeaturesTarget;
} // QgsSpatialQuery::~QgsSpatialQuery()
-void QgsSpatialQuery::setSelectedFeaturesTarget(bool useSelected)
+void QgsSpatialQuery::setSelectedFeaturesTarget( bool useSelected )
{
- mUseTargetSelection = useSelected;
+ mUseTargetSelection = useSelected;
} // void QgsSpatialQuery::setSelectedFeaturesTarget(bool useSelected)
-void QgsSpatialQuery::setSelectedFeaturesReference(bool useSelected)
+void QgsSpatialQuery::setSelectedFeaturesReference( bool useSelected )
{
- mUseReferenceSelection = useSelected;
+ mUseReferenceSelection = useSelected;
} // 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%");
- int totalStep = mUseReferenceSelection
- ? mLayerReference->selectedFeatureCount()
- : (int) (mLayerReference->featureCount());
- mPb->init(1, totalStep);
- setSpatialIndexReference(); // Need set mLayerReference before
+ // Create Spatial index for Reference - Set mIndexReference
+ mPb->setFormat( "Processing 1/2 - %p%" );
+ int totalStep = mUseReferenceSelection
+ ? mLayerReference->selectedFeatureCount()
+ : ( int )( mLayerReference->featureCount() );
+ mPb->init( 1, totalStep );
+ setSpatialIndexReference(); // Need set mLayerReference before
- // Make Query
- mPb->setFormat("Processing 2/2 - %p%");
- totalStep = mUseTargetSelection
- ? mLayerTarget->selectedFeatureCount()
- : (int) (mLayerTarget->featureCount());
- mPb->init(1, totalStep);
+ // Make Query
+ mPb->setFormat( "Processing 2/2 - %p%" );
+ totalStep = mUseTargetSelection
+ ? mLayerTarget->selectedFeatureCount()
+ : ( 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
+ /* 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
- (P)oint, (L)ine and (A)rea
- Target Geometry(P,L,A) / Reference Geometry (P,L,A)
- dim -> Dimension of geometry
- Relations:
- 1) Intersects and Disjoint: All
- 2) Touches: P/L P/A L/L L/A A/A
- dimReference > dimTarget OR dimReference = dimTarget if dimReference > 0
- 3) Crosses: P/L P/A L/L L/A
- dimReference > dimTarget OR dimReference = dimTarget if dimReference = 1
- 4) Within: P/L P/A L/A A/A
- dimReference > dimTarget OR dimReference = dimTarget if dimReference = 2
- 5) Equals: P/P L/L A/A
- dimReference = dimTarget
- 6) Overlaps: P/P L/L A/A
- dimReference = dimTarget
- 7) Contains: L/P A/P A/L A/A
- dimReference < dimTarget OR dimReference = dimTarget if dimReference = 2
- */
+ (P)oint, (L)ine and (A)rea
+ Target Geometry(P,L,A) / Reference Geometry (P,L,A)
+ dim -> Dimension of geometry
+ Relations:
+ 1) Intersects and Disjoint: All
+ 2) Touches: P/L P/A L/L L/A A/A
+ dimReference > dimTarget OR dimReference = dimTarget if dimReference > 0
+ 3) Crosses: P/L P/A L/L L/A
+ dimReference > dimTarget OR dimReference = dimTarget if dimReference = 1
+ 4) Within: P/L P/A L/A A/A
+ dimReference > dimTarget OR dimReference = dimTarget if dimReference = 2
+ 5) Equals: P/P L/L A/A
+ dimReference = dimTarget
+ 6) Overlaps: P/P L/L A/A
+ dimReference = dimTarget
+ 7) Contains: L/P A/P A/L A/A
+ dimReference < dimTarget OR dimReference = dimTarget if dimReference = 2
+ */
- QMap<QString, int> * operations = new QMap<QString, int>;
- operations->insert(QObject::tr("Intersects"), Intersects);
- operations->insert(QObject::tr("Disjoint"), Disjoint);
+ QMap<QString, int> * operations = new QMap<QString, int>;
+ 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 );
+ }
+ else if ( dimReference < dimTarget )
+ {
+ 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("Touches"), Touches);
- operations->insert(QObject::tr("Crosses"), Crosses);
- operations->insert(QObject::tr("Within"), Within);
+ case 0:
+ break;
+ case 1:
+ 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 );
}
- else if (dimReference < dimTarget)
- {
- operations->insert(QObject::tr("Contains"), Contains);
- }
- else // dimReference == dimTarget
- {
- 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);
- break;
- case 2:
- operations->insert(QObject::tr("Touches"), Touches);
- operations->insert(QObject::tr("Within"), Within);
- operations->insert(QObject::tr("Contains"), Contains);
- }
- }
- return operations;
+ }
+ 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)
- {
+ int dimGeom = 0;
+ switch ( geomType )
+ {
case QGis::Point:
- dimGeom = 0;
- break;
+ dimGeom = 0;
+ break;
case QGis::Line:
- dimGeom = 1;
- break;
+ dimGeom = 1;
+ break;
case QGis::Polygon:
- dimGeom = 2;
- }
- return dimGeom;
+ 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);
- mLayerReference = layerReference;
+ mLayerTarget = layerTarget;
+ 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() )
{
- return false;
+ return false;
}
QgsGeometry *geom = feature.geometry();
if ( NULL == geom )
{
- return false;
+ return false;
}
GEOSGeometry *geomGeos = geom->asGeos();
- if ( GEOSisEmpty(geomGeos) || 1 != GEOSisValid(geomGeos))
+ if ( GEOSisEmpty( geomGeos ) || 1 != GEOSisValid( geomGeos ) )
{
- return false;
+ return false;
}
return true;
@@ -190,153 +193,153 @@
void QgsSpatialQuery::setSpatialIndexReference()
{
- QgsReaderFeatures * readerFeaturesReference = new QgsReaderFeatures(mLayerReference, mUseReferenceSelection);
- QgsFeature feature;
- int step = 1;
- while ( true )
+ 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++);
+ break;
+ }
+ mPb->step( step++ );
- if ( ! hasValidGeometry(feature) )
- {
- continue;
- }
-
- mIndexReference.insertFeature(feature);
+ if ( ! hasValidGeometry( feature ) )
+ {
+ continue;
}
- delete readerFeaturesReference;
+ 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)
- {
+ // Set function GEOS
+ char( *operation )( const GEOSGeometry *, const GEOSGeometry* );
+ switch ( relation )
+ {
case Disjoint:
- operation = &GEOSDisjoint;
- break;
+ operation = &GEOSDisjoint;
+ break;
case Equals:
- operation = &GEOSEquals;
- break;
+ operation = &GEOSEquals;
+ break;
case Touches:
- operation = &GEOSTouches;
- break;
+ operation = &GEOSTouches;
+ break;
case Overlaps:
- operation = &GEOSOverlaps;
- break;
+ operation = &GEOSOverlaps;
+ break;
case Within:
- operation = &GEOSWithin;
- break;
+ operation = &GEOSWithin;
+ break;
case Contains:
- operation = &GEOSContains;
- break;
+ operation = &GEOSContains;
+ break;
case Crosses:
- operation = &GEOSCrosses;
- break;
+ operation = &GEOSCrosses;
+ break;
case Intersects:
- operation = &GEOSIntersects;
- break;
- }
+ operation = &GEOSIntersects;
+ break;
+ }
- // Transform referencer Target = Reference
- QgsGeometryCoordinateTransform *coordinateTransform = new QgsGeometryCoordinateTransform();
- coordinateTransform->setCoordinateTransform(mLayerTarget, mLayerReference);
+ // Transform referencer Target = Reference
+ QgsGeometryCoordinateTransform *coordinateTransform = new QgsGeometryCoordinateTransform();
+ coordinateTransform->setCoordinateTransform( mLayerTarget, mLayerReference );
- // Set function for populate result
- void (QgsSpatialQuery::* funcPopulateIndexResult)
- (QSet<int> &, int, QgsGeometry *,
- char(*)(const GEOSGeometry *, const GEOSGeometry *) );
- funcPopulateIndexResult = ( relation == Disjoint )
- ? &QgsSpatialQuery::populateIndexResultDisjoint
- : &QgsSpatialQuery::populateIndexResult;
+ // Set function for populate result
+ void ( QgsSpatialQuery::* funcPopulateIndexResult )
+ ( QSet<int> &, int, QgsGeometry *,
+ char( * )( const GEOSGeometry *, const GEOSGeometry * ) );
+ funcPopulateIndexResult = ( relation == Disjoint )
+ ? &QgsSpatialQuery::populateIndexResultDisjoint
+ : &QgsSpatialQuery::populateIndexResult;
- QgsFeature featureTarget;
- QgsGeometry * geomTarget;
- int step = 1;
- while( true )
- {
- if ( ! mReaderFeaturesTarget->nextFeature(featureTarget) ) break;
+ QgsFeature featureTarget;
+ QgsGeometry * geomTarget;
+ int step = 1;
+ while ( true )
+ {
+ if ( ! mReaderFeaturesTarget->nextFeature( featureTarget ) ) break;
- mPb->step(step++);
+ mPb->step( step++ );
- if ( ! hasValidGeometry(featureTarget) )
- {
- continue;
- }
+ if ( ! hasValidGeometry( featureTarget ) )
+ {
+ continue;
+ }
- geomTarget = featureTarget.geometry();
- coordinateTransform->transform(geomTarget);
+ geomTarget = featureTarget.geometry();
+ coordinateTransform->transform( geomTarget );
- (this->*funcPopulateIndexResult)
- (qsetIndexResult, featureTarget.id(), geomTarget, operation);
- }
- delete coordinateTransform;
+ ( this->*funcPopulateIndexResult )
+ ( qsetIndexResult, featureTarget.id(), geomTarget, operation );
+ }
+ delete coordinateTransform;
} // QSet<int> QgsSpatialQuery::execQuery( QSet<int> & qsetIndexResult, int relation)
void QgsSpatialQuery::populateIndexResult(
- QSet<int> &qsetIndexResult, int idTarget, QgsGeometry * geomTarget,
- char(*operation)(const GEOSGeometry *, const GEOSGeometry *) )
+ QSet<int> &qsetIndexResult, int idTarget, QgsGeometry * geomTarget,
+ char( *operation )( const GEOSGeometry *, const GEOSGeometry * ) )
{
- QList<int> listIdReference;
- listIdReference = mIndexReference.intersects(geomTarget->boundingBox());
- if ( listIdReference.count() == 0 )
+ QList<int> listIdReference;
+ listIdReference = mIndexReference.intersects( geomTarget->boundingBox() );
+ if ( listIdReference.count() == 0 )
+ {
+ return;
+ }
+ GEOSGeometry * geosTarget = geomTarget->asGeos();
+ QgsFeature featureReference;
+ QgsGeometry * geomReference;
+ QList<int>::iterator iterIdReference = listIdReference.begin();
+ for ( ; iterIdReference != listIdReference.end(); iterIdReference++ )
+ {
+ mLayerReference->featureAtId( *iterIdReference, featureReference );
+ geomReference = featureReference.geometry();
+ if (( *operation )( geosTarget, geomReference->asGeos() ) == 1 )
{
- return;
+ qsetIndexResult.insert( idTarget );
+ break;
}
- GEOSGeometry * geosTarget = geomTarget->asGeos();
- QgsFeature featureReference;
- QgsGeometry * geomReference;
- QList<int>::iterator iterIdReference = listIdReference.begin();
- for( ; iterIdReference != listIdReference.end(); iterIdReference++ )
- {
- mLayerReference->featureAtId(*iterIdReference, featureReference);
- geomReference = featureReference.geometry();
- if( (*operation)(geosTarget, geomReference->asGeos()) == 1 )
- {
- qsetIndexResult.insert(idTarget);
- break;
- }
- }
+ }
} // void QgsSpatialQuery::populateIndexResult(...
void QgsSpatialQuery::populateIndexResultDisjoint(
- QSet<int> &qsetIndexResult, int idTarget, QgsGeometry * geomTarget,
- char(*operation)(const GEOSGeometry *, const GEOSGeometry *) )
+ QSet<int> &qsetIndexResult, int idTarget, QgsGeometry * geomTarget,
+ char( *operation )( const GEOSGeometry *, const GEOSGeometry * ) )
{
- QList<int> listIdReference;
- listIdReference = mIndexReference.intersects(geomTarget->boundingBox());
- if ( listIdReference.count() == 0 )
+ QList<int> listIdReference;
+ listIdReference = mIndexReference.intersects( geomTarget->boundingBox() );
+ if ( listIdReference.count() == 0 )
+ {
+ qsetIndexResult.insert( idTarget );
+ return;
+ }
+ GEOSGeometry * geosTarget = geomTarget->asGeos();
+ QgsFeature featureReference;
+ QgsGeometry * geomReference;
+ QList<int>::iterator iterIdReference = listIdReference.begin();
+ bool addIndex = true;
+ for ( ; iterIdReference != listIdReference.end(); iterIdReference++ )
+ {
+ mLayerReference->featureAtId( *iterIdReference, featureReference );
+ geomReference = featureReference.geometry();
+ if (( *operation )( geosTarget, geomReference->asGeos() ) == 0 )
{
- qsetIndexResult.insert(idTarget);
- return;
+ addIndex = false;
+ break;
}
- GEOSGeometry * geosTarget = geomTarget->asGeos();
- QgsFeature featureReference;
- QgsGeometry * geomReference;
- QList<int>::iterator iterIdReference = listIdReference.begin();
- bool addIndex = true;
- for( ; iterIdReference != listIdReference.end(); iterIdReference++ )
- {
- mLayerReference->featureAtId(*iterIdReference, featureReference);
- geomReference = featureReference.geometry();
- if( (*operation)(geosTarget, geomReference->asGeos()) == 0 )
- {
- addIndex = false;
- break;
- }
- }
- if ( addIndex )
- {
- qsetIndexResult.insert(idTarget);
- }
+ }
+ if ( addIndex )
+ {
+ qsetIndexResult.insert( idTarget );
+ }
} // void QgsSpatialQuery::populateIndexResultDisjoint( ...
Modified: trunk/qgis/src/plugins/spatialquery/qgsspatialquery.h
===================================================================
--- trunk/qgis/src/plugins/spatialquery/qgsspatialquery.h 2010-04-24 08:28:07 UTC (rev 13359)
+++ trunk/qgis/src/plugins/spatialquery/qgsspatialquery.h 2010-04-24 09:00:25 UTC (rev 13360)
@@ -35,14 +35,14 @@
*/
enum Topologic_Relation
{
- Intersects,
- Disjoint,
- Touches,
- Crosses,
- Within,
- Equals,
- Overlaps,
- Contains
+ Intersects,
+ Disjoint,
+ Touches,
+ Crosses,
+ Within,
+ Equals,
+ Overlaps,
+ Contains
};
@@ -53,12 +53,12 @@
*/
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 @@
* \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 @@
* \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 @@
* \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 @@
* \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
@@ -136,8 +136,8 @@
* \param operation Pointer to function of GEOS operation
*/
void populateIndexResult(
- QSet<int> & qsetIndexResult, int idTarget, QgsGeometry * geomTarget,
- char(*operation)(const GEOSGeometry *, const GEOSGeometry *) );
+ QSet<int> & qsetIndexResult, int idTarget, QgsGeometry * geomTarget,
+ char( *operation )( const GEOSGeometry *, const GEOSGeometry * ) );
/**
* \brief Populate index Result Disjoint
* \param qsetIndexResult Reference to QSet contains the result query
@@ -146,8 +146,8 @@
* \param operation Pointer to function of GEOS operation
*/
void populateIndexResultDisjoint(
- QSet<int> & qsetIndexResult, int idTarget, QgsGeometry * geomTarget,
- char(*operation)(const GEOSGeometry *, const GEOSGeometry *) );
+ QSet<int> & qsetIndexResult, int idTarget, QgsGeometry * geomTarget,
+ char( *operation )( const GEOSGeometry *, const GEOSGeometry * ) );
MngProgressBar *mPb;
bool mUseReferenceSelection;
Modified: trunk/qgis/src/plugins/spatialquery/qgsspatialquerydialog.cpp
===================================================================
--- trunk/qgis/src/plugins/spatialquery/qgsspatialquerydialog.cpp 2010-04-24 08:28:07 UTC (rev 13359)
+++ trunk/qgis/src/plugins/spatialquery/qgsspatialquerydialog.cpp 2010-04-24 09:00:25 UTC (rev 13360)
@@ -34,679 +34,680 @@
QgsSpatialQueryDialog::QgsSpatialQueryDialog( QWidget* parent, QgisInterface* iface ): QDialog( parent )
{
- setupUi( this );
+ setupUi( this );
- grpResults->hide();
- mLayerReference = mLayerTarget = NULL;
+ grpResults->hide();
+ mLayerReference = mLayerTarget = NULL;
- mIface = iface;
- mRubberSelectId = new QgsRubberSelectId( iface->mapCanvas() );
- setColorRubberSelectId();
+ mIface = iface;
+ mRubberSelectId = new QgsRubberSelectId( iface->mapCanvas() );
+ setColorRubberSelectId();
- initGui();
- connectAll();
+ 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 )
QgsSpatialQueryDialog::~QgsSpatialQueryDialog()
{
- disconnectAll();
- delete mRubberSelectId;
- mMapIdVectorLayers.clear();
- mFeatureResult.clear();
+ disconnectAll();
+ delete mRubberSelectId;
+ mMapIdVectorLayers.clear();
+ mFeatureResult.clear();
} // 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()
{
- disconnectAll();
+ disconnectAll();
} // void QgsSpatialQueryDialog::unload()
void QgsSpatialQueryDialog::initGui()
{
- showLogProcessing(false);
- grpResults->hide();
- buttonBox->button(QDialogButtonBox::Close)->hide();
+ showLogProcessing( false );
+ grpResults->hide();
+ buttonBox->button( QDialogButtonBox::Close )->hide();
- populateTargetLayerComboBox();
- if (targetLayerComboBox->count() > 1)
- {
- setLayer(true, 0);
- evaluateCheckBox(true);
- populateReferenceLayerComboBox();
- setLayer(false, 0);
- evaluateCheckBox(false);
- populateOperationComboBox();
- }
- else
- {
- buttonBox->setEnabled(false);
- textEditStatus->append(mMsgLayersLessTwo);
- }
+ populateTargetLayerComboBox();
+ if ( targetLayerComboBox->count() > 1 )
+ {
+ setLayer( true, 0 );
+ evaluateCheckBox( true );
+ populateReferenceLayerComboBox();
+ setLayer( false, 0 );
+ evaluateCheckBox( false );
+ populateOperationComboBox();
+ }
+ else
+ {
+ buttonBox->setEnabled( false );
+ textEditStatus->append( mMsgLayersLessTwo );
+ }
} // QgsSpatialQueryDialog::initGui()
void QgsSpatialQueryDialog::setColorRubberSelectId()
{
- int myRedInt, myGreenInt, myBlueInt;
- myRedInt = QgsProject::instance()->readNumEntry( "Gui", "/SelectionColorRedPart", 255 );
- myGreenInt = QgsProject::instance()->readNumEntry( "Gui", "/SelectionColorGreenPart", 255 );
- myBlueInt = QgsProject::instance()->readNumEntry( "Gui", "/SelectionColorBluePart", 0 );
+ int myRedInt, myGreenInt, myBlueInt;
+ myRedInt = QgsProject::instance()->readNumEntry( "Gui", "/SelectionColorRedPart", 255 );
+ 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)
- {
- disconnect(mLayerTarget, SIGNAL( selectionChanged()),
- this, SLOT( signal_layerTarget_selectionFeaturesChanged() ) );
- }
- mLayerTarget = getLayerFromCombobox(isTarget, index);
- connect(mLayerTarget, SIGNAL( selectionChanged()),
- this, SLOT( signal_layerTarget_selectionFeaturesChanged() ) );
+ if ( isTarget )
+ {
+ if ( mLayerTarget )
+ {
+ disconnect( mLayerTarget, SIGNAL( selectionChanged() ),
+ this, SLOT( signal_layerTarget_selectionFeaturesChanged() ) );
}
- else
+ mLayerTarget = getLayerFromCombobox( isTarget, index );
+ connect( mLayerTarget, SIGNAL( selectionChanged() ),
+ this, SLOT( signal_layerTarget_selectionFeaturesChanged() ) );
+ }
+ else
+ {
+ if ( mLayerReference )
{
- if (mLayerReference)
- {
- disconnect(mLayerReference, SIGNAL( selectionChanged()),
- this, SLOT( signal_layerReference_selectionFeaturesChanged() ) );
- }
- mLayerReference = getLayerFromCombobox(isTarget, index);
- connect(mLayerReference, SIGNAL( selectionChanged()),
- this, SLOT( signal_layerReference_selectionFeaturesChanged() ) );
+ disconnect( mLayerReference, SIGNAL( selectionChanged() ),
+ this, SLOT( signal_layerReference_selectionFeaturesChanged() ) );
}
-
+ 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)
- {
- layer = mLayerTarget;
- checkbox = usingSelectedTargetCheckBox;
- }
- else
- {
- layer = mLayerReference;
- checkbox = usingSelectedReferenceCheckBox;
- }
- int selectedCount = layer->selectedFeatureCount();
- bool isCheckBoxValid = ( layer != NULL && selectedCount > 0 );
- checkbox->setChecked(isCheckBoxValid);
- checkbox->setEnabled(isCheckBoxValid);
- QString textCheckBox = isCheckBoxValid
- ? QString::number(selectedCount) + " " + tr("Selected geometries")
- : tr("Selected geometries");
- checkbox->setText(textCheckBox);
+ QgsVectorLayer* layer = NULL;
+ QCheckBox* checkbox = NULL;
+ if ( isTarget )
+ {
+ layer = mLayerTarget;
+ checkbox = usingSelectedTargetCheckBox;
+ }
+ else
+ {
+ layer = mLayerReference;
+ checkbox = usingSelectedReferenceCheckBox;
+ }
+ int selectedCount = layer->selectedFeatureCount();
+ bool isCheckBoxValid = ( layer != NULL && selectedCount > 0 );
+ checkbox->setChecked( isCheckBoxValid );
+ checkbox->setEnabled( isCheckBoxValid );
+ QString textCheckBox = isCheckBoxValid
+ ? 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())
- {
- spatialQuery->setSelectedFeaturesTarget(true);
- }
- if (usingSelectedReferenceCheckBox->isChecked())
- {
- spatialQuery->setSelectedFeaturesReference(true);
- }
- progressBarStatus->setTextVisible(true);
- mFeatureResult.clear();
+ buttonBox->setEnabled( false );
+ MngProgressBar* pb = new MngProgressBar( progressBarStatus );
+ QgsSpatialQuery* spatialQuery = new QgsSpatialQuery( pb );
+ if ( usingSelectedTargetCheckBox->isChecked() )
+ {
+ spatialQuery->setSelectedFeaturesTarget( true );
+ }
+ if ( usingSelectedReferenceCheckBox->isChecked() )
+ {
+ spatialQuery->setSelectedFeaturesReference( 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);
- delete spatialQuery;
- delete pb;
+ int currentItem = operantionComboBox->currentIndex();
+ bool isOk;
+ 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();
+ grpResults->show();
+ grpInputs->hide();
+ progressBarStatus->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;
+ static int heightDialogNoStatus = 0;
- hasShow ? textEditStatus->show() : textEditStatus->hide();
- this->adjustSize();
+ hasShow ? textEditStatus->show() : textEditStatus->hide();
+ this->adjustSize();
- if ( ! hasShow )
+ if ( ! hasShow )
+ {
+ if ( heightDialogNoStatus == 0 )
{
- if ( heightDialogNoStatus == 0 )
- {
- heightDialogNoStatus = this->geometry().height();
- }
- else
- {
- this->setGeometry(this->geometry().x(), this->geometry().y(),
- this->geometry().width(), heightDialogNoStatus);
- }
+ heightDialogNoStatus = this->geometry().height();
}
+ else
+ {
+ 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()));
+ selectedFeatureListWidget->clear();
+ 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 )
- {
- populateQueryResult();
- mLayerTarget->setSelectedFeatures(mFeatureResult);
- evaluateCheckBox(true);
+ if ( mFeatureResult.size() > 0 )
+ {
+ populateQueryResult();
+ mLayerTarget->setSelectedFeatures( mFeatureResult );
+ evaluateCheckBox( true );
- QString sIdFeat = selectedFeatureListWidget->currentItem()->text();
- on_selectedFeatureListWidget_currentTextChanged(sIdFeat);
- }
- else
- {
- mRubberSelectId->reset();
- }
+ QString sIdFeat = selectedFeatureListWidget->currentItem()->text();
+ on_selectedFeatureListWidget_currentTextChanged( sIdFeat );
+ }
+ else
+ {
+ mRubberSelectId->reset();
+ }
} // 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)
- {
- layer = mLayerTarget;
- checkBox = usingSelectedTargetCheckBox;
- }
- else
- {
- layer = mLayerReference;
- checkBox = usingSelectedReferenceCheckBox;
- }
+ QgsVectorLayer* layer = NULL;
+ QCheckBox * checkBox = NULL;
+ if ( isTarget )
+ {
+ layer = mLayerTarget;
+ checkBox = usingSelectedTargetCheckBox;
+ }
+ else
+ {
+ layer = mLayerReference;
+ checkBox = usingSelectedReferenceCheckBox;
+ }
- QString sDescFeatures = checkBox->isChecked()
- ? tr("%1 of %2").arg(layer->selectedFeatureCount()).arg(layer->featureCount())
- : tr("all = %1").arg(layer->featureCount());
+ QString sDescFeatures = checkBox->isChecked()
+ ? 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) ),
- this, SLOT( signal_qgis_layerWillBeRemoved( QString ) ) );
- connect(showLogProcessingCheckBox, SIGNAL ( clicked() ),
- this, SLOT( on_showLogProcessingCheckBox_clicked(bool) ) );
+ 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 ) ) );
} // QgsSpatialQueryDialog::connectAll()
void QgsSpatialQueryDialog::disconnectAll()
{
- disconnect(QgsMapLayerRegistry::instance(), SIGNAL( layerWasAdded(QgsMapLayer*)),
- this, SLOT( signal_qgis_layerWasAdded(QgsMapLayer*) )) ;
- disconnect(QgsMapLayerRegistry::instance(), SIGNAL( layerWillBeRemoved( QString )),
- this, SLOT( signal_qgis_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()),
- this, SLOT( signal_layerTarget_selectionFeaturesChanged() ) );
+ if ( mLayerTarget )
+ {
+ disconnect( mLayerTarget, SIGNAL( selectionChanged() ),
+ this, SLOT( signal_layerTarget_selectionFeaturesChanged() ) );
- }
- if ( mLayerReference )
- {
- disconnect(mLayerReference, SIGNAL( selectionChanged()),
- this, SLOT( signal_layerReference_selectionFeaturesChanged() ) );
- }
+ }
+ if ( mLayerReference )
+ {
+ disconnect( mLayerReference, SIGNAL( selectionChanged() ),
+ this, SLOT( signal_layerReference_selectionFeaturesChanged() ) );
+ }
} // QgsSpatialQueryDialog::disconnectAll()
void QgsSpatialQueryDialog::reject()
{
- disconnectAll();
+ disconnectAll();
- mRubberSelectId->reset();
- mLayerTarget = mLayerReference = NULL;
- mFeatureResult.clear();
- mMapIdVectorLayers.clear();
+ mRubberSelectId->reset();
+ mLayerTarget = mLayerReference = NULL;
+ mFeatureResult.clear();
+ mMapIdVectorLayers.clear();
- QDialog::reject();
+ QDialog::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);
- QgsVectorLayer* lyr = static_cast<QgsVectorLayer*>( data.value<void *>() );
- return lyr;
+ QVariant data = isTarget
+ ? 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 )
- {
- theName = "/mIconPointLayer.png";
- }
- else if ( geomType == QGis::Line )
- {
- theName = "/mIconLineLayer.png";
- }
- else // Polygon
- {
- theName = "/mIconPolygonLayer.png";
- }
- // Copy from qgisapp.cpp
- QString myPreferredPath = QgsApplication::activeThemePath() + QDir::separator() + theName;
- QString myDefaultPath = QgsApplication::defaultThemePath() + QDir::separator() + theName;
- if ( QFile::exists( myPreferredPath ) )
- {
+ QString theName;
+ if ( geomType == QGis::Point )
+ {
+ theName = "/mIconPointLayer.png";
+ }
+ else if ( geomType == QGis::Line )
+ {
+ theName = "/mIconLineLayer.png";
+ }
+ else // Polygon
+ {
+ theName = "/mIconPolygonLayer.png";
+ }
+ // Copy from qgisapp.cpp
+ QString myPreferredPath = QgsApplication::activeThemePath() + QDir::separator() + theName;
+ QString myDefaultPath = QgsApplication::defaultThemePath() + QDir::separator() + theName;
+ if ( QFile::exists( myPreferredPath ) )
+ {
return QIcon( myPreferredPath );
- }
- else if ( QFile::exists( myDefaultPath ) )
- {
+ }
+ else if ( QFile::exists( myDefaultPath ) )
+ {
//could still return an empty icon if it
//doesnt exist in the default theme either!
return QIcon( myDefaultPath );
- }
- else
- {
+ }
+ else
+ {
return QIcon();
- }
+ }
} // 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);
- 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);
+ 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 );
} // 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);
- QComboBox * cmb = isTarget ? targetLayerComboBox : referenceLayerComboBox;
- return cmb->findData(item);
+ QVariant item = QVariant::fromValue(( void * )vectorLayer );
+ QComboBox * cmb = isTarget ? targetLayerComboBox : referenceLayerComboBox;
+ 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);
- // Remove Combobox
- int index = getIndexLayerCombobox(isTarget, lyrRemove);
- if(index > -1)
+ QComboBox * cmb = isTarget ? targetLayerComboBox : referenceLayerComboBox;
+ cmb->blockSignals( true );
+ // Remove Combobox
+ int index = getIndexLayerCombobox( isTarget, lyrRemove );
+ if ( index > -1 )
+ {
+ cmb->removeItem( index );
+ }
+ else
+ {
+ return;
+ }
+ // Set Layers (Target or Reference)
+ QgsVectorLayer* lyrThis = mLayerTarget;
+ if ( !isTarget )
+ {
+ lyrThis = mLayerReference;
+ }
+ if ( lyrRemove == lyrThis )
+ {
+ lyrThis = NULL;
+ if ( cmb->count() > 0 )
{
- cmb->removeItem(index);
+ cmb->setCurrentIndex( 0 );
+ setLayer( isTarget, 0 );
+ evaluateCheckBox( isTarget );
+ if ( isTarget )
+ {
+ selectedFeatureListWidget->blockSignals( true );
+ selectedFeatureListWidget->clear();
+ selectedFeatureListWidget->blockSignals( false );
+ countSelectedFeats->setText( tr( "Total" ) + ": 0" );
+ mRubberSelectId->reset();
+ }
}
- else
- {
- return;
- }
- // Set Layers (Target or Reference)
- QgsVectorLayer* lyrThis = mLayerTarget;
- if ( !isTarget )
- {
- lyrThis = mLayerReference;
- }
- if (lyrRemove == lyrThis)
- {
- lyrThis = NULL;
- if( cmb->count() > 0 )
- {
- cmb->setCurrentIndex(0);
- setLayer(isTarget, 0);
- evaluateCheckBox(isTarget);
- if (isTarget)
- {
- selectedFeatureListWidget->blockSignals(true);
- selectedFeatureListWidget->clear();
- 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);
- QgsMapLayer * mapLayer = NULL;
- QgsVectorLayer * vectorLayer = NULL;
- QString layerId;
- while ( item.hasNext() )
+ QMap <QString, QgsMapLayer*> map = QgsMapLayerRegistry::instance()->mapLayers();
+ QMapIterator <QString, QgsMapLayer*> item( map );
+ QgsMapLayer * mapLayer = NULL;
+ QgsVectorLayer * vectorLayer = NULL;
+ QString layerId;
+ while ( item.hasNext() )
+ {
+ item.next();
+ mapLayer = item.value();
+ if ( mapLayer->type() != QgsMapLayer::VectorLayer )
{
- item.next();
- mapLayer = item.value();
- if( mapLayer->type() != QgsMapLayer::VectorLayer )
- {
- continue;
- }
- vectorLayer = qobject_cast<QgsVectorLayer *>(mapLayer);
- if (!vectorLayer)
- {
- continue;
- }
-
- addLayerCombobox(true, vectorLayer);
- mMapIdVectorLayers.insert(vectorLayer->getLayerID(), vectorLayer);
+ continue;
}
- targetLayerComboBox->setCurrentIndex(0);
- targetLayerComboBox->blockSignals(false);
+ vectorLayer = qobject_cast<QgsVectorLayer *>( mapLayer );
+ if ( !vectorLayer )
+ {
+ continue;
+ }
+ addLayerCombobox( true, vectorLayer );
+ mMapIdVectorLayers.insert( vectorLayer->getLayerID(), vectorLayer );
+ }
+ targetLayerComboBox->setCurrentIndex( 0 );
+ targetLayerComboBox->blockSignals( false );
+
} // void QgsSpatialQueryDialog::populateTargetLayerComboBox()
void QgsSpatialQueryDialog::populateReferenceLayerComboBox()
{
- referenceLayerComboBox->blockSignals(true);
- referenceLayerComboBox->clear();
+ referenceLayerComboBox->blockSignals( true );
+ referenceLayerComboBox->clear();
- // Populate new values and Set current item keeping the previous value
- QString itemText;
- QVariant itemData;
- QIcon itemIcon;
- QgsVectorLayer * itemLayer = NULL;
- int idNew = 0;
- for (int id = 0; id < targetLayerComboBox->count(); id++)
+ // Populate new values and Set current item keeping the previous value
+ QString itemText;
+ QVariant itemData;
+ QIcon itemIcon;
+ QgsVectorLayer * itemLayer = NULL;
+ int idNew = 0;
+ 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);
- idNew++;
+ continue;
}
- int idCurrent = getIndexLayerCombobox(false, mLayerReference);
- if (idCurrent == -1)
- {
- idCurrent = 0;
- }
- referenceLayerComboBox->setCurrentIndex(idCurrent);
- referenceLayerComboBox->blockSignals(false);
+ referenceLayerComboBox->addItem( itemIcon, itemText, itemData );
+ referenceLayerComboBox->setItemData( idNew, QVariant( itemLayer->source() ), Qt::ToolTipRole );
+ idNew++;
+ }
+ int idCurrent = getIndexLayerCombobox( false, mLayerReference );
+ if ( idCurrent == -1 )
+ {
+ idCurrent = 0;
+ }
+ 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);
- }
+ if ( mLayerTarget == NULL || mLayerReference == NULL )
+ {
+ operantionComboBox->clear();
+ operantionComboBox->blockSignals( true );
+ }
- QVariant currentValueItem;
- bool isStartEmpty = false;
- if (operantionComboBox->count() == 0)
- {
- isStartEmpty = true;
- }
- else
- {
- currentValueItem = operantionComboBox->itemData(operantionComboBox->currentIndex());
- }
+ QVariant currentValueItem;
+ bool isStartEmpty = false;
+ if ( operantionComboBox->count() == 0 )
+ {
+ isStartEmpty = true;
+ }
+ else
+ {
+ currentValueItem = operantionComboBox->itemData( operantionComboBox->currentIndex() );
+ }
- // Populate new values
- 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()));
- }
- delete map;
+ // Populate new values
+ 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() ) );
+ }
+ delete map;
- // Set current item keeping the previous value
- int idCurrent = 0;
- if (!isStartEmpty)
+ // Set current item keeping the previous value
+ int idCurrent = 0;
+ if ( !isStartEmpty )
+ {
+ idCurrent = operantionComboBox->findData( currentValueItem );
+ if ( idCurrent == -1 )
{
- idCurrent = operantionComboBox->findData(currentValueItem);
- if (idCurrent == -1)
- {
- idCurrent = 0;
- }
+ idCurrent = 0;
}
- operantionComboBox->setCurrentIndex(idCurrent);
- operantionComboBox->blockSignals(false);
+ }
+ operantionComboBox->setCurrentIndex( idCurrent );
+ operantionComboBox->blockSignals( false );
} // QgsSpatialQueryDialog::populateOperantionComboBox()
void QgsSpatialQueryDialog::populateQueryResult()
{
- selectedFeatureListWidget->blockSignals(true);
- selectedFeatureListWidget->clear();
- selectedFeatureListWidget->setEnabled(false);
+ selectedFeatureListWidget->blockSignals( true );
+ selectedFeatureListWidget->clear();
+ selectedFeatureListWidget->setEnabled( false );
- QSetIterator <int>item(mFeatureResult);
- while ( item.hasNext() )
- {
- selectedFeatureListWidget->addItem(QString::number(item.next()));
- }
- selectedFeatureListWidget->setEnabled(true);
- selectedFeatureListWidget->setCurrentRow(0);
- selectedFeatureListWidget->blockSignals(false);
+ QSetIterator <int>item( mFeatureResult );
+ while ( item.hasNext() )
+ {
+ selectedFeatureListWidget->addItem( QString::number( item.next() ) );
+ }
+ selectedFeatureListWidget->setEnabled( true );
+ selectedFeatureListWidget->setCurrentRow( 0 );
+ selectedFeatureListWidget->blockSignals( false );
} // QgsSpatialQueryDialog::populateQueryResult()
//! Slots for signs of Dialog
void QgsSpatialQueryDialog::on_buttonBox_accepted()
- {
- if( ! mLayerReference )
- {
- QMessageBox::warning(0, tr("Missing reference layer"), tr("Select reference layer!"), QMessageBox::Ok);
- return;
- }
- if( ! mLayerTarget )
- {
- QMessageBox::warning(0, tr("Missing target layer"), tr("Select target layer!"), QMessageBox::Ok);
- return;
- }
+{
+ if ( ! mLayerReference )
+ {
+ QMessageBox::warning( 0, tr( "Missing reference layer" ), tr( "Select reference layer!" ), QMessageBox::Ok );
+ return;
+ }
+ if ( ! mLayerTarget )
+ {
+ QMessageBox::warning( 0, tr( "Missing target layer" ), tr( "Select target layer!" ), QMessageBox::Ok );
+ return;
+ }
- QDateTime datetimeStart = QDateTime::currentDateTime();
- runQuery();
- QDateTime datetimeEnd = QDateTime::currentDateTime();
+ QDateTime datetimeStart = QDateTime::currentDateTime();
+ runQuery();
+ QDateTime datetimeEnd = QDateTime::currentDateTime();
- showResultQuery(&datetimeStart, &datetimeEnd);
+ showResultQuery( &datetimeStart, &datetimeEnd );
} // QgsSpatialQueryDialog::on_buttonBox_accepted()
void QgsSpatialQueryDialog::on_buttonBox_rejected()
{
- reject();
+ reject();
} // 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);
+ // Add old target layer in reference combobox
+ addLayerCombobox( false, mLayerTarget );
- // Set target layer
- setLayer(true, index);
- evaluateCheckBox(true);
+ // Set target layer
+ setLayer( true, index );
+ evaluateCheckBox( true );
- // Remove new target layer in reference combobox
- removeLayer(false, mLayerTarget);
+ // Remove new target layer in reference combobox
+ removeLayer( false, mLayerTarget );
- populateOperationComboBox();
+ 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();
+ 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);
+ mRubberSelectId->reset();
+ selectedFeatureListWidget->setEnabled( false );
- QCursor cursor;
- cursor.setShape(Qt::WaitCursor);
- Qt::CursorShape shapeCurrent = this->cursor().shape();
- this->setCursor(cursor);
- cursor.setShape(shapeCurrent);
+ QCursor cursor;
+ cursor.setShape( Qt::WaitCursor );
+ Qt::CursorShape shapeCurrent = this->cursor().shape();
+ this->setCursor( cursor );
+ cursor.setShape( shapeCurrent );
- bool ok;
- int Id = currentText.toInt(&ok);
- mRubberSelectId->addFeature( mLayerTarget, Id);
+ bool ok;
+ int Id = currentText.toInt( &ok );
+ mRubberSelectId->addFeature( mLayerTarget, Id );
- selectedFeatureListWidget->setEnabled(true);
- this->setCursor(cursor);
- selectedFeatureListWidget->setFocus();
- mRubberSelectId->show();
+ 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 )
- {
- return;
- }
- QgsVectorLayer * vectorLayer = qobject_cast<QgsVectorLayer *>(mapLayer);
- if (!vectorLayer)
- {
- return;
- }
- addLayerCombobox(true, vectorLayer);
- addLayerCombobox(false, vectorLayer);
- mMapIdVectorLayers.insert(vectorLayer->getLayerID(), vectorLayer);
+ if ( mapLayer->type() != QgsMapLayer::VectorLayer )
+ {
+ return;
+ }
+ QgsVectorLayer * vectorLayer = qobject_cast<QgsVectorLayer *>( mapLayer );
+ if ( !vectorLayer )
+ {
+ return;
+ }
+ 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)
- {
- buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
- }
+ // Verify is can enable buttonBox
+ if ( buttonBox->button( QDialogButtonBox::Ok )->isEnabled() == false && targetLayerComboBox->count() > 1 )
+ {
+ 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() )
- {
- reject();
- }
- // idLayer = QgsMapLayer::getLayerID()
- // Get Pointer layer removed
- QMap<QString, QgsVectorLayer *>::const_iterator i = mMapIdVectorLayers.find(idLayer);
- if (i == mMapIdVectorLayers.end() )
- {
- return;
- }
- 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(false, mLayerTarget);
- }
+ // If Frozen: the QGis can be: Exit, Add Project, New Project
+ if ( mIface->mapCanvas()->isFrozen() )
+ {
+ reject();
+ }
+ // idLayer = QgsMapLayer::getLayerID()
+ // Get Pointer layer removed
+ QMap<QString, QgsVectorLayer *>::const_iterator i = mMapIdVectorLayers.find( idLayer );
+ if ( i == mMapIdVectorLayers.end() )
+ {
+ return;
+ }
+ 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( false, mLayerTarget );
+ }
- populateOperationComboBox();
+ populateOperationComboBox();
- if( targetLayerComboBox->count() < 2 )
- {
- buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
- textEditStatus->append(mMsgLayersLessTwo);
- }
+ if ( targetLayerComboBox->count() < 2 )
+ {
+ buttonBox->button( QDialogButtonBox::Ok )->setEnabled( false );
+ textEditStatus->append( mMsgLayersLessTwo );
+ }
} // 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 );
}
Modified: trunk/qgis/src/plugins/spatialquery/qgsspatialquerydialog.h
===================================================================
--- trunk/qgis/src/plugins/spatialquery/qgsspatialquerydialog.h 2010-04-24 08:28:07 UTC (rev 13359)
+++ trunk/qgis/src/plugins/spatialquery/qgsspatialquerydialog.h 2010-04-24 09:00:25 UTC (rev 13360)
@@ -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,24 +50,24 @@
//! 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();
void signal_layerReference_selectionFeaturesChanged();
- private:
+ private:
//! Initialize the Gui
void initGui();
//! Set Color mRubberSelectId
@@ -79,11 +79,11 @@
//! 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 @@
//! 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 @@
// Menssage
QString mMsgLayersLessTwo;
- void MsgDEBUG(QString sMSg);
+ void MsgDEBUG( QString sMSg );
};
#endif // SPATIALQUERYDIALOG_H
Modified: trunk/qgis/src/plugins/spatialquery/qgsspatialqueryplugin.cpp
===================================================================
--- trunk/qgis/src/plugins/spatialquery/qgsspatialqueryplugin.cpp 2010-04-24 08:28:07 UTC (rev 13359)
+++ trunk/qgis/src/plugins/spatialquery/qgsspatialqueryplugin.cpp 2010-04-24 09:00:25 UTC (rev 13360)
@@ -57,83 +57,84 @@
* @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;
+ mDialog = NULL;
}
QgsSpatialQueryPlugin::~QgsSpatialQueryPlugin()
{
- mIface = NULL;
- delete mSpatialQueryAction;
- delete mDialog;
+ mIface = NULL;
+ delete mSpatialQueryAction;
+ delete mDialog;
}
/*
* Initialize the GUI interface for the plugin
*/
void QgsSpatialQueryPlugin::initGui()
{
- // Create the action for tool
- mSpatialQueryAction = new QAction( QIcon(), tr("&Spatial Query"), this);
+ // Create the action for tool
+ mSpatialQueryAction = new QAction( QIcon(), tr( "&Spatial Query" ), this );
- // Connect the action to the spatialQuery slot
- connect(mSpatialQueryAction, SIGNAL(activated()), this, SLOT(run()));
+ // Connect the action to the spatialQuery slot
+ 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 ) ) );
+ 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);
+ // Add the icon to the toolbar and to the plugin menu
+ mIface->addToolBarIcon( mSpatialQueryAction );
+ mIface->addPluginToMenu( tr( "&Spatial Query" ), mSpatialQueryAction );
}
//Unload the plugin by cleaning up the GUI
void QgsSpatialQueryPlugin::unload()
{
- // remove the GUI
- mIface->removeToolBarIcon(mSpatialQueryAction);
- mIface->removePluginMenu(tr("&Spatial Query"), mSpatialQueryAction);
+ // remove the GUI
+ mIface->removeToolBarIcon( mSpatialQueryAction );
+ mIface->removePluginMenu( tr( "&Spatial Query" ), mSpatialQueryAction );
- delete mSpatialQueryAction;
+ delete mSpatialQueryAction;
}
void QgsSpatialQueryPlugin::run()
{
- if (!mDialog){
- if(QgsMapLayerRegistry::instance()->mapLayers().size() < 2)
- {
- QgsSpatialQueryDialog::messageLayersLessTwo();
- return;
- }
- mDialog = new QgsSpatialQueryDialog(mIface->mainWindow(), mIface);
- mDialog->setModal(false);
- mDialog->show();
+ if ( !mDialog )
+ {
+ if ( QgsMapLayerRegistry::instance()->mapLayers().size() < 2 )
+ {
+ QgsSpatialQueryDialog::messageLayersLessTwo();
+ return;
}
+ mDialog = new QgsSpatialQueryDialog( mIface->mainWindow(), mIface );
+ mDialog->setModal( false );
+ mDialog->show();
+ }
+ else
+ {
+ if ( !mDialog->isVisible() )
+ {
+ delete mDialog;
+ mDialog = NULL;
+ run();
+ }
else
{
- if ( !mDialog->isVisible() )
- {
- delete mDialog;
- mDialog = NULL;
- run();
- }
- else
- {
- mDialog->activateWindow();
- }
+ mDialog->activateWindow();
}
+ }
}
//! 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 @@
{
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 @@
* 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 @@
}
// Delete ourself
-QGISEXTERN void unload(QgisPlugin* theSpatialQueryPluginPointer)
+QGISEXTERN void unload( QgisPlugin* theSpatialQueryPluginPointer )
{
delete theSpatialQueryPluginPointer;
}
Modified: trunk/qgis/src/plugins/spatialquery/qgsspatialqueryplugin.h
===================================================================
--- trunk/qgis/src/plugins/spatialquery/qgsspatialqueryplugin.h 2010-04-24 08:28:07 UTC (rev 13359)
+++ trunk/qgis/src/plugins/spatialquery/qgsspatialqueryplugin.h 2010-04-24 09:00:25 UTC (rev 13360)
@@ -45,17 +45,17 @@
class QgsSpatialQueryPlugin: public QObject, public QgisPlugin
{
Q_OBJECT
- public:
+ public:
/**
* \brief Constructor for a plugin. The QgisInterface pointer is passed by
* QGIS when it attempts to instantiate the plugin.
* \param iface Pointer to the QgisInterface object.
*/
- QgsSpatialQueryPlugin(QgisInterface* iface);
+ QgsSpatialQueryPlugin( QgisInterface* iface );
//! Destructor
~QgsSpatialQueryPlugin();
- public slots:
+ public slots:
//! init the gui
void initGui();
//! unload the plugin
@@ -66,7 +66,7 @@
void setCurrentTheme( QString theThemeName );
QIcon getThemeIcon( const QString &theThemeName );
- private:
+ private:
QgsSpatialQueryDialog *mDialog;
//! Pointer to the QgisInterface object
@@ -75,7 +75,7 @@
QAction* mSpatialQueryAction;
- void MsgDEBUG(QString sMSg);
+ void MsgDEBUG( QString sMSg );
};
#endif
More information about the QGIS-commit
mailing list