Salome HOME
Merge from V5_1_main 14/05/2010
[modules/visu.git] / src / VISUGUI / VisuGUI_Tools.cxx
index 4748228c14b6503032c31862c1c168916063e586..91b9e9081f32e207af1db5821c4e1e4dc07980d3 100644 (file)
@@ -1,4 +1,4 @@
-//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -19,6 +19,7 @@
 //
 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
 //  VISU VISUGUI : GUI of VISU component
 //  File   : VisuGUI_Tools.cxx
 //  Author : Sergey Anikin
@@ -31,6 +32,9 @@
 
 #include "VisuGUI.h"
 
+#include "VISU_Tools.h"
+
+#include "VISU_ColoredPrs3dHolder_i.hh"
 #include "VISU_Gen_i.hh"
 #include "VISU_Prs3d_i.hh"
 #include "VISU_Result_i.hh"
@@ -44,6 +48,8 @@
 #include "SalomeApp_Module.h"
 #include "SalomeApp_Study.h"
 #include "SalomeApp_Application.h"
+#include "SalomeApp_IntSpinBox.h"
+#include "SalomeApp_DoubleSpinBox.h"
 
 #include "LightApp_DataObject.h"
 #include "LightApp_SelectionMgr.h"
@@ -67,6 +73,7 @@
 #include "SUIT_MessageBox.h"
 #include "SUIT_Desktop.h"
 #include "SUIT_ViewWindow.h"
+#include "SUIT_ResourceMgr.h"
 
 #include "CAM_DataModel.h"
 
@@ -76,6 +83,7 @@
 #include <QString>
 #include <QSpinBox>
 #include <QDoubleSpinBox>
+#include <QVariant>
 
 using namespace std;
 
@@ -121,13 +129,13 @@ namespace VISU
   //------------------------------------------------------------
   bool
   CheckLock( _PTR(Study) theStudy,
-            QWidget* theWidget )
+             QWidget* theWidget )
   {
     if(IsStudyLocked(theStudy)){
       SUIT_MessageBox::warning(theWidget,
                                QObject::tr("WRN_VISU_WARNING"),
                                QObject::tr("WRN_STUDY_LOCKED") );
-       return true;
+        return true;
     }
     return false;
   }
@@ -143,8 +151,8 @@ namespace VISU
   //------------------------------------------------------------
   LightApp_DataObject*
   FindDataObject(SUIT_DataObject* theDataObject,
-                const QString& theEntry,
-                int theLevel)
+                 const QString& theEntry,
+                 int theLevel)
   {
     int aLevel = theDataObject->level() + 2;
     QString aSourceEntry = theEntry.section(':',0,aLevel);
@@ -153,15 +161,15 @@ namespace VISU
     DataObjectList::Iterator aDataObjectIter = aList.begin();
     while( aDataObjectIter!= aList.end() ) {
       if(LightApp_DataObject* aChildDataObject = dynamic_cast<LightApp_DataObject*>(*aDataObjectIter)){
-       QString anEntry = aChildDataObject->entry();
-       QString aCurrentEntry = anEntry.section(':',0,aLevel);
-       if(aSourceEntry == aCurrentEntry){
-         if(theLevel == aLevel){
-           return aChildDataObject;
-         }else{
-           return FindDataObject(aChildDataObject,theEntry,theLevel);
-         }
-       }
+        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++;
     }
@@ -171,7 +179,7 @@ namespace VISU
   //------------------------------------------------------------
   LightApp_DataObject*
   FindDataObject(CAM_Module* theModule,
-                _PTR(SObject) theSObject)
+                 _PTR(SObject) theSObject)
   {
     CAM_DataModel* aDataModel = theModule->dataModel();
     CAM_DataObject* aRootDataObject = aDataModel->root();
@@ -186,8 +194,8 @@ namespace VISU
   //------------------------------------------------------------
   void
   UpdateObjBrowser(SalomeApp_Module* theModule,
-                  bool theIsUpdateDataModel,
-                  _PTR(SObject) theSObject)
+                   bool theIsUpdateDataModel,
+                   _PTR(SObject) theSObject)
   {
     LightApp_DataObject* aDataObject = NULL;
     if(theSObject)
@@ -204,9 +212,9 @@ namespace VISU
     if ( theSObject ) {
       _PTR(GenericAttribute) anAttr;
       if (theSObject->FindAttribute( anAttr, "AttributeTableOfInteger" ))
-       return true;
+        return true;
       if (theSObject->FindAttribute( anAttr, "AttributeTableOfReal" ))
-       return true;
+        return true;
     }
     return false;
   }
@@ -215,17 +223,18 @@ namespace VISU
   VISU_Gen_i*
   GetVisuGen(const CAM_Module* theModule)
   {
-    static VISU_Gen_i* aGen = NULL;
+    static VISU_Gen_i* aGen = 0;
     if(!aGen){
       SALOME_LifeCycleCORBA aLCC(SalomeApp_Application::namingService());
       Engines::Component_var aComponent = aLCC.FindOrLoad_Component("FactoryServer","VISU");
       VISU_Gen_var aVISU = VISU_Gen::_narrow(aComponent);
-      if(!CORBA::is_nil(aVISU)){
-       if((aGen = VISU_Gen_i::GetVisuGenImpl()))
-         aGen->SetCurrentStudy(GetDSStudy(GetCStudy(GetAppStudy(theModule))));
-      }
+      if(!CORBA::is_nil(aVISU))
+        aGen = VISU_Gen_i::GetVisuGenImpl();
     }
-    if(!aGen)
+    
+    if(aGen)
+      aGen->SetCurrentStudy(GetDSStudy(GetCStudy(GetAppStudy(theModule))));
+    else
       throw std::runtime_error(QObject::tr("ERR_CANT_FIND_VISU_COMPONENT").toLatin1().data());
     return aGen;
   }
@@ -260,18 +269,18 @@ namespace VISU
       SALOME_ListIteratorOfListIO anIter(aListIO);
       while(anIter.More())
       {
-       Handle(SALOME_InteractiveObject) anIO = anIter.Value();
-       if(anIO->hasEntry())
-       {
-         TObjectInfo anObjectInfo = GetObjectByEntry(aStudy, anIO->getEntry());
-         if(anObjectInfo.mySObject){
-           TSelectionItem aSelectionItem;
-           aSelectionItem.myObjectInfo = anObjectInfo;
-           aSelectionItem.myIO = anIO;
-           aSelectionInfo.push_back(aSelectionItem);
-         }
-       }
-       anIter.Next(); // MULTIPR fixed
+        Handle(SALOME_InteractiveObject) anIO = anIter.Value();
+        if(anIO->hasEntry())
+        {
+          TObjectInfo anObjectInfo = GetObjectByEntry(aStudy, anIO->getEntry());
+          if(anObjectInfo.mySObject){
+            TSelectionItem aSelectionItem;
+            aSelectionItem.myObjectInfo = anObjectInfo;
+            aSelectionItem.myIO = anIO;
+            aSelectionInfo.push_back(aSelectionItem);
+          }
+        }
+        anIter.Next(); // MULTIPR fixed
       }
     }
     return aSelectionInfo;
