Salome HOME
Getting rid of vtkEDFCutter.
[modules/paravis.git] / src / Macro / modes.py
index db4b623bb10c7fa67313c602bf51ef20d259783f..eaf168fb8cd559c51cdf241179e14ce0d27e0af0 100644 (file)
@@ -1,9 +1,9 @@
-# Copyright (C) 2010-2012  CEA/DEN, EDF R&D
+# Copyright (C) 2010-2014  CEA/DEN, EDF R&D
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
 # License as published by the Free Software Foundation; either
-# version 2.1 of the License.
+# version 2.1 of the License, or (at your option) any later version.
 #
 # This library is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -21,11 +21,16 @@ try: paraview.simple
 except: from paraview.simple import *
 paraview.simple._DisableFirstRenderCameraReset()
 
+import sys
+
 source = GetActiveSource()
 representation = GetDisplayProperties(source)
 representation.Visibility = 0
 
+oldmode = None
+
 if source.SMProxy.GetVTKClassName() == 'vtkMedReader' :
+  oldmode = source.AnimationMode
   source.AnimationMode = 'Modes'
 
 ExtractSurface1 = ExtractSurface()
@@ -52,42 +57,45 @@ for arrayid in range(0, pinfo.GetNumberOfArrays()) :
     WarpByVector1.Vectors = ['POINTS', rootname]
     break
 
-ScaleVector1.ScaleFactor = 0
-ScaleVector1.UpdatePipeline()
-bounds = info.DataInformation.GetBounds()
-side = [bounds[1] - bounds[0], bounds[3] - bounds[2], bounds[5] - bounds[4]]
-length = side[0]
-if side[1] > length : length = side[1] 
-if side[2] > length : length = side[2] 
-
-scale = length / 20
-if vectorname != None :
-  arrayrange = arrayinfo.GetComponentRange(-1)
-  if arrayrange[1] > 0 :
-    scale = scale / arrayrange[1]
-
-WarpByVector1.ScaleFactor = scale
-
-AnimationScene1 = GetAnimationScene()
-
-TimeAnimationCue1 = GetTimeTrack()
-TimeAnimationCue1.Enabled = 0
+if vectorname == None :
+  source.AnimationMode = oldmode
+else :
+  ScaleVector1.ScaleFactor = 0
+  ScaleVector1.UpdatePipeline()
+  bounds = info.DataInformation.GetBounds()
+  side = [bounds[1] - bounds[0], bounds[3] - bounds[2], bounds[5] - bounds[4]]
+  length = side[0]
+  if side[1] > length : length = side[1] 
+  if side[2] > length : length = side[2] 
 
-KeyFrameAnimationCue1 = GetAnimationTrack( ScaleVector1.GetProperty('ScaleFactor'))
-KeyFrame0 = CompositeKeyFrame( KeyValues=[1.0], Interpolation='Sinusoid' )
-KeyFrame1 = CompositeKeyFrame( KeyTime=1.000000001, KeyValues=[1.0] )
+  scale = length / 20
+  if vectorname != None :
+    arrayrange = arrayinfo.GetComponentRange(-1)
+    if arrayrange[1] > 0 :
+      scale = scale / arrayrange[1]
+  
+  WarpByVector1.ScaleFactor = scale
+  
+  AnimationScene1 = GetAnimationScene()
 
-KeyFrameAnimationCue1.KeyFrames = [ KeyFrame0, KeyFrame1 ]
+  TimeAnimationCue1 = GetTimeTrack()
+  TimeAnimationCue1.Enabled = 0
 
-AnimationScene1.Cues.append(KeyFrameAnimationCue1)
-AnimationScene1.Loop = 1
-AnimationScene1.PlayMode = 'Sequence'
-AnimationScene1.NumberOfFrames = 21
+  KeyFrameAnimationCue1 = GetAnimationTrack( ScaleVector1.GetProperty('ScaleFactor'))
+  KeyFrame0 = CompositeKeyFrame( KeyValues=[1.0], Interpolation='Sinusoid' )
+  KeyFrame1 = CompositeKeyFrame( KeyTime=1.000000001, KeyValues=[1.0] )
 
-WarpByVectorDataRepresentation = Show(WarpByVector1)
-if rootname != None :
-  pvLookupTable = GetLookupTableForArray( rootname, 3, VectorMode='Magnitude' )
-  WarpByVectorDataRepresentation.ColorArrayName = rootname
-  WarpByVectorDataRepresentation.LookupTable = pvLookupTable
+  KeyFrameAnimationCue1.KeyFrames = [ KeyFrame0, KeyFrame1 ]
 
-AnimationScene1.Play()
+  AnimationScene1.Cues.append(KeyFrameAnimationCue1)
+  AnimationScene1.Loop = 1
+  AnimationScene1.PlayMode = 'Sequence'
+  AnimationScene1.NumberOfFrames = 21
+  
+  WarpByVectorDataRepresentation = Show(WarpByVector1)
+  if rootname != None :
+    pvLookupTable = GetLookupTableForArray( rootname, 3, VectorMode='Magnitude' )
+    WarpByVectorDataRepresentation.ColorArrayName = rootname
+    WarpByVectorDataRepresentation.LookupTable = pvLookupTable
+  
+  AnimationScene1.Play()