paraviewweb icon indicating copy to clipboard operation
paraviewweb copied to clipboard

dual render

Open kmilo9999 opened this issue 6 years ago • 28 comments

Hi,

Following the RemoteRenderer example, I am rendering two instances in the same webpage. I doing this in the client side:

`const config = { sessionURL: 'ws://localhost:1234/ws' }; const smartConnect = SmartConnect.newInstance({ config }); smartConnect.onConnectionReady((connection) => { const pvwClient = ParaViewWebClient.createClient(connection, [ 'MouseHandler', 'ViewPort', 'ViewPortImageDelivery', ]); const renderer = new RemoteRenderer(pvwClient); renderer.setContainer(divRenderer1); renderer.onImageReady(() => { console.log('We are good'); });

window.renderer = renderer; SizeHelper.onSizeChange(() => { renderer.resize(); }); SizeHelper.startListening(); }); smartConnect.connect();

const smartConnect2 = SmartConnect.newInstance({ config }); smartConnect.onConnectionReady((connection) => { const pvwClient = ParaViewWebClient.createClient(connection, [ 'MouseHandler', 'ViewPort', 'ViewPortImageDelivery', ]);

const renderer2 = new RemoteRenderer(pvwClient); renderer2.setContainer(divRenderer2); renderer2.onImageReady(() => { console.log('We are good 2'); });

window.renderer = renderer2; SizeHelper.onSizeChange(() => { renderer.resize(); }); SizeHelper.startListening(); }); smartConnect2.connect();`

And this is my result:

paraviewdual

The problem is the mouse interaction between the two renders. If I rotate the one above, the one below wont update the model. However, if you interact with the one below it will update form the current position of the above render, plus its new transformation.

Is it possible to synchronize both renders ?

Thank you.

kmilo9999 avatar Aug 08 '18 18:08 kmilo9999

Yes it is possible but the way you are doing it may not be what you want since you are starting 2 process for 1 client.

Here is an example of what you may try to do https://github.com/Kitware/paraviewweb-examples

jourdain avatar Aug 08 '18 19:08 jourdain

2 views aims to be independant content and camera wise, but you can create a link between your views.

But maybe I don't understand what you are trying to do. Is it for collaboration?

jourdain avatar Aug 08 '18 19:08 jourdain

Which version of ParaView are you using since we had to fix something to handle multiple view correctly. You need ParaView/master as the changes don't fully get into PV5.5.

jourdain avatar Aug 08 '18 19:08 jourdain

No, I want to apply the same transformations on both views, independently on the content they render. Still possible?

kmilo9999 avatar Aug 08 '18 19:08 kmilo9999

In ParaView, you just need to create a camera link between the views... That's it.

jourdain avatar Aug 08 '18 19:08 jourdain

Can I find how to do that in the multi view example ?

kmilo9999 avatar Aug 08 '18 19:08 kmilo9999

when you said "In paraview", you mean the pv server?

kmilo9999 avatar Aug 08 '18 19:08 kmilo9999

I mean pvpython

jourdain avatar Aug 08 '18 19:08 jourdain

If you do it via the GUI in Paraview with the Trace enabled, you will get the python code to do to create that link.

jourdain avatar Aug 08 '18 19:08 jourdain

Hi, I did the suggested step of tracking link cameras in paraview and move the resulting code to the pv server file in the multi view example:

`
view1 = simple.CreateView('RenderView'); view1.EnableRenderOnInteraction = 0; view1.Background = [0,0,0]; simple.Show(simple.Cone(), view1);

    view1.GetGlobalIDAsString()

    view2 = simple.CreateView('RenderView')
    view2.EnableRenderOnInteraction = 0
    view2.Background = [0,0,0]

    simple.Show(simple.Cone(), view2)

    #view.GetGlobalIDAsString()


    self.registerVtkWebProtocol(UserProtocol([view1.GetGlobalIDAsString(), view2.GetGlobalIDAsString()]));
    SetActiveView(view1)
    SetActiveView(view2)`

However, I still dont get the expected result. Am I missing something?

Thank you very much for your help.

kmilo9999 avatar Aug 09 '18 12:08 kmilo9999

Nvm, I solved it.

This is the code that links two views.

AddCameraLink(view1, view2, 'mycameraLink')

However, there is a 'lag' between the two views, and the one that is not the "active view" is hard to manipulate with the mouse events.

Any ideas how to approach this issue.

kmilo9999 avatar Aug 09 '18 13:08 kmilo9999

It is hard to tell without seeing the issue and truly focusing on the possible solutions. I can already think of several but it won't be possible to explain them on an issue tracker without me spending some time reproducing the issue and trying various approach to solve it. Therefore If you want to pursue with our help, you will need a support contract.

jourdain avatar Aug 09 '18 14:08 jourdain

I see. Can you point to an example where I can intersect the mouse events into my own protocols? WHat I can see the second dual window is not active. I would like to activate it when the user right click on it.

That will be extremely helpful.

Thanks.

kmilo9999 avatar Aug 13 '18 13:08 kmilo9999

Just add a right click listener on JavaScript and then call your own protocol to activate the view you provide as argument. Don't have any specific example on how to add a mouse listener in JavaScript but you should find that on the web.

jourdain avatar Aug 13 '18 14:08 jourdain

Thanks for the hint. It was easy to do. However, when I move the geometry in the active view I got this exception:

