Salome HOME
Fix for Bug IPAL8945
[modules/visu.git] / src / VISUGUI / VisuGUI_Tools.cxx
index 72f28a92a471ace5a0a134e96b0c6a940cc9e536..978a4c24f0c010ad7cf0e2e503b9de443cd9308c 100644 (file)
 #include "SalomeApp_Module.h"
 #include "SalomeApp_Study.h"
 #include "SalomeApp_Application.h"
-#include "SalomeApp_SelectionMgr.h"
+
+#include "OB_Browser.h"
+#include "LightApp_DataObject.h"
+#include "LightApp_SelectionMgr.h"
 
 #include "SALOME_ListIO.hxx"
 #include "SALOME_ListIteratorOfListIO.hxx"
@@ -58,6 +61,8 @@
 #include "SUIT_Session.h"
 #include "SUIT_MessageBox.h"
 
+#include "VisuGUI.h"
+
 #include <vtkRenderer.h>
 #include <vtkActorCollection.h>
 
@@ -71,7 +76,7 @@ namespace VISU
     return theModule->application()->desktop();
   }
 
-  SalomeApp_SelectionMgr*
+  LightApp_SelectionMgr*
   GetSelectionMgr(const SalomeApp_Module* theModule)
   {
     return theModule->getApp()->selectionMgr();
@@ -99,10 +104,83 @@ namespace VISU
   }
 
   bool
-  CheckLock( _PTR(Study) theStudy )
+  CheckLock( _PTR(Study) theStudy,
+            QWidget* theWidget )
+  {
+    if(IsStudyLocked(theStudy)){
+      SUIT_MessageBox::warn1(theWidget,
+                            QObject::tr("WRN_VISU_WARNING"),
+                            QObject::tr("WRN_STUDY_LOCKED"),
+                            QObject::tr("BUT_OK"));
+       return true;
+    }
+    return false;
+  }
+
+  LightApp_DataObject*
+  FindDataObject(SUIT_DataObject* theDataObject,
+                const QString& theEntry,
+                int theLevel)
+  {
+    int aLevel = theDataObject->level() + 2;
+    QString aSourceEntry = theEntry.section(':',0,aLevel);
+    DataObjectList aList;
+    theDataObject->children(aList);
+    DataObjectListIterator aDataObjectIter(aList);
+    while(SUIT_DataObject* aDataObject = aDataObjectIter.current()){
+      if(LightApp_DataObject* aChildDataObject = dynamic_cast<LightApp_DataObject*>(aDataObject)){
+       QString anEntry = aChildDataObject->entry();
+       QString aCurrentEntry = anEntry.section(':',0,aLevel);
+       if(aSourceEntry == aCurrentEntry){
+         if(theLevel == aLevel){
+           return aChildDataObject;
+         }else{
+           return FindDataObject(aChildDataObject,theEntry,theLevel);
+         }
+       }
+      }
+      ++aDataObjectIter;
+    }
+    return NULL;
+  }
+
+  LightApp_DataObject*
+  FindDataObject(CAM_Module* theModule,
+                _PTR(SObject) theSObject)
+  {
+    CAM_DataModel* aDataModel = theModule->dataModel();
+    CAM_DataObject* aRootDataObject = aDataModel->root();
+    if(_PTR(SComponent) aComponent = theSObject)
+      return dynamic_cast<LightApp_DataObject*>(aRootDataObject);
+
+    int aLevel = theSObject->Depth();
+    std::string anEntry = theSObject->GetID();
+    return FindDataObject(aRootDataObject,anEntry.c_str(),aLevel);
+  }
+
+  void
+  UpdateObjBrowser(SalomeApp_Module* theModule,
+                  bool theIsUpdateDataModel,
+                  _PTR(SObject) theSObject)
+  {
+    LightApp_DataObject* aDataObject = NULL;
+    if(theSObject)
+      aDataObject = FindDataObject(theModule,theSObject);
+
+    theModule->updateObjBrowser(theIsUpdateDataModel,aDataObject);
+    theModule->getApp()->updateActions();
+  }
+
+  bool
+  IsSObjectTable( _PTR(SObject) theSObject )
   {
-    if(IsStudyLocked(theStudy))
-      throw std::runtime_error(QObject::tr("WRN_STUDY_LOCKED").latin1());
+    if ( theSObject ) {
+      _PTR(GenericAttribute) anAttr;
+      if (theSObject->FindAttribute( anAttr, "AttributeTableOfInteger" ))
+       return true;
+      if (theSObject->FindAttribute( anAttr, "AttributeTableOfReal" ))
+       return true;
+    }
     return false;
   }
 
