Salome HOME
Implementation of NPAL16149 (EDF 442 GEOM : Create a shell from a compound containing...
authorrnv <rnv@opencascade.com>
Tue, 18 Mar 2008 07:41:27 +0000 (07:41 +0000)
committerrnv <rnv@opencascade.com>
Tue, 18 Mar 2008 07:41:27 +0000 (07:41 +0000)
src/BuildGUI/BuildGUI_ShellDlg.cxx
src/GEOMBase/GEOMBase_Helper.cxx
src/GEOMBase/GEOMBase_Helper.h
src/GEOMFiltersSelection/GEOM_CompoundFilter.cxx [new file with mode: 0644]
src/GEOMFiltersSelection/GEOM_CompoundFilter.h [new file with mode: 0644]
src/GEOMFiltersSelection/Makefile.am
src/GEOMGUI/GEOM_Displayer.cxx
src/GEOMGUI/GEOM_Displayer.h
src/GEOMImpl/GEOMImpl_Types.hxx

index 99c99f03f15232cde5d4c5740e7deed1da42b9c9..4d5c0e367da5ff2a181c6da63317b949c3a1e95d 100644 (file)
@@ -101,8 +101,12 @@ void BuildGUI_ShellDlg::Init()
   TColStd_MapOfInteger aMap;
   aMap.Add(GEOM_SHELL);
   aMap.Add(GEOM_FACE);
-  globalSelection( aMap );
-
+  aMap.Add(GEOM_COMPOUNDFILTER);
+  
+  QValueList<int> aSubShapes;
+  aSubShapes.append(GEOM_FACE);
+  globalSelection( aMap, aSubShapes );
+  
   /* signals and slots connections */
   connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
   connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
@@ -179,7 +183,12 @@ void BuildGUI_ShellDlg::SetEditCurrentArgument()
   TColStd_MapOfInteger aMap;
   aMap.Add(GEOM_SHELL);
   aMap.Add(GEOM_FACE);
-  globalSelection( aMap );
+  aMap.Add(GEOM_COMPOUNDFILTER);
+
+  QValueList<int> aSubShapes;
+  aSubShapes.append(GEOM_FACE);
+  globalSelection( aMap, aSubShapes );
+  
   myEditCurrentArgument = GroupShell->LineEdit1;
 
   myEditCurrentArgument->setFocus();
@@ -196,10 +205,16 @@ void BuildGUI_ShellDlg::ActivateThisDialog()
   GEOMBase_Skeleton::ActivateThisDialog();
   connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 
          SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ;
+
   TColStd_MapOfInteger aMap;
   aMap.Add(GEOM_SHELL);
   aMap.Add(GEOM_FACE);
-  globalSelection( aMap );
+  aMap.Add(GEOM_COMPOUNDFILTER);
+  
+  QValueList<int> aSubShapes;
+  aSubShapes.append(GEOM_FACE);
+  globalSelection( aMap, aSubShapes );
+  
 }
 
 
index d62fc63cdc82445a8ecc9ff5f45a44a3965d8b58..32f321691da55faa8468598f4da353f51dcc63ea 100755 (executable)
@@ -498,6 +498,18 @@ void GEOMBase_Helper::globalSelection( const TColStd_MapOfInteger& theModes,
   getDisplayer()->GlobalSelection( theModes, update );
 }
 
+//================================================================
+// Function : globalSelection
+// Purpose  : Activate selection of subshapes. Set selection filters
+//            in accordance with mode. theMode is from GEOMImpl_Types
+//================================================================
+void GEOMBase_Helper::globalSelection( const TColStd_MapOfInteger& theModes,
+                                       const QValueList<int>& subShapes,
+                                      const bool update )
+{
+  getDisplayer()->GlobalSelection( theModes, update, &subShapes);
+}
+
 //================================================================
 // Function : addInStudy
 // Purpose  : Add object in study
