Skip to content

Commit 7fe35ac

Browse files
author
rblazek
committed
continue line after zoom; delete last segment before zoom
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@5178 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent df6922e commit 7fe35ac

File tree

2 files changed

+22
-20
lines changed

2 files changed

+22
-20
lines changed

src/plugins/grass/qgsgrassedittools.cpp

+21-20
Original file line numberDiff line numberDiff line change
@@ -110,32 +110,33 @@ QgsGrassEditNewLine::QgsGrassEditNewLine(QgsGrassEdit* edit, bool newBoundary)
110110

111111
void QgsGrassEditNewLine::deactivate()
112112
{
113-
// Write the line to vector
113+
// Delete last segment
114114
if ( e->mEditPoints->n_points > 1 ) {
115-
int type;
116-
117-
if ( mNewBoundary ) // boundary or line?
118-
type = GV_BOUNDARY;
119-
else
120-
type = GV_LINE;
121-
122-
int line;
123-
line = e->writeLine ( type, e->mEditPoints );
124-
e->updateSymb();
125-
e->displayUpdated();
126-
127-
if ( e->mAttributes ) delete e->mAttributes;
128-
e->mAttributes = new QgsGrassAttributes ( e, e->mProvider, line, e->mQgisApp );
129-
for ( int i = 0; i < e->mCats->n_cats; i++ ) {
130-
e->addAttributes ( e->mCats->field[i], e->mCats->cat[i] );
131-
}
132-
e->mAttributes->show();
115+
Vect_reset_line ( e->mPoints );
116+
Vect_append_points ( e->mPoints, e->mEditPoints, GV_FORWARD );
117+
e->displayDynamic ( e->mPoints );
133118
}
134119
e->setCanvasPropmt( QObject::tr("New vertex"), "", "");
135120

136121
QgsGrassEditTool::deactivate(); // call default bahivour
137122
}
138123

124+
void QgsGrassEditNewLine::activate()
125+
{
126+
std::cerr << "QgsGrassEditNewLine::activate()" << std::endl;
127+
128+
// Display dynamic segment
129+
if ( e->mEditPoints->n_points > 0 ) {
130+
Vect_reset_line ( e->mPoints );
131+
Vect_append_points ( e->mPoints, e->mEditPoints, GV_FORWARD );
132+
// TODO: how to get mouse position?
133+
//Vect_append_point ( e->mPoints, newPoint.x(), newPoint.y(), 0.0 );
134+
e->displayDynamic ( e->mPoints );
135+
}
136+
137+
QgsGrassEditTool::activate(); // call default bahivour
138+
}
139+
139140
void QgsGrassEditNewLine::mouseClick(QgsPoint & point, Qt::ButtonState button)
140141
{
141142
switch ( button ) {
@@ -190,7 +191,7 @@ void QgsGrassEditNewLine::mouseMove(QgsPoint & newPoint)
190191
// Draw the line with new segment
191192
Vect_reset_line ( e->mPoints );
192193
Vect_append_points ( e->mPoints, e->mEditPoints, GV_FORWARD );
193-
Vect_append_point ( e->mPoints, newPoint.x(), newPoint.y(), 0.0 ); // FIXME: [MD] cast to int was here... any reason?
194+
Vect_append_point ( e->mPoints, newPoint.x(), newPoint.y(), 0.0 );
194195
e->displayDynamic ( e->mPoints );
195196
}
196197
}

src/plugins/grass/qgsgrassedittools.h

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class QgsGrassEditNewLine : public QgsGrassEditTool
6363
public:
6464
QgsGrassEditNewLine(QgsGrassEdit* edit, bool newBoundary);
6565

66+
virtual void activate();
6667
virtual void deactivate();
6768

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

0 commit comments

Comments
 (0)