Salome HOME
Correct the scalar bar title for the volume control.
[modules/smesh.git] / src / SMESHGUI / SMESHGUI.cxx
index aade73a3e9c36c066f409d9c6627ee1aefaca024..c8a76665754cdcd87240d1224b5ff9535d1ad0af 100644 (file)
@@ -95,8 +95,7 @@
 #include <SVTK_ViewModel.h>
 #include <SVTK_InteractorStyle.h>
 #include <SVTK_RenderWindowInteractor.h>
-
-#include <VTKViewer_ViewManager.h>
+#include <SVTK_ViewManager.h>
 
 #include "OB_Browser.h"
 
@@ -301,6 +300,7 @@ namespace{
            SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
            fd->setCaption( aTitle );
            fd->setFilters( filters );
+           fd->setSelectedFilter( QObject::tr("MED 2.2 (*.med)") );
            bool is_ok = false;
            while(!is_ok){
              fd->exec();
@@ -583,6 +583,10 @@ namespace{
            aTitle = QObject::tr( "SKEW_ELEMENTS" );
            aControl = SMESH_Actor::eSkew;
            break;
+         case 6009:
+           aTitle = QObject::tr( "SMESH_VOLUME" );
+           aControl = SMESH_Actor::eVolume3D;
+           break;
          }
          anActor->SetControlMode(aControl);
          anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
@@ -664,7 +668,7 @@ namespace{
   {
     // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
     SalomeApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
-    SALOME_ListIO selected; aSel->selectedObjects( selected );
+    SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
 
     QString aParentComponent = QString::null;
     for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
@@ -805,8 +809,8 @@ SalomeApp_Module( "SMESH" )
     myComponentSMESH = SMESH::SMESH_Gen::_narrow( comp );
   }
 
-  myActiveDialogBox = 0 ;
-  myState = -1 ;
+  myActiveDialogBox = 0;
+  myState = -1;
   myDisplayer = 0;
 
   SMESH::GetFilterManager();
@@ -824,6 +828,7 @@ SalomeApp_Module( "SMESH" )
 SMESHGUI::~SMESHGUI()
 {
   SMESH::GetFilterManager()->Destroy();
+  SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
 }
 
 //=============================================================================
@@ -1058,6 +1063,10 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
   if( !mgr )
     return false;
 
+  if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
+    GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
+  }
+
   SUIT_ViewWindow* view = application()->desktop()->activeWindow();
   SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
 
@@ -1155,12 +1164,46 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
       }
 
       SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
-      SALOME_ListIO selected;
+      SALOME_ListIO sel_objects, to_process;
       if (aSel)
-        aSel->selectedObjects( selected );
+        aSel->selectedObjects( sel_objects );
+
+      SALOME_ListIteratorOfListIO anIt( sel_objects );
+      for( ; anIt.More(); anIt.Next() )
+      {
+       Handle( SALOME_InteractiveObject ) obj = anIt.Value();
+       if( obj->hasEntry() )
+       {
+         _PTR(SObject) SO = activeStudy()->studyDS()->FindObjectID( obj->getEntry() );
+         if( SO && QString( SO->GetID().c_str() ) == SO->GetFatherComponent()->GetID().c_str() )
+         { //component is selected
+           _PTR(SComponent) SC( SO->GetFatherComponent() );
+           _PTR(ChildIterator) anIter ( activeStudy()->studyDS()->NewChildIterator( SC ) );
+           anIter->InitEx( true );
+           while( anIter->More() )
+           {
+             _PTR(SObject) valSO ( anIter->Value() );
+             _PTR(SObject) refSO;
+             if( !valSO->ReferencedObject( refSO ) )
+             {
+               QString id = valSO->GetID().c_str(),
+                        comp = SC->ComponentDataType().c_str(),
+                       val = valSO->GetName().c_str();
+
+               Handle( SALOME_InteractiveObject ) new_obj =
+                 new SALOME_InteractiveObject( id.latin1(), comp.latin1(), val.latin1() );
+               to_process.Append( new_obj );
+             }
+             anIter->Next();
+           }
+           continue;
+         }
+       }
+       to_process.Append( obj );
+      }
 
       if (vtkwnd) {
-       SALOME_ListIteratorOfListIO It (selected);
+       SALOME_ListIteratorOfListIO It( to_process );
        for (; It.More(); It.Next()) {
          Handle(SALOME_InteractiveObject) IOS = It.Value();
          if (IOS->hasEntry()) {
@@ -1176,7 +1219,7 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
        aSel->setSelectedObjects( l1 );
       }
       else
-       aSel->setSelectedObjects( selected );
+       aSel->setSelectedObjects( to_process );
       break;
     }
 
@@ -1787,7 +1830,7 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
       SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
       SALOME_ListIO selected;
       if( aSel )
-        aSel->selectedObjects( selected );
+        aSel->selectedObjects( selected, QString::null, false );
 
       SALOME_ListIteratorOfListIO It(selected);
       for (int i = 0; It.More(); It.Next(), i++) {
@@ -2023,6 +2066,7 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
   case 6002:
   case 6003:
   case 6004:
+  case 6009:
     if ( vtkwnd ) {
 
       SalomeApp_SelectionMgr* mgr = selectionMgr();
@@ -2244,6 +2288,7 @@ void SMESHGUI::initialize( CAM_Application* app )
   createSMESHAction( 6017, "ASPECT_3D",       "ICON_ASPECT_3D",     0, true );
   createSMESHAction( 6018, "LENGTH_2D",       "ICON_LENGTH_2D",     0, true );
   createSMESHAction( 6019, "CONNECTION_2D",   "ICON_CONNECTION_2D", 0, true );
+  createSMESHAction( 6009, "VOLUME_3D",       "ICON_VOLUME_3D",     0, true );
   createSMESHAction(  400, "NODE",            "ICON_DLG_NODE" );
   createSMESHAction(  401, "EDGE",            "ICON_DLG_EDGE" );
   createSMESHAction( 4021, "TRIANGLE",        "ICON_DLG_TRIANGLE" );
@@ -2367,6 +2412,7 @@ void SMESHGUI::initialize( CAM_Application* app )
   createMenu( 6016, ctrlId, -1 );
   createMenu( separator(), ctrlId, -1 );
   createMenu( 6017, ctrlId, -1 );
+  createMenu( 6009, ctrlId, -1 );
   createMenu( separator(), ctrlId, -1 );
 
   createMenu( 400, addId, -1 );
@@ -2441,6 +2487,7 @@ void SMESHGUI::initialize( CAM_Application* app )
   createTool( 6016, ctrlTb );
   createTool( separator(), ctrlTb );
   createTool( 6017, ctrlTb );
+  createTool( 6009, ctrlTb );
   createTool( separator(), ctrlTb );
 
   createTool( 400, addRemTb );
@@ -2548,7 +2595,8 @@ void SMESHGUI::initialize( CAM_Application* app )
 
   QString lc = QtxPopupMgr::Selection::defEquality();
   QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
-  QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() ).arg( mesh_group );
+  QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() );
+  aType = aType.arg( mesh_group );
   QString aMeshInVTK = aClient + "&&" + aType;
 
   //-------------------------------------------------
@@ -2704,6 +2752,10 @@ void SMESHGUI::initialize( CAM_Application* app )
   popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, true );
   popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", false );
 
+  popupMgr()->insert ( action( 6009 ), anId, -1 ); // VOLUME_3D
+  popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, true );
+  popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", false );
+
   popupMgr()->insert( separator(), anId, -1 );
 
   popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
