From: nds Date: Fri, 18 Sep 2015 04:25:22 +0000 (+0300) Subject: #968 parameter creation problem X-Git-Tag: V_1.4.0~23 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=38a503cd21409d05639a2508de05b5065f1805fa;p=modules%2Fshaper.git #968 parameter creation problem do not display operation presentation if there are not shapes/result on it. --- diff --git a/src/PartSet/PartSet_CustomPrs.cpp b/src/PartSet/PartSet_CustomPrs.cpp index 0ac8ee0c6..ab7a858fb 100755 --- a/src/PartSet/PartSet_CustomPrs.cpp +++ b/src/PartSet/PartSet_CustomPrs.cpp @@ -26,17 +26,18 @@ #define OPERATION_PARAMETER_COLOR "255, 255, 0" PartSet_CustomPrs::PartSet_CustomPrs(ModuleBase_IWorkshop* theWorkshop) - : myWorkshop(theWorkshop) + : myWorkshop(theWorkshop), myIsActive(false) { initPrs(); } bool PartSet_CustomPrs::isActive() { - Handle(PartSet_OperationPrs) anOperationPrs = getPresentation(); + return myIsActive; + /*Handle(PartSet_OperationPrs) anOperationPrs = getPresentation(); Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext(); - return !aContext.IsNull() && aContext->IsDisplayed(anOperationPrs); + return !aContext.IsNull() && aContext->IsDisplayed(anOperationPrs);*/ } bool PartSet_CustomPrs::activate(const FeaturePtr& theFeature, const bool theUpdateViewer) @@ -45,6 +46,7 @@ bool PartSet_CustomPrs::activate(const FeaturePtr& theFeature, const bool theUpd Handle(PartSet_OperationPrs) anOperationPrs = getPresentation(); if (anOperationPrs->canActivate(theFeature)) { + myIsActive = true; anOperationPrs->setFeature(theFeature); if (theFeature.get()) { displayPresentation(theUpdateViewer); @@ -56,6 +58,7 @@ bool PartSet_CustomPrs::activate(const FeaturePtr& theFeature, const bool theUpd bool PartSet_CustomPrs::deactivate(const bool theUpdateViewer) { + myIsActive = false; bool isModified = false; Handle(PartSet_OperationPrs) anOperationPrs = getPresentation(); @@ -77,16 +80,21 @@ void PartSet_CustomPrs::displayPresentation(const bool theUpdateViewer) Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext(); if (!aContext.IsNull() && !aContext->IsDisplayed(anOperationPrs)) { - PartSet_Module* aModule = dynamic_cast(myWorkshop->module()); - - XGUI_Workshop* aWorkshop = workshop(); - aWorkshop->displayer()->displayAIS(myOperationPrs, false/*load object in selection*/, theUpdateViewer); - aContext->SetZLayer(anOperationPrs, aModule->getVisualLayerId()); + if (anOperationPrs->hasShapes()) { + PartSet_Module* aModule = dynamic_cast(myWorkshop->module()); + XGUI_Workshop* aWorkshop = workshop(); + aWorkshop->displayer()->displayAIS(myOperationPrs, false/*load object in selection*/, theUpdateViewer); + aContext->SetZLayer(anOperationPrs, aModule->getVisualLayerId()); + } } else { - anOperationPrs->Redisplay(); - if (theUpdateViewer) - workshop()->displayer()->updateViewer(); + if (!anOperationPrs->hasShapes()) + erasePresentation(theUpdateViewer); + else { + anOperationPrs->Redisplay(); + if (theUpdateViewer) + workshop()->displayer()->updateViewer(); + } } } @@ -111,16 +119,22 @@ bool PartSet_CustomPrs::redisplay(const ObjectPtr& theObject, const bool theUpda // [it should be hiddend] or the new AIS depend on it [it should be visualized] Handle(PartSet_OperationPrs) anOperationPrs = getPresentation(); Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext(); - if (!aContext.IsNull() && aContext->IsDisplayed(anOperationPrs)) { - // if there are performance poblems, to improve them, the necessity of redisplay can be checked - //bool aChanged = anOperationPrs->dependOn(theObject); - anOperationPrs->updateShapes(); - //aChanged = aChanged || anOperationPrs->dependOn(theObject); - //if (aChanged) - anOperationPrs->Redisplay(); - isModified = true; - if (theUpdateViewer) - workshop()->displayer()->updateViewer(); + if (!aContext.IsNull()) { + if (aContext->IsDisplayed(anOperationPrs)) { + // if there are performance poblems, to improve them, the necessity of redisplay can be checked + //bool aChanged = anOperationPrs->dependOn(theObject); + anOperationPrs->updateShapes(); + //aChanged = aChanged || anOperationPrs->dependOn(theObject); + //if (aChanged) + anOperationPrs->Redisplay(); + isModified = true; + if (theUpdateViewer) + workshop()->displayer()->updateViewer(); + } + else { + anOperationPrs->updateShapes(); + displayPresentation(theUpdateViewer); + } } return isModified; } diff --git a/src/PartSet/PartSet_CustomPrs.h b/src/PartSet/PartSet_CustomPrs.h index aafb37887..d21bdd0e3 100755 --- a/src/PartSet/PartSet_CustomPrs.h +++ b/src/PartSet/PartSet_CustomPrs.h @@ -80,6 +80,7 @@ private: void customizePresentation(const bool theUpdateViewer); private: + bool myIsActive; ModuleBase_IWorkshop* myWorkshop; /// current workshop AISObjectPtr myOperationPrs; /// the AIS presentation, which is displayed/erased in the viewer }; diff --git a/src/PartSet/PartSet_OperationPrs.cpp b/src/PartSet/PartSet_OperationPrs.cpp index 146699459..58b5a53f5 100755 --- a/src/PartSet/PartSet_OperationPrs.cpp +++ b/src/PartSet/PartSet_OperationPrs.cpp @@ -76,10 +76,17 @@ void PartSet_OperationPrs::updateShapes() myFeatureResults = myFeature->results(); } +bool PartSet_OperationPrs::hasShapes() +{ + return !myFeatureShapes.empty() || !myFeatureResults.empty(); +} + void PartSet_OperationPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager, const Handle(Prs3d_Presentation)& thePresentation, const Standard_Integer theMode) { + if (!hasShapes()) + return; // when the feature can not be visualized in the module, the operation preview should not // be visualized also if (!myWorkshop->module()->canDisplayObject(myFeature)) diff --git a/src/PartSet/PartSet_OperationPrs.h b/src/PartSet/PartSet_OperationPrs.h index ca3eaa2dd..64d92151a 100755 --- a/src/PartSet/PartSet_OperationPrs.h +++ b/src/PartSet/PartSet_OperationPrs.h @@ -62,6 +62,9 @@ public: // Recompute internal list of shaped dependent on the current feature void updateShapes(); + /// Returns true if the feature contains shapes or results + bool hasShapes(); + DEFINE_STANDARD_RTTI(PartSet_OperationPrs) protected: