def playForward(event=None):
    if CTK.t == []: return
    walls = VARS[3].get()
    t0 = CTK.varsFromWidget(VARS[0].get(), type=1)[0]
    time = CTK.varsFromWidget(VARS[1].get(), type=1)[0]
    tf = CTK.varsFromWidget(VARS[2].get(), type=1)[0]
    step = (tf - t0) / 100.

    if CTK.__MAINTREE__ == 1:
        CTK.__MAINACTIVEZONES__ = CPlot.getActiveZones()

    if (walls == '1' and CTK.dt == []):
        zones = Internal.getNodesFromType(CTK.t, 'Zone_t')
        Z = buildWalls(zones)
        CTK.dt = C.newPyTree(['Base'])
        CTK.dt[2][1][2] += Z

    CTK.__BUSY__ = True
    CPlot.setState(cursor=2)
    while (time < tf and CTK.__BUSY__):
        if (walls == '1'): temp = RM.evalPosition(CTK.dt, time)
        else: temp = RM.evalPosition(CTK.t, time)
        CTK.display(temp, mainTree=CTK.TIME)
        time += step
        VARS[1].set(str(time))
        WIDGETS['slider'].set((time - t0) / step)
        WIDGETS['time'].update()
        WIDGETS['slider'].update()
    CTK.__BUSY__ = False
    CPlot.setState(cursor=0)
def setTime(event=None):
    if CTK.t == []: return
    walls = VARS[3].get()
    time = CTK.varsFromWidget(VARS[1].get(), type=1)
    if len(time) != 1:
        CTK.TXT.insert('START', 'Invalid time.\n')
        CTK.TXT.insert('START', 'Error: ', 'Error')
        return
    time = time[0]
    t0 = CTK.varsFromWidget(VARS[0].get(), type=1)[0]
    tf = CTK.varsFromWidget(VARS[2].get(), type=1)[0]
    step = (tf - t0) / 100.

    if CTK.__MAINTREE__ == 1:
        CTK.__MAINACTIVEZONES__ = CPlot.getActiveZones()
    if walls == '1' and CTK.dt == []:
        zones = Internal.getZones(CTK.t)
        Z = buildWalls(zones)
        CTK.dt = C.newPyTree(['Base'])
        CTK.dt[2][1][2] += Z

    if walls == '1': temp = RM.evalPosition(CTK.dt, time)
    else: temp = RM.evalPosition(CTK.t, time)

    WIDGETS['slider'].set((time - t0) / step)
    WIDGETS['slider'].update()
    CTK.display(temp, mainTree=CTK.TIME)
Beispiel #3
0
def extract():
    if CTK.t == []: return
    type = VARS[0].get()

    if CTK.__MAINTREE__ == 1:
        CTK.__MAINACTIVEZONES__ = CPlot.getActiveZones()

    active = []
    zones = Internal.getZones(CTK.t)
    for z in CTK.__MAINACTIVEZONES__:
        active.append(CTK.t[2][CTK.Nb[z] + 1][2][CTK.Nz[z]])

    Z = None
    if type == 'cellN=-99999':
        Z = selectWithFormula(active, '{cellN} == -99999')
    elif type == 'cellN=1':
        Z = selectWithFormula(active, '{cellN} == 1')
    elif type == 'cellN=0':
        Z = selectWithFormula(active, '{cellN} == 0')
    elif type == 'cellN=2':
        Z = selectWithFormula(active, '{cellN} == 2')
    elif type == 'cellN<0':
        Z = selectWithFormula(active, '{cellN}<0')
    elif type == '0<cellN<1':
        Z = selectWithFormula(active, '({cellN}>0) & ({cellN}<1)')
    elif type == 'Interpolated points':
        Z = X.extractChimeraInfo(zones, type='interpolated', loc='centers')
        if Z == []: Z = None
    elif type == 'Extrapolated points':
        Z = X.extractChimeraInfo(zones, type='extrapolated', loc='centers')
        if Z == []: Z = None
    elif type == 'Orphan points':
        Z = X.extractChimeraInfo(zones, type='orphan', loc='centers')
        if Z == []: Z = None
    elif type == 'cf>1':
        Z = X.extractChimeraInfo(zones, type='cf>1', loc='centers')
        if Z == []: Z = None

    if Z is not None:
        CTK.TXT.insert('START', 'Filter ' + type + ' extracted.\n')
        C._addBase2PyTree(CTK.t, 'EXTRACT')
        b = Internal.getNodesFromName1(CTK.t, 'EXTRACT')
        base = b[0]
        base[2] += Z
        (CTK.Nb, CTK.Nz) = CPlot.updateCPlotNumbering(CTK.t)
        #C._fillMissingVariables(CTK.t)
        CTK.TKTREE.updateApp()
        CTK.display(CTK.t)
    else:
        CTK.TXT.insert('START', 'Nothing extracted.\n')
        CTK.TXT.insert('START', 'Error: ', 'Error')
