Back to index

salome-smesh  6.5.0
SMESHGUI.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 // SMESH SMESHGUI : GUI for SMESH component
00024 // File   : SMESHGUI.h
00025 // Author : Nicolas REJNERI, Open CASCADE S.A.S.
00026 //
00027 #ifndef SMESHGUI_H
00028 #define SMESHGUI_H
00029 
00030 // SMESH includes
00031 #include "SMESH_SMESHGUI.hxx"
00032 
00033 // SALOME GUI includes
00034 #include <SalomeApp_Module.h>
00035 #include <VTKViewer_MarkerDef.h>
00036 #include <SALOME_InteractiveObject.hxx>
00037 
00038 // IDL includes
00039 #include <SALOMEconfig.h>
00040 #include CORBA_SERVER_HEADER(SMESH_Gen)
00041 
00042 // VTK includes
00043 #include <vtkSmartPointer.h>
00044 #include <vtkType.h>
00045 
00046 class vtkActor;
00047 class vtkCallbackCommand;
00048 class vtkObject;
00049 
00050 class QDialog;
00051 
00052 class SUIT_Desktop;
00053 class SUIT_Study;
00054 class SUIT_ViewWindow;
00055 class SUIT_ResourceMgr;
00056 class SUIT_ViewManager;
00057 
00058 class LightApp_Operation;
00059 class SalomeApp_Study;
00060 class LightApp_Selection;
00061 class LightApp_SelectionMgr;
00062 
00063 class SMESH_Actor;
00064 class SMESHGUI_FilterLibraryDlg;
00065 
00066 typedef std::map<int, VTK::MarkerMap> SMESHGUI_StudyId2MarkerMap;
00067 
00068 namespace SMESH
00069 {
00070   class OrientedPlane;
00071   struct ClippingPlaneInfo
00072   {
00073     OrientedPlane*       Plane;
00074     std::list<vtkActor*> ActorList;
00075   };
00076 }
00077 
00078 typedef std::list<SMESH::ClippingPlaneInfo>                         SMESHGUI_ClippingPlaneInfoList;
00079 typedef std::map<SUIT_ViewManager*, SMESHGUI_ClippingPlaneInfoList> SMESHGUI_ClippingPlaneInfoMap;
00080 
00081 //=================================================================================
00082 // class    : SMESHGUI
00083 // purpose  :
00084 //=================================================================================
00085 class SMESHGUI_EXPORT SMESHGUI : public SalomeApp_Module
00086 {
00087   Q_OBJECT;
00088 
00089 public :
00090   SMESHGUI();
00091   ~SMESHGUI();
00092 
00093   static SMESH::SMESH_Gen_var     GetSMESHGen();
00094   static SMESHGUI*                GetSMESHGUI();
00095   static LightApp_SelectionMgr*   selectionMgr();
00096   static SUIT_ResourceMgr*        resourceMgr();
00097   static SUIT_Desktop*            desktop();
00098   static SalomeApp_Study*         activeStudy();
00099   
00100   bool                            isActiveStudyLocked();
00101 
00102   static bool                     automaticUpdate(unsigned int requestedSize = 0, bool* limitExceeded = 0);
00103 
00104   static void                     Modified( bool = true );
00105 
00106   virtual LightApp_Displayer*     displayer();
00107   virtual QString                 engineIOR() const;
00108   virtual void                    initialize( CAM_Application* );
00109   virtual void                    windows( QMap<int, int>& ) const;
00110   virtual void                    viewManagers( QStringList& ) const;
00111 
00112   QDialog*                        GetActiveDialogBox();
00113   void                            SetActiveDialogBox( QDialog* );
00114 
00115   void                            ResetState();
00116   void                            SetState( int );
00117   bool                            DefineDlgPosition( QWidget*, int&, int& );
00118   void                            switchToOperation( int );
00119 
00120   virtual bool                    OnGUIEvent( int );
00121   virtual bool                    OnMousePress( QMouseEvent*, SUIT_ViewWindow* );
00122   virtual bool                    OnMouseMove( QMouseEvent*, SUIT_ViewWindow* );
00123   virtual bool                    OnKeyPress( QKeyEvent*, SUIT_ViewWindow* );
00124 
00125   virtual LightApp_Selection*     createSelection() const;
00126 
00127   virtual void                    BuildPresentation ( const Handle(SALOME_InteractiveObject)&,
00128                                                       SUIT_ViewWindow* = 0 );
00129 
00130   /* Non modal dialog boxes management */
00131   void                            EmitSignalDeactivateDialog();
00132   void                            EmitSignalStudyFrameChanged();
00133   void                            EmitSignalCloseAllDialogs();
00134   void                            EmitSignalVisibilityChanged();
00135 
00136   virtual void                    contextMenuPopup( const QString&, QMenu*, QString& );
00137   virtual void                    createPreferences();
00138   virtual void                    preferencesChanged( const QString&, const QString& );
00139 
00140   virtual void                    message( const QString& );
00141 
00142   virtual void                    update( const int );
00143 
00144   static SALOMEDS::Color          getUniqueColor( const QList<SALOMEDS::Color>& );
00145 
00146   virtual void                    storeVisualParameters  (int savePoint);
00147   virtual void                    restoreVisualParameters(int savePoint);
00148 
00149   virtual void                    addActorAsObserver( SMESH_Actor* theActor );
00150   
00151   virtual bool                    renameAllowed( const QString& ) const;
00152   virtual bool                    renameObject( const QString&, const QString& );
00153 
00154 
00155   SMESHGUI_ClippingPlaneInfoMap&  getClippingPlaneInfoMap() { return myClippingPlaneInfoMap; }
00156 
00157 public slots:
00158   virtual bool                    deactivateModule( SUIT_Study* );
00159   virtual bool                    activateModule( SUIT_Study* );
00160   virtual void                    studyClosed( SUIT_Study* );
00161   void                            onViewClosed( SUIT_ViewWindow* );
00162 
00163 private slots:
00164   void                            OnGUIEvent();
00165   void                            onViewManagerActivated( SUIT_ViewManager* );
00166   void                            onViewManagerRemoved( SUIT_ViewManager* );
00167   void                            onOperationCommited( SUIT_Operation* );
00168   void                            onOperationAborted( SUIT_Operation* );
00169   void                            onHypothesisEdit( int result );
00170 
00171 signals:
00172   void                            SignalDeactivateActiveDialog();
00173   void                            SignalStudyFrameChanged();
00174   void                            SignalCloseAllDialogs();
00175   void                            SignalVisibilityChanged();
00176 
00177 protected:
00178   void                            createSMESHAction( const int,
00179                                                      const QString&,
00180                                                      const QString& = QString(),
00181                                                      const int = 0,
00182                                                      const bool = false,
00183                                                      const QString& = QString() );
00184   void                            createPopupItem( const int,
00185                                                    const QString&,
00186                                                    const QString&,
00187                                                    const QString& = QString(),
00188                                                    const int = -1 );
00189 
00190   virtual LightApp_Operation*     createOperation( const int ) const;
00191 
00192   virtual bool                    isSelectionCompatible();
00193 
00194   virtual bool                    reusableOperation( const int id ); 
00195 
00196   static void                     ProcessEvents( vtkObject* theObject, 
00197                                                  unsigned long theEvent,
00198                                                  void* theClientData, 
00199                                                  void* theCallData );
00200 
00201 private:
00202   void                            OnEditDelete();
00203   int                             addVtkFontPref( const QString& label, 
00204                                                   const int pId, 
00205                                                   const QString& param );
00206 
00207   void                            connectView( const SUIT_ViewWindow* );
00208  
00209 
00210 private :
00211   static SMESH::SMESH_Gen_var     myComponentSMESH;
00212   QDialog*                        myActiveDialogBox;
00213   int                             myState;
00214   QMap<int, QString>              myRules;
00215   LightApp_Displayer*             myDisplayer;
00216 
00217   SMESHGUI_FilterLibraryDlg*      myFilterLibraryDlg;
00218 
00219   SMESHGUI_StudyId2MarkerMap      myMarkerMap;
00220   SMESHGUI_ClippingPlaneInfoMap   myClippingPlaneInfoMap;
00221 
00222   vtkSmartPointer<vtkCallbackCommand> myEventCallbackCommand;
00223   vtkFloatingPointType            myPriority;
00224 };
00225 
00226 #endif // SMESHGUI_H