]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Relation between slider and holder objects
authorouv <ouv@opencascade.com>
Wed, 22 Nov 2006 10:14:12 +0000 (10:14 +0000)
committerouv <ouv@opencascade.com>
Wed, 22 Nov 2006 10:14:12 +0000 (10:14 +0000)
src/VISUGUI/VisuGUI_Slider.cxx
src/VISU_I/VISU_ColoredPrs3dCache_i.cc
src/VISU_I/VISU_ColoredPrs3d_i.cc
src/VISU_I/VISU_ColoredPrs3d_i.hh
src/VISU_I/VISU_PrsObject_i.hh

index 3146410335c661a8b00a6d533179bf4cd4baf3f4..442078e9b61961cc0e980f1ebdcb69cbf9d36720 100644 (file)
 #include "VisuGUI_Slider.h"
 
 #include "SUIT_ResourceMgr.h"
+#include "SUIT_Session.h"
+
+#include "SalomeApp_Application.h"
+#include "SalomeApp_Study.h"
 
 #include "LightApp_SelectionMgr.h"
 
+#include "SVTK_Functor.h"
 #include "SVTK_Renderer.h"
 #include "SVTK_RenderWindowInteractor.h"
 
 #include "VTKViewer_Algorithm.h"
-#include "SVTK_Functor.h"
 
 #include "SALOME_ListIteratorOfListIO.hxx"
 
@@ -45,6 +49,7 @@
 #include "VVTK_ViewWindow.h"
 
 #include "VISU_ColoredPrs3d_i.hh"
+#include "VISU_ColoredPrs3dHolder_i.hh"
 
 #include <vtkActorCollection.h>
 #include <vtkRenderer.h>
