Salome HOME
Update copyright information
[modules/visu.git] / src / VISUGUI / VisuGUI.cxx
index bd5497082d3736d18df5a6964ec67d6e0e6a9b6f..b90e7175a2ad9c1e48c332179c6cff7d24058ec0 100644 (file)
@@ -1,23 +1,23 @@
-//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2012  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
+// 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
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
 //  VISU VISUGUI : GUI of VISU component
@@ -26,6 +26,9 @@
 //  Module : VISU
 
 #include <Standard_math.hxx>  // E.A. must be included before Python.h to fix compilation on windows
+#ifdef HAVE_FINITE
+#undef HAVE_FINITE            // VSR: avoid compilation warning on Linux : "HAVE_FINITE" redefined
+#endif
 #include "Python.h"
 
 #include "VisuGUI.h"
@@ -74,6 +77,7 @@
 #include "VisuGUI_SetupPlot2dDlg.h"
 #include "Plot2d_SetupCurveDlg.h"
 #include "Plot2d_ViewManager.h"
+#include "Plot2d_SetupCurveScaleDlg.h"
 
 #include "QtxPagePrefMgr.h"
 #include "OB_Browser.h"
@@ -83,6 +87,7 @@
 #include "SalomeApp_Application.h"
 #include "SalomeApp_DataModel.h"
 #include "SalomeApp_Study.h"
+#include "SalomeApp_DataObject.h"
 #include "SalomeApp_CheckFileDlg.h"
 
 #include "LightApp_SelectionMgr.h"
@@ -220,6 +225,118 @@ VisuGUI
   }
 }
 
+void
+VisuGUI
+::OnImportFromSauvFile()
+{
+  if(MYDEBUG) MESSAGE("VisuGUI::OnImportFromSauvFile()");
+
+  if ( CheckLock(GetCStudy(GetAppStudy(this)),GetDesktop(this)) )
+    return;
+
+  SUIT_ResourceMgr* aResourceMgr = GetResourceMgr();
+
+  // Get file name(s)
+  QStringList aFilter;
+  aFilter.append( tr( "FLT_SAUV_FILES" ) );
+  aFilter.append( tr( "FLT_ALL_FILES" ) );
+
+  bool toUseBuildProgress = aResourceMgr->booleanValue("VISU", "use_build_progress", false);
+
+  SalomeApp_CheckFileDlg fd( GetDesktop(this), true, tr("USE_BUILD_PROGRESS") );
+  fd.setWindowTitle( tr( "IMPORT_FROM_FILE" ) );
+  fd.setFileMode( SalomeApp_CheckFileDlg::ExistingFiles );
+  fd.setFilters( aFilter );
+  fd.SetChecked( toUseBuildProgress );
+  if ( SalomeApp_CheckFileDlg::getLastVisitedPath().isEmpty() )
+    fd.setDirectory( QDir::currentPath() );
+
+  QStringList fileNames;
+  if ( !fd.exec() )
+    return; // cancelled, return
+
+  fileNames = fd.selectedFiles();
+  toUseBuildProgress = fd.IsChecked();
+
+  if ( fileNames.count() == 0 )
+    return; // nothing selected, return
+
+  SUIT_OverrideCursor wc;
+  QStringList errors;
+
+  for ( QStringList::ConstIterator it = fileNames.begin(); it != fileNames.end(); ++it ) {
+    QFileInfo aFileInfo( *it );
+
+    if ( !aFileInfo.exists() ) {
+      // file not exist
+      errors.append( QString( "%1 :\n\t%2" ).arg( aFileInfo.filePath() ).
+                     arg( tr( "ERR_FILE_NOT_EXISTS" ) ) );
+    }
+    else {
+      std::string file_in = aFileInfo.filePath().toLatin1().constData();
+      std::string file_tmp = file_in + ".med";
+#ifdef WNT
+      std::string cmd = "%PYTHONBIN% ";
+#else
+      std::string cmd = "python ";
+#endif
+      cmd += "-c \"";
+      cmd += "from medutilities import convert ; convert(r'" + file_in + "', 'GIBI', 'MED', 1, r'" + file_tmp + "')";
+      cmd += "\"";
+      system(cmd.c_str());
+      QString fff(file_tmp.c_str());
+      aFileInfo = fff;
+      try {
+        if ( !toUseBuildProgress ) {
+          // build progress is not used, use build flags from settings
+          bool toBuildFields = aResourceMgr->booleanValue( "VISU", "build_fields",     true );
+          bool toBuildMinMax = aResourceMgr->booleanValue( "VISU", "build_min_max",    true );
+          bool toBuildGroups = aResourceMgr->booleanValue( "VISU", "build_groups",     true );
+          bool toBuildAll    = aResourceMgr->booleanValue( "VISU", "full_med_loading", false );
+          bool toBuildAtOnce = aResourceMgr->booleanValue( "VISU", "build_at_once",    false );
+
+          QString anInfo( tr( "IMPORT_FROM_FILE" ) + " " + aFileInfo.filePath() + " ... " );
+          application()->putInfo( anInfo );
+
+          VISU::Result_var aResult = GetVisuGen( this )->CreateResult( aFileInfo.filePath().toLatin1().constData() );
+
+          if ( CORBA::is_nil( aResult.in() ) ) {
+            errors.append( QString( "%1 :\n\t%2" ).arg( aFileInfo.filePath() ).
+                           arg( tr( "ERR_ERROR_IN_THE_FILE" ) ) );
+          }
+          else {
+            aResult->SetBuildFields( toBuildFields, toBuildMinMax );
+            aResult->SetBuildGroups( toBuildGroups );
+            aResult->Build( toBuildAll, toBuildAtOnce );
+            application()->putInfo( anInfo + tr("INF_DONE") );
+          }
+        } // if ( !toUseBuildProgress )
+        else {
+          // use build progress
+          wc.suspend();
+          VisuGUI_BuildProgressDlg* aBuildProgressDlg = new VisuGUI_BuildProgressDlg( GetDesktop(this) );
+          aBuildProgressDlg->setFileName( aFileInfo.filePath() );
+          aBuildProgressDlg->setGenerator( GetVisuGen(this) );
+          aBuildProgressDlg->exec();
+          wc.resume();
+        }
+      } // try
+      catch(...) {
+        errors.append( QString( "%1 :\n\t%2" ).arg( aFileInfo.filePath() ).arg( tr( "UNKNOWN_IMPORT_ERROR" ) ) );
+      }
+    } // else // if ( !aFileInfo.exists() )
+  } // for (...)
+
+  if ( errors.count() > 0 ) {
+    SUIT_MessageBox::critical( GetDesktop(this),
+                               tr("ERR_ERROR"),
+                               tr("IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
+  }
+  else {
+    UpdateObjBrowser(this);
+  }
+}
+
 void
 VisuGUI
 ::OnImportFromFile()
@@ -259,6 +376,7 @@ VisuGUI
 
   SUIT_OverrideCursor wc;
   QStringList errors;
+  QStringList anEntryList;
 
   for ( QStringList::ConstIterator it = fileNames.begin(); it != fileNames.end(); ++it ) {
     QFileInfo aFileInfo( *it );
@@ -291,6 +409,8 @@ VisuGUI
             aResult->SetBuildFields( toBuildFields, toBuildMinMax );
             aResult->SetBuildGroups( toBuildGroups );
             aResult->Build( toBuildAll, toBuildAtOnce );
+            if( VISU::Result_i* aCResult = dynamic_cast<VISU::Result_i*>( VISU::GetServant( aResult ).in() ) )
+              anEntryList.append( aCResult->GetEntry().c_str() );
             application()->putInfo( anInfo + tr("INF_DONE") );
           }
         } // if ( !toUseBuildProgress )
@@ -317,6 +437,8 @@ VisuGUI
   }
   else {
     UpdateObjBrowser(this);
+    if( getApp() )
+      getApp()->browseObjects( anEntryList );
   }
 }
 
