]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Publishing Cache and Holder objects in study
authorouv <ouv@opencascade.com>
Tue, 21 Nov 2006 12:20:05 +0000 (12:20 +0000)
committerouv <ouv@opencascade.com>
Tue, 21 Nov 2006 12:20:05 +0000 (12:20 +0000)
idl/VISU_Gen.idl
src/VISUGUI/VisuGUI.cxx
src/VISUGUI/VisuGUI_Displayer.cxx
src/VISUGUI/VisuGUI_Prs3dTools.h
src/VISUGUI/VisuGUI_Tools.cxx
src/VISU_I/VISU_ColoredPrs3dCache_i.cc
src/VISU_I/VISU_ColoredPrs3dCache_i.hh
src/VISU_I/VISU_ColoredPrs3dHolder_i.cc
src/VISU_I/VISU_Gen_i.cc
src/VISU_I/VISU_Gen_i.hh
src/VISU_SWIG/visu_cache.py

index ad9aa1490e76b1997856ff870388a0ebe6cbf7b9..310b95aff40e4c5a5970df9d7f0d37828dd75835 100644 (file)
@@ -625,7 +625,7 @@ module VISU {
    * This interface is responsible for memory management of 3d presentations.
    * One cache corresponds to one study.
    */
-  interface ColoredPrs3dCache : SALOME::GenericObj
+  interface ColoredPrs3dCache : PrsObject, SALOME::GenericObj
   {
     /*!
      * Creates %ColoredPrs3dHolder.
index 5500c4d6576c0475db4c7f54d415ae3e78ffcef5..1b5463e1704cb39940f029da1949017043d95bcb 100644 (file)
@@ -635,6 +635,19 @@ OnDisplayPrs()
     CORBA::Object_var anObject = GetSelectedObj(GetAppStudy(this), anIO->getEntry());
 
     if (!CORBA::is_nil(anObject)) {
+      // is it Holder ?
+      VISU::ColoredPrs3dHolder_i* aHolder = 
+       dynamic_cast<VISU::ColoredPrs3dHolder_i*>(VISU::GetServant(anObject).in());
+      if (aHolder) {
+        if(MYDEBUG) MESSAGE("VisuGUI::OnDisplayPrs : Holder object");
+        //UpdateViewer( this, aHolder );
+        if (vw) {
+         displayer()->Display(anIO->getEntry());
+         vw->highlight(anIO, 1);
+        }
+        continue;
+      }
+
       // is it Prs3d object ?
       VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
       if (aPrsObject) {
@@ -2461,7 +2474,8 @@ createPopupMenus()
   // Rules
 
   QString aPrsAll ("'VISU::TSCALARMAP' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' "
-                   "'VISU::TCUTLINES' 'VISU::TVECTORS' 'VISU::TSTREAMLINES' 'VISU::TPLOT3D' 'VISU::TSCALARMAPONDEFORMEDSHAPE'");
+                   "'VISU::TCUTLINES' 'VISU::TVECTORS' 'VISU::TSTREAMLINES' 'VISU::TPLOT3D' "
+                  "'VISU::TSCALARMAPONDEFORMEDSHAPE' 'VISU::TCOLOREDPRS3DHOLDER'");
 
   // VISU root commands
   QString aRule = "client='ObjectBrowser' and selcount=1 and type='VISU::TVISUGEN'";
index 46fd092202d4a2675ad1c0bd6f2e9bfd5251cdd6..79a50235fd73418dce0e003584741b26b97908f0 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "VisuGUI_Tools.h"
 #include "VISU_ViewManager_i.hh"
+#include "VISU_ColoredPrs3dHolder_i.hh"
 #include "VISU_Actor.h"
 
 #include "VVTK_ViewModel.h"
@@ -79,11 +80,20 @@ SALOME_Prs* VisuGUI_Displayer::buildPresentation( const QString& entry, SALOME_V
         dynamic_cast<SVTK_ViewWindow*>( vtk_viewer->getViewManager()->getActiveView() );
       if( wnd )
       {
-       VISU::Prs3d_i* thePrs = dynamic_cast<VISU::Prs3d_i*>( VISU::GetServant( anObj ).in() );
+       VISU::Prs3d_i* thePrs;
+       VISU::Base_i* aBase = dynamic_cast<VISU::Base_i*>(VISU::GetServant(anObj).in());
+       if(aBase->GetType() == VISU::TCOLOREDPRS3DHOLDER)
+       {
+         VISU::ColoredPrs3dHolder_i* aHolder = dynamic_cast<VISU::ColoredPrs3dHolder_i*>( aBase );
+         thePrs = dynamic_cast<VISU::Prs3d_i*>( VISU::GetServant(aHolder->GetDevice()).in() );
+       }
+       else
+         thePrs = dynamic_cast<VISU::Prs3d_i*>( aBase );
+
        if( thePrs )
        {
          buildPrs3d( wnd, thePrs );
-         prs = LightApp_Displayer::buildPresentation( entry, aViewFrame );
+         prs = LightApp_Displayer::buildPresentation( thePrs->GetEntry(), aViewFrame );
        }
       }
     }
@@ -243,8 +253,11 @@ bool VisuGUI_Displayer::canBeDisplayed( const QString& entry, const QString& vie
 
   if( viewer_type==SVTK_Viewer::Type() || viewer_type==VVTK_Viewer::Type())
   {
-    VISU::Prs3d_i* thePrs = dynamic_cast<VISU::Prs3d_i*>( VISU::GetServant( anObj ).in() );
-    return thePrs;
+    VISU::Base_i* aBase = dynamic_cast<VISU::Base_i*>(VISU::GetServant(anObj).in());
+    if(aBase->GetType() == VISU::TCOLOREDPRS3DHOLDER)
+      return dynamic_cast<VISU::ColoredPrs3dHolder_i*>(aBase);
+
+    return dynamic_cast<VISU::Prs3d_i*>(aBase);
   }
   else if( viewer_type==SPlot2d_Viewer::Type() )
   {
index 4de653448ca64d0879eb0e01a5d56512d186a42f..ebdf2129d4b39566fc69ee54e161056351cfa7d4 100644 (file)
@@ -93,7 +93,7 @@ namespace VISU
                      false ); // in edition mode
        QApplication::restoreOverrideCursor();
       }
-      RestoreSelection(theModule, thePrs3d);
+      RestoreSelection(theModule, NULL/*thePrs3d*/);
       delete aDlg;
     }
   }
