- ModuleBase_ViewerPrs aPrs;
- // 1. find selected presentation either in the viewer or in OB
- XGUI_Selection* aSelection = myWorkshop->selector()->selection();
- QList<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
- // the selection in OCC viewer - the selection of a face in the viewer
- // it can be th main plane's face of a face on a visualized body
- if (!aSelected.empty()) {
- aPrs = aSelected.first();
+ std::shared_ptr<GeomAPI_Pln> aPlane = plane();
+ if (aPlane.get())
+ return false;
+
+ QList<ModuleBase_ViewerPrsPtr> aSelected = getFilteredSelected();
+
+ if (aSelected.empty())
+ return false;
+ ModuleBase_ViewerPrsPtr aPrs = aSelected.first();
+ bool aDone = setSelectionInternal(aSelected, false);
+ if (aDone) {
+ updateByPlaneSelected(aPrs);
+ updateObject(myFeature);
+ }
+
+ return aDone;
+}
+
+void PartSet_WidgetSketchLabel::onShowConstraint(bool theOn)
+{
+ QCheckBox* aSenderCheckBox = qobject_cast<QCheckBox*>(sender());
+
+ QMap<PartSet_Tools::ConstraintVisibleState, QCheckBox*>::const_iterator
+ anIt = myShowConstraints.begin(), aLast = myShowConstraints.end();
+
+ PartSet_Tools::ConstraintVisibleState aState = PartSet_Tools::Geometrical;
+ bool aFound = false;
+ for (; anIt != aLast && !aFound; anIt++) {
+ aFound = anIt.value() == aSenderCheckBox;
+ if (aFound)
+ aState = anIt.key();
+ }
+ if (aFound)
+ emit showConstraintToggled(aState, theOn);
+}
+
+void PartSet_WidgetSketchLabel::blockAttribute(const AttributePtr& theAttribute,
+ const bool& theToBlock, bool& isFlushesActived,
+ bool& isAttributeSetInitializedBlocked,
+ bool& isAttributeSendUpdatedBlocked)
+{
+ ModuleBase_WidgetValidated::blockAttribute(theAttribute, theToBlock, isFlushesActived,
+ isAttributeSetInitializedBlocked,
+ isAttributeSendUpdatedBlocked);
+ // 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);
+ }
+}
+
+bool PartSet_WidgetSketchLabel::setSelectionInternal(
+ const QList<ModuleBase_ViewerPrsPtr>& theValues,
+ const bool theToValidate)
+{
+ bool aDone = false;
+ if (theValues.empty()) {
+ // In order to make reselection possible, set empty object and shape should be done
+ setSelectionCustom(std::shared_ptr<ModuleBase_ViewerPrs>(
+ new ModuleBase_ViewerPrs(ObjectPtr(), GeomShapePtr(), NULL)));
+ aDone = false;