1 // Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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, or (at your option) any later version.
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
23 // GEOM GEOMGUI : GUI for Geometry component
25 // Author : Damien COQUERET, Open CASCADE S.A.S.
30 #include "GEOM_GEOMBase.hxx"
33 #include <GEOM_AISShape.hxx>
34 #include "GEOM_GenericObjPtr.h"
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 );
59 static TopoDS_Shape GetShapeFromIOR( const QString& IOR );
60 static bool GetShape( GEOM::GEOM_Object_ptr object,
62 const TopAbs_ShapeEnum type = TopAbs_SHAPE );
63 static TopoDS_Shape GetTopoFromSelection( const SALOME_ListIO& IObjects );
64 static int GetNameOfSelectedIObjects( const SALOME_ListIO& IObjects,
66 const bool shapesOnly = false );
67 static QString GetShapeTypeString( const TopoDS_Shape& shape );
70 static Handle(GEOM_AISShape)
71 ConvertIOinGEOMAISShape( const Handle(SALOME_InteractiveObject)& IO,
72 bool onlyInActiveView = false );
74 static Handle(AIS_InteractiveObject)
75 GetAIS( const Handle(SALOME_InteractiveObject)& IO,
76 bool onlyInActiveView = false,
77 bool onlyGeom = false );
78 static QStringList ConvertListOfIOInListOfIOR( const SALOME_ListIO& IObjects );
80 static Handle(GEOM_AISShape)
81 ConvertIORinGEOMAISShape( const QString& IOR,
82 bool onlyInActiveView = false );
83 static GEOM_Actor* ConvertIORinGEOMActor( const QString& IOR,
84 bool onlyInActiveView = false );
86 static GEOM::GEOM_Object_ptr
87 ConvertIOinGEOMObject( const Handle(SALOME_InteractiveObject)& IO );
89 static void ConvertListOfIOInListOfGO( const SALOME_ListIO& IObjects,
90 GEOM::ListOfGO& geomObjects,
91 bool shapesOnly = false );
93 static GEOM::GEOM_Object_ptr
94 GetObjectFromIOR( const QString& IOR );
96 static QString GetIORFromObject( GEOM::GEOM_Object_ptr object );
99 static bool VertexToPoint( const TopoDS_Shape& shape, gp_Pnt& point );
101 /* Used just by Plane and Prism */
102 static bool LinearEdgeExtremities( const TopoDS_Shape& shape,
103 gp_Pnt& point1, gp_Pnt& point2 );
104 static void GetBipointDxDyDz( const gp_Pnt& point1, const gp_Pnt& point2,
105 double& dx, double& dy, double& dz );
107 /* Simulation management */
108 static TopoDS_Shape CreateArrowForLinearEdge( const TopoDS_Shape& tds );
110 /* Generates default names */
111 static bool SelectionByNameInDialogs( QWidget* widget,
112 const QString& userObjectName,
113 const SALOME_ListIO& IObjects );
114 /* Shows message box with error code */
115 static void DefineDlgPosition( QWidget* dlg, int& x, int& y );
117 /* This method generates default names for results of geometrical operations */
118 static QString GetDefaultName( const QString& operation, bool extractPrefix = false );
120 /* Shows message box with error code and comment */
121 static void ShowErrorMessage( const QString& errorCode, const QString& comment = QString() );
123 /* Gets name of object */
124 static QString GetName( GEOM::GEOM_Object_ptr object );
126 /* Check if object has shape */
127 static bool IsShape( GEOM::GEOM_Object_ptr object );
129 /* Get string representation of shape type */
130 static QString TypeName( TopAbs_ShapeEnum type, bool capitalize = false );
132 /* Get study entry for the given object */
133 static QString GetEntry( GEOM::GEOM_Object_ptr object );
135 /* Publish sub-shape under the main object */
136 static void PublishSubObject( GEOM::GEOM_Object_ptr object, const QString& name = QString() );
138 static void Synchronize( QList<GEOM::GeomObjPtr>& left, QList<GEOM::GeomObjPtr>& right );