From 7e0af4dfdaaf4168d0a6f8153e513e728bd4b544 Mon Sep 17 00:00:00 2001 From: nds Date: Fri, 16 Oct 2015 08:39:17 +0300 Subject: [PATCH] Code improvement: 'myIsResetCurrentValue', 'myIsMouseOverWindow' are removed. --- src/ModuleBase/ModuleBase_IModule.cpp | 5 -- src/PartSet/PartSet_Module.cpp | 5 -- src/PartSet/PartSet_SketcherMgr.cpp | 83 ++------------------------- src/PartSet/PartSet_SketcherMgr.h | 6 -- src/XGUI/XGUI_OperationMgr.cpp | 6 +- 5 files changed, 7 insertions(+), 98 deletions(-) diff --git a/src/ModuleBase/ModuleBase_IModule.cpp b/src/ModuleBase/ModuleBase_IModule.cpp index 4e1718da3..3cbe89b5b 100644 --- a/src/ModuleBase/ModuleBase_IModule.cpp +++ b/src/ModuleBase/ModuleBase_IModule.cpp @@ -184,11 +184,6 @@ bool ModuleBase_IModule::canRedo() const return aMgr->hasModuleDocument() && aMgr->canRedo() && !aMgr->isOperation(); } -/*/bool ModuleBase_IModule::canCommitOperation() const -{ - return true; -}*/ - void ModuleBase_IModule::onFeatureTriggered() { QAction* aCmd = dynamic_cast(sender()); diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 70c741069..ce68a0c8d 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -376,11 +376,6 @@ bool PartSet_Module::canApplyAction(const ObjectPtr& theObject, const QString& t return aValid; } -/*bool PartSet_Module::canCommitOperation() const -{ - return mySketchMgr->canCommitOperation(); -}*/ - bool PartSet_Module::canEraseObject(const ObjectPtr& theObject) const { // the sketch manager put the restriction to the objects erase diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index f89de6f2d..60e578113 100755 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -75,7 +75,6 @@ #include //#define DEBUG_DO_NOT_BY_ENTER -//#define DEBUG_MOUSE_OVER_WINDOW_FLAGS /// Returns list of unique objects by sum of objects from List1 and List2 /*QList getSumList(const QList& theList1, @@ -152,7 +151,7 @@ void getAttributesOrResults(const Handle(SelectMgr_EntityOwner)& theOwner, PartSet_SketcherMgr::PartSet_SketcherMgr(PartSet_Module* theModule) : QObject(theModule), myModule(theModule), myIsDragging(false), myDragDone(false), - /*myIsResetCurrentValue(false), */myIsMouseOverWindow(false), + myIsMouseOverWindow(false), myIsMouseOverViewProcessed(true), myPreviousUpdateViewerEnabled(true), myIsPopupMenuActive(false), myIsConstraintsShown(true) { @@ -191,14 +190,6 @@ void PartSet_SketcherMgr::onEnterViewPort() // the mouse move and use the cursor position to update own values. If the presentaion is // redisplayed before this update, the feature presentation jumps from reset value to current. myIsMouseOverWindow = true; - //myIsResetCurrentValue = false; - //myIsCurrentValueUnderModification = false; - // it is important to validate operation here only if sketch entity create operation is active - // because at this operation we reacts to the mouse leave/enter view port - //operationMgr()->onValidateOperation(); -#ifdef DEBUG_MOUSE_OVER_WINDOW_FLAGS - qDebug(QString("onEnterViewPort: %1").arg(mouseOverWindowFlagsInfo()).toStdString().c_str()); -#endif #ifdef DEBUG_DO_NOT_BY_ENTER return; @@ -234,9 +225,6 @@ void PartSet_SketcherMgr::onLeaveViewPort() // it is important to validate operation here only if sketch entity create operation is active // because at this operation we reacts to the mouse leave/enter view port //operationMgr()->onValidateOperation(); -#ifdef DEBUG_MOUSE_OVER_WINDOW_FLAGS - qDebug(QString("onLeaveViewPort: %1").arg(mouseOverWindowFlagsInfo()).toStdString().c_str()); -#endif #ifdef DEBUG_DO_NOT_BY_ENTER return; @@ -262,9 +250,8 @@ void PartSet_SketcherMgr::onLeaveViewPort() // obtained after reset value bool isEnableUpdateViewer = aDisplayer->enableUpdateViewer(false); ModuleBase_ModelWidget* anActiveWidget = getActiveWidget(); - if (anActiveWidget && anActiveWidget->reset()) { - //myIsResetCurrentValue = true; - } + if (anActiveWidget) + anActiveWidget->reset(); aDisplayer->enableUpdateViewer(isEnableUpdateViewer); // hides the presentation of the current operation feature @@ -280,12 +267,6 @@ void PartSet_SketcherMgr::onLeaveViewPort() void PartSet_SketcherMgr::onValueStateChanged() { - ///myIsCurrentValueUnderModification = true; - // update Apply enable state - //myIsResetCurrentValue = false; - //if (!isNestedCreateOperation(getCurrentOperation())) - // return; - ModuleBase_ModelWidget* anActiveWidget = getActiveWidget(); if (anActiveWidget && anActiveWidget->getValueState() != ModuleBase_ModelWidget::Stored) operationMgr()->onValidateOperation(); @@ -293,9 +274,6 @@ void PartSet_SketcherMgr::onValueStateChanged() void PartSet_SketcherMgr::onBeforeValuesChangedInPropertyPanel() { - //myIsResetCurrentValue = false; - //myIsCurrentValueUnderModification = false; - if (isNestedCreateOperation(getCurrentOperation())) return; // it is necessary to save current selection in order to restore it after the values are modifed @@ -330,8 +308,6 @@ void PartSet_SketcherMgr::onValuesChangedInPropertyPanel() if (!isNestedCreateOperation(getCurrentOperation())) return; - // visualize the current operation feature - //myIsResetCurrentValue = false; operationMgr()->onValidateOperation(); // the feature is to be erased here, but it is correct to call canDisplayObject because // there can be additional check (e.g. editor widget in distance constraint) @@ -716,28 +692,6 @@ QString PartSet_SketcherMgr::getFeatureError(const FeaturePtr& theFeature) AttributeStringPtr aAttributeString = aSketch->string(SketchPlugin_Sketch::SOLVER_ERROR()); anError = aAttributeString->value().c_str(); } - /*else if (myIsResetCurrentValue /*|| myIsCurrentValueUnderModification*+/) { - // this flags do not allow commit of the current operation - ModuleBase_OperationFeature* aFOperation = dynamic_cast - (getCurrentOperation()); - if (aFOperation) { - FeaturePtr aFeature = aFOperation->feature(); - if (aFeature.get() && aFeature == theFeature && isNestedCreateOperation(aFOperation)) { - QString anAttributeName = ""; - ModuleBase_ModelWidget* anActiveWidget = getActiveWidget(); - if (anActiveWidget) { - AttributePtr anAttr = aFeature->attribute(anActiveWidget->attributeID()); - if (anAttr.get()) - anAttributeName = anAttr->id().c_str(); - } - if (myIsResetCurrentValue) - anError = "Attribute \"" + anAttributeName + "\" is not initialized."; - //else if (myIsCurrentValueUnderModification) { - // anError = "Attribute \"" + anAttributeName + "\" modification is not applyed. Please click \"Enter\" or \"Tab\"."; - //} - } - } - }*/ else { ModuleBase_ModelWidget* anActiveWidget = getActiveWidget(); if (anActiveWidget) { @@ -904,9 +858,7 @@ void PartSet_SketcherMgr::stopSketch(ModuleBase_Operation* theOperation) { myIsMouseOverWindow = false; myIsConstraintsShown = true; -#ifdef DEBUG_MOUSE_OVER_WINDOW_FLAGS - qDebug(QString("stopSketch: %1").arg(mouseOverWindowFlagsInfo()).toStdString().c_str()); -#endif + XGUI_ModuleConnector* aConnector = dynamic_cast(myModule->workshop()); DataPtr aData = myCurrentSketch->data(); @@ -974,8 +926,6 @@ void PartSet_SketcherMgr::startNestedSketch(ModuleBase_Operation* theOperation) void PartSet_SketcherMgr::stopNestedSketch(ModuleBase_Operation* theOp) { connectToPropertyPanel(false); - //myIsResetCurrentValue = false; - //myIsCurrentValueUnderModification = false; myIsMouseOverViewProcessed = true; operationMgr()->onValidateOperation(); if (isNestedCreateOperation(theOp)) @@ -1008,17 +958,6 @@ bool PartSet_SketcherMgr::canRedo() const return isNestedCreateOperation(getCurrentOperation()); } -/*bool PartSet_SketcherMgr::canCommitOperation() const -{ - bool aCanCommit = true; - - if (isNestedCreateOperation(getCurrentOperation()) && - (myIsResetCurrentValue || myIsCurrentValueUnderModification)) - aCanCommit = false; - - return aCanCommit; -}*/ - bool PartSet_SketcherMgr::canEraseObject(const ObjectPtr& theObject) const { bool aCanErase = true; @@ -1116,14 +1055,10 @@ bool PartSet_SketcherMgr::canDisplayCurrentCreatedFeature() const bool aCanDisplay = myIsMouseOverWindow; if (!aCanDisplay) { ModuleBase_ModelWidget* anActiveWidget = getActiveWidget(); - bool isValueStored = anActiveWidget && anActiveWidget->getValueState() == ModuleBase_ModelWidget::Stored; - aCanDisplay = /*!myIsResetCurrentValue &&*/isValueStored; + if (anActiveWidget) + aCanDisplay = anActiveWidget->getValueState() == ModuleBase_ModelWidget::Stored; } return aCanDisplay; - //return myIsMouseOverWindow || (!myIsResetCurrentValue && !myIsCurrentValueUnderModification); -#ifdef DEBUG_MOUSE_OVER_WINDOW_FLAGS - qDebug(QString("canDisplayCurrentCreatedFeature: %1").arg(mouseOverWindowFlagsInfo()).toStdString().c_str()); -#endif } bool PartSet_SketcherMgr::isObjectOfSketch(const ObjectPtr& theObject) const @@ -1417,12 +1352,6 @@ void PartSet_SketcherMgr::onShowConstraintsToggle(bool theOn) Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); } -QString PartSet_SketcherMgr::mouseOverWindowFlagsInfo() const -{ - return "";//QString("myIsResetCurrentValue = %1, myIsMouseOverWindow = %2") - //.arg(myIsResetCurrentValue).arg(myIsMouseOverWindow); -} - XGUI_OperationMgr* PartSet_SketcherMgr::operationMgr() const { ModuleBase_IWorkshop* anIWorkshop = myModule->workshop(); diff --git a/src/PartSet/PartSet_SketcherMgr.h b/src/PartSet/PartSet_SketcherMgr.h index 44cbca6d5..d2a5226ed 100644 --- a/src/PartSet/PartSet_SketcherMgr.h +++ b/src/PartSet/PartSet_SketcherMgr.h @@ -291,10 +291,6 @@ private: void visualizeFeature(const FeaturePtr& theFeature, const bool isEditOperation, const bool isToDisplay, const bool isFlushRedisplay = true); private: - /// Gives a debug information about internal flags myIsMouseOverWindow and myIsResetCurrentValue - /// \return a string value - QString mouseOverWindowFlagsInfo() const; - XGUI_OperationMgr* operationMgr() const; private: @@ -303,8 +299,6 @@ private: bool myPreviousDrawModeEnabled; // the previous selection enabled state in the viewer bool myIsDragging; bool myDragDone; - bool myIsResetCurrentValue; /// the state that value in the property panel is reset - //bool myIsCurrentValueUnderModification; /// the value is modified in PP but it is not applyed in the model bool myIsMouseOverWindow; /// the state that the mouse over the view bool myIsMouseOverViewProcessed; /// the state whether the over view state is processed by mouseMove method bool myIsPopupMenuActive; /// the state of the popup menu is shown diff --git a/src/XGUI/XGUI_OperationMgr.cpp b/src/XGUI/XGUI_OperationMgr.cpp index 119e36078..0410fce49 100644 --- a/src/XGUI/XGUI_OperationMgr.cpp +++ b/src/XGUI/XGUI_OperationMgr.cpp @@ -192,14 +192,10 @@ void XGUI_OperationMgr::onValidateOperation() { if (!hasOperation()) return; - //ModuleBase_Operation* anOperation = currentOperation(); ModuleBase_OperationFeature* aFOperation = dynamic_cast (currentOperation()); - if(aFOperation && aFOperation->feature().get()) { - //bool aCanCommit = myWorkshop->module()->canCommitOperation(); - //setApplyEnabled(!myIsValidationLock && aCanCommit && anOperation->isValid()); + if(aFOperation && aFOperation->feature().get()) setApplyEnabled(myWorkshop->module()->getFeatureError(aFOperation->feature()).isEmpty()); - } } void XGUI_OperationMgr::setLockValidating(bool toLock) -- 2.39.2