index 1b307d201bd115e0635ab48cccfc9e64894e426e..926bf60801540abfc548eda06c5c8edef696b13e 100644 (file)
@@ -37,6 +37,8 @@
 #include "VISU_Table_i.hh"
 #include "VISU_Mesh_i.hh"
 #include "VISU_ViewManager_i.hh"
+#include "VISU_ColoredPrs3dCache_i.hh"
+#include "VISU_ColoredPrs3dHolder_i.hh"
 
 #include "VISU_Actor.h"
 #include "VISU_ScalarMapAct.h"
@@ -303,7 +305,14 @@ namespace VISU
     if (!aServant.in())
       return NULL;
 
-    return dynamic_cast<VISU::Prs3d_i*>(aServant.in());
+    VISU::Base_i* aBase = dynamic_cast<VISU::Base_i*>(aServant.in());
+    if(aBase->GetType() == VISU::TCOLOREDPRS3DHOLDER)
+    {
+      VISU::ColoredPrs3dHolder_i* aHolder = dynamic_cast<VISU::ColoredPrs3dHolder_i*>(aBase);
+      return dynamic_cast<VISU::ColoredPrs3d_i*>(VISU::GetServant(aHolder->GetDevice()).in());
+    }
+
+    return dynamic_cast<VISU::Prs3d_i*>(aBase);
   }
 
   void
index 3fbf6f25ac155bc1266ae122a1b6395edfa1f947..69bd3b512e2bd2f60ad8250777c304a71d56e499 100644 (file)
 
 #include "VISU_ColoredPrs3dCache_i.hh"
 
+#include "VISU_ColoredPrs3d_i.hh"
+#include "VISU_ColoredPrs3dHolder_i.hh"
 #include "VISU_Gen_i.hh"
+#include "VISU_Result_i.hh"
 #include "VISU_View_i.hh"
 #include "VISU_ViewManager_i.hh"
