myWorkshop->setSelected(getAttributeSelection());
myWorkshop->module()->customizeObject(myFeature, ModuleBase_IModule::CustomizeAllObjects, true);
}
- return true; // if the delete should be processed outsize, the method should return isDone
+ return aDone;
}
//********************************************************************
return aValid;
}
- DataPtr aData = myFeature->data();
- AttributePtr anAttribute = myFeature->attribute(attributeID());
-
// stores the current values of the widget attribute
- Events_Loop* aLoop = Events_Loop::loop();
- // 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
- bool isActive = aLoop->activateFlushes(false);
+ bool isFlushesActived, isAttributeSetInitializedBlocked;
+ blockAttribute(true, isFlushesActived, isAttributeSetInitializedBlocked);
- aData->blockSendAttributeUpdated(true);
- bool isAttributeBlocked = anAttribute->blockSetInitialized(true);
storeAttributeValue();
// saves the owner value to the widget attribute
// restores the current values of the widget attribute
restoreAttributeValue(aValid);
- aData->blockSendAttributeUpdated(false);
- anAttribute->blockSetInitialized(isAttributeBlocked);
- aLoop->activateFlushes(isActive);
+ blockAttribute(false, isFlushesActived, isAttributeSetInitializedBlocked);
// In particular case the results are deleted and called as redisplayed inside of this
// highlight-selection, to they must be flushed as soon as possible.
// Example: selection of group-vertices subshapes with shift pressend on body. Without
// removed results still in the viewer.
static Events_ID aDeletedEvent = Events_Loop::eventByName(EVENT_OBJECT_DELETED);
static Events_ID aRedispEvent = Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY);
- aLoop->flush(aDeletedEvent);
- aLoop->flush(aRedispEvent);
+ Events_Loop::loop()->flush(aDeletedEvent);
+ Events_Loop::loop()->flush(aRedispEvent);
storeValidState(theValue, aValid);
return aValid;
}
}
+//********************************************************************
+void ModuleBase_WidgetValidated::blockAttribute(const bool& theToBlock, bool& isFlushesActived,
+ bool& isAttributeSetInitializedBlocked)
+{
+ Events_Loop* aLoop = Events_Loop::loop();
+ DataPtr aData = myFeature->data();
+ AttributePtr anAttribute = myFeature->attribute(attributeID());
+ 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
+ isFlushesActived = aLoop->activateFlushes(false);
+
+ aData->blockSendAttributeUpdated(true);
+ isAttributeSetInitializedBlocked = anAttribute->blockSetInitialized(true);
+ }
+ else {
+ aData->blockSendAttributeUpdated(false);
+ anAttribute->blockSetInitialized(isAttributeSetInitializedBlocked);
+ aLoop->activateFlushes(isFlushesActived);
+ }
+}
+
//********************************************************************
void ModuleBase_WidgetValidated::storeValidState(const ModuleBase_ViewerPrs& theValue, const bool theValid)
{
/// \param toActivate a flag about activation or deactivation the filters
void activateFilters(const bool toActivate);
+ /// Block the model flush of update and intialization of attribute
+ /// \param theToBlock flag whether the model is blocked or unblocked
+ /// \param isActive out value if model is blocked, in value if model is unblocked
+ /// to be used to restore flush state when unblocked
+ /// \param isAttributeSetInitializedBlocked out value if model is blocked
+ /// in value if model is unblocked to be used to restore previous state when unblocked
+ virtual void blockAttribute(const bool& theToBlock, bool& isFlushesActived,
+ bool& isAttributeSetInitializedBlocked);
+
protected:
/// Reference to workshop
ModuleBase_IWorkshop* myWorkshop;
emit showConstraintToggled(theOn, aState);
}
+void PartSet_WidgetSketchLabel::blockAttribute(const bool& theToBlock, bool& isFlushesActived,
+ bool& isAttributeSetInitializedBlocked)
+{
+ ModuleBase_WidgetValidated::blockAttribute(theToBlock, isFlushesActived,
+ isAttributeSetInitializedBlocked);
+ // We do not restore the previous state of isAttributeSetInitializedBlocked for each of
+ // attributes. It it is necessary, these states should be append to the method attributes
+ // or stored in the widget
+
+ std::list<AttributePtr> anAttributes = myFeature->data()->attributes("");
+ std::list<AttributePtr>::const_iterator anIt = anAttributes.begin(), aLast = anAttributes.end();
+ QStringList aValues;
+ for(; anIt != aLast; anIt++) {
+ AttributePtr anAttribute = *anIt;
+ if (theToBlock)
+ anAttribute->blockSetInitialized(true);
+ else
+ anAttribute->blockSetInitialized(isAttributeSetInitializedBlocked);
+ }
+}
+
void PartSet_WidgetSketchLabel::updateByPlaneSelected(const ModuleBase_ViewerPrs& thePrs)
{
// 1. hide main planes if they have been displayed
/// The methiod called when widget is activated
virtual void activateCustom();
+ /// Block the model flush of update and intialization of attribute
+ /// In additional to curstom realization it blocks initialization for all feature attributes
+ /// as the current attribute is selection but its modification leads to other attributes change
+ /// \param theToBlock flag whether the model is blocked or unblocked
+ /// \param isActive out value if model is blocked, in value if model is unblocked
+ /// to be used to restore flush state when unblocked
+ /// \param isAttributeSetInitializedBlocked out value if model is blocked
+ /// in value if model is unblocked to be used to restore previous state when unblocked
+ virtual void blockAttribute(const bool& theToBlock, bool& isFlushesActived,
+ bool& isAttributeSetInitializedBlocked);
+
/// Erase preview planes, disconnect widget, change the view projection
/// \param thePrs a selected presentation
void updateByPlaneSelected(const ModuleBase_ViewerPrs& thePrs);
if (aData) {
std::shared_ptr<GeomDataAPI_Dir> aNormal =
std::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SketchPlugin_Sketch::NORM_ID()));
- aHasSketchPlane = aNormal && !(aNormal->x() == 0 && aNormal->y() == 0 && aNormal->z() == 0);
+ // it is important to check whether the normal attribute is initialized
+ // because it is possible that normal values are filled when the plane is checked on validity
+ aHasSketchPlane = aNormal && aNormal->isInitialized() &&
+ !(aNormal->x() == 0 && aNormal->y() == 0 && aNormal->z() == 0);
aMsg->setState(SketchPlugin_Point::ID(), aHasSketchPlane);
aMsg->setState(SketchPlugin_Line::ID(), aHasSketchPlane);