Salome HOME
Fix problems with compilation
[modules/visu.git] / src / VISUGUI / VisuGUI_Tools.cxx
index 2156d7ddb1c9705d8b03800cc42e956813ae83a8..43991c9bcb8e6acfb098e1a0112ee8dcad7dc013 100644 (file)
@@ -1,31 +1,30 @@
-//  VISU VISUGUI : GUI of VISU component
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-//  Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
-//  This library is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU Lesser General Public
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
 //
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
 //
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
 // 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
 //  Module : VISU
 
-
 #include "VisuGUI_Tools.h"
 #include "VisuGUI_ViewTools.h"
 #include "VisuGUI_Prs3dTools.h"
 
 #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"
 #include "VISU_Table_i.hh"
-#include "VISU_Mesh_i.hh"
+//#include "VISU_Mesh_i.hh"
 #include "VISU_ViewManager_i.hh"
 
 #include "VISU_Actor.h"
 #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"
 
-#include "OB_Browser.h"
+//TODO
+//#include "OB_Browser.h"
 
 #include "SALOME_ListIO.hxx"
 #include "SALOME_ListIteratorOfListIO.hxx"
 
 #include "SUIT_Session.h"
 #include "SUIT_MessageBox.h"
+#include "SUIT_Desktop.h"
+#include "SUIT_ViewWindow.h"
+#include "SUIT_ResourceMgr.h"
+
+#include "CAM_DataModel.h"
 
 #include <vtkRenderer.h>
 #include <vtkActorCollection.h>
 
-#include <qstring.h>
+#include <QString>
+#include <QSpinBox>
+#include <QDoubleSpinBox>
+#include <QVariant>
 
+using namespace std;
 
 //=============================================================================
 namespace VISU
@@ -80,51 +94,48 @@ namespace VISU
   SUIT_Desktop*
   GetDesktop(const CAM_Module* theModule)
   {
-    return theModule->application()->desktop();
+    return theModule && theModule->application() ? theModule->application()->desktop() : 0;
   }
 
   //------------------------------------------------------------
   LightApp_SelectionMgr*
   GetSelectionMgr(const SalomeApp_Module* theModule)
   {
-    return theModule->getApp()->selectionMgr();
+    return theModule && theModule->getApp() ? theModule->getApp()->selectionMgr() : 0;
   }
 
   //------------------------------------------------------------
   SalomeApp_Study*
   GetAppStudy(const CAM_Module* theModule)
   {
-    return
-      dynamic_cast<SalomeApp_Study*>(theModule->application()->activeStudy());
+    return theModule && theModule->application() ?
+      dynamic_cast<SalomeApp_Study*>(theModule->application()->activeStudy()) : 0;
   }
 
   //------------------------------------------------------------
   _PTR(Study)
   GetCStudy(const SalomeApp_Study* theStudy)
   {
-    return theStudy->studyDS();
+    return theStudy ? theStudy->studyDS() : _PTR(Study)();
   }
 
   //------------------------------------------------------------
   bool
   IsStudyLocked( _PTR(Study) theStudy )
   {
-    if( theStudy )
-      return theStudy->GetProperties()->IsLocked();
-    return true;
+    return theStudy ? theStudy->GetProperties()->IsLocked() : true;
   }
 
   //------------------------------------------------------------
   bool
   CheckLock( _PTR(Study) theStudy,
-            QWidget* theWidget )
+             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;
+      SUIT_MessageBox::warning(theWidget,
+                               QObject::tr("WRN_VISU_WARNING"),
+                               QObject::tr("WRN_STUDY_LOCKED") );
+        return true;
     }
     return false;
   }
@@ -140,27 +151,27 @@ 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);
     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);
-         }
-       }
+    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);
+          }
+        }
       }
-      ++aDataObjectIter;
+      aDataObjectIter++;
     }
     return NULL;
   }
@@ -168,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();
@@ -183,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)
@@ -201,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;
   }
@@ -212,21 +223,23 @@ 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");
+      Engines::EngineComponent_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)
-      throw std::runtime_error(QObject::tr("ERR_CANT_FIND_VISU_COMPONENT").latin1());
+
+    if(aGen)
+      aGen->SetCurrentStudy(GetDSStudy(GetCStudy(GetAppStudy(theModule))));
+    else
+      throw std::runtime_error(QObject::tr("ERR_CANT_FIND_VISU_COMPONENT").toLatin1().data());
     return aGen;
   }
 
+#ifdef WITH_MEDGEN
   //------------------------------------------------------------
   SALOME_MED::MED_Gen_var
   GetMEDEngine()
