Skip to content

Commit fb3287b

Browse files
committed
Addressed @dlonie comments, thanks!
1 parent 7c420bb commit fb3287b

4 files changed

Lines changed: 14 additions & 41 deletions

File tree

Packages/vcs/Lib/VTKAnimate.py

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@ def __init__(self, controller):
1414
self.controller = controller
1515

1616
def run(self):
17-
#self.describe()
1817
self.controller.animation_created = True
1918
self.controller._unique_prefix=hashlib.sha1(time.asctime()+str(random.randint(0,10000))).hexdigest()
20-
#print "NFRAMES:",self.controller.number_of_frames()
2119

2220
def describe(self):
2321
for info in self.controller.animate_info:
@@ -33,7 +31,6 @@ def describe(self):
3331
class VTKAnimationPlayback(animate_helper.AnimationPlayback):
3432
def __init__(self, controller):
3533
animate_helper.AnimationPlayback.__init__(self,controller)
36-
pass
3734

3835
class VTKAnimate(animate_helper.AnimationController):
3936
def __init__(self,vcs_self):
@@ -44,9 +41,8 @@ def __init__(self,vcs_self):
4441
import atexit
4542
atexit.register(self.close)
4643
def draw_frame(self):
47-
#print "Drawing frame:",self.frame_num,self._unique_prefix
4844
png_name=os.path.join(os.environ["HOME"],".uvcdat",self._unique_prefix,"anim_%i.png" % self.frame_num)
49-
if os.path.exists(png_name) and len(self.animation_files)==self.number_of_frames():# and self.playback_params.zoom_factor!=1:
45+
if os.path.exists(png_name) and len(self.animation_files)==self.number_of_frames():
5046
## Ok we have the pngs and we need to zoom, need to use png
5147
## maybe the zoom factor thing can be taken off, not sure what's faster
5248
if not self.cleared:
@@ -66,24 +62,20 @@ def draw_frame(self):
6662
continue # nothing to do
6763
#Ok we have a slab, let's figure which slice it is
6864
args=[]
69-
N=1
65+
Ntot=1
7066
for a in slab.getAxisList()[:-self._number_of_dims_used_for_plot][::-1]:
71-
n=self.frame_num/N % len(a)
72-
N*=len(a)
67+
n=self.frame_num/Ntot % len(a)
68+
Ntot*=len(a)
7369
args.append(slice(n,n+1))
7470
args=args[::-1]
75-
#if self.frame_num == 0:
76-
#print "NFrame <-> args: %i <-> %s" % (self.frame_num,args)
77-
#print "BE ANIM:",disp.backend
7871
if slabs[1] is None:
7972
self.vcs_self.backend.update_input(disp.backend,slab(*args),update=True)
8073
else:
8174
self.vcs_self.backend.update_input(disp.backend,slab(*args),slabs[1](*args),update=True)
8275
self.vcs_self.backend.renWin.Render()
83-
if not os.path.exists(png_name):
84-
if not os.path.exists(os.path.dirname(png_name)):
85-
os.makedirs(os.path.dirname(png_name))
86-
self.vcs_self.png(png_name)
87-
self.animation_files = sorted(glob.glob(os.path.join(os.path.dirname(png_name),"*.png")))
76+
if not os.path.exists(os.path.dirname(png_name)):
77+
os.makedirs(os.path.dirname(png_name))
78+
self.vcs_self.png(png_name)
79+
self.animation_files = sorted(glob.glob(os.path.join(os.path.dirname(png_name),"*.png")))
8880
if self.signals is not None:
8981
self.signals.drawn.emit(self.frame_num)

