Hello again,
I have a follow-up question concerning my attempts to create a
collaborative standalone client. The attached example connects to a
pvserver running on localhost (with --multi-clients option) and creates a
SphereSource together with its representation. Depending on whether
"USEVIEW" is defined or undefined in the beginning, also a RenderView is
created and shows the sphere.
The plan is that other clients can pick up and display the created
pipeline. Unfortunately this doesn't work if the example code doesn't
create a RenderView by itself. Maybe my understanding is wrong, but isn't
it sufficient if a client creates sources and their representations so that
other clients can display these in their views? Moreover, the behaviour
depends on the order in which the example client and the ParaView client
are started.
This is a more structured summary of the different test "modes":
If I compile the example with "USEVIEW" defined in the beginning,
a) Starting in the order pvserver->example->ParaView, ParaView reports
"This code may not work in multi-clients mode. Could not locate server on
which the source is being added." and shows the sphere in the renderer, but
not in the pipeline panel.
b) Starting in the order pvserver->ParaView->example, everything works as
expected.
If I undefine "USEVIEW" in the beginning, it is not quite running as
expected:
c) Starting in the order pvserver->example->ParaView, ParaView reports
"Could not locate server on which the source is being added." and shows
nothing.
d) Starting in the order pvserver->ParaView->example, ParaView shows "Sph1"
in the pipeline panel, but nothing in the renderer.
Why does the Sphere not show up in ParaView's pipeline panel in case a)?
Why does the Sphere show up in ParaView's pipeline panel, but not in the
renderer in case d)?
And what does "This code may not work in multi-clients mode" and "Could not
locate server on which the source is being added" exactly wnat to tell me?
If you could share any answers to one or more of these questions or suggest
what else to try, it'll be highly appreciated.
Peter
#include "vtkSMSession.h"
#include "vtkSMSessionClient.h"
#include "vtkProcessModule.h"
#include "vtkPVOptions.h"
#include "vtkInitializationHelper.h"
#include "vtkSMProxy.h"
#include "vtkSMProxyManager.h"
#include "vtkSMSessionProxyManager.h"
#include "vtkSMProxy.h"
#include "vtkSMPropertyHelper.h"
#include "vtkSMParaViewPipelineController.h"
#include "vtkSMProxy.h"
#include "vtkSMRepresentationProxy.h"
#include "vtkCollection.h"
#include "vtkSMRenderViewProxy.h"
#include "vtkSMCollaborationManager.h"
#include "vtkSMMessage.h"
#include "vtkCommand.h"
#include "vtkNetworkAccessManager.h"
#include "vtkRenderWindowInteractor.h"
#include <chrono>
#include <thread>
#define USEVIEW
//#undef USEVIEW
using namespace std;
class Callback: public vtkCommand{
private:
public:
static Callback* New(){
return new Callback;
}
virtual void Execute(vtkObject* caller, unsigned long event, void* data) {
while(vtkProcessModule::GetProcessModule()->GetNetworkAccessManager()->ProcessEvents(1)){
}
}
};
int main(int argc, char* argv[]){
vtkPVOptions *options=vtkPVOptions::New();
vtkInitializationHelper::Initialize(argc,argv,vtkProcessModule::PROCESS_CLIENT,options);
vtkSMSessionClient *session=vtkSMSessionClient::New();
session->Connect("cs://localhost:11111");
vtkSMParaViewPipelineController* smcontroller=vtkSMParaViewPipelineController::New();
smcontroller->InitializeSession(session);
vtkSMSessionProxyManager* pxm = session->GetSessionProxyManager();
//Collaboration:
vtkSMCollaborationManager *collaboration=session->GetCollaborationManager();
collaboration->SetSession(session);
collaboration->UpdateUserInformations();
collaboration->FollowUser(collaboration->GetMasterId());
vtkCollection *coll=vtkCollection::New();
vtkSMRenderViewProxy *view=NULL;
#ifdef USEVIEW
// try to find view
pxm->GetProxies("views",coll);
view=vtkSMRenderViewProxy::SafeDownCast(coll->GetItemAsObject(0));
// if not found, create new view
if (view==NULL){
view=vtkSMRenderViewProxy::SafeDownCast(pxm->NewProxy("views","RenderView"));
}
view->UpdateVTKObjects();
#endif
vtkSMSourceProxy *sphere=vtkSMSourceProxy::SafeDownCast(pxm->NewProxy("sources","SphereSource"));
sphere->UpdateVTKObjects();
//vtkSMRepresentationProxy *repr=view->CreateDefaultRepresentation(sphere,0);
vtkSMRepresentationProxy *repr=vtkSMRepresentationProxy::SafeDownCast(pxm->NewProxy("representations","SurfaceRepresentation"));
vtkSMPropertyHelper(repr,"Input").Set(sphere,0);
#ifdef USEVIEW
vtkSMPropertyHelper(view,"Representations").Add(repr);
view->UpdateVTKObjects();
#endif
repr->UpdateVTKObjects();
pxm->RegisterProxy("sources","Sph1",sphere);
pxm->RegisterProxy("representations","Repr1",repr);
#ifdef USEVIEW
pxm->RegisterProxy("views","View1",view);
view->MakeRenderWindowInteractor(true);
vtkRenderWindowInteractor *iren=view->GetInteractor();
iren->Initialize();
Callback *timer=Callback::New();
iren->AddObserver(vtkCommand::TimerEvent,timer);
iren->CreateRepeatingTimer(100);
view->GetInteractor()->Start();
#else
while(true){
while(vtkProcessModule::GetProcessModule()->GetNetworkAccessManager()->ProcessEvents(100));
}
#endif
cout<<"Closing Session..."<<endl;
session->CloseSession();
vtkInitializationHelper::Finalize();
}
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the ParaView Wiki at:
http://paraview.org/Wiki/ParaView
Search the list archives at: http://markmail.org/search/?q=ParaView
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/paraview