From: rnv Date: Tue, 5 Apr 2011 09:26:20 +0000 (+0000) Subject: Implementation "21042: EDF 1600 ALL: Rename objects in the OB" issue. X-Git-Tag: before_mergefrom_PortingMED3_07Apr11 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=9abf506973f8c4644f60734509fb10fea70130f2;p=modules%2Fvisu.git Implementation "21042: EDF 1600 ALL: Rename objects in the OB" issue. --- diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index a60d3e78..4420fdfd 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -2040,109 +2040,6 @@ VisuGUI VISU::View3D_i::RestoreViewParams(aViewMgr, aSObj->GetName().c_str());//jfa tmp } -//---------------------------------------------------------------------------- -void -VisuGUI -::OnRename() -{ - _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this)); - if (CheckLock(aCStudy,GetDesktop(this))) - return; - - VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this); - if (aSelectionInfo.empty()) - return; - - VisuGUI_Selection aSel (this); - aSel.init("", getApp()->selectionMgr()); - if (aSel.count() < 1) return; - - bool isAny = false; // is there any appropriate object selected - for (int i = 0; i < aSelectionInfo.size(); i++) { - VISU::TSelectionItem aSelectionItem = aSelectionInfo[i]; - VISU::TObjectInfo anObjectInfo = aSelectionItem.myObjectInfo; - - _PTR(SObject) aSObject = anObjectInfo.mySObject; - if (!aSObject) - continue; - - // Check, if the selected object can be renamed - QString aStr = aSel.parameter(i, "type" ).toString(); - if (aStr == "VISU::TSCALARMAP" || aStr == "VISU::TISOSURFACES" || - aStr == "VISU::TDEFORMEDSHAPE" || aStr == "VISU::TCUTPLANES" || - aStr == "VISU::TCUTLINES" || aStr == "VISU::TCUTSEGMENT" || aStr == "VISU::TVECTORS" || - aStr == "VISU::TSTREAMLINES" || aStr == "VISU::TPLOT3D" || - aStr == "VISU::TSCALARMAPONDEFORMEDSHAPE" || aStr == "VISU::TCOLOREDPRS3DHOLDER" || - aStr == "VISU::TTABLE" || aStr == "VISU::TCURVE" || aStr == "VISU::TCONTAINER" || - aStr == "VISU::POINTMAP3D" || aStr == "VISU::TVIEW3D" || - aStr == "VISU::TPOINTMAP3D" || aStr == "VISU::TGAUSSPOINTS") - { - _PTR(GenericAttribute) anAttr; - if (aSObject->FindAttribute(anAttr, "AttributeName")) { - isAny = true; - _PTR(AttributeName) aName (anAttr); - QString Name = VisuGUI_NameDlg::getName( GetDesktop( this ), aName->Value().c_str() ); - if (!Name.isEmpty()) { - QApplication::setOverrideCursor(Qt::WaitCursor); - - // rename specific objects - if (VISU::Base_i* aBase = anObjectInfo.myBase) { - switch (aBase->GetType()) { - case VISU::TCURVE: { // Curve object - if (VISU::Curve_i* aCurve = dynamic_cast(aBase)) - aCurve->SetName(Name.toLatin1().constData(), true); - break; - } - case VISU::TTABLE: { // Table object - if (VISU::Table_i* aTable = dynamic_cast(aBase)) - aTable->SetName(Name.toLatin1().constData(), true); - break; - } - case VISU::TPOINTMAP3D: { // Table object - if (VISU::PointMap3d_i* aTable3d = dynamic_cast(aBase)) { - aTable3d->SetTitle(Name.toLatin1().constData()); - aTable3d->UpdateActors(); - } - break; - } - case VISU::TCONTAINER: { // Container object - if (VISU::Container_i* aContainer = dynamic_cast(aBase)) - aContainer->SetName(Name.toLatin1().constData(), true); - break; - } - default: { - }} - } - - // rename the study object - Handle(SALOME_InteractiveObject) anIO = aSelectionItem.myIO; - aName->SetValue(Name.toLatin1().constData()); // rename the SObject - anIO->setName(Name.toLatin1().constData()); // rename the InteractiveObject - - ViewManagerList aViewManagerList; - getApp()->viewManagers(SPlot2d_Viewer::Type(), aViewManagerList); - SUIT_ViewManager* aViewManager; - foreach( aViewManager, aViewManagerList ) { - if (Plot2d_ViewManager* aManager = dynamic_cast(aViewManager)) { - if (SPlot2d_Viewer* aViewer = dynamic_cast(aManager->getViewModel())) - aViewer->renameAll( anIO, Name.toLatin1().constData() ); - } - } - - UpdateObjBrowser(this, false); - QApplication::restoreOverrideCursor(); - } - } - } - } // for - - if (!isAny) { - SUIT_MessageBox::warning(GetDesktop(this), - QObject::tr("WRN_VISU"), - QObject::tr("WRN_NO_APPROPRIATE_SELECTION")); - } -} - //---------------------------------------------------------------------------- void VisuGUI @@ -2724,10 +2621,6 @@ VisuGUI tr("MEN_CURVE_PROPS"), "", 0, aParent, false, this, SLOT(OnCurveProperties())); - createAction( VISU_RENAME, tr("MEN_RENAME"), QIcon(), - tr("MEN_RENAME"), "", Qt::Key_F2, aParent, false, - this, SLOT(OnRename())); - createAction( VISU_EDIT_CONTAINER, tr("MEN_EDIT_CONTAINER"), QIcon(), tr("MEN_EDIT_CONTAINER"), "", 0, aParent, false, this, SLOT(OnEditContainer())); @@ -3120,9 +3013,6 @@ VisuGUI mgr->insert( action( VISU_FILTERSCALARS ), -1, -1, -1 ); - // rename - mgr->insert( action( VISU_RENAME ), -1, -1, -1 ); - // copy mgr->insert( action( VISU_COPY_PRS ), -1, -1, -1 ); @@ -3360,12 +3250,8 @@ VisuGUI mgr->setRule( action( VISU_POINT_MARKER ), aRule + aLineType + " and hasActor=1 and representation='VISU::POINT'" ); mgr->setRule( action( VISU_SHRINK_FACTOR ), aRule + aShrinkType + " and isShrunk=1" ); - // rename command QString aCurveAll = "'VISU::TTABLE' 'VISU::TCURVE' 'VISU::TCONTAINER' 'VISU::POINTMAP3D'"; - aRule = "selcount=1 and ($type in {'VISU::TVIEW3D' 'VISU::TPOINTMAP3D' " + aCurveAll + " " + aPrsAll + "})"; - mgr->setRule( action( VISU_RENAME ), aRule ); - // copy presentation command aRule = "selcount=1 and ($type in {" + aPrsAll + "})"; mgr->setRule( action( VISU_COPY_PRS ), aRule ); @@ -3704,7 +3590,6 @@ VisuGUI action(VISU_IMPORT_FROM_FILE)->setShortcuts(shortcuts); action(VISU_DELETE_OBJS)->setEnabled(true); // Delete: Key_Delete - action(VISU_RENAME )->setEnabled(true); // Rename: Key_F2 ((VisuGUI_ClippingPanel*) myPanels[ClippingPlanesPanelId])->init(); GetVisuGen( this )->GetClippingPlaneMgr().SetStudy(GetCStudy(dynamic_cast(theStudy)),true); @@ -3725,7 +3610,6 @@ VisuGUI action(VISU_IMPORT_FROM_FILE)->setShortcuts(QKeySequence::UnknownKey); // Import: CTRL + Key_I action(VISU_DELETE_OBJS)->setEnabled(false); // Delete: Key_Delete - action(VISU_RENAME )->setEnabled(false); // Rename: Key_F2 bool aResult = SalomeApp_Module::deactivateModule( theStudy ); @@ -4865,3 +4749,122 @@ void VisuGUI::OnArcQuadMode(){ void VisuGUI::OnLineQuadMode(){ ChangeQuadratic2DRepresentation(this,VISU::LINES); } + +/*! + \brief Return \c true if object can be renamed +*/ +bool VisuGUI::renameAllowed( const QString& entry) const { + bool appRes = SalomeApp_Module::renameAllowed(entry); + if( !appRes ) + return false; + + VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry( GetAppStudy(this), qPrintable(entry) ); + VISU::Base_i* aBase = anObjectInfo.myBase; + if(aBase){ + VISU::VISUType aType = aBase->GetType(); + if( aType == VISU::TCOLOREDPRS3DHOLDER ) { + CORBA::Object_var anObject = ClientSObjectToObject(anObjectInfo.mySObject); + VISU::ColoredPrs3dHolder_var aHolder = VISU::ColoredPrs3dHolder::_narrow(anObject); + aType = aHolder->GetPrsType(); + } + if (aType == VISU::TSCALARMAP || aType == VISU::TISOSURFACES || + aType == VISU::TDEFORMEDSHAPE || aType == VISU::TCUTPLANES || + aType == VISU::TCUTLINES || aType == VISU::TCUTSEGMENT || aType == VISU::TVECTORS || + aType == VISU::TSTREAMLINES || aType == VISU::TPLOT3D || + aType == VISU::TSCALARMAPONDEFORMEDSHAPE || aType == VISU::TCOLOREDPRS3DHOLDER || + aType == VISU::TTABLE || aType == VISU::TCURVE || aType == VISU::TCONTAINER || + aType == VISU::TPOINTMAP3D || aType == VISU::TVIEW3D || + aType == VISU::TPOINTMAP3D || aType == VISU::TGAUSSPOINTS) + return true; + } + return 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 VisuGUI::renameObject( const QString& entry, const QString& name) { + bool appRes = SalomeApp_Module::renameObject(entry, name); + if( !appRes ) + return false; + + VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(GetAppStudy(this) , qPrintable(entry) ); + + _PTR(SObject) aSObject = anObjectInfo.mySObject; + if (aSObject) { + VISU::Base_i* aBase = anObjectInfo.myBase; + if(aBase){ + VISU::VISUType aType = aBase->GetType(); + if( aType == VISU::TCOLOREDPRS3DHOLDER ) { + CORBA::Object_var anObject = ClientSObjectToObject(anObjectInfo.mySObject); + VISU::ColoredPrs3dHolder_var aHolder = VISU::ColoredPrs3dHolder::_narrow(anObject); + aType = aHolder->GetPrsType(); + } + if (aType == VISU::TSCALARMAP || aType == VISU::TISOSURFACES || + aType == VISU::TDEFORMEDSHAPE || aType == VISU::TCUTPLANES || + aType == VISU::TCUTLINES || aType == VISU::TCUTSEGMENT || aType == VISU::TVECTORS || + aType == VISU::TSTREAMLINES || aType == VISU::TPLOT3D || + aType == VISU::TSCALARMAPONDEFORMEDSHAPE || aType == VISU::TCOLOREDPRS3DHOLDER || + aType == VISU::TTABLE || aType == VISU::TCURVE || aType == VISU::TCONTAINER || + aType == VISU::TPOINTMAP3D || aType == VISU::TVIEW3D || + aType == VISU::TPOINTMAP3D || aType == VISU::TGAUSSPOINTS) { + _PTR(GenericAttribute) anAttr; + if (aSObject->FindAttribute(anAttr, "AttributeName")) { + _PTR(AttributeName) aName (anAttr); + if (!name.isEmpty()) { + QApplication::setOverrideCursor(Qt::WaitCursor); + // rename specific objects + if (VISU::Base_i* aBase = anObjectInfo.myBase) { + switch (aBase->GetType()) { + case VISU::TCURVE: { // Curve object + if (VISU::Curve_i* aCurve = dynamic_cast(aBase)) + aCurve->SetName(qPrintable(name), true); + break; + } + case VISU::TTABLE: { // Table object + if (VISU::Table_i* aTable = dynamic_cast(aBase)) + aTable->SetName(qPrintable(name), true); + break; + } + case VISU::TPOINTMAP3D: { // Table object + if (VISU::PointMap3d_i* aTable3d = dynamic_cast(aBase)) { + aTable3d->SetTitle(qPrintable(name)); + aTable3d->UpdateActors(); + } + break; + } + case VISU::TCONTAINER: { // Container object + if (VISU::Container_i* aContainer = dynamic_cast(aBase)) + aContainer->SetName(qPrintable(name), true); + break; + } + default: { + }} + } + + // rename the study object + aName->SetValue( qPrintable(name) ); // rename the SObject + + ViewManagerList aViewManagerList; + getApp()->viewManagers(SPlot2d_Viewer::Type(), aViewManagerList); + SUIT_ViewManager* aViewManager; + Handle(SALOME_InteractiveObject) anIO = + new SALOME_InteractiveObject ( qPrintable(entry), "VISU", qPrintable(name) ); + foreach( aViewManager, aViewManagerList ) { + if (Plot2d_ViewManager* aManager = dynamic_cast(aViewManager)) { + if (SPlot2d_Viewer* aViewer = dynamic_cast(aManager->getViewModel())) + aViewer->renameAll( anIO, qPrintable(name) ); + } + } + QApplication::restoreOverrideCursor(); + return true; + } + } + } + } + } + return false; +} diff --git a/src/VISUGUI/VisuGUI.h b/src/VISUGUI/VisuGUI.h index 1d7e3e10..05c61184 100644 --- a/src/VISUGUI/VisuGUI.h +++ b/src/VISUGUI/VisuGUI.h @@ -85,6 +85,10 @@ public: VISU::TViewToPrs3d& getScalarBarsMap(); + virtual bool renameAllowed( const QString& ) const; + virtual bool renameObject( const QString&, const QString& ); + + signals: void moduleDeactivated(); void moduleActivated(); @@ -174,7 +178,6 @@ protected slots: virtual void OnSaveViewParams(); virtual void OnRestoreViewParams(); - void OnRename(); void OnClippingPlanes(); void OnSweep(); void OnParallelTimeAnimation(); diff --git a/src/VISUGUI/VisuGUI_ActionsDef.h b/src/VISUGUI/VisuGUI_ActionsDef.h index c474c082..62b52c3c 100644 --- a/src/VISUGUI/VisuGUI_ActionsDef.h +++ b/src/VISUGUI/VisuGUI_ActionsDef.h @@ -65,7 +65,6 @@ #define VISU_COPY_PRS 4037 #define VISU_CURVE_PROPS 4040 -#define VISU_RENAME 4041 #define VISU_EDIT_CONTAINER 4042 #define VISU_CLEAR_CONTAINER 4043 diff --git a/src/VISUGUI/VisuGUI_Module.cxx b/src/VISUGUI/VisuGUI_Module.cxx index 7da3b5ea..6eb9146a 100644 --- a/src/VISUGUI/VisuGUI_Module.cxx +++ b/src/VISUGUI/VisuGUI_Module.cxx @@ -143,10 +143,10 @@ static int MYDEBUG = 0; #define GAUSS_DISPLAY_PRS 5500 #define GAUSS_DISPLAY_ONLY_PRS 5600 -#define GAUSS_SAVE_CONFIGURATION 5700 -#define GAUSS_OVERWRITE_CONFIGURATION 5701 -#define GAUSS_RESTORE_CONFIGURATION 5702 -#define GAUSS_RENAME_CONFIGURATION 5703 +//#define GAUSS_SAVE_CONFIGURATION 5700 +//#define GAUSS_OVERWRITE_CONFIGURATION 5701 +//#define GAUSS_RESTORE_CONFIGURATION 5702 +//#define GAUSS_RENAME_CONFIGURATION 5703 using namespace std; @@ -267,13 +267,15 @@ void VisuGUI_Module::initialize( CAM_Application* theApp ) createMenu( action( GAUSS_CREATE_PRS ), createMenu( tr( "MEN_VISUALISATION" ), -1 ), -1 ); createTool( GAUSS_CREATE_PRS, createTool( tr( "TOOL_VISUALISATION" ) ), -1 ); - createAction( GAUSS_RENAME, VisuGUI::tr("MEN_RENAME"), QIcon(), + /* + createAction( GAUSS_RENAME, VisuGUI::tr("MEN_RENAME"), QIcon(), VisuGUI::tr("MEN_RENAME"), "", 0, this, false, this, SLOT(OnRename())); - mgr->insert( action( GAUSS_RENAME ), -1, 0, -1 ); - mgr->setRule( action( GAUSS_RENAME ), - "selcount=1 and type='VISU::TGAUSSPOINTS'" ); - + mgr->insert( action( GAUSS_RENAME ), -1, 0, -1 ); + mgr->setRule( action( GAUSS_RENAME ), + "selcount=1 and type='VISU::TGAUSSPOINTS'" ); + */ + createAction( GAUSS_EDIT_PRS, VisuGUI::tr("MEN_EDIT_PRS"), QIcon(), VisuGUI::tr("MEN_EDIT_PRS"), "", 0, this, false, this, SLOT(OnEditGaussPoints())); @@ -289,7 +291,7 @@ void VisuGUI_Module::initialize( CAM_Application* theApp ) "selcount=1 and type='VISU::TGAUSSPOINTS'" ); action( GAUSS_COPY_PRS )->setEnabled(false); - + QStringList viewers; #ifndef DISABLE_OCCVIEWER @@ -347,7 +349,7 @@ void VisuGUI_Module::initialize( CAM_Application* theApp ) mgr->insert( action( GAUSS_DISPLAY_ONLY_PRS ), -1, -1, -1 ); // display only mgr->setRule( action( GAUSS_DISPLAY_ONLY_PRS ), aRule + " and ({true} in $canBeDisplayed)" );*/ - +/* createAction( GAUSS_RENAME_CONFIGURATION, VisuGUI::tr("MEN_RENAME"), QIcon(), VisuGUI::tr("MEN_RENAME"), "", 0, this, false, this, SLOT(OnRename())); @@ -374,6 +376,7 @@ void VisuGUI_Module::initialize( CAM_Application* theApp ) mgr->insert( action( GAUSS_RESTORE_CONFIGURATION ), -1, -1, -1 ); mgr->setRule( action( GAUSS_RESTORE_CONFIGURATION ), "selcount=1 and type='VISU::TGAUSSVIEW'" ); +*/ } // //---------------------------------------------------------------