From 2047ad9384312b58e764cea4d90527d1205467b4 Mon Sep 17 00:00:00 2001 From: nds Date: Thu, 29 Oct 2015 08:46:34 +0300 Subject: [PATCH] 1. Circle creation - when 'internal' edit operation is active, the first click should fill the first attribute of a new circle. 2. onNoMoreWidgets is moved to sketch reentrant manager. --- src/PartSet/PartSet_Module.cpp | 14 ++-------- src/PartSet/PartSet_Module.h | 7 ----- src/PartSet/PartSet_SketcherMgr.cpp | 6 ++++ src/PartSet/PartSet_SketcherReetntrantMgr.cpp | 28 +++++++++++-------- src/PartSet/PartSet_SketcherReetntrantMgr.h | 16 +++++++---- src/XGUI/XGUI_PropertyPanel.cpp | 6 ++-- src/XGUI/XGUI_Workshop.cpp | 4 --- 7 files changed, 37 insertions(+), 44 deletions(-) diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index d55095a44..16119db37 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -525,16 +525,6 @@ void PartSet_Module::onOperationActivatedByPreselection() } } -void PartSet_Module::onNoMoreWidgets(const std::string& thePreviousAttributeID) -{ - mySketchReentrantMgr->noMoreWidgets(thePreviousAttributeID); -} - -void PartSet_Module::onVertexSelected() -{ - mySketchReentrantMgr->vertexSelected(); -} - ModuleBase_ModelWidget* PartSet_Module::createWidgetByType(const std::string& theType, QWidget* theParent, Config_WidgetAPI* theWidgetApi, std::string theParentId) { @@ -554,13 +544,13 @@ ModuleBase_ModelWidget* PartSet_Module::createWidgetByType(const std::string& th PartSet_WidgetPoint2D* aPointWgt = new PartSet_WidgetPoint2D(theParent, aWorkshop, theWidgetApi, theParentId); aPointWgt->setSketch(mySketchMgr->activeSketch()); - connect(aPointWgt, SIGNAL(vertexSelected()), this, SLOT(onVertexSelected())); + connect(aPointWgt, SIGNAL(vertexSelected()), sketchReentranceMgr(), SLOT(onVertexSelected())); aWgt = aPointWgt; } else if (theType == "sketch-2dpoint_flyout_selector") { PartSet_WidgetPoint2DFlyout* aPointWgt = new PartSet_WidgetPoint2DFlyout(theParent, aWorkshop, theWidgetApi, theParentId); aPointWgt->setSketch(mySketchMgr->activeSketch()); - connect(aPointWgt, SIGNAL(vertexSelected()), this, SLOT(onVertexSelected())); + connect(aPointWgt, SIGNAL(vertexSelected()), sketchReentranceMgr(), SLOT(onVertexSelected())); aWgt = aPointWgt; } else if (theType == "point2ddistance") { PartSet_WidgetPoint2dDistance* aDistanceWgt = new PartSet_WidgetPoint2dDistance(theParent, diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index 8db2d8305..e5a37bcda 100644 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -212,10 +212,6 @@ public: virtual void grantedOperationIds(ModuleBase_Operation* theOperation, QStringList& theIds) const; public slots: - /// SLOT, that is called by no more widget signal emitted by property panel - /// Set a specific flag to restart the sketcher operation - void onNoMoreWidgets(const std::string& thePreviousAttributeID); - /// Redefines the parent method in order to customize the next case: /// If the sketch nested operation is active and the presentation is not visualized in the viewer, /// the operation should be always aborted. @@ -266,9 +262,6 @@ protected slots: virtual void registerProperties(); private slots: - /// Processing of vertex selected - void onVertexSelected(); - void onTreeViewDoubleClick(const QModelIndex&); private: diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index 62a37589c..bf034c85a 100644 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -632,6 +632,12 @@ void PartSet_SketcherMgr::onApplicationStarted() if (aPropertyPanel) { connect(aPropertyPanel, SIGNAL(beforeWidgetActivated(ModuleBase_ModelWidget*)), this, SLOT(onBeforeWidgetActivated(ModuleBase_ModelWidget*))); + + PartSet_SketcherReetntrantMgr* aReentranceMgr = myModule->sketchReentranceMgr(); + connect(aPropertyPanel, SIGNAL(noMoreWidgets(const std::string&)), + aReentranceMgr, SLOT(onNoMoreWidgets(const std::string&))); + connect(aPropertyPanel, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)), + aReentranceMgr, SLOT(onWidgetActivated())); } XGUI_ViewerProxy* aViewerProxy = aWorkshop->viewer(); diff --git a/src/PartSet/PartSet_SketcherReetntrantMgr.cpp b/src/PartSet/PartSet_SketcherReetntrantMgr.cpp index 96050b878..de4baeee1 100755 --- a/src/PartSet/PartSet_SketcherReetntrantMgr.cpp +++ b/src/PartSet/PartSet_SketcherReetntrantMgr.cpp @@ -89,7 +89,7 @@ bool PartSet_SketcherReetntrantMgr::operationCommitted(ModuleBase_Operation* the myIsInternalEditOperation = true; // activate selection filters of the first widget in the viewer - onInternalActivateFirstWidgetSelection(); + onWidgetActivated(); // activate the last active widget in the Property Panel if (!myPreviousAttributeID.empty()) { @@ -135,6 +135,8 @@ void PartSet_SketcherReetntrantMgr::operationAborted(ModuleBase_Operation* theOp SessionPtr aMgr = ModelAPI_Session::get(); if (aMgr->hasModuleDocument() && aMgr->canUndo()) { aMgr->undo(); + workshop()->operationMgr()->updateApplyOfOperations(); + workshop()->updateCommandStatus(); } } myIsInternalEditOperation = false; @@ -152,7 +154,6 @@ bool PartSet_SketcherReetntrantMgr::processMouseMoved(ModuleBase_IViewWindow*/* PartSet_WidgetPoint2D* aPoint2DWdg = dynamic_cast(module()->activeWidget()); if (aPoint2DWdg && aPoint2DWdg->canBeActivatedByMove()) { ModuleBase_Operation* anOperation = myWorkshop->currentOperation(); - //if (operationMgr()->isApplyEnabled()) anOperation->commit(); aProcessed = true; } @@ -175,14 +176,17 @@ bool PartSet_SketcherReetntrantMgr::processMouseReleased(ModuleBase_IViewWindow* if (myIsInternalEditOperation) { ModuleBase_Operation* anOperation = myWorkshop->currentOperation(); - //if (operationMgr()->isApplyEnabled()) - anOperation->commit(); - aProcessed = true; - // fill the widget by the mouse event point - PartSet_WidgetPoint2D* aPoint2DWdg = dynamic_cast(module()->activeWidget()); - if (aPoint2DWdg) { - aPoint2DWdg->onMouseRelease(theWnd, theEvent); + ModuleBase_ModelWidget* anActiveWidget = anOperation->propertyPanel()->activeWidget(); + if (!anActiveWidget || !anActiveWidget->isViewerSelector()) { + anOperation->commit(); + aProcessed = true; + + // fill the widget by the mouse event point + PartSet_WidgetPoint2D* aPoint2DWdg = dynamic_cast(module()->activeWidget()); + if (aPoint2DWdg) { + aPoint2DWdg->onMouseRelease(theWnd, theEvent); + } } } @@ -215,7 +219,7 @@ void PartSet_SketcherReetntrantMgr::propertyPanelDefined(ModuleBase_Operation* t } } -void PartSet_SketcherReetntrantMgr::noMoreWidgets(const std::string& thePreviousAttributeID) +void PartSet_SketcherReetntrantMgr::onNoMoreWidgets(const std::string& thePreviousAttributeID) { if (!isActiveMgr()) return; @@ -236,7 +240,7 @@ void PartSet_SketcherReetntrantMgr::noMoreWidgets(const std::string& thePrevious } } -void PartSet_SketcherReetntrantMgr::vertexSelected() +void PartSet_SketcherReetntrantMgr::onVertexSelected() { if (!isActiveMgr()) return; @@ -277,7 +281,7 @@ bool PartSet_SketcherReetntrantMgr::canBeCommittedByPreselection() return !isActiveMgr() || myRestartingMode == RM_None; } -void PartSet_SketcherReetntrantMgr::onInternalActivateFirstWidgetSelection() +void PartSet_SketcherReetntrantMgr::onWidgetActivated() { if (!isActiveMgr()) return; diff --git a/src/PartSet/PartSet_SketcherReetntrantMgr.h b/src/PartSet/PartSet_SketcherReetntrantMgr.h index 0c232eef0..54cdfd20c 100755 --- a/src/PartSet/PartSet_SketcherReetntrantMgr.h +++ b/src/PartSet/PartSet_SketcherReetntrantMgr.h @@ -81,9 +81,6 @@ public: /// Activates the operation widgets relatively the internal reentrant flags void propertyPanelDefined(ModuleBase_Operation* theOperation); - /// It is called by no more widget signal emitted by property panel - /// Set a specific flag to restart the sketcher operation - void noMoreWidgets(const std::string& thePreviousAttributeID); /// Processing of vertex selected, if the feature is line, save flags to stop reentrant operation void vertexSelected(); @@ -96,8 +93,17 @@ public: /// Returns false if the reentrant mode of the operation is not empty. bool canBeCommittedByPreselection(); -public slots: - void onInternalActivateFirstWidgetSelection(); +private slots: + /// SLOT, that is called by a widget activating in the property panel + /// If the 'internal' edit operation is started, it activates the first control selection + void onWidgetActivated(); + + /// SLOT, that is called by no more widget signal emitted by property panel + /// Set a specific flag to restart the sketcher operation + void onNoMoreWidgets(const std::string& thePreviousAttributeID); + + /// Processing of vertex selected + void onVertexSelected(); private: /// Returns true if the current operation is a sketch or a nested sketch operation diff --git a/src/XGUI/XGUI_PropertyPanel.cpp b/src/XGUI/XGUI_PropertyPanel.cpp index d1eea7687..73cdab5a2 100644 --- a/src/XGUI/XGUI_PropertyPanel.cpp +++ b/src/XGUI/XGUI_PropertyPanel.cpp @@ -209,11 +209,9 @@ void XGUI_PropertyPanel::activateWidget(ModuleBase_ModelWidget* theWidget) theWidget->activate(); } myActiveWidget = theWidget; - if (myActiveWidget) { - emit widgetActivated(theWidget); - } else if (!isEditingMode()) { + emit widgetActivated(theWidget); + if (!myActiveWidget && !isEditingMode()) { emit noMoreWidgets(aPreviosAttributeID); - //setFocusOnOkButton(); } } diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index cb6e77a0e..71af25fb3 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -1010,14 +1010,10 @@ void XGUI_Workshop::createDockWidgets() QAction* aCancelAct = myActionsMgr->operationStateAction(XGUI_ActionsMgr::Abort); connect(aCancelAct, SIGNAL(triggered()), myOperationMgr, SLOT(onAbortOperation())); - connect(myPropertyPanel, SIGNAL(noMoreWidgets(const std::string&)), - myModule, SLOT(onNoMoreWidgets(const std::string&))); connect(myPropertyPanel, SIGNAL(keyReleased(QKeyEvent*)), myOperationMgr, SLOT(onKeyReleased(QKeyEvent*))); //connect(myOperationMgr, SIGNAL(validationStateChanged(bool)), // this, SLOT(onValidationStateChanged(bool))); - connect(myPropertyPanel, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)), - myModule, SLOT(onInternalActivateFirstWidgetSelection())); } //****************************************************** -- 2.39.2