From 50f12acad4771f987b28a288169e67b79d75839d Mon Sep 17 00:00:00 2001 From: ouv Date: Tue, 21 Nov 2006 12:20:05 +0000 Subject: [PATCH] Publishing Cache and Holder objects in study --- idl/VISU_Gen.idl | 2 +- src/VISUGUI/VisuGUI.cxx | 16 ++++- src/VISUGUI/VisuGUI_Displayer.cxx | 21 +++++-- src/VISUGUI/VisuGUI_Prs3dTools.h | 2 +- src/VISUGUI/VisuGUI_Tools.cxx | 11 +++- src/VISU_I/VISU_ColoredPrs3dCache_i.cc | 81 +++++++++++++++++++------ src/VISU_I/VISU_ColoredPrs3dCache_i.hh | 37 ++++++++--- src/VISU_I/VISU_ColoredPrs3dHolder_i.cc | 11 +--- src/VISU_I/VISU_Gen_i.cc | 38 +++++++++++- src/VISU_I/VISU_Gen_i.hh | 18 ++++++ src/VISU_SWIG/visu_cache.py | 14 ++++- 11 files changed, 200 insertions(+), 51 deletions(-) diff --git a/idl/VISU_Gen.idl b/idl/VISU_Gen.idl index ad9aa149..310b95af 100644 --- a/idl/VISU_Gen.idl +++ b/idl/VISU_Gen.idl @@ -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. diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 5500c4d6..1b5463e1 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -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::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::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'"; diff --git a/src/VISUGUI/VisuGUI_Displayer.cxx b/src/VISUGUI/VisuGUI_Displayer.cxx index 46fd0922..79a50235 100644 --- a/src/VISUGUI/VisuGUI_Displayer.cxx +++ b/src/VISUGUI/VisuGUI_Displayer.cxx @@ -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( vtk_viewer->getViewManager()->getActiveView() ); if( wnd ) { - VISU::Prs3d_i* thePrs = dynamic_cast( VISU::GetServant( anObj ).in() ); + VISU::Prs3d_i* thePrs; + VISU::Base_i* aBase = dynamic_cast(VISU::GetServant(anObj).in()); + if(aBase->GetType() == VISU::TCOLOREDPRS3DHOLDER) + { + VISU::ColoredPrs3dHolder_i* aHolder = dynamic_cast( aBase ); + thePrs = dynamic_cast( VISU::GetServant(aHolder->GetDevice()).in() ); + } + else + thePrs = dynamic_cast( 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::GetServant( anObj ).in() ); - return thePrs; + VISU::Base_i* aBase = dynamic_cast(VISU::GetServant(anObj).in()); + if(aBase->GetType() == VISU::TCOLOREDPRS3DHOLDER) + return dynamic_cast(aBase); + + return dynamic_cast(aBase); } else if( viewer_type==SPlot2d_Viewer::Type() ) { diff --git a/src/VISUGUI/VisuGUI_Prs3dTools.h b/src/VISUGUI/VisuGUI_Prs3dTools.h index 4de65344..ebdf2129 100644 --- a/src/VISUGUI/VisuGUI_Prs3dTools.h +++ b/src/VISUGUI/VisuGUI_Prs3dTools.h @@ -93,7 +93,7 @@ namespace VISU false ); // in edition mode QApplication::restoreOverrideCursor(); } - RestoreSelection(theModule, thePrs3d); + RestoreSelection(theModule, NULL/*thePrs3d*/); delete aDlg; } } diff --git a/src/VISUGUI/VisuGUI_Tools.cxx b/src/VISUGUI/VisuGUI_Tools.cxx index 1b307d20..926bf608 100644 --- a/src/VISUGUI/VisuGUI_Tools.cxx +++ b/src/VISUGUI/VisuGUI_Tools.cxx @@ -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(aServant.in()); + VISU::Base_i* aBase = dynamic_cast(aServant.in()); + if(aBase->GetType() == VISU::TCOLOREDPRS3DHOLDER) + { + VISU::ColoredPrs3dHolder_i* aHolder = dynamic_cast(aBase); + return dynamic_cast(VISU::GetServant(aHolder->GetDevice()).in()); + } + + return dynamic_cast(aBase); } void diff --git a/src/VISU_I/VISU_ColoredPrs3dCache_i.cc b/src/VISU_I/VISU_ColoredPrs3dCache_i.cc index 3fbf6f25..69bd3b51 100644 --- a/src/VISU_I/VISU_ColoredPrs3dCache_i.cc +++ b/src/VISU_I/VISU_ColoredPrs3dCache_i.cc @@ -26,11 +26,23 @@ #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 = "<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::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; diff --git a/src/VISU_I/VISU_ColoredPrs3dCache_i.hh b/src/VISU_I/VISU_ColoredPrs3dCache_i.hh index d3183efe..0abd10bb 100644 --- a/src/VISU_I/VISU_ColoredPrs3dCache_i.hh +++ b/src/VISU_I/VISU_ColoredPrs3dCache_i.hh @@ -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; }; } diff --git a/src/VISU_I/VISU_ColoredPrs3dHolder_i.cc b/src/VISU_I/VISU_ColoredPrs3dHolder_i.cc index 446299f0..0e295ddb 100644 --- a/src/VISU_I/VISU_ColoredPrs3dHolder_i.cc +++ b/src/VISU_I/VISU_ColoredPrs3dHolder_i.cc @@ -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); } diff --git a/src/VISU_I/VISU_Gen_i.cc b/src/VISU_I/VISU_Gen_i.cc index d5f296ed..bf48e73e 100644 --- a/src/VISU_I/VISU_Gen_i.cc +++ b/src/VISU_I/VISU_Gen_i.cc @@ -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(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(); } } diff --git a/src/VISU_I/VISU_Gen_i.hh b/src/VISU_I/VISU_Gen_i.hh index 68a78fe6..a1f97108 100644 --- a/src/VISU_I/VISU_Gen_i.hh +++ b/src/VISU_I/VISU_Gen_i.hh @@ -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 TPrs3d_i* CreatePrs3d(Result_ptr theResult, @@ -196,6 +205,15 @@ namespace VISU if(Result_i* aResult = dynamic_cast(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(aPrs3d); + } + if(CreatColoredPrs3d(aPresent,theMeshName,theEntity,theFieldName,theIteration)) return aPresent; aPresent->_remove_ref(); diff --git a/src/VISU_SWIG/visu_cache.py b/src/VISU_SWIG/visu_cache.py index f123da20..cc90e55d 100644 --- a/src/VISU_SWIG/visu_cache.py +++ b/src/VISU_SWIG/visu_cache.py @@ -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) -- 2.39.2