Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
added rubberband for moveVertex
git-svn-id: http://svn.osgeo.org/qgis/trunk@4745 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Jan 25, 2006
1 parent 2f0e168 commit 56bb3c9
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 4 deletions.
39 changes: 35 additions & 4 deletions src/gui/qgsmapcanvas.cpp
Expand Up @@ -1629,9 +1629,25 @@ void QgsMapCanvas::mousePressEvent(QMouseEvent * e)
}

paint.end();
#else
#ifdef QGISDEBUG
qWarning("Creating rubber band for moveVertex");
#endif
mRubberBand2 = new QgsRubberBand(this, mPolygonEditing);
mRubberBand2->addPoint(QPoint(static_cast<int>(round(x1)), static_cast<int>(round(y1))));
mRubberBand2->addPoint(e->pos());
mRubberBand2->addPoint(QPoint(static_cast<int>(round(x2)), static_cast<int>(round(y2))));
QgsProject * project = QgsProject::instance();
QColor color(
project->readNumEntry("Digitizing", "/LineColorRedPart", 255),
project->readNumEntry("Digitizing", "/LineColorGreenPart", 0),
project->readNumEntry("Digitizing", "/LineColorBluePart", 0));
mRubberBand2->setColor(color);
int width = project->readNumEntry("Digitizing", "/LineWidth", 1);
mRubberBand2->setWidth(width);
mRubberBand2->show();
} // if snapVertexWithContext

#endif

break;
}
Expand Down Expand Up @@ -1799,6 +1815,7 @@ void QgsMapCanvas::mouseReleaseEvent(QMouseEvent * e)
paint.end();
#else
delete mRubberBand;
mRubberBand = 0;
#endif
// store the rectangle
mCanvasProperties->zoomBox.setRight(e->pos().x());
Expand Down Expand Up @@ -1834,6 +1851,7 @@ void QgsMapCanvas::mouseReleaseEvent(QMouseEvent * e)
paint.end();
#else
delete mRubberBand;
mRubberBand = 0;
#endif
// store the rectangle
mCanvasProperties->zoomBox.setRight(e->pos().x());
Expand Down Expand Up @@ -1899,6 +1917,7 @@ void QgsMapCanvas::mouseReleaseEvent(QMouseEvent * e)
paint.end();
#else
delete mRubberBand;
mRubberBand = 0;
#endif

QgsMapLayer *lyr = mCanvasProperties->mapLegend->currentLayer();
Expand Down Expand Up @@ -2153,6 +2172,7 @@ void QgsMapCanvas::mouseReleaseEvent(QMouseEvent * e)
mCanvasProperties->capturing = FALSE;
#if !(QT_VERSION < 0x040000)
delete mRubberBand2;
mRubberBand2 = 0;
#endif

//create QgsFeature with wkb representation
Expand Down Expand Up @@ -2348,6 +2368,9 @@ void QgsMapCanvas::mouseReleaseEvent(QMouseEvent * e)
paint.drawLine(mCanvasProperties->rubberStartPoint, mCanvasProperties->rubberMidPoint);
paint.drawLine(mCanvasProperties->rubberMidPoint, mCanvasProperties->rubberStopPoint);
paint.end();
#else
delete mRubberBand2;
mRubberBand2 = 0;
#endif

// Move the vertex
Expand All @@ -2373,14 +2396,14 @@ void QgsMapCanvas::mouseReleaseEvent(QMouseEvent * e)
point.x(), point.y(),
mCanvasProperties->snappedAtFeatureId,
mCanvasProperties->snappedAtVertex);
render();
update();

#ifdef QGISDEBUG
std::cout << "QgsMapCanvas::mouseReleaseEvent: Completed vlayer->moveVertexAt." << std::endl;
#endif
}
}
// TODO: Redraw?

}
break;
}

Expand Down Expand Up @@ -2587,6 +2610,14 @@ void QgsMapCanvas::mouseMoveEvent(QMouseEvent * e)
paint.drawLine(mCanvasProperties->rubberMidPoint, mCanvasProperties->rubberStopPoint);

paint.end();
#else
if(mRubberBand2)
{
#ifdef QGISDEBUG
qWarning("Moving rubber band for moveVertex");
#endif
mRubberBand2->movePoint(1, e->pos());
}
#endif

break;
Expand Down
6 changes: 6 additions & 0 deletions src/gui/qgsrubberband.cpp
Expand Up @@ -82,6 +82,12 @@ void QgsRubberBand::movePoint(const QPoint & p)
update();
}

void QgsRubberBand::movePoint(int index, const QPoint& p)
{
mPoints.setPoint(index, p);
update();
}

/*!
Draw the shape in response to an update event.
*/
Expand Down
1 change: 1 addition & 0 deletions src/gui/qgsrubberband.h
Expand Up @@ -34,6 +34,7 @@ class QgsRubberBand: public QWidget
void reset(bool isPolygon = false);
void addPoint(const QPoint & p);
void movePoint(const QPoint & p);
void movePoint(int index, const QPoint& p);

protected:
virtual void paintEvent(QPaintEvent * event);
Expand Down

0 comments on commit 56bb3c9

Please sign in to comment.