Hi,
How do I change default representation from ‘Surface’ to ‘Surface with Edges’ in Paraview Lite?
I have changed the default in script.js in RepresentationToolbar folder like this:
representation: {
  name: 'Representation',
  autoApply: true,
  default: 'Surface With Edges',
},
 
but it continues to render it as Surface.
Thanks in advance,
Francesc
             
            
               
               
               
            
            
           
          
            
              
                cory.quammen  
                (Cory Quammen (Kitware))
               
              
                  
                    February 1, 2021,  1:27pm
                   
                   
              2 
               
             
            
              Setting custom defaults for the Representation is not yet supported, unfortunately…
             
            
               
               
               
            
            
           
          
            
            
              Thanks
Is there any workaround? Can I load the default by code?
It seems to me that what I want to do is very basic.
Francesc
             
            
               
               
               
            
            
           
          
            
              
                jourdain  
                (Sebastien Jourdain)
               
              
                  
                    February 1, 2021,  4:19pm
                   
                   
              4 
               
             
            
              You just have to change the code in the protocol to override the default behavior when a new representation gets created.
             
            
               
               
               
            
            
           
          
            
            
              Can I do this from lite_protocols.py or pvw-lite.py? Or do I need to modify vtk.js library?
I would appreciate if you can point to the file.
Thanks,
Francesc
             
            
               
               
               
            
            
           
          
            
              
                jourdain  
                (Sebastien Jourdain)
               
              
                  
                    February 2, 2021,  3:51pm
                   
                   
              6 
               
             
            
              That part seems to be defined inside ParaView but could be overridden on your side. 
The protocol that you will have to fix/override is that one .
More specifically at that line  you should do something like
rep = simple.Show()
rep.Representation = 'Surface With Edges'
 
             
            
               
               
               
            
            
           
          
            
            
              Thanks!
Is there a tutorial on how to override a protocol?
it is not as simple as overriding @exportRpc (“pv.proxy.manager.create”) inside class ParaViewLite, is it?
Should I create a custom protocol for ParaViewWebProxyManager and instantiate it? How do I do that?
Thanks,
Francesc
             
            
               
               
               
            
            
           
          
            
              
                jourdain  
                (Sebastien Jourdain)
               
              
                  
                    February 2, 2021,  9:20pm
                   
                   
              8 
               
             
            
              You might be able to just register @exportRpc(“pv.proxy.manager.create”) after the main one and yours will be called rather than the first one. You may have to play with it and test it out.
             
            
               
               
               
            
            
           
          
            
            
              I try it inside lite_protocols.py and pvw-lite.py but my exportRpc(“pv.proxy.manager.create”) is not being called
Can you provide more hints?
I do not seem to progress blindly playing with it.
Thanks in advance,
Francesc
             
            
               
               
               
            
            
           
          
            
              
                jourdain  
                (Sebastien Jourdain)
               
              
                  
                    February 3, 2021,  3:40pm
                   
                   
              10 
               
             
            
              Did you swap the order in which the protocols are registered?
  
  
    
self.registerVtkWebProtocol(pv_protocols.ParaViewWebMouseHandler()) self.registerVtkWebProtocol(pv_protocols.ParaViewWebViewPort(_Server.viewportScale, _Server.viewportMaxWidth, _Server.viewportMaxHeight)) self.registerVtkWebProtocol(pv_protocols.ParaViewWebPublishImageDelivery(decode=False)) self.registerVtkWebProtocol(pv_protocols.ParaViewWebTimeHandler()) self.registerVtkWebProtocol(pv_protocols.ParaViewWebSelectionHandler()) self.registerVtkWebProtocol(pv_protocols.ParaViewWebWidgetManager()) self.registerVtkWebProtocol(pv_protocols.ParaViewWebKeyValuePairStore()) self.registerVtkWebProtocol(pv_protocols.ParaViewWebSaveData(baseSavePath=_Server.saveDataDir)) # Bring used components from ParaView Lite self.registerVtkWebProtocol(local_protocols.ParaViewLite()) # Update authentication key to use self.updateSecret(_Server.authKey) # tell the C++ web app to use no encoding. ParaViewWebPublishImageDelivery must be set to decode=False to match. self.getApplication().SetImageEncoding(0); # Disable interactor-based render calls view = simple.GetRenderView() view.EnableRenderOnInteraction = 0 
  
   
  
    
    
  
  
 
             
            
               
               
               
            
            
           
          
            
            
              No. I understood ParaViewLite should be after ParaViewWebProxyManager
             
            
               
               
               
            
            
           
          
            
              
                jourdain  
                (Sebastien Jourdain)
               
              
                  
                    February 3, 2021,  4:07pm
                   
                   
              12 
               
             
            
              The order should not matter since we are not generally expecting override. But in your case, you want to play with it. So if one order does not work, then maybe the other will?
             
            
               
               
               
            
            
           
          
            
            
              I change it (play with it as you say) but it didn’t work.
All this does not seem very deterministic. I found it strange that it is seems to me that I am the first one to request changing the default Representation.
Any other idea to achieve it?
Francesc
             
            
               
               
               
            
            
           
          
            
              
                jourdain  
                (Sebastien Jourdain)
               
              
                  
                    February 3, 2021,  7:01pm
                   
                   
              14 
               
             
            
              Simple create your own protocol that replace the default one with the same expected rpc endpoint.
             
            
               
               
               
            
            
           
          
            
              
                jourdain  
                (Sebastien Jourdain)
               
              
                  
                    February 3, 2021,  8:38pm
                   
                   
              15 
               
             
            
              I’ve just tested it since you were not clear. And the last registered method is indeed overriding any previous one and it is working great.
             
            
               
               
               
            
            
           
          
            
              
                jourdain  
                (Sebastien Jourdain)
               
              
                  
                    February 3, 2021,  8:50pm
                   
                   
              16 
               
             
            
              diff --git a/server/lite_protocols.py b/server/lite_protocols.py
