From: nds Date: Thu, 14 Apr 2016 13:27:01 +0000 (+0300) Subject: 1. Correction for perfomance problem by Apply button state update: do not listen... X-Git-Tag: V_2.3.0~225 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3b676e8f67d0b110ecee42985223b99fc181532b;p=modules%2Fshaper.git 1. Correction for perfomance problem by Apply button state update: do not listen EVENT_OBJECT_ERROR_CHANGED, perform update after flushing Updated signal of modified value 2. Layout correction for Extrusion's multi-selector height(regression) 3. Issue #1343 correction to do not show preview planes if there is a visualized sketch --- diff --git a/src/ModuleBase/ModuleBase_ModelWidget.cpp b/src/ModuleBase/ModuleBase_ModelWidget.cpp index dc56812fc..b1d5b5a46 100644 --- a/src/ModuleBase/ModuleBase_ModelWidget.cpp +++ b/src/ModuleBase/ModuleBase_ModelWidget.cpp @@ -285,13 +285,10 @@ bool ModuleBase_ModelWidget::restoreValue() return isDone; } -void ModuleBase_ModelWidget::updateObject(ObjectPtr theObj) +void ModuleBase_ModelWidget::updateObject(ObjectPtr theObject) { - blockUpdateViewer(true); - - Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); - - blockUpdateViewer(false); + ModuleBase_Tools::flushUpdated(theObject); + emit objectUpdated(); } void ModuleBase_ModelWidget::moveObject(ObjectPtr theObj) @@ -360,23 +357,3 @@ void ModuleBase_ModelWidget::onWidgetValuesModified() { setValueState(ModifiedInPP); } - -//************************************************************** -void ModuleBase_ModelWidget::blockUpdateViewer(const bool theValue) -{ - // the viewer update should be blocked in order to avoid the temporary feature content - // when the solver processes the feature, the redisplay message can be flushed - // what caused the display in the viewer preliminary states of object - // e.g. fillet feature, angle value change - std::shared_ptr aMsg; - if (theValue) { - aMsg = std::shared_ptr( - new Events_Message(Events_Loop::eventByName(EVENT_UPDATE_VIEWER_BLOCKED))); - } - else { - // the viewer update should be unblocked - aMsg = std::shared_ptr( - new Events_Message(Events_Loop::eventByName(EVENT_UPDATE_VIEWER_UNBLOCKED))); - } - Events_Loop::loop()->send(aMsg); -} diff --git a/src/ModuleBase/ModuleBase_ModelWidget.h b/src/ModuleBase/ModuleBase_ModelWidget.h index 2075a16de..def9a3fcb 100644 --- a/src/ModuleBase/ModuleBase_ModelWidget.h +++ b/src/ModuleBase/ModuleBase_ModelWidget.h @@ -196,16 +196,12 @@ Q_OBJECT /// Sends Update and Redisplay for the given object /// \param theObj is updating object - static void updateObject(ObjectPtr theObj); + void updateObject(ObjectPtr theObj); /// Sends Move event for the given object /// \param theObj is object for moving static void moveObject(ObjectPtr theObj); - /// Sends a message about block/unblock viewer updating - /// \param theValue a boolean value - static void blockUpdateViewer(const bool theValue); - signals: /// The signal about widget values are to be changed void beforeValuesChanged(); @@ -241,6 +237,9 @@ signals: /// The signal about value state modification void valueStateChanged(int theState); + /// The signal is emitted after flush of updates singal for the widget + void objectUpdated(); + protected: /// Sets default value of widget. Normally, widget should fetch this value /// from the xml. However, some widgets derived widgets could define it @@ -269,7 +268,7 @@ protected: /// Saves the internal parameters to the given feature /// \return True in success - virtual bool storeValueCustom() const = 0; + virtual bool storeValueCustom() = 0; /// Restore value from attribute data to the widget's control virtual bool restoreValueCustom() = 0; diff --git a/src/ModuleBase/ModuleBase_OperationFeature.cpp b/src/ModuleBase/ModuleBase_OperationFeature.cpp index f6838a049..2508ac0c1 100755 --- a/src/ModuleBase/ModuleBase_OperationFeature.cpp +++ b/src/ModuleBase/ModuleBase_OperationFeature.cpp @@ -172,8 +172,10 @@ FeaturePtr ModuleBase_OperationFeature::createFeature(const bool theFlushMessage }*/ } - if (theFlushMessage) + if (theFlushMessage) { Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED)); + Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); + } return myFeature; } @@ -381,7 +383,7 @@ ModuleBase_ModelWidget* ModuleBase_OperationFeature::activateByPreselection( // in order to redisplay object in the viewer, the update/redisplay signals should be flushed // it is better to perform it not in setSelection of each widget, but do it here, // after the preselection is processed - ModuleBase_ModelWidget::updateObject(myFeature); + ModuleBase_Tools::flushUpdated(myFeature); } } clearPreselection(); diff --git a/src/ModuleBase/ModuleBase_PagedContainer.cpp b/src/ModuleBase/ModuleBase_PagedContainer.cpp index 4da74e212..d069b57f6 100644 --- a/src/ModuleBase/ModuleBase_PagedContainer.cpp +++ b/src/ModuleBase/ModuleBase_PagedContainer.cpp @@ -93,7 +93,7 @@ void ModuleBase_PagedContainer::activateCustom() focusTo(); } -bool ModuleBase_PagedContainer::storeValueCustom() const +bool ModuleBase_PagedContainer::storeValueCustom() { // A rare case when plugin was not loaded. if(!myFeature) diff --git a/src/ModuleBase/ModuleBase_PagedContainer.h b/src/ModuleBase/ModuleBase_PagedContainer.h index aee2e5c75..4522a8a8e 100644 --- a/src/ModuleBase/ModuleBase_PagedContainer.h +++ b/src/ModuleBase/ModuleBase_PagedContainer.h @@ -60,7 +60,7 @@ class MODULEBASE_EXPORT ModuleBase_PagedContainer : public ModuleBase_ModelWidge virtual void activateCustom(); /// Redefinition of virtual function - virtual bool storeValueCustom() const; + virtual bool storeValueCustom(); /// Redefinition of virtual function virtual bool restoreValueCustom(); diff --git a/src/ModuleBase/ModuleBase_Tools.cpp b/src/ModuleBase/ModuleBase_Tools.cpp index 56d7d2dbf..baaea0da0 100755 --- a/src/ModuleBase/ModuleBase_Tools.cpp +++ b/src/ModuleBase/ModuleBase_Tools.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -26,6 +27,7 @@ #include #include #include +#include #include @@ -513,6 +515,34 @@ GeomShapePtr getShape(const AttributePtr& theAttribute, ModuleBase_IWorkshop* th return aShape; } +void flushUpdated(ObjectPtr theObject) +{ + blockUpdateViewer(true); + + Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); + + blockUpdateViewer(false); +} + +void blockUpdateViewer(const bool theValue) +{ + // the viewer update should be blocked in order to avoid the temporary feature content + // when the solver processes the feature, the redisplay message can be flushed + // what caused the display in the viewer preliminary states of object + // e.g. fillet feature, angle value change + std::shared_ptr aMsg; + if (theValue) { + aMsg = std::shared_ptr( + new Events_Message(Events_Loop::eventByName(EVENT_UPDATE_VIEWER_BLOCKED))); + } + else { + // the viewer update should be unblocked + aMsg = std::shared_ptr( + new Events_Message(Events_Loop::eventByName(EVENT_UPDATE_VIEWER_UNBLOCKED))); + } + Events_Loop::loop()->send(aMsg); +} + } // namespace ModuleBase_Tools diff --git a/src/ModuleBase/ModuleBase_Tools.h b/src/ModuleBase/ModuleBase_Tools.h index 1c29e7a99..610136420 100755 --- a/src/ModuleBase/ModuleBase_Tools.h +++ b/src/ModuleBase/ModuleBase_Tools.h @@ -199,6 +199,14 @@ MODULEBASE_EXPORT void setObject(const AttributePtr& theAttribute, const ObjectP MODULEBASE_EXPORT std::shared_ptr getShape(const AttributePtr& theAttribute, ModuleBase_IWorkshop* theWorkshop); +/// Flush updated signal for the object. The viewer update is blocked in the process +/// \param theObject parameter of the signal +MODULEBASE_EXPORT void flushUpdated(ObjectPtr theObject); + +/// Sends a message about block/unblock viewer updating +/// \param theValue a boolean value +MODULEBASE_EXPORT void blockUpdateViewer(const bool theValue); + } #endif diff --git a/src/ModuleBase/ModuleBase_WidgetBoolValue.cpp b/src/ModuleBase/ModuleBase_WidgetBoolValue.cpp index 074b832c0..b0ff0d2a1 100644 --- a/src/ModuleBase/ModuleBase_WidgetBoolValue.cpp +++ b/src/ModuleBase/ModuleBase_WidgetBoolValue.cpp @@ -44,7 +44,7 @@ ModuleBase_WidgetBoolValue::~ModuleBase_WidgetBoolValue() { } -bool ModuleBase_WidgetBoolValue::storeValueCustom() const +bool ModuleBase_WidgetBoolValue::storeValueCustom() { DataPtr aData = myFeature->data(); std::shared_ptr aBool = aData->boolean(attributeID()); diff --git a/src/ModuleBase/ModuleBase_WidgetBoolValue.h b/src/ModuleBase/ModuleBase_WidgetBoolValue.h index c3764bdcc..237460ec7 100644 --- a/src/ModuleBase/ModuleBase_WidgetBoolValue.h +++ b/src/ModuleBase/ModuleBase_WidgetBoolValue.h @@ -38,7 +38,7 @@ Q_OBJECT protected: /// Saves the internal parameters to the given feature /// \return True in success - virtual bool storeValueCustom() const; + virtual bool storeValueCustom(); virtual bool restoreValueCustom(); diff --git a/src/ModuleBase/ModuleBase_WidgetCheckGroupBox.cpp b/src/ModuleBase/ModuleBase_WidgetCheckGroupBox.cpp index cee0ff987..116269485 100755 --- a/src/ModuleBase/ModuleBase_WidgetCheckGroupBox.cpp +++ b/src/ModuleBase/ModuleBase_WidgetCheckGroupBox.cpp @@ -103,7 +103,7 @@ QLayout* ModuleBase_WidgetCheckGroupBox::pageLayout() return myMainLayout; } -bool ModuleBase_WidgetCheckGroupBox::storeValueCustom() const +bool ModuleBase_WidgetCheckGroupBox::storeValueCustom() { DataPtr aData = myFeature->data(); std::shared_ptr aBool = aData->boolean(attributeID()); diff --git a/src/ModuleBase/ModuleBase_WidgetCheckGroupBox.h b/src/ModuleBase/ModuleBase_WidgetCheckGroupBox.h index dcb7012ce..d9d9f533c 100755 --- a/src/ModuleBase/ModuleBase_WidgetCheckGroupBox.h +++ b/src/ModuleBase/ModuleBase_WidgetCheckGroupBox.h @@ -62,7 +62,7 @@ protected: /// Methods to be redefined from ModuleBase_ModelWidget: start /// Saves the internal parameters to the given feature /// \return True in success - virtual bool storeValueCustom() const; + virtual bool storeValueCustom(); /// Restore value from attribute data to the widget's control virtual bool restoreValueCustom(); /// Methods to be redefined from ModuleBase_ModelWidget: end diff --git a/src/ModuleBase/ModuleBase_WidgetChoice.cpp b/src/ModuleBase/ModuleBase_WidgetChoice.cpp index f8b4ff516..e35f3c212 100644 --- a/src/ModuleBase/ModuleBase_WidgetChoice.cpp +++ b/src/ModuleBase/ModuleBase_WidgetChoice.cpp @@ -104,7 +104,7 @@ ModuleBase_WidgetChoice::~ModuleBase_WidgetChoice() { } -bool ModuleBase_WidgetChoice::storeValueCustom() const +bool ModuleBase_WidgetChoice::storeValueCustom() { DataPtr aData = myFeature->data(); std::shared_ptr aIntAttr = aData->integer(attributeID()); diff --git a/src/ModuleBase/ModuleBase_WidgetChoice.h b/src/ModuleBase/ModuleBase_WidgetChoice.h index e0f90d720..e5c66a9cc 100644 --- a/src/ModuleBase/ModuleBase_WidgetChoice.h +++ b/src/ModuleBase/ModuleBase_WidgetChoice.h @@ -65,7 +65,7 @@ signals: protected: /// Saves the internal parameters to the given feature /// \return True in success - virtual bool storeValueCustom() const; + virtual bool storeValueCustom(); virtual bool restoreValueCustom(); diff --git a/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp b/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp index fa4e22c18..5bbf18447 100644 --- a/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp +++ b/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp @@ -126,7 +126,7 @@ bool ModuleBase_WidgetDoubleValue::resetCustom() return aDone; } -bool ModuleBase_WidgetDoubleValue::storeValueCustom() const +bool ModuleBase_WidgetDoubleValue::storeValueCustom() { DataPtr aData = myFeature->data(); AttributeDoublePtr aReal = aData->real(attributeID()); diff --git a/src/ModuleBase/ModuleBase_WidgetDoubleValue.h b/src/ModuleBase/ModuleBase_WidgetDoubleValue.h index e77b17cc3..de2a9acef 100644 --- a/src/ModuleBase/ModuleBase_WidgetDoubleValue.h +++ b/src/ModuleBase/ModuleBase_WidgetDoubleValue.h @@ -56,7 +56,7 @@ Q_OBJECT protected: /// Saves the internal parameters to the given feature /// \return True in success - virtual bool storeValueCustom() const; + virtual bool storeValueCustom(); //! Read value of corresponded attribute from data model to the input control // \return True in success diff --git a/src/ModuleBase/ModuleBase_WidgetExprEditor.cpp b/src/ModuleBase/ModuleBase_WidgetExprEditor.cpp index a47d9e367..ed22ac55f 100644 --- a/src/ModuleBase/ModuleBase_WidgetExprEditor.cpp +++ b/src/ModuleBase/ModuleBase_WidgetExprEditor.cpp @@ -248,7 +248,7 @@ void ModuleBase_WidgetExprEditor::initializeValueByActivate() { } -bool ModuleBase_WidgetExprEditor::storeValueCustom() const +bool ModuleBase_WidgetExprEditor::storeValueCustom() { // A rare case when plugin was not loaded. if(!myFeature) diff --git a/src/ModuleBase/ModuleBase_WidgetExprEditor.h b/src/ModuleBase/ModuleBase_WidgetExprEditor.h index b3a63174b..ef04f2386 100644 --- a/src/ModuleBase/ModuleBase_WidgetExprEditor.h +++ b/src/ModuleBase/ModuleBase_WidgetExprEditor.h @@ -126,7 +126,7 @@ protected: /// Saves the internal parameters to the given feature /// \return True in success - virtual bool storeValueCustom() const; + virtual bool storeValueCustom(); /// Redefinition of virtual method virtual bool restoreValueCustom(); diff --git a/src/ModuleBase/ModuleBase_WidgetFileSelector.cpp b/src/ModuleBase/ModuleBase_WidgetFileSelector.cpp index f3238f222..4c7573061 100644 --- a/src/ModuleBase/ModuleBase_WidgetFileSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetFileSelector.cpp @@ -65,7 +65,7 @@ ModuleBase_WidgetFileSelector::~ModuleBase_WidgetFileSelector() { } -bool ModuleBase_WidgetFileSelector::storeValueCustom() const +bool ModuleBase_WidgetFileSelector::storeValueCustom() { // A rare case when plugin was not loaded. if (!myFeature) diff --git a/src/ModuleBase/ModuleBase_WidgetFileSelector.h b/src/ModuleBase/ModuleBase_WidgetFileSelector.h index 4d6c3b1d5..2f6612413 100644 --- a/src/ModuleBase/ModuleBase_WidgetFileSelector.h +++ b/src/ModuleBase/ModuleBase_WidgetFileSelector.h @@ -64,7 +64,7 @@ class MODULEBASE_EXPORT ModuleBase_WidgetFileSelector : public ModuleBase_ModelW protected: /// Saves the internal parameters to the given feature /// \return True in success - virtual bool storeValueCustom() const; + virtual bool storeValueCustom(); virtual bool restoreValueCustom(); diff --git a/src/ModuleBase/ModuleBase_WidgetIntValue.cpp b/src/ModuleBase/ModuleBase_WidgetIntValue.cpp index 95074f73a..996e16fb5 100644 --- a/src/ModuleBase/ModuleBase_WidgetIntValue.cpp +++ b/src/ModuleBase/ModuleBase_WidgetIntValue.cpp @@ -110,7 +110,7 @@ bool ModuleBase_WidgetIntValue::resetCustom() return aDone; } -bool ModuleBase_WidgetIntValue::storeValueCustom() const +bool ModuleBase_WidgetIntValue::storeValueCustom() { DataPtr aData = myFeature->data(); AttributeIntegerPtr anAttribute = aData->integer(attributeID()); diff --git a/src/ModuleBase/ModuleBase_WidgetIntValue.h b/src/ModuleBase/ModuleBase_WidgetIntValue.h index d88b4d156..d873304de 100644 --- a/src/ModuleBase/ModuleBase_WidgetIntValue.h +++ b/src/ModuleBase/ModuleBase_WidgetIntValue.h @@ -48,7 +48,7 @@ Q_OBJECT protected: /// Saves the internal parameters to the given feature /// \return True in success - virtual bool storeValueCustom() const; + virtual bool storeValueCustom(); //! Read value of corresponded attribute from data model to the input control // \return True in success diff --git a/src/ModuleBase/ModuleBase_WidgetLabel.h b/src/ModuleBase/ModuleBase_WidgetLabel.h index 97454bf6f..d2ab2d647 100644 --- a/src/ModuleBase/ModuleBase_WidgetLabel.h +++ b/src/ModuleBase/ModuleBase_WidgetLabel.h @@ -44,7 +44,7 @@ Q_OBJECT protected: /// Saves the internal parameters to the given feature /// \return True in success - virtual bool storeValueCustom() const + virtual bool storeValueCustom() { return true; } diff --git a/src/ModuleBase/ModuleBase_WidgetLineEdit.cpp b/src/ModuleBase/ModuleBase_WidgetLineEdit.cpp index 5b2929c4f..54223e6d2 100644 --- a/src/ModuleBase/ModuleBase_WidgetLineEdit.cpp +++ b/src/ModuleBase/ModuleBase_WidgetLineEdit.cpp @@ -105,7 +105,7 @@ ModuleBase_WidgetLineEdit::~ModuleBase_WidgetLineEdit() { } -bool ModuleBase_WidgetLineEdit::storeValueCustom() const +bool ModuleBase_WidgetLineEdit::storeValueCustom() { // A rare case when plugin was not loaded. if(!myFeature) diff --git a/src/ModuleBase/ModuleBase_WidgetLineEdit.h b/src/ModuleBase/ModuleBase_WidgetLineEdit.h index 3b8070af8..a977963c0 100644 --- a/src/ModuleBase/ModuleBase_WidgetLineEdit.h +++ b/src/ModuleBase/ModuleBase_WidgetLineEdit.h @@ -47,7 +47,7 @@ class MODULEBASE_EXPORT ModuleBase_WidgetLineEdit : public ModuleBase_ModelWidge protected: /// Saves the internal parameters to the given feature /// \return True in success - virtual bool storeValueCustom() const; + virtual bool storeValueCustom(); /// Redefinition of virtual method virtual bool restoreValueCustom(); diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp index 6e47e2892..57852847b 100755 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp @@ -179,7 +179,7 @@ void ModuleBase_WidgetMultiSelector::deactivate() } //******************************************************************** -bool ModuleBase_WidgetMultiSelector::storeValueCustom() const +bool ModuleBase_WidgetMultiSelector::storeValueCustom() { // the value is stored on the selection changed signal processing // A rare case when plugin was not loaded. diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.h b/src/ModuleBase/ModuleBase_WidgetMultiSelector.h index ee15240ed..6a0c9e37c 100755 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.h +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.h @@ -105,7 +105,7 @@ protected: /// Saves the internal parameters to the given feature /// \return True in success - virtual bool storeValueCustom() const; + virtual bool storeValueCustom(); virtual bool restoreValueCustom(); diff --git a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp index 39387667a..c59fdceaf 100644 --- a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp @@ -101,7 +101,7 @@ ModuleBase_WidgetShapeSelector::~ModuleBase_WidgetShapeSelector() } //******************************************************************** -bool ModuleBase_WidgetShapeSelector::storeValueCustom() const +bool ModuleBase_WidgetShapeSelector::storeValueCustom() { // the value is stored on the selection changed signal processing return true; diff --git a/src/ModuleBase/ModuleBase_WidgetShapeSelector.h b/src/ModuleBase/ModuleBase_WidgetShapeSelector.h index e7154df8e..193819d8d 100644 --- a/src/ModuleBase/ModuleBase_WidgetShapeSelector.h +++ b/src/ModuleBase/ModuleBase_WidgetShapeSelector.h @@ -84,7 +84,7 @@ Q_OBJECT protected: /// Saves the internal parameters to the given feature /// \return True in success - virtual bool storeValueCustom() const; + virtual bool storeValueCustom(); virtual bool restoreValueCustom(); diff --git a/src/PartSet/PartSet_PreviewPlanes.cpp b/src/PartSet/PartSet_PreviewPlanes.cpp index f7735336a..424deec9d 100755 --- a/src/PartSet/PartSet_PreviewPlanes.cpp +++ b/src/PartSet/PartSet_PreviewPlanes.cpp @@ -42,6 +42,25 @@ bool PartSet_PreviewPlanes::hasVisualizedBodies(ModuleBase_IWorkshop* theWorksho return aBodyIsVisualized; } +bool PartSet_PreviewPlanes::hasVisualizedSketch(ModuleBase_IWorkshop* theWorkshop) +{ + bool aSketchIsVisualized = false; + + XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(theWorkshop); + XGUI_Displayer* aDisp = aWorkshop->displayer(); + QObjectPtrList aDisplayed = aDisp->displayedObjects(); + foreach (ObjectPtr anObj, aDisplayed) { + ResultPtr aResult = std::dynamic_pointer_cast(anObj); + if (aResult.get() != NULL) { + FeaturePtr aFeature = ModelAPI_Feature::feature(aResult); + aSketchIsVisualized = aFeature.get() && aFeature->getKind() == SketchPlugin_Sketch::ID(); + if (aSketchIsVisualized) + break; + } + } + return aSketchIsVisualized; +} + void PartSet_PreviewPlanes::erasePreviewPlanes(ModuleBase_IWorkshop* theWorkshop) { if (myPreviewDisplayed) { diff --git a/src/PartSet/PartSet_PreviewPlanes.h b/src/PartSet/PartSet_PreviewPlanes.h index d64f10fbf..ac94dc350 100755 --- a/src/PartSet/PartSet_PreviewPlanes.h +++ b/src/PartSet/PartSet_PreviewPlanes.h @@ -38,6 +38,11 @@ public: /// \return boolean value static bool hasVisualizedBodies(ModuleBase_IWorkshop* theWorkshop); + /// Returns true if there is at least one Sketch visualized in the viewer + /// \param theWorkshop the application workshop + /// \return boolean value + static bool hasVisualizedSketch(ModuleBase_IWorkshop* theWorkshop); + /// Returns if the preview was displayed /// \param theWorkshop the application workshop /// \return boolean value diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index 22c4b653a..be2d63ec4 100755 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -247,9 +247,6 @@ void PartSet_SketcherMgr::onLeaveViewPort() { myIsMouseOverViewProcessed = false; myIsMouseOverWindow = 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_DO_NOT_BY_ENTER return; @@ -270,6 +267,8 @@ void PartSet_SketcherMgr::onLeaveViewPort() if (myIsPopupMenuActive) return; + // 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(); // 2. if the mouse IS NOT over window, reset the active widget value and hide the presentation diff --git a/src/PartSet/PartSet_SketcherReetntrantMgr.cpp b/src/PartSet/PartSet_SketcherReetntrantMgr.cpp index 943e488a0..cc5f7602a 100755 --- a/src/PartSet/PartSet_SketcherReetntrantMgr.cpp +++ b/src/PartSet/PartSet_SketcherReetntrantMgr.cpp @@ -205,7 +205,7 @@ bool PartSet_SketcherReetntrantMgr::processMouseReleased(ModuleBase_IViewWindow* // in activate() the value of the point is initialized and it can be displayed // but the default value is [0, 0]. So, we block update viewer contentent until // onMouseRelease happens, which correct the point position - ModuleBase_ModelWidget::blockUpdateViewer(true); + ModuleBase_Tools::blockUpdateViewer(true); restartOperation(); aProcessed = true; @@ -219,7 +219,7 @@ bool PartSet_SketcherReetntrantMgr::processMouseReleased(ModuleBase_IViewWindow* aPoint2DWdg->onMouseRelease(theWnd, theEvent); } // unblock viewer update - ModuleBase_ModelWidget::blockUpdateViewer(false); + ModuleBase_Tools::blockUpdateViewer(false); } } @@ -552,7 +552,7 @@ bool PartSet_SketcherReetntrantMgr::copyReetntrantAttributes(const FeaturePtr& t AttributeStringPtr aSourceFeatureTypeAttr = theSourceFeature->data()->string(aTypeAttributeId); AttributeStringPtr aNewFeatureTypeAttr = theNewFeature->data()->string(aTypeAttributeId); aNewFeatureTypeAttr->setValue(aSourceFeatureTypeAttr->value()); - ModuleBase_ModelWidget::updateObject(theNewFeature); + ModuleBase_Tools::flushUpdated(theNewFeature); aChanged = true; } return aChanged; diff --git a/src/PartSet/PartSet_Tools.cpp b/src/PartSet/PartSet_Tools.cpp index 188a41f9a..a08190d7b 100755 --- a/src/PartSet/PartSet_Tools.cpp +++ b/src/PartSet/PartSet_Tools.cpp @@ -53,6 +53,7 @@ #include #include +#include #include #include @@ -304,7 +305,7 @@ std::shared_ptr PartSet_Tools::findFirstEqualPointInArgumen // may be feature is not updated yet, execute is not performed and references features // are not created. Case: rectangle macro feature - ModuleBase_ModelWidget::updateObject(theFeature); + ModuleBase_Tools::flushUpdated(theFeature); std::list anAttributes = theFeature->data()->attributes( ModelAPI_AttributeRefList::typeId()); diff --git a/src/PartSet/PartSet_WidgetFileSelector.cpp b/src/PartSet/PartSet_WidgetFileSelector.cpp index b493c2a86..f8c46f408 100644 --- a/src/PartSet/PartSet_WidgetFileSelector.cpp +++ b/src/PartSet/PartSet_WidgetFileSelector.cpp @@ -34,7 +34,7 @@ bool PartSet_WidgetFileSelector::restoreValueCustom() return ModuleBase_WidgetFileSelector::restoreValueCustom(); } -bool PartSet_WidgetFileSelector::storeValueCustom() const +bool PartSet_WidgetFileSelector::storeValueCustom() { // A rare case when plugin was not loaded. if (!myFeature) diff --git a/src/PartSet/PartSet_WidgetFileSelector.h b/src/PartSet/PartSet_WidgetFileSelector.h index 632cb0571..adda54eac 100644 --- a/src/PartSet/PartSet_WidgetFileSelector.h +++ b/src/PartSet/PartSet_WidgetFileSelector.h @@ -37,7 +37,7 @@ public: protected: /// Reimplemented from ModuleBase_WidgetFileSelector::storeValueCustom() - virtual bool storeValueCustom() const; + virtual bool storeValueCustom(); /// Reimplemented from ModuleBase_WidgetFileSelector::restoreValue() virtual bool restoreValueCustom(); diff --git a/src/PartSet/PartSet_WidgetPoint2d.cpp b/src/PartSet/PartSet_WidgetPoint2d.cpp index 1563bad48..29b8cf03d 100644 --- a/src/PartSet/PartSet_WidgetPoint2d.cpp +++ b/src/PartSet/PartSet_WidgetPoint2d.cpp @@ -263,7 +263,7 @@ bool PartSet_WidgetPoint2D::setPoint(double theX, double theY) return true; } -bool PartSet_WidgetPoint2D::storeValueCustom() const +bool PartSet_WidgetPoint2D::storeValueCustom() { std::shared_ptr aData = myFeature->data(); if (!aData) // can be on abort of sketcher element diff --git a/src/PartSet/PartSet_WidgetPoint2d.h b/src/PartSet/PartSet_WidgetPoint2d.h index b04dfc776..3c0f8c360 100755 --- a/src/PartSet/PartSet_WidgetPoint2d.h +++ b/src/PartSet/PartSet_WidgetPoint2d.h @@ -118,7 +118,7 @@ public slots: protected: /// Saves the internal parameters to the given feature /// \return True in success - virtual bool storeValueCustom() const; + virtual bool storeValueCustom(); /// Restore value from attribute data to the widget's control virtual bool restoreValueCustom(); diff --git a/src/PartSet/PartSet_WidgetSketchCreator.cpp b/src/PartSet/PartSet_WidgetSketchCreator.cpp index ade61b334..76c2e720e 100644 --- a/src/PartSet/PartSet_WidgetSketchCreator.cpp +++ b/src/PartSet/PartSet_WidgetSketchCreator.cpp @@ -99,7 +99,7 @@ bool PartSet_WidgetSketchCreator::restoreValueCustom() return true; } -bool PartSet_WidgetSketchCreator::storeValueCustom() const +bool PartSet_WidgetSketchCreator::storeValueCustom() { return true; } @@ -195,7 +195,8 @@ void PartSet_WidgetSketchCreator::setVisibleSelectionControl(const bool theSelec if (theSelectionControl) { bool aBodyIsVisualized = myPreviewPlanes->hasVisualizedBodies(myWorkshop); - if (!aBodyIsVisualized) { + bool aSketchIsVisualized = myPreviewPlanes->hasVisualizedSketch(myWorkshop); + if (!aBodyIsVisualized && !aSketchIsVisualized) { // We have to select a plane before any operation myPreviewPlanes->showPreviewPlanes(myWorkshop); } diff --git a/src/PartSet/PartSet_WidgetSketchCreator.h b/src/PartSet/PartSet_WidgetSketchCreator.h index 22d58f750..57ba50eca 100644 --- a/src/PartSet/PartSet_WidgetSketchCreator.h +++ b/src/PartSet/PartSet_WidgetSketchCreator.h @@ -81,7 +81,7 @@ protected: /// Saves the internal parameters to the given feature /// \return True in success - virtual bool storeValueCustom() const; + virtual bool storeValueCustom(); virtual bool restoreValueCustom(); diff --git a/src/PartSet/PartSet_WidgetSketchLabel.h b/src/PartSet/PartSet_WidgetSketchLabel.h index 30efc49ec..dc391906f 100644 --- a/src/PartSet/PartSet_WidgetSketchLabel.h +++ b/src/PartSet/PartSet_WidgetSketchLabel.h @@ -108,7 +108,7 @@ protected: /// Saves the internal parameters to the given feature /// \return True in success - virtual bool storeValueCustom() const + virtual bool storeValueCustom() { return true; } diff --git a/src/SamplePanelPlugin/SamplePanelPlugin_ModelWidget.cpp b/src/SamplePanelPlugin/SamplePanelPlugin_ModelWidget.cpp index a5cf68391..4f6530e20 100755 --- a/src/SamplePanelPlugin/SamplePanelPlugin_ModelWidget.cpp +++ b/src/SamplePanelPlugin/SamplePanelPlugin_ModelWidget.cpp @@ -48,7 +48,7 @@ QList SamplePanelPlugin_ModelWidget::getControls() const return aControls; } -bool SamplePanelPlugin_ModelWidget::storeValueCustom() const +bool SamplePanelPlugin_ModelWidget::storeValueCustom() { AttributePtr anAttribute = myFeature->attribute(SamplePanelPlugin_Feature::VALUE_ID()); AttributeIntegerPtr aValueAttribute = diff --git a/src/SamplePanelPlugin/SamplePanelPlugin_ModelWidget.h b/src/SamplePanelPlugin/SamplePanelPlugin_ModelWidget.h index dfee20d53..e69fc1908 100755 --- a/src/SamplePanelPlugin/SamplePanelPlugin_ModelWidget.h +++ b/src/SamplePanelPlugin/SamplePanelPlugin_ModelWidget.h @@ -36,7 +36,7 @@ public: protected: /// Saves the internal parameters to the given feature /// \return True in success - virtual bool storeValueCustom() const; + virtual bool storeValueCustom(); /// Restore value from attribute data to the widget's control virtual bool restoreValueCustom(); diff --git a/src/XGUI/XGUI_ErrorMgr.cpp b/src/XGUI/XGUI_ErrorMgr.cpp index e360e9971..c9505229a 100644 --- a/src/XGUI/XGUI_ErrorMgr.cpp +++ b/src/XGUI/XGUI_ErrorMgr.cpp @@ -17,6 +17,9 @@ #include #include +#include +#include + #include #include #include @@ -32,6 +35,7 @@ const QString INVALID_VALUE = "invalid_action"; +//#define DEBUG_ERROR_STATE XGUI_ErrorMgr::XGUI_ErrorMgr(QObject* theParent, ModuleBase_IWorkshop* theWorkshop) : ModuleBase_IErrorMgr(theParent), @@ -78,6 +82,15 @@ void XGUI_ErrorMgr::updateActions(const FeaturePtr& theFeature) } updateActionState(anOkAction, anError); updateToolTip(anActiveWidget, aWidgetError); + +#ifdef DEBUG_ERROR_STATE + QString anInfo = ModuleBase_Tools::objectInfo(theFeature); + + QString aResultInfo = QString("valid = %1, anError = %2, aWidgetError = %3") + .arg(anError.isEmpty()).arg(anError).arg(aWidgetError); + qDebug(QString("XGUI_ErrorMgr::updateActions for %1, result: %2").arg(anInfo) + .arg(aResultInfo).toStdString().c_str()); +#endif } } diff --git a/src/XGUI/XGUI_PropertyPanel.cpp b/src/XGUI/XGUI_PropertyPanel.cpp index c1b78937e..c2c318683 100755 --- a/src/XGUI/XGUI_PropertyPanel.cpp +++ b/src/XGUI/XGUI_PropertyPanel.cpp @@ -81,7 +81,7 @@ XGUI_PropertyPanel::XGUI_PropertyPanel(QWidget* theParent, XGUI_OperationMgr* th myPanelPage = new ModuleBase_PageWidget(aContent); myPanelPage->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding); - aMainLayout->addWidget(myPanelPage, aPanelRow++, kPanelColumn); + aMainLayout->addWidget(myPanelPage, aPanelRow, kPanelColumn); // spit to make the preview button on the bottom of the panel aMainLayout->setRowStretch(aPanelRow++, 1); diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index bf87ecc31..0e20e9ab1 100755 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -535,10 +535,12 @@ void XGUI_Workshop::connectToPropertyPanel(const bool isToConnect) if (isToConnect) { connect(aWidget, SIGNAL(valueStateChanged(int)), this, SLOT(onWidgetStateChanged(int))); connect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onValuesChanged())); - } + connect(aWidget, SIGNAL(objectUpdated()), this, SLOT(onWidgetObjectUpdated())); + } else { disconnect(aWidget, SIGNAL(valueStateChanged(int)), this, SLOT(onWidgetStateChanged(int))); disconnect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onValuesChanged())); + disconnect(aWidget, SIGNAL(objectUpdated()), this, SLOT(onWidgetObjectUpdated())); } } } @@ -929,6 +931,11 @@ void XGUI_Workshop::onValuesChanged() } } +void XGUI_Workshop::onWidgetObjectUpdated() +{ + operationMgr()->onValidateOperation(); +} + ModuleBase_IModule* XGUI_Workshop::loadModule(const QString& theModule) { QString libName = QString::fromStdString(library(theModule.toStdString())); diff --git a/src/XGUI/XGUI_Workshop.h b/src/XGUI/XGUI_Workshop.h index edf22c262..0c09e0873 100755 --- a/src/XGUI/XGUI_Workshop.h +++ b/src/XGUI/XGUI_Workshop.h @@ -341,6 +341,9 @@ signals: /// differs in the new state of paged container void onValuesChanged(); + /// Listens the corresponded signal of model widget and updates Apply button state by feature + void onWidgetObjectUpdated(); + /// Show property panel void showPropertyPanel(); diff --git a/src/XGUI/XGUI_WorkshopListener.cpp b/src/XGUI/XGUI_WorkshopListener.cpp index e4d13e93b..afdbe6e8e 100755 --- a/src/XGUI/XGUI_WorkshopListener.cpp +++ b/src/XGUI/XGUI_WorkshopListener.cpp @@ -90,7 +90,6 @@ void XGUI_WorkshopListener::initializeEventListening() aLoop->registerListener(this, Events_LongOp::eventID()); aLoop->registerListener(this, Events_Loop::eventByName(EVENT_PLUGIN_LOADED)); aLoop->registerListener(this, Events_Loop::eventByName(EVENT_SELFILTER_LOADED)); - aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_ERROR_CHANGED)); aLoop->registerListener(this, Events_Loop::eventByName(EVENT_UPDATE_VIEWER_BLOCKED)); aLoop->registerListener(this, Events_Loop::eventByName(EVENT_UPDATE_VIEWER_UNBLOCKED)); @@ -180,25 +179,6 @@ void XGUI_WorkshopListener::processEvent(const std::shared_ptr& // the viewer's update context is unblocked, the viewer's update works XGUI_Displayer* aDisplayer = workshop()->displayer(); aDisplayer->enableUpdateViewer(true); - } else if (theMessage->eventID() == Events_Loop::eventByName(EVENT_OBJECT_ERROR_CHANGED)) { - std::shared_ptr aUpdMsg = - std::dynamic_pointer_cast(theMessage); - std::set anObjects = aUpdMsg->objects(); - - ModuleBase_OperationFeature* aFOperation = dynamic_cast - (workshop()->operationMgr()->currentOperation()); - bool aFeatureChanged = false; - if(aFOperation ) { - FeaturePtr aFeature = aFOperation->feature(); - if (aFeature.get()) { - std::set::const_iterator aIt; - for (aIt = anObjects.begin(); aIt != anObjects.end() && !aFeatureChanged; ++aIt) { - aFeatureChanged = ModelAPI_Feature::feature(*aIt) == aFeature; - } - } - if (aFeatureChanged) - workshop()->operationMgr()->onValidateOperation(); - } } else { //Show error dialog if error message received. std::shared_ptr anAppError = std::dynamic_pointer_cast(theMessage);