Skip to content
Permalink
Browse files

Updates from Luiz for spatial query plugin

git-svn-id: http://svn.osgeo.org/qgis/trunk@15301 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux
timlinux committed Mar 1, 2011
1 parent d0e4d4b commit 0b65851e64fa4212cfbdcc5b97bf762f86fe0875
@@ -16,18 +16,22 @@
* (at your option) any later version. *
* *
***************************************************************************/
/* $Id$ */
/* $Id: qgsrubberselectid.cpp 13377 2010-04-25 01:07:36Z jef $ */

#include "qgsrubberselectid.h"

#include "qgsfeature.h"

QgsRubberSelectId::QgsRubberSelectId( QgsMapCanvas* mapCanvas )
{
mIsPolygon = true;
mIsPolygon = false;
mMapCanvas = mapCanvas;
mRubberBand = new QgsRubberBand( mMapCanvas, mIsPolygon );

mColorRGB[0] = 255;
mColorRGB[1] = 0;
mColorRGB[2] = 0;
mWidth = 2;
setStyle();
} // QgsRubberSelectId::QgsRubberSelectId( QgsMapCanvas* mapCanvas, bool isPolygon = true )

QgsRubberSelectId::~QgsRubberSelectId()
@@ -37,47 +41,51 @@ QgsRubberSelectId::~QgsRubberSelectId()

} // QgsRubberSelectId::~QgsRubberSelectId()

void QgsRubberSelectId::isGeometryNotPolygon( bool isPolygon = false )
{
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::setStyle( int colorRed, int colorGreen, int colorBlue, int width )
{
QColor color = QColor( colorRed, colorGreen, colorBlue );
color.setAlpha( alfa );
mRubberBand->setColor( color );
mRubberBand->setWidth( width );

mColorRGB[0] = colorRed;
mColorRGB[1] = colorGreen;
mColorRGB[2] = colorBlue;
mWidth = width;
setStyle();
} // void QgsRubberSelectId::setColor(int colorRed, int colorGreen, int colorBlue, float alfa, width)

void QgsRubberSelectId::addFeature( QgsVectorLayer* mLayer, int fid )
void QgsRubberSelectId::addFeature( QgsVectorLayer* lyr, int fid )
{
bool isPolygon = ( lyr->geometryType() == QGis::Polygon );
if( mIsPolygon != isPolygon)
{
reset();
delete mRubberBand;
mIsPolygon = isPolygon;
mRubberBand = new QgsRubberBand( mMapCanvas, mIsPolygon );
setStyle();
}
QgsFeature feat;
if ( !mLayer->featureAtId( fid, feat, true, false ) )
if ( !lyr->featureAtId( fid, feat, true, false ) )
{
return;
}
if ( !feat.geometry() )
{
return;
}

mRubberBand->setToGeometry( feat.geometry(), mLayer );

mRubberBand->setToGeometry( feat.geometry(), lyr );
} // void QgsRubberSelectId::addFeature( QgsVectorLayer* mLayer, int Id )

void QgsRubberSelectId::show()
{
mRubberBand->show();
} // QgsRubberSelectId::show()

void QgsRubberSelectId::setStyle()
{
QColor color = QColor( mColorRGB[0], mColorRGB[1], mColorRGB[2] );
mRubberBand->setColor( color );
mRubberBand->setWidth( mWidth );
}
@@ -15,7 +15,7 @@
* (at your option) any later version. *
* *
***************************************************************************/
/* $Id$ */
/* $Id: qgsrubberselectid.h 13377 2010-04-25 01:07:36Z jef $ */

#ifndef QGSRUBBERSELECTID_H
#define QGSRUBBERSELECTID_H
@@ -41,12 +41,6 @@ class QgsRubberSelectId
*/
~QgsRubberSelectId();

/**
* \brief Set if is geometry polygon for rubber band
* \param isPolygon boolean for type geometry is polygon
*/
void isGeometryNotPolygon( bool isPolygon );

/**
* \brief Reset rubber band
*/
@@ -57,24 +51,28 @@ class QgsRubberSelectId
* \param colorRed integer for value red (0 - 255)
* \param colorGreen integer for value green (0 - 255)
* \param colorBlue integer for value blue (0 - 255)
* \param alfa float for transparent(0.0 - 1)
*/
void setColor( int colorRed, int colorGreen, int colorBlue, int width, float alfa );
void setStyle( int colorRed, int colorGreen, int colorBlue, int width);

/**
* \brief Create rubber band from geometry by feature
* \param mLayer pointer to QgsVectorLayer
* \param fid integer for ID for feature
*/
void addFeature( QgsVectorLayer* mLayer, int fid );
void addFeature( QgsVectorLayer* lyr, int fid );

/**
* \brief Show rubber band
*/
void show();
private:
//! Set Style
void setStyle();

//! RubberBand
QgsRubberBand* mRubberBand;
int mColorRGB[3];
int mWidth;
bool mIsPolygon;
QgsMapCanvas* mMapCanvas;
};

0 comments on commit 0b65851

Please sign in to comment.
You can’t perform that action at this time.