Salome HOME
Merge from V5_1_main branch 24/11/2010
[modules/geom.git] / src / GEOMBase / GEOMBase.h
1 //  Copyright (C) 2007-2010  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, int ShapeType);
58   static TopoDS_Shape GetShapeFromIOR(QString IOR);
59   static bool GetShape(const GEOM::GEOM_Object_ptr&, TopoDS_Shape&,
60                        const TopAbs_ShapeEnum = TopAbs_SHAPE);
61   static bool GetTopoFromSelection(const SALOME_ListIO& aList, TopoDS_Shape& tds);
62   static int GetNameOfSelectedIObjects(const SALOME_ListIO& aList, QString& aName,
63                                        const bool theShapesOnly = false);
64   static bool GetShapeTypeString(const TopoDS_Shape& aShape, Standard_CString& aTypeString);
65
66   /* Convertions */
67   static GEOM::GEOM_Object_ptr ConvertIOinGEOMShape(const Handle(SALOME_InteractiveObject)& IO, 
68                                                     Standard_Boolean& testResult);
69   static Handle(GEOM_AISShape) ConvertIOinGEOMAISShape(const Handle(SALOME_InteractiveObject)& IO,
70                                                        Standard_Boolean& testResult,
71                                                        bool onlyInActiveView = false);
72
73   static Handle(AIS_InteractiveObject) GetAIS(const Handle(SALOME_InteractiveObject)& theIO,
74                                               const bool isOnlyInActiveView = false); 
75   static void ConvertListOfIOInListOfIOR(const SALOME_ListIO& aList,
76                                          GEOM::string_array& listIOR); 
77
78   static Handle(GEOM_AISShape) ConvertIORinGEOMAISShape(const char * IOR,
79                                                         Standard_Boolean& testResult,
80                                                         bool onlyInActiveView = false);
81   static GEOM_Actor* ConvertIORinGEOMActor(const char * IOR, Standard_Boolean& testResult,
82                                            bool onlyInActiveView = false);
83
84   static GEOM::GEOM_Object_ptr ConvertIOinGEOMObject(const Handle(SALOME_InteractiveObject)& IO, 
85                                                      Standard_Boolean& testResult);
86
87   static void ConvertListOfIOInListOfGO(const SALOME_ListIO& aList,
88                                         GEOM::ListOfGO& listGO,
89                                         const bool theShapesOnly = false); 
90
91   static GEOM::GEOM_Object_ptr GetObjectFromIOR(const char* theIOR);
92
93   static QString GetIORFromObject(const GEOM::GEOM_Object_ptr& theObject);
94
95   /* Geometry */
96   static bool VertexToPoint(const TopoDS_Shape& S, gp_Pnt& P);
97
98   /* Used just by Plane and Prism */
99   static bool LinearEdgeExtremities(const TopoDS_Shape& S, gp_Pnt& P1, gp_Pnt& P2);
100   static void GetBipointDxDyDz(gp_Pnt P1, gp_Pnt P2, double& dx, double& dy, double& dz);
101
102   /* Simulation management */
103   static bool CreateArrowForLinearEdge(const TopoDS_Shape& tds, TopoDS_Shape& ArrowCone);
104
105   /*  Generates default names */
106   static bool SelectionByNameInDialogs(QWidget* aWidget, const QString& userObjectName,
107                                        const SALOME_ListIO& aList);
108   /* Shows message box with error code */
109   static bool DefineDlgPosition(QWidget* aDlg, int& x, int& y);
110
111   /* This method generates default names for results of geometrical operations */
112   static QString GetDefaultName(const QString& theOperation, const bool extractPrefix = false);
113
114   /* Shows message box with error code and comment */
115   static void ShowErrorMessage(const char* theErrorCode, const char* theComment = 0);
116
117   /* Gets name of object */
118   static QString GetName(GEOM::GEOM_Object_ptr);
119
120   static bool IsShape(GEOM::GEOM_Object_ptr theObj);
121 };
122
123 #endif // GEOMBASE_H