Esempio n. 1
0
def explore(cs, proxies, iSave=True, currentTime=None, userDefined={}):
    """
    Runs a pipeline through all the changes we know how to make and saves off
    images into the store for each one.
    """
    #    import pv_explorers
    import explorers

    view_proxy = paraview.simple.GetActiveView()
    dist = paraview.simple.GetActiveCamera().GetDistance()

    #associate control points wlth parameters of the data store
    cam = pv_explorers.Camera([0, 0, 0], [0, 1, 0], dist, view_proxy)

    params = cs.parameter_list.keys()

    tracks = []
    tracks.append(cam)

    cols = []

    ctime_float = None
    if currentTime:
        ctime_float = float(currentTime['time'])

    #hide all annotations
    view_proxy.OrientationAxesVisibility = 0

    for x in proxies:
        name = x['name']
        for y in params:

            if (y in explorerDir) and (name == y):
                #print "name in ExplorerDir: ", y, ", ", explorerDir[y]
                tracks.append(explorerDir[y])

            if name in y:
                #print "N", name
                #print "X", x
                #print "Y", y

                #visibility of the layer
                sp = paraview.simple.FindSource(name)
                rep = paraview.simple.GetRepresentation(sp, view_proxy)

                #hide all annotations
                if rep.LookupTable:
                    rep.SetScalarBarVisibility(view_proxy, False)
                tc1 = pv_explorers.SourceProxyInLayer(name, rep)
                lt = explorers.Layer('vis', [tc1])
                tracks.append(lt)

                #fields for the layer
                cC = pv_explorers.ColorList()
                cC.AddDepth('depth')
                cC.AddLuminance('luminance')
                sp.UpdatePipeline(ctime_float)

                numVals = 0
                if rep.Representation != 'Outline':
                    numVals = explore_customized_array_selection(
                        name, sp, cC, userDefined)

                if numVals == 0:
                    cC.AddSolidColor('white', [1, 1, 1])
                col = pv_explorers.Color("color" + name, cC, rep)
                tracks.append(col)
                cols.append(col)

    e = pv_explorers.ImageExplorer(cs, params, tracks, view_proxy, iSave)

    for c in cols:
        c.imageExplorer = e

    times = paraview.simple.GetAnimationScene().TimeKeeper.TimestepValues
    if not times:
        e.explore(currentTime)
    else:
        for t in times:
            view_proxy.ViewTime = t
            e.explore({'time': float_limiter(t)})
Esempio n. 2
0
def explore(cs, proxies, iSave=True, currentTime=None):
    """
    Takes in the store, which contains only the list of parameters,
    """
#    import pv_explorers
    import explorers

    view_proxy = paraview.simple.GetActiveView()
    dist = paraview.simple.GetActiveCamera().GetDistance()

    #associate control points wlth parameters of the data store
    cam = pv_explorers.Camera([0,0,0], [0,1,0], dist, view_proxy)

    params = cs.parameter_list.keys()

    tracks = []
    tracks.append(cam)

    cols = []

    ctime_float=None
    if currentTime:
        ctime_float = float(currentTime['time'])

    #hide all annotations
    view_proxy.OrientationAxesVisibility = 0

    for x in proxies:
        name = x['name']
        for y in params:

            if (y in explorerDir) and (name == y):
                #print "name in ExplorerDir: ", y, ", ", explorerDir[y]
                tracks.append(explorerDir[y])

            if name in y:
                #print "N", name
                #print "X", x
                #print "Y", y

                #visibility of the layer
                sp = paraview.simple.FindSource(name)
                rep = paraview.simple.GetRepresentation(sp, view_proxy)

                #hide all annotations
                if rep.LookupTable:
                    rep.SetScalarBarVisibility(view_proxy, False)
                tc1 = pv_explorers.SourceProxyInLayer(name, rep)
                lt = explorers.Layer('vis', [tc1])
                tracks.append(lt)

                #fields for the layer
                cC = pv_explorers.ColorList()
                cC.AddDepth('depth')
                cC.AddLuminance('luminance')
                sp.UpdatePipeline(ctime_float)
                cda = sp.GetCellDataInformation()

                numVals = 0
                if rep.Representation != 'Outline':
                    for a in range(0, cda.GetNumberOfArrays()):
                        arr = cda.GetArray(a)
                        arrName = arr.GetName()
                        if not arrName == "Normals":
                            for i in range(0,arr.GetNumberOfComponents()):
                                numVals+=1
                                cC.AddValueRender(arrName+"_"+str(i),
                                                True,
                                                arrName,
                                                i, arr.GetRange(i))
                    pda = sp.GetPointDataInformation()
                    for a in range(0, pda.GetNumberOfArrays()):
                        arr = pda.GetArray(a)
                        arrName = arr.GetName()
                        if not arrName == "Normals":
                            for i in range(0,arr.GetNumberOfComponents()):
                                numVals+=1
                                cC.AddValueRender(arrName+"_"+str(i),
                                                False,
                                                arrName,
                                                i, arr.GetRange(i))
                if numVals == 0:
                    cC.AddSolidColor('white', [1,1,1])
                col = pv_explorers.Color("color"+name, cC, rep)
                tracks.append(col)
                cols.append(col)

    e = pv_explorers.ImageExplorer(cs, params,
                                   tracks,
                                   view_proxy,
                                   iSave)

    for c in cols:
        c.imageExplorer = e

    times = paraview.simple.GetAnimationScene().TimeKeeper.TimestepValues
    if not times:
        e.explore(currentTime)
    else:
        for t in times:
            view_proxy.ViewTime=t
            e.explore({'time':float_limiter(t)})
