Salome HOME
Merge from V6_3_BR 06/06/2011
[modules/smesh.git] / src / StdMeshersGUI / StdMeshersGUI_SubShapeSelectorWdg.cxx
index 9a8e3827cdba266006dc49908b8f40e824c8512e..09ba1f2f0850425d5c21128c2d23db99409e660c 100644 (file)
@@ -1,20 +1,20 @@
-//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-//  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
 //
 
 // File   : StdMeshersGUI_SubShapeSelectorWdg.cxx
@@ -50,7 +50,7 @@
 
 // GEOM Includes
 #include <GEOMBase.h>
-#include <GEOM_EdgeFilter.h>
+#include <GEOM_TypeFilter.h>
 #include <GEOM_CompoundFilter.h>
 
 // Qt includes
@@ -82,7 +82,7 @@
 //================================================================================
 
 StdMeshersGUI_SubShapeSelectorWdg
-::StdMeshersGUI_SubShapeSelectorWdg( QWidget * parent ): 
+::StdMeshersGUI_SubShapeSelectorWdg( QWidget * parent, TopAbs_ShapeEnum aSubShType ): 
   QWidget( parent ),
   myPreviewActor( 0 ),
   myMaxSize( -1 )
@@ -102,13 +102,13 @@ StdMeshersGUI_SubShapeSelectorWdg
   edgesLayout->addWidget(myAddButton,    0, 4);
   edgesLayout->addWidget(myRemoveButton, 1, 4);
 
-  edgesLayout->setRowStretch(2, 5);
+  //edgesLayout->setRowStretch(2, 5);
   edgesLayout->setColumnStretch(2, 5);
 
   setLayout( edgesLayout );
   setMinimumWidth( 300 );
 
-  mySubShType = TopAbs_EDGE;
+  mySubShType = aSubShType;
 
   init();
 }
@@ -166,15 +166,8 @@ void StdMeshersGUI_SubShapeSelectorWdg::init()
   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
     aViewWindow->SetSelectionMode( ActorSelection );
 
-
-  SalomeApp_Study* study = mySMESHGUI->activeStudy();
-  GEOM_EdgeFilter* edgeFilter = new GEOM_EdgeFilter(study,StdSelect_AnyEdge);
-  GEOM_CompoundFilter* gpoupFilter = new GEOM_CompoundFilter(study);
-  gpoupFilter->addSubType( TopAbs_EDGE );
-  myGeomFilters.append( edgeFilter );
-  myGeomFilters.append( gpoupFilter );
-  myFilter = new SMESH_LogicalFilter( myGeomFilters, SMESH_LogicalFilter::LO_OR );
-  mySelectionMgr->installFilter( myFilter );
+  myFilter=0;
+  //setFilter();
 
   connect( myAddButton,    SIGNAL(clicked()), SLOT(onAdd()));
   connect( myRemoveButton, SIGNAL(clicked()), SLOT(onRemove()));
@@ -185,6 +178,24 @@ void StdMeshersGUI_SubShapeSelectorWdg::init()
   updateState();
 }
 
+//================================================================================
+/*!
+ * \brief Install filters to select sub-shapes of mySubShType or their groups
+ */
+//================================================================================
+
+void StdMeshersGUI_SubShapeSelectorWdg::setFilter()
+{
+  SalomeApp_Study* study = mySMESHGUI->activeStudy();
+  GEOM_TypeFilter* typeFilter = new GEOM_TypeFilter(study, mySubShType, /*isShapeType=*/true );
+  GEOM_CompoundFilter* gpoupFilter = new GEOM_CompoundFilter(study);
+  gpoupFilter->addSubType( mySubShType );
+  myGeomFilters.append( typeFilter );
+  myGeomFilters.append( gpoupFilter );
+  myFilter = new SMESH_LogicalFilter( myGeomFilters, SMESH_LogicalFilter::LO_OR );
+  mySelectionMgr->installFilter( myFilter );
+}
+
 //================================================================================
 /*!
  *  Create a layout, initialize fields
@@ -371,7 +382,7 @@ void StdMeshersGUI_SubShapeSelectorWdg::onListSelectionChanged()
 
 //=================================================================================
 // function : setGeomShape
-// purpose  : Called to set geometry
+// purpose  : Called to set geometry whose sub-shapes are selected
 //================================================================================
 void StdMeshersGUI_SubShapeSelectorWdg::SetGeomShapeEntry( const QString& theEntry )
 {
@@ -484,7 +495,7 @@ void StdMeshersGUI_SubShapeSelectorWdg::SetListOfIDs( SMESH::long_array_var theI
 
 //=================================================================================
 // function : SetMainShapeEntry
-// purpose  : Called to set the Main Object Entry
+// purpose  : Called to set the Entry of main shape of the mesh
 //=================================================================================
 void StdMeshersGUI_SubShapeSelectorWdg::SetMainShapeEntry( const QString& theEntry )
 {