def changeChartCI(changeNotes=True): global systemPanel, chartPanel global fdc, selRec2, isDominant, isTemporal if isTemporal: confLines = CPlot.calcCPlot(systemPanel.getCI(), lpath + os.sep + "out.dat") elif isDominant: confLines = fdc.run_cplot(systemPanel.getCI(), lpath, version=2) else: confLines = fdc.run_cplot(systemPanel.getCI(), lpath, version=1) top, avg, bottom = [], [], [] oldX = -1 for group in confLines: if oldX == float(group[0]): continue #strange but possible oldX = float(group[0]) if not isDominant: top.append((float(group[0]), float(group[3]))) avg.append((float(group[0]), float(group[2]))) bottom.append((float(group[0]), float(group[1]))) else: top.append((float(group[0]), float(group[4]))) avg.append((float(group[0]), float(group[3]))) bottom.append((float(group[0]), float(group[2]))) chartPanel.setBottom(bottom) #chartPanel.setAvg(avg) chartPanel.setTop(top) chartPanel.updateChartDataset(False) if changeNotes: if isDominant: pv = fdc.run_pv(data_dir = lpath, version=2) else: pv = fdc.run_pv(data_dir = lpath, version=1) selLoci = getSelLoci(pv) chartPanel.setSelLoci(pv, selRec2.loci_list, selLoci) return confLines
def setMode(mode): """Set CPlot display mode. Usage: setMode(0)""" CPlot.setMode(mode)
def resetKeyboard(): """Reset the keyboard string. Usage: resetKeyboard()""" return CPlot.resetKeyboard()
def getMouseState(): """Return mouse state (mouse position and button state).""" return CPlot.getMouseState()
def getActivePointIndex(): """Return the active point index. Usage: n = getActivePointIndex()""" return CPlot.getActivePointIndex()
def getActiveStatus(zone): """Return the active status of a zone in plotter. Usage: status=getActiveStatus(zone)""" return CPlot.getActiveStatus(zone)
def getSelectedStatus(zone): """Return the selected status of a zone in plotter. Usage: status=getSelectedStatus(zone)""" return CPlot.getSelectedStatus(zone)
def getSelectedZone(): """Return the selected zone in plotter. Usage: n=getSelectedZone()""" return CPlot.getSelectedZone()
# - display (array) - # test scalar mode - import Converter as C import Generator as G import CPlot import time a = G.cartTetra( (0,0,0), (1,1,1), (1,10,10) ) a = C.initVars(a, '{f}={y}') CPlot.display([a], mode=3, scalarStyle=0); time.sleep(1.) CPlot.display([a], mode=3, scalarStyle=1); time.sleep(1.)
#!/usr/bin/python # coding: utf-8 r"""cartTetra (array) Create an unstructured tetrahedral mesh defined from a Cartesian grid of ni x nj x nk points starting from point (xo,yo,zo) and of step (hi,hj,hk). Type of elements are ‘TRI’ for 2D arrays and ‘TETRA’ for 3D arrays. Parameters: (xo,yo,zo) (3-tuple of floats) – coordinates of the starting point (hi,hj,hk) (3-tuple of floats) – values of advancing step in the three directions (ni,nj,nk) (3-tuple of integers) – number of points in each direction Returns:a 1D, 2D or 3D unstructured mesh Return type:array or pyTree zone """ import Generator as G import Converter as C import CPlot a = G.cartTetra((0., 0., 0.), (0.1, 0.1, 0.2), (10, 10, 1)) C.convertArrays2File(a, 'out.plt') CPlot.display(a, displayBB=0, mode='mesh', meshStyle=1)
# - delaunay (array) - import Generator as G import Converter as C import CPlot ni = 11 nj = 11 nk = 1 hi = 1. / (ni - 1) hj = 1. / (nj - 1) hk = 1. a = G.cart((0., 0., 0.), (hi, hj, hk), (ni, nj, nk)) b = G.delaunay(a) C.convertArrays2File([a, b], "out.plt") CPlot.display(a) CPlot.pressKey() CPlot.display(b)
# - display (array) - # Pour les NGons import CPlot import Generator as G import Converter as C # 3D a = G.cartNGon((0, 0, 0), (1, 1, 1), (20, 20, 20)) a = C.initVars(a, '{f}={x}') # 2D b = G.cartNGon((30, 0, 0), (1, 1, 1), (20, 20, 1)) b = C.initVars(b, '{f}={x}') # 1D c = G.cartNGon((0, 30, 0), (1, 1, 1), (20, 1, 1)) c = C.initVars(c, '{f}={x}') CPlot.display([a, b, c], mode=0, meshStyle=2)
import os import Generator as G import CPlot import Transform as T import Converter as C import Geom as D import time a = D.sphere((0, 0, 0), 1) # One image CPlot.display([a], offscreen=1, bgColor=1, mode=1, meshStyle=2, solidStyle=1, posCam=(0, 6, 0), export="one.png") # Movie for i in range(50): a = T.rotate(a, (0, 0, 0), (0, 0, 1), 1.) CPlot.display([a], offscreen=1, bgColor=1, mode=1, meshStyle=2, solidStyle=1, posCam=(0, 6, 0), exportResolution='680x600',
# - setState (array) - import Generator as G import CPlot import time a = G.cart((0, 0, 0), (1, 1, 1), (5, 5, 5)) CPlot.display(a, mode='solid') time.sleep(1.) CPlot.setState(posCam=(8, 8, 8), posEye=(5, 5, 5))
# - render (array) - import Generator as G import CPlot a = G.cart((0,0,0), (1,1,1), (10,10,10)) CPlot.display(a) CPlot.render()
def getState(mode): """Return the state in plotter. Usage: n = getState(mode)""" return CPlot.getState(mode)
# - display (array) - import Geom as D import Generator as G import CPlot import os sphere = D.sphere((0., 0., 0.), 1.0) cube = G.cart((0.2, 0.2, 0.2), (1., 1., 1.), (2, 2, 2)) cube2 = G.cart((-1.5, -0.2, -1.2), (1., 1., 1.), (2, 2, 2)) # Full display CPlot.display([sphere, cube2], posCam=(-0.449, 1.63, -2.9), posEye=(0.35, 0.35, 0.35), dirCam=(0.94, -0.16, -0.3), export="ref.png", offscreen=2) CPlot.finalizeExport() # Accumulate in images CPlot.display([sphere], posCam=(-0.449, 1.63, -2.9), posEye=(0.35, 0.35, 0.35), dirCam=(0.94, -0.16, -0.3), export="composited.png", offscreen=3) CPlot.finalizeExport(3) CPlot.display([cube2], posCam=(-0.449, 1.63, -2.9), posEye=(0.35, 0.35, 0.35),
def getSelectedZones(): """Return the selected zones in plotter. Usage: list=getSelectedZones()""" return CPlot.getSelectedZones()
# - travel* (array) - import Geom as D import Generator as G import CPlot import Converter as C import Transform as T # Model a = D.sphere((0,0,0), 1., N=20) a = C.convertArray2Hexa(a); a = G.close(a) CPlot.display(a, posCam=(3,0,0), posEye=(0,0,0)) time = 0. for i in xrange(1300): # change model defo = C.initVars(a, '{df}=0.1*cos(%f)*sin(10*pi*{x})'%(time)) defo = C.extractVars(defo, ['df']) b = T.deformNormals(a, defo) CPlot.display(b) time += 0.05 if i < 200: CPlot.travelLeft(0.001, N=3) elif i < 400: CPlot.travelRight(0.001, N=3) elif i < 600: CPlot.travelUp(0.001, N=3) elif i < 800: CPlot.travelIn(0.001, N=3)
def getActiveZones(): """Return the active (displayed) zones in plotter. Usage: list=getActiveZones()""" return CPlot.getActiveZones()
#!/usr/bin/python # coding: utf-8 r"""changeStyle (array) CPlot.changeStyle: change CPlot display style""" import Generator as G import CPlot import time a = G.cart((0, 0, 0), (0.1, 0.1, 0.1), (10, 10, 3)) t = [a] CPlot.display(t, dim=3, mode=0) for i in range(10): CPlot.changeStyle() time.sleep(2)
def getActivePoint(): """Return the active point coordinates in plotter. Usage: n=getActivePoint()""" return CPlot.getActivePoint()
yp = yp * (bb[4] - bb[1]) * 0.1 + yc zp = zp * (bb[5] - bb[2]) / 30. + zc posCam[0] = xp posCam[1] = zp posCam[2] = yp return posCam #a = C.convertFile2Arrays('fontaine.plt', 'bin_tp') a = C.convertFile2Arrays('dauphin2.plt', 'bin_tp') #a = C.convertFile2Arrays('interceptor.plt', 'bin_tp') #a = C.convertFile2Arrays('tiep.plt', 'bin_tp') #a = T.rotate(a, (0,0,0),(1,0,0),-90.) CPlot.display(a, win=(700, 500), displayBB=0, displayInfo=0, mode=1, solidStyle=0) bb = G.bbox(a) xc = 0.5 * (bb[3] + bb[0]) yc = 0.5 * (bb[4] + bb[1]) zc = 0.5 * (bb[5] + bb[2]) posCam = [bb[0], bb[1], bb[2]] posEye = [xc, yc, zc] dirCam = [0, 0, 1] i = 0 while (i != -1): posCam = fly(a, bb, posCam, posEye, dirCam, 0.003) i = i + 1
def getActivePointF(): """Return the active point field values. Usage: n = getActivePointF()""" return CPlot.getActivePointF()
# - delete (array) - import Generator as G import CPlot import time a = G.cart((0, 0, 0), (1, 1, 1), (10, 10, 10)) b = G.cart((11, 0, 0), (1, 1, 1), (10, 10, 10)) CPlot.display([a, b]) time.sleep(3) CPlot.delete([0]) CPlot.render() time.sleep(3) CPlot.delete(['S-Zone 1']) CPlot.render() time.sleep(3)
def getKeyboard(): """Return the pressed keys. Usage: n = getKeyboard()""" return CPlot.getKeyboard()
# - display (array) - # Offscreen using FBO import CPlot import Transform as T import Geom as D a = D.sphere((0,0,0), 1, N=200) # Multi images CPlot.display(a, offscreen=2, bgColor=1, mode=0, meshStyle=2, solidStyle=1, posCam=(0,6,0), export='one.png') CPlot.finalizeExport() # wait for end of file write for i in range(5): a = T.rotate(a, (0,0,0), (0,0,1), 1.) CPlot.display(a, offscreen=2, bgColor=1, mode=0, meshStyle=2, solidStyle=1, posCam=(0,6,0), export='one%d.png'%i) CPlot.finalizeExport() # wait for end of file write import os; os._exit(0) # Mpeg Movie for i in range(50): a = T.rotate(a, (0,0,0), (0,0,1), 1.) CPlot.display(a, bgColor=1, mode=0, solidStyle=1, posCam=(0,6,0), export='export.mpeg', exportResolution='680x600', offscreen=2) CPlot.finalizeExport() # wait for end of file write CPlot.finalizeExport(1) # close mpeg file import os; os._exit(0)
def setState(dim=-1, mode=-1, scalarField=-1, vectorField1=-1, vectorField2=-1, vectorField3=-1, displayBB=-1, displayInfo=-1, displayIsoLegend=-1, meshStyle=-1, solidStyle=-1, scalarStyle=-1, vectorStyle=-1, vectorScale=-1., vectorDensity=-1., vectorNormalize=-1, vectorShowSurface=-1, vectorShape=-1, vectorProjection=-1, colormap=-1, niso=-1, isoEdges=-1, isoScales=[], win=(-1,-1), posCam=(-999,-999,-999), posEye=(-999,-999,-999), dirCam=(-999,-999,-999), viewAngle=-1., lightOffset=(-999,-999), bgColor=-1, shadow=-1, dof=-1, dofPower=-1, gamma=-1, sobelThreshold=-1, ghostifyDeactivatedZones=-1, edgifyActivatedZones=-1, edgifyDeactivatedZones=-1, export="None", exportResolution="None", continuousExport=-1, envmap="None", message="None", stereo=-1, stereoDist=-1., cursor=-1, gridSize=(-1,-1), timer=-1, selectionStyle=-1, activateShortCuts=-1, billBoards=None, billBoardSize=-1, materials=None, bumpMaps=None): """Set CPlot state. Usage: setState(posCam=(12,0,0))""" CPlot.setState(dim, mode, scalarField, vectorField1, vectorField2, vectorField3, displayBB, displayInfo, displayIsoLegend, meshStyle, solidStyle, scalarStyle, vectorStyle, vectorScale, vectorDensity, vectorNormalize, vectorShowSurface, vectorShape, vectorProjection, colormap, niso, isoEdges, isoScales, win, posCam, posEye, dirCam, viewAngle, lightOffset, bgColor, shadow, dof, dofPower, gamma, sobelThreshold, ghostifyDeactivatedZones, edgifyActivatedZones, edgifyDeactivatedZones, export, exportResolution, continuousExport, envmap, message, stereo, stereoDist, cursor, gridSize, timer, selectionStyle, activateShortCuts, billBoards, billBoardSize, materials, bumpMaps)
# - getSelectedStatus (array) - import Generator as G import CPlot import time a1 = G.cart((0, 0, 0), (1, 1, 1), (5, 5, 5)) a2 = G.cart((7, 0, 0), (1, 1, 1), (3, 3, 3)) CPlot.display([a1, a2]) time.sleep(5.) ret = CPlot.getSelectedStatus(0) if ret == 1: print('Zone 0 is selected.') else: print('Zone 0 is not selected.')
def pressKey(): """Wait for user to press a key. Usage: pressKey()""" CPlot.pressKey()
# - changeVariable (array) - import Generator as G import Converter as C import CPlot import time def F(x, y): return x * x + y * y a = G.cart((0, 0, 0), (1, 1, 1), (5, 5, 1)) a = C.addVars(a, 'Density') a = C.initVars(a, 'F', F, ['x', 'y']) CPlot.display(a, dim=2, mode=3) CPlot.changeVariable() time.sleep(2) CPlot.changeVariable() time.sleep(2)