@@ -173,13 +173,23 @@ STDMETHODIMP CShapeEditor::get_ValidatedShape(IShape** retVal)
173173// *******************************************************
174174void CShapeEditor::CopyData (int firstIndex, int lastIndex, IShape* target )
175175{
176+ ShpfileType shpType;
177+ target->get_ShapeType (&shpType);
178+ bool haveZ = ShapeUtility::IsZ (shpType);
179+ bool haveM = ShapeUtility::HaveM (shpType);
176180 long index, partCount = 0 ;
177181 VARIANT_BOOL vb;
178182 for (int i = firstIndex; i < lastIndex; i++)
179183 {
180184 MeasurePoint* pnt = _activeShape->GetPoint (i);
181185 if (pnt) {
182186 target->AddPoint (pnt->Proj .x , pnt->Proj .y , &index);
187+ IPoint* pt;
188+ target->get_Point (index, &pt);
189+ if (haveZ)
190+ pt->put_Z (pnt->z );
191+ if (haveM)
192+ pt->put_M (pnt->m );
183193 if (pnt->Part == PartBegin) {
184194 target->InsertPart (i, &partCount, &vb);
185195 partCount++;
@@ -345,11 +355,13 @@ STDMETHODIMP CShapeEditor::StartEdit(LONG LayerHandle, LONG ShapeIndex, VARIANT_
345355 if (list) {
346356 list->get_UndoCount (&_startingUndoCount);
347357 }
348-
358+
359+ _startedEditOnInvalidShape = false ;
349360 CComPtr<IShape> shp = NULL ;
350361 sf->get_Shape (ShapeIndex, &shp);
351362 if (shp)
352363 {
364+ _startedEditOnInvalidShape = !Validate (&shp);
353365 put_EditorState (esEdit);
354366 SetShape (shp);
355367 _layerHandle = LayerHandle;
@@ -391,17 +403,28 @@ STDMETHODIMP CShapeEditor::SetShape( IShape* shp )
391403 }
392404
393405 VARIANT_BOOL vb;
394- double x, y;
406+ double x, y, z, m ;
395407 shp->get_NumPoints (&numPoints);
396408
409+ bool haveZ = ShapeUtility::IsZ (shpType);
410+ bool haveM = ShapeUtility::HaveM (shpType);
411+
397412 for (long i = 0 ; i < numPoints; i++)
398413 {
399414 PointPart part = PartNone;
400415 if (parts.find (i) != parts.end ()) part = PartBegin;
401416 if (endParts.find (i) != endParts.end ()) part = PartEnd;
402417
403418 shp->get_XY (i, &x, &y, &vb);
404- _activeShape->AddPoint (x, y, -1 , -1 , part);
419+ if (haveZ)
420+ shp->get_Z (i, &z, &vb);
421+ else
422+ z = 0.0 ;
423+ if (haveM)
424+ shp->get_M (i, &m, &vb);
425+ else
426+ m = 0.0 ;
427+ _activeShape->AddPoint (x, y, z, m, -1 , -1 , part);
405428 }
406429 return S_OK ;
407430}
@@ -717,11 +740,13 @@ STDMETHODIMP CShapeEditor::AddPoint(IPoint *newPoint, VARIANT_BOOL* retVal)
717740 get_IsDigitizing (&digitizing);
718741 tkCursorMode cursor = _mapCallback->_GetCursorMode ();
719742 if (digitizing) {
720- double x, y;
743+ double x, y, z, m ;
721744 newPoint->get_X (&x);
722745 newPoint->get_Y (&y);
746+ newPoint->get_Z (&z);
747+ newPoint->get_Z (&m);
723748 newPoint->Release ();
724- _activeShape->AddPoint (x, y, -1 , -1 , PartBegin);
749+ _activeShape->AddPoint (x, y, z, m, -1 , -1 , PartBegin);
725750 *retVal = VARIANT_TRUE ;
726751 return S_OK ;
727752 }
@@ -1167,6 +1192,8 @@ bool CShapeEditor::TryStop()
11671192
11681193 CComPtr<IShape> shp = NULL ;
11691194 get_ValidatedShape (&shp);
1195+ if (!shp && _startedEditOnInvalidShape ) // Invalid so get the invalid raw shape if we started with invalid shape (IK-379)
1196+ get_RawData (&shp);
11701197
11711198 switch (_state)
11721199 {
@@ -1183,8 +1210,9 @@ bool CShapeEditor::TryStop()
11831210 VARIANT_BOOL isEmpty;
11841211 get_IsEmpty (&isEmpty);
11851212 if (isEmpty) return true ;
1186- if (!shp) return false ;
1187- bool result = TrySaveShape (shp);
1213+ if (!shp && !_activeShape->AllowSaveInvalidGeometry ) return false ;
1214+ if ( shp ) // Only try to save if we have a shape (IK-379)
1215+ bool result = TrySaveShape (shp);
11881216 SetRedrawNeeded (rtVolatileLayer);
11891217 break ;
11901218 }
@@ -1277,8 +1305,9 @@ void CShapeEditor::HandleProjPointAdd(double projX, double projY)
12771305{
12781306 double pixelX, pixelY;
12791307 _mapCallback->_ProjectionToPixel (projX, projY, &pixelX, &pixelY);
1280- _activeShape->AddPoint (projX, projY, pixelX, pixelY);
1308+ _activeShape->AddPoint (projX, projY, 0.0 , 0.0 , pixelX, pixelY);
12811309 _activeShape->ClearSnapPoint ();
1310+ _mapCallback->_FireVertexAdded (&projX, &projY);
12821311}
12831312
12841313// ***************************************************************
@@ -1783,3 +1812,37 @@ STDMETHODIMP CShapeEditor::Deserialize(BSTR state, VARIANT_BOOL* retVal)
17831812
17841813 return S_OK ;
17851814}
1815+
1816+ // ***************************************************************
1817+ // EnableInsertVertex()
1818+ // ***************************************************************
1819+ STDMETHODIMP CShapeEditor::get_EnableInsertVertex (VARIANT_BOOL * pVal)
1820+ {
1821+ AFX_MANAGE_STATE (AfxGetStaticModuleState ());
1822+ *pVal = _activeShape->EnableInsertVertex ;
1823+ return S_OK ;
1824+ }
1825+
1826+ STDMETHODIMP CShapeEditor::put_EnableInsertVertex (VARIANT_BOOL newVal)
1827+ {
1828+ AFX_MANAGE_STATE (AfxGetStaticModuleState ());
1829+ _activeShape->EnableInsertVertex = newVal ? true : false ;
1830+ return S_OK ;
1831+ }
1832+
1833+ // ***************************************************************
1834+ // AllowSaveInvalidGeometry()
1835+ // ***************************************************************
1836+ STDMETHODIMP CShapeEditor::get_AllowSaveInvalidGeometry (VARIANT_BOOL * pVal)
1837+ {
1838+ AFX_MANAGE_STATE (AfxGetStaticModuleState ());
1839+ *pVal = _activeShape->AllowSaveInvalidGeometry ;
1840+ return S_OK ;
1841+ }
1842+
1843+ STDMETHODIMP CShapeEditor::put_AllowSaveInvalidGeometry (VARIANT_BOOL newVal)
1844+ {
1845+ AFX_MANAGE_STATE (AfxGetStaticModuleState ());
1846+ _activeShape->AllowSaveInvalidGeometry = newVal ? true : false ;
1847+ return S_OK ;
1848+ }
0 commit comments