Hello,
I have attached a short custom client example which I would like to always
show the same perspective as a ParaView session connected to the same
pvserver.
However, although this example renders once the objects that are available
in the ParaView session, it does not update itself when the camera is
changed in ParaView, despite of the line
"collaboration->FollowUser(collaboration->GetMasterId());" (see attached
code).
Apparently I am missing one important step, maybe register the view with
some proxymanager, call some *::AddObserver(...) or something similar? I
don't know and couldn't find out after several attempts to understand
ParaView with the help of a debugger.
As a side note: collaboration in the other direction runs successfully. If
I choose ParaView to follow this custom client by double-clicking on the
eye symbol in the collaboration panel, then the ParaView view always
displays the same perspective as the custom client.
Which are the missing steps to have the client update its view, when the
(master) ParaView camera changes?
Steps to reproduce:
+ compile attached main.cxx
+ run "pvserver --multi-clients &"
+ run "paraview --server-url=cs://localhost:11111 &"
+ create a simple pipeline in paraview
+ run "./main" -> same pipeline as in paraview is rendered in custom client
+ interact with view in ParaView -> client view does not update although it
is expected to follow the master
Peter
project(myClient)
add_definitions(-std=c++11)
FIND_PACKAGE(ParaView REQUIRED)
INCLUDE( ${PARAVIEW_USE_FILE})
add_executable(main main.cxx)
target_link_libraries(main ${VTK_LIBRARIES})
#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 "vtkCollection.h"
#include "vtkSMRenderViewProxy.h"
#include "vtkSMCollaborationManager.h"
#include "vtkSMMessage.h"
#include "vtkCommand.h"
#include "vtkNetworkAccessManager.h"
#include "vtkRenderWindowInteractor.h"
using namespace std;
class Callback: public vtkCommand{
private:
long id;
vtkRenderWindowInteractor *iren=NULL;
public:
static Callback* New(){
return new Callback;
}
virtual void Execute(vtkObject* caller, unsigned long event, void* data) {
vtkSMMessage* msg = reinterpret_cast<vtkSMMessage*>(data);
if (id!=vtkCommand::TimerEvent)
cout<<"Message: #"<<id<<" "<<msg<<endl;
int k;
for(k=0;vtkProcessModule::GetProcessModule()->GetNetworkAccessManager()->ProcessEvents(1);k++){
}
if (k>0) cout<<"#events: "<<k<<endl;
if (iren!=NULL){
iren->Render();
}
}
void SetEventId(long id){
this->id=id;
}
void SetIren(vtkRenderWindowInteractor *iren){
this->iren=iren;
}
};
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=vtkSMCollaborationManager::New();
collaboration->SetSession(session);
collaboration->UpdateUserInformations();
Callback *feedback;
for (long evt=vtkSMCollaborationManager::CollaborationNotification; evt<vtkSMCollaborationManager::CameraChanged;evt++){
feedback=Callback::New();
feedback->SetEventId(evt);
collaboration->AddObserver( evt, feedback);
}
Callback *sessionchanged=Callback::New();
sessionchanged->SetEventId(vtkSMProxyManager::ActiveSessionChanged);
vtkSMProxyManager::GetProxyManager()->AddObserver(vtkSMProxyManager::ActiveSessionChanged,sessionchanged);
collaboration->AddObserver(vtkSMProxyManager::ActiveSessionChanged,sessionchanged);
collaboration->FollowUser(collaboration->GetMasterId()); //expected to make camera updates at the master available to this client.
vtkCollection *coll=vtkCollection::New();
pxm->GetProxies("views",coll);
vtkSMRenderViewProxy *view=vtkSMRenderViewProxy::SafeDownCast(coll->GetItemAsObject(0));
if (view!=NULL){
view->MakeRenderWindowInteractor(false);
vtkRenderWindowInteractor *iren=view->GetInteractor();
iren->Initialize();
Callback *timer=Callback::New();
timer->SetIren(iren);
timer->SetEventId(vtkCommand::TimerEvent);
iren->AddObserver(vtkCommand::TimerEvent,timer);
iren->CreateRepeatingTimer(100);
view->GetInteractor()->Start();
}
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