@@ -280,7 +289,7 @@ namespace VISU
   //----------------------------------------------------------------------------
   TObjectInfo
   GetObjectByEntry(const SalomeApp_Study* theStudy,
-                  const std::string& theEntry)
+                   const std::string& theEntry)
   {
     TObjectInfo anObjectInfo;
     if(!theStudy || theEntry == "")
@@ -291,7 +300,7 @@ namespace VISU
       anObjectInfo.mySObject = aSObject;
       CORBA::Object_var anObject = ClientSObjectToObject(aSObject);
       if(VISU::Base_i* aBase = GetServantInterface<VISU::Base_i>(anObject))
-       anObjectInfo.myBase = aBase;
+        anObjectInfo.myBase = aBase;
     }
     
     return anObjectInfo;
@@ -301,7 +310,7 @@ namespace VISU
   //----------------------------------------------------------------------------
   VISU::Prs3d_i*
   GetPrs3dToModify(const SalomeApp_Module* theModule,
-                  Base_i* theBase)
+                   Base_i* theBase)
   {
     if (CheckLock(GetCStudy(GetAppStudy(theModule)), GetDesktop(theModule)))
       return NULL;
@@ -326,9 +335,9 @@ namespace VISU
   //----------------------------------------------------------------------------
   bool
   GetPrs3dSelectionInfo(const SalomeApp_Module* theModule,
-                       VISU::Prs3d_i*& thePrs3d,
-                       SVTK_ViewWindow*& theViewWindow,
-                       VISU_Actor*& thenActor)
+                        VISU::Prs3d_i*& thePrs3d,
+                        SVTK_ViewWindow*& theViewWindow,
+                        VISU_Actor*& thenActor)
   {
     VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(theModule);
     if(aSelectionInfo.empty())
@@ -365,7 +374,7 @@ namespace VISU
   //------------------------------------------------------------
   void
   Remove(LightApp_SelectionMgr* theSelectionMgr,
-        const Handle(SALOME_InteractiveObject)& theIO)
+         const Handle(SALOME_InteractiveObject)& theIO)
   {
     if (theIO.IsNull()) return;
     SALOME_ListIO aListIO, aNewListIO;
@@ -374,7 +383,7 @@ namespace VISU
     for (; anIter.More(); anIter.Next()) {
       Handle(SALOME_InteractiveObject) anIO = anIter.Value();
       if (!anIO->isSame(theIO)) {
-       aNewListIO.Append(theIO);
+        aNewListIO.Append(theIO);
       }
     }
     theSelectionMgr->setSelectedObjects(aNewListIO);
@@ -414,14 +423,14 @@ namespace VISU
         _PTR(GenericAttribute) anAttr;
         _PTR(AttributeString) aComment;
 
-       _PTR(SObject) aRefSObject;
-       if (aSObject->ReferencedObject(aRefSObject)) {
-         // It can be a reference on curve, published under a container. IPAL 20317
-         VISU::TObjectInfo aRefObjectInfo = GetObjectByEntry(GetAppStudy(theModule), aRefSObject->GetID());
-         VISU::Base_i* aRefBase = aRefObjectInfo.myBase;
-         if( (aRefBase && aRefBase->GetType() == VISU::TCURVE) || (aRefBase && aRefBase->GetType() == VISU::TMESH) )
-           return true;
-       }
+        _PTR(SObject) aRefSObject;
+        if (aSObject->ReferencedObject(aRefSObject)) {
+          // It can be a reference on curve, published under a container. IPAL 20317
+          VISU::TObjectInfo aRefObjectInfo = GetObjectByEntry(GetAppStudy(theModule), aRefSObject->GetID());
+          VISU::Base_i* aRefBase = aRefObjectInfo.myBase;
+          if( (aRefBase && aRefBase->GetType() == VISU::TCURVE) || (aRefBase && aRefBase->GetType() == VISU::TMESH) )
+            return true;
+        }
 
         bool isUnderVISU = false;
         _PTR(SObject) aFatherSObject = aSObject->GetFather();
@@ -495,8 +504,8 @@ namespace VISU
   //------------------------------------------------------------
   void
   DeleteSObject(VisuGUI* theModule,
-               _PTR(Study) theStudy,
-               _PTR(SObject) theSObject)
+                _PTR(Study) theStudy,
+                _PTR(SObject) theSObject)
   {
     _PTR(ChildIterator) aChildIter = theStudy->NewChildIterator(theSObject);
     for (aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()) {
@@ -539,15 +548,15 @@ namespace VISU
     if(VISU::ColoredPrs3d_i* aColoredPrs3d = dynamic_cast<VISU::ColoredPrs3d_i*>(thePrs)){
       std::string anEntry = aColoredPrs3d->GetHolderEntry();
       if(anEntry != ""){
-       VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(GetAppStudy(theModule), anEntry);
-       if(VISU::Base_i* aBase = anObjectInfo.myBase){
-         if(aBase->GetType() == VISU::TCOLOREDPRS3DHOLDER){
-           CORBA::Object_var anObject = aBase->_this();
-           VISU::RemovableObject_var aRemovableObject = VISU::RemovableObject::_narrow(anObject);
-           aRemovableObject->RemoveFromStudy();
-           return;
-         }
-       }
+        VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(GetAppStudy(theModule), anEntry);
+        if(VISU::Base_i* aBase = anObjectInfo.myBase){
+          if(aBase->GetType() == VISU::TCOLOREDPRS3DHOLDER){
+            CORBA::Object_var anObject = aBase->_this();
+            VISU::RemovableObject_var aRemovableObject = VISU::RemovableObject::_narrow(anObject);
+            aRemovableObject->RemoveFromStudy();
+            return;
+          }
+        }
       }
     } 
       
@@ -575,7 +584,7 @@ namespace VISU
     if(!aPrs3d) {
       aTable = dynamic_cast<VISU::PointMap3d_i*>(aSelectionItem.myObjectInfo.myBase);      
       if(!aTable)
-       return;
+        return;
     }
 
     SVTK_ViewWindow* aViewWindow = GetActiveViewWindow<SVTK_ViewWindow>(theModule);
@@ -585,46 +594,46 @@ namespace VISU
     if (aPrs3d) {
       anActor = FindActor(aViewWindow, aPrs3d);
       if(!anActor)
-       return;
+        return;
     } else {
       anActorBase = VISU::FindActorBase(aViewWindow, aTable);
       if(!anActorBase)
-       return;
+        return;
     }
 
     switch (theType) {
     case VISU::SHRINK:
       if (aPrs3d) {
-       bool toShrink;
-       if (anActor->IsShrunk()) {
-         anActor->UnShrink();
-         toShrink = false;
-       }
-       else {
-         anActor->SetShrink();
-         toShrink = true;
-       }
-       if (VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d)) {
-         aMesh->SetShrink(toShrink);
-       }
+        bool toShrink;
+        if (anActor->IsShrunk()) {
+          anActor->UnShrink();
+          toShrink = false;
+        }
+        else {
+          anActor->SetShrink();
+          toShrink = true;
+        }
+        if (VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d)) {
+          aMesh->SetShrink(toShrink);
+        }
       } else if (aTable) {
-       if (anActorBase->IsShrunk())
-         anActorBase->UnShrink();
-       else
-         anActorBase->SetShrink();
+        if (anActorBase->IsShrunk())
+          anActorBase->UnShrink();
+        else
+          anActorBase->SetShrink();
       }
       break;
     default:
       if (aPrs3d) {
-       if (VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d)) {
-         aMesh->SetPresentationType(theType);
-         RecreateActor(theModule, aMesh);
-       } else {
-         anActor->SetRepresentation(theType);
-       }
+        if (VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d)) {
+          aMesh->SetPresentationType(theType);
+          RecreateActor(theModule, aMesh);
+        } else {
+          anActor->SetRepresentation(theType);
+        }
       }
       else if (aTable) {
-       anActorBase->SetRepresentation(theType);
+        anActorBase->SetRepresentation(theType);
       }
     }
     aViewWindow->Repaint();
