]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Forbid renaming of the objects "in place" by default. V6_main_20120312 V6_main_20120313
authorrnv <rnv@opencascade.com>
Wed, 7 Mar 2012 11:39:45 +0000 (11:39 +0000)
committerrnv <rnv@opencascade.com>
Wed, 7 Mar 2012 11:39:45 +0000 (11:39 +0000)
src/VISUGUI/VisuGUI.cxx

index 7a83d56e9bca8951af3021095f6f53c4791b5b5b..31d5ba4e482a271d1f9010050ce1029b72fa80a7 100644 (file)
@@ -87,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"
@@ -4938,9 +4939,17 @@ void VisuGUI::OnLineQuadMode(){
   \brief Return \c true if object can be renamed
 */
 bool VisuGUI::renameAllowed( const QString& entry) const {  
-  bool appRes = SalomeApp_Module::renameAllowed(entry);
-  if( !appRes )
+  
+  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;
@@ -4999,10 +5008,24 @@ void VisuGUI::OnShowDeviation() {
   \brief Return \c true if rename operation finished successfully, \c false otherwise.
 */
 bool VisuGUI::renameObject( const QString& entry, const QString& name) {    
-  bool appRes = SalomeApp_Module::renameObject(entry, name);
-  if( !appRes )
+
+  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;