Salome HOME
Rollback previous wrong integration, restore improvement 0018239 implementation
[modules/smesh.git] / src / SMESHGUI / SMESHGUI.cxx
index 509b176d95c10522157a1628802e8d587281c351..6397948a909f49ad4cd3f0864f391eadd46d1601 100644 (file)
     _PTR(AttributeIOR) anIOR;
 
     int objectCount = 0;
+    QString aNameList;
     QString aParentComponent = QString::null;
+    Handle(SALOME_InteractiveObject) anIO;
     for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
     {
-      _PTR(SObject) aSO = aStudy->FindObjectID(anIt.Value()->getEntry());
+      anIO = anIt.Value();
+      QString cur = anIO->getComponentDataType();
+      _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
       if (aSO) {
-       // check if object is not reference
-       _PTR(SObject) refobj;
-       if ( !aSO->ReferencedObject( refobj ) )
-         objectCount++;
+       // check if object is reference
+       _PTR(SObject) aRefSObj;
+       aNameList.append("\n    - ");
+       if ( aSO->ReferencedObject( aRefSObj ) ) {
+         QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
+         aNameList.append( aRefName );
+         cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
+       }
+       else
+         aNameList.append(anIO->getName());
+       objectCount++;
       }
 
-      QString cur = anIt.Value()->getComponentDataType();
       if( aParentComponent.isNull() )
         aParentComponent = cur;
       else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
     if (SUIT_MessageBox::warning
        (SMESHGUI::desktop(),
         QObject::tr("SMESH_WRN_WARNING"),
-        QObject::tr("SMESH_REALLY_DELETE"),
+        QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
         SUIT_MessageBox::Yes | SUIT_MessageBox::No,
         SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
       return;
          if ( engineIOR() == anIOR->Value().c_str() )
            continue;
        }
-
-       _PTR(SObject) refobj;
-       if ( aSO && aSO->ReferencedObject( refobj ) )
-         continue; // skip references
+       //Check the referenced object
+       _PTR(SObject) aRefSObject;
+       if ( aSO && aSO->ReferencedObject( aRefSObject ) )
+         aSO = aRefSObject; // Delete main Object instead of reference
 
         // put the whole hierarchy of sub-objects of the selected SO into a list and
         // then treat them all starting from the deepest objects (at list back)
@@ -1554,21 +1564,17 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
     }
 
   case 701:                                    // COMPUTE MESH
+  case 711:                                    // PRECOMPUTE MESH
     {
       if (checkLock(aStudy)) break;
-
-      startOperation( 701 );
+      startOperation( theCommandID );
     }
     break;
 
-  case 702:  // Create mesh
-    startOperation( 702 );
-    break;
-  case 703:  // Create sub-mesh
-    startOperation( 703 );
-    break;
+  case 702: // Create mesh
+  case 703: // Create sub-mesh
   case 704: // Edit mesh/sub-mesh
-    startOperation( 704 );
+    startOperation( theCommandID );
     break;
   case 710: // Build compound mesh
     {
@@ -1870,6 +1876,36 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
       break;
     }
 
+  case 815:                                     // Edit GEOM GROUP as standalone
+    {
+      if ( !vtkwnd )
+      {
+        SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
+                                 tr( "NOT_A_VTK_VIEWER" ) );
+        break;
+      }
+
+      if(checkLock(aStudy)) break;
+      EmitSignalDeactivateDialog();
+
+      LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
+      SALOME_ListIO selected;
+      if( aSel )
+        aSel->selectedObjects( selected );
+
+      SALOME_ListIteratorOfListIO It (selected);
+      for ( ; It.More(); It.Next() )
+      {
+        SMESH::SMESH_GroupOnGeom_var aGroup =
+          SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
+        if (!aGroup->_is_nil()) {
+          SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
+          aDlg->show();
+       }
+      }
+      break;
+    }
+
     case 810: // Union Groups
     case 811: // Intersect groups
     case 812: // Cut groups
@@ -1886,12 +1922,28 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
 
       EmitSignalDeactivateDialog();
 
-      int aMode;
-      if      ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
-      else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
-      else                            aMode = SMESHGUI_GroupOpDlg::CUT;
+      SMESHGUI_GroupOpDlg* aDlg = 0;
+      if ( theCommandID == 810 )
+        aDlg = new SMESHGUI_UnionGroupsDlg( this );
+      else if ( theCommandID == 811 )
+        aDlg = new SMESHGUI_IntersectGroupsDlg( this );
+      else
+        aDlg = new SMESHGUI_CutGroupsDlg( this );
+
+      aDlg->show();
+
+      break;
+    }
+
+    case 814: // Create groups of entities from existing groups of superior dimensions
+    {
+      if ( checkLock( aStudy ) )
+        break;
+
+      EmitSignalDeactivateDialog();
+      SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
+      aDlg->show();
 
-      ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
       break;
     }
 