@@ -671,7 +680,7 @@ namespace VISU
   //------------------------------------------------------------
   void
   SetShading ( const SalomeApp_Module* theModule,
-             bool theOn )
+              bool theOn )
   {
     TSelectionInfo aSelectionInfo = GetSelectedObjects(theModule);
     if(aSelectionInfo.empty())
@@ -702,7 +711,7 @@ namespace VISU
   CheckTimeStamp(const SalomeApp_Module* theModule,
                  _PTR(SObject)&          theSObject,
                  Handle(SALOME_InteractiveObject)& theIO,
-                ColoredPrs3d_i::EPublishInStudyMode& thePublishInStudyMode)
+                 ColoredPrs3d_i::EPublishInStudyMode& thePublishInStudyMode)
   {
     TSelectionInfo aSelectionInfo = GetSelectedObjects(theModule);
     if(!aSelectionInfo.empty()){
@@ -711,13 +720,13 @@ namespace VISU
       theSObject = aSelectionItem.myObjectInfo.mySObject;
       VISU::VISUType aType = VISU::Storable::SObject2Type(theSObject);
       if (VISU::TTIMESTAMP == aType){
-       thePublishInStudyMode = ColoredPrs3d_i::EPublishUnderTimeStamp;
+        thePublishInStudyMode = ColoredPrs3d_i::EPublishUnderTimeStamp;
         return true;
       }
       if (VISU::TFIELD == aType){
-       thePublishInStudyMode = ColoredPrs3d_i::EPublishIndependently;
-       if(theSObject->FindSubObject(2,theSObject))
-         return true;
+        thePublishInStudyMode = ColoredPrs3d_i::EPublishIndependently;
+        if(theSObject->FindSubObject(2,theSObject))
+          return true;
       }
     }
     SUIT_MessageBox::warning(GetDesktop(theModule),
@@ -819,8 +828,8 @@ namespace VISU
   //------------------------------------------------------------
   VISU_Actor*
   FindActor(const SalomeApp_Study* theStudy,
-           SVTK_ViewWindow* theViewWindow,
-           const QString& theEntry)
+            SVTK_ViewWindow* theViewWindow,
+            const QString& theEntry)
   {
     TObjectInfo anObjectInfo = GetObjectByEntry(theStudy, theEntry.toLatin1().data());
     VISU::Prs3d_i* aPrs3d = GetPrs3dFromBase(anObjectInfo.myBase);
@@ -830,8 +839,8 @@ namespace VISU
   //------------------------------------------------------------
   VISU_ActorBase*
   FindActorBase(const SalomeApp_Study* theStudy,
-               SVTK_ViewWindow* theViewWindow,
-               const QString& theEntry)
+                SVTK_ViewWindow* theViewWindow,
+                const QString& theEntry)
   {
     TObjectInfo anObjectInfo = GetObjectByEntry(theStudy, theEntry.toLatin1().constData());
     VISU::PointMap3d_i* aTable = dynamic_cast<VISU::PointMap3d_i*>(anObjectInfo.myBase);
@@ -846,7 +855,7 @@ namespace VISU
     QApplication::setOverrideCursor(Qt::WaitCursor);
 
     /*    SALOMEDS::SObject_var aSObject = thePrs->GetSObject();
-         CORBA::String_var anEntry = aSObject->GetID();*/
+          CORBA::String_var anEntry = aSObject->GetID();*/
 
     try {
       thePrs->UpdateActors();
@@ -866,8 +875,8 @@ namespace VISU
   //------------------------------------------------------------
   bool
   ComputeVisiblePropBounds(SVTK_ViewWindow* theViewWindow,
-                          vtkFloatingPointType allBounds[6], 
-                          const char* theActorClassName)
+                           vtkFloatingPointType allBounds[6], 
+                           const char* theActorClassName)
   {
     vtkRenderer *aRen = theViewWindow->getRenderer();
     VTK::ActorCollectionCopy aCopy(aRen->GetActors());
@@ -889,13 +898,13 @@ namespace VISU
             bounds[2] > -VTK_LARGE_FLOAT && bounds[3] < VTK_LARGE_FLOAT &&
             bounds[4] > -VTK_LARGE_FLOAT && bounds[5] < VTK_LARGE_FLOAT)
         {
-         somethingVisible = true;
-         if (bounds[0] < allBounds[0]) allBounds[0] = bounds[0]; 
-         if (bounds[1] > allBounds[1]) allBounds[1] = bounds[1]; 
-         if (bounds[2] < allBounds[2]) allBounds[2] = bounds[2]; 
-         if (bounds[3] > allBounds[3]) allBounds[3] = bounds[3]; 
-         if (bounds[4] < allBounds[4]) allBounds[4] = bounds[4]; 
-         if (bounds[5] > allBounds[5]) allBounds[5] = bounds[5]; 
+          somethingVisible = true;
+          if (bounds[0] < allBounds[0]) allBounds[0] = bounds[0]; 
+          if (bounds[1] > allBounds[1]) allBounds[1] = bounds[1]; 
+          if (bounds[2] < allBounds[2]) allBounds[2] = bounds[2]; 
+          if (bounds[3] > allBounds[3]) allBounds[3] = bounds[3]; 
+          if (bounds[4] < allBounds[4]) allBounds[4] = bounds[4]; 
+          if (bounds[5] > allBounds[5]) allBounds[5] = bounds[5]; 
         }//not bogus
       }
     }