@@ -362,6 +484,7 @@ VisuGUI
     return; // nothing selected
 
   QStringList errors;
+  QStringList anEntryList;
   for ( QStringList::ConstIterator it = aFiles.begin(); it != aFiles.end(); ++it ) {
     QFileInfo aFileInfo( *it );
 
@@ -374,7 +497,7 @@ VisuGUI
         QString anInfo( tr("TLT_IMPORT_TABLE") + " " + aFileInfo.filePath() + " ..." );
         application()->putInfo( anInfo );
 
-        CORBA::Object_var anObject =
+        SALOMEDS::SObject_var anObject =
           GetVisuGen(this)->ImportTables(aFileInfo.filePath().toLatin1().constData(),
                                          aFirstStrAsTitle);
 
@@ -383,11 +506,12 @@ VisuGUI
                          arg( tr( "ERR_ERROR_IN_THE_FILE" ) ) );
         }
         else {
+          anEntryList.append( anObject->GetID() );
           application()->putInfo( anInfo + tr("INF_DONE") );
         }
       }
       catch(...) {
-        errors.append( QString( "%1 :\n\t%2" ).arg( aFileInfo.filePath() ).arg( tr( "UNKNOWN_IMPORT_ERROR" ) ) );
+        errors.append( QString( "%1 :\n\t%2" ).arg( aFileInfo.filePath() ).arg( tr( "UNSUPPORTED_FILE_FORMAT" ) ) );
       }
     }
   }
@@ -399,6 +523,8 @@ VisuGUI
   }
   else {
     UpdateObjBrowser(this);
+    if( getApp() )
+      getApp()->browseObjects( anEntryList );
   }
 }
 
@@ -519,6 +645,7 @@ VisuGUI
   SALOME_ListIO aListIO;
   aSelectionMgr->selectedObjects(aListIO);
 
+  QStringList anEntryList;
   SALOME_ListIteratorOfListIO It (aListIO);
   QApplication::setOverrideCursor(Qt::WaitCursor);
   for (; It.More(); It.Next()) {
@@ -558,14 +685,15 @@ VisuGUI
         }
       }
 
+      VISU::Result_var aResult;
       CORBA::Object_var anObject = VISU::SObjectToObject(aSObject);
       if (!CORBA::is_nil(anObject)) {
         SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow(anObject);
         if (!CORBA::is_nil(aMED.in()))
-          GetVisuGen(this)->ImportMed(aSObject);
+          aResult = GetVisuGen(this)->ImportMed(aSObject);
         SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow(anObject);
         if (!CORBA::is_nil(aField.in()))
-          GetVisuGen(this)->ImportMedField(aField);
+          aResult = GetVisuGen(this)->ImportMedField(aField);
       } else {
         SALOMEDS::SObject_var aSFather = aSObject->GetFather();
         SALOMEDS::GenericAttribute_var anAttr;
@@ -573,11 +701,17 @@ VisuGUI
         SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
         CORBA::String_var aValue = aName->Value();
         if (strcmp(aValue.in(), "MEDFIELD") == 0)
-          GetVisuGen(this)->ImportMed(aSObject);
+          aResult = GetVisuGen(this)->ImportMed(aSObject);
       }
+
+      if( !CORBA::is_nil( aResult ) )
+        if( VISU::Result_i* aCResult = dynamic_cast<VISU::Result_i*>( VISU::GetServant( aResult ).in() ) )
+          anEntryList.append( aCResult->GetEntry().c_str() );
     }
   }
   UpdateObjBrowser(this, true);
