Back to index

salome-geom  6.5.0
GeometryGUI.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   : GeometryGUI.h
00025 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
00026 
00027 #ifndef GEOMETRYGUI_H
00028 #define GEOMETRYGUI_H
00029 
00030 #include "GEOM_GEOMGUI.hxx"
00031 
00032 #include <Basics_OCCTVersion.hxx>
00033 
00034 #include <SalomeApp_Module.h>
00035 
00036 #include <GEOM_Client.hxx>
00037 #include <SALOME_InteractiveObject.hxx>
00038 #include <SALOMEDSClient.hxx>
00039 
00040 #include "GEOMGUI.h"
00041 
00042 // QT Includes
00043 #include <QMap>
00044 
00045 // OCCT Includes
00046 #include <gp_Ax3.hxx>
00047 
00048 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
00049 #include <TColStd_HArray1OfByte.hxx>
00050 #else
00051 #include <Graphic3d_HArray1OfBytes.hxx>
00052 #endif
00053 
00054 // IDL headers
00055 #include "SALOMEconfig.h"
00056 #include CORBA_CLIENT_HEADER(SALOMEDS)
00057 
00058 class QDialog;
00059 class QMenu;
00060 class QAction;
00061 class GEOMGUI_OCCSelector;
00062 class LightApp_VTKSelector;
00063 class LightApp_Selection;
00064 class SUIT_ViewManager;
00065 class SalomeApp_Study;
00066 
00067 //=================================================================================
00068 // class    : GeometryGUI
00069 // purpose  :
00070 //=================================================================================
00071 class  GEOMGUI_EXPORT GeometryGUI : public SalomeApp_Module
00072 {
00073   Q_OBJECT;
00074 
00075 public:
00076   // Constructor
00077   GeometryGUI();
00078 
00079   // Destructor
00080   ~GeometryGUI();
00081 
00082   virtual LightApp_Displayer* displayer();
00083   virtual void                initialize( CAM_Application* );
00084   virtual QString             engineIOR() const;
00085 
00086 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
00087   static Handle(TColStd_HArray1OfByte) getTexture (SalomeApp_Study*, int, int&, int&);
00088 #else
00089   static Handle(Graphic3d_HArray1OfBytes) getTexture (SalomeApp_Study*, int, int&, int&);
00090 #endif
00091 
00092   static bool                 InitGeomGen();
00093 
00094   static  GEOM::GEOM_Gen_var  GetGeomGen();
00095 
00096   static CORBA::Object_var    ClientSObjectToObject (_PTR(SObject) theSObject);
00097   static SALOMEDS::Study_var  ClientStudyToStudy (_PTR(Study) theStudy);
00098 
00099   static void                 Modified( bool = true );
00100 
00101   GEOM_Client&                GetShapeReader()    { static SHAPE_READER(myShapeReader);return myShapeReader; }
00102 
00103   // Get active dialog box
00104   QDialog*                    GetActiveDialogBox(){ return myActiveDialogBox; }
00105   // Set active dialog box
00106   void                        SetActiveDialogBox( QDialog* aDlg );
00107 
00108   // Non modal dialog boxes management
00109   void                        EmitSignalDeactivateDialog();
00110   void                        EmitSignalCloseAllDialogs();
00111   void                        EmitSignalDefaultStepValueChanged( double newVal );
00112 
00113   // Process action
00114   void                        OnGUIEvent( int id );
00115 
00116   // The Working Plane management
00117   void                        SetWorkingPlane( gp_Ax3 wp ) { myWorkingPlane = wp;   }
00118   gp_Ax3                      GetWorkingPlane()            { return myWorkingPlane; }
00119   void                        ActiveWorkingPlane();
00120 
00121   virtual bool                renameObject( const QString&, const QString& );
00122   virtual bool                renameAllowed( const QString& ) const;
00123 
00124   virtual void                windows( QMap<int, int>& ) const;
00125   virtual void                viewManagers( QStringList& ) const;
00126 
00127   virtual void                contextMenuPopup( const QString&, QMenu*, QString& );
00128   virtual void                createPreferences();
00129   virtual void                preferencesChanged( const QString&, const QString& );
00130   int                         getLocalSelectionMode() const;
00131   void                        setLocalSelectionMode(const int mode);
00132 
00133   virtual void storeVisualParameters  (int savePoint);
00134   virtual void restoreVisualParameters(int savePoint);
00135 
00136   QAction*                    getAction(const int id);
00137 
00138 public slots:
00139   virtual bool                deactivateModule( SUIT_Study* );
00140   virtual bool                activateModule( SUIT_Study* );
00141   virtual void                OnKeyPress  ( SUIT_ViewWindow*, QKeyEvent*   );
00142   virtual void                OnMousePress( SUIT_ViewWindow*, QMouseEvent* );
00143   virtual void                OnMouseMove ( SUIT_ViewWindow*, QMouseEvent* );
00144   virtual void                OnMouseRelease ( SUIT_ViewWindow*, QMouseEvent* );
00145 
00146 protected slots:
00147   virtual void                onViewManagerAdded( SUIT_ViewManager* );
00148   virtual void                onViewManagerRemoved( SUIT_ViewManager* );
00149 
00150 private slots:
00151   void                        OnGUIEvent();
00152   void                        onWindowActivated( SUIT_ViewWindow* );
00153   void                        onViewAboutToShow();
00154 
00155 signals :
00156   void                        SignalDeactivateActiveDialog();
00157   void                        SignalCloseAllDialogs();
00158   void                        SignalDefaultStepValueChanged( double newVal );
00159 
00160 protected:
00161   virtual LightApp_Selection* createSelection() const;
00162 
00163 private:
00164   GEOMGUI*                    getLibrary( const QString& libraryName );
00165   void                        createGeomAction( const int id, const QString& po_id,
00166                                                 const QString& icon_id = QString(""),
00167                                                 const int key = 0, const bool toggle = false,
00168                                           const QString& shortcutAction = QString() );
00169   void                        createPopupItem( const int, const QString& clients, const QString& types,
00170                                                const bool isSingle = false, const int isVisible = -1,
00171                                                const bool isExpandAll = false, const bool isOCC = false,
00172                                                const int parentId = -1 );
00173 
00174   void                        createOriginAndBaseVectors();
00175 
00176 public:
00177   static GEOM::GEOM_Gen_var   myComponentGeom;   // GEOM engine!!!
00178 
00179 private:  
00180 
00181 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
00182   typedef QMap<long, Handle(TColStd_HArray1OfByte)> TextureMap;
00183 #else
00184   typedef QMap<long, Handle(Graphic3d_HArray1OfBytes)> TextureMap;
00185 #endif
00186 
00187   typedef QMap<long, TextureMap> StudyTextureMap;
00188   typedef QMap<QString, GEOMGUI*> GUIMap;
00189 
00190   GUIMap                      myGUIMap;          // GUI libraries map
00191   QDialog*                    myActiveDialogBox; // active dialog box
00192   gp_Ax3                      myWorkingPlane;
00193   QMap<int,QString>           myRules;           // popup rules
00194   static StudyTextureMap      myTextureMap;      // texture map
00195 
00196   QList<GEOMGUI_OCCSelector*>  myOCCSelectors;
00197   QList<LightApp_VTKSelector*> myVTKSelectors;
00198 
00199   LightApp_Displayer*         myDisplayer;
00200   int                         myLocalSelectionMode; //Select Only
00201 
00202   friend class DisplayGUI;
00203 };
00204 
00205 #endif