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