+  if( getApp() )
+    getApp()->browseObjects( anEntryList );
   QApplication::restoreOverrideCursor();
 }
 
@@ -755,8 +889,7 @@ VisuGUI
   // create mesh presentation and display it in aViewWindow
   VISU::Mesh_i* aPrs = CreateMesh(this, anIO, aViewWindow);
   aViewWindow->highlight(anIO, 1);
-  if (aPrs)
-    emit presentationCreated(aPrs);
+  processPresentationCreated(aPrs);
 }
 
 void
@@ -783,8 +916,7 @@ VisuGUI
     // create mesh presentation and display it in aViewWindow
     VISU::Mesh_i* aPrs = CreateMesh(this, anIO, aViewWindow);
     aViewWindow->highlight(anIO, 1);
-    if (aPrs)
-      emit presentationCreated(aPrs);
+    processPresentationCreated(aPrs);
   }
 }
 
@@ -793,8 +925,7 @@ VisuGUI
 ::OnCreateScalarMap()
 {
   Prs3d_i* aPrs = CreatePrs3d<VISU::ScalarMap_i,VisuGUI_ScalarBarDlg,1>(this);
-  if (aPrs)
-    emit presentationCreated(aPrs);
+  processPresentationCreated(aPrs);
 }
 
 
@@ -803,8 +934,7 @@ VisuGUI
 ::OnCreateDeformedShape()
 {
   Prs3d_i* aPrs = CreatePrs3d<VISU::DeformedShape_i,VisuGUI_DeformedShapeDlg,1>(this);
-  if (aPrs)
-    emit presentationCreated(aPrs);
+  processPresentationCreated(aPrs);
 }
 
 void
@@ -812,8 +942,7 @@ VisuGUI
 ::OnCreateDeformedShapeAndScalarMap()
 {
   Prs3d_i* aPrs = CreatePrs3d<VISU::DeformedShapeAndScalarMap_i,VisuGUI_DeformedShapeAndScalarMapDlg,1>(this);
-  if (aPrs)
-    emit presentationCreated(aPrs);
+  processPresentationCreated(aPrs);
 }
 
 void
@@ -821,8 +950,7 @@ VisuGUI
 ::OnCreateVectors()
 {
   Prs3d_i* aPrs = CreatePrs3d<VISU::Vectors_i,VisuGUI_VectorsDlg,1>(this);
-  if (aPrs)
-    emit presentationCreated(aPrs);
+  processPresentationCreated(aPrs);
 }
 
 void
@@ -830,8 +958,7 @@ VisuGUI
 ::OnCreateIsoSurfaces()
 {
   Prs3d_i* aPrs = CreatePrs3d<VISU::IsoSurfaces_i,VisuGUI_IsoSurfacesDlg,1>(this);
-  if (aPrs)
-    emit presentationCreated(aPrs);
+  processPresentationCreated(aPrs);
 }
 
 void
@@ -839,8 +966,7 @@ VisuGUI
 ::OnCreateCutPlanes()
 {
   Prs3d_i* aPrs = CreatePrs3d<VISU::CutPlanes_i,VisuGUI_CutPlanesDlg,0>(this);
-  if (aPrs)
-    emit presentationCreated(aPrs);
+  processPresentationCreated(aPrs);
 }
 
 void
@@ -848,8 +974,7 @@ VisuGUI
 ::OnCreateCutLines()
 {
   Prs3d_i* aPrs = CreatePrs3d<VISU::CutLines_i,VisuGUI_CutLinesDlg,0>(this);
-  if (aPrs)
-    emit presentationCreated(aPrs);
+  processPresentationCreated(aPrs);
 }
 
 void
@@ -857,8 +982,7 @@ VisuGUI
 ::OnCreateCutSegment()
 {
   Prs3d_i* aPrs = CreatePrs3d<VISU::CutSegment_i,VisuGUI_CutSegmentDlg,0>(this);
-  if (aPrs)
-    emit presentationCreated(aPrs);
+  processPresentationCreated(aPrs);
 }
 
 void
@@ -866,8 +990,7 @@ VisuGUI
 ::OnCreateStreamLines()
 {
   Prs3d_i* aPrs = CreatePrs3d<VISU::StreamLines_i,VisuGUI_StreamLinesDlg,1>(this);
-  if (aPrs)
-    emit presentationCreated(aPrs);
+  processPresentationCreated(aPrs);
 }
 
 void
@@ -875,8 +998,7 @@ VisuGUI
 ::OnCreatePlot3D()
 {
   Prs3d_i* aPrs = CreatePrs3d<VISU::Plot3D_i,VisuGUI_Plot3DDlg,0>(this);
-  if (aPrs)
-    emit presentationCreated(aPrs);
+  processPresentationCreated(aPrs);
 }
 
 void
@@ -884,8 +1006,17 @@ VisuGUI
 ::OnCreatePlot2dView()
 {
   CheckLock(GetCStudy(GetAppStudy(this)),GetDesktop(this));
-  GetVisuGen( this )->CreateContainer();
+  VISU::Container_var aContainer = GetVisuGen( this )->CreateContainer();
   UpdateObjBrowser(this);
+
+  if( !CORBA::is_nil( aContainer.in() ) ) {
+    if( VISU::Container_i* aCContainer = dynamic_cast<VISU::Container_i*>( VISU::GetServant( aContainer ).in() ) ) {
+      QStringList anEntryList;
+      anEntryList.append( aCContainer->GetEntry().c_str() );
+      if( getApp() )
+        getApp()->browseObjects( anEntryList );
+    }
+  }
 }
 
 void
@@ -931,6 +1062,7 @@ VisuGUI
     case VISU::TTABLE:
       getViewManager(SPlot2d_Viewer::Type(), true);
       displayer()->Display(anIO->getEntry());