Beispiel #4
0
def view():
    if CTK.t == []: return
    type = VARS[0].get()
    if type == 'Mesh':
        CTK.display(CTK.t)
        return

    if CTK.__MAINTREE__ == 1:
        CTK.__MAINACTIVEZONES__ = CPlot.getActiveZones()

    tp = Internal.appendBaseName2ZoneName(CTK.t, separator=Internal.SEP1)

    active = []
    zones = Internal.getZones(tp)
    for z in CTK.__MAINACTIVEZONES__:
        active.append(zones[z])

    Z = None
    if type == 'cf>1':
        Z = P.selectCells(active, Filter1, [
            'interpCoefs1', 'interpCoefs2', 'interpCoefs3', 'interpCoefs4',
            'interpCoefs5', 'interpCoefs6', 'interpCoefs7', 'interpCoefs8'
        ])
    elif type == 'cellN=-99999':
        Z = selectWithFormula(active, '{cellN} == -99999')
    elif type == 'cellN=1':
        Z = selectWithFormula(active, '{cellN} == 1')
    elif type == 'cellN=0':
        Z = selectWithFormula(active, '{cellN} == 0')
    elif type == 'cellN=2':
        Z = selectWithFormula(active, '{cellN} == 2')
    elif type == 'cellN<0':
        Z = selectWithFormula(active, '{cellN} < 0')
    elif type == '0<cellN<1':
        Z = selectWithFormula(active, '({cellN}>0) & ({cellN}<1)')
    elif type == 'Orphan points':
        Z = X.extractChimeraInfo(active, 'orphan')
    elif type == 'Extrapolated points':
        Z = X.extractChimeraInfo(active, 'extrapolated')

    if Z is not None:
        CTK.TXT.insert('START', 'Filter ' + type + ' displayed.\n')
        CTK.dt = C.newPyTree(['Base'])
        CTK.dt[2][1][2] += Z
        CTK.display(CTK.dt, mainTree=CTK.CELLN)
    else:
        CTK.TXT.insert('START', 'Nothing to display.\n')
        CTK.TXT.insert('START', 'Error: ', 'Error')
def viewQual():
    if CTK.t == []: return
    qtype = VARS[1].get()
    if qtype == 'Neg. volume cells':
        res = findVar('vol')
        if res == 0: CTK.t = G.getVolumeMap(CTK.t)
        if CTK.__MAINTREE__ == 1:
            CTK.__MAINACTIVEZONES__ = CPlot.getActiveZones()
        active = []
        zones = Internal.getZones(CTK.t)
        for z in CTK.__MAINACTIVEZONES__: active.append(CTK.t[2][CTK.Nb[z]+1][2][CTK.Nz[z]])

        temp = C.newPyTree(['Base']); temp[2][1][2] += active
        Z = C.initVars(temp, 'centers:__tag__', F1, ['centers:vol'])
        Z = P.selectCells2(Z, 'centers:__tag__')
        if Z is not None:
            CTK.TXT.insert('START', 'Viewing '+qtype+'.\n')
            CTK.dt = Z
            CTK.display(CTK.dt, mainTree=CTK.MESHQUAL)
    elif qtype == 'Mesh':
        CTK.display(CTK.t)
