Salome HOME
Preparation of intermediate revision
[modules/geom.git] / src / GEOMFiltersSelection / GEOM_TypeFilter.cxx
index 26df6985eb75236fa651a17ec7cf6e3793eda6e7..a9bbde7380e790af5232d2f349b8c1cd279e04c4 100644 (file)
-//  GEOM GEOMGUI : Implementation of selection filters for GEOM module
+//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-//  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+//  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.
 //
-//              
-//  File   : GEOM_TypeFilter.cxx
-//  Author : Sergey LITONIN
-//  Module : GEOM
-
-#include "GEOM_TypeFilter.hxx"
-#include "SALOME_InteractiveObject.hxx"
-#include "GEOM_Client.hxx"
-#include "QAD_Application.h"
-#include "QAD_Desktop.h"
-#include "utilities.h"
-
-static GEOM::GEOM_Object_ptr convertIOinGEOMObject(
-  const Handle(SALOME_InteractiveObject)& theIO, Standard_Boolean& theResult )
-{
-  theResult = Standard_False;
-  GEOM::GEOM_Object_var aReturnObject;
-  if ( !theIO.IsNull() )
-  {
-    const char* anEntry = theIO->getEntry();
-    SALOMEDS::SObject_var aSObj =
-      QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument()->FindObjectID( anEntry );
-    if ( !CORBA::is_nil( aSObj ) )
-    {
-      aReturnObject = GEOM::GEOM_Object::_narrow( aSObj->GetObject() );
-      theResult = !CORBA::is_nil( aReturnObject );
-    }
-  }
-  return aReturnObject._retn();
-}
-
-/*
-  Class       : GEOM_TypeFilter
-  Description : Filter for combaining several filters with logical operation (OR or AND)
-*/
-
-IMPLEMENT_STANDARD_HANDLE( GEOM_TypeFilter, SALOME_TypeFilter )
-IMPLEMENT_STANDARD_RTTIEXT( GEOM_TypeFilter, SALOME_TypeFilter )
+//  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
+//
+#include "GEOM_TypeFilter.h"
 
 //=======================================================================
-// name    : GEOM_TypeFilter::GEOM_TypeFilter
-// Purpose : Constructor
+// function : GEOM_TypeFilter
+// purpose  : 
 //=======================================================================
-GEOM_TypeFilter::GEOM_TypeFilter( const int theType )
-: SALOME_TypeFilter( "GEOM" )
+GEOM_TypeFilter::GEOM_TypeFilter( SalomeApp_Study* study, const int type, const bool isShapeType )
+:GEOM_SelectionFilter( study ),
+ myType( type ),
+ myIsShapeType(isShapeType)
 {
-  myType = theType;
 }
 
 //=======================================================================
-// name    : GEOM_TypeFilter::~GEOM_TypeFilter
-// Purpose : Destructor
+// function : ~GEOM_TypeFilter
+// purpose  : 
 //=======================================================================
 GEOM_TypeFilter::~GEOM_TypeFilter()
 {
 }
 
 //=======================================================================
-// name    : GEOM_TypeFilter::IsOk
-// Purpose : Verify validity of entry object
+// function : isOk
+// purpose  : 
 //=======================================================================
-Standard_Boolean GEOM_TypeFilter::IsOk( const Handle(SALOME_InteractiveObject)& theIO ) const
+bool GEOM_TypeFilter::isOk( const SUIT_DataOwner* sOwner ) const
 {
-  if ( SALOME_TypeFilter::IsOk( theIO ) )
-  {
-    Standard_Boolean aTestRes = Standard_False;
-    GEOM::GEOM_Object_var anObj = convertIOinGEOMObject( theIO, aTestRes );
-    if ( aTestRes && !anObj->_is_nil() )
-      return anObj->GetType() == myType;
-  }
-
+  GEOM::GEOM_Object_var obj = getObject( sOwner );
+  if ( !CORBA::is_nil( obj ) )
+    {
+      if (!myIsShapeType)
+       return obj->GetType() == type();
+      else
+       return obj->GetShapeType() == type();
+    }
+  
   return false;
 }
 
 //=======================================================================
-// name    : GEOM_TypeFilter::SetType
-// Purpose : Set type of object
+// function : type
+// purpose  : 
 //=======================================================================
-void GEOM_TypeFilter::SetType( const int theType )
-{
-  myType = theType;
-}
-
-//=======================================================================
-// name    : GEOM_TypeFilter::GetType
-// Purpose : Get type of object
-//=======================================================================
-int GEOM_TypeFilter::GetType() const
+int GEOM_TypeFilter::type() const
 {
   return myType;
 }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-