Salome HOME
Remove not used files
[modules/geom.git] / src / BuildGUI / BuildGUI_ShellDlg.cxx
index 3cf46a4717578266d25dadbdeeed595f933d240d..073b9ceb4c84fc4712148b3d87167d85fa447414 100644 (file)
@@ -1,23 +1,23 @@
-//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
-//  This library is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU Lesser General Public
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
 //
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
 //
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
 // GEOM GEOMGUI : GUI for Geometry component
@@ -101,7 +101,7 @@ void BuildGUI_ShellDlg::Init()
   myEditCurrentArgument = GroupShell->LineEdit1;
   GroupShell->LineEdit1->setReadOnly( true );
   
-  myOkFacesAndShells = false;
+  myFacesAndShells.clear();
   
   TColStd_MapOfInteger aMap;
   aMap.Add( GEOM_SHELL );
@@ -132,6 +132,7 @@ void BuildGUI_ShellDlg::Init()
 //=================================================================================
 void BuildGUI_ShellDlg::ClickOnOk()
 {
+  setIsApplyAndClose( true );
   if ( ClickOnApply() )
     ClickOnCancel();
 }
@@ -158,25 +159,15 @@ bool BuildGUI_ShellDlg::ClickOnApply()
 void BuildGUI_ShellDlg::SelectionIntoArgument()
 {
   myEditCurrentArgument->setText( "" );
-  QString aString;
 
-  LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
-  SALOME_ListIO aSelList;
-  aSelMgr->selectedObjects(aSelList);
+  QList<TopAbs_ShapeEnum> types;
+  types << TopAbs_FACE << TopAbs_SHELL << TopAbs_COMPOUND;
+  myFacesAndShells = getSelected( types, -1 );
 
-  myOkFacesAndShells = false;
-  int nbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aString, true);
-  if ( nbSel == 0 )
-    return;
-  if ( nbSel != 1 )
-    aString = QString( "%1_objects ").arg( nbSel );
-
-  GEOMBase::ConvertListOfIOInListOfGO(aSelList, myFacesAndShells, true);
-  if ( !myFacesAndShells.length() )
-    return;
-
-  myEditCurrentArgument->setText( aString );
-  myOkFacesAndShells = true;
+  if ( !myFacesAndShells.isEmpty() ) {
+    QString aName = myFacesAndShells.count() > 1 ? QString( "%1_objects").arg( myFacesAndShells.count() ) : GEOMBase::GetName( myFacesAndShells[0].get() );
+    myEditCurrentArgument->setText( aName );
+  }
 }
 
 
@@ -251,7 +242,7 @@ GEOM::GEOM_IOperations_ptr BuildGUI_ShellDlg::createOperation()
 //=================================================================================
 bool BuildGUI_ShellDlg::isValid( QString& )
 {
-  return myOkFacesAndShells;
+  return !myFacesAndShells.isEmpty();
 }
 
 //=================================================================================
@@ -261,7 +252,13 @@ bool BuildGUI_ShellDlg::isValid( QString& )
 bool BuildGUI_ShellDlg::execute( ObjectList& objects )
 {
   GEOM::GEOM_IShapesOperations_var anOper = GEOM::GEOM_IShapesOperations::_narrow( getOperation() );
-  GEOM::GEOM_Object_var anObj = anOper->MakeShell( myFacesAndShells );
+
+  GEOM::ListOfGO_var objlist = new GEOM::ListOfGO();
+  objlist->length( myFacesAndShells.count() );
+  for ( int i = 0; i < myFacesAndShells.count(); i++ )
+    objlist[i] = myFacesAndShells[i].copy();
+
+  GEOM::GEOM_Object_var anObj = anOper->MakeShell( objlist.in() );
 
   if ( !anObj->_is_nil() )
     objects.push_back( anObj._retn() );