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