Salome HOME
Copyright update 2022
[modules/paravis.git] / src / PVGUI / PVGUI_Module.h
index ba573470fde78904e49d7844728f40932247b4fa..4715c0a9e1b1cb61782a834fd6a05493c0cbd20c 100644 (file)
@@ -1,12 +1,11 @@
 // PARAVIS : ParaView wrapper SALOME module
 //
-// Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// Copyright (C) 2010-2022  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 // File   : PVGUI_Module.h
-// Author : Sergey ANIKIN
+// Author : Sergey ANIKIN, Adrien BRUNETON
 //
 
-/*!
-  \mainpage
-
-  Insert the content of introduction page here.
-
-  A link to the file documentation PVGUI_Module_actions.cxx
-
-  A link to the file documentation PVGUI_Module_impl.h
-
-  A link to the class documentation PVGUI_Module
-
-  The class name as a text (not a link to its documentation) %PVGUI_Module
-
-  A link to the constructor of the class PVGUI_ViewWindow#PVGUI_ViewWindow or PVGUI_Module::PVGUI_Module()
-
-  A link to the destructor of the class PVGUI_ViewWindow#~PVGUI_ViewWindow
-
-  A link to the member function PVGUI_ViewWindow::getVisualParameters or PVGUI_ViewWindow#getVisualParameters
-
-  Arguments of a function should be specified only for the overloaded functions PVGUI_Module::initialize(CAM_Application*)
-
-  A link to some enumeration values PVGUI_Module::OpenFileId and PVGUI_Module::CreateLookmarkId
-
-  A link to a protected member variable of the class PVGUI_ViewWindow#myModel
-
-  A link to a variable \link PVGUI_ViewWindow#myModel using another text\endlink as a link
-
-*/
 
 #ifndef PVGUI_Module_H
 #define PVGUI_Module_H
 
 #include <LightApp_Module.h>
 
-#include <ostream.h>
-
 class QMenu;
-class QDockWidget;
-class LightApp_Selection;
-class LightApp_SelectionMgr;
-class PVGUI_ProcessModuleHelper;
-class vtkPVMain;
-class pqOptions;
+class QTimer;
+class vtkEventQtSlotConnect;
 class pqServer;
-class pqActiveServer;
-class pqViewManager;
+class pqPythonScriptEditor;
+class pqPVApplicationCore;
+class PVViewer_GUIElements;
+class PVServer_ServiceWrapper;
+class SUIT_ViewWindow;
 