index 911d6e4436170dc2131bb1887fa348c8cf8cd474..62d1f2bb0f5d3a983dc2df6ef8a730fc321b935f 100755 (executable)
@@ -100,6 +100,7 @@ protected:
   void activate( const int );
   void globalSelection( const int = GEOM_ALLOBJECTS, const bool = false  );
   void globalSelection( const TColStd_MapOfInteger&, const bool = false );
+  void globalSelection( const TColStd_MapOfInteger&, const QValueList<int>& ,const bool = false );
   void updateViewer    ();
 
   void prepareSelection( const ObjectList&, const int );
diff --git a/src/GEOMFiltersSelection/GEOM_CompoundFilter.cxx b/src/GEOMFiltersSelection/GEOM_CompoundFilter.cxx
new file mode 100644 (file)
index 0000000..4859885
--- /dev/null
@@ -0,0 +1,136 @@
+//  GEOM GEOM_CompoundFilter : filter selector for the viewer
+//
+//  Copyright (C) 2003  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 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 
+// 
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//
+//  File   : GEOM_CompoundFilter.cxx
+//  Author : Roman NIKOLAEV
+//  Module : GEOM
+
+#include "GEOM_CompoundFilter.h"
+
+// OCCT Includes
+#include <TopTools_MapOfShape.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopoDS_Iterator.hxx>
+
+
+
+//=======================================================================
+// function : GEOM_CompoundFilter
+// purpose  : 
+//=======================================================================
+GEOM_CompoundFilter::GEOM_CompoundFilter(SalomeApp_Study* study)
+: GEOM_SelectionFilter( study )
+{
+  add( TopAbs_COMPOUND );
+}
+
+//=======================================================================
+// function : ~GEOM_CompoundFilter
+// purpose  : 
+//=======================================================================
+GEOM_CompoundFilter::~GEOM_CompoundFilter()
+{
+}
+
+//=======================================================================
+// function : isOk
+// purpose  : 
+//=======================================================================
+bool GEOM_CompoundFilter::isOk( const SUIT_DataOwner* sOwner) const
+{
+  if(GEOM_SelectionFilter::isOk(sOwner)){
+
+    GEOM::GEOM_Object_var obj = getObject( sOwner );
+    TopoDS_Shape shape;
+    if ( getShape( obj, shape )){
+      bool subTypes[TopAbs_SHAPE];
+      getInfo(shape,subTypes);
+      QValueList<int>::const_iterator it;
+      bool result = false;
+      for ( it = myKinds.constBegin(); it != myKinds.constEnd(); ++it )
+        result = result || subTypes[(*it)];
+      
+      return result;
+    }
+  }
+  return false;
+}
+
+
+//=======================================================================
+// function : addSubType
+// purpose  : 
+//=======================================================================
+void GEOM_CompoundFilter::addSubType( const int type)
+{
+  if(!myKinds.contains(type))
+    myKinds.append(type);
+}
+
+//=======================================================================
+// function : addSubTypes
+// purpose  : 
+//=======================================================================
+void GEOM_CompoundFilter::addSubTypes(const QValueList<int>& kinds)
+{
+  myKinds = kinds;     
+}
+
+//=======================================================================
+// function : getInfo()
+// purpose  : 
+//=======================================================================
+void GEOM_CompoundFilter::getInfo(const TopoDS_Shape& aShape, bool subTypes[]) const
+{
+  int iType, nbTypes[TopAbs_SHAPE];
+  for (iType = 0; iType < TopAbs_SHAPE; ++iType){
+    nbTypes[iType] = 0;
+    subTypes[iType] = false;
+  }
+
+  nbTypes[aShape.ShapeType()]++;
+  TopTools_MapOfShape aMapOfShape;
+  aMapOfShape.Add(aShape);
+  TopTools_ListOfShape aListOfShape;
+  aListOfShape.Append(aShape);
+  
+  TopTools_ListIteratorOfListOfShape itL (aListOfShape);
+  for (; itL.More(); itL.Next()) {
+    TopoDS_Iterator it (itL.Value());
+    for (; it.More(); it.Next()) {
+      TopoDS_Shape s = it.Value();
+      if (aMapOfShape.Add(s)) {
+        aListOfShape.Append(s);
+        nbTypes[s.ShapeType()]++;
+      }
+    }
+  }
+  
+  for(iType = TopAbs_COMPSOLID; iType < TopAbs_SHAPE; ++iType) {
+    if(nbTypes[iType] > 0) {
+      subTypes[iType] = true;
+      break;
+    }
+  }
+}
diff --git a/src/GEOMFiltersSelection/GEOM_CompoundFilter.h b/src/GEOMFiltersSelection/GEOM_CompoundFilter.h
new file mode 100644 (file)
index 0000000..2e20c08
--- /dev/null
@@ -0,0 +1,44 @@
+// Copyright (C) 2005  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 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
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#ifndef GEOM_COMPOUNDFILTER_H
+#define GEOM_COMPOUNDFILTER_H
+#include "GEOM_SelectionFilter.h"
+
+class Standard_EXPORT GEOM_CompoundFilter : public GEOM_SelectionFilter
+{
+ public:
+  GEOM_CompoundFilter( SalomeApp_Study* study );
+  ~GEOM_CompoundFilter();
+
+  virtual bool isOk( const SUIT_DataOwner* ) const;
+  void addSubType(const int );
+  void addSubTypes(const QValueList<int>& );
+
+ private:
+  void getInfo(const TopoDS_Shape&, bool subTypes []) const;
+  
+  
+ private:
+  QValueList<int>              myKinds;
+};
+
+
+#endif
+
index 43f5b0d1750d35ce25c72555a9fff1a43870fe25..42c88bb30661a3f5f0967d13fdaf1e6feac8afda 100644 (file)
@@ -40,7 +40,8 @@ salomeinclude_HEADERS = \
        GEOM_TypeFilter.h \
        GEOM_PreviewFilter.h \
        GEOM_LogicalFilter.h \