@@ -964,66 +973,16 @@ namespace VISU
     return NULL;
   }
 
-  //------------------------------------------------------------
-  // Internal function used by several public functions below
-  void
-  UpdateCurve(VISU::Curve_i* theCurve,
-              Plot2d_ViewFrame* aPlot,
-              SPlot2d_Curve* plotCurve,
-              int theDisplaying)
-  {
-    if ( theDisplaying == VISU::eErase ) {
-      if ( plotCurve && aPlot )
-        aPlot->eraseCurve( plotCurve, false );
-    }
-    else if ( theDisplaying == VISU::eDisplay || theDisplaying == VISU::eDisplayOnly ) {
-      if ( plotCurve ) {
-        plotCurve->setHorTitle( theCurve->GetHorTitle().c_str() );
-        //plotCurve->setVerTitle( ( theCurve->GetVerTitle().c_str() ) );
-        plotCurve->setVerTitle( theCurve->GetName().c_str() );
-        plotCurve->setHorUnits( theCurve->GetHorUnits().c_str() );
-        plotCurve->setVerUnits( theCurve->GetVerUnits().c_str() );
-        double* xList = 0;
-        double* yList = 0;
-       QStringList zList;
-        int     nbPoints = theCurve->GetData( xList, yList, zList );
-        if ( nbPoints > 0 && xList && yList ) {
-          plotCurve->setData( xList, yList, nbPoints, zList );
-        }
-        if ( !theCurve->IsAuto() ) {
-          plotCurve->setLine( (Plot2d::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
-          plotCurve->setMarker( (Plot2d::MarkerType)theCurve->GetMarker() );
-          SALOMEDS::Color color = theCurve->GetColor();
-          plotCurve->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
-        }
-        plotCurve->setAutoAssign( theCurve->IsAuto() );
-       if( aPlot )
-         aPlot->displayCurve( plotCurve, false );
-      }
-      else {
-        Plot2d_Curve* crv = theCurve->CreatePresentation();
-        if ( crv ) {
-         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;
-          newColor.R = crv->getColor().red()/255.;
-          newColor.G = crv->getColor().green()/255.;
-          newColor.B = crv->getColor().blue()/255.;
-          theCurve->SetColor( newColor );
-          crv->setAutoAssign( theCurve->IsAuto() );
-        }
-      }
-    }
-  }
-
   //------------------------------------------------------------
   void
   PlotTable(const SalomeApp_Module* theModule,
             VISU::Table_i* table,
             int theDisplaying)
   {
+    SalomeApp_Study* aStudy = GetAppStudy( theModule );
+    if( !aStudy )
+      return;
+
     SPlot2d_Viewer* aView = GetPlot2dViewer( theModule, true ); // create if necessary
     if ( !aView )
       return;
@@ -1031,41 +990,8 @@ namespace VISU
     if ( !aPlot )
       return;
 
-    if ( theDisplaying == VISU::eDisplayOnly )
-      aPlot->EraseAll();
-    QList<Plot2d_Curve*> clist;
-    aPlot->getCurves( clist );
-    _PTR(Study) aStudy = GetCStudy( GetAppStudy( theModule ) );
-    _PTR(SObject) TableSO = aStudy->FindObjectID( table->GetEntry() );
-    if ( TableSO ) {
-      _PTR(ChildIterator) Iter = aStudy->NewChildIterator( TableSO );
-      for ( ; Iter->More(); Iter->Next() ) {
-        CORBA::Object_var childObject = VISU::ClientSObjectToObject( Iter->Value() );
-        if( !CORBA::is_nil( childObject ) ) {
-          CORBA::Object_ptr aCurve = VISU::Curve::_narrow( childObject );
-          if( !CORBA::is_nil( aCurve ) ) {
-            VISU::Curve_i* theCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
-            SPlot2d_Curve* plotCurve = 0;
-            SPlot2d_Curve* tmpCurve;
-            for ( int i = 0; i < clist.count(); i++ ) {
-              tmpCurve = dynamic_cast<SPlot2d_Curve*>( clist.at( i ) );
-              if (tmpCurve && tmpCurve->hasIO() &&
-                  theCurve->GetEntry() == tmpCurve->getIO()->getEntry()) {
-                plotCurve = tmpCurve;
-                break;
-              }
-            }
-
-            UpdateCurve( theCurve, aPlot, plotCurve, theDisplaying );
-
-            if ( theDisplaying == VISU::eErase && plotCurve ) {
-              clist.removeAll(plotCurve );
-            }
-          }
-        }
-      }
-      aPlot->Repaint();
-    }
+    // implementation moved to VISU_I package (see VISU_Tools.h)
+    VISU::PlotTable( aStudy, aPlot, table, theDisplaying );
   }
 
   //------------------------------------------------------------
@@ -1081,69 +1007,17 @@ namespace VISU
     if ( !aPlot )
       return;
 
-//  if ( theDisplaying == VISU::eDisplayOnly )
-//    aPlot->EraseAll();
-    QList<Plot2d_Curve*> clist;
-    aPlot->getCurves( clist );
-    SPlot2d_Curve* plotCurve = 0;
-    SPlot2d_Curve* tmpCurve;
-    if(theDisplaying == VISU::eErase) {
-      // 23.06.2008 skl for IPAL17672
-      for (int i = 0; i < clist.count(); i++) {
-        tmpCurve = dynamic_cast<SPlot2d_Curve*>(clist.at(i));
-        if (tmpCurve && tmpCurve->hasIO() &&
-            theCurve->GetEntry() == tmpCurve->getIO()->getEntry()) {
-          plotCurve = tmpCurve;
-          aPlot->eraseCurve(clist.at(i));
-          break;
-        }
-      }
-      UpdateCurve(theCurve, aPlot, plotCurve, theDisplaying);
-    }
-    else {
-      for (int i = 0; i < clist.count(); i++) {
-        tmpCurve = dynamic_cast<SPlot2d_Curve*>(clist.at(i));
-        if (tmpCurve && tmpCurve->hasIO() &&
-            theCurve->GetEntry() == tmpCurve->getIO()->getEntry()) {
-          plotCurve = tmpCurve;
-        }
-        else if (theDisplaying == VISU::eDisplayOnly) {
-          aPlot->eraseCurve(clist.at(i));
-        }
-      }
-      UpdateCurve(theCurve, aPlot, plotCurve, theDisplaying);
-    }
-
-    aPlot->Repaint();
+    // implementation moved to VISU_I package (see VISU_Tools.h)
+    VISU::PlotCurve( aPlot, theCurve, theDisplaying );
   }
 
   //------------------------------------------------------------
   void
   PlotRemoveCurve(const SalomeApp_Module* theModule,
-                 VISU::Curve_i* pCrv)
+                  VISU::Curve_i* pCrv)
   {
-    QString anEntry = pCrv->GetEntry().c_str();
-    ViewManagerList pvm_list;
-    theModule->getApp()->viewManagers( SPlot2d_Viewer::Type(), pvm_list );
-    ViewManagerList::Iterator pvm_it = pvm_list.begin();
-    for( ; pvm_it != pvm_list.end(); pvm_it++ ){
-      Plot2d_ViewManager* pvm = dynamic_cast<Plot2d_ViewManager*>( *pvm_it );
-      if( pvm ){
-       SPlot2d_Viewer* aSPlot2d = dynamic_cast<SPlot2d_Viewer*>( pvm->getViewModel() );
-       if( aSPlot2d ){
-         Plot2d_ViewFrame* aPlot = aSPlot2d->getActiveViewFrame();
-         if(aPlot){
-           QList<Plot2d_Curve*> clist;
-           aPlot->getCurves( clist );
-           for (int i = 0; i < clist.count(); i++) {
-             if(SPlot2d_Curve* plotCurve = dynamic_cast<SPlot2d_Curve*>(clist[i]))
-               if(plotCurve->hasIO() && (plotCurve->getIO()->getEntry() == anEntry))
-                 aPlot->eraseCurve(clist[i]);
-           }
-         }
-       }
-      }
-    }
+    // implementation moved to VISU_I package (see VISU_Tools.h)
+    VISU::PlotRemoveCurve( theModule->getApp(), pCrv );
   }
   
   //------------------------------------------------------------
