+void PartSet_WidgetSketchLabel::storeAttributeValue()
+{
+ ModuleBase_WidgetValidated::storeAttributeValue();
+}
+
+void PartSet_WidgetSketchLabel::restoreAttributeValue(const bool theValid)
+{
+ ModuleBase_WidgetValidated::restoreAttributeValue(theValid);
+
+ // it is not necessary to save the previous plane value because the plane is chosen once
+ DataPtr aData = feature()->data();
+ AttributeSelectionPtr aSelAttr = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>
+ (aData->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID()));
+ if (aSelAttr) {
+ ResultPtr anEmptyResult;
+ GeomShapePtr anEmptyShape;
+ aSelAttr->setValue(anEmptyResult, anEmptyShape);
+ }
+}
+
+bool PartSet_WidgetSketchLabel::setSelectionCustom(const ModuleBase_ViewerPrs& thePrs)
+{
+ bool isOwnerSet = false;
+
+ const TopoDS_Shape& aShape = thePrs.shape();
+ std::shared_ptr<GeomAPI_Dir> aDir;
+
+ if (thePrs.object() && (feature() != thePrs.object())) {
+ DataPtr aData = feature()->data();
+ AttributeSelectionPtr aSelAttr =
+ std::dynamic_pointer_cast<ModelAPI_AttributeSelection>
+ (aData->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID()));
+ if (aSelAttr) {
+ ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(thePrs.object());
+ if (aRes) {
+ GeomShapePtr aShapePtr(new GeomAPI_Shape());
+ if (aShape.IsNull()) { // selection happens in the OCC viewer
+ aShapePtr = ModelAPI_Tools::shape(aRes);
+ }
+ else { // selection happens in OB browser
+ aShapePtr->setImpl(new TopoDS_Shape(aShape));
+ }
+ if (aShapePtr.get() != NULL) {
+ aSelAttr->setValue(aRes, aShapePtr);
+ isOwnerSet = true;
+ }
+ }
+ }
+ }
+ else if (!aShape.IsNull()) {
+ aDir = setSketchPlane(aShape);
+ isOwnerSet = aDir.get();
+ }
+ return isOwnerSet;