Beispiel #6
0
def check():
    if CTK.t == []: return

    node = Internal.getNodeFromName(CTK.t, 'EquationDimension')
    if node is not None: ndim = Internal.getValue(node)
    else:
        CTK.TXT.insert('START',
                       'EquationDimension not found (tkState). Using 3D.\n')
        CTK.TXT.insert('START', 'Warning: ', 'Warning')
        ndim = 3

    # Varie de 0 a 180 degres
    global __SPLITFACTOR__
    splitFactor = 180. - WIDGETS['splitFactor'].get() * 180. / 100.
    __SPLITFACTOR__ = splitFactor

    wins = C.getEmptyBC(CTK.t, ndim, splitFactor)
    if CTK.__MAINTREE__ == 1:
        CTK.__MAINACTIVEZONES__ = CPlot.getActiveZones()
    CTK.dt = C.newPyTree(['Base', 'Edges'])
    tp = Internal.appendBaseName2ZoneName(CTK.t,
                                          updateRef=False,
                                          separator=Internal.SEP1,
                                          trailing=Internal.SEP1)
    bases = Internal.getBases(tp)
    nb = 0
    for b in bases:
        nodes = Internal.getNodesFromType1(b, 'Zone_t')
        nz = 0
        for z in nodes:
            ztype = Internal.getZoneType(z)
            winz = wins[nb][nz]
            if ztype == 1:  # structure
                for w in winz:
                    imin = w[0]
                    imax = w[1]
                    jmin = w[2]
                    jmax = w[3]
                    kmin = w[4]
                    kmax = w[5]
                    zp = T.subzone(z, (imin, jmin, kmin), (imax, jmax, kmax))
                    CTK.dt[2][1][2].append(zp)
            else:  # non structure
                for w in winz:
                    zp = T.subzone(z, w, type='faces')
                    CTK.dt[2][1][2].append(zp)
            nz += 1
        nb += 1

    if VARS[7].get() == '1':  # display les edges des zones en +
        exts = []
        zones = Internal.getZones(tp)
        for z in zones:
            ztype = Internal.getZoneType(z)
            if ztype == 1:
                zp = P.exteriorFacesStructured(z)
                exts += zp
            else:
                #zp = P.exteriorFaces(z); zp = P.sharpEdges(zp)
                zp = []
                exts += zp
        CTK.dt[2][2][2] += exts
        #C._fillMissingVariables(CTK.dt) # bug exteriorFacesStruct

        # Activate
        lenZ = len(CTK.dt[2][1][2])
        lenExts = len(exts)
        active = [(i, 1) for i in range(lenZ + lenExts)]
        for i in range(lenZ):
            active[i] = (i, 1)
        for i in range(lenExts):
            active[i + lenZ] = (i + lenZ, 0)

        CTK.display(CTK.dt, mainTree=CTK.UNDEFINEDBC)
        CPlot.setActiveZones(active)
        CPlot.setState(edgifyDeactivatedZones=1)
    else:
        lenZ = len(CTK.dt[2][1][2])
        active = [(i, 1) for i in range(lenZ)]
        CTK.display(CTK.dt, mainTree=CTK.UNDEFINEDBC)
        CPlot.setActiveZones(active)

    # modifie la couleur du bouton
    l = len(Internal.getZones(CTK.dt))
    if l == 0: TTK.setButtonGreen(WIDGETS['undefinedBC'])
    else: TTK.setButtonRed(WIDGETS['undefinedBC'])
    WIDGETS['undefinedBC'].update()
