From: nds Date: Wed, 4 May 2016 06:18:42 +0000 (+0300) Subject: #1478 Fatal error when Create fixed constraint X-Git-Tag: V_2.3.0~51 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=458dc749f3c0253233d53e7f724d9a05cf33db5b;p=modules%2Fshaper.git #1478 Fatal error when Create fixed constraint --- diff --git a/src/ModuleBase/ModuleBase_WidgetValidated.cpp b/src/ModuleBase/ModuleBase_WidgetValidated.cpp index a5915e51f..98ba56f71 100644 --- a/src/ModuleBase/ModuleBase_WidgetValidated.cpp +++ b/src/ModuleBase/ModuleBase_WidgetValidated.cpp @@ -79,9 +79,9 @@ bool ModuleBase_WidgetValidated::isValidInFilters(const ModuleBase_ViewerPrsPtr& // creates a selection owner on the base of object shape and the object AIS object if (anOwner.IsNull() && thePrs->owner().IsNull() && thePrs->object().get()) { ResultPtr aResult = myWorkshop->selection()->getResult(thePrs); - if (aResult.get() && aResult->shape().get()) { - // some results have no shape, e.g. the parameter one. So, they should not be validated - GeomShapePtr aShape = aResult->shape(); + GeomShapePtr aShape = aResult.get() ? aResult->shape() : GeomShapePtr(); + // some results have no shape, e.g. the parameter one. So, they should not be validated + if (aShape.get()) { const TopoDS_Shape aTDShape = aShape->impl(); Handle(AIS_InteractiveObject) anIO = myWorkshop->selection()->getIO(thePrs); anOwner = new StdSelect_BRepOwner(aTDShape, anIO); @@ -244,52 +244,45 @@ void ModuleBase_WidgetValidated::blockAttribute(const AttributePtr& theAttribute //******************************************************************** void ModuleBase_WidgetValidated::storeValidState(const ModuleBase_ViewerPrsPtr& theValue, const bool theValid) { - if (theValid) { - GeomShapePtr aShape = theValue.get() ? theValue->shape() : GeomShapePtr(); - const TopoDS_Shape& aTDShape = aShape->impl(); - bool aValidPrsContains = aShape.get() && myValidPrs.IsBound(aTDShape) && - theValue.get()->isEqual(myValidPrs.Find(aTDShape).get()); - if (!aValidPrsContains) { -#ifdef LIST_OF_VALID_PRS - - myValidPrs.append(theValue); -#else - GeomShapePtr aShape = theValue->shape(); - if (aShape.get()) { - const TopoDS_Shape& aTDShape = aShape->impl(); + GeomShapePtr aShape = theValue.get() ? theValue->shape() : GeomShapePtr(); + if (aShape.get()) { + if (theValid) { + const TopoDS_Shape& aTDShape = aShape->impl(); + bool aValidPrsContains = myValidPrs.IsBound(aTDShape) && + theValue.get()->isEqual(myValidPrs.Find(aTDShape).get()); + if (!aValidPrsContains) { + #ifdef LIST_OF_VALID_PRS + myValidPrs.append(theValue); + #else myValidPrs.Bind(aTDShape, theValue); + #endif + // the commented code will be useful when the valid state of the presentation + // will be changable between activate/deactivate. Currently it does not happen. + //if (anInvalidPrs) + // myInvalidPrs.removeOne(theValue); } -#endif - // the commented code will be useful when the valid state of the presentation - // will be changable between activate/deactivate. Currently it does not happen. - //if (anInvalidPrs) - // myInvalidPrs.removeOne(theValue); } - } - else { // !theValid - GeomShapePtr aShape = theValue.get() ? theValue->shape() : GeomShapePtr(); - const TopoDS_Shape& aTDShape = aShape->impl(); - bool anIValidPrsContains = aShape.get() && myInvalidPrs.IsBound(aTDShape) && - theValue.get()->isEqual(myInvalidPrs.Find(aTDShape).get()); - - if (!anIValidPrsContains) { -#ifdef LIST_OF_VALID_PRS - myInvalidPrs.append(theValue); -#else - GeomShapePtr aShape = theValue->shape(); + else { // !theValid if (aShape.get()) { const TopoDS_Shape& aTDShape = aShape->impl(); - myInvalidPrs.Bind(aTDShape, theValue); + bool anIValidPrsContains = myInvalidPrs.IsBound(aTDShape) && + theValue.get()->isEqual(myInvalidPrs.Find(aTDShape).get()); + if (!anIValidPrsContains) { + #ifdef LIST_OF_VALID_PRS + myInvalidPrs.append(theValue); + #else + myInvalidPrs.Bind(aTDShape, theValue); + #endif + //if (!aValidPrs) + // myValidPrs.removeOne(theValue); + } } -#endif - //if (!aValidPrs) - // myValidPrs.removeOne(theValue); } } -#ifdef DEBUG_VALID_STATE - qDebug(QString("storeValidState: myValidPrs.size() = %1, myInvalidPrs.size() = %2").arg(myValidPrs.count()) - .arg(myInvalidPrs.count()).toStdString().c_str()); -#endif + #ifdef DEBUG_VALID_STATE + qDebug(QString("storeValidState: myValidPrs.size() = %1, myInvalidPrs.size() = %2").arg(myValidPrs.count()) + .arg(myInvalidPrs.count()).toStdString().c_str()); + #endif } //******************************************************************** @@ -303,19 +296,14 @@ bool ModuleBase_WidgetValidated::getValidState(const ModuleBase_ViewerPrsPtr& th bool anInvalidPrsContains = myInvalidPrs.contains(theValue); #else GeomShapePtr aShape = theValue.get() ? theValue->shape() : GeomShapePtr(); + if (!aShape.get()) + return false; + const TopoDS_Shape& aTDShape = aShape->impl(); - bool aValidPrsContains = aShape.get() && myValidPrs.IsBound(aTDShape) && + bool aValidPrsContains = myValidPrs.IsBound(aTDShape) && theValue.get()->isEqual(myValidPrs.Find(aTDShape).get()); - /*if (aShape.get() && myValidPrs.IsBound(aTDShape)) { - ModuleBase_ViewerPrs* aPrs1 = theValue.get(); - ModuleBase_ViewerPrs* aPrs2 = myValidPrs.Find(aTDShape).get(); - - bool isEqual2 = aPrs1->isEqual(aPrs2); - - bool aValue = 9; - }*/ - bool anInvalidPrsContains = aShape.get() && myInvalidPrs.IsBound(aTDShape) && + bool anInvalidPrsContains = myInvalidPrs.IsBound(aTDShape) && theValue.get()->isEqual(myInvalidPrs.Find(aTDShape).get()); /* bool aValidPrsContains = false, anInvalidPrsContains = false;