@@ -45,6 +45,7 @@ def __init__(self, *, project=None, mapCanvas=None, logger=None):
4545 default_bounding_box ['zmax' ],
4646 ],
4747 )
48+ self ._bounding_box_set = False
4849
4950 self ._basal_contacts = None
5051 self ._fault_traces = None
@@ -99,7 +100,9 @@ def set_model_manager(self, model_manager):
99100 self ._model_manager .set_fault_topology (self ._fault_topology )
100101 self ._model_manager .update_bounding_box (self ._bounding_box )
101102
102- def set_bounding_box (self , xmin = None , xmax = None , ymin = None , ymax = None , zmin = None , zmax = None ):
103+ def set_bounding_box (
104+ self , xmin = None , xmax = None , ymin = None , ymax = None , zmin = None , zmax = None , * , mark_set = True
105+ ):
103106 """Set the bounding box for the model."""
104107 origin = self ._bounding_box .origin
105108 maximum = self ._bounding_box .maximum
@@ -118,8 +121,8 @@ def set_bounding_box(self, xmin=None, xmax=None, ymin=None, ymax=None, zmin=None
118121 maximum [2 ] = zmax
119122 self ._bounding_box .origin = origin
120123 self ._bounding_box .maximum = maximum
121- self . _bounding_box . origin = origin
122- self ._bounding_box . maximum = maximum
124+ if mark_set :
125+ self ._bounding_box_set = True
123126 self ._model_manager .update_bounding_box (self ._bounding_box )
124127 if self .bounding_box_callback :
125128 self .bounding_box_callback (self ._bounding_box )
@@ -128,6 +131,10 @@ def set_bounding_box_update_callback(self, callback):
128131 self .bounding_box_callback = callback
129132 self .bounding_box_callback (self ._bounding_box )
130133
134+ def is_bounding_box_set (self ):
135+ """Return True if the bounding box has been explicitly set by the user."""
136+ return bool (self ._bounding_box_set )
137+
131138 def set_fault_trace_layer_callback (self , callback ):
132139 """Set the callback for when the fault trace layer is updated."""
133140 self .fault_traces_callback = callback
@@ -162,6 +169,7 @@ def get_bounding_box(self):
162169 """Get the current bounding box."""
163170 return self ._bounding_box
164171
172+
165173 def set_elevation (self , elevation ):
166174 """Set the elevation for the model."""
167175 self .elevation = elevation
@@ -457,6 +465,7 @@ def to_dict(self):
457465
458466 return {
459467 'bounding_box' : self ._bounding_box .to_dict (),
468+ 'bounding_box_set' : self ._bounding_box_set ,
460469 'basal_contacts' : basal_contacts ,
461470 'fault_traces' : fault_traces ,
462471 'structural_orientations' : structural_orientations ,
@@ -478,6 +487,7 @@ def from_dict(self, data):
478487 ymax = data ['bounding_box' ]['maximum' ][1 ],
479488 zmin = data ['bounding_box' ]['origin' ][2 ],
480489 zmax = data ['bounding_box' ]['maximum' ][2 ],
490+ mark_set = data .get ('bounding_box_set' , True ),
481491 )
482492 if 'dem_layer' in data and data ['dem_layer' ] is not None :
483493 dem_layer = QgsProject .instance ().mapLayersByName (data ['dem_layer' ])
@@ -512,9 +522,10 @@ def update_from_dict(self, data):
512522 ymax = data ['bounding_box' ]['maximum' ][1 ],
513523 zmin = data ['bounding_box' ]['origin' ][2 ],
514524 zmax = data ['bounding_box' ]['maximum' ][2 ],
525+ mark_set = data .get ('bounding_box_set' , True ),
515526 )
516527 else :
517- self .set_bounding_box (** default_bounding_box )
528+ self .set_bounding_box (** default_bounding_box , mark_set = False )
518529 if 'dem_layer' in data and data ['dem_layer' ] is not None :
519530 dem_layer = QgsProject .instance ().mapLayersByName (data ['dem_layer' ])
520531 if dem_layer :
0 commit comments