Beispiel #7
0
def view(event=None):
    if CTK.t == []: return

    BCTypes = []
    selection = WIDGETS['BCLB'].curselection()
    for s in selection:
        t = WIDGETS['BCLB'].get(s)
        if t not in Internal.KNOWNBCS: t = 'FamilySpecified:' + t
        BCTypes.append(t)
    if 'FamilySpecified:-All BC-' in BCTypes: BCTypes = ['*']

    if CTK.__MAINTREE__ == 1:
        CTK.__MAINACTIVEZONES__ = CPlot.getActiveZones()

    tp = Internal.appendBaseName2ZoneName(CTK.t,
                                          updateRef=False,
                                          separator=Internal.SEP1)
    CTK.dt = C.newPyTree(['Base', 'Edges'])
    active = []
    for z in CTK.__MAINACTIVEZONES__:
        active.append(tp[2][CTK.Nb[z] + 1][2][CTK.Nz[z]])

    Z = []
    for t in BCTypes:
        Z += C.extractBCOfType(active, t, topTree=tp)
        if t == 'BCWall':  # Dans ce cas, affiche tous les types de BCWall
            Z += C.extractBCOfType(active, 'BCWallInviscid')
            Z += C.extractBCOfType(active, 'BCWallViscous')
            Z += C.extractBCOfType(active, 'BCWallViscousIsoThermal')
    CTK.dt[2][1][2] += Z

    if VARS[7].get() == '1':  # display les edges des zones en +
        exts = []
        for z in active:
            ztype = Internal.getZoneType(z)
            if ztype == 1:
                zp = P.exteriorFacesStructured(z)
                exts += zp
            else:
                #zp = P.exteriorFaces(z)
                #zp = P.sharpEdges(zp)
                zp = []
                exts += zp

        CTK.dt[2][2][2] += exts
        C._fillMissingVariables(CTK.dt)  # bug exteriorFaces

        # Activate
        lenZ = len(CTK.dt[2][1][2])
        lenExts = len(CTK.dt[2][2][2])
        active = [(i, 1) for i in range(lenZ + lenExts)]
        for i in range(lenZ):
            active[i] = (i, 1)
        for i in range(lenExts):
            active[i + lenZ] = (i + lenZ, 0)

        CTK.display(CTK.dt, mainTree=CTK.DEFINEDBC)
        CPlot.setActiveZones(active)
        CPlot.setState(edgifyDeactivatedZones=1)
    else:
        lenZ = len(CTK.dt[2][1][2])
        active = [(i, 1) for i in range(lenZ)]
        C._fillMissingVariables(CTK.dt)  # si BCDataSet != fields
        CTK.display(CTK.dt, mainTree=CTK.DEFINEDBC)
        CPlot.setActiveZones(active)
        CPlot.setState(edgifyDeactivatedZones=0)
Beispiel #8
0
def view(event=None):
    if CTK.t == []: return
    pos = float(VARS[1].get())
    global VALUE
    VALUE = pos
    delta = float(VARS[4].get())
    global DELTA
    DELTA = delta
    plane = VARS[0].get()
    order = int(VARS[3].get())
    eps = float(VARS[2].get())
    algo = VARS[5].get()

    nzs = CPlot.getSelectedZones()
    if nzs != []:
        point = CPlot.getActivePoint()
        if len(point) == 3:
            if plane == 'X': pos = point[0]
            elif plane == 'Y': pos = point[1]
            elif plane == 'Z': pos = point[2]
            VARS[1].set(str(pos))
            VALUE = pos

    if plane == 'Mesh':
        CTK.display(CTK.t)
        return
    try:
        if CTK.__MAINTREE__ == 1:
            CTK.__MAINACTIVEZONES__ = CPlot.getActiveZones()
        active = []
        tp = Internal.appendBaseName2ZoneName(CTK.t,
                                              updateRef=False,
                                              separator=Internal.SEP1)
        for z in CTK.__MAINACTIVEZONES__:
            active.append(tp[2][CTK.Nb[z] + 1][2][CTK.Nz[z]])

        temp = C.newPyTree(['Base'])
        temp[2][1][2] += active
        if plane == 'X' and algo == 'Slice1':
            p = P.isoSurfMC(active, 'CoordinateX', pos)
        elif plane == 'Y' and algo == 'Slice1':
            p = P.isoSurfMC(active, 'CoordinateY', pos)
        elif plane == 'Z' and algo == 'Slice1':
            p = P.isoSurfMC(active, 'CoordinateZ', pos)
        elif plane == 'X' and algo == 'Slice2':
            p = P.extractPlane(active, (1, 0, 0, -pos), order=order, tol=eps)
        elif plane == 'Y' and algo == 'Slice2':
            p = P.extractPlane(active, (0, 1, 0, -pos), order=order, tol=eps)
        elif plane == 'Z' and algo == 'Slice2':
            p = P.extractPlane(active, (0, 0, 1, -pos), order=order, tol=eps)
        elif plane == 'X' and algo == 'Select+':
            p = P.selectCells(temp, '{CoordinateX}>=' + str(VALUE))
        elif plane == 'Y' and algo == 'Select+':
            p = P.selectCells(temp, '{CoordinateY}>=' + str(VALUE))
        elif plane == 'Z' and algo == 'Select+':
            p = P.selectCells(temp, '{CoordinateZ}>=' + str(VALUE))
        elif plane == 'X' and algo == 'Select-':
            p = P.selectCells(temp, '{CoordinateX}<=' + str(VALUE))
        elif plane == 'Y' and algo == 'Select-':
            p = P.selectCells(temp, '{CoordinateY}<=' + str(VALUE))
        elif plane == 'Z' and algo == 'Select-':
            p = P.selectCells(temp, '{CoordinateZ}<=' + str(VALUE))
        elif plane == 'X' and algo == 'Select=':
            p = P.selectCells(
                temp, '({CoordinateX}>=' + str(VALUE - DELTA) +
                ') & ({CoordinateX}<=' + str(VALUE + DELTA) + ')')
        elif plane == 'Y' and algo == 'Select=':
            p = P.selectCells(
                temp, '({CoordinateY}>=' + str(VALUE - DELTA) +
                ') & ({CoordinateY}<=' + str(VALUE + DELTA) + ')')
        elif plane == 'Z' and algo == 'Select=':
            p = P.selectCells(
                temp, '({CoordinateZ}>=' + str(VALUE - DELTA) +
                ') & ({CoordinateZ}<=' + str(VALUE + DELTA) + ')')
        CTK.dt = C.newPyTree(['Base'])
        if algo == 'Slice1': CTK.dt[2][1][2] += p
        elif algo == 'Slice2': CTK.dt[2][1][2] += [p]
        else: CTK.dt[2][1][2] += p[2][1][2]
        CTK.display(CTK.dt, mainTree=CTK.SLICE)
        if CTK.TKPLOTXY is not None: CTK.TKPLOTXY.updateApp()
    except ValueError:
        CTK.TXT.insert('START', 'Intersection is empty.\n')
        return
    except Exception as e:
        Panels.displayErrors([0, str(e)], header='Error: slice')
        CTK.TXT.insert('START', 'Slice failed.\n')
        CTK.TXT.insert('START', 'Error: ', 'Error')
        return
