Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 committed Apr 5, 2006
1 parent 1026372 commit c0ebfa5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
41 changes: 21 additions & 20 deletions src/plugins/grass/qgsgrassedittools.cpp
Expand Up @@ -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 ) {
Expand Down Expand Up @@ -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 );
}
}
Expand Down
1 change: 1 addition & 0 deletions src/plugins/grass/qgsgrassedittools.h
Expand Up @@ -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);
Expand Down

0 comments on commit c0ebfa5

Please sign in to comment.