#include "VISU_PipeLine.hxx"
+#include "SALOME_Event.hxx"
+
#include "VTKViewer_Algorithm.h"
#include "SVTK_Functor.h"
::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);
::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 );
::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();
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
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)){
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;
}
}
#include "VISU_ColoredPrs3dCache_i.hh"
#include "VISU_ColoredPrs3d_i.hh"
+#include "SALOME_Event.hxx"
+
using namespace VISU;
using namespace std;
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
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);
}
//----------------------------------------------------------------------------
#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"
{
static std::string PREFIX(" ");
+ static std::string aResultName;
+
typedef std::map<std::string,std::string> TName2EntryMap;
typedef std::map<std::string,std::string> TEntry2NameMap;
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){
}
}
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))*/