@@ -234,14 +247,14 @@ namespace VISU
     static SALOME_MED::MED_Gen_var aGen;
     if(CORBA::is_nil(aGen)){
       SALOME_LifeCycleCORBA aLCC(SalomeApp_Application::namingService());
-      Engines::Component_var aComponent = aLCC.FindOrLoad_Component("FactoryServer","MED");
+      Engines::EngineComponent_var aComponent = aLCC.FindOrLoad_Component("FactoryServer","MED");
       aGen = SALOME_MED::MED_Gen::_narrow(aComponent);
     }
     if(CORBA::is_nil(aGen))
-      throw std::runtime_error(QObject::tr("ERR_CANT_FIND_MED_COMPONENT").latin1());
+      throw std::runtime_error(QObject::tr("ERR_CANT_FIND_MED_COMPONENT").toLatin1().data());
     return aGen;
   }
-
+#endif // WITH_MEDGEN
 
   //----------------------------------------------------------------------------
   // Selection
@@ -251,23 +264,25 @@ namespace VISU
     TSelectionInfo aSelectionInfo;
     const SalomeApp_Study* aStudy = GetAppStudy(theModule);
     LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(theModule);
-    SALOME_ListIO aListIO;
-    aSelectionMgr->selectedObjects(aListIO);
-    SALOME_ListIteratorOfListIO anIter(aListIO);
-    while(anIter.More())
-    {
-      Handle(SALOME_InteractiveObject) anIO = anIter.Value();
-      if(anIO->hasEntry())
+    if ( aStudy && aSelectionMgr ) {
+      SALOME_ListIO aListIO;
+      aSelectionMgr->selectedObjects(aListIO);
+      SALOME_ListIteratorOfListIO anIter(aListIO);
+      while(anIter.More())
       {
-        TObjectInfo anObjectInfo = GetObjectByEntry(aStudy, anIO->getEntry());
-       if(anObjectInfo.mySObject){
-         TSelectionItem aSelectionItem;
-         aSelectionItem.myObjectInfo = anObjectInfo;
-         aSelectionItem.myIO = anIO;
-         aSelectionInfo.push_back(aSelectionItem);
-       }
+        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
       }
-      anIter.Next(); // MULTIPR fixed
     }
     return aSelectionInfo;
   }
@@ -275,7 +290,7 @@ namespace VISU
   //----------------------------------------------------------------------------
   TObjectInfo
   GetObjectByEntry(const SalomeApp_Study* theStudy,
-                  const std::string& theEntry)
+                   const std::string& theEntry)
   {
     TObjectInfo anObjectInfo;
     if(!theStudy || theEntry == "")
@@ -286,9 +301,9 @@ 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;
   }
 
@@ -296,7 +311,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;
@@ -321,27 +336,27 @@ 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())
       return false;
-  
+
     VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
     thePrs3d = GetPrs3dFromBase(aSelectionItem.myObjectInfo.myBase);
     if(!thePrs3d)
       return false;
-  
+
     theViewWindow = GetActiveViewWindow<SVTK_ViewWindow>(theModule);
     if(!theViewWindow)
       return false;
-  
+
     thenActor = FindActor(theViewWindow, thePrs3d);
     if(!thenActor)
       return false;
-    
+
     return true;
   }
 
@@ -360,7 +375,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;
@@ -369,12 +384,94 @@ 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);
   }
 
