Salome HOME
0fd37801dca1517e8a218e98ab7ffc9fd29adc7c
[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 // 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.h>
42 //#if defined WNT
43 //#include <SALOME_WNT.hxx>
44 //#else
45 //#define SALOME_WNT_EXPORT
46 //#endif
47
48 #if defined WNT && defined WIN32 && defined SALOME_WNT_EXPORTS
49 #define GEOMBASE_WNT_EXPORT __declspec( dllexport )
50 #else
51 #define GEOMBASE_WNT_EXPORT
52 #endif
53
54 class GEOM_Actor;
55 class SALOME_ListIO;
56 class TColStd_MapOfInteger;
57
58 class QWidget;
59
60 //=================================================================================
61 // class    : GEOMBase
62 // purpose  :
63 //=================================================================================
64 class GEOMBASE_WNT_EXPORT GEOMBase
65 {
66 public :
67   /* Selection and objects management */
68   static int GetIndex(const TopoDS_Shape& subshape, const TopoDS_Shape& shape, int ShapeType);
69   static TopoDS_Shape GetShapeFromIOR(QString IOR);
70   static bool GetShape(const GEOM::GEOM_Object_ptr&, TopoDS_Shape&,
71                        const TopAbs_ShapeEnum = TopAbs_SHAPE);
72   static bool GetTopoFromSelection(const SALOME_ListIO& aList, TopoDS_Shape& tds);
73   static int GetNameOfSelectedIObjects(const SALOME_ListIO& aList, QString& aName,
74                                        const bool theShapesOnly = false);
75   static bool GetShapeTypeString(const TopoDS_Shape& aShape, Standard_CString& aTypeString);
76
77   /* Convertions */
78   static GEOM::GEOM_Object_ptr ConvertIOinGEOMShape(const Handle(SALOME_InteractiveObject)& IO, 
79                                                     Standard_Boolean& testResult);
80   static Handle(GEOM_AISShape) ConvertIOinGEOMAISShape(const Handle(SALOME_InteractiveObject)& IO,
81                                                        Standard_Boolean& testResult,
82                                                        bool onlyInActiveView = false);
83
84   static Handle(AIS_InteractiveObject) GetAIS(const Handle(SALOME_InteractiveObject)& theIO,
85                                               const bool isOnlyInActiveView = false); 
86   static void ConvertListOfIOInListOfIOR(const SALOME_ListIO& aList,
87                                          GEOM::string_array& listIOR); 
88
89   static Handle(GEOM_AISShape) ConvertIORinGEOMAISShape(const char * IOR,
90                                                         Standard_Boolean& testResult,
91                                                         bool onlyInActiveView = false);
92   static GEOM_Actor* ConvertIORinGEOMActor(const char * IOR, Standard_Boolean& testResult,
93                                            bool onlyInActiveView = false);
94
95   static GEOM::GEOM_Object_ptr ConvertIOinGEOMObject(const Handle(SALOME_InteractiveObject)& IO, 
96                                                      Standard_Boolean& testResult);
97
98   static void ConvertListOfIOInListOfGO(const SALOME_ListIO& aList,
99                                         GEOM::ListOfGO& listGO,
100                                         const bool theShapesOnly = false); 
101
102   static GEOM::GEOM_Object_ptr GetObjectFromIOR(const char* theIOR);
103
104   static char* GetIORFromObject(const GEOM::GEOM_Object_ptr& theObject);
105
106   /* Geometry */
107   static bool VertexToPoint(const TopoDS_Shape& S, gp_Pnt& P);
108
109   /* Used just by Plane and Prism */
110   static bool LinearEdgeExtremities(const TopoDS_Shape& S, gp_Pnt& P1, gp_Pnt& P2);
111   static void GetBipointDxDyDz(gp_Pnt P1, gp_Pnt P2, double& dx, double& dy, double& dz);
112
113   /* User dialog 1 parameter returned */
114   static double Parameter(Standard_Boolean& res,
115                           const char* aValue1 = 0, const char* aTitle1 = 0,
116                           const char* aTitle = 0, const double bottom = -1E6,
117                           const double top = +1E6, const int decimals = 6);
118
119   /* Simulation management */
120   static bool CreateArrowForLinearEdge(const TopoDS_Shape& tds, TopoDS_Shape& ArrowCone);
121
122   /*  Generates default names */
123   static bool SelectionByNameInDialogs(QWidget* aWidget, const QString& userObjectName,
124                                        const SALOME_ListIO& aList);
125   /* Shows message box with error code */
126   static bool DefineDlgPosition(QWidget* aDlg, int& x, int& y);
127
128   /* This method generates default names for results of geometrical operations */
129   static QString GetDefaultName(const QString& theOperation);   
130   /* Shows message box with error code and comment */
131   static void ShowErrorMessage(const char* theErrorCode, const char* theComment = 0);
132
133   /* Gets name of object */
134   static QString GetName(GEOM::GEOM_Object_ptr);
135
136   static bool IsShape(GEOM::GEOM_Object_ptr theObj);
137 };
138
139 #endif