Back to index

salome-geom  6.5.0
GEOMBase.h
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 // GEOM GEOMGUI : GUI for Geometry component
00024 // File   : GEOMBase.h
00025 // Author : Damien COQUERET, Open CASCADE S.A.S.
00026 //
00027 #ifndef GEOMBASE_H
00028 #define GEOMBASE_H
00029 
00030 #include "GEOM_GEOMBase.hxx"
00031 
00032 // SALOME Includes
00033 #include <GEOM_AISShape.hxx>
00034 
00035 // IDL Headers
00036 #include <SALOMEconfig.h>
00037 #include CORBA_SERVER_HEADER(SALOMEDS)
00038 #include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
00039 #include CORBA_SERVER_HEADER(GEOM_Gen)
00040 
00041 // QT Includes
00042 #include <QString>
00043 
00044 class GEOM_Actor;
00045 class SALOME_ListIO;
00046 
00047 class QWidget;
00048 
00049 //=================================================================================
00050 // class    : GEOMBase
00051 // purpose  :
00052 //=================================================================================
00053 class GEOMBASE_EXPORT GEOMBase
00054 {
00055 public :
00056   /* Selection and objects management */
00057   static int          GetIndex( const TopoDS_Shape& subshape, const TopoDS_Shape& shape );
00058   static TopoDS_Shape GetShapeFromIOR( const QString& IOR );
00059   static bool         GetShape( GEOM::GEOM_Object_ptr object,
00060                             TopoDS_Shape& shape,
00061                             const TopAbs_ShapeEnum type = TopAbs_SHAPE );
00062   static TopoDS_Shape GetTopoFromSelection( const SALOME_ListIO& IObjects );
00063   static int          GetNameOfSelectedIObjects( const SALOME_ListIO& IObjects,
00064                                            QString& name,
00065                                            const bool shapesOnly = false );
00066   static QString      GetShapeTypeString( const TopoDS_Shape& shape );
00067 
00068   /* Convertions */
00069   static Handle(GEOM_AISShape)
00070                       ConvertIOinGEOMAISShape( const Handle(SALOME_InteractiveObject)& IO,
00071                                           bool onlyInActiveView = false );
00072 
00073   static Handle(AIS_InteractiveObject)
00074                       GetAIS( const Handle(SALOME_InteractiveObject)& IO,
00075                            bool onlyInActiveView = false,
00076                            bool onlyGeom = false ); 
00077   static QStringList  ConvertListOfIOInListOfIOR( const SALOME_ListIO& IObjects ); 
00078 
00079   static Handle(GEOM_AISShape) 
00080                       ConvertIORinGEOMAISShape( const QString& IOR,
00081                                           bool onlyInActiveView = false );
00082   static GEOM_Actor*  ConvertIORinGEOMActor( const QString& IOR,
00083                                         bool onlyInActiveView = false );
00084 
00085   static GEOM::GEOM_Object_ptr
00086                       ConvertIOinGEOMObject( const Handle(SALOME_InteractiveObject)& IO );
00087 
00088   static void         ConvertListOfIOInListOfGO( const SALOME_ListIO& IObjects,
00089                                            GEOM::ListOfGO& geomObjects,
00090                                            bool shapesOnly = false ); 
00091 
00092   static GEOM::GEOM_Object_ptr
00093                       GetObjectFromIOR( const QString& IOR );
00094 
00095   static QString      GetIORFromObject( GEOM::GEOM_Object_ptr object );
00096 
00097   /* Geometry */
00098   static bool         VertexToPoint( const TopoDS_Shape& shape, gp_Pnt& point );
00099 
00100   /* Used just by Plane and Prism */
00101   static bool         LinearEdgeExtremities( const TopoDS_Shape& shape,
00102                                         gp_Pnt& point1, gp_Pnt& point2 );
00103   static void         GetBipointDxDyDz( const gp_Pnt& point1, const gp_Pnt& point2,
00104                                    double& dx, double& dy, double& dz );
00105 
00106   /* Simulation management */
00107   static TopoDS_Shape CreateArrowForLinearEdge( const TopoDS_Shape& tds );
00108 
00109   /*  Generates default names */
00110   static bool         SelectionByNameInDialogs( QWidget* widget,
00111                                           const QString& userObjectName,
00112                                           const SALOME_ListIO& IObjects );
00113   /* Shows message box with error code */
00114   static void         DefineDlgPosition( QWidget* dlg, int& x, int& y );
00115 
00116   /* This method generates default names for results of geometrical operations */
00117   static QString      GetDefaultName( const QString& operation, bool extractPrefix = false );
00118 
00119   /* Shows message box with error code and comment */
00120   static void         ShowErrorMessage( const QString& errorCode, const QString& comment = QString() );
00121 
00122   /* Gets name of object */
00123   static QString      GetName( GEOM::GEOM_Object_ptr object );
00124 
00125   /* Check if object has shape */
00126   static bool         IsShape( GEOM::GEOM_Object_ptr object );
00127 
00128   /* Get string representation of shape type */
00129   static QString      TypeName( TopAbs_ShapeEnum type );
00130   
00131   /* Get study entry for the given object  */
00132   static QString      GetEntry( GEOM::GEOM_Object_ptr object );
00133 
00134   /* Publish sub-shape under the main object */
00135   static void         PublishSubObject( GEOM::GEOM_Object_ptr object );
00136 };
00137 
00138 #endif // GEOMBASE_H