Skip to content
Permalink
Browse files

continue line after zoom; delete last segment before zoom

git-svn-id: http://svn.osgeo.org/qgis/trunk@5178 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
rblazek
rblazek committed Apr 5, 2006
1 parent 1026372 commit c0ebfa52d88c4aec9cd7d96cc17256806066a58c
Showing with 22 additions and 20 deletions.
  1. +21 −20 src/plugins/grass/qgsgrassedittools.cpp
  2. +1 −0 src/plugins/grass/qgsgrassedittools.h
@@ -110,32 +110,33 @@ QgsGrassEditNewLine::QgsGrassEditNewLine(QgsGrassEdit* edit, bool newBoundary)

void QgsGrassEditNewLine::deactivate()
{
// Write the line to vector
// Delete last segment
if ( e->mEditPoints->n_points > 1 ) {
int type;

if ( mNewBoundary ) // boundary or line?
type = GV_BOUNDARY;
else
type = GV_LINE;

int line;
line = e->writeLine ( type, e->mEditPoints );
e->updateSymb();
e->displayUpdated();

if ( e->mAttributes ) delete e->mAttributes;
e->mAttributes = new QgsGrassAttributes ( e, e->mProvider, line, e->mQgisApp );
for ( int i = 0; i < e->mCats->n_cats; i++ ) {
e->addAttributes ( e->mCats->field[i], e->mCats->cat[i] );
}
e->mAttributes->show();
Vect_reset_line ( e->mPoints );
Vect_append_points ( e->mPoints, e->mEditPoints, GV_FORWARD );
e->displayDynamic ( e->mPoints );
}
e->setCanvasPropmt( QObject::tr("New vertex"), "", "");

QgsGrassEditTool::deactivate(); // call default bahivour
}

void QgsGrassEditNewLine::activate()
{
std::cerr << "QgsGrassEditNewLine::activate()" << std::endl;

// Display dynamic segment
if ( e->mEditPoints->n_points > 0 ) {
Vect_reset_line ( e->mPoints );
Vect_append_points ( e->mPoints, e->mEditPoints, GV_FORWARD );
// TODO: how to get mouse position?
//Vect_append_point ( e->mPoints, newPoint.x(), newPoint.y(), 0.0 );
e->displayDynamic ( e->mPoints );
}

QgsGrassEditTool::activate(); // call default bahivour
}

void QgsGrassEditNewLine::mouseClick(QgsPoint & point, Qt::ButtonState button)
{
switch ( button ) {
@@ -190,7 +191,7 @@ void QgsGrassEditNewLine::mouseMove(QgsPoint & newPoint)
// Draw the line with new segment
Vect_reset_line ( e->mPoints );
Vect_append_points ( e->mPoints, e->mEditPoints, GV_FORWARD );
Vect_append_point ( e->mPoints, newPoint.x(), newPoint.y(), 0.0 ); // FIXME: [MD] cast to int was here... any reason?
Vect_append_point ( e->mPoints, newPoint.x(), newPoint.y(), 0.0 );
e->displayDynamic ( e->mPoints );
}
}
@@ -63,6 +63,7 @@ class QgsGrassEditNewLine : public QgsGrassEditTool
public:
QgsGrassEditNewLine(QgsGrassEdit* edit, bool newBoundary);

virtual void activate();
virtual void deactivate();

virtual void mouseClick(QgsPoint & point, Qt::ButtonState button);

0 comments on commit c0ebfa5

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