-       GEOM_OCCFilter.h
+       GEOM_OCCFilter.h \
+       GEOM_CompoundFilter.h
 
 # Sources
 dist_libGEOMFiltersSelection_la_SOURCES = \
@@ -50,7 +51,8 @@ dist_libGEOMFiltersSelection_la_SOURCES = \
        GEOM_TypeFilter.cxx \
         GEOM_PreviewFilter.cxx \
        GEOM_LogicalFilter.cxx \
-       GEOM_OCCFilter.cxx
+       GEOM_OCCFilter.cxx \
+       GEOM_CompoundFilter.cxx
 
 # LIB_CLIENT_IDL= GEOM_Gen.idl SALOMEDS.idl SALOME_Exception.idl SALOME_GenericObj.idl SALOME_Component.idl
 
index fdceadb4d2fdb2898b2be6de0e382ca027d34f1d..79e6926fc6fcaedb9335bcd7ab678203fbf11dd6 100644 (file)
@@ -33,6 +33,7 @@
 #include "GEOM_TypeFilter.h"
 #include "GEOM_EdgeFilter.h"
 #include "GEOM_FaceFilter.h"
+#include "GEOM_CompoundFilter.h"
 #include "GEOM_PreviewFilter.h"
 #include "GEOM_LogicalFilter.h"
 #include "GEOM_OCCFilter.h"
@@ -167,6 +168,30 @@ SUIT_SelectionFilter* GEOM_Displayer::getFilter( const int theMode )
   return aFilter;
 }
 