+  /*!
+   * \brief Check, if the object can be deleted
+   *
+   * \param theEntry - entry of the object to check
+   * \param theModule - is used to access Study and VISU_Gen
+   * \retval bool - returns TRUE if the object is removable
+   */
+  bool
+  IsRemovable (const std::string theEntry,
+               const SalomeApp_Module* theModule)
+  {
+    // asv : if selected object is a Save Point object selected in object browser - return false
+    if ( QString( theEntry.c_str() ).startsWith( QObject::tr( "SAVE_POINT_DEF_NAME" ) ) )
+      return false;
+
+    _PTR(Study) aStudy = GetCStudy(GetAppStudy(theModule));
+
+    _PTR(SObject) aSObject = aStudy->FindObjectID(theEntry);
+    VISU::Storable::TRestoringMap pMap;
+    if (aSObject) {
+      CORBA::Object_var aCORBAObject = VISU::ClientSObjectToObject(aSObject);
+      if (!CORBA::is_nil(aCORBAObject)) {
+        VISU::RemovableObject_var aRemovableObj = VISU::RemovableObject::_narrow(aCORBAObject);
+        if (CORBA::is_nil(aRemovableObj)) {
+          // Not removable CORBA object
+          return false;
+        }
+      } else {
+        // Can be removed, if lays directly under VISU
+        // (first sub-level) or is a child of such an object
+        string aNAME, aVisuNAME = GetVisuGen(theModule)->ComponentDataType();
+        _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;
+        }
+
+        bool isUnderVISU = false;
+        _PTR(SObject) aFatherSObject = aSObject->GetFather();
+        if (aFatherSObject->FindAttribute(anAttr, "AttributeName")) {
+          // mkr : 24.11.2006 : use AttributeName and module title for correct "Delete"
+          //                    popup item displaying in object browser popup
+          _PTR(AttributeName) aComment (anAttr);
+          aNAME = aComment->Value();
+          QString aVisuTITLE = theModule->getApp()->moduleTitle(aVisuNAME.c_str());
+          if (!aVisuTITLE.compare(aNAME.c_str())) {
+            isUnderVISU = true;
+          }
+        }
+        if (!isUnderVISU) {
+          // Not directly under VISU component, check father
+          aCORBAObject = VISU::ClientSObjectToObject(aFatherSObject);
+          if (!CORBA::is_nil(aCORBAObject)) {
+            // Father has IOR
+            return false;
+          }
+
+          isUnderVISU = false;
+          aFatherSObject = aFatherSObject->GetFather();
+          if (aFatherSObject->FindAttribute(anAttr, "AttributeString")) {
+            _PTR(AttributeString) aComment (anAttr);
+            aNAME = aComment->Value();
+            if (aNAME == aVisuNAME) {
+              isUnderVISU = true;
+            }
+          }
+          if (!isUnderVISU) {
+            // Father is not directly under VISU component
+            return false;
+          }
+        }
+      }
+    }
+    return true;
+  }
+
   /*!
    * \brief Check, if "Delete" popup-menu can be put on current selection
    *
@@ -398,64 +495,8 @@ namespace VISU
     for (; anIter.More(); anIter.Next()) {
       Handle(SALOME_InteractiveObject) anIO = anIter.Value();
       if (anIO->hasEntry()) {
-
-       // asv : if selected object is a Save Point object selected in object browser - return false
-       if ( QString( anIO->getEntry() ).startsWith( QObject::tr( "SAVE_POINT_DEF_NAME" ) ) )
-         return false;
-
-        _PTR(SObject) aSObject = aStudy->FindObjectID(anIO->getEntry());
-        VISU::Storable::TRestoringMap pMap;
-        if (aSObject) {
-          CORBA::Object_var aCORBAObject = VISU::ClientSObjectToObject(aSObject);
-          if (!CORBA::is_nil(aCORBAObject)) {
-            VISU::RemovableObject_var aRemovableObj = VISU::RemovableObject::_narrow(aCORBAObject);
-            if (CORBA::is_nil(aRemovableObj)) {
-              // Not removable CORBA object
-              return false;
-            }
-          } else {
-            // Can be removed, if lays directly under VISU
-            // (first sub-level) or is a child of such an object
-            string aNAME, aVisuNAME = GetVisuGen(theModule)->ComponentDataType();
-            _PTR(GenericAttribute) anAttr;
-            _PTR(AttributeString) aComment;
-
-            bool isUnderVISU = false;
-            _PTR(SObject) aFatherSObject = aSObject->GetFather();
-            if (aFatherSObject->FindAttribute(anAttr, "AttributeName")) {
-             // mkr : 24.11.2006 : use AttributeName and module title for correct "Delete"
-             //                    popup item displaying in object browser popup
-              _PTR(AttributeName) aComment (anAttr);
-              aNAME = aComment->Value();
-             QString aVisuTITLE = theModule->getApp()->moduleTitle(QString(aVisuNAME));
-              if (!aVisuTITLE.compare(QString(aNAME))) {
-                isUnderVISU = true;
-              }
-            }
-            if (!isUnderVISU) {
-              // Not directly under VISU component, check father
-              aCORBAObject = VISU::ClientSObjectToObject(aFatherSObject);
-              if (!CORBA::is_nil(aCORBAObject)) {
-                // Father has IOR
-                return false;
-              }
-
-              isUnderVISU = false;
-              aFatherSObject = aFatherSObject->GetFather();
-              if (aFatherSObject->FindAttribute(anAttr, "AttributeString")) {
-                _PTR(AttributeString) aComment (anAttr);
-                aNAME = aComment->Value();
-                if (aNAME == aVisuNAME) {
-                  isUnderVISU = true;
-                }
-              }
-              if (!isUnderVISU) {
-                // Father is not directly under VISU component
-               return false;
-              }
-            }
-          }
-        }
+        if (!IsRemovable(anIO->getEntry(), theModule))
+          return false;
       }
     }
     return true;
@@ -464,8 +505,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()) {
@@ -487,7 +528,7 @@ namespace VISU
       // Remove aSObject together with all its sub-objects
       VISU::RemoveFromStudy(theSObject,
                             false,  // remove not only IOR attribute, but Object With Children
-                            false); // not Destroy() sub-objects
+                            false); // not UnRegister() sub-objects
     }
   }
 
@@ -508,20 +549,19 @@ 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;
+          }
+        }
       }
-    } 
-      
+    }
+
     thePrs->RemoveFromStudy();
-      
   }
 
   //------------------------------------------------------------
@@ -534,41 +574,113 @@ namespace VISU
     if(aSelectionInfo.empty())
       return;
 
+    VISU::Prs3d_i* aPrs3d;
+    VISU::PointMap3d_i* aTable;
+    VISU_Actor* anActor;
+    VISU_ActorBase* anActorBase;
+
     TSelectionItem aSelectionItem = aSelectionInfo.front();
-    VISU::Prs3d_i* aPrs3d = GetPrs3dFromBase(aSelectionItem.myObjectInfo.myBase);
-    if(!aPrs3d)
-      return;
+    aPrs3d = GetPrs3dFromBase(aSelectionItem.myObjectInfo.myBase);
+    if(!aPrs3d) {
+      aTable = dynamic_cast<VISU::PointMap3d_i*>(aSelectionItem.myObjectInfo.myBase);
+      if(!aTable)
+        return;
+    }
 
     SVTK_ViewWindow* aViewWindow = GetActiveViewWindow<SVTK_ViewWindow>(theModule);
     if(!aViewWindow)
       return;
 
-    VISU_Actor* anActor = FindActor(aViewWindow, aPrs3d);
-    if(!anActor)
-      return;
+    if (aPrs3d) {
+      anActor = FindActor(aViewWindow, aPrs3d);
+      if(!anActor)
+        return;
+    } else {
+      anActorBase = VISU::FindActorBase(aViewWindow, aTable);
+      if(!anActorBase)
+        return;
+    }
 
     switch (theType) {
     case VISU::SHRINK:
-      if (anActor->IsShrunk())
-       anActor->UnShrink();
-      else
-       anActor->SetShrink();
+      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);
+        }
+      } else if (aTable) {
+        if (anActorBase->IsShrunk())
+          anActorBase->UnShrink();
+        else
+          anActorBase->SetShrink();
+      }
       break;
     default:
-      if (VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d)) {
-       aMesh->SetPresentationType(theType);
-       RecreateActor(theModule, aMesh);
-      } else {
-       anActor->SetRepresentation(theType);
+      if (aPrs3d) {
+        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);
       }
     }
     aViewWindow->Repaint();
   }
 
+
+  void ChangeQuadratic2DRepresentation (const SalomeApp_Module* theModule,
+                                        VISU::Quadratic2DPresentationType  theType)
+  {
+    TSelectionInfo aSelectionInfo = GetSelectedObjects(theModule);
+    if(aSelectionInfo.empty())
+      return;
+
+    TSelectionItem aSelectionItem = aSelectionInfo.front();
+
+    VISU::Prs3d_i* aPrs3d = GetPrs3dFromBase(aSelectionItem.myObjectInfo.myBase);
+
+    SVTK_ViewWindow* aViewWindow = GetActiveViewWindow<SVTK_ViewWindow>(theModule);
+
+    if(!aPrs3d || !aViewWindow)
+      return;
+
+    VISU_Actor *anActor = FindActor(aViewWindow, aPrs3d);
+    if(!anActor)
+      return;
+
+    if (VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d)) {
+      aMesh->SetQuadratic2DPresentationType(theType);
+      RecreateActor(theModule, aMesh);
+    } else {
+      switch(theType){
+      case VISU::LINES:
+        anActor->SetQuadratic2DRepresentation(VISU_Actor::eLines);
+        break;
+      case VISU::ARCS:
+        anActor->SetQuadratic2DRepresentation(VISU_Actor::eArcs);
+        break;
+      default:
+        break;
+      }
+    }
+  }
+
   //------------------------------------------------------------
   void
   SetShading ( const SalomeApp_Module* theModule,
-             bool theOn )
+              bool theOn )
   {
     TSelectionInfo aSelectionInfo = GetSelectedObjects(theModule);
     if(aSelectionInfo.empty())
@@ -599,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()){
@@ -608,19 +720,18 @@ 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::warn1(GetDesktop(theModule),
-                           QObject::tr("WRN_VISU"),
-                           QObject::tr("WRN_NO_AVAILABLE_DATA"),
-                           QObject::tr("BUT_OK") );
+    SUIT_MessageBox::warning(GetDesktop(theModule),
+                             QObject::tr("WRN_VISU"),
+                             QObject::tr("WRN_NO_AVAILABLE_DATA") );
     return false;
   }
 
@@ -632,7 +743,7 @@ namespace VISU
   {
     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;
@@ -667,23 +778,36 @@ namespace VISU
                     VISU::Prs3d_i* thePrs,
                     SVTK_ViewWindow* theViewWindow)
   {
-    VISU_Actor* aActor = NULL;
+    VISU_Actor* anActor = NULL;
     if (!thePrs || !theViewWindow)
-      return aActor;
+      return anActor;
+
+    SalomeApp_Application *anApp = dynamic_cast<SalomeApp_Application*>(theModule->application());
+    if(!anApp)
+      return anActor;
+    
+    SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(anApp->activeStudy());
 
-    QApplication::setOverrideCursor( Qt::waitCursor );
+    if(!aStudy)
+      return anActor;
+    
+
+    QApplication::setOverrideCursor( Qt::WaitCursor );
     try {
-      if ((aActor = thePrs->CreateActor()))
-        theViewWindow->AddActor(aActor);
+      if ((anActor = thePrs->CreateActor())) {
+        theViewWindow->AddActor(anActor);
+
+       if(anActor->hasIO() && anActor->getIO()->hasEntry())
+         aStudy->setVisibilityState(anActor->getIO()->getEntry(), Qtx::ShownState);
+      }
     } catch(std::exception& exc) {
-      SUIT_MessageBox::warn1
+      SUIT_MessageBox::warning
         (GetDesktop(theModule), QObject::tr("WRN_VISU"),
-         QObject::tr("ERR_CANT_CREATE_ACTOR") + ": " + QObject::tr(exc.what()),
-         QObject::tr("BUT_OK"));
+         QObject::tr("ERR_CANT_CREATE_ACTOR") + ": " + QObject::tr(exc.what()) );
     }
     QApplication::restoreOverrideCursor();
 
-    return aActor;
+    return anActor;
   }
 
   //------------------------------------------------------------
@@ -695,9 +819,10 @@ namespace VISU
     if (SalomeApp_Application* anApp = theModule->getApp()) {
       ViewManagerList aViewManagerList;
       anApp->viewManagers(SVTK_Viewer::Type(),aViewManagerList);
-      QPtrListIterator<SUIT_ViewManager> anIter (aViewManagerList);
-      while (SUIT_ViewManager* aViewManager = anIter.current()) {
-        QPtrVector<SUIT_ViewWindow> aViews = aViewManager->getViews();
+      QList<SUIT_ViewManager*>::Iterator anIter = aViewManagerList.begin();
+      while ( anIter != aViewManagerList.end() )
+      {
+        QVector<SUIT_ViewWindow*> aViews = (*anIter)->getViews();
         for (int i = 0, iEnd = aViews.size(); i < iEnd; i++) {
           if (SUIT_ViewWindow* aViewWindow = aViews.at(i)) {
             if (SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(aViewWindow)) {
@@ -709,7 +834,7 @@ namespace VISU
             }
           }
         }
-        ++anIter;
+        anIter++;
       }
     }
   }
@@ -717,33 +842,43 @@ 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);
+    TObjectInfo anObjectInfo = GetObjectByEntry(theStudy, theEntry.toLatin1().data());
     VISU::Prs3d_i* aPrs3d = GetPrs3dFromBase(anObjectInfo.myBase);
     return FindActor(theViewWindow, aPrs3d);
   }
 
+  //------------------------------------------------------------
+  VISU_ActorBase*
+  FindActorBase(const SalomeApp_Study* theStudy,
+                SVTK_ViewWindow* theViewWindow,
+                const QString& theEntry)
+  {
+    TObjectInfo anObjectInfo = GetObjectByEntry(theStudy, theEntry.toLatin1().constData());
+    VISU::PointMap3d_i* aTable = dynamic_cast<VISU::PointMap3d_i*>(anObjectInfo.myBase);
+    return FindActorBase(theViewWindow, aTable);
+  }
+
   //------------------------------------------------------------
   void
   RecreateActor (const SalomeApp_Module* theModule,
                  VISU::Prs3d_i* thePrs)
   {
-    QApplication::setOverrideCursor(Qt::waitCursor);
+    QApplication::setOverrideCursor(Qt::WaitCursor);
 
-    SALOMEDS::SObject_var aSObject = thePrs->GetSObject();
-    CORBA::String_var anEntry = aSObject->GetID();
+    /*    SALOMEDS::SObject_var aSObject = thePrs->GetSObject();
+          CORBA::String_var anEntry = aSObject->GetID();*/
 
     try {
       thePrs->UpdateActors();
     } catch (std::runtime_error& exc) {
       INFOS(exc.what());
       QApplication::restoreOverrideCursor();
-      SUIT_MessageBox::warn1
+      SUIT_MessageBox::warning
         (GetDesktop(theModule), QObject::tr("WRN_VISU"),
-         QObject::tr("ERR_CANT_BUILD_PRESENTATION") + ": " + QObject::tr(exc.what()),
-         QObject::tr("BUT_OK"));
+         QObject::tr("ERR_CANT_BUILD_PRESENTATION") + ": " + QObject::tr(exc.what()) );
 
       thePrs->RemoveActors();
       return;