@@ -205,6 +210,10 @@ void VisuGUI_Slider::enableControls( bool on )
   {
     myTimeStampStrings->clear();
     myTimeStampIndices->clear();
+
+    if( myPrsList.size() == 0 )
+      return;
+
     VISU::ColoredPrs3d_i* aPrs = myPrsList[0];
 
     CORBA::Long aTimeStampNumber = aPrs->GetTimeStampNumber();
@@ -252,28 +261,41 @@ void VisuGUI_Slider::onSelectionChanged()
 {
   myPrsList.resize(0);
 
+  _PTR(SObject) aSObject;
+
+  SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>
+    (SUIT_Session::session()->activeApplication());
+
   SALOME_ListIO aListIO;
   mySelectionMgr->selectedObjects(aListIO);
-  SALOME_ListIteratorOfListIO anIter( aListIO );
-  vtkActorCollection* anActorCollection = myMainWindow->getRenderer()->GetActors();
+  SALOME_ListIteratorOfListIO anIter(aListIO);
   for( int k = 0; anIter.More(); anIter.Next() )
   {
-    VISU_Actor* anActor = 
-      SVTK::Find<VISU_Actor>(anActorCollection, SVTK::TIsSameIObject<VISU_Actor>(anIter.Value()));
-    if( anActor )
-    {
-      if( !anActor->GetVisibility() )
-       continue;
-
-      if( VISU::ColoredPrs3d_i* aPrs = dynamic_cast<VISU::ColoredPrs3d_i*>( anActor->GetPrs3d() ) )
-      {
-       if( !aPrs->IsTimeStampFixed() )
-       {
-         //cout << "ColoredPrs3d" << endl;
-         myPrsList.resize(k+1);
-         myPrsList[k] = aPrs;
-         k++;
-       }
+    Handle(SALOME_InteractiveObject) anIO = anIter.Value();
+    if (anIO->hasEntry()) {
+      SalomeApp_Study* theStudy = dynamic_cast<SalomeApp_Study*>(anApp->activeStudy());
+      _PTR(Study) aStudy = theStudy->studyDS();
+      aSObject = aStudy->FindObjectID(anIO->getEntry());
+
+      if (aSObject) {
+       CORBA::Object_var anObject = VISU::ClientSObjectToObject(aSObject);
+        if (!CORBA::is_nil(anObject)) {
+         VISU::ColoredPrs3dHolder_i* aHolder =
+           dynamic_cast<VISU::ColoredPrs3dHolder_i*>(VISU::GetServant(anObject).in());
+
+         if( aHolder )
+         {
+           VISU::ColoredPrs3d_i* aPrs =
+             dynamic_cast<VISU::ColoredPrs3d_i*>( VISU::GetServant(aHolder->GetDevice()).in() );
+
+           if( aPrs && !aPrs->IsTimeStampFixed() ) {
+             cout << "ColoredPrs3d" << endl;
+             myPrsList.resize(k+1);
+             myPrsList[k] = aPrs;
+             k++;
+           }
+         }
+        }
       }
     }
   }
index 69bd3b512e2bd2f60ad8250777c304a71d56e499..ad63258543254c18250019e3d911e3ee8dbf3ca0 100644 (file)
@@ -146,6 +146,7 @@ CreatePrs(VISU::VISUType theType,
          VISU::ColoredPrs3dHolder_i* theHolder)
 {
   VISU::ColoredPrs3d_i* aPrs3d = Base_i::GetVisuGenImpl()->CreatePrs3d_i(theType, GetStudyDocument());
+  aPrs3d->SetHolderEntry( theHolder->GetEntry() );
   aPrs3d->SetResultObject( theInput.myResult );  
   aPrs3d->SetMeshName( theInput.myMeshName );  
   aPrs3d->SetEntity( theInput.myEntity );  
index fb9f3580a67c0567e33bdd9552973fd17eca85b9..1f380d471ea0b8ba83847764b57d6f82a82ba60a 100644 (file)
@@ -357,6 +357,16 @@ VISU::ColoredPrs3d_i
   return aBasicInput;
 }
 
+QString
+VISU::ColoredPrs3d_i
+::GetEntry()
+{
+  if( !myHolderEntry.isEmpty() )
+    return myHolderEntry;
+
+  return TSuperClass::GetEntry();
+}
+
 //----------------------------------------------------------------------------
 CORBA::Boolean 
 VISU::ColoredPrs3d_i
@@ -964,6 +974,8 @@ VISU::ColoredPrs3d_i
   myIsTimeStampFixed = VISU::Storable::FindValue(theMap,"myIsTimeStampFixed").toInt();
   OnSetInput();
 
+  SetHolderEntry(VISU::Storable::FindValue(theMap,"myHolderEntry").latin1());
+
   Build(ERestore);
 
   TSuperClass::Restore(theMap);
@@ -1010,6 +1022,8 @@ VISU::ColoredPrs3d_i
   Storable::DataToStream( theStr, "myIteration",      int(GetTimeStampNumber()) );
   Storable::DataToStream( theStr, "myIsTimeStampFixed", int(myIsTimeStampFixed) );
 
+  Storable::DataToStream( theStr, "myHolderEntry",    myHolderEntry );
+
   Storable::DataToStream( theStr, "myScalarMode",     int(GetScalarMode()) );
   Storable::DataToStream( theStr, "myNumberOfColors", int(GetNbColors()) );
   Storable::DataToStream( theStr, "myOrientation",    myOrientation );
index 90bdee9238a6652ff9dfa6b47f6bb6511870d9fd..16c3d76f806ed2a80807be594378309c695ed3b2 100644 (file)
@@ -224,6 +224,13 @@ namespace VISU
     VISU::ColoredPrs3dHolder::BasicInput*
     GetBasicInput();
 
+    virtual
+    void
+    SetHolderEntry( const QString& theEntry ) { myHolderEntry = theEntry; }
+
+    virtual
+    QString
+    GetEntry();
     //----------------------------------------------------------------------------
   public:
     /*!
@@ -432,6 +439,8 @@ namespace VISU
     PField myField;
     EPublishInStudyMode myPublishInStudyMode;
 
+    QString myHolderEntry;
+
     std::string myTitle;
     std::string myScalarBarTitle;
 
index 4fc64ebde157c991cd7bd063ffc5ace12681690b..781c6eb1a0f33f992c9455c2e80661416841cf75 100644 (file)
@@ -61,7 +61,9 @@ namespace VISU
     const SALOMEDS::Study_var& 
     GetStudyDocument() const;
 
-    QString GetEntry();
+    virtual
+    QString
+    GetEntry();
   };
 }