Salome HOME
0021014: EDF 1583 SMESH: Improvement of the Python Dump for the creation of groups
[modules/smesh.git] / src / SMESH_I / SMESH_Group_i.hxx
1 // Copyright (C) 2007-2011  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
23 //  SMESH SMESH_I : idl implementation based on 'SMESH' unit's classes
24 //  File   : SMESH_Group_i.hxx
25 //  Author : Sergey ANIKIN, OCC
26 //  Module : SMESH
27 //
28 #ifndef SMESH_Group_i_HeaderFile
29 #define SMESH_Group_i_HeaderFile
30
31 #include "SMESH.hxx"
32 #include "SMESH_Mesh_i.hxx"
33 #include "SMESH_Filter_i.hxx"
34
35 #include <SALOMEconfig.h>
36 #include CORBA_SERVER_HEADER(SMESH_Group)
37 #include CORBA_SERVER_HEADER(SMESH_Mesh)
38 #include CORBA_CLIENT_HEADER(GEOM_Gen)
39
40 #include "SALOME_GenericObj_i.hh"
41
42 class SMESH_Group;
43 class SMESHDS_GroupBase;
44
45 // ===========
46 // Group Base
47 // ===========
48 class SMESH_I_EXPORT SMESH_GroupBase_i:
49   public virtual POA_SMESH::SMESH_GroupBase,
50   public virtual SALOME::GenericObj_i
51 {
52  public:
53   SMESH_GroupBase_i(PortableServer::POA_ptr thePOA,
54                     SMESH_Mesh_i*           theMeshServant,
55                     const int               theLocalID );
56   virtual ~SMESH_GroupBase_i();
57
58   // CORBA interface implementation
59   void SetName(const char* name);
60   char* GetName();
61   SMESH::ElementType GetType();
62   CORBA::Long Size();
63   CORBA::Boolean IsEmpty();
64   CORBA::Boolean Contains(CORBA::Long elem_id);
65   CORBA::Long GetID(CORBA::Long elem_index);
66   SMESH::long_array* GetListOfID();
67   SMESH::SMESH_Mesh_ptr GetMesh();
68
69   /*!
70    * Returns statistic of mesh elements
71    * Result array of number enityties
72    * Inherited from SMESH_IDSource
73    */
74   virtual SMESH::long_array* GetMeshInfo();
75
76   // Inherited from SMESH_IDSource interface
77   virtual SMESH::long_array* GetIDs();
78
79   /*!
80    * Returns types of elements it contains
81    * Inherited from SMESH_IDSource interface
82    */
83   virtual SMESH::array_of_ElementType* GetTypes();
84
85   // Internal C++ interface
86   int GetLocalID() const { return myLocalID; }
87   SMESH_Mesh_i* GetMeshServant() const { return myMeshServant; }
88   SMESH_Group* GetSmeshGroup() const;
89   SMESHDS_GroupBase* GetGroupDS() const;
90
91   void SetColor(const SALOMEDS::Color& color);
92   SALOMEDS::Color GetColor();
93
94   void SetColorNumber(CORBA::Long color);
95   CORBA::Long GetColorNumber();
96
97 private:
98   SMESH_Mesh_i* myMeshServant;
99   int myLocalID;
100
101   void changeLocalId(int localId) { myLocalID = localId; }
102   friend class SMESH_Mesh_i;
103 };
104
105 // ======
106 // Group
107 // ======
108
109 class SMESH_I_EXPORT SMESH_Group_i:
110   public virtual POA_SMESH::SMESH_Group,
111   public SMESH_GroupBase_i
112 {
113  public:
114   SMESH_Group_i( PortableServer::POA_ptr thePOA,
115                  SMESH_Mesh_i*           theMeshServant,
116                  const int               theLocalID );
117   // CORBA interface implementation
118   void Clear();
119   CORBA::Long Add( const SMESH::long_array& theIDs );
120   CORBA::Long Remove( const SMESH::long_array& theIDs );
121
122   CORBA::Long AddByPredicate( SMESH::Predicate_ptr thePredicate );
123   CORBA::Long RemoveByPredicate( SMESH::Predicate_ptr thePredicate );
124
125   CORBA::Long AddFrom( SMESH::SMESH_IDSource_ptr theSource );
126 };
127
128 // =========================
129 // Group linked to geometry
130 // =========================
131
132 class SMESH_I_EXPORT SMESH_GroupOnGeom_i:
133   public virtual POA_SMESH::SMESH_GroupOnGeom,
134   public SMESH_GroupBase_i
135 {
136  public:
137   SMESH_GroupOnGeom_i( PortableServer::POA_ptr thePOA,
138                        SMESH_Mesh_i*           theMeshServant,
139                        const int               theLocalID );
140   // CORBA interface implementation
141   GEOM::GEOM_Object_ptr GetShape();
142 };
143
144 // =========================
145 // Group deined by filter
146 // =========================
147
148 class SMESH_I_EXPORT SMESH_GroupOnFilter_i:
149   public virtual POA_SMESH::SMESH_GroupOnFilter,
150   public SMESH_GroupBase_i,
151   public SMESH::Filter_i::TPredicateChangeWaiter
152 {
153  public:
154   SMESH_GroupOnFilter_i( PortableServer::POA_ptr thePOA,
155                          SMESH_Mesh_i*           theMeshServant,
156                          const int               theLocalID );
157   ~SMESH_GroupOnFilter_i();
158
159   // Persistence
160   static SMESH::Filter_ptr StringToFilter(const std::string& thePersistentString );
161   std::string FilterToString() const;
162
163   static SMESH_PredicatePtr GetPredicate( SMESH::Filter_ptr );
164
165   // CORBA interface implementation
166   void SetFilter(SMESH::Filter_ptr theFilter);
167   SMESH::Filter_ptr GetFilter();
168
169   // method of SMESH::Filter_i::TPredicateChangeWaiter
170   virtual void PredicateChanged();
171
172  private:
173   SMESH::Filter_var myFilter;
174 };
175 #endif