From: nds Date: Tue, 22 Mar 2016 06:24:56 +0000 (+0300) Subject: Issue #1343 Improvement of Extrusion and Revolution operations: disable selection... X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b332ba481ad04435865974bb322117ad002b75a3;p=modules%2Fshaper.git Issue #1343 Improvement of Extrusion and Revolution operations: disable selection control in edit mode. --- diff --git a/src/ModuleBase/ModuleBase_ModelWidget.h b/src/ModuleBase/ModuleBase_ModelWidget.h index c2859e975..ce425194c 100644 --- a/src/ModuleBase/ModuleBase_ModelWidget.h +++ b/src/ModuleBase/ModuleBase_ModelWidget.h @@ -170,7 +170,7 @@ Q_OBJECT void setFeature(const FeaturePtr& theFeature, const bool theToStoreValue = false); /// Editing mode depends on mode of current operation. This value is defined by it. - void setEditingMode(bool isEditing) { myIsEditing = isEditing; } + virtual void setEditingMode(bool isEditing) { myIsEditing = isEditing; } /// \return Current Editing mode bool isEditingMode() const { return myIsEditing; } diff --git a/src/PartSet/PartSet_WidgetMultiSelectorComposite.cpp b/src/PartSet/PartSet_WidgetMultiSelectorComposite.cpp index 32bd055cc..fb1238c3a 100755 --- a/src/PartSet/PartSet_WidgetMultiSelectorComposite.cpp +++ b/src/PartSet/PartSet_WidgetMultiSelectorComposite.cpp @@ -19,17 +19,32 @@ PartSet_WidgetMultiSelectorComposite::~PartSet_WidgetMultiSelectorComposite() bool PartSet_WidgetMultiSelectorComposite::focusTo() { - bool aCanSetFocus = true; - CompositeFeaturePtr aComposite = std::dynamic_pointer_cast(myFeature); - if (aComposite.get()) - aCanSetFocus = aComposite->numberOfSubs() == 0; + bool aHasSubObjects = hasSubObjects(); // disable widget controls - if (!aCanSetFocus) { + if (aHasSubObjects) disableControls(); - } - return aCanSetFocus; + return !aHasSubObjects; +} + +void PartSet_WidgetMultiSelectorComposite::setEditingMode(bool isEditing) +{ + ModuleBase_ModelWidget::setEditingMode(isEditing); + bool aHasSubObjects = hasSubObjects(); + if (aHasSubObjects) + disableControls(); +} + +bool PartSet_WidgetMultiSelectorComposite::hasSubObjects() const +{ + bool aHasSubObjects = false; + + bool aCanSetFocus = true; + CompositeFeaturePtr aComposite = std::dynamic_pointer_cast(myFeature); + if (aComposite.get()) + aHasSubObjects = aComposite->numberOfSubs() > 0; + return aHasSubObjects; } void PartSet_WidgetMultiSelectorComposite::disableControls() diff --git a/src/PartSet/PartSet_WidgetMultiSelectorComposite.h b/src/PartSet/PartSet_WidgetMultiSelectorComposite.h index 62afac31c..4cfd940a0 100755 --- a/src/PartSet/PartSet_WidgetMultiSelectorComposite.h +++ b/src/PartSet/PartSet_WidgetMultiSelectorComposite.h @@ -36,7 +36,14 @@ Q_OBJECT /// \return the state whether the widget can accept the focus virtual bool focusTo(); + /// Editing mode depends on mode of current operation. This value is defined by it. + virtual void setEditingMode(bool isEditing); + private: + /// Returns true if the current composite feature contains at least one sub-object + /// \return boolean value + bool hasSubObjects() const; + /// Disable controls by setting them focus policy NoFocus and disabling them void disableControls(); }; diff --git a/src/PartSet/PartSet_WidgetSketchCreator.cpp b/src/PartSet/PartSet_WidgetSketchCreator.cpp index 972a0e7a8..4e9ccb983 100644 --- a/src/PartSet/PartSet_WidgetSketchCreator.cpp +++ b/src/PartSet/PartSet_WidgetSketchCreator.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include @@ -130,8 +131,7 @@ void PartSet_WidgetSketchCreator::activateCustom() void PartSet_WidgetSketchCreator::setVisibleSelectionControl(const bool theSelectionControl) { // hide current widget, activate the next widget - XGUI_ModuleConnector* aConnector = dynamic_cast(myModule->workshop()); - XGUI_Workshop* aWorkshop = aConnector->workshop(); + XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myModule->workshop()); XGUI_PropertyPanel* aPanel = aWorkshop->propertyPanel(); const QList& aWidgets = aPanel->modelWidgets(); foreach(ModuleBase_ModelWidget* aWidget, aWidgets) { @@ -159,9 +159,15 @@ QIntList PartSet_WidgetSketchCreator::getShapeTypes() const void PartSet_WidgetSketchCreator::deactivate() { - if (isSelectionMode()) { - ModuleBase_WidgetSelector::activateCustom(); - } + if (isSelectionMode()) + ModuleBase_WidgetSelector::deactivate(); +} + +void PartSet_WidgetSketchCreator::setEditingMode(bool isEditing) +{ + ModuleBase_ModelWidget::setEditingMode(isEditing); + if (isEditing) + setVisibleSelectionControl(false); } bool PartSet_WidgetSketchCreator::isSelectionMode() const @@ -326,8 +332,10 @@ void PartSet_WidgetSketchCreator::onResumed(ModuleBase_Operation* theOp) CompositeFeaturePtr aSketchFeature = std::dynamic_pointer_cast(aCompFeature->subFeature(0)); if (aSketchFeature->numberOfSubs() == 0) { + // do nothing, selection control should be shown + // Abort operation - SessionPtr aMgr = ModelAPI_Session::get(); + //SessionPtr aMgr = ModelAPI_Session::get(); // Close transaction /* bool aIsOp = aMgr->isOperation(); @@ -336,8 +344,17 @@ void PartSet_WidgetSketchCreator::onResumed(ModuleBase_Operation* theOp) aMgr->startOperation(aNestedOpID, true); } */ - theOp->abort(); + //theOp->abort(); } else { + // Update value in attribute selection list + XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myModule->workshop()); + XGUI_PropertyPanel* aPanel = aWorkshop->propertyPanel(); + const QList& aWidgets = aPanel->modelWidgets(); + foreach(ModuleBase_ModelWidget* aWidget, aWidgets) { + if (aWidget->attributeID() == myAttributeListID) + aWidget->restoreValue(); + } + // Hide sketcher result std::list aResults = aSketchFeature->results(); std::list::const_iterator aIt; @@ -346,22 +363,23 @@ void PartSet_WidgetSketchCreator::onResumed(ModuleBase_Operation* theOp) } aSketchFeature->setDisplayed(false); + // restore value in the selection control + + + // Add Selected body were created the sketcher to list of selected objects if(myUseBody) { - // Add Selected body were created the sketcher to list of selected objects - DataPtr aData = aSketchFeature->data(); - AttributeSelectionPtr aSelAttr = - std::dynamic_pointer_cast - (aData->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID())); - if (aSelAttr.get()) { - ResultPtr aRes = aSelAttr->context(); - GeomShapePtr aShape = aSelAttr->value(); + std::string anObjectsAttribute = FeaturesPlugin_CompositeBoolean::BOOLEAN_OBJECTS_ID(); + AttributeSelectionListPtr aSelList = aCompFeature->data()->selectionList(anObjectsAttribute); + if (aSelList.get()) { + DataPtr aData = aSketchFeature->data(); + AttributeSelectionPtr aSelAttr = std::dynamic_pointer_cast + (aData->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID())); + ResultPtr aRes = aSelAttr.get() ? aSelAttr->context() : ResultPtr(); if (aRes.get()) { - std::string anObjectsAttribute = FeaturesPlugin_CompositeBoolean::BOOLEAN_OBJECTS_ID(); SessionPtr aMgr = ModelAPI_Session::get(); ModelAPI_ValidatorsFactory* aFactory = aMgr->validators(); AttributePtr anAttribute = myFeature->attribute(anObjectsAttribute); std::string aValidatorID, anError; - AttributeSelectionListPtr aSelList = aCompFeature->data()->selectionList(anObjectsAttribute); aSelList->append(aRes, GeomShapePtr()); if (aFactory->validate(anAttribute, aValidatorID, anError)) updateObject(aCompFeature); diff --git a/src/PartSet/PartSet_WidgetSketchCreator.h b/src/PartSet/PartSet_WidgetSketchCreator.h index a03e71021..f6f56f8a2 100644 --- a/src/PartSet/PartSet_WidgetSketchCreator.h +++ b/src/PartSet/PartSet_WidgetSketchCreator.h @@ -50,6 +50,9 @@ public: /// The methiod called when widget is deactivated virtual void deactivate(); + /// Editing mode depends on mode of current operation. This value is defined by it. + virtual void setEditingMode(bool isEditing); + protected: /// Saves the internal parameters to the given feature /// \return True in success