<div dir="ltr"><div><div><div><div><div>Thank you!<br></div>Your example runs fine. The controller's sources also helped me to sort out what was missing in my example, and what you meant by adding the representation to the corresponding property of the view. Basically I missed two calls "vtkSMPropertyHelper(repr, "Input").Set(sphere, 0);" and "vtkSMPropertyHelper(view, "Representations").Add(repr);" and a few "UpdateVTKObjects()."<br></div>I include my working example below, and I think we can consider my question solved :)<br><br></div>By the way, is it ok to ask this kind of questions on the developers list? I tried some other paraview coding years ago and didn't get any reply on the users mailing list.<br><br></div><div>Thanks<br></div>Peter<br><br></div>my working solution:<br><br><div class="gmail_extra">#include "vtkInitializationHelper.h"<br>#include "vtkProcessModule.h"<br>#include "vtkPVOptions.h"<br>#include "vtkSMProxyManager.h"<br>#include "vtkSMSession.h"<br>#include "vtkSMSessionClient.h"<br>#include "vtkSMSessionProxyManager.h"<br>#include "vtkSMSourceProxy.h"<br>#include "vtkSMProperty.h"<br>#include "vtkSMRenderViewProxy.h"<br><br>#include "vtkRenderWindow.h"<br>#include "vtkRenderWindowInteractor.h"<br><br>#include "vtkSMRepresentationProxy.h"<br>#include "vtkSMPropertyHelper.h"<br><br>int main(int argc, char* argv[])<br>{<br>  // Initialization<br>  vtkPVOptions* options = vtkPVOptions::New();<br>  vtkInitializationHelper::Initialize(argc, argv,<br>                                      vtkProcessModule::PROCESS_CLIENT,<br>                                      options);<br><br>  vtkSMSessionClient* session = vtkSMSessionClient::New();<br>  vtkProcessModule::GetProcessModule()->RegisterSession(session);<br>  session->Connect(options->GetServerURL());<br>  cout<<"Connected to: "<<options->GetServerURL()<<endl;<br><br>  vtkSMSessionProxyManager *pxm = session->GetSessionProxyManager();<br>  vtkSMProxy *sphere = pxm->NewProxy("sources", "SphereSource");<br>  sphere->UpdateVTKObjects();<br>  cout<<"SphereSource created."<<endl;<br>  vtkSMRenderViewProxy* view=(vtkSMRenderViewProxy*)pxm->NewProxy("views", "RenderView");<br>  bool ok=view->MakeRenderWindowInteractor(false);<br>  cout<<"RenderView created. "<<ok<<endl;<br>  vtkSMRepresentationProxy* repr=view->CreateDefaultRepresentation(sphere,0);<br>  cout<<"DefaultRepresentation created."<<endl;<br><br>  vtkSMPropertyHelper(repr, "Input").Set(sphere, 0);<br>  vtkSMPropertyHelper(view, "Representations").Add(repr);<br>  repr->UpdateVTKObjects();<br>  view->UpdateVTKObjects();<br><br>  view->GetInteractor()->Initialize();<br>  view->GetInteractor()->Start();<br><br>  //TODO: clean up stuff<br>}<br><br><br><div class="gmail_quote">On Thu, Apr 21, 2016 at 4:49 PM, Utkarsh Ayachit <span dir="ltr"><<a href="mailto:utkarsh.ayachit@kitware.com" target="_blank">utkarsh.ayachit@kitware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Peter,<br>
<br>
Here's an example:<br>
<br>
<a href="https://gitlab.kitware.com/paraview/paraview/merge_requests/747/diffs" rel="noreferrer" target="_blank">https://gitlab.kitware.com/paraview/paraview/merge_requests/747/diffs</a><br>
<span class=""><font color="#888888"><br>
Utkarsh<br>
</font></span><div class=""><div class="h5"><br>
On Thu, Apr 21, 2016 at 9:57 AM, Peter Vogt <<a href="mailto:vogtpeter5@gmail.com">vogtpeter5@gmail.com</a>> wrote:<br>
> Thank you, Utkarsh,<br>
> the time for writing our last posts has overlapped. I had fixed the missing<br>
> UpdateVTKObjects() call in between, and I think the only missing step is to<br>
> add the sphere's representation to the view proxy.<br>
> But how do I add it to the Representations "property"? Neither<br>
> vtkSMViewProxy nor vtkSMRenderViewProxy have a method like<br>
> GetRepresentations() or InsertRepresentation(). Getting this final step<br>
> right will certainly help me understand the programming principle.<br>
><br>
> If the vtkSMParaViewPipleineControllerWithRendering is the recommended way<br>
> of remotely rendering objects, I'll definitely appreciate an example using<br>
> this class, if it doesn't cost you too much time.<br>
><br>
> Thanks<br>
> Peter<br>
><br>
><br>
> On Thu, Apr 21, 2016 at 3:42 PM, Utkarsh Ayachit<br>
> <<a href="mailto:utkarsh.ayachit@kitware.com">utkarsh.ayachit@kitware.com</a>> wrote:<br>
>><br>
>> Peter,<br>
>><br>
>> After a proxy is created or after any of its properties are changed,<br>
>> one must call "vtkSMProxy::UpdateVTKObject()" to push the changes made<br>
>> locally to the server or the underlying VTK objects. Try putting a<br>
>> call to this method the NewProxy(...) calls. You're also missing<br>
>> adding the Sphere source's representation to the View proxy's<br>
>> "Representations" property. Other option is to use the<br>
>> vtkSMParaViewPipleineControllerWithRendering.<br>
>><br>
>> Give me a few hours, and I can put together an example that uses the<br>
>> controller to create a view and show something in it to get you<br>
>> started.<br>
>><br>
>> Utkarsh<br>
>><br>
>><br>
>><br>
>> On Thu, Apr 21, 2016 at 8:49 AM, Peter Vogt <<a href="mailto:vogtpeter5@gmail.com">vogtpeter5@gmail.com</a>> wrote:<br>
>> > Hello again,<br>
>> > thanks to your help, I was able to establish a connection to a pvserver<br>
>> > and<br>
>> > create a SphereSource proxy. Now I cannot figure out how to view the<br>
>> > rendered scene on the client.<br>
>> ><br>
>> > My attempt, "TestConnection.cxx", is attached below. I have tried three<br>
>> > alternatives, which I have marked in the code:<br>
>> > Alternative 1 calls "view->StillRender()", which shows the greyish<br>
>> > background, maybe because the sphere is outside the viewport?<br>
>> > Alternative 2 calls "view->ResetCamera()" before the StillRender(), but<br>
>> > ResetCamera crashes with the following output:<br>
>> >>ERROR: In<br>
>> >><br>
>> >> /opt/ParaView-v5.0.1-source/ParaViewCore/ServerImplementation/Core/vtkPVSessionCoreInterpreterHelper.cxx,<br>
>> >> line 63<br>
>> >>vtkPVSessionCoreInterpreterHelper (0x976950): No vtkSIProxy for id : 257<br>
>> >><br>
>> >>ERROR: In<br>
>> >><br>
>> >> /opt/ParaView-v5.0.1-source/ParaViewCore/ServerImplementation/Core/vtkPVSessionCore.cxx,<br>
>> >> line 390<br>
>> >>vtkPVSessionCore (0x8ca480): Wrapper function not found for class "(vtk<br>
>> >> object is NULL)".<br>
>> >>while processing<br>
>> >>Message 0 = Invoke<br>
>> >>  Argument 0 = stream_value {<br>
>> >>    Message 0 = Invoke<br>
>> >>      Argument 0 = id_value {1}<br>
>> >>      Argument 1 = string_value {GetVTKObject}<br>
>> >>      Argument 2 = uint32_value {257}<br>
>> >>    }<br>
>> >>  Argument 1 = string_value {ResetCamera}<br>
>> >><br>
>> >><br>
>> >>ERROR: In<br>
>> >><br>
>> >> /opt/ParaView-v5.0.1-source/ParaViewCore/ServerImplementation/Core/vtkPVSessionCore.cxx,<br>
>> >> line 391<br>
>> >>vtkPVSessionCore (0x8ca480): Aborting execution for debugging purposes.<br>
>> >><br>
>> >>############ ABORT #############<br>
>> >>Wrong tag but don't know how to handle it... 188971<br>
>> >>Aborted (core dumped)<br>
>> > Alternative 3 tries to show an interactive RenderWindow, but crashes,<br>
>> > because view->GetInteractor() returns NULL.<br>
>> ><br>
>> > Apparently I am missing some important step. Can somebody point out how<br>
>> > to<br>
>> > modify the example (below) in order to render the sphere source visible?<br>
>> ><br>
>> > Thank you<br>
>> > Peter<br>
>> ><br>
>> > TestConnection.cxx:<br>
>> ><br>
>> > #include "vtkInitializationHelper.h"<br>
>> > #include "vtkProcessModule.h"<br>
>> > #include "vtkPVOptions.h"<br>
>> > #include "vtkSMProxyManager.h"<br>
>> > #include "vtkSMSession.h"<br>
>> > #include "vtkSMSessionClient.h"<br>
>> > #include "vtkSMSessionProxyManager.h"<br>
>> > #include "vtkSMSourceProxy.h"<br>
>> > #include "vtkSMProperty.h"<br>
>> > #include "vtkSMRenderViewProxy.h"<br>
>> ><br>
>> > #include "vtkRenderWindow.h"<br>
>> > #include "vtkRenderWindowInteractor.h"<br>
>> ><br>
>> > int main(int argc, char* argv[])<br>
>> > {<br>
>> >   // Initialization<br>
>> >   vtkPVOptions* options = vtkPVOptions::New();<br>
>> >   vtkInitializationHelper::Initialize(argc, argv,<br>
>> >                                       vtkProcessModule::PROCESS_CLIENT,<br>
>> >                                       options);<br>
>> ><br>
>> >   vtkSMSessionClient* session = vtkSMSessionClient::New();<br>
>> >   vtkProcessModule::GetProcessModule()->RegisterSession(session);<br>
>> >   session->Connect(options->GetServerURL());<br>
>> >   cout<<"Connected to: "<<options->GetServerURL()<<endl;<br>
>> ><br>
>> >   vtkSMSessionProxyManager *pxm = session->GetSessionProxyManager();<br>
>> >   vtkSMProxy *sphere = pxm->NewProxy("sources", "SphereSource");<br>
>> >   cout<<"SphereSource created."<<endl;<br>
>> >   vtkSMRenderViewProxy*<br>
>> > view=(vtkSMRenderViewProxy*)pxm->NewProxy("views",<br>
>> > "RenderView");<br>
>> >   cout<<"RenderView created."<<endl;<br>
>> >   vtkSMRepresentationProxy*<br>
>> > repr=view->CreateDefaultRepresentation(sphere,0);<br>
>> >   cout<<"DefaultRepresentation created."<<endl;<br>
>> ><br>
>> > //Alternative 1:<br>
>> >   view->StillRender(); while(1); //no crash, but only background<br>
>> > visible.<br>
>> ><br>
>> > //Alternative 2:<br>
>> > /*<br>
>> >   view->ResetCamera(); //crash here<br>
>> >   view->StillRender(); while(1);<br>
>> > */<br>
>> ><br>
>> > //Alternative 3:<br>
>> > /*<br>
>> >   view->InteractiveRender();<br>
>> >   view->GetInteractor()->Initialize(); //crash here, because<br>
>> > view->GetInteractor()==NULL<br>
>> >   view->GetInteractor()->Start();<br>
>> > */<br>
>> >   //TODO: clean up stuff<br>
>> > }<br>
>> ><br>
>> > On Wed, Apr 20, 2016 at 5:26 PM, Utkarsh Ayachit<br>
>> > <<a href="mailto:utkarsh.ayachit@kitware.com">utkarsh.ayachit@kitware.com</a>> wrote:<br>
>> >><br>
>> >> > Thank you, but we need a pure C++ solution. There is plenty of<br>
>> >> > information<br>
>> >> > how this is done with python scripting, but I can't find anything for<br>
>> >> > C++.<br>
>> >> > I really need nothing more than a minimal example.<br>
>> >><br>
>> >> Peter, look at TestComparativeAnimationCueProxy.cxx[1] file in the<br>
>> >> ParaView source. It demonstrates how the initialization needs to<br>
>> >> happen. If you have further questions on how to use anything specific<br>
>> >> in this application, feel free to holler :).<br>
>> >><br>
>> >> [1]<br>
>> >><br>
>> >> <a href="https://gitlab.kitware.com/paraview/paraview/blob/master/ParaViewCore/ServerManager/Default/Testing/Cxx/TestComparativeAnimationCueProxy.cxx" rel="noreferrer" target="_blank">https://gitlab.kitware.com/paraview/paraview/blob/master/ParaViewCore/ServerManager/Default/Testing/Cxx/TestComparativeAnimationCueProxy.cxx</a><br>
>> >><br>
>> >> Utkarsh<br>
>> ><br>
>> ><br>
><br>
><br>
</div></div></blockquote></div><br></div></div>