@@ -1159,31 +1033,8 @@ namespace VISU
     if ( !aPlot )
       return;
 
-    if ( theDisplaying == VISU::eDisplayOnly )
-      aPlot->EraseAll();
-    QList<Plot2d_Curve*> clist;
-    aPlot->getCurves( clist );
-    if ( container->GetNbCurves() > 0 ) {
-      int nbCurves = container->GetNbCurves();
-      for ( int k = 1; k <= nbCurves; k++ ) {
-        VISU::Curve_i* theCurve = container->GetCurve( k );
-        if ( theCurve && theCurve->IsValid() ) {
-          SPlot2d_Curve* plotCurve = dynamic_cast<SPlot2d_Curve*>
-            (aView->getCurveByIO(new SALOME_InteractiveObject(theCurve->GetEntry().c_str(), "", "")));
-
-          UpdateCurve( theCurve, aPlot, plotCurve, theDisplaying );
-
-          if ( plotCurve && theDisplaying == VISU::eErase ) {
-            clist.removeAll( plotCurve );
-          }
-        }
-      }
-    }
-    aPlot->Repaint();
-    if(GetResourceMgr()->booleanValue("VISU","automatic_fit_all",false)){
-      aPlot->fitAll();
-    }
-    qApp->processEvents();
+    // implementation moved to VISU_I package (see VISU_Tools.h)
+    VISU::PlotContainer( aPlot, container, theDisplaying );
   }
 
   //------------------------------------------------------------