@@ -193,7 +271,7 @@ namespace VISU
                 Handle(SALOME_InteractiveObject)* theIO,
                 VISU::Storable::TRestoringMap* theMap)
   {
-    SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(theModule);
+    LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(theModule);
     SALOME_ListIO aListIO;
     aSelectionMgr->selectedObjects(aListIO);
     SALOME_ListIteratorOfListIO anIter(aListIO);
@@ -212,7 +290,7 @@ namespace VISU
                 Handle(SALOME_InteractiveObject)* theIO,
                 VISU::Storable::TRestoringMap* theMap)
   {
-    if (CheckLock(GetCStudy(GetAppStudy(theModule))))
+    if (CheckLock(GetCStudy(GetAppStudy(theModule)),GetDesktop(theModule)))
       return NULL;
 
     CORBA::Object_var anObject = GetSelectedObj(theModule, theIO);
@@ -227,7 +305,7 @@ namespace VISU
   }
 
   void
-  Add(SalomeApp_SelectionMgr* theSelectionMgr,
+  Add(LightApp_SelectionMgr* theSelectionMgr,
       const Handle(SALOME_InteractiveObject)& theIO)
   {
     SALOME_ListIO aListIO;
@@ -237,7 +315,7 @@ namespace VISU
   }
 
   void
-  Remove(SalomeApp_SelectionMgr* theSelectionMgr,
+  Remove(LightApp_SelectionMgr* theSelectionMgr,
         const Handle(SALOME_InteractiveObject)& theIO)
   {
     if (theIO.IsNull()) return;
@@ -262,7 +340,7 @@ namespace VISU
   bool
   IsRemovableSelected (const SalomeApp_Module* theModule)
   {
-    SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(theModule);
+    LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(theModule);
     SALOME_ListIO aListIO;
     aSelectionMgr->selectedObjects(aListIO);
 
@@ -343,7 +421,6 @@ namespace VISU
     return true;
   }
 
-  //************************************************************
   // Display/Erase
 
   void
@@ -388,30 +465,26 @@ namespace VISU
   }
 
   void
-  DeleteSObject (SalomeApp_Module* theModule,
-                 _PTR(Study)       theStudy,
-                 _PTR(SObject)     theSObject)
+  DeleteSObject(VisuGUI* theModule,
+               _PTR(Study) theStudy,
+               _PTR(SObject) theSObject)
   {
-    SalomeApp_Study* study = GetAppStudy( theModule );
-
     _PTR(ChildIterator) aChildIter = theStudy->NewChildIterator(theSObject);
     for (aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()) {
       _PTR(SObject) aChildSObject = aChildIter->Value();
       
       CORBA::Object_var aChildObj = VISU::ClientSObjectToObject(aChildSObject);
-      VISU::RemovableObject_var aRemovableObject = VISU::RemovableObject::_narrow(aChildObj);
-      if( !CORBA::is_nil( aRemovableObject ) ) 
-       study->deleteReferencesTo( aChildSObject );
+      RemoveScalarBarPosition(theModule,aChildObj);
       ErasePrs(theModule, aChildObj);
     }
 
     CORBA::Object_var anObj = VISU::ClientSObjectToObject(theSObject);
     if (!CORBA::is_nil(anObj)) {
+      RemoveScalarBarPosition(theModule,anObj);
       ErasePrs(theModule, anObj);
 
       VISU::RemovableObject_var aRemovableObject = VISU::RemovableObject::_narrow(anObj);
       if (!CORBA::is_nil(aRemovableObject)) {
-       study->deleteReferencesTo( theSObject );
         aRemovableObject->RemoveFromStudy();
       }
     } else {
@@ -424,26 +497,16 @@ namespace VISU
   }
 
   void
-  DeletePrs3d(SalomeApp_Module* theModule,
+  DeletePrs3d(VisuGUI* theModule,
               VISU::Prs3d_i* thePrs,
               const Handle(SALOME_InteractiveObject)& theIO)
   {
     if (!thePrs)
       return;
-    if (CheckLock(GetCStudy(GetAppStudy(theModule))))
+    if (CheckLock(GetCStudy(GetAppStudy(theModule)),GetDesktop(theModule)))
       return;
-    SALOMEDS::SObject_var aSObject = thePrs->GetSObject();
-    CORBA::String_var anEntry = aSObject->GetID();
-    SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(theModule);
-    Remove(aSelectionMgr,theIO);
-    TViewWindows aViewWindows = GetViews(theModule);
-    for(int i = 0, iEnd = aViewWindows.size(); i < iEnd; i++){
-      SVTK_ViewWindow* aView = aViewWindows[i];
-      if(VISU_Actor* anActor = FindActor(aView,anEntry.in())){
-        aView->RemoveActor(anActor);
-        anActor->Delete();
-      }
-    }
+
+    RemoveScalarBarPosition(theModule,thePrs);
     thePrs->RemoveFromStudy();
   }
 
@@ -452,23 +515,19 @@ namespace VISU
              VISU::Prs3d_i* thePrs)
   {
     if ( SVTK_ViewWindow* vw = GetViewWindow( theModule ) ){
-      VISU_Actor* anVISUActor = FindActor( vw, thePrs );
-      if (anVISUActor) {
+      if (VISU_Actor* anVISUActor = FindActor( vw, thePrs )) {
         anVISUActor->VisibilityOff();
       }
     }
   }
 
-  //************************************************************
   // Presentation management
 
   void
   ChangeRepresentation (const SalomeApp_Module* theModule,
                         VISU::PresentationType  theType)
   {
-    SUIT_ViewWindow* aView = GetActiveView(theModule, SVTK_Viewer::Type());
-    if (!aView) return;
-    SVTK_ViewWindow* vw  = dynamic_cast<SVTK_ViewWindow*>( aView );
+    SVTK_ViewWindow* vw  = GetViewWindow( theModule, false );
     if( !vw )
       return;
 
@@ -535,7 +594,6 @@ namespace VISU
     }
   }
 
-  //************************************************************
   // SObject type
 
   bool
@@ -566,6 +624,9 @@ namespace VISU
               _PTR(SObject)           theSource,
               VISU::Result_var&       theResult)
   {
+    if(theSource->Depth() < 3) // Bug of SALOMEDS : can\t get father from root object
+      return NULL;
+      
     _PTR(SObject) aSObj = theSource->GetFather();
     if (!aSObj)
       return NULL;
@@ -590,16 +651,9 @@ namespace VISU
       return NULL;
 
     theResult = VISU::Result::_narrow(anObject);
-    VISU::Result_i* pResult = dynamic_cast<VISU::Result_i*>(VISU::GetServant(anObject).in());
-    if (pResult == NULL)
-      SUIT_MessageBox::warn1(GetDesktop(theModule),
-                             QObject::tr("WRN_VISU"),
-                             QObject::tr("WRN_NO_AVAILABLE_DATA"),
-                             QObject::tr("BUT_OK"));
-    return pResult;
+    return dynamic_cast<VISU::Result_i*>(VISU::GetServant(anObject).in());
   }
 
-  //************************************************************
   // Views
 
   SUIT_ViewWindow* GetActiveView(const SalomeApp_Module* theModule, QString theType)
@@ -616,7 +670,6 @@ namespace VISU
     return 0;
   }
 
-  //************************************************************
   // VTK View
 
   TViewWindows
@@ -641,18 +694,39 @@ namespace VISU
   }
 
   SVTK_ViewWindow*