-#include "VISU_ColoredPrs3d_i.hh"
-#include "VISU_ColoredPrs3dHolder_i.hh"
+
+#include "VISU_ScalarMap_i.hh"
+#include "VISU_IsoSurfaces_i.hh"
+#include "VISU_DeformedShape_i.hh"
+#include "VISU_ScalarMapOnDeformedShape_i.hh"
+#include "VISU_GaussPoints_i.hh"
+#include "VISU_Plot3D_i.hh"
+#include "VISU_CutPlanes_i.hh"
+#include "VISU_CutLines_i.hh"
+#include "VISU_Vectors_i.hh"
+#include "VISU_StreamLines_i.hh"
 
 #include "VVTK_ViewWindow.h"
 
@@ -46,9 +58,16 @@ static int MYDEBUG = 0;
 //----------------------------------------------------------------------------
 VISU::ColoredPrs3dCache_i::
 ColoredPrs3dCache_i(SALOMEDS::Study_ptr theStudy):
-  myStudy(SALOMEDS::Study::_duplicate(theStudy))
+  PrsObject_i(theStudy)
 {
   if(MYDEBUG) MESSAGE("ColoredPrs3dCache_i::ColoredPrs3dCache_i - this = "<<this);
+
+  QString aComment;
+  myName = GetFolderName();
+  CORBA::String_var anIOR = GetID();
+  SALOMEDS::SComponent_var aSComponent = VISU::FindOrCreateVisuComponent(theStudy);
+  CORBA::String_var aFatherEntry = aSComponent->GetID();
+  CreateAttributes(GetStudyDocument(), aFatherEntry.in(), "", anIOR.in(), myName, "", "", true);
 }
 
 
@@ -60,22 +79,46 @@ VISU::ColoredPrs3dCache_i::
 }
 
 
-//---------------------------------------------------------------
-const SALOMEDS::Study_var& 
-VISU::ColoredPrs3dCache_i::
-GetStudyDocument() const 
-{ 
-  return myStudy;
-}
-
-
 //----------------------------------------------------------------------------
-bool
+int
 VISU::ColoredPrs3dCache_i::
-IsPossibleToCreate(VISU::VISUType theType,
-                  const VISU::ColoredPrs3dHolder::BasicInput& theInput)
+IsPossible(VISU::VISUType theType,
+          const VISU::ColoredPrs3dHolder::BasicInput& theInput)
 {
-  return true;
+  //cout << "VISU::ColoredPrs3dCache_i::IsPossible " << endl;
+  VISU::Result_i* aResult = dynamic_cast<VISU::Result_i*>( VISU::GetServant(theInput.myResult).in() );
+  std::string aMeshName = theInput.myMeshName.in();
+  VISU::Entity anEntity = theInput.myEntity;
+  std::string aFieldName = theInput.myFieldName.in();
+  long aTimeStampNumber = theInput.myTimeStampNumber;
+
+  bool ok = 0;
+  switch( theType ){
+    case TSCALARMAP: ok = VISU::ScalarMap_i::IsPossible(aResult,aMeshName,anEntity,aFieldName,aTimeStampNumber);
+      break;
+    case TISOSURFACE: ok = VISU::IsoSurfaces_i::IsPossible(aResult,aMeshName,anEntity,aFieldName,aTimeStampNumber); 
+      break;
+    case TDEFORMEDSHAPE: ok = VISU::DeformedShape_i::IsPossible(aResult,aMeshName,anEntity,aFieldName,aTimeStampNumber);
+      break;
+    case TSCALARMAPONDEFORMEDSHAPE: ok = VISU::ScalarMapOnDeformedShape_i::IsPossible(aResult,aMeshName,anEntity,aFieldName,aTimeStampNumber);
+      break;
+    case TGAUSSPOINTS: ok = VISU::GaussPoints_i::IsPossible(aResult,aMeshName,anEntity,aFieldName,aTimeStampNumber);
+      break;
+    case TPLOT3D: ok = VISU::Plot3D_i::IsPossible(aResult,aMeshName,anEntity,aFieldName,aTimeStampNumber);
+      break;
+    case TCUTPLANES: ok = VISU::CutPlanes_i::IsPossible(aResult,aMeshName,anEntity,aFieldName,aTimeStampNumber);
+      break;
+    case TCUTLINES: ok = VISU::CutLines_i::IsPossible(aResult,aMeshName,anEntity,aFieldName,aTimeStampNumber);
+      break;
+    case TVECTORS: ok = VISU::Vectors_i::IsPossible(aResult,aMeshName,anEntity,aFieldName,aTimeStampNumber);
+      break;
+    case TSTREAMLINES: ok = VISU::StreamLines_i::IsPossible(aResult,aMeshName,anEntity,aFieldName,aTimeStampNumber);
+      break;
+  default: break;
+  }
+
+  //cout << "returned " << ok << endl;
+  return ok;
 }
 
 
