Salome HOME
Remove useless files; Use SALOMEDSClient classes instead of CORBA interfaces; fix...
[modules/visu.git] / src / VISUGUI / VisuGUI_Tools.h
index d06b7a2eb70a19515b981ae01c0a2c736f456546..0c2469bfb0789cf2d84682d0e88fecc4f3baf880 100644 (file)
@@ -1,28 +1,28 @@
 //  VISU VISUGUI : GUI of VISU component
 //
 //  Copyright (C) 2005  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 
-//  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. 
-// 
-//  This library is distributed in the hope that it will be useful, 
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
-//  Lesser General Public License for more details. 
-// 
-//  You should have received a copy of the GNU Lesser General Public 
-//  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 
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+//  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.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  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
 //
 //
 //
 //  File   : VisuGUI_Tools.h
-//  Author : Sergey Anikin 
+//  Author : Sergey Anikin
 //  Module : VISU
 
 #ifndef VisuGUI_Tools_HeaderFile
 #include "SALOMEDSClient_Study.hxx"
 
 #include "SALOMEconfig.h"
-#include CORBA_SERVER_HEADER(SALOMEDS)
-#include CORBA_SERVER_HEADER(VISU_Gen)
 #include CORBA_SERVER_HEADER(MED_Gen)
 
 class SUIT_Desktop;
+class SUIT_ViewWindow;
 class VISU_Actor;
 class SVTK_ViewWindow;
 class SPlot2d_Viewer;
@@ -48,7 +47,7 @@ class SalomeApp_Module;
 class SalomeApp_SelectionMgr;
 class SalomeApp_Study;
 
-namespace VISU{
+namespace VISU {
   class Prs3d_i;
   class Result_i;
   class Table_i;
@@ -58,75 +57,125 @@ namespace VISU{
   typedef std::vector<SVTK_ViewWindow*> TViewWindows;
 
   SUIT_Desktop*                        GetDesktop(const CAM_Module* theModule);
-  SalomeApp_SelectionMgr*              GetSelectionMgr(const SalomeApp_Module* theModule);
   SalomeApp_Study*                     GetAppStudy(const CAM_Module* theModule);
   _PTR(Study)                          GetCStudy(const SalomeApp_Study* theStudy);
-  bool                                 IsStudyLocked(const SALOMEDS::Study_var& theStudy);
-  bool                                 CheckLock(const SALOMEDS::Study_var& theStudy, const CAM_Module* theModule);
-  VISU::Storable::TRestoringMap        getMapOfValue(SALOMEDS::SObject_var theSObject);
-  VISU::Storable::TRestoringMap        getMapOfValue(_PTR(SObject) theSObject);
-  QString                              getValue(SALOMEDS::SObject_var theSObject, QString theKey);
-  QString                              getValue(_PTR(SObject) theSObject, QString theKey);
-  SVTK_ViewWindow*                     GetViewWindow(const SalomeApp_Module* theModule);
-  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);
-  VISU_Actor*                          FindActor(SVTK_ViewWindow* theViewWindow,
-                                                const char* theEntry);
-  VISU_Actor*                          FindActor(SVTK_ViewWindow* theViewWindow,
-                                                VISU::Prs3d_i* thePrs);
-  void                                 Add(SalomeApp_SelectionMgr* theSelectionMgr,
-                                          const Handle(SALOME_InteractiveObject)& theIO);
-  void                                 Remove(SalomeApp_SelectionMgr* theSelectionMgr,
-                                             const Handle(SALOME_InteractiveObject)& theIO);
 
-  SALOMEDS::StudyManager_var           GetStudyManager();
+  bool                                 IsStudyLocked( _PTR(Study) theStudy );
+  bool                                 CheckLock( _PTR(Study) theStudy );
+
   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, 
+                                                     const QString& theEntry,
                                                      VISU::Storable::TRestoringMap* theMap = NULL);
   CORBA::Object_var                    GetSelectedObj(const SalomeApp_Module* theModule,
-                                                     Handle(SALOME_InteractiveObject)* theIO = NULL, 
+                                                     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);
+
+  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);
+
+  // Presentation management
+  void ChangeRepresentation (const SalomeApp_Module* theModule,
+                            VISU::PresentationType  theType);
+
+  // SObject type
   bool                                 CheckTimeStamp(const SalomeApp_Module* theModule,
-                                                     SALOMEDS::SObject_var& theSObject,
+                                                     _PTR(SObject)&          theSObject,
                                                      Handle(SALOME_InteractiveObject)* theIO = NULL);
-  inline bool                          IsSObjectTable(_PTR(SObject) theSObject);
   VISU::Result_i*                      CheckResult(const SalomeApp_Module* theModule,
-                                                  SALOMEDS::SObject_var theSource, 
+                                                  _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);
-  void                                 DeletePrs3d(SalomeApp_Module* theModule,
-                                                  VISU::Prs3d_i* thePrs,
-                                                  const Handle(SALOME_InteractiveObject)& theIO);
-  void                                 ErasePrs3d(SalomeApp_Module* theModule,
-                                                 VISU::Prs3d_i* thePrs);
+  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);
 
-  SPlot2d_Viewer*                      GetPlot2dViewer(const SalomeApp_Module* theModule);
-  void                                 PlotTable( const SalomeApp_Module* theModule, 
-                                                 VISU::Table_i* table, 
+  /*!
+   * \brief Repaint all SVTK view windows, where the given object is displayed.
+   * \param theModule  - is used to access application.
+   * \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);
+  void                                 RecreateActor(const SalomeApp_Module* theModule,
+                                                    VISU::Prs3d_i* thePrs);
+
+  // Plot2d View
+  SPlot2d_Viewer*                      GetPlot2dViewer(const SalomeApp_Module* theModule,
+                                                      const bool theCreate = false);
+  void                                 PlotTable( const SalomeApp_Module* theModule,
+                                                 VISU::Table_i* table,
                                                  int theDisplaying );
-  void                                 PlotCurve( const SalomeApp_Module* theModule, 
-                                                 VISU::Curve_i* curve, 
+  void                                 PlotCurve( const SalomeApp_Module* theModule,
+                                                 VISU::Curve_i* curve,
                                                  int theDisplaying );
-  void                                 PlotContainer( const SalomeApp_Module* theModule, 
-                                                     VISU::Container_i* container, 
+  void                                 PlotContainer( const SalomeApp_Module* theModule,
+                                                     VISU::Container_i* container,
                                                      int theDisplaying );
+  void                                 CreatePlot( SalomeApp_Module* theModule,
+                                                  _PTR(SObject) theSobj );
+
+  // 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);
+  std::vector<VISU::Prs3d_i*> GetPrs3dList (const SalomeApp_Module* theModule,
+                                           _PTR(SObject) theObject);
 }
 
 bool VISU::IsSObjectTable( _PTR(SObject) theSObject )
 {
-  if( theSObject ) {
+  if ( theSObject ) {
     _PTR(GenericAttribute) anAttr;
-    if(theSObject->FindAttribute( anAttr, "AttributeTableOfInteger" ))
+    if (theSObject->FindAttribute( anAttr, "AttributeTableOfInteger" ))
       return true;
-    if(theSObject->FindAttribute( anAttr, "AttributeTableOfReal" ))
+    if (theSObject->FindAttribute( anAttr, "AttributeTableOfReal" ))
       return true;
-  }  
+  }
   return false;
 }