@@ -752,23 +887,23 @@ namespace VISU
   }
 
   //------------------------------------------------------------
-  static 
   bool
   ComputeVisiblePropBounds(SVTK_ViewWindow* theViewWindow,
-                          vtkFloatingPointType allBounds[6], 
-                          const char* theActorClassName = "VISU_Actor")
+                           double allBounds[6],
+                           const char* theActorClassName)
   {
     vtkRenderer *aRen = theViewWindow->getRenderer();
-    vtkActorCollection *anActColl = aRen->GetActors(); 
+    VTK::ActorCollectionCopy aCopy(aRen->GetActors());
+    vtkActorCollection *anActColl = aCopy.GetActors();
     vtkProp *prop;
-    vtkFloatingPointType *bounds;
+    double *bounds;
     int somethingVisible = false;
 
     allBounds[0] = allBounds[2] = allBounds[4] = VTK_LARGE_FLOAT;
     allBounds[1] = allBounds[3] = allBounds[5] = -VTK_LARGE_FLOAT;
     // loop through all props
     for (anActColl->InitTraversal(); (prop = anActColl->GetNextProp()); ) {
-      // if it's invisible, or has no geometry, we can skip the rest 
+      // if it's invisible, or has no geometry, we can skip the rest
       if (prop->GetVisibility() && prop->IsA(theActorClassName)) {
         bounds = prop->GetBounds();
         // make sure we haven't got bogus bounds
@@ -777,13 +912,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
       }
     }
@@ -793,14 +928,14 @@ namespace VISU
   //------------------------------------------------------------
   void SetFitAll(SVTK_ViewWindow* theViewWindow)
   {
-    static vtkFloatingPointType PRECISION = 0.000001;
-    static vtkFloatingPointType DEVIATION = 600;
-    vtkFloatingPointType XYZ_Bnd[6];
+    static double PRECISION = 0.000001;
+    static double DEVIATION = 600;
+    double XYZ_Bnd[6];
     if (!ComputeVisiblePropBounds(theViewWindow, XYZ_Bnd)) return;
 
-    vtkFloatingPointType absX = XYZ_Bnd[1] - XYZ_Bnd[0];
-    vtkFloatingPointType absY = XYZ_Bnd[3] - XYZ_Bnd[2];
-    vtkFloatingPointType absZ = XYZ_Bnd[5] - XYZ_Bnd[4];
+    double absX = XYZ_Bnd[1] - XYZ_Bnd[0];
+    double absY = XYZ_Bnd[3] - XYZ_Bnd[2];
+    double absZ = XYZ_Bnd[5] - XYZ_Bnd[4];
 
     enum CameraOrient {e3D, eFront, eLeft, eTop};
     CameraOrient aCameraOrient = e3D;
@@ -811,9 +946,9 @@ namespace VISU
         if (absZ <= PRECISION) aCameraOrient = eTop;
         else {
           // all the three dimensions exceeds precision
-          vtkFloatingPointType dev_abs_XY = absX / absY;
-          vtkFloatingPointType dev_abs_YZ = absY / absZ;
-          vtkFloatingPointType dev_abs_XZ = absX / absZ;
+          double dev_abs_XY = absX / absY;
+          double dev_abs_YZ = absY / absZ;
+          double dev_abs_XZ = absX / absZ;
           if (dev_abs_XY >= DEVIATION || 1./dev_abs_YZ >= DEVIATION)
             aCameraOrient = eLeft;
           else {
@@ -852,66 +987,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() );
-        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_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
-          plotCurve->setMarker( (Plot2d_Curve::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;
@@ -919,41 +1004,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.remove( plotCurve );
-            }
-          }
-        }
-      }
-      aPlot->Repaint();
-    }
+    // implementation moved to VISU_I package (see VISU_Tools.h)
+    VISU::PlotTable( aStudy, aPlot, table, theDisplaying );
   }
 
   //------------------------------------------------------------
