]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Implementation "21042: EDF 1600 ALL: Rename objects in the OB" issue. before_mergefrom_PortingMED3_07Apr11
authorrnv <rnv@opencascade.com>
Tue, 5 Apr 2011 09:26:20 +0000 (09:26 +0000)
committerrnv <rnv@opencascade.com>
Tue, 5 Apr 2011 09:26:20 +0000 (09:26 +0000)
src/VISUGUI/VisuGUI.cxx
src/VISUGUI/VisuGUI.h
src/VISUGUI/VisuGUI_ActionsDef.h
src/VISUGUI/VisuGUI_Module.cxx

index a60d3e7816fb42e2fb9f93f48b08e1d2a2f46968..4420fdfda5565f3569fc20741b73ea0a7b58e75b 100644 (file)
@@ -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<VISU::Curve_i*>(aBase))
-                aCurve->SetName(Name.toLatin1().constData(), true);
-              break;
-            }
-            case VISU::TTABLE: { // Table object
-              if (VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(aBase))
-                aTable->SetName(Name.toLatin1().constData(), true);
-              break;
-            }
-            case VISU::TPOINTMAP3D: { // Table object
-              if (VISU::PointMap3d_i* aTable3d = dynamic_cast<VISU::PointMap3d_i*>(aBase)) {
-                aTable3d->SetTitle(Name.toLatin1().constData());
-                aTable3d->UpdateActors();
-              }
-              break;
-            }
-            case VISU::TCONTAINER: { // Container object
-              if (VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(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<Plot2d_ViewManager*>(aViewManager)) {
-              if (SPlot2d_Viewer* aViewer = dynamic_cast<SPlot2d_Viewer*>(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<SalomeApp_Study*>(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<VISU::Curve_i*>(aBase))
+                 aCurve->SetName(qPrintable(name), true);
+               break;
+             }
+             case VISU::TTABLE: { // Table object
+               if (VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(aBase))
+                 aTable->SetName(qPrintable(name), true);
+               break;
+             }
+             case VISU::TPOINTMAP3D: { // Table object
+               if (VISU::PointMap3d_i* aTable3d = dynamic_cast<VISU::PointMap3d_i*>(aBase)) {
+                 aTable3d->SetTitle(qPrintable(name));
+                 aTable3d->UpdateActors();
+               }
+               break;
+             }
+             case VISU::TCONTAINER: { // Container object
+               if (VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(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<Plot2d_ViewManager*>(aViewManager)) {
+               if (SPlot2d_Viewer* aViewer = dynamic_cast<SPlot2d_Viewer*>(aManager->getViewModel()))
+                 aViewer->renameAll( anIO, qPrintable(name) );
+             }
+           }
+           QApplication::restoreOverrideCursor();          
+           return true;
+         }
+       }
+      }
+    }
+  }
+  return false;
+}
index 1d7e3e108cfebfe894cad1b4d9a0f883f2e1dd2e..05c611845b83daa5aca4bff8d8483c29e52eca5b 100644 (file)
@@ -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();
index c474c082c44964b18f56d140f160da7f1a6dda6c..62b52c3cc210b963b1f996bb7d3ff8be18d6ba1f 100644 (file)
@@ -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
 
index 7da3b5eaa9fe560f60e6d1b9d52148f682cffe88..6eb9146aa8e2fcd0bc430aac5cc5f2ff372e0869 100644 (file)
@@ -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'" );
+*/
 }
 
 // //---------------------------------------------------------------