Salome HOME
0023614: EDF 16256 - Coordinates of a group
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_SelectionProxy.h
index 8301c2576a292015655e4afa24662ff2d2bb55e9..63d479de007d3c499e6700b8e9ee3fad2809e6c5 100644 (file)
@@ -20,8 +20,8 @@
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
-#ifndef SMESHGUI_OBJECTPROXY_H
-#define SMESHGUI_OBJECTPROXY_H
+#ifndef SMESHGUI_SELECTIONPROXY_H
+#define SMESHGUI_SELECTIONPROXY_H
 
 #include "SMESH_SMESHGUI.hxx"
 
 #include CORBA_SERVER_HEADER(GEOM_Gen)
 
 #include <QColor>
+#include <QList>
 #include <QMap>
 #include <QSet>
 #include <QString>
 
-class SMESH_Actor;
-
-class SMESHGUI_EXPORT SMESHGUI_MeshInfo
-{
-  QMap<int, long> myInfo;
+#include <gp_XYZ.hxx>
 
-public:
-  SMESHGUI_MeshInfo();
-
-  void addInfo( int, long );
-  uint info( int ) const;
-  uint operator[] ( int );
-  uint count( int, int ) const;
-};
+class SMESH_Actor;
 
-class SMESHGUI_EXPORT SMESHGUI_MedFileInfo
+namespace SMESH
 {
-  QString myFileName;
-  uint mySize;
-  uint myMajor, myMinor, myRelease;
-
-public:
-  SMESHGUI_MedFileInfo();
-
-  bool isValid() const;
-  QString fileName() const;
-  void setFileName( const QString& );
-  uint size() const;
-  void setSize( uint );
-  QString version() const;
-  void setVersion( uint, uint, uint );
-};
-
-class SMESHGUI_EXPORT SMESHGUI_SelectionProxy
-{
-  Handle(SALOME_InteractiveObject) myIO;
-  SMESH::SMESH_IDSource_var myObject;
-  SMESH_Actor* myActor;
-  bool myDirty;
-
-public:
-  enum Type
+  class SMESHGUI_EXPORT MeshInfo
   {
-    Unknown,
-    Mesh,
-    Submesh,
-    Group,
-    GroupStd,
-    GroupGeom,
-    GroupFilter
+    QMap<int, long> myInfo;
+  public:
+    MeshInfo();
+    uint info( int ) const;
+    uint operator[] ( int );
+    uint count( int, int ) const;
+  private:
+    void addInfo( int, long );
+    friend class SelectionProxy;
   };
 
-  SMESHGUI_SelectionProxy();
-  SMESHGUI_SelectionProxy( const Handle(SALOME_InteractiveObject)& );
-  SMESHGUI_SelectionProxy( SMESH::SMESH_IDSource_ptr );
-  SMESHGUI_SelectionProxy( const SMESHGUI_SelectionProxy& );
-
-  SMESHGUI_SelectionProxy& operator= ( const SMESHGUI_SelectionProxy& );
-  bool operator== ( const SMESHGUI_SelectionProxy& );
-
-  void refresh();
-
-  bool isNull() const;
-  operator bool() const;
-
-  SMESH::SMESH_IDSource_ptr object() const;
-  const Handle(SALOME_InteractiveObject)& io() const;
-  SMESH_Actor* actor() const;
-
-  bool isValid() const;
-  void load();
+  class SMESHGUI_EXPORT MedInfo
+  {
+    QString myFileName;
+    uint mySize;
+    uint myMajor, myMinor, myRelease;
+  public:
+    MedInfo();
+    bool isValid() const;
+    QString fileName() const;
+    uint size() const;
+    QString version() const;
+  private:
+    void setFileName( const QString& );
+    void setSize( uint );
+    void setVersion( uint, uint, uint );
+    friend class SelectionProxy;
+  };
 
-  QString name() const;
-  Type type() const;
-  SMESHGUI_MeshInfo meshInfo() const;
-  SMESHGUI_SelectionProxy mesh() const;
-  bool hasShapeToMesh() const;
-  GEOM::GEOM_Object_ptr shape() const;
-  QString shapeName() const;
-  int shapeType() const;
+  class SMESHGUI_EXPORT Position
+  {
+    int myShapeId;
+    int myShapeType;
+    double myU, myV;
+    bool myHasU, myHasV;
+  public:
+    Position();
+    bool isValid() const;
+    int shapeId() const;
+    int shapeType() const;
+    bool hasU() const;
+    double u() const;
+    bool hasV() const;
+    double v() const;
+  private:
+    void setShapeId( int );
+    void setShapeType( int );
+    void setU( double );
+    void setV( double );
+    friend class SelectionProxy;
+  };
 
-  bool isMeshLoaded() const;
-  SMESHGUI_MedFileInfo medFileInfo() const;
-  QList<SMESHGUI_SelectionProxy> submeshes() const;
-  QList<SMESHGUI_SelectionProxy> groups() const;
+  class XYZ
+  {
+    double myX, myY, myZ;
+  public:
+    XYZ();
+    XYZ( double, double, double );
+    XYZ( const gp_XYZ& );
+    void add( double, double, double );
+    void divide( double );
+    double x() const;
+    double y() const;
+    double z() const;
+    operator gp_XYZ() const;
+  };
 
-  SMESH::ElementType elementType() const;
-  QColor color() const;
-  int size( bool = false ) const;
-  int nbNodes( bool = false ) const;
-  QSet<uint> ids() const;
+  typedef QMap< int, QList<int> > Connectivity;
 
-private:
-  void init();
-};
+  class SMESHGUI_EXPORT SelectionProxy
+  {
+    Handle(SALOME_InteractiveObject) myIO;
+    SMESH::SMESH_IDSource_var myObject;
+    SMESH_Actor* myActor;
+    bool myDirty;
+
+  public:
+    enum Type
+    {
+      Unknown,
+      Mesh,
+      Submesh,
+      Group,
+      GroupStd,
+      GroupGeom,
+      GroupFilter
+    };
+
+    // construction
+    SelectionProxy();
+    SelectionProxy( const Handle(SALOME_InteractiveObject)& );
+    SelectionProxy( SMESH::SMESH_IDSource_ptr );
+    SelectionProxy( const SelectionProxy& );
+
+    SelectionProxy& operator= ( const SelectionProxy& );
+
+    // comparison
+    bool operator== ( const SelectionProxy& );
+
+    // general purpose methods
+    void refresh();
+
+    bool isNull() const;
+    operator bool() const;
+
+    SMESH::SMESH_IDSource_ptr object() const;
+    const Handle(SALOME_InteractiveObject)& io() const;
+    SMESH_Actor* actor() const;
+
+    bool isValid() const;
+    void load();
+
+    // methods common to all types of proxy
+    QString name() const;
+    Type type() const;
+    MeshInfo meshInfo() const;
+    SelectionProxy mesh() const;
+    bool hasShapeToMesh() const;
+    GEOM::GEOM_Object_ptr shape() const;
+    QString shapeName() const;
+    int shapeType() const;
+    bool isMeshLoaded() const;
+
+    bool hasNode( int );
+    bool nodeCoordinates( int, XYZ& );
+    bool nodeConnectivity( int, Connectivity& );
+    bool nodePosition( int, Position& );
+    QList<SelectionProxy> nodeGroups( int ) const;
+
+    bool hasElement( int );
+    SMESH::ElementType elementType( int ) const;
+    int elementEntityType( int ) const;
+    bool elementConnectivity( int, Connectivity& );
+    bool elementPosition( int, Position& );
+    bool elementGravityCenter( int, XYZ& );
+    bool elementNormal( int, XYZ& );
+    bool elementControl( int, int, double, double& ) const;
+    QList<SelectionProxy> elementGroups( int ) const;
+
+    // methods that work for mesh only
+    MedInfo medFileInfo() const;
+    QList<SelectionProxy> submeshes() const;
+    QList<SelectionProxy> groups() const;
+
+    // methods that work for group only
+    SMESH::ElementType groupElementType() const;
+    QColor color() const;
+    int size( bool = false ) const;
+    int nbNodes( bool = false ) const;
+    QSet<uint> ids() const;
+
+  private:
+    void init();
+  };
+}
 
-#endif // SMESHGUI_OBJECTPROXY_H
+#endif // SMESHGUI_SELECTIONPROXY_H