]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Initial implementation of the cache system.
authorouv <ouv@opencascade.com>
Wed, 15 Nov 2006 15:02:13 +0000 (15:02 +0000)
committerouv <ouv@opencascade.com>
Wed, 15 Nov 2006 15:02:13 +0000 (15:02 +0000)
Added interfaces for VISU_ColoredPrs3dCache and VISU_ColoredPrs3dHolder.

15 files changed:
idl/VISU_Gen.idl
src/ENGINE/VISU_Engine_i.cc
src/ENGINE/VISU_Engine_i.hh
src/VISU_I/Makefile.in
src/VISU_I/VISUConfig.hh
src/VISU_I/VISU_ColoredPrs3dCache_i.cc [new file with mode: 0644]
src/VISU_I/VISU_ColoredPrs3dCache_i.hh [new file with mode: 0644]
src/VISU_I/VISU_ColoredPrs3dHolder_i.cc [new file with mode: 0644]
src/VISU_I/VISU_ColoredPrs3dHolder_i.hh [new file with mode: 0644]
src/VISU_I/VISU_ColoredPrs3d_i.cc
src/VISU_I/VISU_ColoredPrs3d_i.hh
src/VISU_I/VISU_Gen_i.cc
src/VISU_I/VISU_Gen_i.hh
src/VISU_SWIG/Makefile.in
src/VISU_SWIG/visu_cache.py [new file with mode: 0644]

index 7a659d09405074aa06f328ad1265d68a89c2a4bb..ad9aa1490e76b1997856ff870388a0ebe6cbf7b9 100644 (file)
@@ -94,6 +94,8 @@ module VISU {
     TFIELD, /*!< Field represents the results of calculations (it can be scalar or vector values), grouped together under one physical concept. */
     TTIMESTAMP, /*!<Time stamp represents a subfield: the results of calculations are taken in one definite moment. */
     TANIMATION, /*!< Represents Animation object. */
+    TCOLOREDPRS3DHOLDER, /*!< Colored 3D presentation holder */
+    TCOLOREDPRS3DCACHE, /*!< Colored 3D presentation cache */
     TALL
   };
 
@@ -564,6 +566,72 @@ module VISU {
      * Gets the title of the scalar bar.
      */
     string GetTitle();
+    
+    /*!
+     * Gets an expended memory size for the presentation.
+     */
+    long GetMemorySize();
+  };
+
+
+  //-------------------------------------------------------
+  interface View3D;
+
+  /*! \brief %ColoredPrs3dHolder interface.
+   * Interface of 3d presentation's holder, which represents colored 3d presentations,
+   * created on fields. It is publishing in the object browser in a separate folder
+   * and can be controled by viewer's slider.
+   */
+  interface ColoredPrs3dHolder : PrsObject, SALOME::GenericObj
+  {
+    /*!
+     * Presentation input parameters.
+     */
+    struct BasicInput
+    {
+      Result myResult;
+      string myMeshName;
+      Entity myEntity;
+      string myFieldName;
+      long myTimeStampNumber;
+    };
+
+    /*!
+     * Apply input parameters to last visited presentation in the cache.
+     */
+    boolean Apply(in ColoredPrs3d thePrs3d,
+                 in BasicInput theInput,
+                 in View3D theView3D);
+
+    /*!
+     * Gets the last visited presentation in the cache.
+     */
+    ColoredPrs3d GetDevice();
+
+    /*!
+     * Gets TimeStampsRange information from the last visited presentation.
+     */
+    ColoredPrs3d::TimeStampsRange GetTimeStampsRange();
+
+    /*!
+     * Gats input parameters of the last visited presentation.
+     */
+    BasicInput GetBasicInput();
+  };
+
+
+  //-------------------------------------------------------
+  /*! \brief %ColoredPrs3dCache interface.
+   * This interface is responsible for memory management of 3d presentations.
+   * One cache corresponds to one study.
+   */
+  interface ColoredPrs3dCache : SALOME::GenericObj
+  {
+    /*!
+     * Creates %ColoredPrs3dHolder.
+     */
+    ColoredPrs3dHolder CreateHolder(in VISUType theType,
+                                   in ColoredPrs3dHolder::BasicInput theInput);
   };
 
 
