1 // GEOM GEOMGUI : GUI for Geometry component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
25 // Author : Damien COQUERET
31 #include "GEOM_GEOMBase.hxx"
34 #include "GEOM_AISShape.hxx"
37 #include <SALOMEconfig.h>
38 #include CORBA_SERVER_HEADER(SALOMEDS)
39 #include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
40 #include CORBA_SERVER_HEADER(GEOM_Gen)
50 //=================================================================================
53 //=================================================================================
54 class GEOMBASE_EXPORT GEOMBase
57 /* Selection and objects management */
58 static int GetIndex(const TopoDS_Shape& subshape, const TopoDS_Shape& shape, int ShapeType);
59 static TopoDS_Shape GetShapeFromIOR(QString IOR);
60 static bool GetShape(const GEOM::GEOM_Object_ptr&, TopoDS_Shape&,
61 const TopAbs_ShapeEnum = TopAbs_SHAPE);
62 static bool GetTopoFromSelection(const SALOME_ListIO& aList, TopoDS_Shape& tds);
63 static int GetNameOfSelectedIObjects(const SALOME_ListIO& aList, QString& aName,
64 const bool theShapesOnly = false);
65 static bool GetShapeTypeString(const TopoDS_Shape& aShape, Standard_CString& aTypeString);
68 static GEOM::GEOM_Object_ptr ConvertIOinGEOMShape(const Handle(SALOME_InteractiveObject)& IO,
69 Standard_Boolean& testResult);
70 static Handle(GEOM_AISShape) ConvertIOinGEOMAISShape(const Handle(SALOME_InteractiveObject)& IO,
71 Standard_Boolean& testResult,
72 bool onlyInActiveView = false);
74 static Handle(AIS_InteractiveObject) GetAIS(const Handle(SALOME_InteractiveObject)& theIO,
75 const bool isOnlyInActiveView = false);
76 static void ConvertListOfIOInListOfIOR(const SALOME_ListIO& aList,
77 GEOM::string_array& listIOR);
79 static Handle(GEOM_AISShape) ConvertIORinGEOMAISShape(const char * IOR,
80 Standard_Boolean& testResult,
81 bool onlyInActiveView = false);
82 static GEOM_Actor* ConvertIORinGEOMActor(const char * IOR, Standard_Boolean& testResult,
83 bool onlyInActiveView = false);
85 static GEOM::GEOM_Object_ptr ConvertIOinGEOMObject(const Handle(SALOME_InteractiveObject)& IO,
86 Standard_Boolean& testResult);
88 static void ConvertListOfIOInListOfGO(const SALOME_ListIO& aList,
89 GEOM::ListOfGO& listGO,
90 const bool theShapesOnly = false);
92 static GEOM::GEOM_Object_ptr GetObjectFromIOR(const char* theIOR);
94 static char* GetIORFromObject(const GEOM::GEOM_Object_ptr& theObject);
97 static bool VertexToPoint(const TopoDS_Shape& S, gp_Pnt& P);
99 /* Used just by Plane and Prism */
100 static bool LinearEdgeExtremities(const TopoDS_Shape& S, gp_Pnt& P1, gp_Pnt& P2);
101 static void GetBipointDxDyDz(gp_Pnt P1, gp_Pnt P2, double& dx, double& dy, double& dz);
103 /* User dialog 1 parameter returned */
104 static double Parameter(Standard_Boolean& res,
105 const char* aValue1 = 0, const char* aTitle1 = 0,
106 const char* aTitle = 0, const double bottom = -1E6,
107 const double top = +1E6, const int decimals = 6);
109 /* Simulation management */
110 static bool CreateArrowForLinearEdge(const TopoDS_Shape& tds, TopoDS_Shape& ArrowCone);
112 /* Generates default names */
113 static bool SelectionByNameInDialogs(QWidget* aWidget, const QString& userObjectName,
114 const SALOME_ListIO& aList);
115 /* Shows message box with error code */
116 static bool DefineDlgPosition(QWidget* aDlg, int& x, int& y);
118 /* This method generates default names for results of geometrical operations */
119 static QString GetDefaultName(const QString& theOperation);
120 /* Shows message box with error code and comment */
121 static void ShowErrorMessage(const char* theErrorCode, const char* theComment = 0);
123 /* Gets name of object */
124 static QString GetName(GEOM::GEOM_Object_ptr);
126 static bool IsShape(GEOM::GEOM_Object_ptr theObj);