Salome HOME
Fix for the bug IPAL22851: Sub-shapes spelling
[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::long_array* GetNodeIDs();
68   CORBA::Long GetNumberOfNodes();
69   CORBA::Boolean IsNodeInfoAvailable(); // for gui
70   SMESH::SMESH_Mesh_ptr GetMesh();
71
72   /*!
73    * Returns statistic of mesh elements
74    * Result array of number enityties
75    * Inherited from SMESH_IDSource
76    */
77   virtual SMESH::long_array* GetMeshInfo();
78
79   // Inherited from SMESH_IDSource interface
80   virtual SMESH::long_array* GetIDs();
81
82   /*!
83    * Returns types of elements it contains
84    * Inherited from SMESH_IDSource interface
85    */
86   virtual SMESH::array_of_ElementType* GetTypes();
87
88   // Internal C++ interface
89   int GetLocalID() const { return myLocalID; }
90   SMESH_Mesh_i* GetMeshServant() const { return myMeshServant; }
91   SMESH_Group* GetSmeshGroup() const;
92   SMESHDS_GroupBase* GetGroupDS() const;
93
94   void SetColor(const SALOMEDS::Color& color);
95   SALOMEDS::Color GetColor();
96
97   void SetColorNumber(CORBA::Long color);
98   CORBA::Long GetColorNumber();
99
100 private:
101   SMESH_Mesh_i* myMeshServant;
102   int myLocalID;
103
104   void changeLocalId(int localId) { myLocalID = localId; }
105   friend class SMESH_Mesh_i;
106
107   int myNbNodes, myGroupDSTic;
108 };
109
110 // ======
111 // Group
112 // ======
113
114 class SMESH_I_EXPORT SMESH_Group_i:
115   public virtual POA_SMESH::SMESH_Group,
116   public SMESH_GroupBase_i
117 {
118  public:
119   SMESH_Group_i( PortableServer::POA_ptr thePOA,
120                  SMESH_Mesh_i*           theMeshServant,
121                  const int               theLocalID );
122   // CORBA interface implementation
123   void Clear();
124   CORBA::Long Add( const SMESH::long_array& theIDs );
125   CORBA::Long Remove( const SMESH::long_array& theIDs );
126
127   CORBA::Long AddByPredicate( SMESH::Predicate_ptr thePredicate );
128   CORBA::Long RemoveByPredicate( SMESH::Predicate_ptr thePredicate );
129
130   CORBA::Long AddFrom( SMESH::SMESH_IDSource_ptr theSource );
131 };
132
133 // =========================
134 // Group linked to geometry
135 // =========================
136
137 class SMESH_I_EXPORT SMESH_GroupOnGeom_i:
138   public virtual POA_SMESH::SMESH_GroupOnGeom,
139   public SMESH_GroupBase_i
140 {
141  public:
142   SMESH_GroupOnGeom_i( PortableServer::POA_ptr thePOA,
143                        SMESH_Mesh_i*           theMeshServant,
144                        const int               theLocalID );
145   // CORBA interface implementation
146   GEOM::GEOM_Object_ptr GetShape();
147 };
148
149 // =========================
150 // Group deined by filter
151 // =========================
152
153 class SMESH_I_EXPORT SMESH_GroupOnFilter_i:
154   public virtual POA_SMESH::SMESH_GroupOnFilter,
155   public SMESH_GroupBase_i,
156   public SMESH::Filter_i::TPredicateChangeWaiter
157 {
158  public:
159   SMESH_GroupOnFilter_i( PortableServer::POA_ptr thePOA,
160                          SMESH_Mesh_i*           theMeshServant,
161                          const int               theLocalID );
162   ~SMESH_GroupOnFilter_i();
163
164   // Persistence
165   static SMESH::Filter_ptr StringToFilter(const std::string& thePersistentString );
166   std::string FilterToString() const;
167
168   static SMESH_PredicatePtr GetPredicate( SMESH::Filter_ptr );
169
170   // CORBA interface implementation
171   void SetFilter(SMESH::Filter_ptr theFilter);
172   SMESH::Filter_ptr GetFilter();
173
174   // method of SMESH::Filter_i::TPredicateChangeWaiter
175   virtual void PredicateChanged();
176
177  private:
178   SMESH::Filter_var myFilter;
179 };
180 #endif