+      aSelectionMgr->setSelectedObjects(aList);
       break;
     default: {
       VISU::Prs3d_i* aPrs3d = VISU::GetPrs3dFromBase(aBase);
@@ -1294,6 +1426,7 @@ VisuGUI
         break;
       case VISU::WIREFRAME :
       case VISU::INSIDEFRAME :
+      case VISU::FEATURE_EDGES :       
         anOldColor = aMesh->GetLinkColor();
         break;
       case VISU::SHADED :
@@ -1326,6 +1459,7 @@ VisuGUI
           break;
         case VISU::SHADED :
         case VISU::SURFACEFRAME :
+        case VISU::FEATURE_EDGES :
           aMesh->SetCellColor(aNewColor);
           break;
       }
@@ -1750,7 +1884,7 @@ VisuGUI
         _PTR(Study) aStudy = GetCStudy(GetAppStudy(this));
         _PTR(SObject) aSObject = aStudy->FindObjectID( aTable->GetObjectEntry() );
         if(IsSObjectTable(aSObject)){
-          VisuGUI_SetupPlot2dDlg* aDlg = new VisuGUI_SetupPlot2dDlg(aSObject, GetDesktop(this));
+          VisuGUI_SetupPlot2dDlg* aDlg = new VisuGUI_SetupPlot2dDlg(aSObject, aTable ,GetDesktop(this));
           if(aDlg->exec() == QDialog::Accepted){
             if(!IsStudyLocked(aStudy)){
               // if study is not locked - create new container, create curves and insert them
@@ -1765,7 +1899,10 @@ VisuGUI
                   for( int i = 0; i < verIndices.count(); i++ ){
                     bool isV2 = ver2Indices.contains(verIndices[i]);
                     VISU::Curve_var aCurveObject =
-                      GetVisuGen(this)->CreateCurveWithZExt(aTable->_this(), horIndex+1, verIndices[i]+1, zIndices[i]+1, isV2 );
+                      GetVisuGen(this)->CreateCurveWithZExt(aTable->_this(), 
+                                                            aDlg->idx(horIndex)+1, 
+                                                            aDlg->idx(verIndices[i])+1, 
+                                                            aDlg->idx(zIndices[i])+1, isV2 );
                     if(VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurveObject).in())){
                       bool isAuto;
                       int  marker, line, lineWidth;
@@ -1814,7 +1951,7 @@ VisuGUI
     // check if Table SObject is selected
     _PTR(SObject) aSObject = aSelectionItem.myObjectInfo.mySObject;
     if(IsSObjectTable(aSObject)){
-      VisuGUI_SetupPlot2dDlg* aDlg = new VisuGUI_SetupPlot2dDlg(aSObject, GetDesktop(this));
+      VisuGUI_SetupPlot2dDlg* aDlg = new VisuGUI_SetupPlot2dDlg(aSObject, NULL, GetDesktop(this));
       if(aDlg->exec() == QDialog::Accepted){
         _PTR(Study) aStudy = GetCStudy(GetAppStudy(this));
         if(!IsStudyLocked(aStudy)){
@@ -1917,6 +2054,44 @@ VisuGUI
   }
 }
 
+//----------------------------------------------------------------------------
+void
+VisuGUI
+::OnCurveScale()
+{
+  if(IsStudyLocked(GetCStudy(GetAppStudy(this))))
+    return;
+
+  VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects( this );
+  int nbSel = aSelectionInfo.size();
+  QList<VISU::Curve_i*> curList;
+  bool isValuesEquals = true;                  
+  double value;
+
+  for (int i = 0; i < nbSel; i++ ) {
+    VISU::TSelectionItem aSelectionItem = aSelectionInfo[i];
+    VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase;
+    if(!aBase)
+      continue;
+
+    if(aBase->GetType() == VISU::TCURVE) 
+      // Curve object
+      if(VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(aBase)) {
+        curList.append(aCurve);
+        if( i>0 && isValuesEquals )
+          isValuesEquals = (value == aCurve->GetScale());
+         value = aCurve->GetScale();
+      }
+  }
+
+  Plot2d_SetupCurveScaleDlg aDlg(GetDesktop( this ));
+  if( isValuesEquals )
+     aDlg.setScale(value);
+
+  if( aDlg.exec() == QDialog::Accepted )
+       for ( int i = 0; i < curList.size(); ++i )
+         curList.at(i)->SetScale( aDlg.getScale() );
+}
 //----------------------------------------------------------------------------
 void
 VisuGUI
@@ -2026,109 +2201,6 @@ VisuGUI
     VISU::View3D_i::RestoreViewParams(aViewMgr, aSObj->GetName().c_str());//jfa tmp
 }
 
-//----------------------------------------------------------------------------
-void
-VisuGUI
-::OnRename()
-{
-  _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
-  if (CheckLock(aCStudy,GetDesktop(this)))
-    return;
-
-  VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this);
-  if (aSelectionInfo.empty())
-    return;
-
-  VisuGUI_Selection aSel (this);
-  aSel.init("", getApp()->selectionMgr());
-  if (aSel.count() < 1) return;
-
-  bool isAny = false; // is there any appropriate object selected
-  for (int i = 0; i < aSelectionInfo.size(); i++) {
-    VISU::TSelectionItem aSelectionItem = aSelectionInfo[i];
-    VISU::TObjectInfo anObjectInfo = aSelectionItem.myObjectInfo;
-
-    _PTR(SObject) aSObject = anObjectInfo.mySObject;
-    if (!aSObject)
-      continue;
-
-    // Check, if the selected object can be renamed
-    QString aStr = aSel.parameter(i, "type" ).toString();
-    if (aStr == "VISU::TSCALARMAP" || aStr == "VISU::TISOSURFACES" ||
-        aStr == "VISU::TDEFORMEDSHAPE" || aStr == "VISU::TCUTPLANES" ||
-        aStr == "VISU::TCUTLINES" || aStr == "VISU::TCUTSEGMENT" || aStr == "VISU::TVECTORS" ||
-        aStr == "VISU::TSTREAMLINES" || aStr == "VISU::TPLOT3D" ||
-        aStr == "VISU::TSCALARMAPONDEFORMEDSHAPE" || aStr == "VISU::TCOLOREDPRS3DHOLDER" ||
-        aStr == "VISU::TTABLE" || aStr == "VISU::TCURVE" || aStr == "VISU::TCONTAINER" ||
-        aStr == "VISU::POINTMAP3D" || aStr == "VISU::TVIEW3D" ||
-        aStr == "VISU::TPOINTMAP3D" || aStr == "VISU::TGAUSSPOINTS")
-    {
-      _PTR(GenericAttribute) anAttr;
-      if (aSObject->FindAttribute(anAttr, "AttributeName")) {
-        isAny = true;
-        _PTR(AttributeName) aName (anAttr);
-        QString Name = VisuGUI_NameDlg::getName( GetDesktop( this ), aName->Value().c_str() );
-        if (!Name.isEmpty()) {
-          QApplication::setOverrideCursor(Qt::WaitCursor);
-
-          // rename specific objects
-          if (VISU::Base_i* aBase = anObjectInfo.myBase) {
-            switch (aBase->GetType()) {
-            case VISU::TCURVE: { // Curve object
-              if (VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(aBase))
-                aCurve->SetName(Name.toLatin1().constData(), true);
-              break;
-            }
-            case VISU::TTABLE: { // Table object
-              if (VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(aBase))
-                aTable->SetName(Name.toLatin1().constData(), true);
-              break;
-            }
-            case VISU::TPOINTMAP3D: { // Table object
-              if (VISU::PointMap3d_i* aTable3d = dynamic_cast<VISU::PointMap3d_i*>(aBase)) {
-                aTable3d->SetTitle(Name.toLatin1().constData());
-                aTable3d->UpdateActors();
-              }
-              break;
-            }
-            case VISU::TCONTAINER: { // Container object
-              if (VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aBase))
-                aContainer->SetName(Name.toLatin1().constData(), true);
-              break;
-            }
-            default: {
-            }}
-          }
-
-          // rename the study object
-          Handle(SALOME_InteractiveObject) anIO = aSelectionItem.myIO;
-          aName->SetValue(Name.toLatin1().constData()); // rename the SObject
-          anIO->setName(Name.toLatin1().constData()); // rename the InteractiveObject
-
-          ViewManagerList aViewManagerList;
-          getApp()->viewManagers(SPlot2d_Viewer::Type(), aViewManagerList);
-          SUIT_ViewManager* aViewManager;
-          foreach( aViewManager, aViewManagerList ) {
-            if (Plot2d_ViewManager* aManager = dynamic_cast<Plot2d_ViewManager*>(aViewManager)) {
-              if (SPlot2d_Viewer* aViewer = dynamic_cast<SPlot2d_Viewer*>(aManager->getViewModel()))
-                aViewer->renameAll( anIO, Name.toLatin1().constData() );
-            }
-          }
-
-          UpdateObjBrowser(this, false);
-          QApplication::restoreOverrideCursor();
-        }
-      }
-    }
-  } // for
-
-  if (!isAny) {
-    SUIT_MessageBox::warning(GetDesktop(this),
-                             QObject::tr("WRN_VISU"),
-                             QObject::tr("WRN_NO_APPROPRIATE_SELECTION"));
-  }
-}
-
 //----------------------------------------------------------------------------
 void
 VisuGUI
@@ -2567,6 +2639,10 @@ VisuGUI
                 tr("MEN_IMPORT_FROM_FILE"), "", (Qt::CTRL + Qt::Key_I), aParent, false,
                 this, SLOT(OnImportFromFile()));
 
