Salome HOME
Update of CheckDone
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_SelectionProxy.h
1 // Copyright (C) 2007-2021  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, or (at your option) any later version.
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 #ifndef SMESHGUI_SELECTIONPROXY_H
24 #define SMESHGUI_SELECTIONPROXY_H
25
26 #include "SMESH_SMESHGUI.hxx"
27
28 #include <SALOME_InteractiveObject.hxx>
29 #include <SALOMEconfig.h>
30 #include CORBA_SERVER_HEADER(SMESH_Mesh)
31 #include CORBA_SERVER_HEADER(GEOM_Gen)
32
33 #include <QColor>
34 #include <QList>
35 #include <QMap>
36 #include <QSet>
37 #include <QString>
38
39 #include <gp_XYZ.hxx>
40
41 class SMESH_Actor;
42
43 namespace SMESH
44 {
45   class SMESHGUI_EXPORT MeshInfo
46   {
47     QMap<int, long> myInfo;
48   public:
49     MeshInfo();
50     uint info( int ) const;
51     uint operator[] ( int );
52     uint count( int, int ) const;
53   private:
54     void addInfo( int, long );
55     friend class SelectionProxy;
56   };
57
58   class SMESHGUI_EXPORT MedInfo
59   {
60     QString myFileName;
61     uint mySize;
62     uint myMajor, myMinor, myRelease;
63   public:
64     MedInfo();
65     bool isValid() const;
66     QString fileName() const;
67     uint size() const;
68     QString version() const;
69   private:
70     void setFileName( const QString& );
71     void setSize( uint );
72     void setVersion( uint, uint, uint );
73     friend class SelectionProxy;
74   };
75
76   class SMESHGUI_EXPORT Position
77   {
78     int myShapeId;
79     int myShapeType;
80     double myU, myV;
81     bool myHasU, myHasV;
82   public:
83     Position();
84     bool isValid() const;
85     int shapeId() const;
86     int shapeType() const;
87     bool hasU() const;
88     double u() const;
89     bool hasV() const;
90     double v() const;
91   private:
92     void setShapeId( int );
93     void setShapeType( int );
94     void setU( double );
95     void setV( double );
96     friend class SelectionProxy;
97   };
98
99   class XYZ
100   {
101     double myX, myY, myZ;
102   public:
103     XYZ();
104     XYZ( double, double, double );
105     XYZ( const gp_XYZ& );
106     void add( double, double, double );
107     void divide( double );
108     double x() const;
109     double y() const;
110     double z() const;
111     operator gp_XYZ() const;
112   };
113
114   typedef QMap< int, QList<int> > Connectivity;
115
116   class SMESHGUI_EXPORT SelectionProxy
117   {
118     Handle(SALOME_InteractiveObject) myIO;
119     SMESH::SMESH_IDSource_var myObject;
120     SMESH_Actor* myActor;
121     bool myDirty;
122
123   public:
124     enum Type
125     {
126       Unknown,
127       Mesh,
128       Submesh,
129       Group,
130       GroupStd,
131       GroupGeom,
132       GroupFilter
133     };
134
135     // construction
136     SelectionProxy();
137     SelectionProxy( const Handle(SALOME_InteractiveObject)& );
138     SelectionProxy( SMESH::SMESH_IDSource_ptr );
139     SelectionProxy( const SelectionProxy& );
140
141     SelectionProxy& operator= ( const SelectionProxy& );
142
143     // comparison
144     bool operator== ( const SelectionProxy& );
145
146     // general purpose methods
147     void refresh();
148
149     bool isNull() const;
150     operator bool() const;
151
152     SMESH::SMESH_IDSource_ptr object() const;
153     const Handle(SALOME_InteractiveObject)& io() const;
154     SMESH_Actor* actor() const;
155
156     bool isValid() const;
157     void load();
158
159     // methods common to all types of proxy
160     QString name() const;
161     Type type() const;
162     MeshInfo meshInfo() const;
163     SelectionProxy mesh() const;
164     bool hasShapeToMesh() const;
165     GEOM::GEOM_Object_ptr shape() const;
166     QString shapeName() const;
167     int shapeType() const;
168     bool isMeshLoaded() const;
169
170     bool hasNode( int );
171     bool nodeCoordinates( int, XYZ& );
172     bool nodeConnectivity( int, Connectivity& );
173     bool nodePosition( int, Position& );
174     QList<SelectionProxy> nodeGroups( int ) const;
175
176     bool hasElement( int );
177     SMESH::ElementType elementType( int ) const;
178     int elementEntityType( int ) const;
179     bool elementConnectivity( int, Connectivity& );
180     bool perFaceConnectivity( int, Connectivity&, int& );
181     bool elementPosition( int, Position& );
182     bool elementGravityCenter( int, XYZ& );
183     bool elementNormal( int, XYZ& );
184     bool elementControl( int, int, double, double& ) const;
185     QList<SelectionProxy> elementGroups( int ) const;
186
187     // methods that work for mesh only
188     MedInfo medFileInfo() const;
189     QList<SelectionProxy> submeshes() const;
190     QList<SelectionProxy> groups() const;
191
192     // methods that work for group only
193     SMESH::ElementType groupElementType() const;
194     QColor color() const;
195     int size( bool = false ) const;
196     int nbNodes( bool = false ) const;
197     QSet<uint> ids() const;
198
199   private:
200     void init();
201   };
202 }
203
204 #endif // SMESHGUI_SELECTIONPROXY_H