@@ -111,6 +111,8 @@ class PlotModel:
111111 If True, use plot_settings.pkl file to reload settings
112112 model_path : pathlib.Path
113113 Path to model XML file or directory
114+ default_res : int
115+ Default resolution as the number of pixels in each direction
114116
115117 Attributes
116118 ----------
@@ -147,7 +149,7 @@ class PlotModel:
147149 have unapplied changes
148150 """
149151
150- def __init__ (self , use_settings_pkl , model_path ):
152+ def __init__ (self , use_settings_pkl , model_path , default_res ):
151153 """ Initialize PlotModel class attributes """
152154
153155 # Retrieve OpenMC Cells/Materials
@@ -174,7 +176,7 @@ def __init__(self, use_settings_pkl, model_path):
174176 self .previousViews = []
175177 self .subsequentViews = []
176178
177- self .defaultView = self .getDefaultView ()
179+ self .defaultView = self .getDefaultView (default_res )
178180
179181 if model_path .is_file ():
180182 settings_pkl = model_path .with_name ('plot_settings.pkl' )
@@ -228,7 +230,8 @@ def __init__(self, use_settings_pkl, model_path):
228230 self .statepoint = None
229231
230232 self .currentView = PlotView (restore_view = view ,
231- restore_domains = restore_domains )
233+ restore_domains = restore_domains ,
234+ default_res = default_res )
232235
233236 else :
234237 self .currentView = copy .deepcopy (self .defaultView )
@@ -256,14 +259,19 @@ def statepoint(self, statepoint):
256259 if self ._statepoint and not self ._statepoint .is_open :
257260 self ._statepoint .open ()
258261
259- def getDefaultView (self ):
262+ def getDefaultView (self , default_res ):
260263 """ Generates default PlotView instance for OpenMC geometry
261264
262265 Centers plot view origin in every dimension if possible. Defaults
263266 to xy basis, with height and width to accomodate full size of
264267 geometry. Defaults to (0, 0, 0) origin with width and heigth of
265268 25 if geometry bounding box cannot be generated.
266269
270+ Parameters
271+ ----------
272+ default_res : int
273+ Default resolution as the number of pixels in each direction
274+
267275 Returns
268276 -------
269277 default : PlotView instance
@@ -286,7 +294,8 @@ def getDefaultView(self):
286294 else :
287295 zcenter = 0.00
288296
289- default = PlotView ([xcenter , ycenter , zcenter ], width , height )
297+ default = PlotView ([xcenter , ycenter , zcenter ], width , height ,
298+ default_res = default_res )
290299 return default
291300
292301 def resetColors (self ):
@@ -760,6 +769,8 @@ class ViewParam(openmc.lib.plot._PlotBase):
760769 Width of plot view in model units
761770 height : float
762771 Height of plot view in model units
772+ default_res : int
773+ Default resolution as the number of pixels in each direction
763774
764775 Attributes
765776 ----------
@@ -781,7 +792,7 @@ class ViewParam(openmc.lib.plot._PlotBase):
781792 The universe level for the plot (default: -1 -> all universes shown)
782793 """
783794
784- def __init__ (self , origin = (0 , 0 , 0 ), width = 10 , height = 10 ):
795+ def __init__ (self , origin = (0 , 0 , 0 ), width = 10 , height = 10 , default_res = 1000 ):
785796 """Initialize ViewParam attributes"""
786797 super ().__init__ ()
787798
@@ -790,8 +801,8 @@ def __init__(self, origin=(0, 0, 0), width=10, height=10):
790801 self .origin = origin
791802 self .width = width
792803 self .height = height
793- self .h_res = 1000
794- self .v_res = 1000
804+ self .h_res = default_res
805+ self .v_res = default_res
795806 self .basis = 'xy'
796807 self .color_overlaps = False
797808
@@ -976,15 +987,22 @@ class PlotView:
976987 'h_res' , 'v_res' , 'basis' , 'llc' , 'urc' , 'color_overlaps' )
977988
978989 def __init__ (self , origin = (0 , 0 , 0 ), width = 10 , height = 10 , restore_view = None ,
979- restore_domains = False ):
990+ restore_domains = False , default_res = None ):
980991 """Initialize PlotView attributes"""
981992
982993 if restore_view is not None :
983994 self .view_ind = copy .copy (restore_view .view_ind )
984995 self .view_params = copy .copy (restore_view .view_params )
996+ if default_res is not None :
997+ p = self .view_params
998+ p .h_res = default_res
999+ p .v_res = int (default_res * p .height / p .width )
9851000 else :
9861001 self .view_ind = PlotViewIndependent ()
987- self .view_params = ViewParam (origin = origin , width = width , height = height )
1002+ if default_res is not None :
1003+ self .view_params = ViewParam (origin , width , height , default_res )
1004+ else :
1005+ self .view_params = ViewParam (origin , width , height )
9881006
9891007 # Get model domain info
9901008 if restore_domains and restore_view is not None :
0 commit comments