+  createAction( VISU_IMPORT_SAUV, "", QIcon(),
+                tr("MEN_IMPORT_SAUV"), "", 0, aParent, false,
+                this, SLOT(OnImportFromSauvFile()));
+
   createAction( VISU_IMPORT_TABLE, "", QIcon(),
                 tr("MEN_IMPORT_TABLE"), "", 0, aParent, false,
                 this, SLOT(OnImportTableFromFile()));
@@ -2710,9 +2786,9 @@ VisuGUI
                 tr("MEN_CURVE_PROPS"), "", 0, aParent, false,
                 this, SLOT(OnCurveProperties()));
 
-  createAction( VISU_RENAME, tr("MEN_RENAME"), QIcon(),
-                tr("MEN_RENAME"), "", Qt::Key_F2, aParent, false,
-                this, SLOT(OnRename()));
+  createAction( VISU_CURVE_SCALE, tr("MEN_CURVE_SCALE"), QIcon(),
+                tr("MEN_CURVE_SCALE"), "", 0, aParent, false,
+                this, SLOT(OnCurveScale()));
 
   createAction( VISU_EDIT_CONTAINER, tr("MEN_EDIT_CONTAINER"), QIcon(),
                 tr("MEN_EDIT_CONTAINER"), "", 0, aParent, false,
@@ -2979,6 +3055,10 @@ VisuGUI
                tr("MEN_VISU_LINEQUAD_MODE"), "",0, aParent, true,
                this, SLOT(OnLineQuadMode()));
 
+  createAction(VISU_SHOW_DEVIATION, tr("MEN_VISU_SHOW_DEVIATION"),QIcon(),
+               tr("MEN_VISU_SHOW_DEVIATION"), "",0, aParent, true,
+               this, SLOT(OnShowDeviation()));
+
 }
 
 void
