Salome HOME
SALOME::GenericObj : Destroy() -> UnRegister()
[modules/visu.git] / src / VISUGUI / VisuGUI_Tools.h
index f5fee0973b4c0921703119b20419f7cd383d8339..9f29ed5aff65bcea0fa9376386903a411a594298 100644 (file)
@@ -1,6 +1,6 @@
-//  VISU VISUGUI : GUI of VISU component
+//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-//  Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
 //  This library is free software; you can redistribute it and/or
 //  License along with this library; if not, write to the Free Software
 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
+//  VISU VISUGUI : GUI of VISU component
 //  File   : VisuGUI_Tools.h
 //  Author : Sergey Anikin
 //  Module : VISU
-
+//
 #ifndef VisuGUI_Tools_HeaderFile
 #define VisuGUI_Tools_HeaderFile
 
 #include "SALOME_InteractiveObject.hxx"
 
 #include "VISUConfig.hh"
-
-#include "SalomeApp_Module.h"
-#include "SalomeApp_Application.h"
+#include "VISU_ColoredPrs3d_i.hh"
 
 #include "SALOMEDSClient_Study.hxx"
 
 #include "SALOMEconfig.h"
 #include CORBA_SERVER_HEADER(MED_Gen)
 
+class QWidget;
+class QDialog;
+class QSpinBox;
+class QDoubleSpinBox;
+
 class SUIT_Desktop;
 class SUIT_ViewWindow;
 class VISU_Actor;
 class SVTK_ViewWindow;
 class SPlot2d_Viewer;
+class SPlot2d_Curve;
+class Plot2d_ViewFrame;
 class CAM_Module;
-class SalomeApp_SelectionMgr;
+class LightApp_SelectionMgr;
+class SalomeApp_DoubleSpinBox;
+class SalomeApp_IntSpinBox;
+class SalomeApp_Module;
 class SalomeApp_Study;
+class VisuGUI;
 
