From: rnv Date: Tue, 5 Apr 2011 09:24:16 +0000 (+0000) Subject: Implementation "21042: EDF 1600 ALL: Rename objects in the OB" issue. X-Git-Tag: V6_3_0a1~14 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=bda9b5412aded730d1703993b36b26ae942699a0;p=modules%2Fgeom.git Implementation "21042: EDF 1600 ALL: Rename objects in the OB" issue. --- diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx index 4ecb54520..5d15de5e2 100644 --- a/src/GEOMGUI/GeometryGUI.cxx +++ b/src/GEOMGUI/GeometryGUI.cxx @@ -54,6 +54,7 @@ #include #include +#include #include #include @@ -352,8 +353,7 @@ void GeometryGUI::OnGUIEvent( int id ) // if current viewframe is not of OCC and not of VTK type - return immediately // fix for IPAL8958 - allow some commands to execute even when NO viewer is active (rename for example) QList NotViewerDependentCommands; - NotViewerDependentCommands << GEOMOp::OpRename - << GEOMOp::OpDelete + NotViewerDependentCommands << GEOMOp::OpDelete << GEOMOp::OpShow << GEOMOp::OpShowOnly << GEOMOp::OpShowChildren @@ -403,7 +403,6 @@ void GeometryGUI::OnGUIEvent( int id ) case GEOMOp::OpUnpublishObject: // POPUP MENU - UNPUBLISH case GEOMOp::OpPublishObject: // ROOT GEOM OBJECT - POPUP MENU - PUBLISH case GEOMOp::OpPointMarker: // POPUP MENU - POINT MARKER - case GEOMOp::OpRename: // POPUP MENU - RENAME libName = "GEOMToolsGUI"; break; case GEOMOp::OpDisplayMode: // MENU VIEW - WIREFRAME/SHADING @@ -776,7 +775,6 @@ void GeometryGUI::initialize( CAM_Application* app ) createGeomAction( GEOMOp::OpShowOnly, "DISPLAY_ONLY" ); createGeomAction( GEOMOp::OpHide, "ERASE" ); - createGeomAction( GEOMOp::OpRename, "POP_RENAME", "", Qt::Key_F2 ); createGeomAction( GEOMOp::OpWireframe, "POP_WIREFRAME", "", 0, true ); createGeomAction( GEOMOp::OpShading, "POP_SHADING", "", 0, true ); createGeomAction( GEOMOp::OpVectors, "POP_VECTORS", "", 0, true ); @@ -1100,8 +1098,6 @@ void GeometryGUI::initialize( CAM_Application* app ) QtxPopupMgr* mgr = popupMgr(); - mgr->insert( action( GEOMOp::OpRename ), -1, -1 ); // rename - mgr->setRule( action( GEOMOp::OpRename ), QString("$type in {'Shape' 'Group'} and selcount=1"), QtxPopupMgr::VisibleRule ); mgr->insert( action( GEOMOp::OpDelete ), -1, -1 ); // delete mgr->setRule( action( GEOMOp::OpDelete ), QString("$type in {'Shape' 'Group'} and selcount>0"), QtxPopupMgr::VisibleRule ); mgr->insert( action( GEOMOp::OpGroupCreatePopup ), -1, -1 ); // create group @@ -1240,7 +1236,6 @@ bool GeometryGUI::activateModule( SUIT_Study* study ) action(GEOMOp::OpImport)->setEnabled( true ); // Import: CTRL + Key_I action(GEOMOp::OpExport)->setEnabled( true ); // Export: CTRL + Key_E action(GEOMOp::OpDelete)->setEnabled( true ); // Delete: Key_Delete - action(GEOMOp::OpRename)->setEnabled( true ); // Rename: Key_F2 GUIMap::Iterator it; for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it ) @@ -1330,7 +1325,6 @@ bool GeometryGUI::deactivateModule( SUIT_Study* study ) action(GEOMOp::OpImport)->setEnabled( false ); // Import: CTRL + Key_I action(GEOMOp::OpExport)->setEnabled( false ); // Export: CTRL + Key_E action(GEOMOp::OpDelete)->setEnabled( false ); // Delete: Key_Delete - action(GEOMOp::OpRename)->setEnabled( false ); // Rename: Key_F2 qDeleteAll(myOCCSelectors); myOCCSelectors.clear(); @@ -1955,3 +1949,45 @@ void GeometryGUI::onViewAboutToShow() a->setEnabled(false); } } + +/*! + 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 GeometryGUI::renameObject( const QString& entry, const QString& name) { + + bool appRes = SalomeApp_Module::renameObject(entry,name); + if( !appRes ) + return false; + + bool result = false; + + SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication()); + SalomeApp_Study* appStudy = app ? dynamic_cast( app->activeStudy() ) : 0; + + if(!appStudy) + return result; + + _PTR(Study) aStudy = appStudy->studyDS(); + + if(!aStudy) + return result; + + _PTR(SObject) obj ( aStudy->FindObjectID(qPrintable(entry)) ); + _PTR(GenericAttribute) anAttr; + if ( obj ) { + if ( obj->FindAttribute(anAttr, "AttributeName") ) { + _PTR(AttributeName) aName (anAttr); + + GEOM::GEOM_Object_var anObj = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(obj)); + if (!CORBA::is_nil(anObj)) { + aName->SetValue( name.toLatin1().data() ); // rename the SObject + anObj->SetName( name.toLatin1().data() ); // Rename the corresponding GEOM_Object + result = true; + } + } + } + return result; +} diff --git a/src/GEOMGUI/GeometryGUI.h b/src/GEOMGUI/GeometryGUI.h index 2688dcc55..3899253f0 100644 --- a/src/GEOMGUI/GeometryGUI.h +++ b/src/GEOMGUI/GeometryGUI.h @@ -124,6 +124,8 @@ public: gp_Ax3 GetWorkingPlane() { return myWorkingPlane; } void ActiveWorkingPlane(); + virtual bool renameObject( const QString&, const QString& ); + virtual void windows( QMap& ) const; virtual void viewManagers( QStringList& ) const; diff --git a/src/GEOMGUI/GeometryGUI_Operations.h b/src/GEOMGUI/GeometryGUI_Operations.h index 4d86e9bdd..24da14bed 100644 --- a/src/GEOMGUI/GeometryGUI_Operations.h +++ b/src/GEOMGUI/GeometryGUI_Operations.h @@ -50,7 +50,6 @@ namespace GEOMOp { OpPointMarker = 1210, // POPUP MENU - POINT MARKER OpShowChildren = 1250, // POPUP MENU - SHOW CHILDREN OpHideChildren = 1251, // POPUP MENU - HIDE CHILDREN - OpRename = 1252, // POPUP MENU - RENAME OpUnpublishObject = 1253, // POPUP MENU - UNPUBLISH OpPublishObject = 1254, // GEOM ROOT OBJECT - POPUP MENU - PUBLISH diff --git a/src/GEOMToolsGUI/GEOMToolsGUI.cxx b/src/GEOMToolsGUI/GEOMToolsGUI.cxx index cbde99ce1..f32ee0896 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI.cxx +++ b/src/GEOMToolsGUI/GEOMToolsGUI.cxx @@ -322,9 +322,6 @@ bool GEOMToolsGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent) case GEOMOp::OpSelectAll: // POPUP - SELECT ONLY - SELECT ALL OnSelectOnly( GEOM_ALLOBJECTS ); break; - case GEOMOp::OpRename: // POPUP - RENAME - OnRename(); - break; case GEOMOp::OpDeflection: // POPUP - DEFLECTION ANGLE OnDeflection(); break; diff --git a/src/GEOMToolsGUI/GEOMToolsGUI.h b/src/GEOMToolsGUI/GEOMToolsGUI.h index 25516496a..5cff2ef45 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI.h +++ b/src/GEOMToolsGUI/GEOMToolsGUI.h @@ -60,8 +60,6 @@ private: bool Export(); void OnEditDelete(); - - void OnRename(); void OnCheckGeometry(); // Popup commands diff --git a/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx b/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx index 8f434de96..278e4785f 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx +++ b/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx @@ -91,65 +91,6 @@ // VTK includes #include -void GEOMToolsGUI::OnRename() -{ - SALOME_ListIO selected; - SalomeApp_Application* app = - dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); - if ( app ) { - LightApp_SelectionMgr* aSelMgr = app->selectionMgr(); - SalomeApp_Study* appStudy = dynamic_cast( app->activeStudy() ); - if ( aSelMgr && appStudy ) { - aSelMgr->selectedObjects( selected ); - if ( !selected.IsEmpty() ) { - _PTR(Study) aStudy = appStudy->studyDS(); - - bool aLocked = (_PTR(AttributeStudyProperties)(aStudy->GetProperties()))->IsLocked(); - if ( aLocked ) { - SUIT_MessageBox::warning ( app->desktop(), - QObject::tr("WRN_WARNING"), - QObject::tr("WRN_STUDY_LOCKED") ); - return; - } - - bool isAny = false; // is there any appropriate object selected - for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) { - Handle(SALOME_InteractiveObject) IObject = It.Value(); - - _PTR(SObject) obj ( aStudy->FindObjectID(IObject->getEntry()) ); - _PTR(GenericAttribute) anAttr; - if ( obj ) { - if ( obj->FindAttribute(anAttr, "AttributeName") ) { - _PTR(AttributeName) aName (anAttr); - - GEOM::GEOM_Object_var anObj = - GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(obj)); - if (!CORBA::is_nil(anObj)) { - isAny = true; - QString newName = LightApp_NameDlg::getName( app->desktop(), aName->Value().c_str() ); - if (!newName.isEmpty()) { - aName->SetValue( newName.toLatin1().data() ); // rename the SObject - IObject->setName( newName.toLatin1().data() );// rename the InteractiveObject - anObj->SetName( newName.toLatin1().data() ); // Rename the corresponding GEOM_Object - (dynamic_cast(app->activeModule()))->updateObjBrowser( false ); - } - } // if ( anObj ) - } // if ( name attribute ) - } // if ( obj ) - } // iterator - - if (!isAny) { - SUIT_MessageBox::warning( app->desktop(), - QObject::tr("WRN_WARNING"), - QObject::tr("GEOM_WRN_NO_APPROPRIATE_SELECTION") ); - return; - } - } - } - } - - app->updateActions(); //SRN: To update a Save button in the toolbar -} void GEOMToolsGUI::OnCheckGeometry() {