@@ -2992,6 +3072,7 @@ VisuGUI
 
   int anImportId = createMenu( tr( "MEN_IMPORT" ), aMenuId, -1, 10 );
   createMenu( VISU_IMPORT_FROM_FILE, anImportId ); // import from file
+  createMenu( VISU_IMPORT_SAUV, anImportId ); // import sauv file
   createMenu( VISU_IMPORT_TABLE, anImportId ); // import table
 
   aMenuId = createMenu( tr( "MEN_VISUALIZATION" ), -1, -1, 30 );
@@ -3068,6 +3149,7 @@ VisuGUI
 
   // VISU root commands
   mgr->insert( action( VISU_IMPORT_FROM_FILE ), -1, -1, -1 ); // import MED file
+  mgr->insert( action( VISU_IMPORT_SAUV ), -1, -1, -1 ); // import SAUV file
   mgr->insert( action( VISU_IMPORT_TABLE ), -1, -1, -1 ); // import tables from file
   mgr->insert( action( VISU_PLOT2D ), -1, -1, -1 ); // create Plot2d View
 
@@ -3106,9 +3188,6 @@ VisuGUI
 
   mgr->insert( action( VISU_FILTERSCALARS ), -1, -1, -1 );
 
-  // rename
-  mgr->insert( action( VISU_RENAME ), -1, -1, -1 );
-
   // copy
   mgr->insert( action( VISU_COPY_PRS ), -1, -1, -1 );
 
@@ -3192,6 +3271,9 @@ VisuGUI
   mgr->insert( action( VISU_ARRANGE_ACTORS ), -1, -1, -1 ); // arrange actors
 
   mgr->insert( action( VISU_CURVE_PROPS ), -1, -1, -1 ); // curve properties
+  mgr->insert( action( VISU_CURVE_SCALE ), -1, -1, -1 ); // curve scale
+  //Show deviation command on curve
+  mgr->insert( action( VISU_SHOW_DEVIATION ), -1, -1, -1 ); // deviation
 
   mgr->insert( action( VISU_MULTIPR_FULL_RES ), -1, -1, -1 );
   mgr->insert( action( VISU_MULTIPR_MED_RES ), -1, -1, -1 );
@@ -3213,6 +3295,7 @@ VisuGUI
   // VISU root commands
   QString aRule = "client='ObjectBrowser' and selcount=1 and type='VISU::TVISUGEN'";
   mgr->setRule( action( VISU_IMPORT_FROM_FILE ), aRule );
+  mgr->setRule( action( VISU_IMPORT_SAUV ), aRule );
   mgr->setRule( action( VISU_IMPORT_TABLE ), aRule );
   mgr->setRule( action( VISU_PLOT2D ), aRule );
 
@@ -3339,19 +3422,15 @@ VisuGUI
   mgr->setRule( action( VISU_CELL_COLOR ), aRule + " and type='VISU::TMESH' and representation='VISU::SURFACEFRAME'" );
   mgr->setRule( action( VISU_EDGE_COLOR ), aRule + aSurfFrameType + " and representation='VISU::SURFACEFRAME'" );
   mgr->setRule( action( VISU_COLOR ), aRule + " and ((type='VISU::TMESH'"
-               " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::INSIDEFRAME'}) "
+               " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::INSIDEFRAME' 'VISU::FEATURE_EDGES'}) "
                "or (type='VISU::TDEFORMEDSHAPE' and hasActor=1))" );
   mgr->setRule( action( VISU_OPACITY ), aRule + " and hasActor=1" );
-  mgr->setRule( action( VISU_LINE_WIDTH ), aRule + aLineType + " and hasActor=1" );
+  mgr->setRule( action( VISU_LINE_WIDTH ), aRule + aLineType + " and hasActor=1 and representation!='VISU::POINT'" );
   mgr->setRule( action( VISU_POINT_MARKER ), aRule + aLineType + " and hasActor=1 and representation='VISU::POINT'" );
   mgr->setRule( action( VISU_SHRINK_FACTOR ), aRule + aShrinkType + " and isShrunk=1" );
 
-  // rename command
   QString aCurveAll = "'VISU::TTABLE' 'VISU::TCURVE' 'VISU::TCONTAINER' 'VISU::POINTMAP3D'";
 
-  aRule = "selcount=1 and ($type in {'VISU::TVIEW3D' 'VISU::TPOINTMAP3D' " + aCurveAll + " " + aPrsAll + "})";
-  mgr->setRule( action( VISU_RENAME ), aRule );
-
   // copy presentation command
   aRule = "selcount=1 and ($type in {" + aPrsAll + "})";
   mgr->setRule( action( VISU_COPY_PRS ), aRule );
@@ -3359,6 +3438,7 @@ VisuGUI
   // Curve commands
   aRule = "selcount=1 and type='VISU::TCURVE'";
   mgr->setRule( action( VISU_CURVE_PROPS ), aRule );
+  mgr->setRule( action( VISU_CURVE_SCALE ), "selcount > 0 and type='VISU::TCURVE'");
 
   // Table Commands
   aRule = "selcount=1 and ( type='VISU::TPOINTMAP3D' or type='VISU::TTABLE')";
@@ -3447,6 +3527,11 @@ VisuGUI
 
   mgr->setRule( action( VISU_FILE_INFO ), "selcount=1 and type in {'VISU::TRESULT'}" );
   mgr->setRule( action( VISU_EXPORT_MED ), "selcount=1 and type in {'VISU::TRESULT'}" );
