]> SALOME platform Git repositories - modules/gui.git/blob - src/SVTK/SVTK_Functor.h
Salome HOME
eab12cb14a4542935abfe152c7b6da33a323a447
[modules/gui.git] / src / SVTK / SVTK_Functor.h
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 #ifndef SVTK_Functor_H
23 #define SVTK_Functor_H
24
25 #include <functional>
26
27 #include <string>
28
29 #include <VTKViewer_Functor.h>
30
31 #include "SALOME_InteractiveObject.hxx"
32
33 /*!
34   \file SVTK_Functor.h
35   This file contains numbers of functors that allows user to perform corresponding operations with existing presentations.
36   Combination with algorithms it gives powerful, flexible and simple to extend way to introduce new type of operation.
37 */
38
39 namespace SVTK
40 {
41   using namespace VTK;
42
43   //! This functor check, if the actor have pointed entry
44   template<class TActor> 
45   struct TIsSameEntry
46   {
47     std::string myEntry;
48     //! To construct the functor
49     TIsSameEntry(const char* theEntry): 
50       myEntry(theEntry) 
51     {}
52     //! To calculate the functor
53     bool operator()(TActor* theActor)
54     {
55       if ( theActor->hasIO() )
56       {
57         Handle(SALOME_InteractiveObject) anIO = theActor->getIO();
58         if ( anIO->hasEntry() )
59           return myEntry == anIO->getEntry();
60       }
61       return false;
62     }
63   };
64
65
66   //----------------------------------------------------------------
67   //! This functor check, if the actor point to the same #SALOME_InteractiveObject
68   template<class TActor> 
69   struct TIsSameIObject
70   {
71     Handle(SALOME_InteractiveObject) myIObject;
72     //! To construct the functor
73     TIsSameIObject(const Handle(SALOME_InteractiveObject)& theIObject):
74       myIObject(theIObject)
75     {}
76     //! To calculate the functor
77     bool operator()(TActor* theActor)
78     {
79       if(theActor->hasIO())
80       {
81         Handle(SALOME_InteractiveObject) anIO = theActor->getIO();
82         return myIObject->isSame(anIO);
83       }
84       return false;
85     }
86   };
87
88
89   //----------------------------------------------------------------
90   /*!
91     This highlight every input actor
92   */
93   template<class TActor> 
94   struct THighlight
95   {
96     bool myIsHighlight;
97     //! To construct the functor
98     THighlight(bool theIsHighlight):
99       myIsHighlight( theIsHighlight ) 
100     {}
101     //! To calculate the functor
102     void operator()(TActor* theActor) 
103     {
104       if(theActor->GetVisibility() && theActor->GetMapper())
105         theActor->highlight( myIsHighlight );
106     }
107   };
108
109 }
110
111
112 #endif