/// Returns true if attribute was initialized by some value
MODEL_EXPORT virtual bool isInitialized();
-
protected:
/// Objects are created for features automatically
MODEL_EXPORT Model_AttributeRefAttr(TDF_Label& theLabel);
return aResult;
}
+bool Model_AttributeSelection::isInitialized()
+{
+ if (ModelAPI_AttributeSelection::isInitialized()) { // additional checkings if it is initialized
+ std::shared_ptr<GeomAPI_Shape> aResult;
+ if (myRef.isInitialized()) {
+ TDF_Label aSelLab = selectionLabel();
+ if (aSelLab.IsAttribute(kSIMPLE_REF_ID)) { // it is just reference to shape, not sub-shape
+ ResultPtr aContext = context();
+ if (!aContext.get())
+ return false;
+ }
+ if (aSelLab.IsAttribute(kCONSTUCTION_SIMPLE_REF_ID)) { // it is just reference to construction, nothing is in value
+ return false;
+ }
+
+ Handle(TNaming_NamedShape) aSelection;
+ if (selectionLabel().FindAttribute(TNaming_NamedShape::GetID(), aSelection)) {
+ return !aSelection->Get().IsNull();
+ } else { // for simple construction element: just shape of this construction element
+ ResultConstructionPtr aConstr =
+ std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(context());
+ if (aConstr.get()) {
+ return aConstr->shape().get();
+ }
+ }
+ }
+ }
+ return false;
+}
+
Model_AttributeSelection::Model_AttributeSelection(TDF_Label& theLabel)
: myRef(theLabel)
{
/// Selects (i.e. creates Naming data structure) of sub-shape specifed by textual name
MODEL_EXPORT virtual void selectSubShape(const std::string& theType, const std::string& theSubShapeName);
+ /// Returns true if attribute was initialized by some value
+ MODEL_EXPORT virtual bool isInitialized();
+
protected:
/// Objects are created for features automatically
MODEL_EXPORT Model_AttributeSelection(TDF_Label& theLabel);
// we don't need the update only on operation start (caused problems in PartSet_Listener::processEvent)
isOperationChanged = true;
} else if (theMessage->eventID() == kOpFinishEvent || theMessage->eventID() == kOpAbortEvent) {
- processOperation(true);
+ processOperation(true, theMessage->eventID() == kOpFinishEvent);
isOperationChanged = true;
}
if (isOperationChanged) {
}
}
-void Model_Update::processOperation(const bool theTotalUpdate)
+void Model_Update::processOperation(const bool theTotalUpdate, const bool theFinish)
{
- // the hardcode (DBC asked): hide the sketch referenced by extrusion on apply
- std::set<std::shared_ptr<ModelAPI_Object> >::iterator aFIter;
- for(aFIter = myJustCreated.begin(); aFIter != myJustCreated.end(); aFIter++)
- {
- FeaturePtr aF = std::dynamic_pointer_cast<ModelAPI_Feature>(*aFIter);
- if (aF && aF->data().get() && aF->getKind() == "Extrusion") {
- AttributeSelectionListPtr aBase = aF->selectionList("base");
- if (aBase.get()) {
- for(int a = aBase->size() - 1; a >= 0; a--) {
- ResultPtr aSketchRes = aBase->value(a)->context();
- if (aSketchRes) {
- aSketchRes->setDisplayed(false);
+ if (theFinish) {
+ // the hardcode (DBC asked): hide the sketch referenced by extrusion on apply
+ std::set<std::shared_ptr<ModelAPI_Object> >::iterator aFIter;
+ for(aFIter = myJustCreated.begin(); aFIter != myJustCreated.end(); aFIter++)
+ {
+ FeaturePtr aF = std::dynamic_pointer_cast<ModelAPI_Feature>(*aFIter);
+ if (aF && aF->data().get() && aF->getKind() == "Extrusion") {
+ AttributeSelectionListPtr aBase = aF->selectionList("base");
+ if (aBase.get()) {
+ for(int a = aBase->size() - 1; a >= 0; a--) {
+ ResultPtr aSketchRes = aBase->value(a)->context();
+ if (aSketchRes) {
+ aSketchRes->setDisplayed(false);
+ }
}
}
}
/// On operation start/end/abort the "Just" fileds must be cleared and processed in the right way
/// \param theTotalUpdate force to updates everything that has been changed in this operation
- void processOperation(const bool theTotalUpdate);
+ void processOperation(const bool theTotalUpdate, const bool theFinish = false);
/// Performs the feature execution
/// \returns the status of execution