@@ -340,29 +340,31 @@ def __iter__(self):
340
340
341
341
class ConfigurationView (BonesisView ):
342
342
project = True
343
- def __init__ (self , cfg , * args , ** kwargs ):
343
+ _pred_name = "cfg"
344
+ def __init__ (self , cfg , * args , scope = None , ** kwargs ):
344
345
super ().__init__ (* args , ** kwargs )
345
346
self .cfg = cfg
347
+ self .scope = scope
346
348
def configure_show (self ):
347
349
name = symbol_of_py (self .cfg .name )
348
- self .control .add ("base" , [],
349
- "#show."
350
- f"#show cfg(X,N,V) : cfg(X,N,V), X={ name } ." )
350
+ self .control .add ("base" , [], "#show." )
351
+ if self .scope is not None :
352
+ for n in self .scope :
353
+ n = symbol_of_py (n )
354
+ self .control .add ("base" , [], f"show_scope({ self ._pred_name } ({ name } ,{ n } ))." )
355
+ self .control .add ("base" , [], f"#show { self ._pred_name } (X,N,V) : "
356
+ f"{ self ._pred_name } (X,N,V), X={ name } ,"
357
+ f"show_scope({ self ._pred_name } (X,N))." )
358
+ else :
359
+ self .control .add ("base" , [], f"#show { self ._pred_name } (X,N,V) :"
360
+ f"{ self ._pred_name } (X,N,V), X={ name } ." )
351
361
def format_model (self , model ):
352
362
atoms = model .symbols (shown = True )
353
363
x = self .cfg .name
354
364
return configurations_of_facts (atoms , keys = [x ])[x ]
355
365
356
- class HypercubeView (BonesisView ):
357
- project = True
358
- def __init__ (self , h , * args , ** kwargs ):
359
- super ().__init__ (* args , ** kwargs )
360
- self .h = h
361
- def configure_show (self ):
362
- name = symbol_of_py (self .h .name )
363
- self .control .add ("base" , [],
364
- "#show."
365
- f"#show hypercube(X,N,V) : hypercube(X,N,V), X={ name } ." )
366
+ class HypercubeView (ConfigurationView ):
367
+ _pred_name = "hypercube"
366
368
def format_model (self , model ):
367
369
pairs = []
368
370
for a in model .symbols (shown = True ):
0 commit comments