Beispiel #9
0
def extract(event=None):
    if CTK.t == []: return
    pos = float(VARS[1].get())
    global VALUE
    VALUE = pos
    delta = float(VARS[4].get())
    global DELTA
    DELTA = delta
    plane = VARS[0].get()
    order = int(VARS[3].get())
    eps = float(VARS[2].get())
    algo = VARS[5].get()

    nzs = CPlot.getSelectedZones()
    if nzs != []:
        point = CPlot.getActivePoint()
        if plane == 'X': pos = point[0]
        elif plane == 'Y': pos = point[1]
        elif plane == 'Z': pos = point[2]
        VARS[1].set(str(pos))
        VALUE = pos

    if plane == 'Mesh': return
    try:
        CTK.saveTree()
        if CTK.__MAINTREE__ == 1:
            CTK.__MAINACTIVEZONES__ = CPlot.getActiveZones()
        active = []
        zones = Internal.getZones(CTK.t)
        for z in CTK.__MAINACTIVEZONES__:
            active.append(zones[z])
        temp = C.newPyTree(['Base'])
        temp[2][1][2] += active
        if plane == 'X' and algo == 'Slice1':
            p = P.isoSurfMC(active, 'CoordinateX', pos)
        elif plane == 'Y' and algo == 'Slice1':
            p = P.isoSurfMC(active, 'CoordinateY', pos)
        elif plane == 'Z' and algo == 'Slice1':
            p = P.isoSurfMC(active, 'CoordinateZ', pos)
        elif plane == 'X' and algo == 'Slice2':
            p = P.extractPlane(active, (1, 0, 0, -pos), order=order, tol=eps)
        elif plane == 'Y' and algo == 'Slice2':
            p = P.extractPlane(active, (0, 1, 0, -pos), order=order, tol=eps)
        elif plane == 'Z' and algo == 'Slice2':
            p = P.extractPlane(active, (0, 0, 1, -pos), order=order, tol=eps)
        elif plane == 'X' and algo == 'Select+':
            p = P.selectCells(temp, '{CoordinateX}>=' + str(VALUE))
        elif plane == 'Y' and algo == 'Select+':
            p = P.selectCells(temp, '{CoordinateY}>=' + str(VALUE))
        elif plane == 'Z' and algo == 'Select+':
            p = P.selectCells(temp, '{CoordinateZ}>=' + str(VALUE))
        elif plane == 'X' and algo == 'Select-':
            p = P.selectCells(temp, '{CoordinateX}<=' + str(VALUE))
        elif plane == 'Y' and algo == 'Select-':
            p = P.selectCells(temp, '{CoordinateY}<=' + str(VALUE))
        elif plane == 'Z' and algo == 'Select-':
            p = P.selectCells(temp, '{CoordinateZ}<=' + str(VALUE))
        elif plane == 'X' and algo == 'Select=':
            p = P.selectCells(
                temp, '({CoordinateX}>=' + str(VALUE - DELTA) +
                ') & ({CoordinateX}<=' + str(VALUE + DELTA) + ')')
        elif plane == 'Y' and algo == 'Select=':
            p = P.selectCells(
                temp, '({CoordinateY}>=' + str(VALUE - DELTA) +
                ') & ({CoordinateY}<=' + str(VALUE + DELTA) + ')')
        elif plane == 'Z' and algo == 'Select=':
            p = P.selectCells(
                temp, '({CoordinateZ}>=' + str(VALUE - DELTA) +
                ') & ({CoordinateZ}<=' + str(VALUE + DELTA) + ')')
        CTK.t = C.addBase2PyTree(CTK.t, 'EXTRACT', 2)
        base = Internal.getNodeFromName1(CTK.t, 'EXTRACT')
        if algo == 'Slice1':
            for i in p:
                i[0] = C.getZoneName(i[0])
            base[2] += p
        elif algo == 'Slice2':
            p[0] = C.getZoneName(p[0])
            base[2] += [p]
        else:
            p = C.deleteEmptyZones(p)
            for i in p[2][1][2]:
                i[0] = C.getZoneName(i[0])
            base[2] += p[2][1][2]
        #C._fillMissingVariables(CTK.t)
        CTK.TXT.insert('START', 'Slice extracted.\n')
        (CTK.Nb, CTK.Nz) = CPlot.updateCPlotNumbering(CTK.t)
        CTK.TKTREE.updateApp()
        CTK.display(CTK.t)
        if CTK.TKPLOTXY is not None: CTK.TKPLOTXY.updateApp()
    except ValueError:
        CTK.TXT.insert('START', 'Intersection is empty.\n')
        return
    except Exception as e:
        Panels.displayErrors([0, str(e)], header='Error: slice')
        CTK.TXT.insert('START', 'Slice failed.\n')
        CTK.TXT.insert('START', 'Error: ', 'Error')
        return
