return true;
#endif
GeomShapePtr aShape = myWorkshop->selection()->getShape(thePrs);
- // if there is no selected shape, the method returns true
- bool aValid;
- if (!aShape.get())
- aValid = true;
- else {
- // Check that the selection corresponds to selection type
- TopoDS_Shape aTopoShape = aShape->impl<TopoDS_Shape>();
- aValid = acceptSubShape(aTopoShape);
+ // if there is no result(the feature is presentable only), result is false
+ ResultPtr aResult = myWorkshop->selection()->getResult(thePrs);
+ bool aValid = aResult.get() != NULL;
+ if (aValid) {
+ // if there is no selected shape, the method returns true
+ if (!aShape.get())
+ aValid = true;
+ else {
+ // Check that the selection corresponds to selection type
+ TopoDS_Shape aTopoShape = aShape->impl<TopoDS_Shape>();
+ aValid = acceptSubShape(aTopoShape);
+ }
}
if (aValid) {
- ResultPtr aResult = myWorkshop->selection()->getResult(thePrs);
-
if (myFeature) {
// We can not select a result of our feature
const std::list<ResultPtr>& aResList = myFeature->results();
if(isSkipSelf)
aValid = false;
}
-
}
return aValid;
DataPtr aData = myFeature->data();
AttributeSelectionListPtr aSelectionListAttr =
std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(aData->attribute(attributeID()));
-
aSelectionListAttr->clear();
- if (aSelected.size() > 0) {
- foreach (ModuleBase_ViewerPrs aPrs, aSelected) {
- if (isValidSelection(aPrs)) {
- setSelectionCustom(aPrs);
- }
- }
- }
+
+ setSelection(aSelected);
+
emit valuesChanged();
// the updateObject method should be called to flush the updated sigal. The workshop listens it,
// calls validators for the feature and, as a result, updates the Apply button state.
// In order to make reselection possible, set empty object and shape should be done
setObject(ObjectPtr(), std::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape()));
- bool aHasObject = false;
- QList<ModuleBase_ViewerPrs> aSelectedPrs = myWorkshop->selection()->getSelected(ModuleBase_ISelection::AllControls);
- if (!aSelectedPrs.empty()) {
- ModuleBase_ViewerPrs aPrs = aSelectedPrs.first();
- if (!aPrs.isEmpty() && isValidSelection(aPrs)) {
- setSelectionCustom(aPrs);
- aHasObject = true;
- }
- }
+ QList<ModuleBase_ViewerPrs> aSelected = myWorkshop->selection()->getSelected(ModuleBase_ISelection::AllControls);
+ bool aHasObject = setSelection(aSelected);
+
// the updateObject method should be called to flush the updated sigal. The workshop listens it,
// calls validators for the feature and, as a result, updates the Apply button state.
updateObject(myFeature);
//********************************************************************
bool PartSet_WidgetMultiSelector::setSelectionCustom(const ModuleBase_ViewerPrs& thePrs)
{
- TopoDS_Shape aShape = thePrs.shape();
- if (!acceptSubShape(aShape))
- return false;
-
- ResultPtr aResult;
- if (!thePrs.owner().IsNull()) {
- ObjectPtr anObject = myWorkshop->selection()->getSelectableObject(thePrs.owner());
- aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
- }
- else {
- aResult = std::dynamic_pointer_cast<ModelAPI_Result>(thePrs.object());
- }
-
+ //TopoDS_Shape aShape = thePrs.shape();
+ //if (!acceptSubShape(aShape))
+ // return false;
- if (myFeature) {
+ ResultPtr aResult = myWorkshop->selection()->getResult(thePrs);
+ /*if (myFeature) {
// We can not select a result of our feature
const std::list<ResultPtr>& aResList = myFeature->results();
std::list<ResultPtr>::const_iterator aIt;
}
if(isSkipSelf)
return false;
- }
+ }*/
- GeomShapePtr aGShape = GeomShapePtr();
+ /*GeomShapePtr aGShape = GeomShapePtr();
const TopoDS_Shape& aTDSShape = thePrs.shape();
// if only result is selected, an empty shape is set to the model
if (aTDSShape.IsNull()) {
else {
//aSelectionListAttr->append(aResult, aShape);
}
- }
+ }*/
+ GeomShapePtr aGShape = myWorkshop->selection()->getShape(thePrs);
setObject(aResult, aGShape);
return true;
}
void PartSet_WidgetSketchLabel::onSelectionChanged()
{
- QList<ModuleBase_ViewerPrs> aSelectedPrs = myWorkshop->selector()->selection()->getSelected(
+ QList<ModuleBase_ViewerPrs> aSelected = myWorkshop->selector()->selection()->getSelected(
ModuleBase_ISelection::AllControls);
- if (aSelectedPrs.empty())
+ if (aSelected.empty())
return;
- ModuleBase_ViewerPrs aPrs = aSelectedPrs.first();
- if (aPrs.isEmpty() || !isValidSelection(aPrs))
+ ModuleBase_ViewerPrs aPrs = aSelected.first();
+
+ bool isDone = ModuleBase_WidgetValidated::setSelection(aSelected);
+ if (!isDone)
return;
- // 2. set the selection to sketch
- setSelectionCustom(aPrs);
// 3. hide main planes if they have been displayed
erasePreviewPlanes();
// 4. if the planes were displayed, change the view projection