@@ -1419,7 +1487,6 @@ module VISU {
 
   //-------------------------------------------------------
   interface ViewManager;
-  interface View3D;
 
   /*! \brief %VISU_Gen interface
    *
@@ -1694,6 +1761,11 @@ module VISU {
     void DeleteResult(in Result theResult);
 
     void DeletePrs3d(in Prs3d thePrs3d);
+
+    /*!
+     * Get or create %ColoredPrs3dCache object.
+     */
+    ColoredPrs3dCache GetColoredPrs3dCache(in SALOMEDS::Study theStudy);
   };
 
   /*! \brief %View interface
index fcce515b7888c1944e570e2e0baaf123b7f04637..f09b5ddc7fd33c09ed2711d6953ca85dc16ce0ea 100644 (file)
@@ -422,4 +422,10 @@ namespace VISU{
     return myVisuGen->DumpPython(theStudy, theIsPublished, theIsValidScript);
   }     
 
+  VISU::ColoredPrs3dCache_ptr
+  VISU_Gen_i::
+  GetColoredPrs3dCache(SALOMEDS::Study_ptr theStudy)
+  {
+    return myVisuGen->GetColoredPrs3dCache(theStudy);
+  }
 };
index 0b6727a1f39d342a719bf5172461386777b1f24e..c10bbc80aa60e2215fa2d1c89274c647cf3826d1 100644 (file)
@@ -166,6 +166,10 @@ namespace VISU
     virtual Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy,
                                         CORBA::Boolean theIsPublished,
                                         CORBA::Boolean& theIsValidScript);   
+
+    virtual
+    VISU::ColoredPrs3dCache_ptr
+    GetColoredPrs3dCache(SALOMEDS::Study_ptr theStudy);
   };
 };
 
index 41b9c67e5df289959da881e30d2926f6ce2b67d0..4f0074bf390c42e6dbc83f29a5734bc3c4b83bdc 100644 (file)
@@ -55,7 +55,9 @@ LIB_SRC = \
        VISU_TimeAnimation.cxx \
        VISU_CorbaMedConvertor.cxx \
        VISU_DumpPython.cc \
-       VISU_ScalarMapOnDeformedShape_i.cc
+       VISU_ScalarMapOnDeformedShape_i.cc \
+       VISU_ColoredPrs3dHolder_i.cc \
+       VISU_ColoredPrs3dCache_i.cc
 
 LIB_MOC = \
        VISU_TimeAnimation.h
@@ -100,7 +102,9 @@ EXPORT_HEADERS = \
        VISU_ViewManager_i.hh \
        VISU_View_i.hh \
        VISU_TimeAnimation.h \
-       VISU_ScalarMapOnDeformedShape_i.hh
+       VISU_ScalarMapOnDeformedShape_i.hh \
+       VISU_ColoredPrs3dHolder_i.hh \
+       VISU_ColoredPrs3dCache_i.hh
 
 # additionnal information to compil and link file
 CPPFLAGS += \
index c3326194ae79ee9d3fe8b8539e642cc31b97dfb1..dcf5d80d0f6a01764d2f70fbfc98f45631f040f0 100644 (file)
@@ -53,6 +53,7 @@
 
 // STL headers
 #include <map>
+#include <deque>
 #include <string>
 #include <sstream>
 #include <iostream>
diff --git a/src/VISU_I/VISU_ColoredPrs3dCache_i.cc b/src/VISU_I/VISU_ColoredPrs3dCache_i.cc
new file mode 100644 (file)
index 0000000..3fbf6f2
--- /dev/null
@@ -0,0 +1,215 @@
+//  VISU OBJECT : interactive object for VISU entities implementation
+//
+//  Copyright (C) 2003  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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//  File   : VISU_ColoredPrs3dCache_i.cc
+//  Author : Oleg UVAROV
+//  Module : VISU
+
+#include "VISU_ColoredPrs3dCache_i.hh"
+
+#include "VISU_Gen_i.hh"
+#include "VISU_View_i.hh"
+#include "VISU_ViewManager_i.hh"
+#include "VISU_ColoredPrs3d_i.hh"
+#include "VISU_ColoredPrs3dHolder_i.hh"
+
+#include "VVTK_ViewWindow.h"
+
+using namespace VISU;
+using namespace std;
+
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
+//----------------------------------------------------------------------------
+VISU::ColoredPrs3dCache_i::
+ColoredPrs3dCache_i(SALOMEDS::Study_ptr theStudy):
+  myStudy(SALOMEDS::Study::_duplicate(theStudy))
+{
+  if(MYDEBUG) MESSAGE("ColoredPrs3dCache_i::ColoredPrs3dCache_i - this = "<<this);
+}
+
+
+//----------------------------------------------------------------------------
+VISU::ColoredPrs3dCache_i::
+~ColoredPrs3dCache_i() 
+{
+  if(MYDEBUG) MESSAGE("ColoredPrs3dCache_i::~ColoredPrs3dCache_i - this = "<<this);
+}
+
+
+//---------------------------------------------------------------
+const SALOMEDS::Study_var& 
+VISU::ColoredPrs3dCache_i::
+GetStudyDocument() const 
+{ 
+  return myStudy;
+}
+
+
+//----------------------------------------------------------------------------
+bool
+VISU::ColoredPrs3dCache_i::
+IsPossibleToCreate(VISU::VISUType theType,
+                  const VISU::ColoredPrs3dHolder::BasicInput& theInput)
+{
+  return true;
+}
+
+
+//----------------------------------------------------------------------------
+VISU::ColoredPrs3dHolder_ptr
+VISU::ColoredPrs3dCache_i::
+CreateHolder(VISU::VISUType theType,
+            const VISU::ColoredPrs3dHolder::BasicInput& theInput)
+{
+  if(IsPossibleToCreate(theType, theInput))
+  {
+    VISU::ColoredPrs3dHolder_i* aHolder = new VISU::ColoredPrs3dHolder_i(theType, theInput, *this);
+    CreatePrs(theType, theInput, aHolder);
+    return aHolder->_this();
+  }
+  return VISU::ColoredPrs3dHolder::_nil();
+}
+
+
+//----------------------------------------------------------------------------
+VISU::ColoredPrs3d_i*
+VISU::ColoredPrs3dCache_i::
+CreatePrs(VISU::VISUType theType,
+         VISU::ColoredPrs3dHolder::BasicInput theInput,
+         VISU::ColoredPrs3dHolder_i* theHolder)
+{
+  VISU::ColoredPrs3d_i* aPrs3d = Base_i::GetVisuGenImpl()->CreatePrs3d_i(theType, myStudy);
+  aPrs3d->SetResultObject( theInput.myResult );  
+  aPrs3d->SetMeshName( theInput.myMeshName );  
+  aPrs3d->SetEntity( theInput.myEntity );  
+  aPrs3d->SetFieldName( theInput.myFieldName );  
+  aPrs3d->SetTimeStampNumber( theInput.myTimeStampNumber );
+  aPrs3d->Apply();
+
+  GetLastVisitedPrsList(theHolder).push_back(aPrs3d);
+  
+  return aPrs3d;
+}
+
+
+//----------------------------------------------------------------------------
+TLastVisitedPrsList&
+VISU::ColoredPrs3dCache_i::
+GetLastVisitedPrsList(VISU::ColoredPrs3dHolder_i* theHolder)
+{
+  //cout << "VISU::ColoredPrs3dCache_i::GetLastVisitedPrsList(";
+  //cout << theHolder->GetEntry().latin1() << ")" << endl;
+  return myHolderMap[theHolder->GetEntry()];
+}
+
+
+//----------------------------------------------------------------------------
+VISU::ColoredPrs3d_i*
+VISU::ColoredPrs3dCache_i::
+GetLastVisitedPrs(VISU::ColoredPrs3dHolder_i* theHolder)
+{
+  TLastVisitedPrsList aList = GetLastVisitedPrsList(theHolder);
+  if( !aList.empty() )
+    return aList.front();
+
+  return NULL;
+}
+
+
+//----------------------------------------------------------------------------
+VISU::ColoredPrs3d_i*
+VISU::ColoredPrs3dCache_i::
+FindPrsByInput(TLastVisitedPrsList& theLastVisitedPrsList,
+              const VISU::ColoredPrs3dHolder::BasicInput& theInput)
+{
+  //cout << "VISU::ColoredPrs3dCache_i::FindPrsByInput() ";
+  VISU::ColoredPrs3d_i* aPrs3d = NULL;
+  VISU::ColoredPrs3dHolder::BasicInput_var anInput;
+  TLastVisitedPrsList::iterator it = theLastVisitedPrsList.begin();
+  TLastVisitedPrsList::iterator itEnd = theLastVisitedPrsList.end();
+  for(; it != itEnd; ++it)
+  {
+    aPrs3d = *it;
+    anInput = aPrs3d->GetBasicInput();
+
+    if(anInput->myResult->_is_equivalent(theInput.myResult) &&
+       !strcmp(anInput->myMeshName.in(), theInput.myMeshName.in()) &&
+       anInput->myEntity == theInput.myEntity &&
+       !strcmp(anInput->myFieldName.in(), theInput.myFieldName.in()) &&
+       anInput->myTimeStampNumber == theInput.myTimeStampNumber )
+    {
+      //cout << "returns " << aPrs3d->GetName() << endl;
+      return aPrs3d;
+    }
+  }
+
+  //cout << "returns NULL" << endl;
+  return NULL;
+}
+
+
+//----------------------------------------------------------------------------
+bool
+VISU::ColoredPrs3dCache_i::
+UpdateLastVisitedPrs(VISU::ColoredPrs3dHolder_i* theHolder,
+                    VISU::ColoredPrs3d_i* thePrs,
+                    const VISU::ColoredPrs3dHolder::BasicInput& theInput,
+                    VISU::View3D_ptr theView3D)
+{
+  //cout << "VISU::ColoredPrs3dCache_i::UpdateLastVisitedPrs" << endl;
+  VISU::ColoredPrs3d_i* aPrs3d = NULL;
+  TLastVisitedPrsList& aLastVisitedPrsList = GetLastVisitedPrsList(theHolder);
+
+  if(aPrs3d = FindPrsByInput(aLastVisitedPrsList, theInput))
+  {
+    aLastVisitedPrsList.pop_front();
+  }
+  else if(IsPossibleToCreate(theHolder->GetPrsType(), theInput))
+  {
+    aPrs3d = CreatePrs(theHolder->GetPrsType(), theInput, theHolder);
+    //cout << "Created " << aPrs3d->GetName() << endl;
+  }
+  else
+  {
+    //cout << "Move only" << endl;
+    aPrs3d = aLastVisitedPrsList.front();
+    aLastVisitedPrsList.pop_front();
+  }
+  aLastVisitedPrsList.push_back(aPrs3d);
+
+  //aPrs3d->SameAs(thePrs);
+
+  if(aPrs3d && !CORBA::is_nil(theView3D))
+  {
+    //cout << "Display " << aPrs3d->GetName() << endl;
+    VISU::ColoredPrs3d_var aColoredPrs3d = aPrs3d->_this();
+    theView3D->DisplayOnly(aColoredPrs3d);
+    return true;
+  }
+
+  return false;
+}
diff --git a/src/VISU_I/VISU_ColoredPrs3dCache_i.hh b/src/VISU_I/VISU_ColoredPrs3dCache_i.hh
new file mode 100644 (file)
index 0000000..d3183ef
--- /dev/null
@@ -0,0 +1,105 @@
+//  VISU OBJECT : interactive object for VISU entities implementation
+//
+//  Copyright (C) 2003  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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//  File   : VISU_ColoredPrs3dCache_i.hxx
+//  Author : Oleg UVAROV
+//  Module : VISU
+
+#ifndef VISU_ColoredPrs3dCache_i_HeaderFile
+#define VISU_ColoredPrs3dCache_i_HeaderFile
+
+#include "VISUConfig.hh"
+
+#include "SALOME_GenericObj_i.hh"
+
+namespace VISU
+{
+  class ColoredPrs3d_i;
+  class ColoredPrs3dHolder_i;
+
+  typedef std::string THolderEntry;
+  typedef std::deque<VISU::ColoredPrs3d_i*> TLastVisitedPrsList;
+  typedef std::map<THolderEntry,TLastVisitedPrsList> TColoredPrs3dHolderMap;
+
+  /*!
+   * This interface is responsible for memory management of 3d presentations.
+   * One cache corresponds to one study.
+   */
+  class ColoredPrs3dCache_i : public virtual POA_VISU::ColoredPrs3dCache,
+                             public virtual SALOME::GenericObj_i
+  {
+    ColoredPrs3dCache_i();
+    ColoredPrs3dCache_i(const ColoredPrs3dCache_i&);
+  public:
+    //----------------------------------------------------------------------------
+    //! A constructor to create an instance of the class
+    explicit
+    ColoredPrs3dCache_i(SALOMEDS::Study_ptr theStudy);
+
+    virtual
+    ~ColoredPrs3dCache_i();
+
+    //----------------------------------------------------------------------------
+    /*!
+     * Creates ColoredPrs3dHolder.
+     */
+    VISU::ColoredPrs3dHolder_ptr
+    CreateHolder(VISU::VISUType theType,
+                const VISU::ColoredPrs3dHolder::BasicInput& theInput);
+
+    //----------------------------------------------------------------------------
+    VISU::ColoredPrs3d_i*
+    CreatePrs(VISU::VISUType theType,
+             VISU::ColoredPrs3dHolder::BasicInput theInput,
+             VISU::ColoredPrs3dHolder_i* theHolder);
+
+    TLastVisitedPrsList&
+    GetLastVisitedPrsList(VISU::ColoredPrs3dHolder_i* theHolder);
+
+    VISU::ColoredPrs3d_i*
+    GetLastVisitedPrs(VISU::ColoredPrs3dHolder_i* theHolder);
+
+    bool
+    UpdateLastVisitedPrs(VISU::ColoredPrs3dHolder_i* theHolder,
+                        VISU::ColoredPrs3d_i* thePrs,
+                        const VISU::ColoredPrs3dHolder::BasicInput& theInput,
+                        VISU::View3D_ptr theView3D);
+
+    //----------------------------------------------------------------------------
+    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; 
+  };
+}
+
+#endif
diff --git a/src/VISU_I/VISU_ColoredPrs3dHolder_i.cc b/src/VISU_I/VISU_ColoredPrs3dHolder_i.cc
new file mode 100644 (file)
index 0000000..446299f
--- /dev/null
@@ -0,0 +1,150 @@
+//  VISU OBJECT : interactive object for VISU entities implementation
+//
+//  Copyright (C) 2003  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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//  File   : VISU_ColoredPrs3dHolder_i.cc
+//  Author : Oleg UVAROV
+//  Module : VISU
+
+#include "VISU_ColoredPrs3dHolder_i.hh"
+
+#include "VISU_ColoredPrs3dCache_i.hh"
+#include "VISU_ColoredPrs3d_i.hh"
+
+using namespace VISU;
+using namespace std;
+
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
+//---------------------------------------------------------------
+int VISU::ColoredPrs3dHolder_i::myNbHolders = 0;
+
+//---------------------------------------------------------------
+QString 
+VISU::ColoredPrs3dHolder_i::
+GenerateName() 
+{ 
+  return VISU::GenerateName("Holder",myNbHolders++);
+}
+
+//----------------------------------------------------------------------------
+VISU::ColoredPrs3dHolder_i::
+ColoredPrs3dHolder_i(VISU::VISUType theType,
+                    VISU::ColoredPrs3dHolder::BasicInput theInput,
+                    VISU::ColoredPrs3dCache_i& theCache) :
+  PrsObject_i(theCache.GetStudyDocument()),
+  myPrsType(theType),
+  myCache(theCache)
+{
+  if(MYDEBUG) MESSAGE("ColoredPrs3dHolder_i::ColoredPrs3dHolder_i - this = "<<this);
+
+  QString aType;
+  switch( theType ){
+    case TSCALARMAP:                aType = "SCALARMAP"; break;
+    case TISOSURFACE:               aType = "ISOSURFACES"; break;
+    case TDEFORMEDSHAPE:            aType = "DEFORMEDSHAPE"; break;
+    case TSCALARMAPONDEFORMEDSHAPE: aType = "SCALARMAPONDEFORMEDSHAPE"; break;
+    case TGAUSSPOINTS:              aType = "GAUSSPOINTS"; break;
+    case TPLOT3D:                   aType = "PLOT3D"; break;
+    case TCUTPLANES:                aType = "CUTPLANES"; break;
+    case TCUTLINES:                 aType = "CUTLINES"; break;
+    case TVECTORS:                  aType = "VECTORS"; break;
+    case TSTREAMLINES:              aType = "STREAMLINES"; break;
+    default: break;
+  }
+
+  QString aComment;
+  myName = GenerateName().latin1();
+  CORBA::String_var anIOR = GetID();
+  std::string aFatherEntry = VISU::FindOrCreate3DPresentationsFolder(GetStudyDocument());
+  aComment = QString("myComment=") + aType;
+  CreateAttributes(GetStudyDocument(),
+                  aFatherEntry,
+                  "",
+                  anIOR.in(),
+                  myName,
+                  "",
+                  aComment,
+                  true);
+}
+
+
+//----------------------------------------------------------------------------
+VISU::ColoredPrs3dHolder_i::
+~ColoredPrs3dHolder_i() 
+{
+  if(MYDEBUG) MESSAGE("ColoredPrs3dHolder_i::~ColoredPrs3dHolder_i - this = "<<this);
+}
+
+
+//----------------------------------------------------------------------------
+CORBA::Boolean 
+VISU::ColoredPrs3dHolder_i::
+Apply(VISU::ColoredPrs3d_ptr thePrs3d,
+      const VISU::ColoredPrs3dHolder::BasicInput& theInput,
+      VISU::View3D_ptr theView3D)
+{
+  VISU::ColoredPrs3d_i* aPrs3d = dynamic_cast<VISU::ColoredPrs3d_i*>( VISU::GetServant(thePrs3d).in() );
+  return myCache.UpdateLastVisitedPrs(this, aPrs3d, theInput, theView3D);
+}
+
+//----------------------------------------------------------------------------
+VISU::ColoredPrs3d_ptr
+VISU::ColoredPrs3dHolder_i::
+GetDevice()
+{
+  if(VISU::ColoredPrs3d_i* aPrs3d = myCache.GetLastVisitedPrs(this))
+    return aPrs3d->_this();
+
+  return VISU::ColoredPrs3d::_nil();
+}
+
+
+//----------------------------------------------------------------------------
+VISU::ColoredPrs3d::TimeStampsRange*
+VISU::ColoredPrs3dHolder_i::
+GetTimeStampsRange()
+{
+  if( VISU::ColoredPrs3d_ptr aDevice = GetDevice() )
+    return aDevice->GetTimeStampsRange();
+
+  return NULL;
+}
+
+
+//----------------------------------------------------------------------------
+VISU::ColoredPrs3dHolder::BasicInput*
+VISU::ColoredPrs3dHolder_i::
+GetBasicInput()
+{
+  if( VISU::ColoredPrs3d_ptr aDevice = GetDevice() )
+  {
+    VISU::ColoredPrs3d_i* aPrs3d = dynamic_cast<VISU::ColoredPrs3d_i*>( VISU::GetServant(aDevice).in() );
+    if( aPrs3d )
+      return aPrs3d->GetBasicInput();
+  }
+
+  return NULL;
+}
diff --git a/src/VISU_I/VISU_ColoredPrs3dHolder_i.hh b/src/VISU_I/VISU_ColoredPrs3dHolder_i.hh
new file mode 100644 (file)
index 0000000..673cb75
--- /dev/null
@@ -0,0 +1,121 @@
+//  VISU OBJECT : interactive object for VISU entities implementation
+//
+//  Copyright (C) 2003  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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//  File   : VISU_ColoredPrs3dHolder_i.hxx
+//  Author : Oleg UVAROV
+//  Module : VISU
+
+#ifndef VISU_ColoredPrs3dHolder_i_HeaderFile
+#define VISU_ColoredPrs3dHolder_i_HeaderFile
+
+#include "VISU_PrsObject_i.hh"
+
+#include "SALOME_GenericObj_i.hh"
+
+namespace VISU
+{
+  class ColoredPrs3d_i;
+  class ColoredPrs3dCache_i;
+
+  /*!
+   * Interface of 3d presentation's holder, which represents colored 3d presentations,
+   * created on fields. It is publishing in the object browser in a separate folder
+   * and can be controled by viewer's slider.
+   */
+  class ColoredPrs3dHolder_i : public virtual POA_VISU::ColoredPrs3dHolder,
+                              public virtual SALOME::GenericObj_i,
+                              public virtual PrsObject_i
+  {
+    ColoredPrs3dHolder_i();
+    ColoredPrs3dHolder_i(const ColoredPrs3dHolder_i&);
+  public:
+    //----------------------------------------------------------------------------
+    //! A constructor to create an instance of the class
+    explicit
+    ColoredPrs3dHolder_i(VISU::VISUType theType,
+                        VISU::ColoredPrs3dHolder::BasicInput theInput,
+                        VISU::ColoredPrs3dCache_i& theCache);
+
+    virtual
+    ~ColoredPrs3dHolder_i();
+
+    //----------------------------------------------------------------------------
+    /*! Apply input parameters to last visited presentation in the cache.
+     */
+    virtual
+    CORBA::Boolean 
+    Apply(VISU::ColoredPrs3d_ptr thePrs3d,
+         const VISU::ColoredPrs3dHolder::BasicInput& theInput,
+         VISU::View3D_ptr theView3D);
+
+    /*! Gets the last visited presentation in the cache.
+     */
+    virtual
+    VISU::ColoredPrs3d_ptr
+    GetDevice();
+
+    /*! Gets TimeStampsRange information from the last visited presentation.
+     */
+    virtual
+    VISU::ColoredPrs3d::TimeStampsRange*
+    GetTimeStampsRange();
+
+    /*! Gats input parameters of the last visited presentation.
+     */
+    VISU::ColoredPrs3dHolder::BasicInput*
+    GetBasicInput();
+
+    //----------------------------------------------------------------------------
+    virtual 
+    VISU::VISUType 
+    GetType() { return VISU::TCOLOREDPRS3DHOLDER; }
+
+    virtual
+    void
+    RemoveFromStudy() {}
+
+    virtual
+    void
+    ToStream(std::ostringstream&) {}
+
+    virtual
+    QString 
+    GenerateName();
+
+    virtual
+    const char*
+    GetComment() const { return NULL; }
+
+    //----------------------------------------------------------------------------
+    VISU::VISUType
+    GetPrsType() const { return myPrsType; }
+
+  private:
+    VISU::VISUType               myPrsType;
+
+    VISU::ColoredPrs3dCache_i&   myCache;
+
+    static int                   myNbHolders;
+  };
+}
+
+#endif
index 561c3eeb557c5453848a786fc44b16f3939b38c8..fb9f3580a67c0567e33bdd9552973fd17eca85b9 100644 (file)
@@ -343,6 +343,20 @@ VISU::ColoredPrs3d_i
   return aTimeStampsRange._retn();
 }
 