Esempio n. 3
0
def explore(cs,
            proxies,
            iSave=True,
            currentTime=None,
            userDefined={},
            specLevel="A",
            camType='phi-theta',
            tracking={},
            floatValues=True):
    """
    Runs a pipeline through all the changes we know how to make and saves off
    images into the store for each one.
    """
    #    import pv_explorers
    import explorers

    view_proxy = paraview.simple.GetActiveView()
    dist = paraview.simple.GetActiveCamera().GetDistance()

    #associate control points with parameters of the data store
    params = cs.parameter_list.keys()
    tracks = []
    if camType == 'static':
        pass
    elif camType == "phi-theta":
        up = [math.fabs(x) for x in view_proxy.CameraViewUp]
        uppest = 0
        if up[1] > up[uppest]: uppest = 1
        if up[2] > up[uppest]: uppest = 2
        cinup = [0, 0, 0]
        cinup[uppest] = 1
        cam = pv_explorers.Camera(view_proxy.CameraFocalPoint, cinup, dist,
                                  view_proxy)
        tracks.append(cam)
    else:
        cam = pv_explorers.PoseCamera(view_proxy, camType, cs)
        tracks.append(cam)

    cols = []

    ctime_float = None
    if currentTime:
        ctime_float = float(currentTime['time'])

    #hide all annotations
    view_proxy.OrientationAxesVisibility = 0

    for x in proxies:
        name = x['name']
        for y in params:

            if (y in explorerDir) and (name == y):
                #print ("name in ExplorerDir: ", y, ", ", explorerDir[y])
                tracks.append(explorerDir[y])

            if name in y:
                #print ("N", name)
                #print ("X", x)
                #print ("Y", y)

                #visibility of the layer
                sp = paraview.simple.FindSource(name)
                if specLevel == "A":
                    pass
                else:
                    rep = paraview.servermanager.GetRepresentation(
                        sp, view_proxy)

                    #hide all annotations
                    if rep.LookupTable:
                        rep.SetScalarBarVisibility(view_proxy, False)
                    tc1 = pv_explorers.SourceProxyInLayer(name, rep)
                    lt = explorers.Layer('vis', [tc1])
                    tracks.append(lt)

                    #fields for the layer
                    cC = pv_explorers.ColorList()
                    cC.AddDepth('depth')
                    cC.AddLuminance('luminance')

                sp.UpdatePipeline(ctime_float)

                if specLevel == "A":
                    pass
                else:
                    numVals = 0
                    if rep.Representation != 'Outline':
                        numVals = explore_customized_array_selection(
                            name, sp, cC, userDefined)

                    if numVals == 0:
                        cC.AddSolidColor('white', [1, 1, 1])
                    col = pv_explorers.Color("color" + name, cC, rep)
                    tracks.append(col)
                    cols.append(col)

    e = pv_explorers.ImageExplorer(cs, params, tracks, view_proxy, iSave)
    e.enableFloatValues(floatValues)

    for c in cols:
        c.imageExplorer = e

    eye_values = cs.metadata['camera_eye']
    at_values = cs.metadata['camera_at']
    up_values = cs.metadata['camera_up']

    eye = [x for x in view_proxy.CameraPosition]
    _fp = [x for x in view_proxy.CameraFocalPoint]
    _cr = [x for x in view_proxy.CenterOfRotation]
    at = project_to_at(eye, _fp, _cr)
    up = [x for x in view_proxy.CameraViewUp]
    times = paraview.simple.GetAnimationScene().TimeKeeper.TimestepValues

    #if tracking is turned on, find out how to move
    tracked_source = None
    if 'object' in tracking:
        #for now, just emulate animation's best mode with a mode that follows
        #an object
        objname = tracking['object']
        tracked_source = paraview.simple.FindSource(objname)
        if tracked_source is None:
            name_upper = objname[0].upper() + objname[1:]
            tracked_source = paraview.simple.FindSource(name_upper)

    if not times:
        eye, at, up = track_source(tracked_source, eye, at, up)
        eye_values.append([x for x in eye])
        at_values.append([x for x in at])
        up_values.append([x for x in up])
        cs.add_metadata({'camera_eye': eye_values})
        cs.add_metadata({'camera_at': at_values})
        cs.add_metadata({'camera_up': up_values})
        e.explore(currentTime)
    else:
        for t in times:
            view_proxy.ViewTime = t
            paraview.simple.Render(view_proxy)
            minbds, maxbds = max_bounds()
            view_proxy.MaxClipBounds = [
                minbds, maxbds, minbds, maxbds, minbds, maxbds
            ]
            eye, at, up = track_source(tracked_source, eye, at, up)
            eye_values.append([x for x in eye])
            at_values.append([x for x in at])
            up_values.append([x for x in up])
            cs.add_metadata({'camera_eye': eye_values})
            cs.add_metadata({'camera_at': at_values})
            cs.add_metadata({'camera_up': up_values})
            e.explore({'time': float_limiter(t)})