@@ -110,32 +110,33 @@ QgsGrassEditNewLine::QgsGrassEditNewLine(QgsGrassEdit* edit, bool newBoundary)
110
110
111
111
void QgsGrassEditNewLine::deactivate ()
112
112
{
113
- // Write the line to vector
113
+ // Delete last segment
114
114
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 );
133
118
}
134
119
e->setCanvasPropmt ( QObject::tr (" New vertex" ), " " , " " );
135
120
136
121
QgsGrassEditTool::deactivate (); // call default bahivour
137
122
}
138
123
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
+
139
140
void QgsGrassEditNewLine::mouseClick (QgsPoint & point, Qt::ButtonState button)
140
141
{
141
142
switch ( button ) {
@@ -190,7 +191,7 @@ void QgsGrassEditNewLine::mouseMove(QgsPoint & newPoint)
190
191
// Draw the line with new segment
191
192
Vect_reset_line ( e->mPoints );
192
193
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 );
194
195
e->displayDynamic ( e->mPoints );
195
196
}
196
197
}
0 commit comments