From: nds Date: Mon, 4 Apr 2016 13:22:25 +0000 (+0300) Subject: Issue #1343. Improvement of Extrusion and Revolution operations: Bug correction:... X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e8dee7c7fb83975c3547671fb49fee16a64f6556;p=modules%2Fshaper.git Issue #1343. Improvement of Extrusion and Revolution operations: Bug correction: Open saved study, activate part, start extrusion, Crash. Additionaly the validation for attribute selection is called in widget sketch creator. --- diff --git a/src/ModuleBase/ModuleBase_WidgetSelector.cpp b/src/ModuleBase/ModuleBase_WidgetSelector.cpp index 28f94ae02..5dc76b164 100755 --- a/src/ModuleBase/ModuleBase_WidgetSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetSelector.cpp @@ -175,8 +175,7 @@ bool ModuleBase_WidgetSelector::setSelectionCustom(const ModuleBase_ViewerPrs& t GeomShapePtr aShape; getGeomSelection(thePrs, anObject, aShape); - AttributePtr anAttribute = myFeature->data()->attribute(attributeID()); - ModuleBase_Tools::setObject(anAttribute, anObject, aShape, myWorkshop, false); + ModuleBase_Tools::setObject(attributeToValidate(), anObject, aShape, myWorkshop, false); return true; } diff --git a/src/ModuleBase/ModuleBase_WidgetValidated.cpp b/src/ModuleBase/ModuleBase_WidgetValidated.cpp index fd41a85f5..be322691a 100644 --- a/src/ModuleBase/ModuleBase_WidgetValidated.cpp +++ b/src/ModuleBase/ModuleBase_WidgetValidated.cpp @@ -57,21 +57,14 @@ void ModuleBase_WidgetValidated::clearValidatedCash() void ModuleBase_WidgetValidated::storeAttributeValue() { myIsInValidate = true; - DataPtr aData = myFeature->data(); - AttributePtr anAttribute = myFeature->attribute(attributeID()); - - myAttributeStore->storeAttributeValue(anAttribute, myWorkshop); + myAttributeStore->storeAttributeValue(attributeToValidate(), myWorkshop); } //******************************************************************** void ModuleBase_WidgetValidated::restoreAttributeValue(const bool theValid) { myIsInValidate = false; - - DataPtr aData = myFeature->data(); - AttributePtr anAttribute = myFeature->attribute(attributeID()); - - myAttributeStore->restoreAttributeValue(anAttribute, myWorkshop); + myAttributeStore->restoreAttributeValue(attributeToValidate(), myWorkshop); } //******************************************************************** @@ -124,6 +117,12 @@ bool ModuleBase_WidgetValidated::isValidInFilters(const ModuleBase_ViewerPrs& th return aValid; } +//******************************************************************** +AttributePtr ModuleBase_WidgetValidated::attributeToValidate() const +{ + return myFeature->attribute(attributeID()); +} + //******************************************************************** bool ModuleBase_WidgetValidated::isValidSelection(const ModuleBase_ViewerPrs& theValue) { @@ -140,6 +139,7 @@ bool ModuleBase_WidgetValidated::isValidSelection(const ModuleBase_ViewerPrs& th // stores the current values of the widget attribute bool isFlushesActived, isAttributeSetInitializedBlocked; + blockAttribute(true, isFlushesActived, isAttributeSetInitializedBlocked); storeAttributeValue(); @@ -179,7 +179,7 @@ bool ModuleBase_WidgetValidated::isValidAttribute() const { SessionPtr aMgr = ModelAPI_Session::get(); ModelAPI_ValidatorsFactory* aFactory = aMgr->validators(); - AttributePtr anAttribute = myFeature->attribute(attributeID()); + AttributePtr anAttribute = attributeToValidate(); std::string aValidatorID, anError; return aFactory->validate(anAttribute, aValidatorID, anError); } @@ -217,7 +217,7 @@ void ModuleBase_WidgetValidated::blockAttribute(const bool& theToBlock, bool& is { Events_Loop* aLoop = Events_Loop::loop(); DataPtr aData = myFeature->data(); - AttributePtr anAttribute = myFeature->attribute(attributeID()); + AttributePtr anAttribute = attributeToValidate(); if (theToBlock) { // blocks the flush signals to avoid the temporary objects visualization in the viewer // they should not be shown in order to do not lose highlight by erasing them diff --git a/src/ModuleBase/ModuleBase_WidgetValidated.h b/src/ModuleBase/ModuleBase_WidgetValidated.h index 5f8aae3b7..ef503aacc 100644 --- a/src/ModuleBase/ModuleBase_WidgetValidated.h +++ b/src/ModuleBase/ModuleBase_WidgetValidated.h @@ -14,6 +14,7 @@ #include #include #include +#include #include @@ -61,6 +62,11 @@ protected: /// \return a boolean value bool isValidInFilters(const ModuleBase_ViewerPrs& thePrs); + /// Retunrs attribute, which should be validated. In default implementation, + /// this is an attribute of ID + /// \return an attribute + virtual AttributePtr attributeToValidate() const; + /// Creates a backup of the current values of the attribute /// It should be realized in the specific widget because of different /// parameters of the current attribute diff --git a/src/PartSet/PartSet_WidgetSketchCreator.cpp b/src/PartSet/PartSet_WidgetSketchCreator.cpp index d7130e5f6..1379e1cdc 100644 --- a/src/PartSet/PartSet_WidgetSketchCreator.cpp +++ b/src/PartSet/PartSet_WidgetSketchCreator.cpp @@ -114,6 +114,11 @@ bool PartSet_WidgetSketchCreator::storeValueCustom() const return true; } +AttributePtr PartSet_WidgetSketchCreator::attributeToValidate() const +{ + return myFeature->attribute(myAttributeListID); +} + void PartSet_WidgetSketchCreator::activateSelectionControl() { setVisibleSelectionControl(true); @@ -248,12 +253,13 @@ bool PartSet_WidgetSketchCreator::setSelection(QList& theV { bool aDone = false; if (!startSketchOperation(theValues)) { + ModuleBase_WidgetSelector::setSelection(theValues, theToValidate); QList::const_iterator anIt = theValues.begin(), aLast = theValues.end(); bool aProcessed = false; for (; anIt != aLast; anIt++) { ModuleBase_ViewerPrs aValue = *anIt; if (!theToValidate || isValidInFilters(aValue)) - aProcessed = setBaseAttributeSelection(aValue) || aProcessed; + aProcessed = setSelectionCustom(aValue) || aProcessed; } aDone = aProcessed; if (aProcessed) { @@ -441,17 +447,3 @@ void PartSet_WidgetSketchCreator::onResumed(ModuleBase_Operation* theOp) } } } - -bool PartSet_WidgetSketchCreator::setBaseAttributeSelection(const ModuleBase_ViewerPrs& theValue) -{ - bool isDone = false; - ObjectPtr anObject; - GeomShapePtr aShape; - getGeomSelection(theValue, anObject, aShape); - - std::string anAttributeId = myAttributeListID; - DataPtr aData = myFeature->data(); - ModuleBase_Tools::setObject(aData->attribute(anAttributeId), anObject, aShape, - myWorkshop, false); - return true; -} diff --git a/src/PartSet/PartSet_WidgetSketchCreator.h b/src/PartSet/PartSet_WidgetSketchCreator.h index a229fda23..d11c92e60 100644 --- a/src/PartSet/PartSet_WidgetSketchCreator.h +++ b/src/PartSet/PartSet_WidgetSketchCreator.h @@ -75,6 +75,11 @@ protected: virtual bool restoreValueCustom(); + /// Retunrs attribute, which should be validated. In default implementation, + /// this is an attribute of ID + /// \return an attribute + virtual AttributePtr attributeToValidate() const; + /// Sets the selection control visible and set the current widget as active in property panel /// It leads to connect to onSelectionChanged slot void activateSelectionControl(); @@ -110,11 +115,6 @@ private: /// \return true if the sketch is started bool startSketchOperation(const QList& theValues); - /// Appends the selection to the sketch base attribute - /// \param theValue a selection value from the viewer - /// \return true if the value is set - bool setBaseAttributeSelection(const ModuleBase_ViewerPrs& theValue); - private: std::string myAttributeListID; diff --git a/src/PartSet/PartSet_WidgetSketchLabel.cpp b/src/PartSet/PartSet_WidgetSketchLabel.cpp index 01ebff93e..262070bc8 100644 --- a/src/PartSet/PartSet_WidgetSketchLabel.cpp +++ b/src/PartSet/PartSet_WidgetSketchLabel.cpp @@ -359,9 +359,11 @@ bool PartSet_WidgetSketchLabel::canFillSketch(const ModuleBase_ViewerPrs& thePrs std::shared_ptr aGeomFace; const TopoDS_Shape aShape = thePrs.shape(); if (aShape.IsNull()) { - GeomShapePtr aGeomShape = aResult->shape(); - std::shared_ptr aGeomFace(new GeomAPI_Face(aGeomShape)); - aCanFillSketch = aGeomFace.get() && aGeomFace->isPlanar(); + if (aResult.get()) { + GeomShapePtr aGeomShape = aResult->shape(); + std::shared_ptr aGeomFace(new GeomAPI_Face(aGeomShape)); + aCanFillSketch = aGeomFace.get() && aGeomFace->isPlanar(); + } } else if (aShape.ShapeType() == TopAbs_FACE) { std::shared_ptr aGeomFace(new GeomAPI_Face());