@@ -1191,43 +1042,27 @@ namespace VISU
   CreatePlot(SalomeApp_Module* theModule,
              _PTR(SObject) theTableSO)
   {
-    if ( IsSObjectTable(theTableSO) ) {
-      CORBA::Object_var aTable = VISU::ClientSObjectToObject(theTableSO);
-      CORBA::Object_var aContainer = GetVisuGen( theModule )->CreateContainer();
-      if ( !CORBA::is_nil( aTable ) && !CORBA::is_nil( aContainer ) ) {
-        VISU::Table_i*     pTable     = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
-        VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
-
-        if ( pContainer && pTable ) {
-          for ( int i = 2; i <= pTable->GetNbRows(); i++ ) {
-            CORBA::Object_var aNewCurve = GetVisuGen( theModule )->CreateCurve( pTable->_this(), 1, i );
-            if( !CORBA::is_nil( aNewCurve ) ) {
-              VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>( VISU::GetServant(aNewCurve).in() );
-              if ( pCrv ) {
-                pContainer->AddCurve( pCrv->_this() );
-              }
-            }
-          }
-          PlotContainer( theModule, pContainer, VISU::eDisplay );
+    SPlot2d_Viewer* aView = GetPlot2dViewer( theModule, true );
+    if ( !aView )
+      return;
+    Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
+    if ( !aPlot )
+      return;
 
-         QString anEntry = pContainer->GetEntry().c_str();
-         _PTR(Study) aStudy = theTableSO->GetStudy();
-         _PTR(SObject) aContainerSO = aStudy->FindObjectID(anEntry.toLatin1().data());
-         _PTR(SObject) aParentSO = aContainerSO->GetFather();
-         UpdateObjBrowser(theModule,true,aParentSO);
-        }
-      }
-    }
+    VISU::VISU_Gen_i* aVisuGen = VISU::GetVisuGen( theModule );
+
+    // implementation moved to VISU_I package (see VISU_Tools.h)
+    VISU::CreatePlot( aVisuGen, aPlot, theTableSO );
   }
 
   //************************************************************
   // Others
   VISU::Mesh_i*
   CreateMesh(VisuGUI* theModule,
-            const Handle(SALOME_InteractiveObject)& theIO,
-            SVTK_ViewWindow* theViewWindow)
+             const Handle(SALOME_InteractiveObject)& theIO,
+             SVTK_ViewWindow* theViewWindow)
   {  
-       _PTR(Study) aStudy = GetCStudy(GetAppStudy(theModule));
+        _PTR(Study) aStudy = GetCStudy(GetAppStudy(theModule));
     //if (CheckLock(aStudy))
     //  return;
 
@@ -1289,13 +1124,13 @@ namespace VISU
         timer.Start();
 #endif
         if(GetResourceMgr()->booleanValue("VISU","display_only",false)){
-         const VisuGUI* av = dynamic_cast<const VisuGUI*>(theModule);
-         if(av)(const_cast<VisuGUI*>(av))->OnEraseAll();
-       }
+          const VisuGUI* av = dynamic_cast<const VisuGUI*>(theModule);
+          if(av)(const_cast<VisuGUI*>(av))->OnEraseAll();
+        }
         PublishMeshInView(theModule, pPresent, theViewWindow);
         if(GetResourceMgr()->booleanValue("VISU","automatic_fit_all",false)){
-         SetFitAll(theViewWindow);
-       }
+          SetFitAll(theViewWindow);
+        }
 #ifdef CHECKTIME
         timer.Stop();
         MESSAGE("VisuGUI::CreateMesh() - DISPLAY MESH");