@@ -2012,7 +2064,7 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
       if( aSel )
         aSel->selectedObjects( selected );
 
-      bool isAny = false; // iss there any appropriate object selected
+      bool isAny = false; // is there any appropriate object selected
 
       SALOME_ListIteratorOfListIO It( selected );
       for ( ; It.More(); It.Next() )
@@ -2040,14 +2092,7 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
               newName = LightApp_NameDlg::getName(desktop(), newName);
               if ( !newName.isEmpty() )
               {
-                //old source: aStudy->renameIObject( IObject, newName );
-                aName->SetValue( newName.toLatin1().constData() );
-
-                // if current object is group update group's name
-                SMESH::SMESH_GroupBase_var aGroup =
-                  SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
-                if (!aGroup->_is_nil() )
-                  aGroup->SetName( newName.toLatin1().constData() );
+                SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), newName.toLatin1().data());
 
                 updateObjBrowser();
               }
@@ -2586,15 +2631,18 @@ void SMESHGUI::initialize( CAM_Application* app )
   createSMESHAction(  703, "CREATE_SUBMESH",  "ICON_DLG_ADD_SUBMESH" );
   createSMESHAction(  704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
   createSMESHAction(  710, "BUILD_COMPOUND",  "ICON_BUILD_COMPOUND" );
+  createSMESHAction(  711, "PRECOMPUTE",      "ICON_PRECOMPUTE" );
   createSMESHAction(  806, "CREATE_GEO_GROUP","ICON_CREATE_GEO_GROUP" );
   createSMESHAction(  801, "CREATE_GROUP",    "ICON_CREATE_GROUP" );
   createSMESHAction(  802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
   createSMESHAction(  803, "EDIT_GROUP",      "ICON_EDIT_GROUP" );
+  createSMESHAction(  815, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
   createSMESHAction(  804, "ADD" );
   createSMESHAction(  805, "REMOVE" );
   createSMESHAction(  810, "UN_GROUP",        "ICON_UNION" );
   createSMESHAction(  811, "INT_GROUP",       "ICON_INTERSECT" );
   createSMESHAction(  812, "CUT_GROUP",       "ICON_CUT" );
+  createSMESHAction(  814, "UNDERLYING_ELEMS","ICON_UNDERLYING_ELEMS" );
   createSMESHAction(  813, "DEL_GROUP",       "ICON_DEL_GROUP" );
   createSMESHAction(  900, "ADV_INFO",        "ICON_ADV_INFO" );
   createSMESHAction(  902, "STD_INFO",        "ICON_STD_INFO" );
@@ -2693,8 +2741,8 @@ void SMESHGUI::initialize( CAM_Application* app )
 
   createMenu( separator(), fileId );
 
-  int importId = createMenu( tr( "MEN_IMPORT" ), fileId, 11, 10 ),
-      exportId = createMenu( tr( "MEN_EXPORT" ), fileId, 12, 10 ),
+  int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
+      exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
       addId    = createMenu( tr( "MEN_ADD" ),    modifyId, 402 ),
       removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
       renumId  = createMenu( tr( "MEN_RENUM" ),  modifyId, 404 ),
@@ -2721,16 +2769,20 @@ void SMESHGUI::initialize( CAM_Application* app )
   createMenu( 710, meshId, -1 );
   createMenu( separator(), meshId, -1 );
   createMenu( 701, meshId, -1 );
+  createMenu( 711, meshId, -1 );
   createMenu( separator(), meshId, -1 );
   createMenu( 801, meshId, -1 );
   createMenu( 806, meshId, -1 );
   createMenu( 802, meshId, -1 );
   createMenu( 803, meshId, -1 );
+  createMenu( 815, meshId, -1 );
   createMenu( separator(), meshId, -1 );
   createMenu( 810, meshId, -1 );
   createMenu( 811, meshId, -1 );
   createMenu( 812, meshId, -1 );
   createMenu( separator(), meshId, -1 );
+  createMenu( 814, meshId, -1 );
+  createMenu( separator(), meshId, -1 );
   createMenu( 813, meshId, -1 );
   createMenu( separator(), meshId, -1 );
   createMenu( 900, meshId, -1 );
@@ -2816,11 +2868,13 @@ void SMESHGUI::initialize( CAM_Application* app )
   createTool( 710, meshTb );
   createTool( separator(), meshTb );
   createTool( 701, meshTb );
+  createTool( 711, meshTb );
   createTool( separator(), meshTb );
   createTool( 801, meshTb );
   createTool( 806, meshTb );
   createTool( 802, meshTb );
   createTool( 803, meshTb );
+  //createTool( 815, meshTb );
   createTool( separator(), meshTb );
   createTool( 900, meshTb );
   createTool( 902, meshTb );
@@ -2918,11 +2972,16 @@ void SMESHGUI::initialize( CAM_Application* app )
   // popup for object browser
 
   createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" );      // FILE INFORMATION
+  createPopupItem( 703, OB, mesh, "&& isComputable");      // CREATE_SUBMESH
+  //createPopupItem( 703, OB, subMesh, "&& isComputable" );  // CREATE_SUBMESH
   createPopupItem( 704, OB, mesh, "&& isComputable");      // EDIT_MESHSUBMESH
   createPopupItem( 704, OB, subMesh, "&& isComputable" );  // EDIT_MESHSUBMESH
   createPopupItem( 803, OB, group );                       // EDIT_GROUP
+  createPopupItem( 815, OB, group, "&& groupType = 'GroupOnGeom'" ); // EDIT_GROUP
+
   popupMgr()->insert( separator(), -1, 0 );
   createPopupItem( 701, OB, mesh, "&& isComputable" );     // COMPUTE
+  createPopupItem( 711, OB, mesh, "&& isComputable" );     // PRECOMPUTE
   createPopupItem( 214, OB, mesh_group );                  // UPDATE
   createPopupItem( 900, OB, mesh_group );                  // ADV_INFO
   createPopupItem( 902, OB, mesh );                        // STD_INFO
@@ -2952,6 +3011,7 @@ void SMESHGUI::initialize( CAM_Application* app )
   createPopupItem( 803, View, group ); // EDIT_GROUP
   createPopupItem( 804, View, elems ); // ADD
   createPopupItem( 805, View, elems ); // REMOVE
+
   popupMgr()->insert( separator(), -1, 0 );
   createPopupItem( 214, View, mesh_group ); // UPDATE
   createPopupItem( 900, View, mesh_group ); // ADV_INFO
@@ -3445,23 +3505,11 @@ void SMESHGUI::createPreferences()
   int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
   setPreferenceProperty( fontGr, "columns", 2 );
 
-  int tfont = addPreference( tr( "SMESH_TITLE" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_title_font" );
+  addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
   addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
-  int lfont = addPreference( tr( "SMESH_LABELS" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_label_font" );
-  addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
 
-  QStringList fam;
-  fam.append( tr( "SMESH_FONT_ARIAL" ) );
-  fam.append( tr( "SMESH_FONT_COURIER" ) );
-  fam.append( tr( "SMESH_FONT_TIMES" ) );
-  int wflag = ( QtxFontEdit::Family | QtxFontEdit::Scripting );
-
-  setPreferenceProperty( tfont, "families", fam );
-  setPreferenceProperty( tfont, "system", false );
-  setPreferenceProperty( tfont, "widget_flags", wflag );
-  setPreferenceProperty( lfont, "families", fam );
-  setPreferenceProperty( lfont, "system", false );
-  setPreferenceProperty( lfont, "widget_flags", wflag );
+  addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
+  addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
 
   int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
   setPreferenceProperty( colorsLabelsGr, "columns", 2 );
@@ -3665,6 +3713,9 @@ LightApp_Operation* SMESHGUI::createOperation( const int id ) const
     case 704: // Edit mesh/sub-mesh
       op = new SMESHGUI_MeshOp( false );
     break;
+    case 711: // Precompute mesh
+      op = new SMESHGUI_PrecomputeOp();
+    break;
     case 806: // Create group on geom
       op = new SMESHGUI_GroupOnShapeOp();
       break;
@@ -4168,3 +4219,35 @@ void SMESHGUI::restoreVisualParameters (int savePoint)
     }
   }
 }
+
+/*!
+  \brief Adds preferences for dfont of VTK viewer
+  \param label label
+  \param pIf group identifier
+  \param param parameter
+  \return identifier of preferences
+*/
+int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param )
+{
+  int tfont = addPreference( label, pId, LightApp_Preferences::Font, "VISU", param );
+  
+  setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
+
+  QStringList fam;
+  fam.append( tr( "SMESH_FONT_ARIAL" ) );
+  fam.append( tr( "SMESH_FONT_COURIER" ) );
+  fam.append( tr( "SMESH_FONT_TIMES" ) );
+
+  setPreferenceProperty( tfont, "fonts", fam );
+
+  int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
+  setPreferenceProperty( tfont, "features", f );
+
+  return tfont;
+}
+
+
+
+
+
+