erasePreviewPlanes();
}
+bool PartSet_WidgetSketchLabel::setSelection(const QList<ModuleBase_ViewerPrs>& theValues, int& thePosition)
+{
+ // do not use the given selection if the plane of the sketch has been already set.
+ // If this check is absent, a selected plane in the viewer can be set in the sketch
+ // even if the sketch is built on another plane.
+ if (plane().get())
+ return true;
+
+ return ModuleBase_WidgetValidated::setSelection(theValues, thePosition);
+}
+
QList<QWidget*> PartSet_WidgetSketchLabel::getControls() const
{
QList<QWidget*> aResult;
void PartSet_WidgetSketchLabel::onSelectionChanged()
{
- 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();
- }
- else {
- // the selection in Object Browser: the plane object can be used as sketch plane
- QObjectPtrList anObjects = aSelection->selectedObjects();
- if (!anObjects.empty()) {
- aPrs.setObject(anObjects.first());
- }
- }
- if (aPrs.isEmpty())
+ QList<ModuleBase_ViewerPrs> aSelectedPrs = getSelectedEntitiesOrObjects(
+ myWorkshop->selector()->selection());
+ if (aSelectedPrs.empty())
return;
-
- if (!isValidSelection(aPrs))
+ ModuleBase_ViewerPrs aPrs = aSelectedPrs.first();
+ if (aPrs.isEmpty() || !isValidSelection(aPrs))
return;
// 2. set the selection to sketch
}
else if (!aShape.IsNull()) {
aDir = setSketchPlane(aShape);
- isOwnerSet = aDir;
+ isOwnerSet = aDir.get();
}
return isOwnerSet;
}