@@ -1321,7 +1156,7 @@ namespace VISU
   // ========================================================================================
   std::vector<VISU::Prs3d_i*> GetPrs3dList (const SalomeApp_Module* theModule,
                                             const Handle(SALOME_InteractiveObject)& theIO,
-                                           bool theGP)
+                                            bool theGP)
   {
     std::vector<VISU::Prs3d_i*> aList;
     if (!theIO.IsNull() && theIO->hasEntry()) {
@@ -1334,7 +1169,7 @@ namespace VISU
 
   std::vector<VISU::Prs3d_i*> GetPrs3dList (const SalomeApp_Module* theModule,
                                             _PTR(SObject) theObject,
-                                           bool theGP)
+                                            bool theGP)
   {
     std::vector<VISU::Prs3d_i*> aList; int k = 0;
     if (!theObject)
@@ -1348,9 +1183,9 @@ namespace VISU
       if (!CORBA::is_nil(aVisuObj)) {
         VISU::VISUType aType = aVisuObj->GetType();
         switch (aType) {
-       case VISU::TGAUSSPOINTS:
-         if ( !theGP ) break;
-       case VISU::TSCALARMAP:
+        case VISU::TGAUSSPOINTS:
+          if ( !theGP ) break;
+        case VISU::TSCALARMAP:
         case VISU::TISOSURFACES:
         case VISU::TDEFORMEDSHAPE:
         case VISU::TCUTPLANES:
@@ -1359,9 +1194,9 @@ namespace VISU
         case VISU::TVECTORS:
         case VISU::TSTREAMLINES:
         case VISU::TPLOT3D:
-       case VISU::TSCALARMAPONDEFORMEDSHAPE:
-       case VISU::TDEFORMEDSHAPEANDSCALARMAP:
-       case VISU::TMESH:
+        case VISU::TSCALARMAPONDEFORMEDSHAPE:
+        case VISU::TDEFORMEDSHAPEANDSCALARMAP:
+        case VISU::TMESH:
           {
             PortableServer::ServantBase_var aServant = VISU::GetServant(aCORBAObject);
             if (aServant.in()) {
@@ -1392,47 +1227,60 @@ namespace VISU
             }
           }
           break;
+        case VISU::TCOLOREDPRS3DHOLDER:
+          {
+            PortableServer::ServantBase_var aServant = VISU::GetServant(aCORBAObject);
+            if (aServant.in()) {
+              VISU::ColoredPrs3dHolder_i* aPrsHolderObject = dynamic_cast<VISU::ColoredPrs3dHolder_i*>(aServant.in());
+              if( aPrsHolderObject ) {
+                VISU::Prs3d_i* aPrsObject = aPrsHolderObject->GetPrs3dDevice();
+                aList.resize(k+1);
+                aList[k] = aPrsObject;
+                k++;
+              }
+            }
+          }
         }
       }
     } else {
       VISU::VISUType aType = VISU::Storable::SObject2Type(theObject);
       switch (aType) {
       case VISU::TFIELD: {
-       _PTR(ChildIterator) anIter = aCStudy->NewChildIterator(theObject);
-       _PTR(SObject) aTimeStamp;
-       anIter->Next(); // First is reference on support
-       for (; anIter->More(); anIter->Next()) {
-         aTimeStamp = anIter->Value();
-         if (!aTimeStamp) continue;
-         std::vector<VISU::Prs3d_i*> aSubList = GetPrs3dList(theModule, aTimeStamp);
-         if (!aSubList.empty()) {
-           int n = aSubList.size();
-           aList.resize(k+n);
-           for (int i = 0; i < n; i++) {
-             aList[k] = aSubList[i];
-             k++;
-           }
-         }
-       }
-       break;
+        _PTR(ChildIterator) anIter = aCStudy->NewChildIterator(theObject);
+        _PTR(SObject) aTimeStamp;
+        anIter->Next(); // First is reference on support
+        for (; anIter->More(); anIter->Next()) {
+          aTimeStamp = anIter->Value();
+          if (!aTimeStamp) continue;
+          std::vector<VISU::Prs3d_i*> aSubList = GetPrs3dList(theModule, aTimeStamp);
+          if (!aSubList.empty()) {
+            int n = aSubList.size();
+            aList.resize(k+n);
+            for (int i = 0; i < n; i++) {
+              aList[k] = aSubList[i];
+              k++;
+            }
+          }
+        }
+        break;
       }
       case VISU::TTIMESTAMP: {
-       _PTR(ChildIterator) anIter = aCStudy->NewChildIterator(theObject);
-       _PTR(SObject) aPrs;
-       for (; anIter->More(); anIter->Next()) {
-         aPrs = anIter->Value();
-         if (!aPrs) continue;
-         std::vector<VISU::Prs3d_i*> aSubList = GetPrs3dList(theModule, aPrs);
-         if (!aSubList.empty()) {
-           int n = aSubList.size();
-           aList.resize(k+n);
-           for (int i = 0; i < n; i++) {
-             aList[k] = aSubList[i];
-             k++;
-           }
-         }
-       }
-       break;
+        _PTR(ChildIterator) anIter = aCStudy->NewChildIterator(theObject);
+        _PTR(SObject) aPrs;
+        for (; anIter->More(); anIter->Next()) {
+          aPrs = anIter->Value();
+          if (!aPrs) continue;
+          std::vector<VISU::Prs3d_i*> aSubList = GetPrs3dList(theModule, aPrs);
+          if (!aSubList.empty()) {
+            int n = aSubList.size();
+            aList.resize(k+n);
+            for (int i = 0; i < n; i++) {
+              aList[k] = aSubList[i];
+              k++;
+            }
+          }
+        }
+        break;
       }}
     }
     return aList;
@@ -1448,7 +1296,7 @@ namespace VISU
     if (aViewToPrsIter != aMap.end()) {
       TSetPrs3d::const_iterator aPrsIter = (aViewToPrsIter->second).begin();
       for (; aPrsIter != (aViewToPrsIter->second).end(); aPrsIter++) {
-       aIndexes.insert((*aPrsIter).second);
+        aIndexes.insert((*aPrsIter).second);
       }
     }
     std::set<int>::const_iterator aIter = aIndexes.begin();
@@ -1477,27 +1325,11 @@ namespace VISU
     TSetPrs3d::iterator aIter = aMap[theViewWindow].begin();
     for (; aIter != aMap[theViewWindow].end(); aIter++)
       if ((*aIter).first == thePrs3d) {
-       aMap[theViewWindow].erase(*aIter);
-       return;
+        aMap[theViewWindow].erase(*aIter);
+        return;
       }
   }
   //------------------------------------------------------------