+VISU::ColoredPrs3dHolder::BasicInput*
+VISU::ColoredPrs3d_i
+::GetBasicInput()
+{
+  VISU::ColoredPrs3dHolder::BasicInput* aBasicInput = new VISU::ColoredPrs3dHolder::BasicInput();
+  aBasicInput->myResult = GetResultObject();
+  aBasicInput->myMeshName = GetMeshName();
+  aBasicInput->myEntity = GetEntity();
+  aBasicInput->myFieldName = GetFieldName();
+  aBasicInput->myTimeStampNumber = GetTimeStampNumber();
+
+  return aBasicInput;
+}
+
 //----------------------------------------------------------------------------
 CORBA::Boolean 
 VISU::ColoredPrs3d_i
@@ -1042,7 +1056,7 @@ VISU::ColoredPrs3d_i
 
 //----------------------------------------------------------------------------
 std::string
-FindOrCreate3DPresentationsFolder(SALOMEDS::Study_ptr theStudy)
+VISU::FindOrCreate3DPresentationsFolder(SALOMEDS::Study_ptr theStudy)
 {
   static char aFolderName[] = "3D Presentations";
   CORBA::String_var anEntry;
@@ -1119,7 +1133,7 @@ VISU::ColoredPrs3d_i
     }else if(myPublishInStudyMode == EPublishIndependently){
       myName = GenerateName().latin1();
       CORBA::String_var anIOR = GetID();
-      std::string aFatherEntry = FindOrCreate3DPresentationsFolder(GetStudyDocument());
+      std::string aFatherEntry = VISU::FindOrCreate3DPresentationsFolder(GetStudyDocument());
       aComment.sprintf("myComment=%s",
                       GetComment());
       CreateAttributes(GetStudyDocument(),
index fbf58227397a1a837810359a58a214cba23f0163..90bdee9238a6652ff9dfa6b47f6bb6511870d9fd 100644 (file)
@@ -33,6 +33,9 @@ class VISU_ScalarMapPL;
 
 namespace VISU
 {
+  std::string
+  FindOrCreate3DPresentationsFolder(SALOMEDS::Study_ptr theStudy);
+
   //============================================================================
   class ColoredPrs3d_i : public virtual POA_VISU::ColoredPrs3d,
                         public virtual Prs3d_i
@@ -213,6 +216,14 @@ namespace VISU
     std::string 
     GetCTitle();
 
+    virtual
+    CORBA::Long
+    GetMemorySize() { return 0; }
+
+    //! Returns presentation input
+    VISU::ColoredPrs3dHolder::BasicInput*
+    GetBasicInput();
+
     //----------------------------------------------------------------------------
   public:
     /*!
index 0ba7f8cf8f37a1e107a615f964ec7c55c8462615..d5f296ed3e0a7116c749f460e9400c0af4d64223 100644 (file)
@@ -44,6 +44,9 @@
 #include "VISU_TimeAnimation.h"
 #include "VISU_ScalarMapOnDeformedShape_i.hh"
 
+#include "VISU_ColoredPrs3dCache_i.hh"
+#include "VISU_ColoredPrs3dHolder_i.hh"
+
 #include "VISU_Actor.h"
 
 #include "HDFascii.hxx"
@@ -246,48 +249,44 @@ namespace VISU
   }
 
 
-  template<typename TPrs3d_i> 
-  Prs3d_ptr
-  CreatePrs3d(SALOMEDS::Study_ptr theStudy)
-  {
-    if(!theStudy->GetProperties()->IsLocked()){
-      typedef typename TPrs3d_i::TInterface TPrs3d;
-      typename TPrs3d::_var_type aPrs3d;
-      if(TPrs3d_i* aPresent = new TPrs3d_i(NULL,ColoredPrs3d_i::EPublishIndependently)){
-       return aPresent->_this();
-      }
-    }
-    return Prs3d::_nil();
-  }
-
-
-  Prs3d_ptr
+  ColoredPrs3d_i*
   VISU_Gen_i::
-  CreatePrs3d(VISUType theType,
-             SALOMEDS::Study_ptr theStudy)
+  CreatePrs3d_i(VISUType theType,
+               SALOMEDS::Study_ptr theStudy)
   {
     switch(theType){
     case TSCALARMAP:
-      return VISU::CreatePrs3d<ScalarMap_i>(theStudy);
+      return VISU::CreatePrs3d_i<ScalarMap_i>(theStudy);
     case TGAUSSPOINTS:
-      return VISU::CreatePrs3d<GaussPoints_i>(theStudy);
+      return VISU::CreatePrs3d_i<GaussPoints_i>(theStudy);
     case TDEFORMEDSHAPE:
-      return VISU::CreatePrs3d<DeformedShape_i>(theStudy);
+      return VISU::CreatePrs3d_i<DeformedShape_i>(theStudy);
     case TSCALARMAPONDEFORMEDSHAPE:
-      return VISU::CreatePrs3d<ScalarMapOnDeformedShape_i>(theStudy);
+      return VISU::CreatePrs3d_i<ScalarMapOnDeformedShape_i>(theStudy);
     case TISOSURFACE:
-      return VISU::CreatePrs3d<IsoSurfaces_i>(theStudy);
+      return VISU::CreatePrs3d_i<IsoSurfaces_i>(theStudy);
     case TSTREAMLINES:
-      return VISU::CreatePrs3d<StreamLines_i>(theStudy);
+      return VISU::CreatePrs3d_i<StreamLines_i>(theStudy);
     case TPLOT3D:
-      return VISU::CreatePrs3d<Plot3D_i>(theStudy);
+      return VISU::CreatePrs3d_i<Plot3D_i>(theStudy);
     case TCUTPLANES:
-      return VISU::CreatePrs3d<CutPlanes_i>(theStudy);
+      return VISU::CreatePrs3d_i<CutPlanes_i>(theStudy);
     case TCUTLINES:
-      return VISU::CreatePrs3d<CutLines_i>(theStudy);
+      return VISU::CreatePrs3d_i<CutLines_i>(theStudy);
     case TVECTORS:
-      return VISU::CreatePrs3d<Vectors_i>(theStudy);
+      return VISU::CreatePrs3d_i<Vectors_i>(theStudy);
     }
+    return NULL;
+  }
+
+
+  Prs3d_ptr
+  VISU_Gen_i::
+  CreatePrs3d(VISUType theType,
+             SALOMEDS::Study_ptr theStudy)
+  {
+    if(ColoredPrs3d_i* aPrs3d = CreatePrs3d_i(theType, theStudy))
+      return aPrs3d->_this();
     return Prs3d::_nil();
   }
 
@@ -1237,4 +1236,12 @@ namespace VISU
     anIOR->SetValue(anIORValue);
     return aResultSO._retn();
   }
+
+  VISU::ColoredPrs3dCache_ptr
+  VISU_Gen_i::
+  GetColoredPrs3dCache(SALOMEDS::Study_ptr theStudy)
+  {
+    VISU::ColoredPrs3dCache_i* aCache = new VISU::ColoredPrs3dCache_i(theStudy);
+    return aCache->_this();
+  }
 }
index efce440a9198242b9403659cd434c98a68f62bbc..68a78fe67ec167319b646d68d1698bfc796cc44e 100644 (file)
@@ -36,6 +36,7 @@ namespace VISU
 {
   class Result_i;
   class ColoredPrs3d_i;
+  class ColoredPrs3dCache_i;
 
   bool
   CreatColoredPrs3d(ColoredPrs3d_i* theColoredPrs3d,
@@ -44,6 +45,19 @@ namespace VISU
                    const std::string& theFieldName, 
                    CORBA::Double theIteration);
 
+  template<typename TPrs3d_i> 
+  ColoredPrs3d_i*
+  CreatePrs3d_i(SALOMEDS::Study_ptr theStudy)
+  {
+    if(!theStudy->GetProperties()->IsLocked()){
+      typedef typename TPrs3d_i::TInterface TPrs3d;
+      if(TPrs3d_i* aPresent = new TPrs3d_i(NULL,ColoredPrs3d_i::EPublishIndependently)){
+       return aPresent;
+      }
+    }
+    return NULL;
+  }
+
   class VISU_Gen_i : public virtual POA_VISU::VISU_Gen,
                     public virtual ::Engines_Component_i,
                     public virtual Base_i
@@ -156,6 +170,10 @@ namespace VISU
              const char* theMeshName, 
              const char* theGroupName);
 
+    ColoredPrs3d_i*
+    CreatePrs3d_i(VISUType theType,
+                 SALOMEDS::Study_ptr theStudy);
+
     Prs3d_ptr
     CreatePrs3d(VISUType theType,
                SALOMEDS::Study_ptr theStudy);
@@ -394,6 +412,10 @@ namespace VISU
     PasteInto(const SALOMEDS::TMPFile& theStream,
              CORBA::Long theObjectID,
              SALOMEDS::SObject_ptr theObject);
+
+    virtual
+    VISU::ColoredPrs3dCache_ptr
+    GetColoredPrs3dCache(SALOMEDS::Study_ptr theStudy);
   };
 }
 
index c7718a4e3109cee71082eef116808626e480859b..6f1cc70aaa194e78842ccc33ef1aebe1dc88340f 100644 (file)
@@ -42,7 +42,7 @@ SWIG_DEF = libVISU_Swig.i
 EXPORT_PYSCRIPTS = libVISU_Swig.py batchmode_visu.py batchmode_visu_table.py batchmode_visu_view3d.py \
        visu_med.py visu_view3d.py visu.py visu_gui.py visu_prs_example.py \
        visu_table.py visu_big_table.py visu_view.py visu_delete.py \
-       visu_swig_test.py visu_split_views.py visu_change_input.py \
+       visu_swig_test.py visu_split_views.py visu_change_input.py visu_cache.py \
        VISU_Example_01.py VISU_Example_02.py VISU_Example_03.py VISU_Example_04.py \
        VISU_Example_05.py VISU_Example_06.py VISU_Example_07.py
 EXPORT_SHAREDPYSCRIPTS = VISU_shared_modules.py
diff --git a/src/VISU_SWIG/visu_cache.py b/src/VISU_SWIG/visu_cache.py
new file mode 100644 (file)
index 0000000..f123da2
--- /dev/null
@@ -0,0 +1,76 @@
+import os
+import time
+import VISU
+import SALOMEDS
+from batchmode_visu import *
+
+#---------------------------------------------------------------
+def WalkTroughTimeStamps(theVISUType,
+                         theInput,
+                         theViewManager):
+  aView = theViewManager.Create3DView();
+  aView.SetTitle("To test presentation of %s type" % theVISUType)
+
+  aCache = myVisu.GetColoredPrs3dCache(myVisu.GetCurrentStudy())
+  aHolder = aCache.CreateHolder(theVISUType, theInput)
+  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 "\ttheMeshName = '%s'" % theInput.myMeshName
+    print "\ttheEntity = %s" % theInput.myEntity
+    print "\ttheFieldName = '%s'" % theInput.myFieldName
+    print "\ttheTimeStampNumber = %s" % theInput.myTimeStampNumber
+    return
+
+  aView.FitAll()
+
+  aDelay = 0.0
+  aRange = aHolder.GetTimeStampsRange()
+  for anInfo in aRange:
+    print "%d (%s); " % (anInfo.myNumber, anInfo.myTime)
+    theInput.myTimeStampNumber = anInfo.myNumber
+    aHolder.Apply(aPrs3d, theInput, aView)
+    time.sleep(aDelay)
+    pass
+  pass
+
+#---------------------------------------------------------------
+PRS3D_TYPE_LIST = []
+#PRS3D_TYPE_LIST.append(VISU.TGAUSSPOINTS)
+PRS3D_TYPE_LIST.append(VISU.TSCALARMAP)
+PRS3D_TYPE_LIST.append(VISU.TISOSURFACE)
+PRS3D_TYPE_LIST.append(VISU.TCUTPLANES)
+PRS3D_TYPE_LIST.append(VISU.TCUTLINES)
+PRS3D_TYPE_LIST.append(VISU.TPLOT3D)
+PRS3D_TYPE_LIST.append(VISU.TDEFORMEDSHAPE)
+PRS3D_TYPE_LIST.append(VISU.TVECTORS)
+PRS3D_TYPE_LIST.append(VISU.TSTREAMLINES)
+PRS3D_TYPE_LIST.append(VISU.TSCALARMAPONDEFORMEDSHAPE)
+
+
+#---------------------------------------------------------------
+aMedFile = "TimeStamps.med"
+aMedFile = "ResOK_0000.med"
+aMedFile = os.getenv('DATA_DIR') + '/MedFiles/' + aMedFile
+aResult = myVisu.ImportFile(aMedFile)
+
+aMeshName ="dom"
+anEntity = VISU.NODE
+aFieldName = "vitesse";
+aTimeStampNumber = 1
+
+anInput = VISU.ColoredPrs3dHolder.BasicInput(aResult,aMeshName,anEntity,aFieldName,aTimeStampNumber);
+
+aViewManager = myVisu.GetViewManager();
+
+WalkTroughTimeStamps(VISU.TSCALARMAP, anInput, aViewManager)
+
+for aVISUType in PRS3D_TYPE_LIST:
+  WalkTroughTimeStamps(aVISUType, anInput, aViewManager)
+  pass
+
+anInput.myEntity = VISU.CELL;
+anInput.myFieldName = "pression";
+WalkTroughTimeStamps(VISU.TGAUSSPOINTS, anInput, aViewManager)