index 2d52202..d64f54e 100644
--- a/server/lite_protocols.py
+++ b/server/lite_protocols.py
@@ -33,9 +33,19 @@ except:
     pass
 
 class ParaViewLite(pv_protocols.ParaViewWebProtocol):
-    def __init__(self, **kwargs):
+    def __init__(self, pxm=None, **kwargs):
       super(pv_protocols.ParaViewWebProtocol, self).__init__()
       self.lineContext = None
+      self.pxm = pxm
+
+    @exportRpc("pv.proxy.manager.create")
+    def customCreate(self, functionName, parentId, initialValues={}, skipDomain=False, subProxyValues={}):
+        response = self.pxm.create(functionName, parentId, initialValues, skipDomain, subProxyValues)
+        rep = simple.Show()
+        rep.Representation = 'Surface With Edges'
+        self.getApplication().InvokeEvent('UpdateEvent')
+
+        return response
 
     @exportRpc("paraview.lite.proxy.name")
     def getProxyName(self, pid):
diff --git a/server/pvw-lite.py b/server/pvw-lite.py
index a96743b..5a634da 100644
--- a/server/pvw-lite.py
+++ b/server/pvw-lite.py
@@ -177,10 +177,12 @@ class _Server(pv_wslink.PVServerProtocol):
 
     def initialize(self):
         # Bring used components from ParaView
+        pxm_protocol = pv_protocols.ParaViewWebProxyManager(
+            allowedProxiesFile=_Server.proxies, baseDir=_Server.dataDir, fileToLoad=_Server.fileToLoad, allowUnconfiguredReaders=_Server.allReaders)
         self.registerVtkWebProtocol(pv_protocols.ParaViewWebStartupRemoteConnection(_Server.dsHost, _Server.dsPort, _Server.rsHost, _Server.rsPort, _Server.rcPort))
         self.registerVtkWebProtocol(pv_protocols.ParaViewWebStartupPluginLoader(_Server.plugins))
         self.registerVtkWebProtocol(pv_protocols.ParaViewWebFileListing(_Server.dataDir, "Home", _Server.excludeRegex, _Server.groupRegex))
-        self.registerVtkWebProtocol(pv_protocols.ParaViewWebProxyManager(allowedProxiesFile=_Server.proxies, baseDir=_Server.dataDir, fileToLoad=_Server.fileToLoad, allowUnconfiguredReaders=_Server.allReaders))
+        self.registerVtkWebProtocol(pxm_protocol)
         self.registerVtkWebProtocol(pv_protocols.ParaViewWebColorManager(pathToColorMaps=_Server.colorPalette, showBuiltin=_Server.showBuiltin))
         self.registerVtkWebProtocol(pv_protocols.ParaViewWebMouseHandler())
         self.registerVtkWebProtocol(pv_protocols.ParaViewWebViewPort(_Server.viewportScale, _Server.viewportMaxWidth, _Server.viewportMaxHeight))
@@ -192,7 +194,7 @@ class _Server(pv_wslink.PVServerProtocol):
         self.registerVtkWebProtocol(pv_protocols.ParaViewWebSaveData(baseSavePath=_Server.saveDataDir))
 
         # Bring used components from ParaView Lite
-        self.registerVtkWebProtocol(local_protocols.ParaViewLite())
+        self.registerVtkWebProtocol(local_protocols.ParaViewLite(pxm_protocol))
 
         # Update authentication key to use
         self.updateSecret(_Server.authKey)
 
             
            
               
               
               
            
            
           
          
            
            
              I appreciate your dedication Sebastian but after doing exactly the same thing as your diff, I still get Surface as default representation:
If I add some print traces in customCreate should they appear in the console? I don’t get them
             
            
               
               
               
            
            
           
          
            
              
                jourdain  
                (Sebastien Jourdain)
               
              
                  
                    February 4, 2021,  3:24pm
                   
                   
              18 
               
             
            
              Could you explain what you are doing as it is working for me…
What are you running (command line)? 
Which file are you editing (paths)? 
Which version of ParaView are you using? 
Do you see any error (client/server)?
If you do a print('custom code') in your method it should show up in your terminal where you start the process. Not in the web browser.
             
            
               
               
               
            
            
           
          
            
            
              pvpython --force-offscreen-rendering ./server/pvw-lite.py --data C:\projects_web\3d_samples --port 8082
server/lite_protocols.py 
server/pvw-lite.py
ParaView-5.8.1-Windows-Python3.7-msvc2015-64bit/bin/pvpython
no errors(client/server)
I know it should be in the console. I get a trace from this: 
def initialize(self): 
# Bring used components from ParaView 
print(‘initialize’)
but nothing from this: 
@exportRpc (“pv.proxy.manager.create”) 
def customCreate(self, functionName, parentId, initialValues={}, skipDomain=False, subProxyValues={}): 
print(‘custom create’)
             
            
               
               
               
            
            
           
          
            
              
                jourdain  
                (Sebastien Jourdain)
               
              
                  
                    February 4, 2021,  6:01pm
                   
                   
              20 
               
             
            
              I have no idea why it is not working on your end. I don’t know if it is a Windows issue vs Linux (where I’ve tested it).
I checked and I was also using PV 5.8.1 with Python 3.7.4.