def display1D(event=None):
    if CTK.t == []: return

    # Get slot
    try:
        slot = int(VARS[5].get())
    except:
        slot = 0
    # Get grid size
    try:
        gridSize = VARS[1].get()
        grids = gridSize.split(';')
        if (len(grids) == 1): gridSize = (int(grids[0]), 1)
        else: gridSize = (int(grids[0]), int(grids[1]))
    except:
        gridSize = (1, 1)
    CPlot.setState(gridSize=gridSize)
    # Get grid pos
    try:
        gridPos = VARS[2].get()
        grids = gridPos.split(';')
        if (len(grids) == 1): gridPos = (int(grids[0]), 1)
        else: gridPos = (int(grids[0]), int(grids[1]))
    except:
        gridPos = (0, 0)

    # Recupere la direction pour la coupe ou 'Elements'
    dir = VARS[0].get()
    if dir == 'None':
        CPlot.display1D([], slot=slot)
        return  # clear

    # Recupere le pt pour la coupe ou les elements 1D
    if dir == 'Elements':  # elements -> recupere les elements
        if CTK.__MAINTREE__ <= 0:
            CTK.TXT.insert('START', 'Fail on a temporary tree.\n')
            CTK.TXT.insert('START', 'Error: ', 'Error')
            return
        nzs = CPlot.getSelectedZones()
        if nzs == []:
            CTK.TXT.insert('START', 'Selection is empty.\n')
            CTK.TXT.insert('START', 'Error: ', 'Error')
            return
        points = []
        for nz in nzs:
            nob = CTK.Nb[nz] + 1
            noz = CTK.Nz[nz]
            z = CTK.t[2][nob][2][noz]
            selected = CTK.t[2][nob][0] + '/' + z[0]
            points.append(selected)
    elif (dir == 'I' or dir == 'J'
          or dir == 'K'):  # indice -> recupere les indices + la zone
        if (CTK.__MAINTREE__ <= 0):
            CTK.TXT.insert('START', 'Fail on a temporary tree.\n')
            CTK.TXT.insert('START', 'Error: ', 'Error')
            return
        nz = CPlot.getSelectedZone()
        if (nz == -1):
            CTK.TXT.insert('START', 'Selection is empty.\n')
            CTK.TXT.insert('START', 'Error: ', 'Error')
            return
        points = []
        nob = CTK.Nb[nz] + 1
        noz = CTK.Nz[nz]
        z = CTK.t[2][nob][2][noz]
        selected = CTK.t[2][nob][0] + '/' + z[0]
        index = CPlot.getActivePointIndex()
        points = (selected, index)
    else:  # les coupes -> recupere les coord du pt
        point = CPlot.getActivePoint()
        if point == []: point = (0., 0., 0.)

    # Recupere les variables a afficher
    var1 = VARS[3].get()
    var1 = var1.replace('centers:', '')
    var2 = VARS[4].get()
    var2 = var2.replace('centers:', '')

    # Recupere les zones actives
    actives = []
    zones = Internal.getZones(CTK.t)
    if CTK.__MAINTREE__ == 1:
        nzs = CPlot.getActiveZones()
        for nz in nzs:
            actives.append(zones[nz])
    else:
        actives = zones
    if actives == []: return

    if (dir == 'X (Y)'):
        elts = P.isoSurfMC(actives, 'CoordinateY', point[1])
        if elts != []:
            elts2 = P.isoSurfMC(elts, 'CoordinateZ', point[2])
            if (elts2 != []): elts = elts2
    elif (dir == 'Y (X)'):
        elts = P.isoSurfMC(actives, 'CoordinateX', point[0])
        if elts != []:
            elts2 = P.isoSurfMC(elts, 'CoordinateZ', point[2])
            if (elts2 != []): elts = elts2
    elif (dir == 'Z (X)'):
        elts = P.isoSurfMC(actives, 'CoordinateX', point[0])
        if (elts != []):
            elts2 = P.isoSurfMC(elts, 'CoordinateY', point[1])
            if (elts2 != []): elts = elts2
    elif (dir == 'X (Z)'):
        elts = P.isoSurfMC(actives, 'CoordinateZ', point[2])
        if elts != []:
            elts2 = P.isoSurfMC(elts, 'CoordinateY', point[1])
            if (elts2 != []): elts = elts2
    elif (dir == 'Y (Z)'):
        elts = P.isoSurfMC(actives, 'CoordinateZ', point[2])
        if elts != []:
            elts2 = P.isoSurfMC(elts, 'CoordinateX', point[0])
            if (elts2 != []): elts = elts2
    elif (dir == 'Z (Y)'):
        elts = P.isoSurfMC(actives, 'CoordinateY', point[1])
        if (elts != []):
            elts2 = P.isoSurfMC(elts, 'CoordinateX', point[0])
            if (elts2 != []): elts = elts2
    elif (dir == 'I'):
        v = points[0]
        ind = points[1]
        v = v.lstrip()
        v = v.rstrip()
        sname = v.split('/', 1)
        bases = Internal.getNodesFromName1(CTK.t, sname[0])
        elts = []
        if bases != []:
            zones = Internal.getNodesFromType1(bases[0], 'Zone_t')
            for z in zones:
                if (z[0] == sname[1]):
                    try:
                        zp = C.center2Node(z, Internal.__FlowSolutionCenters__)
                        zp = T.subzone(zp, (1, ind[3], ind[4]),
                                       (-1, ind[3], ind[4]))
                        elts.append(zp)
                    except:
                        pass
    elif (dir == 'J'):
        v = points[0]
        ind = points[1]
        v = v.lstrip()
        v = v.rstrip()
        sname = v.split('/', 1)
        bases = Internal.getNodesFromName1(CTK.t, sname[0])
        elts = []
        if bases != []:
            zones = Internal.getNodesFromType1(bases[0], 'Zone_t')
            for z in zones:
                if (z[0] == sname[1]):
                    try:
                        zp = C.center2Node(z, Internal.__FlowSolutionCenters__)
                        zp = T.subzone(zp, (ind[2], 1, ind[4]),
                                       (ind[2], -1, ind[4]))
                        elts.append(zp)
                    except:
                        pass
    elif (dir == 'K'):
        v = points[0]
        ind = points[1]
        v = v.lstrip()
        v = v.rstrip()
        sname = v.split('/', 1)
        bases = Internal.getNodesFromName1(CTK.t, sname[0])
        elts = []
        if bases != []:
            zones = Internal.getNodesFromType1(bases[0], 'Zone_t')
            for z in zones:
                if (z[0] == sname[1]):
                    try:
                        zp = C.center2Node(z, Internal.__FlowSolutionCenters__)
                        zp = T.subzone(zp, (ind[2], ind[3], 1),
                                       (ind[2], ind[3], -1))
                        elts.append(zp)
                    except:
                        pass
    elif (dir == 'Elements'):
        elts = []
        for v in points:
            v = v.lstrip()
            v = v.rstrip()
            sname = v.split('/', 1)
            bases = Internal.getNodesFromName1(CTK.t, sname[0])
            if (bases != []):
                zones = Internal.getNodesFromType1(bases[0], 'Zone_t')
                for z in zones:
                    if (z[0] == sname[1]): elts.append(z)
    if elts == []:
        CTK.TXT.insert('START', 'Nothing to display.\n')
        CTK.TXT.insert('START', 'Error: ', 'Error')
        return

    try:
        elts = D.getCurvilinearAbscissa(elts)
    except:
        pass

    # Fit first axis
    pos = WIDGETS['rangePos'].get() / 50. - 1.
    zoom = WIDGETS['rangeZoom'].get() / 120.
    minv1 = C.getMinValue(elts, var1)
    maxv1 = C.getMaxValue(elts, var1)
    if (maxv1 - minv1 < 1.e-6):
        maxv1 += 5.e-7
        minv1 -= 5.e-7

    # active point localisation
    nz = CPlot.getSelectedZone()
    if (nz != -1):
        ind = CPlot.getActivePointIndex()
        nob = CTK.Nb[nz] + 1
        noz = CTK.Nz[nz]
        z = CTK.t[2][nob][2][noz]
        f1 = C.getValue(z, var1, ind[0])
        try:
            r1min = (f1 - minv1) * zoom + minv1 + pos * (1. - zoom) * (maxv1 -
                                                                       minv1)
            r1max = (f1 - maxv1) * zoom + maxv1 + pos * (1. - zoom) * (maxv1 -
                                                                       minv1)
        except:  # var1 not found in z, le cherche dans elts
            xf1 = C.getValue(z, 'CoordinateX', ind[0])
            yf1 = C.getValue(z, 'CoordinateY', ind[0])
            zf1 = C.getValue(z, 'CoordinateZ', ind[0])
            f1 = minv1 + 0.5 * (maxv1 - minv1)
            r1min = 0.5 * (maxv1 - minv1) * zoom + minv1 + pos * (
                1. - zoom) * (maxv1 - minv1)
            r1max = -0.5 * (maxv1 - minv1) * zoom + maxv1 + pos * (
                1. - zoom) * (maxv1 - minv1)
    else:
        f1 = minv1 + 0.5 * (maxv1 - minv1)
        r1min = 0.5 * (maxv1 - minv1) * zoom + minv1 + pos * (1. - zoom) * (
            maxv1 - minv1)
        r1max = -0.5 * (maxv1 - minv1) * zoom + maxv1 + pos * (1. - zoom) * (
            maxv1 - minv1)

    # Fit second axis
    p = P.selectCells(
        elts,
        '({%s} < %20.16g) & ({%s} > %20.16g)' % (var1, r1max, var1, r1min))
    minv2 = C.getMinValue(p, var2)
    maxv2 = C.getMaxValue(p, var2)

    # display
    CPlot.display1D(p,
                    slot=slot,
                    bgBlend=0.,
                    gridPos=gridPos,
                    var1=var1,
                    var2=var2,
                    r1=(r1min, r1max),
                    r2=(minv2, maxv2))
    CTK.TXT.insert('START', 'Plot displayed.\n')