def loadImageFiles(t): """Load image files (texture, billboards, bumpmaps) in CPlot.""" if t == []: return renderInfo = Internal.getNodeFromName1(t, '.RenderInfo') if renderInfo is None: return None pos = Internal.getNodeFromName1(renderInfo, 'materials') if pos is not None: out = [] for i in pos[2]: out.append(Internal.getValue(i)) CPlot.setState(materials=out) pos = Internal.getNodeFromName1(renderInfo, 'bumpMaps') if pos is not None: out = [] for i in pos[2]: out.append(Internal.getValue(i)) CPlot.setState(bumpMaps=out) pos = Internal.getNodeFromName1(renderInfo, 'billBoards') if pos is not None: out = [] for i in pos[2]: out.append(Internal.getValue(i)) CPlot.setState(billBoards=out) return None
# - getKeyboard (array) - import Generator as G import CPlot import Geom as D import time a = G.cart((0, 0, 0), (1, 1, 1), (8, 8, 1)) CPlot.display(a, dim=2) CPlot.setState(activateShortCuts=0) for i in range(50): l = '' while l == '': l = CPlot.getKeyboard() time.sleep(0.1) try: a = D.text2D(l) CPlot.display(a) except: v = ord(l[0]) if v == 1: print('up') elif v == 2: print('down') elif v == 3: print('left') elif v == 4: print('right') time.sleep(0.1) l = ''
# - display1D (array) - import Generator as G import CPlot import Transform as T import Converter as C import numpy # 1D data defined in arrays b = G.cart((0, 0, 0), (0.1, 1, 1), (50, 1, 1)) c = G.cart((5, 0, 0), (0.1, 1, 1), (50, 1, 1)) B = [b, c] CPlot.setState(gridSize=(1, 2)) for i in xrange(100): B = C.initVars(B, 'f=sin({x}+0.02*%d)' % i) B = C.initVars(B, 'g={x}') CPlot.display1D(B, slot=0, bgBlend=1., gridPos=(0, 0), var1='x', var2='f') # 1D data defined in numpys x = numpy.linspace(0, 2 * numpy.pi) y = numpy.sin(x) CPlot.display1D([x, y], slot=1, var1='x', var2='y', gridPos=(0, 1), bgBlend=0.)
def loadView(t, slot=0): """Load a view stored in slot.""" renderInfo = Internal.getNodeFromName1(t, '.RenderInfo') if renderInfo is None: return slot = Internal.getNodeFromName1(renderInfo, 'Slot%d'%slot) if slot is None: return pos = Internal.getNodeFromName1(slot, 'posCam') if pos is None: n = pos[1]; CPlot.setState(posCam=(n[0], n[1], n[2])) pos = Internal.getNodeFromName1(slot, 'posEye') if pos is not None: n = pos[1]; CPlot.setState(posEye=(n[0], n[1], n[2])) pos = Internal.getNodeFromName1(slot, 'dirCam') if pos is not None: n = pos[1]; CPlot.setState(dirCam=(n[0], n[1], n[2])) pos = Internal.getNodeFromName1(slot, 'mode') if pos is not None: mode = Internal.getValue(pos) if mode == 'Mesh': imode = 0 elif mode == 'Solid': imode = 1 elif mode == 'Render': imode = 2 elif mode == 'Scalar': imode = 3 elif mode == 'Vector': imode = 4 else: imode = 0 CPlot.setState(mode=imode) pos = Internal.getNodeFromName1(slot, 'scalarField') if pos is not None: field = Internal.getValue(pos) vars = C.getVarNames(t)[0] ifield = 0 for i in vars: if i == field: break if (i != 'CoordinateX' and i != 'CoordinateY' and i != 'CoordinateZ'): ifield += 1 CPlot.setState(scalarField=ifield) pos = Internal.getNodeFromName1(slot, 'niso') if pos is not None: niso = Internal.getValue(pos); CPlot.setState(niso=int(niso)) pos = Internal.getNodeFromName1(slot, 'isoEdges') if pos is not None: edge = Internal.getValue(pos); CPlot.setState(isoEdges=edge) pos = Internal.getNodeFromName1(slot, 'isoLight') if pos is not None: light = Internal.getValue(pos) else: light = 1 pos = Internal.getNodeFromName1(slot, 'colormap') if pos is not None: colormap = Internal.getValue(pos) else: colormap = 'Blue2Red' style = 0 if colormap == 'Blue2Red': style = 0 elif colormap == 'Green2Red': style = 2 elif colormap == 'Black2White': style = 4 elif colormap == 'White2Black': style = 6 elif colormap == 'Diverging': style = 8 if light == 1: style += 1 CPlot.setState(colormap=style) pos = Internal.getNodeFromName1(slot, 'isoScales') if pos is not None: CPlot.setState(isoScales=pos[1].tolist()) # RenderInfo pos = Internal.getNodeFromName1(renderInfo, 'materials') if pos is not None: out = [] for i in pos[2]: out.append(Internal.getValue(i)) CPlot.setState(materials=out) pos = Internal.getNodeFromName1(renderInfo, 'bumpMaps') if pos is not None: out = [] for i in pos[2]: out.append(Internal.getValue(i)) CPlot.setState(bumpMaps=out) pos = Internal.getNodeFromName1(renderInfo, 'billBoards') if pos is not None: out = [] for i in pos[2]: out.append(Internal.getValue(i)) CPlot.setState(billBoards=out)
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)
# - 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))