Implementation "21042: EDF 1600 ALL: Rename objects in the OB" issue.

This commit is contained in:
rnv 2011-04-05 09:24:16 +00:00
parent c6ef193762
commit bda9b5412a
6 changed files with 46 additions and 73 deletions

View File

@ -54,6 +54,7 @@
#include <SVTK_ViewModel.h>
#include <SalomeApp_Application.h>
#include <SalomeApp_DataObject.h>
#include <SalomeApp_Study.h>
#include <LightApp_SelectionMgr.h>
@ -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<int> 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<SalomeApp_Study*>( 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;
}

View File

@ -124,6 +124,8 @@ public:
gp_Ax3 GetWorkingPlane() { return myWorkingPlane; }
void ActiveWorkingPlane();
virtual bool renameObject( const QString&, const QString& );
virtual void windows( QMap<int, int>& ) const;
virtual void viewManagers( QStringList& ) const;

View File

@ -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

View File

@ -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;

View File

@ -60,8 +60,6 @@ private:
bool Export();
void OnEditDelete();
void OnRename();
void OnCheckGeometry();
// Popup commands

View File

@ -91,65 +91,6 @@
// VTK includes
#include <vtkRenderer.h>
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<SalomeApp_Study*>( 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<SalomeApp_Module*>(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()
{