-namespace VISU {
+#include <vector>
+#include <utility>
+#include "VISU_Mesh_i.hh"
+
+namespace VISU 
+{
+  class Base_i;
   class Prs3d_i;
   class Result_i;
   class Table_i;
@@ -58,84 +73,105 @@ namespace VISU {
 
   typedef std::vector<SVTK_ViewWindow*> TViewWindows;
 
+  //----------------------------------------------------------------------------
   SUIT_Desktop*                        GetDesktop(const CAM_Module* theModule);
   SalomeApp_Study*                     GetAppStudy(const CAM_Module* theModule);
   _PTR(Study)                          GetCStudy(const SalomeApp_Study* theStudy);
 
   bool                                 IsStudyLocked( _PTR(Study) theStudy );
-  bool                                 CheckLock( _PTR(Study) theStudy );
+  bool                                 CheckLock( _PTR(Study) theStudy,
+                                                  QWidget* theWidget );
 
-  inline void                          UpdateObjBrowser(SalomeApp_Module* theModule,
-                                                       bool updateDataModel = true);
+  //----------------------------------------------------------------------------
+  int                                  runAndWait( QDialog* dlg, const bool modal );
 
+  void                                 UpdateObjBrowser(SalomeApp_Module* theModule,
+                                                        bool theIsUpdateDataModel = true,
+                                                        _PTR(SObject) theSObject = _PTR(SObject)());
+
+  //----------------------------------------------------------------------------
   VISU_Gen_i*                          GetVisuGen(const CAM_Module* theModule);
   SALOME_MED::MED_Gen_var              GetMEDEngine();
 
-  VISU::Storable::TRestoringMap        getMapOfValue(_PTR(SObject) theSObject);
-  QString                              getValue(_PTR(SObject) theSObject, QString theKey);
-
   // Selection
-  SalomeApp_SelectionMgr*              GetSelectionMgr(const SalomeApp_Module* theModule);
-  CORBA::Object_var                    GetSelectedObj(const SalomeApp_Study* theStudy,
-                                                     const QString& theEntry,
-                                                     VISU::Storable::TRestoringMap* theMap = NULL);
-  CORBA::Object_var                    GetSelectedObj(const SalomeApp_Module* theModule,
-                                                     Handle(SALOME_InteractiveObject)* theIO = NULL,
-                                                     VISU::Storable::TRestoringMap* theMap = NULL);
-  VISU::Prs3d_i*                       GetPrsToModify(const SalomeApp_Module* theModule,
-                                                     Handle(SALOME_InteractiveObject)* theIO = NULL,
-                                                     VISU::Storable::TRestoringMap* theMap = NULL);
-
-  void                                 Add(SalomeApp_SelectionMgr* theSelectionMgr,
-                                          const Handle(SALOME_InteractiveObject)& theIO);
-  void                                 Remove(SalomeApp_SelectionMgr* theSelectionMgr,
-                                             const Handle(SALOME_InteractiveObject)& theIO);
-
+  LightApp_SelectionMgr*               GetSelectionMgr(const SalomeApp_Module* theModule);
+
+  //----------------------------------------------------------------------------
+  struct TObjectInfo
+  {
+    Base_i* myBase;
+    _PTR(SObject) mySObject;
+    TObjectInfo():
+      myBase(NULL)
+    {}
+  };
+
+  struct TSelectionItem
+  {
+    TObjectInfo myObjectInfo;
+    Handle(SALOME_InteractiveObject) myIO;
+  };
+
+  typedef std::vector<TSelectionItem>  TSelectionInfo;
+
+  TSelectionInfo                       GetSelectedObjects(const SalomeApp_Module* theModule);
+
+  TObjectInfo                          GetObjectByEntry(const SalomeApp_Study* theStudy,
+                                                        const std::string& theEntry);
+  
+  VISU::Prs3d_i*                       GetPrs3dToModify(const SalomeApp_Module* theModule,
+                                                        Base_i* theBase);
+
+  VISU::Prs3d_i*                       GetPrs3dFromBase(Base_i* theBase);
+
+  bool                                 GetPrs3dSelectionInfo( const SalomeApp_Module* theModule,
+                                                              VISU::Prs3d_i*& thePrs3d,
+                                                              SVTK_ViewWindow*& theViewWindow,
+                                                              VISU_Actor*& thenActor );
+
+  //----------------------------------------------------------------------------
+  void                                 Add(LightApp_SelectionMgr* theSelectionMgr,
+                                           const Handle(SALOME_InteractiveObject)& theIO);
+  void                                 Remove(LightApp_SelectionMgr* theSelectionMgr,
+                                              const Handle(SALOME_InteractiveObject)& theIO);
+
+  bool                                 IsRemovable        (const std::string theEntry,
+                                                           const SalomeApp_Module* theModule);
   bool                                 IsRemovableSelected(const SalomeApp_Module* theModule);
 
-  // Display/Erase
-  void                                 ErasePrs(const SalomeApp_Module* theModule,
-                                               CORBA::Object_ptr theObject,
-                                               bool theUpdate = true);
-  void                                 DeleteSObject(SalomeApp_Module* theModule,
-                                                    _PTR(Study)       theStudy,
-                                                    _PTR(SObject)     theSObject);
-  void                                 DeletePrs3d(SalomeApp_Module* theModule,
-                                                  VISU::Prs3d_i* thePrs,
-                                                  const Handle(SALOME_InteractiveObject)& theIO);
-  void                                 ErasePrs3d(const SalomeApp_Module* theModule,
-                                                 VISU::Prs3d_i* thePrs);
+  void                                 DeleteSObject(VisuGUI* theModule,
+                                                     _PTR(Study)       theStudy,
+                                                     _PTR(SObject)     theSObject);
+  void                                 DeletePrs3d(VisuGUI* theModule,
+                                                   VISU::Prs3d_i* thePrs);
 
   // Presentation management
   void ChangeRepresentation (const SalomeApp_Module* theModule,
-                            VISU::PresentationType  theType);
+                             VISU::PresentationType  theType);
+
+
+  void ChangeQuadratic2DRepresentation (const SalomeApp_Module* theModule,
+                                        VISU::Quadratic2DPresentationType  theType);
+  
+
 
   void SetShading ( const SalomeApp_Module* theModule, bool theOn = true );
 
   // SObject type
   bool                                 CheckTimeStamp(const SalomeApp_Module* theModule,
-                                                     _PTR(SObject)&          theSObject,
-                                                     Handle(SALOME_InteractiveObject)* theIO = NULL);
+                                                      _PTR(SObject)&          theSObject,
+                                                      Handle(SALOME_InteractiveObject)& theIO,
+                                                      ColoredPrs3d_i::EPublishInStudyMode& thePublishInStudyMode);
   VISU::Result_i*                      CheckResult(const SalomeApp_Module* theModule,
-                                                  _PTR(SObject) theSource,
-                                                  VISU::Result_var& theResult);
-  inline bool                          IsSObjectTable(_PTR(SObject) theSObject);
-
-  // Views
-  SUIT_ViewWindow*                     GetActiveView(const SalomeApp_Module* theModule,
-                                                    QString theType = QString::null);
-
-  // VTK View
-  TViewWindows                         GetViews(const SalomeApp_Module* theModule);
-  SVTK_ViewWindow*                     GetViewWindow(const SalomeApp_Module* theModule,
-                                                    const bool theCreate = false );
-  SVTK_ViewWindow*                     GetViewWindow();
-
-  VISU_Actor*                          PublishInView(const SalomeApp_Module* theModule,
-                                                    VISU::Prs3d_i* thePrs);
-  VISU_Actor*                          UpdateViewer(const SalomeApp_Module* theModule,
-                                                   VISU::Prs3d_i* thePrs,
-                                                   bool theDispOnly = false);
+                                                   _PTR(SObject) theSource,
+                                                   VISU::Result_var& theResult);
+  bool                                 IsSObjectTable(_PTR(SObject) theSObject);
+
+  /*! Display mesh presentation in given VTK view window
+   */
+  VISU_Actor*                          PublishMeshInView(const SalomeApp_Module* theModule,
+                                                         VISU::Prs3d_i* thePrs,
+                                                         SVTK_ViewWindow* theViewWindow);
 
   /*!
    * \brief Repaint all SVTK view windows, where the given object is displayed.
@@ -143,14 +179,20 @@ namespace VISU {
    * \param theIObject - is supposed to be selected (is highlighted in this method).
    */
   void                                 RepaintViewWindows(const SalomeApp_Module* theModule,
-                                                         const Handle(SALOME_InteractiveObject)& theIObject);
-
-  VISU_Actor*                          FindActor(SVTK_ViewWindow* theViewWindow,
-                                                const char* theEntry);
-  VISU_Actor*                          FindActor(SVTK_ViewWindow* theViewWindow,
-                                                VISU::Prs3d_i* thePrs);
+                                                          const Handle(SALOME_InteractiveObject)& theIObject);
+
+  VISU_Actor*                          FindActor(const SalomeApp_Study* theStudy,
+                                                 SVTK_ViewWindow* theViewWindow,
+                                                 const QString& theEntry);
+  VISU_ActorBase*                      FindActorBase(const SalomeApp_Study* theStudy,
+                                                     SVTK_ViewWindow* theViewWindow,
+                                                     const QString& theEntry);
   void                                 RecreateActor(const SalomeApp_Module* theModule,
-                                                    VISU::Prs3d_i* thePrs);
+                                                     VISU::Prs3d_i* thePrs);
+
+  bool                                 ComputeVisiblePropBounds(SVTK_ViewWindow* theViewWindow,
+                                                                vtkFloatingPointType allBounds[6], 
+                                                                const char* theActorClassName = "VISU_Actor");
 
   /*!
    * \brief Advanced FitAll, sets view projection in accordance with current view contents
@@ -165,46 +207,48 @@ namespace VISU {
 
   // Plot2d View
   SPlot2d_Viewer*                      GetPlot2dViewer(const SalomeApp_Module* theModule,
-                                                      const bool theCreate = false);
+                                                       const bool theCreate = false);
   void                                 PlotTable( const SalomeApp_Module* theModule,
-                                                 VISU::Table_i* table,
-                                                 int theDisplaying );
+                                                  VISU::Table_i* table,
+                                                  int theDisplaying );
   void                                 PlotCurve( const SalomeApp_Module* theModule,
-                                                 VISU::Curve_i* curve,
-                                                 int theDisplaying );
+                                                  VISU::Curve_i* curve,
+                                                  int theDisplaying );
+  void                                 PlotRemoveCurve(const SalomeApp_Module* theModule,
+                                                       VISU::Curve_i* curve);
   void                                 PlotContainer( const SalomeApp_Module* theModule,
-                                                     VISU::Container_i* container,
-                                                     int theDisplaying );
+                                                      VISU::Container_i* container,
+                                                      int theDisplaying );
   void                                 CreatePlot( SalomeApp_Module* theModule,
-                                                  _PTR(SObject) theSobj );
+                                                   _PTR(SObject) theSobj );
 
+  /*! Create mesh presentation and display it in \a theViewWindow.
+   *  If \a theViewWindow is NULL, no displaying will be done.
+   */
+  VISU::Mesh_i* CreateMesh(VisuGUI* theModule,
+                           const Handle(SALOME_InteractiveObject)& theIO,
+                           SVTK_ViewWindow* theViewWindow);
+  
   // Others
