33 , mIconType( ICON_CIRCLE )
34 , mGeometryType( geometryType )
35 , mTranslationOffsetX( 0.0 )
36 , mTranslationOffsetY( 0.0 )
38 reset( geometryType );
39 QColor color( Qt::lightGray );
50 , mIconType( ICON_CIRCLE )
51 , mTranslationOffsetX( 0.0 )
52 , mTranslationOffsetY( 0.0 )
55 QColor color( Qt::lightGray );
63 QgsRubberBand::QgsRubberBand()
66 , mIconType( ICON_CIRCLE )
67 , mGeometryType(
QGis::Polygon )
68 , mTranslationOffsetX( 0.0 )
69 , mTranslationOffsetY( 0.0 )
91 QColor fillColor( color.red(), color.green(), color.blue(), color.alpha() );
92 mBrush.setColor( fillColor );
100 QColor penColor( color.red(), color.green(), color.blue(), color.alpha() );
101 mPen.setColor( penColor );
110 mPen.setWidth( width );
120 mIconSize = iconSize;
125 mPen.setStyle( penStyle );
130 mBrush.setStyle( brushStyle );
139 mGeometryType = geometryType;
157 if ( geometryIndex < 0 )
159 geometryIndex = mPoints.size() - 1;
162 if ( geometryIndex < 0 || geometryIndex > mPoints.size() )
167 if ( geometryIndex == mPoints.size() )
169 mPoints.push_back( QList<QgsPoint>() << p );
172 if ( mPoints[geometryIndex].
size() == 2 &&
173 mPoints[geometryIndex][0] == mPoints[geometryIndex][1] )
175 mPoints[geometryIndex].last() = p;
179 mPoints[geometryIndex] << p;
195 if ( mPoints.size() < geometryIndex + 1 )
201 if ( mPoints[geometryIndex].
size() > 0 )
206 index = mPoints[geometryIndex].size() +
index;
208 mPoints[geometryIndex].removeAt( index );
228 if ( mPoints.size() < geometryIndex + 1 )
233 if ( mPoints.at( geometryIndex ).size() < 1 )
238 mPoints[geometryIndex].last() = p;
246 if ( mPoints.size() < geometryIndex + 1 )
251 if ( mPoints.at( geometryIndex ).size() <
index )
256 mPoints[geometryIndex][
index] = p;
266 reset( mGeometryType );
284 int idx = mPoints.size();
310 for (
int i = 0; i < mpt.size(); ++i, ++idx )
331 for (
int i = 0; i < line.count(); i++ )
350 for (
int i = 0; i < mline.size(); ++i, ++idx )
354 if ( line.size() == 0 )
359 for (
int j = 0; j < line.size(); ++j )
379 for (
int i = 0; i < line.count(); i++ )
398 for (
int i = 0; i < multipoly.size(); ++i, ++idx )
402 for (
int j = 0; j < line.count(); ++j )
452 if ( mPoints.size() > 0 )
454 p->setBrush( mBrush );
457 Q_FOREACH (
const QList<QgsPoint>& line, mPoints )
459 QVector<QPointF> pts;
460 Q_FOREACH (
const QgsPoint& pt, line )
463 if ( pts.empty() || std::abs( pts.back().x() - cur.x() ) > 1 || std::abs( pts.back().y() - cur.y() ) > 1 )
467 switch ( mGeometryType )
471 p->drawPolygon( pts );
477 Q_FOREACH (
const QPointF& pt, pts )
482 qreal s = ( mIconSize - 1 ) / 2.0;
490 p->drawLine( QLineF( x - s, y, x + s, y ) );
491 p->drawLine( QLineF( x, y - s, x, y + s ) );
495 p->drawLine( QLineF( x - s, y - s, x + s, y + s ) );
496 p->drawLine( QLineF( x - s, y + s, x + s, y - s ) );
500 p->drawLine( QLineF( x - s, y - s, x + s, y - s ) );
501 p->drawLine( QLineF( x + s, y - s, x + s, y + s ) );
502 p->drawLine( QLineF( x + s, y + s, x - s, y + s ) );
503 p->drawLine( QLineF( x - s, y + s, x - s, y - s ) );
507 p->drawRect( x - s, y - s, mIconSize, mIconSize );
511 p->drawEllipse( x - s, y - s, mIconSize, mIconSize );
521 p->drawPolyline( pts );
531 if ( mPoints.empty() )
541 qreal w = ( ( mIconSize - 1 ) / 2 + mPen.width() ) / res;
544 for (
int i = 0; i < mPoints.size(); ++i )
546 QList<QgsPoint>::const_iterator it = mPoints.at( i ).constBegin(),
547 itE = mPoints.at( i ).constEnd();
548 for ( ; it != itE; ++it )
550 QgsPoint p( it->x() + mTranslationOffsetX, it->y() + mTranslationOffsetY );
586 mTranslationOffsetX = dx;
587 mTranslationOffsetY = dy;
593 return mPoints.size();
598 if ( geometryIndex < 0 || geometryIndex >= mPoints.size() )
return 0;
599 return mPoints[geometryIndex].size();
605 QList<QList<QgsPoint> >::const_iterator it = mPoints.constBegin();
606 for ( ; it != mPoints.constEnd(); ++it )
608 QList<QgsPoint>::const_iterator iter = it->constBegin();
609 for ( ; iter != it->constEnd(); ++iter )
619 if ( i < mPoints.size() && j < mPoints[i].size() )
620 return &mPoints[i][j];
629 switch ( mGeometryType )
634 QList< QList<QgsPoint> >::const_iterator it = mPoints.constBegin();
635 for ( ; it != mPoints.constEnd(); ++it )
637 polygon.append( getPolyline( *it ) );
647 QList< QList<QgsPoint> >::const_iterator it = mPoints.constBegin();
648 for ( ; it != mPoints.constEnd(); ++it )
650 multiPoint += getPolyline( *it );
659 if ( mPoints.size() > 0 )
661 if ( mPoints.size() > 1 )
664 QList< QList<QgsPoint> >::const_iterator it = mPoints.constBegin();
665 for ( ; it != mPoints.constEnd(); ++it )
667 multiPolyline.append( getPolyline( *it ) );
682 QgsPolyline QgsRubberBand::getPolyline(
const QList<QgsPoint> & points )
685 QList<QgsPoint>::const_iterator iter = points.constBegin();
686 for ( ; iter != points.constEnd(); ++iter )
688 polyline.append( *iter );