From: ouv Date: Wed, 22 Nov 2006 10:14:12 +0000 (+0000) Subject: Relation between slider and holder objects X-Git-Tag: WP1_2_3_05-12-2006_cache_system~74 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ba407ce74618165949412dc566bad6278b3fc10d;p=modules%2Fvisu.git Relation between slider and holder objects --- diff --git a/src/VISUGUI/VisuGUI_Slider.cxx b/src/VISUGUI/VisuGUI_Slider.cxx index 31464103..442078e9 100644 --- a/src/VISUGUI/VisuGUI_Slider.cxx +++ b/src/VISUGUI/VisuGUI_Slider.cxx @@ -28,14 +28,18 @@ #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 #include @@ -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 + (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(anActorCollection, SVTK::TIsSameIObject(anIter.Value())); - if( anActor ) - { - if( !anActor->GetVisibility() ) - continue; - - if( VISU::ColoredPrs3d_i* aPrs = dynamic_cast( 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(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::GetServant(anObject).in()); + + if( aHolder ) + { + VISU::ColoredPrs3d_i* aPrs = + dynamic_cast( VISU::GetServant(aHolder->GetDevice()).in() ); + + if( aPrs && !aPrs->IsTimeStampFixed() ) { + cout << "ColoredPrs3d" << endl; + myPrsList.resize(k+1); + myPrsList[k] = aPrs; + k++; + } + } + } } } } diff --git a/src/VISU_I/VISU_ColoredPrs3dCache_i.cc b/src/VISU_I/VISU_ColoredPrs3dCache_i.cc index 69bd3b51..ad632585 100644 --- a/src/VISU_I/VISU_ColoredPrs3dCache_i.cc +++ b/src/VISU_I/VISU_ColoredPrs3dCache_i.cc @@ -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 ); diff --git a/src/VISU_I/VISU_ColoredPrs3d_i.cc b/src/VISU_I/VISU_ColoredPrs3d_i.cc index fb9f3580..1f380d47 100644 --- a/src/VISU_I/VISU_ColoredPrs3d_i.cc +++ b/src/VISU_I/VISU_ColoredPrs3d_i.cc @@ -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 ); diff --git a/src/VISU_I/VISU_ColoredPrs3d_i.hh b/src/VISU_I/VISU_ColoredPrs3d_i.hh index 90bdee92..16c3d76f 100644 --- a/src/VISU_I/VISU_ColoredPrs3d_i.hh +++ b/src/VISU_I/VISU_ColoredPrs3d_i.hh @@ -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; diff --git a/src/VISU_I/VISU_PrsObject_i.hh b/src/VISU_I/VISU_PrsObject_i.hh index 4fc64ebd..781c6eb1 100644 --- a/src/VISU_I/VISU_PrsObject_i.hh +++ b/src/VISU_I/VISU_PrsObject_i.hh @@ -61,7 +61,9 @@ namespace VISU const SALOMEDS::Study_var& GetStudyDocument() const; - QString GetEntry(); + virtual + QString + GetEntry(); }; }