From: nds Date: Thu, 17 May 2018 08:31:04 +0000 (+0300) Subject: Issue #2480 Error: sub shape is not initialized when split sketch X-Git-Tag: V8_5_0rc2~8^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=9133179c55f388d72ef891a7e2158189fb50f49f;p=modules%2Fshaper.git Issue #2480 Error: sub shape is not initialized when split sketch --- diff --git a/src/ModuleBase/ModuleBase_IPropertyPanel.h b/src/ModuleBase/ModuleBase_IPropertyPanel.h index 0ada2eedd..ac54a3527 100644 --- a/src/ModuleBase/ModuleBase_IPropertyPanel.h +++ b/src/ModuleBase/ModuleBase_IPropertyPanel.h @@ -43,8 +43,11 @@ public: /// Returns header widget virtual QWidget* headerWidget() const = 0; - /// Returns currently active widget - virtual ModuleBase_ModelWidget* activeWidget() const = 0; + /// Returns currently active widget. This is a widget from internal container of widgets + /// (myWidgets) activated/deactivated by focus in property panel. If parameter is true, + /// the method finds firstly the custom widget, after the direct active widget. + /// \param isUseCustomWidget boolean state if the custom widget might be a result + virtual ModuleBase_ModelWidget* activeWidget(const bool isUseCustomWidget = false) const = 0; /// Returns all property panel's widget created by WidgetFactory virtual const QList& modelWidgets() const = 0; diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index e2b9c43e3..9696ee41f 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -906,15 +906,15 @@ ModuleBase_ModelWidget* PartSet_Module::activeWidget() const { ModuleBase_ModelWidget* anActiveWidget = 0; - anActiveWidget = mySketchReentrantMgr->internalActiveWidget(); - if (!anActiveWidget) { - ModuleBase_Operation* aOperation = myWorkshop->currentOperation(); - if (aOperation) { - ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel(); - anActiveWidget = aPanel ? aPanel->activeWidget() : 0; - } - } - return anActiveWidget; + ModuleBase_Operation* aOperation = myWorkshop->currentOperation(); + if (!aOperation) + return anActiveWidget; + + ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel(); + if (!aPanel) + return anActiveWidget; + + return aPanel->activeWidget(true); } //****************************************************** diff --git a/src/PartSet/PartSet_SketcherReentrantMgr.cpp b/src/PartSet/PartSet_SketcherReentrantMgr.cpp index 839da3fa0..d861c2b52 100644 --- a/src/PartSet/PartSet_SketcherReentrantMgr.cpp +++ b/src/PartSet/PartSet_SketcherReentrantMgr.cpp @@ -44,7 +44,6 @@ #include #include "ModuleBase_ToolBox.h" #include "ModuleBase_ISelection.h" -#include "ModuleBase_ISelectionActivate.h" #include #include @@ -71,7 +70,6 @@ PartSet_SketcherReentrantMgr::PartSet_SketcherReentrantMgr(ModuleBase_IWorkshop* myRestartingMode(RM_None), myIsFlagsBlocked(false), myIsInternalEditOperation(false), - myInternalActiveWidget(0), myNoMoreWidgetsAttribute("") { } @@ -80,24 +78,6 @@ PartSet_SketcherReentrantMgr::~PartSet_SketcherReentrantMgr() { } -ModuleBase_ModelWidget* PartSet_SketcherReentrantMgr::internalActiveWidget() const -{ - ModuleBase_ModelWidget* aWidget = 0; - if (!isActiveMgr()) - return aWidget; - - ModuleBase_Operation* anOperation = myWorkshop->currentOperation(); - if (anOperation) { - ModuleBase_IPropertyPanel* aPanel = anOperation->propertyPanel(); - if (aPanel) { // check for case when the operation is started but property panel is not filled - ModuleBase_ModelWidget* anActiveWidget = aPanel->activeWidget(); - if (myIsInternalEditOperation && (!anActiveWidget || !anActiveWidget->isViewerSelector())) - aWidget = myInternalActiveWidget; - } - } - return aWidget; -} - bool PartSet_SketcherReentrantMgr::isInternalEditActive() const { return myIsInternalEditOperation; @@ -670,7 +650,7 @@ void PartSet_SketcherReentrantMgr::createInternalFeature() ModuleBase_ModelWidget* aFirstWidget = ModuleBase_IPropertyPanel::findFirstAcceptingValueWidget (aWidgets); if (aFirstWidget) - myInternalActiveWidget = aFirstWidget; + setInternalActiveWidget(aFirstWidget); } } @@ -680,8 +660,7 @@ void PartSet_SketcherReentrantMgr::deleteInternalFeature() std::cout << "PartSet_SketcherReentrantMgr::deleteInternalFeature: " << myInternalFeature->data()->name() << std::endl; #endif - if (myInternalActiveWidget) - myInternalActiveWidget = 0; + setInternalActiveWidget(0); delete myInternalWidget; myInternalWidget = 0; @@ -830,3 +809,16 @@ PartSet_Module* PartSet_SketcherReentrantMgr::module() const { return dynamic_cast(myWorkshop->module()); } + +void PartSet_SketcherReentrantMgr::setInternalActiveWidget(ModuleBase_ModelWidget* theWidget) +{ + ModuleBase_OperationFeature* aFOperation = dynamic_cast + (myWorkshop->currentOperation()); + if (aFOperation) + { + XGUI_PropertyPanel* aPropertyPanel = dynamic_cast + (aFOperation->propertyPanel()); + if (aPropertyPanel) + aPropertyPanel->setInternalActiveWidget(theWidget); + } +} diff --git a/src/PartSet/PartSet_SketcherReentrantMgr.h b/src/PartSet/PartSet_SketcherReentrantMgr.h index 073b534e8..275b59457 100644 --- a/src/PartSet/PartSet_SketcherReentrantMgr.h +++ b/src/PartSet/PartSet_SketcherReentrantMgr.h @@ -74,10 +74,6 @@ public: virtual ~PartSet_SketcherReentrantMgr(); public: - /// Returns a first widget of the current opeation if the internal edit operation is active - /// or return null. If the current widget of the operation is a viewer selector, it returns null. - ModuleBase_ModelWidget* internalActiveWidget() const; - /// Return true if the current edit operation is an internal bool isInternalEditActive() const; @@ -214,6 +210,8 @@ private: /// Returns the workshop module PartSet_Module* module() const; + void setInternalActiveWidget(ModuleBase_ModelWidget* theWidget); + private: ModuleBase_IWorkshop* myWorkshop; /// the workshop @@ -224,7 +222,6 @@ private: FeaturePtr myPreviousFeature; /// feature of the previous operation, which is restarted FeaturePtr myInternalFeature; QWidget* myInternalWidget; - ModuleBase_ModelWidget* myInternalActiveWidget; std::string myNoMoreWidgetsAttribute; std::shared_ptr myReentrantMessage; /// message obtained by operation restart diff --git a/src/SketchPlugin/SketchPlugin_Split.cpp b/src/SketchPlugin/SketchPlugin_Split.cpp index 5ac4b994b..d9e0cc252 100644 --- a/src/SketchPlugin/SketchPlugin_Split.cpp +++ b/src/SketchPlugin/SketchPlugin_Split.cpp @@ -371,7 +371,7 @@ void SketchPlugin_Split::execute() //} //aBaseShape = aShape; -#ifdef DEBUG_TRIM_METHODS +#ifdef DEBUG_SPLIT if (!aSelectedShape.get()) std::cout << "Set empty selected object" << std::endl; else @@ -423,8 +423,8 @@ void SketchPlugin_Split::execute() std::string SketchPlugin_Split::processEvent(const std::shared_ptr& theMessage) { -#ifdef DEBUG_TRIM_METHODS - std::cout << "SketchPlugin_Trim::processEvent:" << data()->name() << std::endl; +#ifdef DEBUG_SPLIT + std::cout << "SketchPlugin_Split::processEvent:" << data()->name() << std::endl; #endif std::string aFilledAttributeName; @@ -462,13 +462,23 @@ std::string SketchPlugin_Split::processEvent(const std::shared_ptrflush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); GeomShapePtr aSelectedShape = getSubShape(SELECTED_OBJECT(), SELECTED_POINT()); - #ifdef DEBUG_TRIM_METHODS + if (aSelectedShape.get()) { + aFilledAttributeName = SELECTED_OBJECT(); + } + else { + // #2480 - sub shape is not initialized when split sketch + // If restarted operation use some selection on the shape that is split and + // result selectiona can not participate in new split(checked shape above is null), + // reset filled values of selection set in this method above + aRefSelectedAttr->setValue(ResultPtr()); + aRefPreviewAttr->setValue(ResultPtr()); + } + #ifdef DEBUG_SPLIT if (!aSelectedShape.get()) std::cout << "Set empty selected object" << std::endl; else std::cout << "Set shape with ShapeType: " << aSelectedShape->shapeTypeStr() << std::endl; #endif - aFilledAttributeName = SELECTED_OBJECT(); } } } @@ -537,8 +547,8 @@ AISObjectPtr SketchPlugin_Split::getAISObject(AISObjectPtr thePrevious) return anAIS; } return AISObjectPtr();*/ -#ifdef DEBUG_TRIM_METHODS - std::cout << "SketchPlugin_Trim::getAISObject: " << data()->name() << std::endl; +#ifdef DEBUG_SPLIT + std::cout << "SketchPlugin_Split::getAISObject: " << data()->name() << std::endl; #endif AISObjectPtr anAIS = thePrevious; diff --git a/src/XGUI/XGUI_PropertyPanel.cpp b/src/XGUI/XGUI_PropertyPanel.cpp index 33288b465..0ea8af4c0 100755 --- a/src/XGUI/XGUI_PropertyPanel.cpp +++ b/src/XGUI/XGUI_PropertyPanel.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -66,6 +67,7 @@ XGUI_PropertyPanel::XGUI_PropertyPanel(QWidget* theParent, XGUI_OperationMgr* th : ModuleBase_IPropertyPanel(theParent), myActiveWidget(NULL), myPreselectionWidget(NULL), + myInternalActiveWidget(NULL), myPanelPage(NULL), myOperationMgr(theMgr) { @@ -230,6 +232,14 @@ void XGUI_PropertyPanel::createContentPanel(FeaturePtr theFeature) findButton(PROP_PANEL_OK_PLUS)->setVisible(aFeatureInfo->isApplyContinue()); } +ModuleBase_ModelWidget* XGUI_PropertyPanel::activeWidget(const bool isUseCustomWidget) const +{ + if (isUseCustomWidget && myInternalActiveWidget) + return myInternalActiveWidget; + + return myActiveWidget; +} + void XGUI_PropertyPanel::activateNextWidget(ModuleBase_ModelWidget* theWidget) { // it is possible that the property panel widgets have not been visualized @@ -574,6 +584,25 @@ void XGUI_PropertyPanel::onAcceptData() } } +void XGUI_PropertyPanel::setInternalActiveWidget(ModuleBase_ModelWidget* theWidget) +{ + if (theWidget) + { + myInternalActiveWidget = theWidget; + emit propertyPanelActivated(); + } + else + { + if (myInternalActiveWidget) + { + delete myInternalActiveWidget; + myInternalActiveWidget = 0; + } + emit propertyPanelDeactivated(); + } + myOperationMgr->workshop()->selectionActivate()->updateSelectionModes(); + myOperationMgr->workshop()->selectionActivate()->updateSelectionFilters(); +} ModuleBase_ModelWidget* XGUI_PropertyPanel::preselectionWidget() const { diff --git a/src/XGUI/XGUI_PropertyPanel.h b/src/XGUI/XGUI_PropertyPanel.h index 9a665ba48..62b87e9be 100644 --- a/src/XGUI/XGUI_PropertyPanel.h +++ b/src/XGUI/XGUI_PropertyPanel.h @@ -87,8 +87,11 @@ Q_OBJECT /// Removes all widgets in the widget area of the property panel virtual void cleanContent(); - /// Returns currently active widget - virtual ModuleBase_ModelWidget* activeWidget() const { return myActiveWidget; } + /// Returns currently active widget. This is a widget from internal container of widgets + /// (myWidgets) activated/deactivated by focus in property panel. If parameter is true, + /// the method finds firstly the custom widget, after the direct active widget. + /// \param isUseCustomWidget boolean state if the custom widget might be a result + virtual ModuleBase_ModelWidget* activeWidget(const bool isUseCustomWidget = false) const; /// Activate the next widget in the property panel /// \param theWidget a widget. The next widget should be activated @@ -136,6 +139,12 @@ Q_OBJECT /// The method is called on accepting of operation virtual void onAcceptData(); + /// Set internal active widget, that can be returned as active widget and participate in active + /// selection filters/modes in application. It emits signal about property panel activation or + /// deactivation and updates selection filters/modes accordingly. + /// \param theWidget a widget control to store as internal active widget + void setInternalActiveWidget(ModuleBase_ModelWidget* theWidget); + public slots: /// \brief Update all widgets in property panel with values from the given feature /// \param theFeature a Feature to update values in widgets @@ -203,6 +212,8 @@ private: ModuleBase_ModelWidget* myActiveWidget; /// Currently widget processed by preselection ModuleBase_ModelWidget* myPreselectionWidget; + /// Some custom widget set from outside + ModuleBase_ModelWidget* myInternalActiveWidget; XGUI_OperationMgr* myOperationMgr; }; diff --git a/src/XGUI/XGUI_SelectionActivate.cpp b/src/XGUI/XGUI_SelectionActivate.cpp index f8a1aaa88..3c6fc2f71 100644 --- a/src/XGUI/XGUI_SelectionActivate.cpp +++ b/src/XGUI/XGUI_SelectionActivate.cpp @@ -49,6 +49,10 @@ //#define DEBUG_ACTIVATE_AIS //#define DEBUG_DEACTIVATE_AIS +#ifdef TINSPECTOR +#include +#endif + #define CLEAR_OUTDATED_SELECTION_BEFORE_REDISPLAY //************************************************************** @@ -333,11 +337,19 @@ void XGUI_SelectionActivate::activateAIS(const Handle(AIS_InteractiveObject)& th } if (!aContext.IsNull()) { if (myWorkshop->module()) { - int aMode = (theMode > 8)? theMode : AIS_Shape::SelectionType(theMode); + // the code is obsolete, used in additional check before activate, it was removed + //int aMode = (theMode > 8)? theMode : AIS_Shape::SelectionType(theMode); aContext->Activate(theIO, theMode, false); - } else +#ifdef TINSPECTOR + if (getDisplayer()->getCallBack()) getDisplayer()->getCallBack()->Activate(theIO, theMode); +#endif + } + else { aContext->Activate(theIO, theMode, false); - +#ifdef TINSPECTOR + if (getDisplayer()->getCallBack()) getDisplayer()->getCallBack()->Activate(theIO, theMode); +#endif + } // the fix from VPA for more suitable selection of sketcher lines if (theIO->Width() > 1) { double aPrecision = theIO->Width() + 2;