Back to index

salome-gui  6.5.0
SVTK_Functor.h
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 #ifndef SVTK_Functor_H
00024 #define SVTK_Functor_H
00025 
00026 #include <functional>
00027 
00028 #include <string>
00029 
00030 #include <VTKViewer_Functor.h>
00031 
00032 #include <SALOME_InteractiveObject.hxx>
00033 #include <SALOME_ListIO.hxx>
00040 namespace SVTK
00041 {
00042   using namespace VTK;
00043 
00045   template<class TActor> 
00046   struct TIsSameEntry
00047   {
00048     std::string myEntry;
00050     TIsSameEntry(const char* theEntry): 
00051       myEntry(theEntry) 
00052     {}
00054     bool operator()(TActor* theActor)
00055     {
00056       if ( theActor->hasIO() )
00057       {
00058         Handle(SALOME_InteractiveObject) anIO = theActor->getIO();
00059         if ( anIO->hasEntry() )
00060           return myEntry == anIO->getEntry();
00061       }
00062       return false;
00063     }
00064   };
00065 
00066 
00067   //----------------------------------------------------------------
00069   template<class TActor> 
00070   struct TIsSameIObject
00071   {
00072     Handle(SALOME_InteractiveObject) myIObject;
00074     TIsSameIObject(const Handle(SALOME_InteractiveObject)& theIObject):
00075       myIObject(theIObject)
00076     {}
00078     bool operator()(TActor* theActor)
00079     {
00080       if(theActor->hasIO())
00081       {
00082         Handle(SALOME_InteractiveObject) anIO = theActor->getIO();
00083         return myIObject->isSame(anIO);
00084       }
00085       return false;
00086     }
00087   };
00088 
00089 
00090   //----------------------------------------------------------------
00094   template<class TActor> 
00095   struct THighlight
00096   {
00097     bool myIsHighlight;
00099     THighlight(bool theIsHighlight):
00100       myIsHighlight( theIsHighlight ) 
00101     {}
00103     void operator()(TActor* theActor) 
00104     {
00105       if(theActor->GetVisibility() && theActor->GetMapper())
00106         theActor->highlight( myIsHighlight );
00107     }
00108   };
00109 
00110 
00111   //----------------------------------------------------------------
00115   template<class TActor> 
00116     struct TCollectIfVisible
00117     {
00118       SALOME_ListIO& myList;
00120       TCollectIfVisible (SALOME_ListIO& theList) : myList(theList)
00121       {}
00123       void operator()(TActor* theActor) 
00124       {
00125        if(theActor->GetVisibility() && theActor->hasIO())
00126          myList.Append( theActor->getIO() );
00127       }
00128     };
00129 }
00130 
00131 
00132 #endif