Traceback (most recent call last): File "Paraview-5.5/lib/python2.7/site-packages/paraview/web/protocols.py", line 605, in startCallback = lambda *args, **kwargs: self.startViewAnimation() File "Paraview-5.5/lib/python2.7/site-packages/paraview/web/protocols.py", line 514, in startViewAnimation sView = self.getView(viewId) File "Paraview-5.5/lib/python2.7/site-packages/paraview/web/protocols.py", line 97, in getView raise Exception("no view provided: " + str(vid)) Exception: no view provided: -1 Traceback (most recent call last): File "Paraview-5.5/lib/python2.7/site-packages/paraview/web/protocols.py", line 605, in startCallback = lambda *args, **kwargs: self.startViewAnimation() File "Paraview-5.5/lib/python2.7/site-packages/paraview/web/protocols.py", line 514, in startViewAnimation sView = self.getView(viewId) File "Paraview-5.5/lib/python2.7/site-packages/paraview/web/protocols.py", line 97, in getView raise Exception("no view provided: " + str(vid)) Exception: no view provided: -1 Traceback (most recent call last): File "Paraview-5.5/lib/python2.7/site-packages/paraview/web/protocols.py", line 606, in stopCallback = lambda *args, **kwargs: self.stopViewAnimation() File "Paraview-5.5/lib/python2.7/site-packages/paraview/web/protocols.py", line 524, in stopViewAnimation sView = self.getView(viewId) File "Paraview-5.5/lib/python2.7/site-packages/paraview/web/protocols.py", line 97, in getView raise Exception("no view provided: " + str(vid)) Exception: no view provided: -1 Traceback (most recent call last): File "Paraview-5.5/lib/python2.7/site-packages/paraview/web/protocols.py", line 606, in stopCallback = lambda *args, **kwargs: self.stopViewAnimation() File "Paraview-5.5/lib/python2.7/site-packages/paraview/web/protocols.py", line 524, in stopViewAnimation sView = self.getView(viewId) File "Paraview-5.5/lib/python2.7/site-packages/paraview/web/protocols.py", line 97, in getView raise Exception("no view provided: " + str(vid))

I guess I will have to live with it in the mean time.

kmilo9999 avatar Aug 13 '18 16:08 kmilo9999

See my previous comment...

Which version of ParaView are you using since we had to fix something to handle multiple view correctly. You need ParaView/master as the changes don't fully get into PV5.5.

jourdain avatar Aug 13 '18 16:08 jourdain

Thanks! I will deploy with the suggested version

kmilo9999 avatar Aug 13 '18 16:08 kmilo9999

Deploying using paraview master helps to remove the exception. Also, the frame rate between linked cameras improved substantially. Thanks!! One more thing, if I link camera A to B for 0.25 seconds and then remove the link, both views will synchronize momentarily ( camera in view B gets the state from camera A ). But If I create a link in the opposite direction (B -> A), the changes on camera B are never reflected in camera A. Would that be another 'contract support' issue?

kmilo9999 avatar Aug 14 '18 18:08 kmilo9999

Most likely since I will have to spend some time to investigate.

jourdain avatar Aug 14 '18 19:08 jourdain

I was expecting that answer. Thanks!!

kmilo9999 avatar Aug 14 '18 19:08 kmilo9999

Hi,

How can I increase the height of the vtk render view? In the multi view example is to short.

Thanks a lot !

kmilo9999 avatar Aug 15 '18 20:08 kmilo9999

Just put the renderer in a div/container that has the expected size... You should be able to google on how to do that with CSS.

jourdain avatar Aug 15 '18 20:08 jourdain

I am rendering the view on a table with the following css properties:

 <td key={'view'+index} id={id}  **style**={{width:'50%',height: '80vh', resize: 'both', overflow: 'hidden',}} onClick={this.handleClick} > 
 <VtkRenderer
                  key={id}
                  connection={network.getConnection()}
                  client={network.getClient()}
                  viewId={id}

                  stillQuality={100}
                  interactiveQuality={60}
                  stillRatio={1}
                  interactiveRatio={1}
                 />
   </td>

But it only increased the size of the cell. Does it only applies on div tags?

kmilo9999 avatar Aug 15 '18 21:08 kmilo9999

no it will use the size of its container.

jourdain avatar Aug 15 '18 21:08 jourdain

This didnt work :(

  <td key={'view'+index} id={id} style={{width:'50%',}} onClick={this.handleClick} >
              <div   style={{position: 'relative',
                     height: '80vh',
                     resize: 'both',
                     overflow: 'hidden',
                     zIndex: '10',
                    }} >
                <VtkRenderer
                  key={id}
                  connection={network.getConnection()}
                  client={network.getClient()}
                  viewId={id}

                  stillQuality={100}
                  interactiveQuality={60}
                  stillRatio={1}
                  interactiveRatio={1}
                 />
              </div>
          </td>

I'll see if it works without the table

kmilo9999 avatar Aug 15 '18 21:08 kmilo9999

does it properly rescale when resizing your browser window?

jourdain avatar Aug 15 '18 21:08 jourdain

Yes, it does resize. I saw another example where they can adjust the render view to the size of the container in the following way:

  <div id="renderContainerOne"
             style={{position: 'relative',
                     height: '80vh',
                     resize: 'both',
                     overflow: 'hidden',
                     zIndex: '10',
                    }}
  />
  myVtkRender = VtkRenderer.newInstance({
              client: this.model.pvwClient,
              viewId: result, 
  myVtkRender.setContainer(
              document.getElementById(renderContainerOne));

Is it possible to set the container in the VtkRender tag in the react component?

kmilo9999 avatar Aug 15 '18 21:08 kmilo9999

Still looking in the wrong direction... The react component is just fine but you need to set the className to a style that is going to either fix its size or use the parent one...

jourdain avatar Aug 15 '18 22:08 jourdain