@@ -2423,7 +2423,20 @@ def _getPyProxy(smproxy, outputPort=0):
2423
2423
if classForProxy :
2424
2424
retVal = classForProxy (proxy = smproxy , port = outputPort )
2425
2425
else :
2426
- retVal = Proxy (proxy = smproxy , port = outputPort )
2426
+ # Since the class for this proxy, doesn't exist yet, we attempt to
2427
+ # create a new class definition for it, if possible and then add it
2428
+ # to the "misc" module. This is essential since the Python property
2429
+ # variables for a proxy are only setup whne the Proxy class is created
2430
+ # (in _createClass).
2431
+ # NOTE: _createClass() takes the xml group and name, not the xml label,
2432
+ # hence we don't pass xmlName variable.
2433
+ classForProxy = _createClass (smproxy .GetXMLGroup (), smproxy .GetXMLName ())
2434
+ if classForProxy :
2435
+ global misc
2436
+ misc .__dict__ [classForProxy .__name__ ] = classForProxy
2437
+ retVal = classForProxy (proxy = smproxy , port = outputPort )
2438
+ else :
2439
+ retVal = Proxy (proxy = smproxy , port = outputPort )
2427
2440
return retVal
2428
2441
2429
2442
def _makeUpdateCameraMethod (rv ):
@@ -2582,6 +2595,65 @@ class PVModule(object):
2582
2595
def _make_name_valid (name ):
2583
2596
return paraview .make_name_valid (name )
2584
2597
2598
+ def _createClass (groupName , proxyName , apxm = None ):
2599
+ """Defines a new class type for the proxy."""
2600
+ global ActiveConnection
2601
+ pxm = ProxyManager () if not apxm else apxm
2602
+ proto = pxm .GetPrototypeProxy (groupName , proxyName )
2603
+ if not proto :
2604
+ paraview .print_error ("Error while loading %s/%s %s" % (groupName , i ['group' ], proxyName ))
2605
+ return None
2606
+ pname = proxyName
2607
+ if paraview .compatibility .GetVersion () >= 3.5 and proto .GetXMLLabel ():
2608
+ pname = proto .GetXMLLabel ()
2609
+ pname = _make_name_valid (pname )
2610
+ if not pname :
2611
+ return None
2612
+ cdict = {}
2613
+ # Create an Initialize() method for this sub-class.
2614
+ cdict ['Initialize' ] = _createInitialize (groupName , proxyName )
2615
+ iter = PropertyIterator (proto )
2616
+ # Add all properties as python properties.
2617
+ for prop in iter :
2618
+ propName = iter .GetKey ()
2619
+ if paraview .compatibility .GetVersion () >= 3.5 :
2620
+ if (prop .GetInformationOnly () and propName != "TimestepValues" ) \
2621
+ or prop .GetIsInternal ():
2622
+ continue
2623
+ names = [propName ]
2624
+ if paraview .compatibility .GetVersion () >= 3.5 :
2625
+ names = [iter .PropertyLabel ]
2626
+
2627
+ propDoc = None
2628
+ if prop .GetDocumentation ():
2629
+ propDoc = prop .GetDocumentation ().GetDescription ()
2630
+ for name in names :
2631
+ name = _make_name_valid (name )
2632
+ if name :
2633
+ cdict [name ] = property (_createGetProperty (propName ),
2634
+ _createSetProperty (propName ),
2635
+ None ,
2636
+ propDoc )
2637
+ # Add the documentation as the class __doc__
2638
+ if proto .GetDocumentation () and \
2639
+ proto .GetDocumentation ().GetDescription ():
2640
+ doc = proto .GetDocumentation ().GetDescription ()
2641
+ else :
2642
+ doc = Proxy .__doc__
2643
+ cdict ['__doc__' ] = doc
2644
+ # Create the new type
2645
+ if proto .GetXMLName () == "ExodusIIReader" :
2646
+ superclasses = (ExodusIIReaderProxy ,)
2647
+ elif proto .IsA ("vtkSMSourceProxy" ):
2648
+ superclasses = (SourceProxy ,)
2649
+ elif proto .IsA ("vtkSMViewLayoutProxy" ):
2650
+ superclasses = (ViewLayoutProxy ,)
2651
+ else :
2652
+ superclasses = (Proxy ,)
2653
+
2654
+ cobj = type (pname , superclasses , cdict )
2655
+ return cobj
2656
+
2585
2657
def createModule (groupName , mdl = None ):
2586
2658
"""Populates a module with proxy classes defined in the given group.
2587
2659
If mdl is not specified, it also creates the module"""
@@ -2601,65 +2673,16 @@ def createModule(groupName, mdl=None):
2601
2673
definitionIter = pxm .NewDefinitionIterator (groupName )
2602
2674
for i in definitionIter :
2603
2675
proxyName = i ['key' ]
2604
- proto = pxm .GetPrototypeProxy (groupName , proxyName )
2605
- if not proto :
2606
- paraview .print_error ("Error while loading %s/%s %s" % (groupName , i ['group' ], proxyName ))
2607
- continue
2608
- pname = proxyName
2609
- if paraview .compatibility .GetVersion () >= 3.5 and \
2610
- proto .GetXMLLabel ():
2611
- pname = proto .GetXMLLabel ()
2612
- pname = _make_name_valid (pname )
2613
- if not pname :
2614
- continue
2615
- if pname in mdl .__dict__ :
2616
- if debug :
2617
- paraview .print_warning ("Warning: %s is being overwritten. This may point to an issue in the ParaView configuration files" % pname )
2618
- cdict = {}
2619
- # Create an Initialize() method for this sub-class.
2620
- cdict ['Initialize' ] = _createInitialize (groupName , proxyName )
2621
- iter = PropertyIterator (proto )
2622
- # Add all properties as python properties.
2623
- for prop in iter :
2624
- propName = iter .GetKey ()
2625
- if paraview .compatibility .GetVersion () >= 3.5 :
2626
- if (prop .GetInformationOnly () and propName != "TimestepValues" ) \
2627
- or prop .GetIsInternal ():
2628
- continue
2629
- names = [propName ]
2630
- if paraview .compatibility .GetVersion () >= 3.5 :
2631
- names = [iter .PropertyLabel ]
2632
-
2633
- propDoc = None
2634
- if prop .GetDocumentation ():
2635
- propDoc = prop .GetDocumentation ().GetDescription ()
2636
- for name in names :
2637
- name = _make_name_valid (name )
2638
- if name :
2639
- cdict [name ] = property (_createGetProperty (propName ),
2640
- _createSetProperty (propName ),
2641
- None ,
2642
- propDoc )
2643
- # Add the documentation as the class __doc__
2644
- if proto .GetDocumentation () and \
2645
- proto .GetDocumentation ().GetDescription ():
2646
- doc = proto .GetDocumentation ().GetDescription ()
2647
- else :
2648
- doc = Proxy .__doc__
2649
- cdict ['__doc__' ] = doc
2650
- # Create the new type
2651
- if proto .GetXMLName () == "ExodusIIReader" :
2652
- superclasses = (ExodusIIReaderProxy ,)
2653
- elif proto .IsA ("vtkSMSourceProxy" ):
2654
- superclasses = (SourceProxy ,)
2655
- elif proto .IsA ("vtkSMViewLayoutProxy" ):
2656
- superclasses = (ViewLayoutProxy ,)
2657
- else :
2658
- superclasses = (Proxy ,)
2659
-
2660
- cobj = type (pname , superclasses , cdict )
2661
- # Add it to the modules dictionary
2662
- mdl .__dict__ [pname ] = cobj
2676
+ cobj = _createClass (groupName , proxyName , apxm = pxm )
2677
+ if cobj :
2678
+ pname = cobj .__name__
2679
+ if pname in mdl .__dict__ and debug :
2680
+ paraview .print_warning (\
2681
+ "Warning: %s is being overwritten." \
2682
+ " This may point to an issue in the ParaView configuration files" \
2683
+ % pname )
2684
+ # Add it to the modules dictionary
2685
+ mdl .__dict__ [pname ] = cobj
2663
2686
return mdl
2664
2687
2665
2688
0 commit comments