From: rnv Date: Wed, 7 Mar 2012 11:39:45 +0000 (+0000) Subject: Forbid renaming of the objects "in place" by default. X-Git-Tag: V6_main_20120312 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d8820abdefdd42926ed4554125e158617e75e977;p=modules%2Fvisu.git Forbid renaming of the objects "in place" by default. --- diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 7a83d56e..31d5ba4e 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -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( app->activeStudy() ) : 0; + SalomeApp_DataObject* obj = appStudy ? dynamic_cast(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( 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;