Salome HOME
WIN32 compilation.
[modules/geom.git] / src / GEOMBase / GEOMBase.h
1 // Copyright (C) 2007-2013  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 // GEOM GEOMGUI : GUI for Geometry component
24 // File   : GEOMBase.h
25 // Author : Damien COQUERET, Open CASCADE S.A.S.
26 //
27 #ifndef GEOMBASE_H
28 #define GEOMBASE_H
29
30 #include "GEOM_GEOMBase.hxx"
31
32 // SALOME Includes
33 #include <GEOM_AISShape.hxx>
34
35 // IDL Headers
36 #include <SALOMEconfig.h>
37 #include CORBA_SERVER_HEADER(SALOMEDS)
38 #include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
39 #include CORBA_SERVER_HEADER(GEOM_Gen)
40
41 // QT Includes
42 #include <QString>
43
44 class GEOM_Actor;
45 class SALOME_ListIO;
46
47 class QWidget;
48
49 //=================================================================================
50 // class    : GEOMBase
51 // purpose  :
52 //=================================================================================
53 class GEOMBASE_EXPORT GEOMBase
54 {
55 public :
56   /* Selection and objects management */
57   static int          GetIndex( const TopoDS_Shape& subshape, const TopoDS_Shape& shape );
58   static TopoDS_Shape GetShapeFromIOR( const QString& IOR );
59   static bool         GetShape( GEOM::GEOM_Object_ptr object,
60                                 TopoDS_Shape& shape,
61                                 const TopAbs_ShapeEnum type = TopAbs_SHAPE );
62   static TopoDS_Shape GetTopoFromSelection( const SALOME_ListIO& IObjects );
63   static int          GetNameOfSelectedIObjects( const SALOME_ListIO& IObjects,
64                                                  QString& name,
65                                                  const bool shapesOnly = false );
66   static QString      GetShapeTypeString( const TopoDS_Shape& shape );
67
68   /* Convertions */
69   static Handle(GEOM_AISShape)
70                       ConvertIOinGEOMAISShape( const Handle(SALOME_InteractiveObject)& IO,
71                                                bool onlyInActiveView = false );
72
73   static Handle(AIS_InteractiveObject)
74                       GetAIS( const Handle(SALOME_InteractiveObject)& IO,
75                               bool onlyInActiveView = false,
76                               bool onlyGeom = false ); 
77   static QStringList  ConvertListOfIOInListOfIOR( const SALOME_ListIO& IObjects ); 
78
79   static Handle(GEOM_AISShape) 
80                       ConvertIORinGEOMAISShape( const QString& IOR,
81                                                 bool onlyInActiveView = false );
82   static GEOM_Actor*  ConvertIORinGEOMActor( const QString& IOR,
83                                              bool onlyInActiveView = false );
84
85   static GEOM::GEOM_Object_ptr
86                       ConvertIOinGEOMObject( const Handle(SALOME_InteractiveObject)& IO );
87
88   static void         ConvertListOfIOInListOfGO( const SALOME_ListIO& IObjects,
89                                                  GEOM::ListOfGO& geomObjects,
90                                                  bool shapesOnly = false ); 
91
92   static GEOM::GEOM_Object_ptr
93                       GetObjectFromIOR( const QString& IOR );
94
95   static QString      GetIORFromObject( GEOM::GEOM_Object_ptr object );
96
97   /* Geometry */
98   static bool         VertexToPoint( const TopoDS_Shape& shape, gp_Pnt& point );
99
100   /* Used just by Plane and Prism */
101   static bool         LinearEdgeExtremities( const TopoDS_Shape& shape,
102                                              gp_Pnt& point1, gp_Pnt& point2 );
103   static void         GetBipointDxDyDz( const gp_Pnt& point1, const gp_Pnt& point2,
104                                         double& dx, double& dy, double& dz );
105
106   /* Simulation management */
107   static TopoDS_Shape CreateArrowForLinearEdge( const TopoDS_Shape& tds );
108
109   /*  Generates default names */
110   static bool         SelectionByNameInDialogs( QWidget* widget,
111                                                 const QString& userObjectName,
112                                                 const SALOME_ListIO& IObjects );
113   /* Shows message box with error code */
114   static void         DefineDlgPosition( QWidget* dlg, int& x, int& y );
115
116   /* This method generates default names for results of geometrical operations */
117   static QString      GetDefaultName( const QString& operation, bool extractPrefix = false );
118
119   /* Shows message box with error code and comment */
120   static void         ShowErrorMessage( const QString& errorCode, const QString& comment = QString() );
121
122   /* Gets name of object */
123   static QString      GetName( GEOM::GEOM_Object_ptr object );
124
125   /* Check if object has shape */
126   static bool         IsShape( GEOM::GEOM_Object_ptr object );
127
128   /* Get string representation of shape type */
129   static QString      TypeName( TopAbs_ShapeEnum type );
130   
131   /* Get study entry for the given object  */
132   static QString      GetEntry( GEOM::GEOM_Object_ptr object );
133
134   /* Publish sub-shape under the main object */
135   static void         PublishSubObject( GEOM::GEOM_Object_ptr object );
136 };
137
138 #endif // GEOMBASE_H