@@ -969,55 +1021,19 @@ 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;
-    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();
-    ViewManagerList pvm_list;
-    theModule->getApp()->viewManagers( SPlot2d_Viewer::Type(), pvm_list );
-    for( SUIT_ViewManager* mgr = pvm_list.first(); mgr; mgr = pvm_list.next() ){
-      Plot2d_ViewManager* pvm = dynamic_cast<Plot2d_ViewManager*>( mgr );
-      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.at(i)))
-               if(plotCurve->hasIO() && (plotCurve->getIO()->getEntry() == anEntry))
-                 aPlot->eraseCurve(clist.at(i));
-           }
-         }
-       }
-      }
-    }
+    // implementation moved to VISU_I package (see VISU_Tools.h)
+    VISU::PlotRemoveCurve( theModule->getApp(), pCrv );
   }
-  
+
   //------------------------------------------------------------
   void
   PlotContainer(const SalomeApp_Module* theModule,
@@ -1031,28 +1047,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.remove( plotCurve );
-          }
-        }
-      }
-    }
-    aPlot->Repaint();
-    aPlot->fitAll();
+    // implementation moved to VISU_I package (see VISU_Tools.h)
+    VISU::PlotContainer( aPlot, container, theDisplaying );
   }
 
   //------------------------------------------------------------