-  GetViewWindow(const SalomeApp_Module* theModule, const bool theCreate )
+  GetViewWindow( const SalomeApp_Module* theModule, const bool theCreate )
   {
-    if(SalomeApp_Application* anApp = theModule->getApp()){
-      if(SUIT_ViewManager* aViewManager = anApp->getViewManager( SVTK_Viewer::Type(), theCreate )){
-        if(SUIT_ViewWindow* aViewWindow = aViewManager->getActiveView()){
-          return dynamic_cast<SVTK_ViewWindow*>(aViewWindow);
-        }
+    if (SalomeApp_Application* anApp = theModule->getApp())
+    {
+      SVTK_ViewWindow* wnd = dynamic_cast<SVTK_ViewWindow*>(anApp->desktop()->activeWindow());
+      if( wnd )
+       return wnd;
+      else
+      {
+       SUIT_ViewManager* aViewManager = anApp->getViewManager( SVTK_Viewer::Type(), theCreate );
+       return aViewManager ? dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() ) : 0;
       }
     }
     return NULL;
   }
 
+  /*SVTK_ViewWindow*
+  GetViewWindow(const SalomeApp_Module* theModule, const bool theCreate )
+  {
+    if (SalomeApp_Application* anApp = theModule->getApp())
+    {
+      SVTK_ViewWindow* wnd = dynamic_cast<SVTK_ViewWindow*>(anApp->desktop()->activeWindow());
+      if( wnd )
+       return wnd;
+      else
+      {
+       if(SUIT_ViewManager* aViewManager = anApp->getViewManager( SVTK_Viewer::Type(), theCreate ))
+         return dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() );
+      }
+    }
+    return NULL;
+  }*/
+
 
   SVTK_ViewWindow*
   GetViewWindow()
@@ -684,10 +758,10 @@ namespace VISU
        if(aActor = thePrs->CreateActor())
          aView->AddActor(aActor);
       }catch(std::exception& exc){
-       SUIT_MessageBox::warn1(GetDesktop(theModule),
-                              QObject::tr("WRN_VISU"),
-                              QObject::tr("ERR_CANT_CREATE_ACTOR") + ": " + QObject::tr(exc.what()),
-                              QObject::tr("BUT_OK"));
+       SUIT_MessageBox::warn1
+          (GetDesktop(theModule), QObject::tr("WRN_VISU"),
+           QObject::tr("ERR_CANT_CREATE_ACTOR") + ": " + QObject::tr(exc.what()),
+           QObject::tr("BUT_OK"));
       }
       QApplication::restoreOverrideCursor();
     }