Packages/vcs/Lib/VTKPlots.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,7 @@ def plotVector(self,data1,data2,tmpl,gm,vtk_backend_grid=None,vtk_backend_geo=No
626626
returned["vtk_backend_grid"]=vtk_backend_grid
627627
returned["vtk_backend_geo"]=geo
628628
missingMapper = vcs2vtk.putMaskOnVTKGrid(data1,vtk_backend_grid,None,False,deep=False)
629+
#None/False are for color and cellData (sent to vcs2vtk.putMaskOnVTKGrid)
629630
returned["vtk_backend_missing_mapper"]=missingMapper,None,False
630631

631632
w=vcs2vtk.generateVectorArray(data1,data2,vtk_backend_grid)
@@ -1158,8 +1159,6 @@ def plotContinents(self,x1,x2,y1,y2,projection,wrap,tmpl):
11581159
contActor.GetProperty().SetColor(0.,0.,0.)
11591160
else:
11601161
geo=None
1161-
#contMapper.SetResolveCoincidentTopologyPolygonOffsetParameters(1, 1)
1162-
#contMapper.SetResolveCoincidentTopologyToPolygonOffset()
11631162

11641163
ren = self.fitToViewport(contActor,[tmpl.data.x1,tmpl.data.x2,tmpl.data.y1,tmpl.data.y2],wc=[x1,x2,y1,y2],geo=geo)
11651164
if tmpl.data.priority!=0:
@@ -1626,30 +1625,26 @@ def fitToViewport(self,Actor,vp,wc=None,geo=None):
16261625
if flipX:
16271626
cam.Azimuth(180.)
16281627
return Renderer
1628+
16291629
def update_input(self,vtkobjects,array1,array2=None,update=True):
16301630
if vtkobjects.has_key("vtk_backend_grid"):
1631-
#print "ok?"
16321631
## Ok ths is where we update the input data
16331632
vg=vtkobjects["vtk_backend_grid"]
16341633
data = vcs2vtk.numpy_to_vtk_wrapper(array1.filled(0.).flat, deep=False)
16351634
pData= vg.GetPointData().GetScalars()
16361635
if pData is not None:
1637-
#print "OK HERE"
16381636
vg.GetPointData().SetScalars(data)
16391637
else:
1640-
#print "OK HERE 2",array1.shape
16411638
vg.GetCellData().SetScalars(data)
16421639
if vtkobjects.has_key("vtk_backend_filter"):
1643-
#print "FILTER"
16441640
vtkobjects["vtk_backend_filter"].Update()
16451641
if vtkobjects.has_key("vtk_backend_missing_mapper"):
16461642
missingMapper,color,cellData = vtkobjects["vtk_backend_missing_mapper"]
16471643
missingMapper2 = vcs2vtk.putMaskOnVTKGrid(array1,vg,color,cellData,deep=False)
16481644
else:
16491645
missingMapper = None
16501646
if vtkobjects.has_key("vtk_backend_contours"):
1651-
for i,c in enumerate(vtkobjects["vtk_backend_contours"]):
1652-
#print "UPING"
1647+
for c in vtkobjects["vtk_backend_contours"]:
16531648
c.Update()
16541649
ports=vtkobjects["vtk_backend_contours"]
16551650
elif vtkobjects.has_key("vtk_backend_geofilters"):
@@ -1685,7 +1680,6 @@ def update_input(self,vtkobjects,array1,array2=None,update=True):
16851680
a[0].SetMapper(act.GetMapper())
16861681
i+=1
16871682

1688-
#vtkobjects["vtk_backend_wrapped_actor"].Update()
16891683
taxis = array1.getTime()
16901684
if taxis is not None:
16911685
tstr = str(cdtime.reltime(taxis[0],taxis.units).tocomp(taxis.getCalendar()))

Packages/vcs/Lib/animate_helper.py

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ class animate_obj_old(object):
3636
##############################################################################
3737
# Initialize the animation flags #
3838
##############################################################################
39-
def __del__(self):
40-
print "Deleting the animation"
4139
def __init__(self, vcs_self):
4240
self.vcs_self = vcs_self
4341
self.gui_popup = 0
@@ -598,8 +596,6 @@ def __init__(self):
598596
self._stop = threading.Event()
599597
self._running = threading.Event()
600598
self._running.set()
601-
def __del__(self):
602-
print "IN DEL"
603599
def stop(self):
604600
self._stop.set()
605601

@@ -638,7 +634,6 @@ def run(self):
638634
if self.is_stopped():
639635
break
640636
self.wait_if_paused()
641-
# print "RENDERING FRAME", i, "OF", len(all_args)
642637
if self._really_used!=[]:
643638
for j,a in enumerate(args):
644639
args[j]=a[:-3]+self._really_used[j]
@@ -674,7 +669,7 @@ def fps(self, value=None):
674669
675670
"""
676671
if value is not None:
677-
#value = max(value, 0.5)
672+
value = max(value, 0.5)
678673
self.frames_per_second = value
679674
return self
680675
return self.frames_per_second
@@ -782,10 +777,8 @@ def is_playing(self):
782777
return self.playback_running
783778

784779
def playback(self):
785-
#print "CREATED:",self.created()
786780
if (self.created() and
787781
(self.playback_thread is None or not self.playback_thread.is_alive())):
788-
#print "Starting playback"
789782
self.playback_thread = self.AnimationPlayback(self)
790783
self.playback_thread.start()
791784

@@ -892,12 +885,10 @@ def generate_number_of_frames(self):
892885
if slabs[0] is None:
893886
## Nothing to do
894887
continue
895-
#print "SLAB:",slabs[0].shape
896888
if disp.g_type == "meshfill":
897889
try:
898890
g=slabs[0].getGrid()
899891
NXY=len(g.shape)
900-
#print "GRID NX:",NXY
901892
except:
902893
## No grid so slab1 rnk will tell us
903894
NXY=slabs[1].ndim-2 # lat/lon/vertices
@@ -910,7 +901,6 @@ def generate_number_of_frames(self):
910901
n=1
911902
for a in slabs[0].getAxisList()[:NXtraDims]:
912903
n*=len(a)
913-
#print "This plot defines:",n,"frames"
914904
# We truncate to mininum number of common frames
915905
NFrames = min(n,NFrames)
916906
self._number_of_frames = NFrames
@@ -962,8 +952,6 @@ def get_all_frame_args(self):
962952
break
963953
args.append(I[1][1](**kw))
964954
args += [d.template,d.g_type,d.g_name]
965-
#b=y.getboxfill(d.g_name)
966-
#y.plot(*args,bg=1)
967955
frameArgs.append(args)
968956
all_args.append(frameArgs)
969957
return all_args
@@ -987,7 +975,6 @@ def render_frame(self, frame_args, frame_num, frame_kargs=[]):
987975
# and prevents segfaults when running multiple animations
988976
#self.vcs_self.replot()
989977

990-
#print "*************************************************************"
991978
self.create_canvas.clear()
992979
displays = []
993980
#checks = ["template","marker","texttable","textorientation","boxfill","isofill","isoline","line","textcombined"]
@@ -1011,7 +998,6 @@ def render_frame(self, frame_args, frame_num, frame_kargs=[]):
1011998
return displays
1012999

10131000
def draw_frame(self):
1014-
#print "drawing frame:",frame_num
10151001
if frame_num is not None:
10161002
self.frame_num = frame_num
10171003
self.vcs_self.backend.clear()
@@ -1039,7 +1025,6 @@ def save(self,movie,bitrate=1024, rate=None, options=''):
10391025
if rate is None:
10401026
rate = self.playback_params.fps()
10411027
files = os.path.join(os.path.dirname(self.animation_files[0]),"anim_%d.png")
1042-
print files
10431028
self.vcs_self.ffmpeg(movie, files, bitrate, rate, options)
10441029

10451030
def fps(self, value=None):

Packages/vcs/Lib/vcs2vtk.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,6 +1319,7 @@ def starPoints(radius_outer, x, y, number_points = 5):
13191319

13201320
theta += delta_theta
13211321
return points
1322+
13221323
def generateVectorArray(data1,data2,vtk_grid):
13231324
u=numpy.ma.ravel(data1)
13241325
v=numpy.ma.ravel(data2)
@@ -1348,6 +1349,7 @@ def generateVectorArray(data1,data2,vtk_grid):
13481349
w = numpy_to_vtk_wrapper(w,deep=False)
13491350
w.SetName("vectors")
13501351
return w
1352+
13511353
def stripGrid(vtk_grid):
13521354
# Strip out masked points.
13531355
if vtk_grid.IsA("vtkStructuredGrid"):

0 commit comments

Comments
 (0)