+
+//******************************************************
+void PartSet_WidgetSketchLabel::onChangePlane()
+{
+ PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
+ if (aModule) {
+ mySizeOfViewWidget->setVisible(false);
+ myRemoveExternal->setVisible(true);
+ myStackWidget->setCurrentIndex(0);
+
+ bool aBodyIsVisualized = myPreviewPlanes->hasVisualizedBodies(myWorkshop);
+
+ if (!aBodyIsVisualized) {
+ // We have to select a plane before any operation
+ myPreviewPlanes->showPreviewPlanes(myWorkshop);
+ }
+
+ CompositeFeaturePtr aSketch = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
+ myTmpPlane = PartSet_Tools::sketchPlane(aSketch);
+ PartSet_Tools::nullifySketchPlane(aSketch);
+
+ Handle(SelectMgr_Filter) aFilter = aModule->selectionFilter(SF_SketchPlaneFilter);
+ if (!aFilter.IsNull()) {
+ std::shared_ptr<GeomAPI_Pln> aPln;
+ Handle(ModuleBase_ShapeInPlaneFilter)::DownCast(aFilter)->setPlane(aPln);
+ }
+ XGUI_Workshop* aWorkshop = aModule->getWorkshop();
+
+ aWorkshop->selectionActivate()->updateSelectionFilters();
+ aWorkshop->selectionActivate()->updateSelectionModes();
+
+ SessionPtr aMgr = ModelAPI_Session::get();
+ aMgr->startOperation("Change Sketch plane");
+ myOpenTransaction = true;
+ myWorkshop->viewer()->update();
+ }
+}
+
+void PartSet_WidgetSketchLabel::setShowPointsState(bool theState)
+{
+ bool aBlock = myShowPoints->blockSignals(true);
+ myShowPoints->setChecked(theState);
+ myShowPoints->blockSignals(aBlock);
+}
+
+bool PartSet_WidgetSketchLabel::restoreValueCustom()
+{
+ if (myFeature.get()) {
+ CompositeFeaturePtr aSketch = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
+ if (aSketch.get() && (aSketch->numberOfSubs() > 0)) {
+ AttributeStringPtr aDOFStr = aSketch->string("SolverDOF");
+ if (aDOFStr.get()) {
+ QString aVal(aDOFStr->value().c_str());
+ if (aVal.contains('=')) {
+ // to support old data
+ aVal = aVal.right(aVal.length() - aVal.lastIndexOf('='));
+ }
+ int aDoF = aVal.toInt();
+ if (aDoF == 0) {
+ myDoFLabel->setText(tr("Sketch is fully fixed (DoF = 0)"));
+ myShowDOFBtn->setEnabled(false);
+ } else {
+ myDoFLabel->setText(tr("DoF (degrees of freedom) = ") + aVal);
+ myShowDOFBtn->setEnabled(true);
+ }
+ }
+ }
+ else {
+ myDoFLabel->setText("");
+ myShowDOFBtn->setEnabled(false);
+ }
+ }
+ return true;
+}
+
+
+void PartSet_WidgetSketchLabel::onShowDOF()
+{
+ CompositeFeaturePtr aCompFeature =
+ std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
+ if (aCompFeature.get()) {
+ static const Events_ID anEvent = Events_Loop::eventByName(EVENT_GET_DOF_OBJECTS);
+ ModelAPI_EventCreator::get()->sendUpdated(aCompFeature, anEvent);
+ Events_Loop::loop()->flush(anEvent);
+
+ // Transfer focus to the current viewport for correct processing of a key event
+ QWidget* aViewPort = myWorkshop->viewer()->activeViewPort();
+ if (aViewPort)
+ aViewPort->setFocus();
+ }
+}
+
+bool PartSet_WidgetSketchLabel::eventFilter(QObject* theObj, QEvent* theEvent)
+{
+ if (theObj == window()) {
+ int aType = theEvent->type();
+ if ((aType == QEvent::Hide) || (aType == QEvent::WindowDeactivate)) {
+ if (myPartSetMessage->isVisible())
+ myPartSetMessage->hide();
+ if (mySizeMessage->isVisible())
+ mySizeMessage->hide();
+ }
+ else if ((aType == QEvent::Show) || (aType == QEvent::WindowActivate))
+ onShowPanel();
+ }
+ return ModuleBase_WidgetValidated::eventFilter(theObj, theEvent);
+}
+
+void PartSet_WidgetSketchLabel::onShowViewPlane(bool toShow)
+{
+ PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
+ PartSet_PreviewSketchPlane* aPreviewPlane = aModule->sketchMgr()->previewSketchPlane();
+ if (toShow) {
+ CompositeFeaturePtr aSketch = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
+ if (aPreviewPlane->isPlaneCreated())
+ aPreviewPlane->displaySketchPlane(myWorkshop);
+ else
+ aPreviewPlane->createSketchPlane(aSketch, myWorkshop);
+ }
+ else {
+ aPreviewPlane->eraseSketchPlane(myWorkshop, false);
+ }
+ myWorkshop->viewer()->update();
+}