From: nds Date: Sun, 6 Sep 2015 13:49:46 +0000 (+0300) Subject: Operation Prs: green preview is low. Scenario: Sketch, Start Circle, 1st Click, move... X-Git-Tag: V_1.4.0_beta4~108 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=65a616a3bb6cbdf09c61fed7eb91d1f5d9667988;p=modules%2Fshaper.git Operation Prs: green preview is low. Scenario: Sketch, Start Circle, 1st Click, move to PP, input R=80, Activate 1st control, Input value. Result: the presentation is not redisplayed. Reason: in onFeatureUpdateMsg UpdateViewer() should be called. --- diff --git a/src/ModuleBase/ModuleBase_IModule.cpp b/src/ModuleBase/ModuleBase_IModule.cpp index cd4375789..1dc47c098 100644 --- a/src/ModuleBase/ModuleBase_IModule.cpp +++ b/src/ModuleBase/ModuleBase_IModule.cpp @@ -69,6 +69,11 @@ ModuleBase_Operation* ModuleBase_IModule::getNewOperation(const std::string& the return new ModuleBase_OperationFeature(theFeatureId.c_str(), this); } +bool ModuleBase_IModule::customizeObject(ObjectPtr theObject, const bool theUpdateViewer) +{ + return false; +} + ModuleBase_Operation* ModuleBase_IModule::createOperation(const std::string& theFeatureId) { ModuleBase_OperationFeature* aFOperation = dynamic_cast diff --git a/src/ModuleBase/ModuleBase_IModule.h b/src/ModuleBase/ModuleBase_IModule.h index e090d3882..a48258607 100644 --- a/src/ModuleBase/ModuleBase_IModule.h +++ b/src/ModuleBase/ModuleBase_IModule.h @@ -164,8 +164,10 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject * If the object is result with the color attribute value set, it is used, * otherwise the customize is applyed to the object's feature if it is a custom prs * \param theObject an object instance + * \param theUpdateViewer the parameter whether the viewer should be update immediatelly + * \returns true if the object is modified */ - virtual void customizeObject(ObjectPtr theObject) {} + virtual bool customizeObject(ObjectPtr theObject, const bool theUpdateViewer); /// This method is called on object browser creation for customisation of module specific features /// \param theObjectBrowser a pinter on Object Browser widget diff --git a/src/PartSet/PartSet_CustomPrs.cpp b/src/PartSet/PartSet_CustomPrs.cpp index d3cdd5020..3bf751b1e 100755 --- a/src/PartSet/PartSet_CustomPrs.cpp +++ b/src/PartSet/PartSet_CustomPrs.cpp @@ -39,27 +39,39 @@ bool PartSet_CustomPrs::isActive() return aContext->IsDisplayed(anOperationPrs); } -void PartSet_CustomPrs::activate(const FeaturePtr& theFeature) +bool PartSet_CustomPrs::activate(const FeaturePtr& theFeature, const bool theUpdateViewer) { + bool isModified = false; Handle(PartSet_OperationPrs) anOperationPrs = getPresentation(); if (anOperationPrs->canActivate(theFeature)) { anOperationPrs->setFeature(theFeature); - if (theFeature.get()) - displayPresentation(); + if (theFeature.get()) { + displayPresentation(theUpdateViewer); + isModified = true; + } } + return isModified; } -void PartSet_CustomPrs::deactivate() +bool PartSet_CustomPrs::deactivate(const bool theUpdateViewer) { + bool isModified = false; + Handle(PartSet_OperationPrs) anOperationPrs = getPresentation(); anOperationPrs->setFeature(FeaturePtr()); - erasePresentation(); + Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext(); + if (aContext->IsDisplayed(anOperationPrs)) { + erasePresentation(theUpdateViewer); + isModified = true; + } + + return isModified; } -void PartSet_CustomPrs::displayPresentation() +void PartSet_CustomPrs::displayPresentation(const bool theUpdateViewer) { Handle(PartSet_OperationPrs) anOperationPrs = getPresentation(); @@ -68,19 +80,20 @@ void PartSet_CustomPrs::displayPresentation() PartSet_Module* aModule = dynamic_cast(myWorkshop->module()); XGUI_Workshop* aWorkshop = workshop(); - aWorkshop->displayer()->displayAIS(myOperationPrs, false/*load object in selection*/, true); + aWorkshop->displayer()->displayAIS(myOperationPrs, false/*load object in selection*/, theUpdateViewer); aContext->SetZLayer(anOperationPrs, aModule->getVisualLayerId()); } else { anOperationPrs->Redisplay(); - workshop()->displayer()->updateViewer(); + if (theUpdateViewer) + workshop()->displayer()->updateViewer(); } } -void PartSet_CustomPrs::erasePresentation() +void PartSet_CustomPrs::erasePresentation(const bool theUpdateViewer) { XGUI_Workshop* aWorkshop = workshop(); - aWorkshop->displayer()->eraseAIS(myOperationPrs, true); + aWorkshop->displayer()->eraseAIS(myOperationPrs, theUpdateViewer); } Handle(PartSet_OperationPrs) PartSet_CustomPrs::getPresentation() @@ -91,8 +104,9 @@ Handle(PartSet_OperationPrs) PartSet_CustomPrs::getPresentation() return Handle(PartSet_OperationPrs)::DownCast(anAISIO); } -void PartSet_CustomPrs::customize(const ObjectPtr& theObject) +bool PartSet_CustomPrs::redisplay(const ObjectPtr& theObject, const bool theUpdateViewer) { + bool isModified = false; // the presentation should be recomputed if the previous AIS depend on the result // [it should be hiddend] or the new AIS depend on it [it should be visualized] Handle(PartSet_OperationPrs) anOperationPrs = getPresentation(); @@ -104,7 +118,11 @@ void PartSet_CustomPrs::customize(const ObjectPtr& theObject) //aChanged = aChanged || anOperationPrs->dependOn(theObject); //if (aChanged) anOperationPrs->Redisplay(); + isModified = true; + if (theUpdateViewer) + workshop()->displayer()->updateViewer(); } + return isModified; } void PartSet_CustomPrs::clearPrs() diff --git a/src/PartSet/PartSet_CustomPrs.h b/src/PartSet/PartSet_CustomPrs.h index 1c7494138..aafb37887 100755 --- a/src/PartSet/PartSet_CustomPrs.h +++ b/src/PartSet/PartSet_CustomPrs.h @@ -23,8 +23,8 @@ class ModuleBase_IWorkshop; class XGUI_Workshop; /** -* Interface of a class which can provide specific customization of -* object presentation + * This is the module custom presentation, which manage an AIS presentation, that can be filled + * by a feature and visualized in the viewer additionally to usual workshop objects. */ class PartSet_CustomPrs { @@ -35,19 +35,32 @@ public: /// Returns true if the presentation is active bool isActive(); - /// Initializes the presentation by the parameter object - void activate(const FeaturePtr& theObject); - - void deactivate(); - - /// Modifies the given presentation in the custom way. - void customize(const ObjectPtr& theObject); - + /// Initializes the operation presentation by the parameter object and display the presentation + /// \param theObject an operation feature source to fill the presentation + /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly + /// \returns true if the presentation is displayed + bool activate(const FeaturePtr& theObject, const bool theUpdateViewer); + + /// Initializes the operation presentation by empty object and erase the presentation + /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly + /// \returns true if the presentation has been displayed and now it is erased + bool deactivate(const bool theUpdateViewer); + + /// If the presentation is active[displayed], the shapes of the presentation is recomputed + /// and the presentation is redisplayed. + /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly + /// \returns true if the presentation is redisplayed + bool redisplay(const ObjectPtr& theObject, const bool theUpdateViewer); + + /// Nullify the operation presentation. For example, it can be useful when the viewer/context + /// is closed. If this is not performed and the presentation is assigned in another context, + /// it caused erroneus case because the presentation has linkage to the previous context. void clearPrs(); +private: + /// Creates the AIS operation presentation void initPrs(); -private: /// Returns the AIS presentation Handle(PartSet_OperationPrs) getPresentation(); @@ -55,11 +68,16 @@ private: XGUI_Workshop* workshop() const; /// Displays the internal presentation in the viewer of workshop - void displayPresentation(); + /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly + void displayPresentation(const bool theUpdateViewer); + /// Erases the internal presentation from the viewer of workshop - void erasePresentation(); + /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly + void erasePresentation(const bool theUpdateViewer); + /// Sets color, point size and width of the presentation - void customizePresentation(); + /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly + void customizePresentation(const bool theUpdateViewer); private: ModuleBase_IWorkshop* myWorkshop; /// current workshop diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 1e3a612d7..3540797e9 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -298,7 +298,7 @@ void PartSet_Module::onOperationStarted(ModuleBase_Operation* theOperation) ModuleBase_OperationFeature* aFOperation = dynamic_cast(theOperation); if (aFOperation) - myCustomPrs->activate(aFOperation->feature()); + myCustomPrs->activate(aFOperation->feature(), true); } void PartSet_Module::onOperationResumed(ModuleBase_Operation* theOperation) @@ -307,12 +307,12 @@ void PartSet_Module::onOperationResumed(ModuleBase_Operation* theOperation) ModuleBase_OperationFeature* aFOperation = dynamic_cast(theOperation); if (aFOperation) - myCustomPrs->activate(aFOperation->feature()); + myCustomPrs->activate(aFOperation->feature(), true); } void PartSet_Module::onOperationStopped(ModuleBase_Operation* theOperation) { - myCustomPrs->deactivate(); + bool isModified = myCustomPrs->deactivate(false); if (PartSet_SketcherMgr::isSketchOperation(theOperation)) { mySketchMgr->stopSketch(theOperation); @@ -320,6 +320,12 @@ void PartSet_Module::onOperationStopped(ModuleBase_Operation* theOperation) else if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation)) { mySketchMgr->stopNestedSketch(theOperation); } + + if (isModified) { + XGUI_ModuleConnector* aConnector = dynamic_cast(myWorkshop); + XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer(); + aDisplayer->updateViewer(); + } } ModuleBase_Operation* PartSet_Module::currentOperation() const @@ -752,10 +758,11 @@ void PartSet_Module::onObjectDisplayed(ObjectPtr theObject, AISObjectPtr theAIS) void PartSet_Module::onBeforeObjectErase(ObjectPtr theObject, AISObjectPtr theAIS) { + // this is obsolete // it should be recomputed in order to disappear in the viewer if the corresponded object // is erased - if (myCustomPrs->isActive()) - myCustomPrs->customize(theObject); + //if (myCustomPrs->isActive()) + // myCustomPrs->redisplay(theObject, false); } void PartSet_Module::onViewTransformed(int theTrsfType) @@ -812,10 +819,13 @@ void PartSet_Module::onViewTransformed(int theTrsfType) aDisplayer->updateViewer(); } -void PartSet_Module::customizeObject(ObjectPtr theObject) +bool PartSet_Module::customizeObject(ObjectPtr theObject, const bool theUpdateViewer) { + bool isRedisplayed = false; if (myCustomPrs->isActive()) - myCustomPrs->customize(theObject); + isRedisplayed = myCustomPrs->redisplay(theObject, theUpdateViewer); + + return isRedisplayed; } void PartSet_Module::customizeObjectBrowser(QWidget* theObjectBrowser) diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index 054e3160e..2828de29f 100644 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -174,8 +174,10 @@ public: * If the object is result with the color attribute value set, it is used, * otherwise the customize is applyed to the object's feature if it is a custom prs * \param theObject an object instance + * \param theUpdateViewer the parameter whether the viewer should be update immediatelly + * \returns true if the object is modified */ - virtual void customizeObject(ObjectPtr theObject); + virtual bool customizeObject(ObjectPtr theObject, const bool theUpdateViewer); /// This method is called on object browser creation for customisation of module specific features /// \param theObjectBrowser a pinter on Object Browser widget diff --git a/src/XGUI/XGUI_WorkshopListener.cpp b/src/XGUI/XGUI_WorkshopListener.cpp index ae49a9141..6a30664d4 100755 --- a/src/XGUI/XGUI_WorkshopListener.cpp +++ b/src/XGUI/XGUI_WorkshopListener.cpp @@ -59,6 +59,7 @@ //#define DEBUG_FEATURE_CREATED //#define DEBUG_FEATURE_REDISPLAY +//#define DEBUG_FEATURE_UPDATED //#define DEBUG_RESULT_COMPSOLID XGUI_WorkshopListener::XGUI_WorkshopListener(ModuleBase_IWorkshop* theWorkshop) @@ -205,6 +206,17 @@ void XGUI_WorkshopListener::processEvent(const std::shared_ptr& void XGUI_WorkshopListener::onFeatureUpdatedMsg( const std::shared_ptr& theMsg) { +#ifdef DEBUG_FEATURE_UPDATED + std::set aObjects = theMsg->objects(); + std::set::const_iterator aIt; + QStringList anInfo; + for (aIt = aObjects.begin(); aIt != aObjects.end(); ++aIt) { + anInfo.append(ModuleBase_Tools::objectInfo((*aIt))); + } + QString anInfoStr = anInfo.join(";\t"); + qDebug(QString("onFeatureUpdatedMsg: %1, %2").arg(aObjects.size()).arg(anInfoStr).toStdString().c_str()); +#endif + bool isModified = false; std::set aFeatures = theMsg->objects(); XGUI_OperationMgr* anOperationMgr = workshop()->operationMgr(); if (anOperationMgr->hasOperation()) { @@ -220,13 +232,15 @@ void XGUI_WorkshopListener::onFeatureUpdatedMsg( break; } } - myWorkshop->module()->customizeObject(aCurrentFeature); + isModified = myWorkshop->module()->customizeObject(aCurrentFeature, false); } } anOperationMgr->onValidateOperation(); //if (myObjectBrowser) // myObjectBrowser->processEvent(theMsg); + if (isModified) + workshop()->displayer()->updateViewer(); } //******************************************************