@@ -1060,44 +1056,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();
-         _PTR(Study) aStudy = theTableSO->GetStudy();
-         _PTR(SObject) aContainerSO = aStudy->FindObjectID(anEntry.latin1());
-         _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
-
-  void
+  VISU::Mesh_i*
   CreateMesh(VisuGUI* theModule,
-            const Handle(SALOME_InteractiveObject)& theIO,
-            SVTK_ViewWindow* theViewWindow)
-  {  
-       _PTR(Study) aStudy = GetCStudy(GetAppStudy(theModule));
+             const Handle(SALOME_InteractiveObject)& theIO,
+             SVTK_ViewWindow* theViewWindow)
+  {
+        _PTR(Study) aStudy = GetCStudy(GetAppStudy(theModule));
     //if (CheckLock(aStudy))
     //  return;
 
@@ -1107,15 +1086,15 @@ namespace VISU
     VISU::Result_var aResult;
     VISU::Result_i* pResult = CheckResult(theModule, aResultSObj, aResult);
     if (pResult == NULL)
-      return;
+      return NULL;
 
     Storable::TRestoringMap aMap = Storable::GetStorableMap(aResultSObj);
     if (aMap.empty())
-      return;
+      return NULL;
 
     CORBA::Object_var aMesh;
-    string aComment = Storable::FindValue(aMap,"myComment").latin1();
-    string aMeshName = Storable::FindValue(aMap,"myMeshName").latin1();
+    string aComment = Storable::FindValue(aMap,"myComment").toLatin1().data();
+    string aMeshName = Storable::FindValue(aMap,"myMeshName").toLatin1().data();
 #ifdef CHECKTIME
     Utils_Timer timer;
     timer.Start();
@@ -1126,12 +1105,12 @@ namespace VISU
         aMesh = GetVisuGen(theModule)->MeshOnEntity(aResult,aMeshName.c_str(),anEntity);
     } else if (aComment == "FAMILY") {
       VISU::Entity anEntity = (VISU::Entity)Storable::FindValue(aMap,"myEntityId").toInt();
-      string aFamilyName = Storable::FindValue(aMap,"myName").latin1();
+      string aFamilyName = Storable::FindValue(aMap,"myName").toLatin1().data();
       if (VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),anEntity,aFamilyName.c_str()))
         aMesh = GetVisuGen(theModule)->FamilyMeshOnEntity
           (aResult,aMeshName.c_str(),anEntity,aFamilyName.c_str());
     } else if (aComment == "GROUP") {
-      string aGroupName = Storable::FindValue(aMap,"myName").latin1();
+      string aGroupName = Storable::FindValue(aMap,"myName").toLatin1().data();
       if (VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),aGroupName.c_str()))
         aMesh = GetVisuGen(theModule)->GroupMesh(aResult,aMeshName.c_str(),aGroupName.c_str());
     }
