mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-02-12 00:23:06 +05:00
Implementation "21042: EDF 1600 ALL: Rename objects in the OB" issue.
This commit is contained in:
parent
c6ef193762
commit
bda9b5412a
@ -54,6 +54,7 @@
|
|||||||
#include <SVTK_ViewModel.h>
|
#include <SVTK_ViewModel.h>
|
||||||
|
|
||||||
#include <SalomeApp_Application.h>
|
#include <SalomeApp_Application.h>
|
||||||
|
#include <SalomeApp_DataObject.h>
|
||||||
#include <SalomeApp_Study.h>
|
#include <SalomeApp_Study.h>
|
||||||
|
|
||||||
#include <LightApp_SelectionMgr.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
|
// 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)
|
// fix for IPAL8958 - allow some commands to execute even when NO viewer is active (rename for example)
|
||||||
QList<int> NotViewerDependentCommands;
|
QList<int> NotViewerDependentCommands;
|
||||||
NotViewerDependentCommands << GEOMOp::OpRename
|
NotViewerDependentCommands << GEOMOp::OpDelete
|
||||||
<< GEOMOp::OpDelete
|
|
||||||
<< GEOMOp::OpShow
|
<< GEOMOp::OpShow
|
||||||
<< GEOMOp::OpShowOnly
|
<< GEOMOp::OpShowOnly
|
||||||
<< GEOMOp::OpShowChildren
|
<< GEOMOp::OpShowChildren
|
||||||
@ -403,7 +403,6 @@ void GeometryGUI::OnGUIEvent( int id )
|
|||||||
case GEOMOp::OpUnpublishObject: // POPUP MENU - UNPUBLISH
|
case GEOMOp::OpUnpublishObject: // POPUP MENU - UNPUBLISH
|
||||||
case GEOMOp::OpPublishObject: // ROOT GEOM OBJECT - POPUP MENU - PUBLISH
|
case GEOMOp::OpPublishObject: // ROOT GEOM OBJECT - POPUP MENU - PUBLISH
|
||||||
case GEOMOp::OpPointMarker: // POPUP MENU - POINT MARKER
|
case GEOMOp::OpPointMarker: // POPUP MENU - POINT MARKER
|
||||||
case GEOMOp::OpRename: // POPUP MENU - RENAME
|
|
||||||
libName = "GEOMToolsGUI";
|
libName = "GEOMToolsGUI";
|
||||||
break;
|
break;
|
||||||
case GEOMOp::OpDisplayMode: // MENU VIEW - WIREFRAME/SHADING
|
case GEOMOp::OpDisplayMode: // MENU VIEW - WIREFRAME/SHADING
|
||||||
@ -776,7 +775,6 @@ void GeometryGUI::initialize( CAM_Application* app )
|
|||||||
createGeomAction( GEOMOp::OpShowOnly, "DISPLAY_ONLY" );
|
createGeomAction( GEOMOp::OpShowOnly, "DISPLAY_ONLY" );
|
||||||
createGeomAction( GEOMOp::OpHide, "ERASE" );
|
createGeomAction( GEOMOp::OpHide, "ERASE" );
|
||||||
|
|
||||||
createGeomAction( GEOMOp::OpRename, "POP_RENAME", "", Qt::Key_F2 );
|
|
||||||
createGeomAction( GEOMOp::OpWireframe, "POP_WIREFRAME", "", 0, true );
|
createGeomAction( GEOMOp::OpWireframe, "POP_WIREFRAME", "", 0, true );
|
||||||
createGeomAction( GEOMOp::OpShading, "POP_SHADING", "", 0, true );
|
createGeomAction( GEOMOp::OpShading, "POP_SHADING", "", 0, true );
|
||||||
createGeomAction( GEOMOp::OpVectors, "POP_VECTORS", "", 0, true );
|
createGeomAction( GEOMOp::OpVectors, "POP_VECTORS", "", 0, true );
|
||||||
@ -1100,8 +1098,6 @@ void GeometryGUI::initialize( CAM_Application* app )
|
|||||||
|
|
||||||
QtxPopupMgr* mgr = popupMgr();
|
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->insert( action( GEOMOp::OpDelete ), -1, -1 ); // delete
|
||||||
mgr->setRule( action( GEOMOp::OpDelete ), QString("$type in {'Shape' 'Group'} and selcount>0"), QtxPopupMgr::VisibleRule );
|
mgr->setRule( action( GEOMOp::OpDelete ), QString("$type in {'Shape' 'Group'} and selcount>0"), QtxPopupMgr::VisibleRule );
|
||||||
mgr->insert( action( GEOMOp::OpGroupCreatePopup ), -1, -1 ); // create group
|
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::OpImport)->setEnabled( true ); // Import: CTRL + Key_I
|
||||||
action(GEOMOp::OpExport)->setEnabled( true ); // Export: CTRL + Key_E
|
action(GEOMOp::OpExport)->setEnabled( true ); // Export: CTRL + Key_E
|
||||||
action(GEOMOp::OpDelete)->setEnabled( true ); // Delete: Key_Delete
|
action(GEOMOp::OpDelete)->setEnabled( true ); // Delete: Key_Delete
|
||||||
action(GEOMOp::OpRename)->setEnabled( true ); // Rename: Key_F2
|
|
||||||
|
|
||||||
GUIMap::Iterator it;
|
GUIMap::Iterator it;
|
||||||
for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++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::OpImport)->setEnabled( false ); // Import: CTRL + Key_I
|
||||||
action(GEOMOp::OpExport)->setEnabled( false ); // Export: CTRL + Key_E
|
action(GEOMOp::OpExport)->setEnabled( false ); // Export: CTRL + Key_E
|
||||||
action(GEOMOp::OpDelete)->setEnabled( false ); // Delete: Key_Delete
|
action(GEOMOp::OpDelete)->setEnabled( false ); // Delete: Key_Delete
|
||||||
action(GEOMOp::OpRename)->setEnabled( false ); // Rename: Key_F2
|
|
||||||
|
|
||||||
qDeleteAll(myOCCSelectors);
|
qDeleteAll(myOCCSelectors);
|
||||||
myOCCSelectors.clear();
|
myOCCSelectors.clear();
|
||||||
@ -1955,3 +1949,45 @@ void GeometryGUI::onViewAboutToShow()
|
|||||||
a->setEnabled(false);
|
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;
|
||||||
|
}
|
||||||
|
@ -124,6 +124,8 @@ public:
|
|||||||
gp_Ax3 GetWorkingPlane() { return myWorkingPlane; }
|
gp_Ax3 GetWorkingPlane() { return myWorkingPlane; }
|
||||||
void ActiveWorkingPlane();
|
void ActiveWorkingPlane();
|
||||||
|
|
||||||
|
virtual bool renameObject( const QString&, const QString& );
|
||||||
|
|
||||||
virtual void windows( QMap<int, int>& ) const;
|
virtual void windows( QMap<int, int>& ) const;
|
||||||
virtual void viewManagers( QStringList& ) const;
|
virtual void viewManagers( QStringList& ) const;
|
||||||
|
|
||||||
|
@ -50,7 +50,6 @@ namespace GEOMOp {
|
|||||||
OpPointMarker = 1210, // POPUP MENU - POINT MARKER
|
OpPointMarker = 1210, // POPUP MENU - POINT MARKER
|
||||||
OpShowChildren = 1250, // POPUP MENU - SHOW CHILDREN
|
OpShowChildren = 1250, // POPUP MENU - SHOW CHILDREN
|
||||||
OpHideChildren = 1251, // POPUP MENU - HIDE CHILDREN
|
OpHideChildren = 1251, // POPUP MENU - HIDE CHILDREN
|
||||||
OpRename = 1252, // POPUP MENU - RENAME
|
|
||||||
OpUnpublishObject = 1253, // POPUP MENU - UNPUBLISH
|
OpUnpublishObject = 1253, // POPUP MENU - UNPUBLISH
|
||||||
OpPublishObject = 1254, // GEOM ROOT OBJECT - POPUP MENU - PUBLISH
|
OpPublishObject = 1254, // GEOM ROOT OBJECT - POPUP MENU - PUBLISH
|
||||||
|
|
||||||
|
@ -322,9 +322,6 @@ bool GEOMToolsGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent)
|
|||||||
case GEOMOp::OpSelectAll: // POPUP - SELECT ONLY - SELECT ALL
|
case GEOMOp::OpSelectAll: // POPUP - SELECT ONLY - SELECT ALL
|
||||||
OnSelectOnly( GEOM_ALLOBJECTS );
|
OnSelectOnly( GEOM_ALLOBJECTS );
|
||||||
break;
|
break;
|
||||||
case GEOMOp::OpRename: // POPUP - RENAME
|
|
||||||
OnRename();
|
|
||||||
break;
|
|
||||||
case GEOMOp::OpDeflection: // POPUP - DEFLECTION ANGLE
|
case GEOMOp::OpDeflection: // POPUP - DEFLECTION ANGLE
|
||||||
OnDeflection();
|
OnDeflection();
|
||||||
break;
|
break;
|
||||||
|
@ -60,8 +60,6 @@ private:
|
|||||||
bool Export();
|
bool Export();
|
||||||
|
|
||||||
void OnEditDelete();
|
void OnEditDelete();
|
||||||
|
|
||||||
void OnRename();
|
|
||||||
void OnCheckGeometry();
|
void OnCheckGeometry();
|
||||||
|
|
||||||
// Popup commands
|
// Popup commands
|
||||||
|
@ -91,65 +91,6 @@
|
|||||||
// VTK includes
|
// VTK includes
|
||||||
#include <vtkRenderer.h>
|
#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()
|
void GEOMToolsGUI::OnCheckGeometry()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user