Customizing ParaView Glance interface

Hello,

I’m still getting up to speed on ParaView Glance, and so have a few questions, but I’ll start with a couple of related ones.

  1. In another thread Sebastien mentions an “index.html” file that can be modified – where do I find this file? If I export as .vtkjs and use the advanced option to read a ParaViewGlance.html file, I see that it produces a new .html file, but I do not find any “index.html” file that is generated.

[ASIDE: Am I correct in understanding that the myapp.html file that is generated uses the supplied ParaViewGlance.html file as a template of sorts?]

[ASIDE2: When I do an open->file on that “myapp.html”, I’m only getting some HTML forms on the left side of the browser and no data, what is the common user error that causes this? Ie. what am I doing wrong? (If I load the .vtkjs file into the Glance lander page, that does work]

  1. Hmmm, I was going to ask a “second” question here, but with the two asides, that’s probably enough for one post, so a hint, I’ll be asking in another post how difficult is it for me to alter the left-side interface options.

    Thanks,
    Bill

Hi Bill,

  1. ParaView Glance get published via npm and its index.html can be found here or in the repo if you plan to build it yourself.

For your myapp.html, you are correct, the file ParaViewGlance.html get used and a new script tag get added along with the data.

Aside2: The myapp.html should already load your data unless you did an export without anything. Otherwise, I’m not sure what you mean by form on the left.

  1. I guess it depend what you are planning to do.

Hello again,

[After working on another project for a couple weeks, I’m back to the project that
is uses Glance.]

So first two quick questions:

  1. Is it known that texture maps don’t work in the HTML Glance view of the .vtkjs file?
    Or am I just doing something wrong?

  2. I suppose it’s also known that pipelines that read a CVS file don’t work (even though
    the data is translated from Table to Points and then Glyph’d from there). With PV 5.7, doing
    the export crashed ParaView, but at least with 5.8-RC1 it only outputs some undecipherable
    error messages to the Output and doesn’t crash.

And the main question for the day:

  1. One simple customization I’d like with my ParaView Glance web interface is to disable the
    access to any object in the pipeline that I wasn’t rendering – i.e. all the transition filters that lead
    up to what I want to render become first-class objects in the Glance page, so the user won’t know which objects are ones that are intended for viewing, and which aren’t. (If there’s a
    simple tweaks to the .vtkjs file, I’m willing to go in and make hand-edits.)

    Thanks,
    Bill

  1. Textures should work in Glance, and I think the vtkjs reader supports it. I’ll have to check.
  2. I’ll defer this to @jourdain
  3. If there is a way to identify what is a filter, then Glance should be easily modifiable to simply ignore those in the Datasets panel.
  1. It is possible but it should be easy to fix on the JS side if indeed missing. Although the PV exporter available in the UI does not capture the textures as that part was not implemented on the C++ side.

  2. It might be related to vtkStringArray, but not sure. If you could post the error message, that would be great.

  3. When you are exporting in ParaView, normally all the pipeline elements that are not visible should not be exported and therefore not available in the Glance pipeline. If need be, you can edit the vtkjs file by unzipping it and editing the root index.json file. Just remove the datasets that you want to ignore from the scene listing.

@Patrick_Avery did you change something that could affect 3?

@jourdain I don’t think so. Invisible elements are only exported in my unmerged ParaView branch (not in master), and they are only exported there if a new variable in the PVWebExporter gets set (which is currently only done in the OpenVR plugin on that branch).

By the way, with regard to exporting the textures, I added an option to export them as jpeg in VTK here.

1 Like

Thank you for the tips and information.

Addressing each by numbrer:

  1. So what can I do in the index.json to re-add the texture map? (I tested again, and it’s definitely not being included.)

  2. Here’s the output from when I have a CSV file reader:
    Generic Warning: In /Users/kitware/dashboards/buildbot-slave/a64f5607/build/superbuild/paraview/src/Remoting/Export/vtkPVWebExporter.cxx, line 71
    Failed to rename datasets using ParaView proxy name

    Traceback (most recent call last):
    File “/Applications/ParaView-5.8.0-RC1.app/Contents/Python/paraview/web/vtkjs_helper.py”, line 64, in applyParaViewNaming
    renameMap = getRenameMap()
    File “/Applications/ParaView-5.8.0-RC1.app/Contents/Python/paraview/web/vtkjs_helper.py”, line 39, in getRenameMap
    names = getAllNames()
    File “/Applications/ParaView-5.8.0-RC1.app/Contents/Python/paraview/web/vtkjs_helper.py”, line 21, in getAllNames
    actorRep = simple.GetRepresentation(val).GetClientSideObject().GetActiveRepresentation().GetActor()
    AttributeError: ‘NoneType’ object has no attribute ‘GetClientSideObject’

NOTE: I found that I get a similar result when including a “Text” source as well.

Oh, and when this happens, the .vtkjs directory is created, but it doesn’t get zipped into a file, and also the items in the list still have just a numeric name rather than their name in the pipeline.

So … I just tried zipping up that directory and naming it to be a .vtkjs file, and
then I loaded it into ParaView Glance – and it works! It reads the CVS data and outputs my glyphs! But as noted, all the elements in the pipeline are just numbers so I’d need to edit the index.json file to correct that. Which basically means it mostly works, but some small thing generates an error that doesn’t allow the finalization of creating the .vtkjs zip file. (And as a reminder, this is with ParaView 5.8-RC1, ParaView 5.7 crashes, though it too leaves the .vtkjs directory behind.)

One final comment on item #2 – I was pleased to search and discover that vim will let me edit .vtkjs files without having to unzip and rezip them! That will come in very handy once I start tweaking the .vtkjs files!

And finally:
3. I was partially mistaken about the pipeline elements showing up in the Glance interface. It’s true that only the “visible” elements are added to the ParaView Glance interface on the left side, but added is what happens. So when I loaded a .vtkjs file, and then went back and loaded another .vtkjs file, the elements from both of these show up! So for a quick example, I loaded the example molecule glance file, and then loaded my own .vtkjs file, and the molecule is still in the interface! So that’s why I was seeing so many elements there. Perhaps this isn’t considered a bug, but it’s very odd and unexpected behavior.

I still have more ParaView Glance questions, but I’ll start a new thread for those. Right now, for this thread, I guess I’m waiting to hear about the texture map solution, and also hoping that the reading of CSV files and adding “Text” source types can be exported to .vtkjs without generating errors that cause the .vtkjs to not be finalized.

 Thanks!
 Bill

Okay, thanks. See my response to Sebastien about what I think the actual issue is regarding the visible pipeline elements – ES: new elements are added to the ParaView Glance in my browser rather than getting rid of the ones from previous Glance views.

Thanks,
Bill

P.S. I tried to include the error message output in “code” format in my response to Sebastien – is that was the </> icon does? But it just showed up indented. I know Matt W. helps me by editing my posts with code, but I’m trying to learn how to do it myself!

Thanks Bill for your detailed feedback. It is indeed very informative.

The issue is related to the TextSource or CSVReader that when we try to figure out their name in the ParaView pipeline we simply fail and exit the execution where the next step was supposed to be the zip of the directory.

You can actually fix it by patching a Python file inside your ParaView bundle.
The file to edit on mac is /Applications/ParaView-5.8.0-RC1.app/Contents/Python/paraview/web/vtkjs_helper.py.

Then inside that file, you should replace the getAllNames() function with the one below

def getAllNames():
    actorNameMapping = {}
    srcs = simple.GetSources()
    duplicates = {}
    for key, val in srcs.items():
        # Prevent name duplication
        nameToUse = key[0]
        if nameToUse in duplicates:
            count = 1
            newName = '%s (%d)' % (nameToUse, count)
            while newName in duplicates:
                count += 1
                newName = '%s (%d)' % (nameToUse, count)
            nameToUse = newName
        duplicates[nameToUse] = True
        vtkRepInstance = simple.GetRepresentation(val).GetClientSideObject()   // EDIT
        if 'GetActiveRepresentation' in dir(vtkRepInstance):                  // EDIT
            actorRep = vtkRepInstance.GetActiveRepresentation().GetActor()   // EDIT
            actorNameMapping[nameToUse] = actorRep                          // EDIT
    return actorNameMapping

I’ve exposed the texture capture from VTK inside ParaView but the scene loader in vtkjs does not understand the extra information yet. But that should be easy to fix.

@jourdain Yeah, I actually fixed it in this PR that did not get merged. It is this commit in particular that fixed it.

Hello Jourdain,

Okay, nice that an edit to a Python file will probably fix the issue. However, there’s still an issue with the line:

vtkRepInstance = simple.GetRepresentation(val).GetClientSideObject()

Here’s the error output:

Failed to rename datasets using ParaView proxy name

Traceback (most recent call last):
  File "/Applications/ParaView-5.8.0-RC1.app/Contents/Python/paraview/web/vtkjs_helper.py", line 66, in applyParaViewNaming
    renameMap = getRenameMap()
  File "/Applications/ParaView-5.8.0-RC1.app/Contents/Python/paraview/web/vtkjs_helper.py", line 41, in getRenameMap
    names = getAllNames()
  File "/Applications/ParaView-5.8.0-RC1.app/Contents/Python/paraview/web/vtkjs_helper.py", line 21, in getAllNames
    vtkRepInstance = simple.GetRepresentation(val).GetClientSideObject()
AttributeError: 'NoneType' object has no attribute 'GetClientSideObject'

I’m ready to try what’s next!
Thanks,
Bill

Okay, so regarding texture maps in Glance, do I need to wait for the next 5.8 release candidate, or what can I do – it’s important for this project to have a texture map in my scene.
Thanks again for the help,
Bill

Here is the MR so far.
I guess your CSVReader does not have a representation for a 3D view. Hence the issue.

Let me know how it goes

def getAllNames():
    actorNameMapping = {}
    srcs = simple.GetSources()
    duplicates = {}
    for key, val in srcs.items():
        # Prevent name duplication
        nameToUse = key[0]
        if nameToUse in duplicates:
            count = 1
            newName = '%s (%d)' % (nameToUse, count)
            while newName in duplicates:
                count += 1
                newName = '%s (%d)' % (nameToUse, count)
            nameToUse = newName
        duplicates[nameToUse] = True
        representation = simple.GetRepresentation(val)
        if representation:
            vtkRepInstance = representation.GetClientSideObject()
            if 'GetActiveRepresentation' in dir(vtkRepInstance):
                actorRep = vtkRepInstance.GetActiveRepresentation().GetActor()
                actorNameMapping[nameToUse] = actorRep
    return actorNameMapping

ParaView 5.8-RC2 will be out soon (tomorrow) with my fix to enable the textures.
@Forrest_Li is working on getting a new version of Glance that will support textures. It won’t be available in the ParaView bundle just yet, but you can easily download it or use the one online.

Works! Thanks!

And yes, the CSV reader itself has no 3D representation, but I send it through the TableToPoints filter and then a Glyph filter to make the 3D.

I notice though that the standard (ie. 2D) “Text” source gets quietly removed from the .vtkjs scene, which is definitely better than causing failure.

Thanks again for all the help,
Bill

Re: fixed textures in 5.8-RC2:

Great! I will look forward to that and try it out right away!

Thanks yet again!
Bill