@@ -119,6 +119,7 @@ def __init__( self, **args ):
119119 self .cs_bbar = None
120120 self .probeFilter = None
121121 self .cursorActor = vtk .vtkActor ()
122+ self .clipPlanes = vtk .vtkPlanes ()
122123
123124 self .pipelineDebug = False
124125
@@ -136,7 +137,6 @@ def __init__( self, **args ):
136137 self .clipping_enabled = False
137138 self .cropRegion = None
138139 self .cropZextent = None
139- self .clipper = None
140140 self .volRenderConfig = [ 'Default' , 'False' ]
141141 self .transFunctGraphVisible = False
142142 self .transferFunctionConfig = None
@@ -429,18 +429,19 @@ def processScaleChange( self, old_spacing, new_spacing ):
429429 if ( self .planeWidgetZ <> None ) and self .planeWidgetZ .IsVisible ():
430430# print " Update planeWidgetZ "
431431 self .planeWidgetZ .UpdateInputs ()
432+
433+ def initializeClipper (self ):
434+ if ( self .cropRegion == None ):
435+ self .cropRegion = self .getVolumeBounds ()
436+ if self .clipper :
437+ if ( self .renderWindowInteractor <> None ):
438+ self .clipper .SetInteractor ( self .renderWindowInteractor )
439+ self .clipper .PlaceWidget ( self .cropRegion )
440+ self .clipper .GetPlanes ( self .clipPlanes )
432441
433442 def activateEvent ( self , caller , event ):
434443 StructuredGridPlot .activateEvent ( self , caller , event )
435- if self .clipper and ( self .cropRegion == None ):
436- self .renwin = self .renderer .GetRenderWindow ( )
437- if self .renwin <> None :
438- if ( self .renderWindowInteractor <> None ):
439- self .clipper .SetInteractor ( self .renderWindowInteractor )
440- self .cropRegion = self .getVolumeBounds ()
441- self .clipper .PlaceWidget ( self .cropRegion )
442- self .clipPlanes = vtk .vtkPlanes ()
443- self .clipper .GetPlanes ( self .clipPlanes )
444+ self .initializeClipper ()
444445 self .render ()
445446
446447 def getVolumeBounds ( self , ** args ):
@@ -1045,6 +1046,7 @@ def processToggleClippingCommand( self, args, config_function ):
10451046 elif args and args [0 ] == "Init" :
10461047 plane_positions = config_function .initial_value
10471048 if (plane_positions <> None ):
1049+ if not self .cropRegion : self .initializeClipper ()
10481050 for ip , pval in enumerate ( plane_positions ):
10491051 self .cropRegion [ip ] = pval
10501052 self .clipper .PlaceWidget ( self .cropRegion )
@@ -1064,7 +1066,7 @@ def endClip( self, caller=None, event=None ):
10641066 def executeClip ( self , caller = None , event = None ):
10651067 np = 6
10661068 self .clipper .GetPlanes ( self .clipPlanes )
1067- if not self .cropRegion : self .cropRegion = [ 0.0 ] * np
1069+ if not self .cropRegion : self .initializeClipper ()
10681070 for ip in range ( np ):
10691071 plane = self .clipPlanes .GetPlane ( ip )
10701072 o = plane .GetOrigin ()
0 commit comments