@@ -1146,11 +1125,10 @@ namespace VISU
     if (!CORBA::is_nil(aMesh))
       pPresent = dynamic_cast<VISU::Mesh_i*>(VISU::GetServant(aMesh).in());
     if (pPresent == NULL) {
-      SUIT_MessageBox::warn1 (GetDesktop(theModule),
-                              QObject::tr("WRN_VISU"),
-                              QObject::tr("ERR_CANT_BUILD_PRESENTATION"),
-                              QObject::tr("BUT_OK"));
-      return;
+      SUIT_MessageBox::warning (GetDesktop(theModule),
+                                QObject::tr("WRN_VISU"),
+                                QObject::tr("ERR_CANT_BUILD_PRESENTATION") );
+      return NULL;
     }
 
     if (theViewWindow) {
@@ -1160,11 +1138,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);
-        SetFitAll(theViewWindow);
+        if(GetResourceMgr()->booleanValue("VISU","automatic_fit_all",false)){
+          SetFitAll(theViewWindow);
+        }
 #ifdef CHECKTIME
         timer.Stop();
         MESSAGE("VisuGUI::CreateMesh() - DISPLAY MESH");
@@ -1172,10 +1152,8 @@ namespace VISU
 #endif
       } 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::warning(GetDesktop(theModule), QObject::tr("WRN_VISU"),
+                                 QObject::tr("ERR_CANT_CREATE_ACTOR") + ": " + QObject::tr(exc.what()) );
       }
     }
 
