From: rnv Date: Wed, 7 Mar 2012 11:40:47 +0000 (+0000) Subject: Forbid renaming of the objects "in place" by default. X-Git-Tag: V6_5_0a1~81 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e30138815a3c6fa984427073edde4ded8fba1121;p=modules%2Fsmesh.git Forbid renaming of the objects "in place" by default. --- diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx index a3a601a83..6de6c06a1 100644 --- a/src/SMESHGUI/SMESHGUI.cxx +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -99,6 +99,7 @@ #include #include #include +#include #include #include @@ -5971,16 +5972,20 @@ bool SMESHGUI::renameAllowed( const QString& entry) const { if( !anApp ) return false; - _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active - if( !aStudy ) + SalomeApp_Study* appStudy = dynamic_cast( anApp->activeStudy() ); + if( !appStudy ) + return false; + + SalomeApp_DataObject* obj = dynamic_cast(appStudy->findObjectByEntry(entry)); + + if(!obj) return false; - bool appRes = SalomeApp_Module::renameAllowed(entry); - if( !appRes ) + if(appStudy->isComponent(entry) || obj->isReference()) return false; // check type to prevent renaming of inappropriate objects - int aType = SMESHGUI_Selection::type(qPrintable(entry), aStudy); + int aType = SMESHGUI_Selection::type(qPrintable(entry), SMESH::GetActiveStudyDocument()); if (aType == MESH || aType == GROUP || aType == SUBMESH || aType == SUBMESH_COMPOUND || aType == SUBMESH_SOLID || aType == SUBMESH_FACE || @@ -6002,14 +6007,23 @@ bool SMESHGUI::renameObject( const QString& entry, const QString& name) { SalomeApp_Application* anApp = dynamic_cast( application() ); if( !anApp ) return false; + + SalomeApp_Study* appStudy = dynamic_cast( anApp->activeStudy() ); - _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active - if( !aStudy ) + if(!appStudy) return false; - - bool appRes = SalomeApp_Module::renameObject(entry,name); - if( !appRes ) + + _PTR(Study) aStudy = appStudy->studyDS(); + + if(!aStudy) + return false; + + bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked(); + if ( aLocked ) { + SUIT_MessageBox::warning ( anApp->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") ); return false; + } + _PTR(SObject) obj = aStudy->FindObjectID( qPrintable(entry) ); _PTR(GenericAttribute) anAttr; @@ -6018,7 +6032,7 @@ bool SMESHGUI::renameObject( const QString& entry, const QString& name) { if ( obj->FindAttribute(anAttr, "AttributeName") ) { aName = anAttr; // check type to prevent renaming of inappropriate objects - int aType = SMESHGUI_Selection::type( qPrintable(entry), aStudy ); + int aType = SMESHGUI_Selection::type( qPrintable(entry), SMESH::GetActiveStudyDocument() ); if (aType == MESH || aType == GROUP || aType == SUBMESH || aType == SUBMESH_COMPOUND || aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||