src/GEOMGUI/GeometryGUI.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   : GeometryGUI.h
00025 //  Author : Lucien PIGNOLONI
00026 //  Module : GEOM
00027 //  $Header: /home/server/cvs/GEOM/GEOM_SRC/src/GEOMGUI/GeometryGUI.h,v 1.19 2006/06/01 11:32:35 jfa Exp $
00028 
00029 #ifndef GEOMETRYGUI_H
00030 #define GEOMETRYGUI_H
00031 
00032 #include "SalomeApp_Module.h"
00033 
00034 #include "GEOMGUI.h"
00035 #include "GEOM_Client.hxx"
00036 #include "SALOME_InteractiveObject.hxx"
00037 
00038 #include "SALOMEDSClient.hxx"
00039 
00040 // QT Includes
00041 #include <qmap.h>
00042 
00043 // OCCT Includes
00044 #include <gp_Ax3.hxx>
00045 
00046 // IDL headers
00047 #include "SALOMEconfig.h"
00048 #include CORBA_CLIENT_HEADER(SALOMEDS)
00049 
00050 #ifdef WNT
00051 #include <SALOME_WNT.hxx>
00052 #else
00053 #define SALOME_WNT_EXPORT
00054 #endif
00055 
00056 //#if defined WNT 
00057 //#include <SALOME_WNT.hxx>
00058 //#else
00059 //#define SALOME_WNT_EXPORT
00060 //#endif
00061 
00062 #if defined WNT && defined WIN32 && defined SALOME_WNT_EXPORTS
00063 #define GEOMGUI_WNT_EXPORT __declspec( dllexport )
00064 #else
00065 #define GEOMGUI_WNT_EXPORT
00066 #endif
00067 
00068 typedef QMap<QString, GEOMGUI*> GUIMap;
00069 
00070 class QDialog;
00071 class QPopupMenu;
00072 class GEOMGUI_OCCSelector;
00073 class LightApp_VTKSelector;
00074 class LightApp_Selection;
00075 class SUIT_ViewManager;
00076 
00077 //=================================================================================
00078 // class    : GeometryGUI
00079 // purpose  :
00080 //=================================================================================
00081 class  GEOMGUI_WNT_EXPORT GeometryGUI : public SalomeApp_Module
00082 {
00083   Q_OBJECT;
00084 
00085 public:
00086   // Constructor
00087   GeometryGUI();
00088 
00089   // Destructor
00090   ~GeometryGUI();
00091 
00092   virtual LightApp_Displayer* displayer();
00093   virtual void                initialize( CAM_Application* );
00094   virtual QString             engineIOR() const;
00095 
00096   static bool                 InitGeomGen();   //BugID IPAL9186: SRN: To be called by Python scripts
00097 
00098   static  GEOM::GEOM_Gen_var  GetGeomGen();//        { return GeometryGUI::myComponentGeom; }
00099 
00100   static CORBA::Object_var    ClientSObjectToObject (_PTR(SObject) theSObject);
00101   static SALOMEDS::Study_var  ClientStudyToStudy (_PTR(Study) theStudy);
00102 
00103   GEOM_Client&                GetShapeReader()    { return myShapeReader; }
00104   Standard_CString&           GetFatherior()      { return myFatherior; }
00105   //void                        SetState( const int state ) { myState = state; }
00106   //int                         GetState() const    { return myState; }
00107 
00108   // Get active dialog box
00109   QDialog*                    GetActiveDialogBox(){ return myActiveDialogBox; }
00110   // Set active dialog box
00111   void                        SetActiveDialogBox( QDialog* aDlg );
00112 
00113   // Non modal dialog boxes management
00114   void                        EmitSignalDeactivateDialog();
00115   void                        EmitSignalCloseAllDialogs();
00116   void                        EmitSignalDefaultStepValueChanged( double newVal );
00117 
00118   void                        OnGUIEvent( int id );
00119 
00120 //  virtual bool                SetSettings();
00121 //  virtual void                SupportedViewType ( int* buffer, int bufferSize );
00122   virtual void                BuildPresentation( const Handle(SALOME_InteractiveObject)&, SUIT_ViewWindow* = 0 );
00123 
00124 //  virtual void                DefinePopup( QString & theContext, QString & theParent, QString & theObject);
00125 //  virtual bool                CustomPopup( QAD_Desktop* parent, QPopupMenu* popup, const QString& theContext,
00126 //                                const QString& theParent, const QString& theObject );
00127 
00128   // The Working Plane management
00129   void                        SetWorkingPlane( gp_Ax3 wp ) { myWorkingPlane = wp;   }
00130   gp_Ax3                      GetWorkingPlane()            { return myWorkingPlane; }
00131   void                        ActiveWorkingPlane();
00132 
00133   virtual void                windows( QMap<int, int>& ) const;
00134   virtual void                viewManagers( QStringList& ) const;
00135 
00136   virtual void                contextMenuPopup( const QString&, QPopupMenu*, QString& );
00137   virtual void                createPreferences();
00138   virtual void                preferencesChanged( const QString&, const QString& );
00139 
00140 
00141 public slots:
00142   virtual bool                deactivateModule( SUIT_Study* );
00143   virtual bool                activateModule( SUIT_Study* );
00144   virtual void                OnKeyPress  ( SUIT_ViewWindow*, QKeyEvent*   );
00145   virtual void                OnMousePress( SUIT_ViewWindow*, QMouseEvent* );
00146   virtual void                OnMouseMove ( SUIT_ViewWindow*, QMouseEvent* );
00147 
00148 protected slots:
00149   virtual void                onViewManagerAdded( SUIT_ViewManager* );
00150   virtual void                onViewManagerRemoved( SUIT_ViewManager* );
00151 
00152 private slots:
00153   void                        OnGUIEvent();
00154   void                        onWindowActivated( SUIT_ViewWindow* );
00155 
00156 signals :
00157   void                        SignalDeactivateActiveDialog();
00158   void                        SignalCloseAllDialogs();
00159   void                        SignalDefaultStepValueChanged( double newVal );
00160 
00161 protected:
00162   virtual LightApp_Selection* createSelection() const;
00163 
00164 private:
00165   GEOMGUI*                    getLibrary( const QString& libraryName );
00166   void                        createGeomAction( const int id, const QString& po_id,
00167                               const QString& icon_id = QString(""),
00168                               const int key = 0, const bool toggle = false );
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 public:
00175   static GEOM::GEOM_Gen_var   myComponentGeom;   // GEOM engine!!!
00176 private:  
00177   GUIMap                      myGUIMap;          // GUI libraries map
00178   QDialog*                    myActiveDialogBox; // active dialog box
00179   GEOM_Client                 myShapeReader;     // geom shape reader
00180   Standard_CString            myFatherior;
00181   int                         myState;           // identify a method
00182   gp_Ax3                      myWorkingPlane;
00183   QMap<int,QString>           myRules;           // popup rules
00184 
00185   QPtrList<GEOMGUI_OCCSelector>   myOCCSelectors;
00186   QPtrList<LightApp_VTKSelector> myVTKSelectors;
00187 
00188   LightApp_Displayer*         myDisplayer;
00189 
00190 friend class DisplayGUI;
00191 };
00192 
00193 #endif