From: Artem Zhidkov Date: Tue, 18 May 2021 13:26:01 +0000 (+0300) Subject: Issue #24206: No plane for sketch X-Git-Tag: V9_8_0a1~46 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=db776cab8c3d7e0075e42255f2f38b02f82eef7e;p=modules%2Fshaper.git Issue #24206: No plane for sketch Invalidate values of the sketch normal if the plane was not selected. --- diff --git a/src/GeomData/GeomData_Dir.cpp b/src/GeomData/GeomData_Dir.cpp index 5d738511a..9d87844a3 100644 --- a/src/GeomData/GeomData_Dir.cpp +++ b/src/GeomData/GeomData_Dir.cpp @@ -83,12 +83,28 @@ void GeomData_Dir::reinit() } } +void GeomData_Dir::reset() +{ + if (myLab.FindAttribute(TDataStd_RealArray::GetID(), myCoords)) { + // invalidate values of the direction + myCoords->SetValue(0, 0.0); + myCoords->SetValue(1, 0.0); + myCoords->SetValue(2, 0.0); + } + GeomDataAPI_Dir::reset(); +} + bool GeomData_Dir::isInitialized() { // Check once again the direction is initialized. // Use case (bos #18905): draw a sketch, click "Change sketch plane", then abort it. // myIsInitialized value is dropped to false, thus recheck. - if (!myIsInitialized) - myIsInitialized = myLab.FindAttribute(TDataStd_RealArray::GetID(), myCoords) == Standard_True; + // Additionally verify the values are valid. + // Use case (bos #24206): start a sketch, highlight a coordinate plane, then click anywhere + // in empty space. Sketch features in menu appears and can be selected. + if (!myIsInitialized) { + myIsInitialized = myLab.FindAttribute(TDataStd_RealArray::GetID(), myCoords) == Standard_True + && myCoords->Value(0) != 0.0 && myCoords->Value(1) != 0.0 && myCoords->Value(2) != 0.0; + } return ModelAPI_Attribute::isInitialized(); } diff --git a/src/GeomData/GeomData_Dir.h b/src/GeomData/GeomData_Dir.h index 91b6cd086..1c53bb8c1 100644 --- a/src/GeomData/GeomData_Dir.h +++ b/src/GeomData/GeomData_Dir.h @@ -57,6 +57,9 @@ class GeomData_Dir : public GeomDataAPI_Dir /// Returns \c ture if the direction is initialized GEOMDATA_EXPORT virtual bool isInitialized(); + /// Resets attribute to default state. + GEOMDATA_EXPORT virtual void reset(); + protected: /// Initializes attributes GEOMDATA_EXPORT GeomData_Dir(TDF_Label& theLabel);