- XGUI_Selection* aSelection = myWorkshop->selector()->selection();
- QList<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
- if (!aSelected.empty()) {
- ModuleBase_ViewerPrs aPrs = aSelected.first();
- Handle(SelectMgr_EntityOwner) anOwner = aSelected.first().owner();
- if (isValid(anOwner)) {
- setSelection(anOwner);
-
- TopoDS_Shape aShape = aPrs.shape();
- if (!aShape.IsNull()) {
- erasePreviewPlanes();
- DataPtr aData = feature()->data();
- AttributeSelectionPtr aSelAttr = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>
- (aData->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID()));
- if (aSelAttr) {
- GeomShapePtr aShapePtr = aSelAttr->value();
- if (aShapePtr.get() == NULL || aShapePtr->isNull()) {
- std::shared_ptr<GeomAPI_Shape> aGShape(new GeomAPI_Shape);
- aGShape->setImpl(new TopoDS_Shape(aShape));
- // get plane parameters
- std::shared_ptr<GeomAPI_Pln> aPlane = GeomAlgoAPI_FaceBuilder::plane(aGShape);
- std::shared_ptr<GeomAPI_Dir> aDir = aPlane->direction();
-
- myWorkshop->viewer()->setViewProjection(aDir->x(), aDir->y(), aDir->z());
- }
- }
+ 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;
+ }
+ else {
+ // it removes the processed value from the parameters list
+ ModuleBase_ViewerPrsPtr aValue = theValues.first();//.takeFirst();
+ if (!theToValidate || isValidInFilters(aValue))
+ aDone = setSelectionCustom(aValue);
+ }
+
+ return aDone;
+}
+
+void PartSet_WidgetSketchLabel::updateByPlaneSelected(const ModuleBase_ViewerPrsPtr& thePrs)
+{
+ GeomPlanePtr aPlane = plane();
+ if (!aPlane.get())
+ return;
+ // 1. hide main planes if they have been displayed and display sketch preview plane
+ myPreviewPlanes->erasePreviewPlanes(myWorkshop);
+
+ PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
+ if (aModule) {
+ CompositeFeaturePtr aSketch = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
+ bool isSetSizeOfView = false;
+ double aSizeOfView = 0;
+ QString aSizeOfViewStr = mySizeOfView->text();
+ if (!aSizeOfViewStr.isEmpty()) {
+ aSizeOfView = aSizeOfViewStr.toDouble(&isSetSizeOfView);
+ if (isSetSizeOfView && aSizeOfView <= 0) {
+ isSetSizeOfView = false;
+ }
+ }
+ if (isSetSizeOfView)
+ aModule->sketchMgr()->previewSketchPlane()->setSizeOfView(aSizeOfView, true);
+ aModule->sketchMgr()->previewSketchPlane()->createSketchPlane(aSketch, myWorkshop);
+ if (isSetSizeOfView)
+ aModule->sketchMgr()->previewSketchPlane()->setSizeOfView(aSizeOfView, false);
+ }
+ // 2. if the planes were displayed, change the view projection