-  void initSpinBox( QSpinBox* spinBox, 
-                   int min,  int max, int step )
-  {
-    spinBox->setRange( min, max );
-    spinBox->setSingleStep( step );
-  }
-  //------------------------------------------------------------
-  void initSpinBox( QDoubleSpinBox* spinBox, 
-                   double min,  double max, 
-                   double step, int decimals )
-  {
-    spinBox->setRange( min, max );
-    spinBox->setSingleStep( step );
-    spinBox->setDecimals( decimals );
-  }
-  //------------------------------------------------------------
   bool getClippingPlanesFolder(_PTR(Study) theStudy, _PTR(SObject)& theSObject)
   {
     _PTR(SComponent) aVisuSO = theStudy->FindComponent("VISU");
@@ -1515,4 +1347,39 @@ namespace VISU
     theSObject = aFolder;
     return true;
   }
+
+  //------------------------------------------------------------
+  void initSpinBox( SalomeApp_IntSpinBox* sb, 
+                    const int bottom, 
+                    const int top, 
+                    const int step )
+  {
+    sb->setAcceptNames( false );
+    sb->setRange( bottom, top );
+    sb->setSingleStep( step );
+  }
+  
+  //------------------------------------------------------------
+  void initSpinBox( SalomeApp_DoubleSpinBox* sb, 
+                    const double& bottom, 
+                    const double& top, 
+                    const double& step, 
+                    const char* quantity )
+  {
+    // Obtain precision from preferences
+    SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+    int precision = resMgr->integerValue( "VISU", quantity, 3 );
+  
+    sb->setPrecision   ( precision ); 
+    sb->setDecimals    ( qAbs(precision) );
+    sb->setRange       ( bottom, top );
+    sb->setSingleStep  ( step );
+    sb->setDefaultValue( bottom );
+    sb->setAcceptNames ( false );
+  
+    // Add a hint for the user saying how to tune precision
+    QString userPropName = QObject::tr( QString( "VISU_PREF_%1" ).arg( quantity ).toLatin1().constData() );
+    sb->setProperty( "validity_tune_hint", 
+                     QVariant( QObject::tr( "VISU_PRECISION_HINT" ).arg( userPropName ) ) );  
+  }
 }