-  void CreateMesh (const SalomeApp_Module* theModule,
-                  const Handle(SALOME_InteractiveObject)& theIO);
-
   std::vector<VISU::Prs3d_i*> GetPrs3dList (const SalomeApp_Module* theModule,
-                                           const Handle(SALOME_InteractiveObject)& theIO);
+                                            const Handle(SALOME_InteractiveObject)& theIO,
+                                            bool theGP = false);
   std::vector<VISU::Prs3d_i*> GetPrs3dList (const SalomeApp_Module* theModule,
-                                           _PTR(SObject) theObject);
-}
+                                            _PTR(SObject) theObject,
+                                            bool theGP = false);
+  
+  int GetFreePositionOfDefaultScalarBar(VisuGUI* theModule, SVTK_ViewWindow* theViewWindow);
+  void AddScalarBarPosition(VisuGUI* theModule, SVTK_ViewWindow* theViewWindow,
+                            VISU::Prs3d_i* thePrs3d, int pos);
+  void RemoveScalarBarPosition(VisuGUI* theModule, SVTK_ViewWindow* theViewWindow,
+                               VISU::Prs3d_i* thePrs3d);
 
-bool VISU::IsSObjectTable( _PTR(SObject) theSObject )
-{
-  if ( theSObject ) {
-    _PTR(GenericAttribute) anAttr;
-    if (theSObject->FindAttribute( anAttr, "AttributeTableOfInteger" ))
-      return true;
-    if (theSObject->FindAttribute( anAttr, "AttributeTableOfReal" ))
-      return true;
-  }
-  return false;
-}
+#define CLIP_PLANES_FOLDER "Clipping Planes"
 
-void VISU::UpdateObjBrowser(SalomeApp_Module* theModule,
-                           bool updateDataModel)
-{
-  theModule->updateObjBrowser(updateDataModel);
-  theModule->getApp()->updateActions();
+  bool getClippingPlanesFolder(_PTR(Study) theStudy, _PTR(SObject)& theSObject);
+
+  void initSpinBox( SalomeApp_IntSpinBox*, const int, const int, const int );
+  void initSpinBox( SalomeApp_DoubleSpinBox*, const double&, const double&, const double&, const char* );
 }
 
 #endif