+
+  aRule = "isPlot2dViewer and isVisible and selcount=1 and type='VISU::TCURVE' and hasDeviation";
+  mgr->setRule (action(VISU_SHOW_DEVIATION), aRule , QtxPopupMgr::VisibleRule);
+  aRule = "isPlot2dViewer and isVisible and selcount > 0 and type='VISU::TCURVE' and hasDeviation and isDeviationDisplayed";
+  mgr->setRule (action(VISU_SHOW_DEVIATION), aRule , QtxPopupMgr::ToggleRule);
 }
 
 void VisuGUI::createPanels()
@@ -3671,7 +3756,7 @@ VisuGUI
 
   // import Python module that manages VISU plugins (need to be here because SalomePyQt API uses active module)
   PyGILState_STATE gstate = PyGILState_Ensure();
-  PyObject* pluginsmanager=PyImport_ImportModule((char*)"salome_pluginsmanager");
+  PyObject* pluginsmanager=PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
   if(pluginsmanager==NULL)
     PyErr_Print();
   else
@@ -3690,7 +3775,6 @@ VisuGUI
   action(VISU_IMPORT_FROM_FILE)->setShortcuts(shortcuts);
 
   action(VISU_DELETE_OBJS)->setEnabled(true); // Delete: Key_Delete
-  action(VISU_RENAME     )->setEnabled(true); // Rename: Key_F2
 
   ((VisuGUI_ClippingPanel*) myPanels[ClippingPlanesPanelId])->init();
   GetVisuGen( this )->GetClippingPlaneMgr().SetStudy(GetCStudy(dynamic_cast<SalomeApp_Study*>(theStudy)),true);
@@ -3711,7 +3795,6 @@ VisuGUI
   action(VISU_IMPORT_FROM_FILE)->setShortcuts(QKeySequence::UnknownKey); // Import: CTRL + Key_I
 
   action(VISU_DELETE_OBJS)->setEnabled(false); // Delete: Key_Delete
-  action(VISU_RENAME     )->setEnabled(false); // Rename: Key_F2
 
   bool aResult = SalomeApp_Module::deactivateModule( theStudy );
 
@@ -3727,6 +3810,25 @@ VisuGUI
   return new VisuGUI_Selection( (SalomeApp_Module*)this );
 }
 
+void
+VisuGUI
+::processPresentationCreated( VISU::Prs3d_i* thePrs )
+{
+  if( thePrs )
+  {
+    QString anEntry = thePrs->GetEntry().c_str();
+    if( anEntry.isEmpty() )
+      if( VISU::ColoredPrs3d_i* aColoredPrs = dynamic_cast<VISU::ColoredPrs3d_i*>( thePrs ) )
+        anEntry = aColoredPrs->GetHolderEntry().c_str();
+
+    QStringList anEntryList( anEntry );
+    if( getApp() )
+      getApp()->browseObjects( anEntryList );
+
+    emit presentationCreated( thePrs );
+  }
+}
+
 //******************************************************************
 void VisuGUI::studyActivated()
 {
@@ -4574,8 +4676,7 @@ void VisuGUI::OnPlot3dFromCutPlane()
 
           AddScalarBarPosition(this, aSVtkWindow, aPrs3d, aPos);
         }
-        if (aPrs3d)
-          emit presentationCreated(aPrs3d);
+        processPresentationCreated(aPrs3d);
      }
    }
    application()->putInfo(QObject::tr("INF_DONE"));