@@ -85,7 +128,7 @@ VISU::ColoredPrs3dCache_i::
 CreateHolder(VISU::VISUType theType,
             const VISU::ColoredPrs3dHolder::BasicInput& theInput)
 {
-  if(IsPossibleToCreate(theType, theInput))
+  if(IsPossible(theType, theInput))
   {
     VISU::ColoredPrs3dHolder_i* aHolder = new VISU::ColoredPrs3dHolder_i(theType, theInput, *this);
     CreatePrs(theType, theInput, aHolder);
@@ -102,7 +145,7 @@ CreatePrs(VISU::VISUType theType,
          VISU::ColoredPrs3dHolder::BasicInput theInput,
          VISU::ColoredPrs3dHolder_i* theHolder)
 {
-  VISU::ColoredPrs3d_i* aPrs3d = Base_i::GetVisuGenImpl()->CreatePrs3d_i(theType, myStudy);
+  VISU::ColoredPrs3d_i* aPrs3d = Base_i::GetVisuGenImpl()->CreatePrs3d_i(theType, GetStudyDocument());
   aPrs3d->SetResultObject( theInput.myResult );  
   aPrs3d->SetMeshName( theInput.myMeshName );  
   aPrs3d->SetEntity( theInput.myEntity );  
@@ -188,7 +231,7 @@ UpdateLastVisitedPrs(VISU::ColoredPrs3dHolder_i* theHolder,
   {
     aLastVisitedPrsList.pop_front();
   }
-  else if(IsPossibleToCreate(theHolder->GetPrsType(), theInput))
+  else if(IsPossible(theHolder->GetPrsType(), theInput))
   {
     aPrs3d = CreatePrs(theHolder->GetPrsType(), theInput, theHolder);
     //cout << "Created " << aPrs3d->GetName() << endl;
index d3183efe1412bd008c5a19bf88faaecf0d812061..0abd10bb488fd27b0b559b671aaee6dad47909f5 100644 (file)
@@ -27,7 +27,7 @@
 #ifndef VISU_ColoredPrs3dCache_i_HeaderFile
 #define VISU_ColoredPrs3dCache_i_HeaderFile
 
-#include "VISUConfig.hh"
+#include "VISU_PrsObject_i.hh"
 
 #include "SALOME_GenericObj_i.hh"
 
@@ -45,7 +45,8 @@ namespace VISU
    * One cache corresponds to one study.
    */
   class ColoredPrs3dCache_i : public virtual POA_VISU::ColoredPrs3dCache,
-                             public virtual SALOME::GenericObj_i
+                             public virtual SALOME::GenericObj_i,
+                             public virtual PrsObject_i
   {
     ColoredPrs3dCache_i();
     ColoredPrs3dCache_i(const ColoredPrs3dCache_i&);
@@ -67,6 +68,26 @@ namespace VISU
                 const VISU::ColoredPrs3dHolder::BasicInput& theInput);
 
     //----------------------------------------------------------------------------
+    virtual 
+    VISU::VISUType 
+    GetType() { return VISU::TCOLOREDPRS3DCACHE; }
+
+    virtual
+    void
+    RemoveFromStudy() {}
+
+    virtual
+    void
+    ToStream(std::ostringstream&) {}
+
+    virtual
+    const char*
+    GetComment() const { return NULL; }
+
+    static
+    const std::string
+    GetFolderName() { return "Cache"; }
+
     VISU::ColoredPrs3d_i*
     CreatePrs(VISU::VISUType theType,
              VISU::ColoredPrs3dHolder::BasicInput theInput,
@@ -85,19 +106,15 @@ namespace VISU
                         VISU::View3D_ptr theView3D);
 
     //----------------------------------------------------------------------------
+    virtual int
+    IsPossible(VISU::VISUType theType,
+              const VISU::ColoredPrs3dHolder::BasicInput& theInput);
+
     VISU::ColoredPrs3d_i*
     FindPrsByInput(TLastVisitedPrsList& theLastVisitedPrsList,
                   const VISU::ColoredPrs3dHolder::BasicInput& theInput);
 
-    bool
-    IsPossibleToCreate(VISU::VISUType theType,
-                      const VISU::ColoredPrs3dHolder::BasicInput& theInput);
-
-    const SALOMEDS::Study_var& 
-    GetStudyDocument() const;
-
   private:
-    SALOMEDS::Study_var      myStudy;
     TColoredPrs3dHolderMap   myHolderMap; 
   };
 }
index 446299f0a939d6e093ae7033d24787b1c36bf548..0e295ddbc59569cfc7de9d35b83f8fc18e14de0d 100644 (file)
@@ -78,16 +78,9 @@ ColoredPrs3dHolder_i(VISU::VISUType theType,
   QString aComment;
   myName = GenerateName().latin1();
   CORBA::String_var anIOR = GetID();
-  std::string aFatherEntry = VISU::FindOrCreate3DPresentationsFolder(GetStudyDocument());
+  std::string aFatherEntry = theCache.GetEntry();
   aComment = QString("myComment=") + aType;
-  CreateAttributes(GetStudyDocument(),
-                  aFatherEntry,
-                  "",
-                  anIOR.in(),
-                  myName,
-                  "",
-                  aComment,
-                  true);
+  CreateAttributes(GetStudyDocument(), aFatherEntry, "", anIOR.in(), myName, "", aComment, true);
 }
 
 
index d5f296ed3e0a7116c749f460e9400c0af4d64223..bf48e73e2447a5cacdaa74f1fdb5f8d773434613 100644 (file)
@@ -1237,11 +1237,45 @@ namespace VISU
     return aResultSO._retn();
   }
 
+  VISU::ColoredPrs3d_i*
+  VISU_Gen_i::
+  CreateHolder(VISU::VISUType theType,
+              Result_i* theResult, 
+              const std::string& theMeshName, 
+              VISU::Entity theEntity,
+              const std::string& theFieldName, 
+              CORBA::Double theIteration)
+  {
+    VISU::ColoredPrs3dHolder::BasicInput anInput;
+    anInput.myResult = theResult->_this();
+    anInput.myMeshName = theMeshName.c_str();
+    anInput.myEntity = theEntity;
+    anInput.myFieldName = theFieldName.c_str();
+    anInput.myTimeStampNumber = theIteration;
+
+    SALOMEDS::Study_var aStudy = GetCurrentStudy();
+    VISU::ColoredPrs3dCache_ptr aCache = GetColoredPrs3dCache(aStudy);
+    VISU::ColoredPrs3dHolder_ptr aHolder = aCache->CreateHolder(theType,anInput);
+
+    VISU::ColoredPrs3d_ptr aPrs3d = aHolder->GetDevice();
+    VISU::ColoredPrs3d_i* aPrs3d_i = dynamic_cast<VISU::ColoredPrs3d_i*>(GetServant(aPrs3d).in());
+
+    return aPrs3d_i;
+  }
+
   VISU::ColoredPrs3dCache_ptr
   VISU_Gen_i::
   GetColoredPrs3dCache(SALOMEDS::Study_ptr theStudy)
   {
-    VISU::ColoredPrs3dCache_i* aCache = new VISU::ColoredPrs3dCache_i(theStudy);
-    return aCache->_this();
+    SALOMEDS::SObject_var aSObject = theStudy->FindObject(VISU::ColoredPrs3dCache_i::GetFolderName().c_str());
+    if(!CORBA::is_nil(aSObject))
+    {
+      CORBA::Object_var anObject = aSObject->GetObject();
+      VISU::ColoredPrs3dCache_var aCache = VISU::ColoredPrs3dCache::_narrow(anObject);
+      if(!CORBA::is_nil(aCache))
+       return aCache._retn();
+    }
+
+    return (new VISU::ColoredPrs3dCache_i(theStudy))->_this();
   }
 }
index 68a78fe67ec167319b646d68d1698bfc796cc44e..a1f971089322650ab582f95b40a51d5ca42d295c 100644 (file)
@@ -37,6 +37,7 @@ namespace VISU
   class Result_i;
   class ColoredPrs3d_i;
   class ColoredPrs3dCache_i;
+  class ColoredPrs3dHolder_i;
 
   bool
   CreatColoredPrs3d(ColoredPrs3d_i* theColoredPrs3d,
@@ -178,6 +179,14 @@ namespace VISU
     CreatePrs3d(VISUType theType,
                SALOMEDS::Study_ptr theStudy);
 
+    ColoredPrs3d_i*
+    CreateHolder(VISU::VISUType theType,
+                Result_i* theResult, 
+                const std::string& theMeshName, 
+                VISU::Entity theEntity,
+                const std::string& theFieldName, 
+                CORBA::Double theIteration);
+
     //Create 3D collored Presentation Of Different Types
     template<typename TPrs3d_i> TPrs3d_i*
     CreatePrs3d(Result_ptr theResult, 
@@ -196,6 +205,15 @@ namespace VISU
       if(Result_i* aResult = dynamic_cast<Result_i*>(GetServant(theResult).in())){
        if(TPrs3d_i::IsPossible(aResult,theMeshName,theEntity,theFieldName,int(theIteration))){
          TPrs3d_i* aPresent = new TPrs3d_i(aResult,thePublishInStudyMode);
+
+         if( thePublishInStudyMode != ColoredPrs3d_i::EPublishUnderTimeStamp )
+         {
+           ColoredPrs3d_i* aPrs3d = 
+             CreateHolder(aPresent->GetType(),aResult,theMeshName,theEntity,theFieldName,theIteration);
+
+           return dynamic_cast<TPrs3d_i*>(aPrs3d);
+         }
+
          if(CreatColoredPrs3d(aPresent,theMeshName,theEntity,theFieldName,theIteration))
            return aPresent;
          aPresent->_remove_ref();
index f123da20338c3925ad08fe2863035a5888c7d916..cc90e55d30c9f2b48588a99c0ced8b34872c6c5c 100644 (file)
@@ -13,11 +13,19 @@ def WalkTroughTimeStamps(theVISUType,
 
   aCache = myVisu.GetColoredPrs3dCache(myVisu.GetCurrentStudy())
   aHolder = aCache.CreateHolder(theVISUType, theInput)
+
+  if not aHolder:
+    print "It is impossible to create such kind of holder (%s) with the given parameters" % theVISUType
+    print "\ttheMeshName = '%s'" % theInput.myMeshName
+    print "\ttheEntity = %s" % theInput.myEntity
+    print "\ttheFieldName = '%s'" % theInput.myFieldName
+    print "\ttheTimeStampNumber = %s" % theInput.myTimeStampNumber
+    return
+
   aPrs3d = aHolder.GetDevice()
 
-  #aPrs3d = myVisu.CreatePrs3d(theVISUType, myVisu.GetCurrentStudy())
   if not aHolder.Apply(aPrs3d, theInput, aView):
-    print "It is impossible to create such kind of presentation (%s) with the given parameters"
+    print "It is impossible to create such kind of presentation (%s) with the given parameters" % theVISUType
     print "\ttheMeshName = '%s'" % theInput.myMeshName
     print "\ttheEntity = %s" % theInput.myEntity
     print "\ttheFieldName = '%s'" % theInput.myFieldName
@@ -38,7 +46,7 @@ def WalkTroughTimeStamps(theVISUType,
 
 #---------------------------------------------------------------
 PRS3D_TYPE_LIST = []
-#PRS3D_TYPE_LIST.append(VISU.TGAUSSPOINTS)
+PRS3D_TYPE_LIST.append(VISU.TGAUSSPOINTS)
 PRS3D_TYPE_LIST.append(VISU.TSCALARMAP)
 PRS3D_TYPE_LIST.append(VISU.TISOSURFACE)
 PRS3D_TYPE_LIST.append(VISU.TCUTPLANES)