@@ -704,24 +778,31 @@ namespace VISU
 
     vtkRenderer *aRen = vw->getRenderer();
     vtkActorCollection *anActColl = aRen->GetActors();
+    anActColl->InitTraversal();
 
     vtkActor *anActor;
     VISU_Actor* anVISUActor = NULL;
     VISU_Actor* aResActor = NULL;
-    for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ){
-      if(!SALOME_Actor::SafeDownCast(anActor))
-        continue;
-      if(anActor->IsA("VISU_Actor")){
-        anVISUActor = VISU_Actor::SafeDownCast(anActor);
+    while(vtkActor *anActor = anActColl->GetNextActor()){
+      anVISUActor = VISU_Actor::SafeDownCast(anActor);
+      if(anVISUActor){
         VISU::Prs3d_i* aPrs = anVISUActor->GetPrs3d();
         if(aPrs == NULL) continue;
         if (thePrs == aPrs) {
-          aResActor = anVISUActor->GetParent();
-          thePrs->UpdateActor(aResActor);
-          aResActor->VisibilityOn();
-
+          try {
+           aResActor = anVISUActor;
+            thePrs->UpdateActor(aResActor);
+            aResActor->VisibilityOn();
+          } catch (std::runtime_error& exc) {
+            aResActor->VisibilityOff();
+            INFOS(exc.what());
+            SUIT_MessageBox::warn1
+              (GetDesktop(theModule), QObject::tr("WRN_VISU"),
+               QObject::tr("ERR_CANT_CREATE_ACTOR") + ": " + QObject::tr(exc.what()),
+               QObject::tr("BUT_OK"));
+          }
         } else if (theDispOnly) {
-          anVISUActor->GetParent()->VisibilityOff();
+          anVISUActor->VisibilityOff();
         } else {
         }
       } else if (theDispOnly && anActor->GetVisibility()) {
@@ -767,11 +848,11 @@ namespace VISU
   FindActor(SVTK_ViewWindow* theViewWindow,
             const char* theEntry)
   {
-    using namespace VTK;
+    using namespace SVTK;
     if(vtkRenderer* aRenderer = theViewWindow->getRenderer()){
       if(vtkActorCollection* aCollection = aRenderer->GetActors()){
         if(VISU_Actor* anActor = Find<VISU_Actor>(aCollection,TIsSameEntry<VISU_Actor>(theEntry))){
-          return anActor->GetParent();
+          return anActor;
         }
       }
     }
@@ -792,43 +873,24 @@ namespace VISU
                  VISU::Prs3d_i* thePrs)
   {
     QApplication::setOverrideCursor(Qt::waitCursor);
-    bool isPublished = false;
 
     SALOMEDS::SObject_var aSObject = thePrs->GetSObject();
     CORBA::String_var anEntry = aSObject->GetID();
 
     try {
-      thePrs->Update();
-
-      TViewWindows aViewWindows = GetViews(theModule);
-      for (int i = 0, iEnd = aViewWindows.size(); i < iEnd; i++) {
-        SVTK_ViewWindow* aView = aViewWindows[i];
-        if (VISU_Actor* anActor = FindActor(aView, anEntry.in())) {
-          isPublished = true;
-          thePrs->UpdateActor(anActor);
-        }
-      }
-    } catch (std::runtime_error& ex) {
-      INFOS(ex.what());
+      thePrs->UpdateActors();
+    } catch (std::runtime_error& exc) {
+      INFOS(exc.what());
       QApplication::restoreOverrideCursor();
-      SUIT_MessageBox::warn1 (GetDesktop(theModule), QObject::tr("WRN_VISU"),
-                              QObject::tr("ERR_CANT_BUILD_PRESENTATION") + ": " + QObject::tr(ex.what()),
-                              QObject::tr("BUT_OK"));
+      SUIT_MessageBox::warn1
+        (GetDesktop(theModule), QObject::tr("WRN_VISU"),
+         QObject::tr("ERR_CANT_BUILD_PRESENTATION") + ": " + QObject::tr(exc.what()),
+         QObject::tr("BUT_OK"));
 
-      TViewWindows aViewWindows = GetViews(theModule);
-      for (int i = 0, iEnd = aViewWindows.size(); i < iEnd; i++) {
-        SVTK_ViewWindow* aView = aViewWindows[i];
-        if (VISU_Actor* anActor = FindActor(aView, anEntry.in())) {
-          aView->RemoveActor(anActor);
-          anActor->Delete();
-        }
-      }
+      thePrs->RemoveActors();
       return;
     }
     QApplication::restoreOverrideCursor();
-
-    if (!isPublished)
-      PublishInView(theModule, thePrs);
   }
 
   static bool ComputeVisiblePropBounds(SVTK_ViewWindow* theViewWindow,
@@ -936,7 +998,7 @@ namespace VISU
               int theDisplaying)
   {
     if ( theDisplaying == VISU::eErase ) {
-      if ( plotCurve )
+      if ( plotCurve && aPlot )
         aPlot->eraseCurve( plotCurve, false );
     }
     else if ( theDisplaying == VISU::eDisplay || theDisplaying == VISU::eDisplayOnly ) {
@@ -959,12 +1021,14 @@ namespace VISU
           plotCurve->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
         }
         plotCurve->setAutoAssign( theCurve->IsAuto() );
-        aPlot->displayCurve( plotCurve, false );
+       if( aPlot )
+         aPlot->displayCurve( plotCurve, false );
       }
       else {
         Plot2d_Curve* crv = theCurve->CreatePresentation();
         if ( crv ) {
-          aPlot->displayCurve( crv, false );
+         if( aPlot )
+           aPlot->displayCurve( crv, false );
           theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
           theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
           SALOMEDS::Color newColor;
@@ -1117,6 +1181,12 @@ namespace VISU
             }
           }
           PlotContainer( theModule, pContainer, VISU::eDisplay );
+
+         QString anEntry = pContainer->GetEntry();
+         _PTR(Study) aStudy = theTableSO->GetStudy();
+         _PTR(SObject) aContainerSO = aStudy->FindObjectID(anEntry.latin1());
+         _PTR(SObject) aParentSO = aContainerSO->GetFather();
+         UpdateObjBrowser(theModule,true,aParentSO);
         }
       }
     }
@@ -1204,10 +1274,10 @@ namespace VISU
         theModule->getApp()->updateActions();
       } catch (std::runtime_error& exc) {
         INFOS(exc.what());
-        SUIT_MessageBox::warn1 (GetDesktop(theModule),
-                                QObject::tr("WRN_VISU"),
-                                QObject::tr("ERR_CANT_CREATE_ACTOR") + ": " + QObject::tr(exc.what()),
-                                QObject::tr("BUT_OK"));
+        SUIT_MessageBox::warn1
+          (GetDesktop(theModule), QObject::tr("WRN_VISU"),
+           QObject::tr("ERR_CANT_CREATE_ACTOR") + ": " + QObject::tr(exc.what()),
+           QObject::tr("BUT_OK"));
       }
     }
   }
