Salome HOME
IPAL18573
[modules/geom.git] / src / GEOMBase / GEOMBase.h
1 // GEOM GEOMGUI : GUI for Geometry component
2 //
3 // Copyright (C) 2003  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 // File   : GEOMBase.h
23 // Author : Damien COQUERET, Open CASCADE S.A.S.
24 //
25
26 #ifndef GEOMBASE_H
27 #define GEOMBASE_H
28
29 #include "GEOM_GEOMBase.hxx"
30
31 // SALOME Includes
32 #include <GEOM_AISShape.hxx>
33
34 // IDL Headers
35 #include <SALOMEconfig.h>
36 #include CORBA_SERVER_HEADER(SALOMEDS)
37 #include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
38 #include CORBA_SERVER_HEADER(GEOM_Gen)
39
40 // QT Includes
41 #include <QString>
42
43 class GEOM_Actor;
44 class SALOME_ListIO;
45
46 class QWidget;
47
48 //=================================================================================
49 // class    : GEOMBase
50 // purpose  :
51 //=================================================================================
52 class GEOMBASE_EXPORT GEOMBase
53 {
54 public :
55   /* Selection and objects management */
56   static int GetIndex(const TopoDS_Shape& subshape, const TopoDS_Shape& shape, int ShapeType);
57   static TopoDS_Shape GetShapeFromIOR(QString IOR);
58   static bool GetShape(const GEOM::GEOM_Object_ptr&, TopoDS_Shape&,
59                        const TopAbs_ShapeEnum = TopAbs_SHAPE);
60   static bool GetTopoFromSelection(const SALOME_ListIO& aList, TopoDS_Shape& tds);
61   static int GetNameOfSelectedIObjects(const SALOME_ListIO& aList, QString& aName,
62                                        const bool theShapesOnly = false);
63   static bool GetShapeTypeString(const TopoDS_Shape& aShape, Standard_CString& aTypeString);
64
65   /* Convertions */
66   static GEOM::GEOM_Object_ptr ConvertIOinGEOMShape(const Handle(SALOME_InteractiveObject)& IO, 
67                                                     Standard_Boolean& testResult);
68   static Handle(GEOM_AISShape) ConvertIOinGEOMAISShape(const Handle(SALOME_InteractiveObject)& IO,
69                                                        Standard_Boolean& testResult,
70                                                        bool onlyInActiveView = false);
71
72   static Handle(AIS_InteractiveObject) GetAIS(const Handle(SALOME_InteractiveObject)& theIO,
73                                               const bool isOnlyInActiveView = false); 
74   static void ConvertListOfIOInListOfIOR(const SALOME_ListIO& aList,
75                                          GEOM::string_array& listIOR); 
76
77   static Handle(GEOM_AISShape) ConvertIORinGEOMAISShape(const char * IOR,
78                                                         Standard_Boolean& testResult,
79                                                         bool onlyInActiveView = false);
80   static GEOM_Actor* ConvertIORinGEOMActor(const char * IOR, Standard_Boolean& testResult,
81                                            bool onlyInActiveView = false);
82
83   static GEOM::GEOM_Object_ptr ConvertIOinGEOMObject(const Handle(SALOME_InteractiveObject)& IO, 
84                                                      Standard_Boolean& testResult);
85
86   static void ConvertListOfIOInListOfGO(const SALOME_ListIO& aList,
87                                         GEOM::ListOfGO& listGO,
88                                         const bool theShapesOnly = false); 
89
90   static GEOM::GEOM_Object_ptr GetObjectFromIOR(const char* theIOR);
91
92   static char* GetIORFromObject(const GEOM::GEOM_Object_ptr& theObject);
93
94   /* Geometry */
95   static bool VertexToPoint(const TopoDS_Shape& S, gp_Pnt& P);
96
97   /* Used just by Plane and Prism */
98   static bool LinearEdgeExtremities(const TopoDS_Shape& S, gp_Pnt& P1, gp_Pnt& P2);
99   static void GetBipointDxDyDz(gp_Pnt P1, gp_Pnt P2, double& dx, double& dy, double& dz);
100
101   /* Simulation management */
102   static bool CreateArrowForLinearEdge(const TopoDS_Shape& tds, TopoDS_Shape& ArrowCone);
103
104   /*  Generates default names */
105   static bool SelectionByNameInDialogs(QWidget* aWidget, const QString& userObjectName,
106                                        const SALOME_ListIO& aList);
107   /* Shows message box with error code */
108   static bool DefineDlgPosition(QWidget* aDlg, int& x, int& y);
109
110   /* This method generates default names for results of geometrical operations */
111   static QString GetDefaultName(const QString& theOperation);   
112   /* Shows message box with error code and comment */
113   static void ShowErrorMessage(const char* theErrorCode, const char* theComment = 0);
114
115   /* Gets name of object */
116   static QString GetName(GEOM::GEOM_Object_ptr);
117
118   static bool IsShape(GEOM::GEOM_Object_ptr theObj);
119 };
120
121 #endif // GEOMBASE_H