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;
}
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);
}
//********************************************************************
return aValid;
}
+//********************************************************************
+AttributePtr ModuleBase_WidgetValidated::attributeToValidate() const
+{
+ return myFeature->attribute(attributeID());
+}
+
//********************************************************************
bool ModuleBase_WidgetValidated::isValidSelection(const ModuleBase_ViewerPrs& theValue)
{
// stores the current values of the widget attribute
bool isFlushesActived, isAttributeSetInitializedBlocked;
+
blockAttribute(true, isFlushesActived, isAttributeSetInitializedBlocked);
storeAttributeValue();
{
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);
}
{
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
#include <GeomAPI_Shape.h>
#include <GeomAPI_AISObject.h>
#include <ModelAPI_Object.h>
+#include <ModelAPI_Attribute.h>
#include <SelectMgr_ListOfFilter.hxx>
/// \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
return true;
}
+AttributePtr PartSet_WidgetSketchCreator::attributeToValidate() const
+{
+ return myFeature->attribute(myAttributeListID);
+}
+
void PartSet_WidgetSketchCreator::activateSelectionControl()
{
setVisibleSelectionControl(true);
{
bool aDone = false;
if (!startSketchOperation(theValues)) {
+ ModuleBase_WidgetSelector::setSelection(theValues, theToValidate);
QList<ModuleBase_ViewerPrs>::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) {
}
}
}
-
-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;
-}
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();
/// \return true if the sketch is started
bool startSketchOperation(const QList<ModuleBase_ViewerPrs>& 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;
std::shared_ptr<GeomAPI_Face> aGeomFace;
const TopoDS_Shape aShape = thePrs.shape();
if (aShape.IsNull()) {
- GeomShapePtr aGeomShape = aResult->shape();
- std::shared_ptr<GeomAPI_Face> aGeomFace(new GeomAPI_Face(aGeomShape));
- aCanFillSketch = aGeomFace.get() && aGeomFace->isPlanar();
+ if (aResult.get()) {
+ GeomShapePtr aGeomShape = aResult->shape();
+ std::shared_ptr<GeomAPI_Face> aGeomFace(new GeomAPI_Face(aGeomShape));
+ aCanFillSketch = aGeomFace.get() && aGeomFace->isPlanar();
+ }
}
else if (aShape.ShapeType() == TopAbs_FACE) {
std::shared_ptr<GeomAPI_Face> aGeomFace(new GeomAPI_Face());