@@ -2715,22 +2767,24 @@ void SMESHGUI::initialize( CAM_Application* app )
   // Display / Erase
   //-------------------------------------------------
   aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
-  QString anActiveVTK = QString("activeView = '%1'").arg(VTKViewer_Viewer::Type());
+  QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
   QString aSelCount = QString( "%1 > 0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
-  QString aRule = aClient + " and " + aType + " and " + aSelCount + " and " + anActiveVTK;
+
+  QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
+    aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
   popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
-  popupMgr()->setRule( action( 301 ), aRule + "&&" + isNotEmpty + "&&" + isInvisible, true);
+  popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), true);
 
   popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
-  popupMgr()->setRule( action( 300 ), aRule + "&&" + isNotEmpty + "&& isVisible", true );
+  popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), true );
 
   popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
-  popupMgr()->setRule( action( 302 ), aRule + "&&" + isNotEmpty, true );
+  popupMgr()->setRule( action( 302 ), aRule.arg( "" ), true );
 
   popupMgr()->insert( separator(), -1, -1 );
 
-  connect( application(), SIGNAL( viewManagerAdded( SUIT_ViewManager* ) ),
-          this, SLOT( onViewManagerAdded( SUIT_ViewManager* ) ) );
+  connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
+          this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
 }
 
 bool SMESHGUI::activateModule( SUIT_Study* study )
@@ -2798,9 +2852,9 @@ void SMESHGUI::viewManagers( QStringList& list ) const
   list.append( SVTK_Viewer::Type() );
 }
 
-void SMESHGUI::onViewManagerAdded( SUIT_ViewManager* mgr )
+void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
 {
-  if ( dynamic_cast<VTKViewer_ViewManager*>( mgr ) )
+  if ( dynamic_cast<SVTK_ViewManager*>( mgr ) )
     SMESH::UpdateSelectionProp( this );
 }
 
@@ -2969,6 +3023,11 @@ void SMESHGUI::createPreferences()
 
 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
 {
+  if( sect=="SMESH" )
+    if( name=="selection_object_color" || name=="selection_element_color" || 
+        name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
+        name=="selection_precision_node" || name=="selection_precision_element" )
+      SMESH::UpdateSelectionProp( this );
 }
 
 //================================================================================