]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
DumpPytnon T_before_integration_15-01-2007
authorouv <ouv@opencascade.com>
Fri, 12 Jan 2007 15:24:56 +0000 (15:24 +0000)
committerouv <ouv@opencascade.com>
Fri, 12 Jan 2007 15:24:56 +0000 (15:24 +0000)
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_DumpPython.cc

index 07fbb5bff2dd71128e02fc069424dafb32740ee3..9d285a702c3249f2426ed74baef55f70db08e2b5 100644 (file)
@@ -35,6 +35,8 @@
 
 #include "VISU_PipeLine.hxx"
 
+#include "SALOME_Event.hxx"
+
 #include "VTKViewer_Algorithm.h"
 #include "SVTK_Functor.h"
 
@@ -386,6 +388,7 @@ VISU::ColoredPrs3dCache_i
 ::CreateHolder(VISU::VISUType theType,
               const VISU::ColoredPrs3dHolder::BasicInput& theInput)
 {
+  if(MYDEBUG) cout << "CreateHolder " << theType << endl;
   CORBA::Float aRequiredMemory = 0.0;
   if(IsPossible(theType, theInput, aRequiredMemory, "")){
     VISU::ColoredPrs3dHolder_i* aHolder = new VISU::ColoredPrs3dHolder_i(*this);
@@ -491,6 +494,7 @@ VISU::ColoredPrs3dCache_i
 ::RegisterInHolder(VISU::ColoredPrs3d_i* thePrs3d,
                   const std::string& theHolderEntry)
 {
+  if(MYDEBUG) cout << "RegisterInHolder " << theHolderEntry.c_str() << " " << thePrs3d << endl;
   TPrs3dPtr aPrs3d(thePrs3d);
   myHolderMap[theHolderEntry].push_front(aPrs3d);  
   thePrs3d->SetHolderEntry( theHolderEntry );
@@ -526,6 +530,7 @@ VISU::ColoredPrs3dCache_i
 ::GetLastVisitedPrs(VISU::ColoredPrs3dHolder_i* theHolder)
 {
   const TLastVisitedPrsList& aList = GetLastVisitedPrsList(theHolder);
+  if(MYDEBUG) cout << "GetLastVisitedPrs " << theHolder->GetEntry().c_str() << " " << aList.size() << endl;
   if( !aList.empty() )
     return aList.front();
   return VISU::TPrs3dPtr();
@@ -551,6 +556,53 @@ VISU::ColoredPrs3dCache_i
   return VISU::TPrs3dPtr();
 }
 
+struct TFindActorEvent: public SALOME_Event
+{
+  VISU::TPrs3dPtr myPrs3d;
+  SVTK_ViewWindow* myViewWindow;
+
+  typedef VISU_Actor* TResult;
+  TResult myResult;
+
+  TFindActorEvent(VISU::TPrs3dPtr thePrs3d, SVTK_ViewWindow* theViewWindow):
+    myPrs3d(thePrs3d),
+    myViewWindow(theViewWindow),
+    myResult(NULL)
+  {}
+
+  virtual
+  void
+  Execute()
+  {
+    myResult = VISU::FindActor(myViewWindow, myPrs3d);
+  }
+};
+
+struct TAddActorEvent: public SALOME_Event
+{
+  VISU_Actor* myActor;
+  SVTK_ViewWindow* myViewWindow;
+public:
+  TAddActorEvent(VISU_Actor* theActor, SVTK_ViewWindow* theViewWindow):
+    myActor(theActor),
+    myViewWindow(theViewWindow)
+  {}
+  virtual void Execute(){
+    myViewWindow->AddActor(myActor);
+  }
+};
+
+struct TRenderEvent: public SALOME_Event
+{
+  SVTK_ViewWindow* myViewWindow;
+public:
+  TRenderEvent(SVTK_ViewWindow* theViewWindow):
+    myViewWindow(theViewWindow)
+  {}
+  virtual void Execute(){
+    myViewWindow->getRenderWindow()->Render();
+  }
+};
 
 //----------------------------------------------------------------------------
 bool
@@ -563,12 +615,12 @@ VISU::ColoredPrs3dCache_i
   if(MYDEBUG) cout << "VISU::ColoredPrs3dCache_i::UpdateLastVisitedPrs" << endl;
   TPrs3dPtr aLastVisitedPrs3d = GetLastVisitedPrs(theHolder);
   TLastVisitedPrsList& aLastVisitedPrsList = GetLastVisitedPrsList(theHolder);
-  TPrs3dPtr aPrs3d = FindPrsByInput(aLastVisitedPrsList, theInput);
+  TPrs3dPtr aPrs3d;
   bool anIsCheckPossible = GetMemoryMode() == VISU::ColoredPrs3dCache::LIMITED;
   std::string aHolderEntry = theHolder->GetEntry();
   VISU::VISUType aPrsType = theHolder->GetPrsType();
   CORBA::Float aRequiredMemory = 0.0;
-  if(aPrs3d){
+  if(aPrs3d = FindPrsByInput(aLastVisitedPrsList, theInput)){
     aLastVisitedPrsList.push_front(aPrs3d);
     if(MYDEBUG) cout << "FindPrsByInput " << aPrs3d << endl;
   }else if(anIsCheckPossible && IsPossible(aPrsType, theInput, aRequiredMemory, aHolderEntry)){
@@ -597,28 +649,43 @@ VISU::ColoredPrs3dCache_i
       if(SUIT_ViewWindow* aView = aView3d->GetViewWindow()){
        if(SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(aView)){
          // Find actor that corresponds to the holder
-         VISU_Actor* anActor = VISU::FindActor(aViewWindow, aLastVisitedPrs3d);
+         VISU_Actor* anActor = ProcessEvent(new TFindActorEvent(aLastVisitedPrs3d,aViewWindow));
+         //VISU_Actor* anActor = VISU::FindActor(aViewWindow, aLastVisitedPrs3d);
 
          // If the holder was erased from view then do nothing
-         if(!anActor || !anActor->GetVisibility())
+         if(anActor && !anActor->GetVisibility())
            return true;
 
-         if(aPrs3d != aLastVisitedPrs3d){
+         if(!anActor)
+         {
+           anActor = aLastVisitedPrs3d->CreateActor();
+           ProcessVoidEvent(new TAddActorEvent(anActor,aViewWindow));
+           //aViewWindow->AddActor(anActor);
+           anActor->SetVisibility(true);
+         }
+
+         if(aPrs3d != aLastVisitedPrs3d)
+         {
            // To erase non active presentation
            aLastVisitedPrs3d->SetActiveState(false);
-           anActor->SetVisibility(false);
+           if(anActor)
+             anActor->SetVisibility(false);
+
            // To find the new one that corresponds to fresh presentation
-           VISU_Actor* aNewActor = VISU::FindActor(aViewWindow, aPrs3d);
+           VISU_Actor* aNewActor = ProcessEvent(new TFindActorEvent(aPrs3d,aViewWindow));
+           //VISU_Actor* aNewActor = VISU::FindActor(aViewWindow, aPrs3d);
            if(!aNewActor){
              aNewActor = aPrs3d->CreateActor();
-             aViewWindow->AddActor(aNewActor);
+             ProcessVoidEvent(new TAddActorEvent(aNewActor,aViewWindow));
+             //aViewWindow->AddActor(aNewActor);
            }else
              aNewActor->SetVisibility(true);
            aNewActor->DeepCopy(anActor);
+
            aPrs3d->SetActiveState(true);
-           //aLastVisitedPrs3d->RemoveActors();
          }
-         aViewWindow->getRenderWindow()->Render();
+         ProcessVoidEvent(new TRenderEvent(aViewWindow));
+         //aViewWindow->getRenderWindow()->Render();
          return true;
        }
       }
index 56ab4a22005ef6fe193a3c27c0d56dc2f2bc0ce1..8017b59bfb163674a3b0c54d74233e355f0ab2d5 100644 (file)
@@ -240,6 +240,9 @@ namespace VISU
     void
     RemoveHolder(VISU::ColoredPrs3dHolder_i* theHolder);
 
+    TColoredPrs3dHolderMap
+    GetHolderMap() { return myHolderMap; }
+
   public:
     static const std::string myComment;
 
index 32b2bc394d8670bf4c1b1150ad54799c88db913a..cefa3e487f3f44c7995be23fe3b48512b5deac63 100644 (file)
@@ -29,6 +29,8 @@
 #include "VISU_ColoredPrs3dCache_i.hh"
 #include "VISU_ColoredPrs3d_i.hh"
 
+#include "SALOME_Event.hxx"
+
 using namespace VISU;
 using namespace std;
 
@@ -90,6 +92,38 @@ VISU::ColoredPrs3dHolder_i
   CreateAttributes(GetStudyDocument(), aFatherEntry, "", anIOR.in(), GetName(), "", theComment, true);
 }
 
+//----------------------------------------------------------------------------
+struct TApplyEvent: public SALOME_Event
+{
+  VISU::ColoredPrs3dCache_i& myCache;
+  VISU::ColoredPrs3dHolder_i* myHolder;
+  VISU::ColoredPrs3d_i* myPrs3d;
+  VISU::ColoredPrs3dHolder::BasicInput myInput;
+  VISU::View3D_ptr myView3D;
+
+  typedef CORBA::Boolean TResult;
+  TResult myResult;
+
+  TApplyEvent(VISU::ColoredPrs3dCache_i& theCache,
+             VISU::ColoredPrs3dHolder_i* theHolder,
+             VISU::ColoredPrs3d_i* thePrs3d,
+             VISU::ColoredPrs3dHolder::BasicInput theInput,
+             VISU::View3D_ptr theView3D):
+    myCache(theCache),
+    myHolder(theHolder),
+    myPrs3d(thePrs3d),
+    myInput(theInput),
+    myView3D(theView3D)
+  {}
+
+  virtual
+  void
+  Execute()
+  {
+    myResult = myCache.UpdateLastVisitedPrs(myHolder, myPrs3d, myInput, myView3D);
+  }
+};
+
 //----------------------------------------------------------------------------
 CORBA::Boolean 
 VISU::ColoredPrs3dHolder_i
@@ -97,8 +131,10 @@ VISU::ColoredPrs3dHolder_i
        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);
+  return ProcessEvent(new TApplyEvent(myCache, this, aPrs3d, theInput, theView3D));
+  //return myCache.UpdateLastVisitedPrs(this, aPrs3d, theInput, theView3D);
 }
 
 //----------------------------------------------------------------------------
index fe78c72aa1473e5cfa9a9dbdbbacec7010620159..c2e892a052de80344021c2b66cd82bcc203a5484 100644 (file)
@@ -41,6 +41,8 @@
 #include "VISU_Table_i.hh"
 #include "VISU_GaussPoints_i.hh"
 #include "VISU_ScalarMapOnDeformedShape_i.hh"
+#include "VISU_ColoredPrs3dCache_i.hh"
+#include "VISU_ColoredPrs3dHolder_i.hh"
 
 #include "utilities.h"
 
@@ -59,6 +61,8 @@ namespace VISU
 {
   static std::string PREFIX("  ");
 
+  static std::string aResultName;
+
   typedef std::map<std::string,std::string> TName2EntryMap;
   typedef std::map<std::string,std::string> TEntry2NameMap;
 
@@ -526,6 +530,7 @@ namespace VISU
         switch(aType){
         case VISU::TRESULT:
           if(Result_i* aServant = dynamic_cast<Result_i*>(GetServant(anObj).in())){
+           aResultName = aName;
            std::string aFileName = aServant->GetFileName();
            Result_i::ECreationId anId = aServant->GetCreationId();
            if(anId == Result_i::eImportFile || anId == Result_i::eCopyAndImportFile){
@@ -1096,6 +1101,36 @@ namespace VISU
            }
           }
           return;
+        case VISU::TCOLOREDPRS3DCACHE:
+          if(ColoredPrs3dCache_i* aServant = dynamic_cast<ColoredPrs3dCache_i*>(GetServant(anObj).in())){
+           theStr<<thePrefix<<"aCache = aVisu.GetColoredPrs3dCache(aVisu.GetCurrentStudy())"<<endl<<endl;
+           TColoredPrs3dHolderMap aHolderMap = aServant->GetHolderMap();
+           TColoredPrs3dHolderMap::const_iterator aHolderIter = aHolderMap.begin();
+           TColoredPrs3dHolderMap::const_iterator aHolderIterEnd = aHolderMap.end();
+           for(; aHolderIter != aHolderIterEnd; aHolderIter++){
+             const TLastVisitedPrsList& aPrsList = aHolderIter->second;
+             if(TPrs3dPtr aPrs3d = aPrsList.front())
+             {
+               ColoredPrs3dHolder::BasicInput_var anInput = aPrs3d->GetBasicInput();
+
+               std::string anEntity;
+               switch(anInput->myEntity){
+                 case VISU::NODE : anEntity = "VISU.NODE"; break;
+                 case VISU::EDGE : anEntity = "VISU.EDGE"; break;
+                 case VISU::FACE : anEntity = "VISU.FACE"; break;
+                 case VISU::CELL : anEntity = "VISU.CELL"; break;
+               }
+
+               theStr<<thePrefix<<"anInput = VISU.ColoredPrs3dHolder.BasicInput("<<aResultName<<",'"<<
+                 anInput->myMeshName<<"',"<<anEntity<<",'"<<
+                 anInput->myFieldName<<"',"<<anInput->myTimeStampNumber<<")"<<endl;
+
+               std::string aType = aPrs3d->GetComment();
+               theStr<<thePrefix<<"aHolder = aCache.CreateHolder(VISU.T"<<aType<<",anInput)"<<endl<<endl;
+             }
+           }
+          }
+          return;
        }
       }
     } else { /*if(!CORBA::is_nil(anObj))*/