+//================================================================
+// Function : getComplexFilter
+// Purpose  : Get compound filter corresponding to the type of 
+//            object from GEOMImpl_Types.h
+//================================================================
+SUIT_SelectionFilter* GEOM_Displayer::getComplexFilter( const QValueList<int>* aSubShapes)
+{
+  GEOM_CompoundFilter* aFilter;
+  
+  if(aSubShapes != NULL ) {
+    aFilter = new GEOM_CompoundFilter(getStudy());
+    QValueList<int> aTopAbsTypes;
+    QValueList<int>::const_iterator it;
+    for(it = aSubShapes->constBegin(); it != aSubShapes->constEnd(); ++it ) {
+      int topAbsMode = getTopAbsMode(*it);
+      if(topAbsMode != -1 )
+        aTopAbsTypes.append(topAbsMode);
+    }
+    aFilter->addSubTypes(aTopAbsTypes);
+  }
+  
+  return aFilter;
+}
+
 //================================================================
 // Function : getEntry
 // Purpose  :
@@ -1032,7 +1057,7 @@ void GEOM_Displayer::GlobalSelection( const int theMode, const bool update )
  */
 //=================================================================
 void GEOM_Displayer::GlobalSelection( const TColStd_MapOfInteger& theModes,
-                                     const bool update )
+                                     const bool update, const QValueList<int>* theSubShapes)
 {
   SUIT_Session* session = SUIT_Session::session();
   SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
@@ -1076,7 +1101,11 @@ void GEOM_Displayer::GlobalSelection( const TColStd_MapOfInteger& theModes,
   if ( theModes.Extent() == 1 )
     {
       int aMode = TColStd_MapIteratorOfMapOfInteger( theModes ).Key();
-      aFilter = getFilter( aMode );
+      
+      if(aMode == GEOM_COMPOUNDFILTER)
+        aFilter = getComplexFilter(theSubShapes);
+      else    
+        aFilter = getFilter( aMode );
     }
   else if ( theModes.Extent() > 1 )
     {
@@ -1085,7 +1114,13 @@ void GEOM_Displayer::GlobalSelection( const TColStd_MapOfInteger& theModes,
       QPtrList<SUIT_SelectionFilter> aListOfFilters;
       for ( ; anIter.More(); anIter.Next() )
        {
-         SUIT_SelectionFilter* aFilter = getFilter( anIter.Key() );
+          SUIT_SelectionFilter* aFilter;
+          int aMode = anIter.Key();
+          if(aMode == GEOM_COMPOUNDFILTER)
+            aFilter = getComplexFilter(theSubShapes);
+          else    
+            aFilter = getFilter( aMode );
+
          if ( aFilter )
            aListOfFilters.append( aFilter );
        }
index 8c877c94f46304a24007480603dbc231e0c81061..e5b736e7a1ff0d8d8f738811c1556b55ec3e9261 100644 (file)
@@ -148,7 +148,7 @@ public:
   void         LocalSelection( const Handle(SALOME_InteractiveObject)&, const int );
   void         LocalSelection( const SALOME_ListIO& theIOList, const int );
   void         GlobalSelection( const int = GEOM_ALLOBJECTS, const bool = false );
-  void         GlobalSelection( const TColStd_MapOfInteger&, const bool = false );
+  void         GlobalSelection( const TColStd_MapOfInteger&, const bool = false, const QValueList<int>* = 0 );
 
   SalomeApp_Study* getStudy() const;
 
@@ -171,6 +171,7 @@ protected:
   void        clearTemporary( LightApp_SelectionMgr* theSelMgr );
 
   SUIT_SelectionFilter* getFilter( const int theMode );
+  SUIT_SelectionFilter* getComplexFilter(const QValueList<int>* );
 
 protected:
   Handle(SALOME_InteractiveObject) myIO;
index b2d1ddf84a3d9b0cbeaf22c7981f9c5d5bc72f2c..df856b8562d25e5f7babcc992caa1248066e76d4 100755 (executable)
@@ -81,6 +81,8 @@
 
 #define GEOM_THRUSECTIONS 40
 
+#define GEOM_COMPOUNDFILTER 41
+
 //GEOM_Function types
 
 #define COPY_WITH_REF    1