@@ -4833,3 +4934,186 @@ void VisuGUI::OnArcQuadMode(){
 void VisuGUI::OnLineQuadMode(){
   ChangeQuadratic2DRepresentation(this,VISU::LINES);
 }
+
+/*!
+  \brief Return \c true if object can be renamed
+*/
+bool VisuGUI::renameAllowed( const QString& entry) const {  
+  
+  SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
+  SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0; 
+  SalomeApp_DataObject* obj = appStudy ? dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry)) : 0;
+  
+  if(!app || !appStudy || !obj)
+    return false;
+
+  if(appStudy->isComponent(entry) || obj->isReference())
+    return false;
+
+  
+  VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry( GetAppStudy(this), qPrintable(entry) );
+  VISU::Base_i* aBase = anObjectInfo.myBase;
+  if(aBase){
+    VISU::VISUType aType = aBase->GetType();
+    if( aType == VISU::TCOLOREDPRS3DHOLDER ) {
+      CORBA::Object_var anObject = ClientSObjectToObject(anObjectInfo.mySObject);
+      VISU::ColoredPrs3dHolder_var aHolder = VISU::ColoredPrs3dHolder::_narrow(anObject);
+      aType = aHolder->GetPrsType();
+    }
+    if (aType == VISU::TSCALARMAP || aType == VISU::TISOSURFACES ||
+        aType == VISU::TDEFORMEDSHAPE || aType == VISU::TCUTPLANES ||
+        aType == VISU::TCUTLINES || aType == VISU::TCUTSEGMENT || aType == VISU::TVECTORS ||
+        aType == VISU::TSTREAMLINES || aType == VISU::TPLOT3D ||
+        aType == VISU::TSCALARMAPONDEFORMEDSHAPE || aType == VISU::TCOLOREDPRS3DHOLDER ||
+        aType == VISU::TTABLE || aType == VISU::TCURVE || aType == VISU::TCONTAINER ||
+        aType == VISU::TPOINTMAP3D || aType == VISU::TVIEW3D ||
+        aType == VISU::TPOINTMAP3D || aType == VISU::TGAUSSPOINTS)
+      return true;
+  } else {
+    VISU::Storable::TRestoringMap aMap = VISU::Storable::GetStorableMap(anObjectInfo.mySObject);
+    bool anIsExist;
+    QString aVal = VISU::Storable::FindValue(aMap, "myComment", &anIsExist);
+    return anIsExist && "VIEW3D" == aVal;
+  }
+  return false;
+}
+
+void VisuGUI::OnShowDeviation() {
+
+  VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this);
+  if(aSelectionInfo.size() != 1)
+    return;
+
+  VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
+  Handle(SALOME_InteractiveObject) anIO = aSelectionItem.myIO;
+  VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase;
+  if(!aBase)
+    return;
+
+  if(aBase->GetType() == VISU::TCURVE) {
+    if(!IsStudyLocked(GetCStudy(GetAppStudy(this)))){
+      // Curve object
+      if(VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(aBase)) {
+        aCurve->ShowDeviation(!aCurve->isDeviationShown());
+        PlotCurve(this, aCurve, VISU::eDisplay);
+      }
+    }
+  }
+}
+
+/*!
+  Rename object by entry.
+  \param entry entry of the object
+  \param name new name of the object
+  \brief Return \c true if rename operation finished successfully, \c false otherwise.
+*/
+bool VisuGUI::renameObject( const QString& entry, const QString& name) {    
+
+  SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication());
+  SalomeApp_Study* appStudy = app ? dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) : 0;
+  
+  if(!appStudy)
+    return false;
+  
+  _PTR(Study) aStudy = appStudy->studyDS();
+  
+  if(!aStudy)
+    return false;
+  
+  bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked();
+  if ( aLocked ) {
+    SUIT_MessageBox::warning ( app->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") );
+    return false;
+  }
+  
+  VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(GetAppStudy(this) , qPrintable(entry) );
+  
+  _PTR(SObject) aSObject = anObjectInfo.mySObject;
+  if (aSObject) {
+    VISU::Base_i* aBase = anObjectInfo.myBase;
+    VISU::Storable::TRestoringMap aMap = VISU::Storable::GetStorableMap(anObjectInfo.mySObject);
+    if(aBase){
+      VISU::VISUType aType = aBase->GetType();
+      if( aType == VISU::TCOLOREDPRS3DHOLDER ) {
+       CORBA::Object_var anObject = ClientSObjectToObject(anObjectInfo.mySObject);
+       VISU::ColoredPrs3dHolder_var aHolder = VISU::ColoredPrs3dHolder::_narrow(anObject);
+       aType = aHolder->GetPrsType();
+      }
+      if (aType == VISU::TSCALARMAP || aType == VISU::TISOSURFACES ||
+         aType == VISU::TDEFORMEDSHAPE || aType == VISU::TCUTPLANES ||
+         aType == VISU::TCUTLINES || aType == VISU::TCUTSEGMENT || aType == VISU::TVECTORS ||
+         aType == VISU::TSTREAMLINES || aType == VISU::TPLOT3D ||
+         aType == VISU::TSCALARMAPONDEFORMEDSHAPE || aType == VISU::TCOLOREDPRS3DHOLDER ||
+         aType == VISU::TTABLE || aType == VISU::TCURVE || aType == VISU::TCONTAINER ||
+         aType == VISU::TPOINTMAP3D || aType == VISU::TVIEW3D ||
+         aType == VISU::TPOINTMAP3D || aType == VISU::TGAUSSPOINTS) {
+       _PTR(GenericAttribute) anAttr;
+       if (aSObject->FindAttribute(anAttr, "AttributeName")) {
+         _PTR(AttributeName) aName (anAttr);
+         if (!name.isEmpty()) {
+           QApplication::setOverrideCursor(Qt::WaitCursor);
+           // rename specific objects
+           if (VISU::Base_i* aBase = anObjectInfo.myBase) {
+             switch (aBase->GetType()) {
+             case VISU::TCURVE: { // Curve object
+               if (VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(aBase))
+                 aCurve->SetName(qPrintable(name), true);
+               break;
+             }
+             case VISU::TTABLE: { // Table object
+               if (VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(aBase))
+                 aTable->SetName(qPrintable(name), true);
+               break;
+             }
+             case VISU::TPOINTMAP3D: { // Table object
+               if (VISU::PointMap3d_i* aTable3d = dynamic_cast<VISU::PointMap3d_i*>(aBase)) {
+                 aTable3d->SetTitle(qPrintable(name));
+                 aTable3d->UpdateActors();
+               }
+               break;
+             }
+             case VISU::TCONTAINER: { // Container object
+               if (VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aBase))
+                 aContainer->SetName(qPrintable(name), true);
+               break;
+             }
+             default: {
+             }}
+           }
+
+           // rename the study object
+           aName->SetValue( qPrintable(name) ); // rename the SObject
+           
+           ViewManagerList aViewManagerList;
+           getApp()->viewManagers(SPlot2d_Viewer::Type(), aViewManagerList);
+           SUIT_ViewManager* aViewManager;
+           Handle(SALOME_InteractiveObject) anIO = 
+             new SALOME_InteractiveObject ( qPrintable(entry), "VISU", qPrintable(name) );
+           foreach( aViewManager, aViewManagerList ) {
+             if (Plot2d_ViewManager* aManager = dynamic_cast<Plot2d_ViewManager*>(aViewManager)) {
+               if (SPlot2d_Viewer* aViewer = dynamic_cast<SPlot2d_Viewer*>(aManager->getViewModel()))
+                 aViewer->renameAll( anIO, qPrintable(name) );
+             }
+           }
+           QApplication::restoreOverrideCursor();          
+           return true;
+         }
+       }
+       //Rename visual params
+      }
+    } else {
+      bool anIsExist;
+      QString aVal = VISU::Storable::FindValue(aMap, "myComment", &anIsExist);
+      if(anIsExist && "VIEW3D" == aVal) {
+       _PTR(GenericAttribute) anAttr;
+       if (aSObject->FindAttribute(anAttr, "AttributeName")) {
+         _PTR(AttributeName) aName (anAttr);
+         if (!name.isEmpty()) {
+           aName->SetValue(qPrintable(name));
+         }
+       }
+      }
+    }
+  }
+  return false;
+}