-class PVGUI_Module : public LightApp_Module
+class PVGUI_Module: public LightApp_Module
 {
   Q_OBJECT
    
   //! Menu actions
-  enum { // Menu "File"
-         OpenFileId,
-
-        LoadStateId,
-        SaveStateId,
-
-        SaveDataId,
-        SaveScreenshotId,
-        ExportId,
-
-        SaveAnimationId,
-        SaveGeometryId,
-
-        ConnectId,
-        DisconnectId,
-
-        // Menu "Edit"
-        UndoId,
-        RedoId,
-
-        CameraUndoId,
-        CameraRedoId,
-
-        ChangeInputId,
-        DeleteId,
-        DeleteAllId,
-
-        InteractId,
-        SelectCellsOnId,
-        SelectPointsOnId,
-        SelectCellsThroughId,
-        SelectPointsThroughId,
-        SelectBlockId,
-
-        SettingsId,
-        ViewSettingsId,
-
-        // Menu "View"
-        ResetCameraId,
-        PositiveXId,
-        NegativeXId,
-        PositiveYId,
-        NegativeYId,
-        PositiveZId,
-        NegativeZId,
-
-        ShowCenterId,
-        ResetCenterId,
-        PickCenterId,
-        ShowColorLegendId,
-        EditColorMapId,
-        ResetRangeId,
-
-        AnimationInspectorId,
-        AnimationViewId,
-        ComparativeViewInspectorId,
-        SelectionInspectorId,
-        LookmarkBrowserId,
-        LookmarkInspectorId,
-        ObjectInspectorId,
-        PipelineBrowserId,
-        StatisticsViewId,
-
-        // Menu "Sources"
-        // TODO...
-
-        // Menu "Filters"
-        // TODO...
-
-        // Menu "Animation"
-        FirstFrameId,
-        PreviousFrameId,
-        PlayId,
-        NextFrameId,
-        LastFrameId,
-        LoopId,
-
-        // Menu "Tools" 
-        CreateCustomFilterId,
-        ManageCustomFiltersId,
-        CreateLookmarkId,
-        ManageLinksId,
-        AddCameraLinkId,
-        ManagePluginsExtensionsId,
-        DumpWidgetNamesId,
-        RecordTestId,
-        RecordTestScreenshotId,
-        PlayTestId,
-        MaxWindowSizeId,
-        TimerLogId,
-        OutputWindowId,
-        PythonShellId,
-
-        // Menu "Help" 
-        AboutParaViewId,
-        ParaViewHelpId,
-        EnableTooltipsId
-
-         /*
-         lgLoadFile = 931,   //!< load text file
-        lgSaveFile,         //!< save text file
-        lgDisplayLine,      //!< display selected line
-        lgEraseLine,        //!< erase selected line
-        lgEditLine,         //!< edit selected line
-        lgAddLine,          //!< insert new line
-        lgDelLine,          //!< delete selected line
-        lgClear             //!< clear all contents
-        */
+  enum {
+    //-----------
+    // Menu "File"
+    OpenFileId,
+    //-
+    LoadStateId,
+    SaveStateId,
+    //-
+    SaveDataId,
+    SaveScreenshotId,
+    ExportId,
+    //-
+    SaveAnimationId,
+    SaveGeometryId,
+    //-
+    ConnectId,
+    DisconnectId,
+    //-----------
+    // Menu "Edit"
+    UndoId,
+    RedoId,
+    //-
+    CameraUndoId,
+    CameraRedoId,
+    //-
+    FindDataId,
+    ChangeInputId,
+    IgnoreTimeId,
+    DeleteId,
+    DeleteAllId,
+    //-
+    SettingsId,             // not used
+    ViewSettingsId,         // not used
+    //-----------
+    // Menu "View"
+    FullScreenId,           // not used
+    //-----------
+    // Menu "Animation"
+    FirstFrameId,           // not used
+    PreviousFrameId,        // not used
+    PlayId,                 // not used
+    NextFrameId,            // not used
+    LastFrameId,            // not used
+    LoopId,                 // not used
+    //-----------
+    // Menu "Tools"
+    CreateCustomFilterId,
+    ManageCustomFiltersId,
+    CreateLookmarkId,       // not used
+    ManageLinksId,
+    AddCameraLinkId,
+    ManagePluginsExtensionsId,
+    DumpWidgetNamesId,      //  not used
+    RecordTestId,
+    RecordTestScreenshotId, // not used
+    PlayTestId,
+    MaxWindowSizeId,
+    CustomWindowSizeId,
+    TimerLogId,
+    PythonShellId,
+    ShowTraceId,
+    RestartTraceId,
+    //-----------
+    // Menu "Help"
+    AboutParaViewId,
+    ParaViewHelpId,
+    EnableTooltipsId,       // not used
   };
 
 public:
   PVGUI_Module();
   ~PVGUI_Module();
 
-  virtual void           initialize( CAM_Application* );
-  virtual void           windows( QMap<int, int>& ) const;
+  virtual void initialize( CAM_Application* );
+  virtual void windows( QMap<int, int>& ) const;
+
+  void openFile( const char* );                   // not used inside PARAVIS
+  void executeScript( const char* );              // not used inside PARAVIS
+
+  void saveParaviewState( const QString& );
+  void loadParaviewState( const QString& );
+  void clearParaviewState();
 
-  //virtual LightApp_Selection* createSelection() const;
+  QString getTraceString();
+  void startTrace();
+  void stopTrace();
+  void saveTrace( const char* );
 
-  pqViewManager*         getMultiViewManager() const;
+  pqServer* getActiveServer();
 
-  virtual bool           eventFilter( QObject*, QEvent* );
+  virtual void createPreferences();
 
-  //! Compares the contents of the window with the given reference image, returns true if they "match" within some tolerance
-  bool                   compareView( const QString& ReferenceImage, double Threshold,
-                                     ostream& Output, const QString& TempDirectory );
+  inline static PVServer_ServiceWrapper* GetEngine();
+  inline static pqPVApplicationCore* GetPVApplication(); // not used inside PARAVIS
 
-protected:
-  //virtual CAM_DataModel* createDataModel();
+  virtual CAM_DataModel* createDataModel();
 
 private:
-  //! Initialize ParaView if not yet done (once per session)
-  static bool            pvInit();  
-  //! Shutdown ParaView, should be called on application exit
-  static void            pvShutdown();   
   //! Create actions for ParaView GUI operations
-  void                   pvCreateActions();
+  void pvCreateActions();
 
-  //! Create menus for ParaView GUI operations
-  //! duplicating menus in pqMainWindow ParaView class
-  void                   pvCreateMenus();
+  //! Create menus for ParaView GUI operations duplicating menus in pqMainWindow ParaView class
+  void pvCreateMenus();
 
-  //! Create toolbars for ParaView GUI operations
-  //! duplicating toolbars in pqMainWindow ParaView class
-  void                   pvCreateToolBars();
+  //! Create toolbars for ParaView GUI operations duplicating toolbars in pqMainWindow ParaView class
+  void pvCreateToolBars();
 
   //! Create dock widgets for ParaView widgets
-  void                   setupDockWidgets();
-
-  //! Create dock widgets context menus
-  void                   setupDockWidgetsContextMenu();
+  void setupDockWidgets();
 
   //! Save states of dockable ParaView widgets
-  void                   saveDockWidgetsState();
+  void saveDockWidgetsState( bool = true );
 
   //! Restore states of dockable ParaView widgets
-  void                   restoreDockWidgetsState();
+  void restoreDockWidgetsState();
 
   //! Shows or hides ParaView view window
-  void                   showView( bool );    
-
-  //! Returns QMenu object for a given menu id
-  QMenu*                 getMenu( const int );
-
-private slots:
-  void onUndoLabel( const QString& );
-  void onRedoLabel( const QString& );
-  
-  void onCameraUndoLabel( const QString& );
-  void onCameraRedoLabel( const QString& );
+  void showView( bool );    
 
-  void onDeleteAll();
+  //! Get list of embedded macros files
+  QStringList getEmbeddedMacrosList();
 
-  void onSelectionModeChanged( int mode );
+  //! update macros state
+  void updateMacros();
 
-  void onShowCenterAxisChanged( bool );
+  //! store visibility of the common dockable windows (OB, PyConsole, ... etc.)
+  void storeCommonWindowsState();
 
-  void setTimeRanges( double, double );
+  //! restore visibility of the common dockable windows (OB, PyConsole, ... etc.)
+  void restoreCommonWindowsState();
 
-  void onPlaying( bool );
-  
-  void onAddCameraLink();
+private slots:
+  void showHelpForProxy( const QString&, const QString& );
   
-  void onHelpAbout();
+  void onPreAccept();    // not used inside PARAVIS
+  void onPostAccept();   // not used inside PARAVIS
+  void endWaitCursor();  // not used inside PARAVIS
 
-  void showHelpForProxy( const QString& proxy );
-  void makeAssistant();
-  void assistantError( const QString& err );
-  
-  void onPreAccept();
-  void onPostAccept();
-  void endWaitCursor();
+  void onDataRepresentationUpdated();
+
+  void onStartProgress();
+  void onEndProgress();
+  void onShowTrace();
+  void onRestartTrace();
+  void onStopTrace();
 
 public slots:
   virtual bool           activateModule( SUIT_Study* );
   virtual bool           deactivateModule( SUIT_Study* );
+  virtual void           onApplicationClosed( SUIT_Application* );
+  virtual void           studyClosed( SUIT_Study* );
 
-private:
-  class pqImplementation;
-  pqImplementation*      Implementation;
+protected slots:
+  virtual void           onInitTimer();
+  virtual void           onViewManagerAdded( SUIT_ViewManager* );
+  virtual void           onViewManagerRemoved( SUIT_ViewManager* );
+  virtual void           onPVViewCreated( SUIT_ViewWindow* );
+  virtual void           onPVViewDelete( SUIT_ViewWindow* );
 
-  int                    mySelectionControlsTb;
+private:
   int                    mySourcesMenuId;
   int                    myFiltersMenuId;
+  int                    myMacrosMenuId;
+  int                    myRecentMenuId;
+  int                    myCatalystMenuId;
+  
+  typedef QMap<QWidget*, bool> WgMap;
+  WgMap                  myDockWidgets;
+  WgMap                  myToolbars;
+  WgMap                  myToolbarBreaks;
+  QList<QMenu*>          myMenus;
+
+  typedef QMap<int, bool> DockWindowMap;         
+  DockWindowMap           myCommonMap; 
+  QtMessageHandler        myOldMsgHandler;
+
+  vtkEventQtSlotConnect*  VTKConnect;
+
+  pqPythonScriptEditor*   myTraceWindow;
+
+  //! Single shot timer used to connect to the PVServer, and start the trace.
+  QTimer*                 myInitTimer;
 
-  QList<QDockWidget*>    myDockWidgets;
+  PVViewer_GUIElements*   myGuiElements;
 };
 
 #endif // PVGUI_Module_H