@@ -1184,25 +1162,28 @@ namespace VISU
     theModule->application()->putInfo(QObject::tr("INF_DONE"));
     // Make "Save" button active
     theModule->getApp()->updateActions();
+    return pPresent;
   }
 
   // ========================================================================================
   // GetPrs3dList: find list of presentations for the given object
   // ========================================================================================
   std::vector<VISU::Prs3d_i*> GetPrs3dList (const SalomeApp_Module* theModule,
-                                            const Handle(SALOME_InteractiveObject)& theIO)
+                                            const Handle(SALOME_InteractiveObject)& theIO,
+                                            bool theGP)
   {
     std::vector<VISU::Prs3d_i*> aList;
     if (!theIO.IsNull() && theIO->hasEntry()) {
       _PTR(Study) aCStudy = GetCStudy(GetAppStudy(theModule));
       _PTR(SObject) aSObject = aCStudy->FindObjectID(theIO->getEntry());
-      aList = GetPrs3dList(theModule, aSObject);
+      aList = GetPrs3dList(theModule, aSObject, theGP);
     }
     return aList;
   }
 
   std::vector<VISU::Prs3d_i*> GetPrs3dList (const SalomeApp_Module* theModule,
-                                            _PTR(SObject) theObject)
+                                            _PTR(SObject) theObject,
+                                            bool theGP)
   {
     std::vector<VISU::Prs3d_i*> aList; int k = 0;
     if (!theObject)
@@ -1216,15 +1197,20 @@ namespace VISU
       if (!CORBA::is_nil(aVisuObj)) {
         VISU::VISUType aType = aVisuObj->GetType();
         switch (aType) {
-       case VISU::TSCALARMAP:
+        case VISU::TGAUSSPOINTS:
+          if ( !theGP ) break;
+        case VISU::TSCALARMAP:
         case VISU::TISOSURFACES:
         case VISU::TDEFORMEDSHAPE:
         case VISU::TCUTPLANES:
         case VISU::TCUTLINES:
+        case VISU::TCUTSEGMENT:
         case VISU::TVECTORS:
         case VISU::TSTREAMLINES:
         case VISU::TPLOT3D:
-       case VISU::TSCALARMAPONDEFORMEDSHAPE:
+        case VISU::TSCALARMAPONDEFORMEDSHAPE:
+        case VISU::TDEFORMEDSHAPEANDSCALARMAP:
+        case VISU::TMESH:
           {
             PortableServer::ServantBase_var aServant = VISU::GetServant(aCORBAObject);
             if (aServant.in()) {
@@ -1255,47 +1241,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;
@@ -1311,13 +1310,13 @@ 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();
     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; } 
+      if (aIter == aIndexes.end()) { minIndx = i; break; }
       else minIndx = i + 1;
     }
     return minIndx;
@@ -1340,9 +1339,61 @@ 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;
       }
   }
   //------------------------------------------------------------
+  bool getClippingPlanesFolder(_PTR(Study) theStudy, _PTR(SObject)& theSObject)
+  {
+    _PTR(SComponent) aVisuSO = theStudy->FindComponent("VISU");
+    if (!aVisuSO) return false;
+    _PTR(SObject) aFolder = theStudy->FindObject(CLIP_PLANES_FOLDER);
+    if (!aFolder) {
+      _PTR(StudyBuilder) aBuilder = theStudy->NewBuilder();
+      aFolder = aBuilder->NewObject(aVisuSO);
+
+      _PTR(GenericAttribute) anAttr;
+      anAttr = aBuilder->FindOrCreateAttribute(aFolder,"AttributeName");
+      _PTR(AttributeName) aName(anAttr);
+      aName->SetValue(CLIP_PLANES_FOLDER);
+    }
+    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 ) ) );
+  }
 }