@@ -1250,6 +1320,7 @@ namespace VISU
         case VISU::TVECTORS:
         case VISU::TSTREAMLINES:
         case VISU::TPLOT3D:
+       case VISU::TSCALARMAPONDEFORMEDSHAPE:
           {
             PortableServer::ServantBase_var aServant = VISU::GetServant(aCORBAObject);
             if (aServant.in()) {
@@ -1340,4 +1411,58 @@ namespace VISU
     }
     return aList;
   }
+  
+  int GetFreePositionOfDefaultScalarBar(VisuGUI* theModule){
+    int minIndx = 1;
+    std::set<int> aIndexes;
+    SVTK_ViewWindow* vw = GetViewWindow(theModule);
+    TViewToPrs3d aMap = theModule->getScalarBarsMap();
+    TViewToPrs3d::const_iterator aViewToPrsIter = aMap.find(vw);
+    if (aViewToPrsIter != aMap.end()){
+      TSetPrs3d::const_iterator aPrsIter = (aViewToPrsIter->second).begin();
+      for(;aPrsIter!=(aViewToPrsIter->second).end();aPrsIter++){
+       aIndexes.insert((*aPrsIter).second);
+      }
+    }
+    std::set<int>::const_iterator aIter = aIndexes.begin();
+    for (int i=1,length=aIndexes.size(); i <= length; i++){
+      std::set<int>::const_iterator aIter = aIndexes.find(i);
+      if(aIter==aIndexes.end()){minIndx = i;break;} 
+      else minIndx = i + 1;
+      
+    }
+    return minIndx;
+  }
+  
+  void AddScalarBarPosition(VisuGUI* theModule,VISU::Prs3d_i* thePrs3d, int pos){
+    SVTK_ViewWindow* vw = GetViewWindow(theModule);
+    TViewToPrs3d& aMap = theModule->myScalarBarsMap;
+    TPrs3dToInd aPair; aPair.first=thePrs3d; aPair.second=pos;
+    aMap[vw].insert(aPair);
+  }
+  
+  void RemoveScalarBarPosition(VisuGUI* theModule,SVTK_ViewWindow* vw,VISU::Prs3d_i* thePrs3d){
+    TViewToPrs3d& aMap = theModule->myScalarBarsMap;
+    TSetPrs3d::iterator aIter = aMap[vw].begin();
+    for(;aIter!=aMap[vw].end();aIter++)
+      if((*aIter).first == thePrs3d){
+       aMap[vw].erase(*aIter);
+       return;
+      }
+  }
+
+  void RemoveScalarBarPosition(VisuGUI* theModule,VISU::Prs3d_i* thePrs3d){
+    SVTK_ViewWindow* vw = GetViewWindow(theModule);
+    RemoveScalarBarPosition(theModule,vw,thePrs3d);
+  }
+  
+  void RemoveScalarBarPosition(VisuGUI* theModule,CORBA::Object_ptr theObject){
+    if (!CORBA::is_nil(theObject)) {
+      Base_var aBase = Base::_narrow(theObject);
+      if (CORBA::is_nil(aBase)) return;
+      if (VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aBase).in())){
+       RemoveScalarBarPosition(theModule,aPrsObject);
+      }
+    }
+  }
 }