src/GEOMBase/GEOMBase.h

Go to the documentation of this file.
00001 //  GEOM GEOMGUI : GUI for Geometry component
00002 //
00003 //  Copyright (C) 2003  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 //
00024 //  File   : GEOMBase.h
00025 //  Author : Damien COQUERET
00026 //  Module : GEOM
00027 
00028 #ifndef GEOMBASE_H
00029 #define GEOMBASE_H
00030 
00031 // SALOME Includes
00032 #include "GEOM_AISShape.hxx"
00033 
00034 // IDL Headers
00035 #include <SALOMEconfig.h>
00036 #include CORBA_SERVER_HEADER(SALOMEDS)
00037 #include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
00038 #include CORBA_SERVER_HEADER(GEOM_Gen)
00039 
00040 // QT Includes
00041 #include <qstring.h>
00042 //#if defined WNT
00043 //#include <SALOME_WNT.hxx>
00044 //#else
00045 //#define SALOME_WNT_EXPORT
00046 //#endif
00047 
00048 #if defined WNT && defined WIN32 && defined SALOME_WNT_EXPORTS
00049 #define GEOMBASE_WNT_EXPORT __declspec( dllexport )
00050 #else
00051 #define GEOMBASE_WNT_EXPORT
00052 #endif
00053 
00054 class GEOM_Actor;
00055 class SALOME_ListIO;
00056 class TColStd_MapOfInteger;
00057 
00058 class QWidget;
00059 
00060 //=================================================================================
00061 // class    : GEOMBase
00062 // purpose  :
00063 //=================================================================================
00064 class GEOMBASE_WNT_EXPORT GEOMBase
00065 {
00066 public :
00067   /* Selection and objects management */
00068   static int GetIndex(const TopoDS_Shape& subshape, const TopoDS_Shape& shape, int ShapeType);
00069   static TopoDS_Shape GetShapeFromIOR(QString IOR);
00070   static bool GetShape(const GEOM::GEOM_Object_ptr&, TopoDS_Shape&,
00071                  const TopAbs_ShapeEnum = TopAbs_SHAPE);
00072   static bool GetTopoFromSelection(const SALOME_ListIO& aList, TopoDS_Shape& tds);
00073   static int GetNameOfSelectedIObjects(const SALOME_ListIO& aList, QString& aName,
00074                            const bool theShapesOnly = false);
00075   static bool GetShapeTypeString(const TopoDS_Shape& aShape, Standard_CString& aTypeString);
00076 
00077   /* Convertions */
00078   static GEOM::GEOM_Object_ptr ConvertIOinGEOMShape(const Handle(SALOME_InteractiveObject)& IO, 
00079                                   Standard_Boolean& testResult);
00080   static Handle(GEOM_AISShape) ConvertIOinGEOMAISShape(const Handle(SALOME_InteractiveObject)& IO,
00081                                      Standard_Boolean& testResult,
00082                                      bool onlyInActiveView = false);
00083 
00084   static Handle(AIS_InteractiveObject) GetAIS(const Handle(SALOME_InteractiveObject)& theIO,
00085                                const bool isOnlyInActiveView = false); 
00086   static void ConvertListOfIOInListOfIOR(const SALOME_ListIO& aList,
00087                           GEOM::string_array& listIOR); 
00088 
00089   static Handle(GEOM_AISShape) ConvertIORinGEOMAISShape(const char * IOR,
00090                                    Standard_Boolean& testResult,
00091                                    bool onlyInActiveView = false);
00092   static GEOM_Actor* ConvertIORinGEOMActor(const char * IOR, Standard_Boolean& testResult,
00093                             bool onlyInActiveView = false);
00094 
00095   static GEOM::GEOM_Object_ptr ConvertIOinGEOMObject(const Handle(SALOME_InteractiveObject)& IO, 
00096                                    Standard_Boolean& testResult);
00097 
00098   static void ConvertListOfIOInListOfGO(const SALOME_ListIO& aList,
00099                          GEOM::ListOfGO& listGO,
00100                          const bool theShapesOnly = false); 
00101 
00102   static GEOM::GEOM_Object_ptr GetObjectFromIOR(const char* theIOR);
00103 
00104   static char* GetIORFromObject(const GEOM::GEOM_Object_ptr& theObject);
00105 
00106   /* Geometry */
00107   static bool VertexToPoint(const TopoDS_Shape& S, gp_Pnt& P);
00108 
00109   /* Used just by Plane and Prism */
00110   static bool LinearEdgeExtremities(const TopoDS_Shape& S, gp_Pnt& P1, gp_Pnt& P2);
00111   static void GetBipointDxDyDz(gp_Pnt P1, gp_Pnt P2, double& dx, double& dy, double& dz);
00112 
00113   /* User dialog 1 parameter returned */
00114   static double Parameter(Standard_Boolean& res,
00115                  const char* aValue1 = 0, const char* aTitle1 = 0,
00116                  const char* aTitle = 0, const double bottom = -1E6,
00117                  const double top = +1E6, const int decimals = 6);
00118 
00119   /* Simulation management */
00120   static bool CreateArrowForLinearEdge(const TopoDS_Shape& tds, TopoDS_Shape& ArrowCone);
00121 
00122   /*  Generates default names */
00123   static bool SelectionByNameInDialogs(QWidget* aWidget, const QString& userObjectName,
00124                            const SALOME_ListIO& aList);
00125   /* Shows message box with error code */
00126   static bool DefineDlgPosition(QWidget* aDlg, int& x, int& y);
00127 
00128   /* This method generates default names for results of geometrical operations */
00129   static QString GetDefaultName(const QString& theOperation);   
00130   /* Shows message box with error code and comment */
00131   static void ShowErrorMessage(const char* theErrorCode, const char* theComment = 0);
00132 
00133   /* Gets name of object */
00134   static QString GetName(GEOM::GEOM_Object_ptr);
00135 
00136   static bool IsShape(GEOM::GEOM_Object_ptr theObj);
00137 };
00138 
00139 #endif