def createApp(win): # - Frame - Frame = TTK.LabelFrame(win, borderwidth=2, relief=CTK.FRAMESTYLE, text='tkInit', font=CTK.FRAMEFONT, takefocus=1) #BB = CTK.infoBulle(parent=Frame, text='Init solution fields.\nCtrl+c to close applet.', temps=0, btype=1) Frame.bind('<Control-c>', hideApp) Frame.bind('<ButtonRelease-3>', displayFrameMenu) Frame.bind('<Enter>', lambda event : Frame.focus_set()) Frame.columnconfigure(0, weight=1) WIDGETS['frame'] = Frame # - Frame menu - FrameMenu = TK.Menu(Frame, tearoff=0) FrameMenu.add_command(label='Close', accelerator='Ctrl+c', command=hideApp) CTK.addPinMenu(FrameMenu, 'tkInit') WIDGETS['frameMenu'] = FrameMenu # - VARS - # -0- Zone filter regexp - #V = TK.StringVar(win); V.set(''); VARS.append(V) # - Init solution - B = TTK.Button(Frame, text="Initialize solution from state", command=initSolution) B.grid(row=0, column=0, columnspan=2, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Initialize the solution in centers (require state).') # - Init wall distances - B = TTK.Button(Frame, text="Initialize wall distances", command=initWallDistance) B.grid(row=1, column=0, columnspan=2, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Compute wall distances.')
def createApp(win): # - Frame - Frame = TTK.LabelFrame(win, borderwidth=2, relief=CTK.FRAMESTYLE, text='tkRuler', font=CTK.FRAMEFONT, takefocus=1) #BB = CTK.infoBulle(parent=Frame, text='Take measures by clicking.\nCtrl+c to close applet.', temps=0, btype=1) Frame.bind('<Control-c>', hideApp) Frame.bind('<ButtonRelease-3>', displayFrameMenu) Frame.bind('<Enter>', lambda event: Frame.focus_set()) Frame.columnconfigure(0, weight=1) WIDGETS['frame'] = Frame # - Frame menu - FrameMenu = TK.Menu(Frame, tearoff=0) FrameMenu.add_command(label='Close', accelerator='Ctrl+c', command=hideApp) CTK.addPinMenu(FrameMenu, 'tkRuler') WIDGETS['frameMenu'] = FrameMenu # - VARS - # -0- Zone filter regexp - #V = TK.StringVar(win); V.set(''); VARS.append(V) # - Buttons - B = TTK.Button(Frame, text="Measure mode", command=measure) B.grid(row=0, column=0, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Click on two points to obtain the distance.') WIDGETS['button'] = B
def createApp(win): # - Frame - Frame = TTK.LabelFrame(win, borderwidth=2, relief=CTK.FRAMESTYLE, text='tkStereo', font=CTK.FRAMEFONT, takefocus=1) #BB = CTK.infoBulle(parent=Frame, text='Set anaglyph mode.\nCtrl+c to close applet.', temps=0, btype=1) Frame.bind('<Control-c>', hideApp) Frame.bind('<ButtonRelease-3>', displayFrameMenu) Frame.bind('<Enter>', lambda event: Frame.focus_set()) Frame.columnconfigure(0, weight=0) Frame.columnconfigure(1, weight=1) WIDGETS['frame'] = Frame # - Frame menu - FrameMenu = TK.Menu(Frame, tearoff=0) FrameMenu.add_command(label='Close', accelerator='Ctrl+c', command=hideApp) FrameMenu.add_command(label='Save', command=saveApp) FrameMenu.add_command(label='Reset', command=resetApp) CTK.addPinMenu(FrameMenu, 'tkStereo') WIDGETS['frameMenu'] = FrameMenu # - VARS - # -0- Stero mode - V = TK.StringVar(win) V.set('None') VARS.append(V) if 'tkStereoMode' in CTK.PREFS: V.set(CTK.PREFS['tkStereoMode']) # -1- Stereo dist info bulle V = TK.StringVar(win) V.set('Stereo distance.') VARS.append(V) # - Stereo mode - B = TTK.Label(Frame, text="Stereo") B.grid(row=0, column=0, sticky=TK.EW) B = TTK.OptionMenu(Frame, VARS[0], 'None', 'Anaglyph (b&w)', 'Anaglyph (color)', command=setStereo) B.grid(row=0, column=1, sticky=TK.EW) # - Stereo Dist - B = TTK.Scale(Frame, from_=0, to=100, orient=TK.HORIZONTAL, showvalue=0, borderwidth=1, command=setDist, value=50) WIDGETS['dist'] = B B.grid(row=1, columnspan=2, sticky=TK.EW) BB = CTK.infoBulle(parent=B, textVariable=VARS[1])
def createApp(win): # - Frame - Frame = TTK.LabelFrame(win, borderwidth=2, relief=CTK.FRAMESTYLE, text='tkPovRay', font=CTK.FRAMEFONT, takefocus=1) #BB = CTK.infoBulle(parent=Frame, text='Export to povRay ray tracer.\nCtrl+c to close applet.', temps=0, btype=1) Frame.bind('<Control-c>', hideApp) Frame.bind('<ButtonRelease-3>', displayFrameMenu) Frame.bind('<Enter>', lambda event : Frame.focus_set()) Frame.columnconfigure(0, weight=1) Frame.columnconfigure(1, weight=1) WIDGETS['frame'] = Frame # - Frame menu - FrameMenu = TK.Menu(Frame, tearoff=0) FrameMenu.add_command(label='Close', accelerator='Ctrl+c', command=hideApp) FrameMenu.add_command(label='Save', command=saveApp) FrameMenu.add_command(label='Reset', command=resetApp) CTK.addPinMenu(FrameMenu, 'tkPovRay') WIDGETS['frameMenu'] = FrameMenu # - VARS - # -0- background - V = TK.StringVar(win); V.set('Black'); VARS.append(V) if 'tkPovRayBackground' in CTK.PREFS: V.set(CTK.PREFS['tkPovRayBackground']) # -1- Image size V = TK.StringVar(win); V.set('800x600'); VARS.append(V) if 'tkPovRaySize' in CTK.PREFS: V.set(CTK.PREFS['tkPovRaySize']) # -2- Dir name (file.pov et file.png) V = TK.StringVar(win); V.set('PovRay'); VARS.append(V) if 'tkPovRayOutput' in CTK.PREFS: V.set(CTK.PREFS['tkPovRayOutput']) # - File - B = TTK.Entry(Frame, textvariable=VARS[2], background='White') B.grid(row=0, column=0, columnspan=2, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Directory name for output (.pov and .png).') # - Background selection - B = TTK.OptionMenu(Frame, VARS[0], 'Black', 'White', 'Blue sky', 'Cloudy sky', 'Starfield' ) B.grid(row=1, column=0, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Output background.') # - Image size - B = TTK.OptionMenu(Frame, VARS[1], '320x200', '800x600', '1024x768', '1600x1200') B.grid(row=1, column=1, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Image resolution.') # - Render scene - B = TTK.Button(Frame, text="Render scene", command=render) B.grid(row=2, column=0, columnspan=2, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Render pov scene.')
def createApp(win): ttk = CTK.importTtk() # - Frame - Frame = TTK.LabelFrame(win, borderwidth=2, relief=CTK.FRAMESTYLE, text='tkCamera', font=CTK.FRAMEFONT, takefocus=1) #BB = CTK.infoBulle(parent=Frame, text='Display mesh informations.\nCtrl+c to close applet.', temps=0, btype=1) Frame.bind('<Control-c>', hideApp) Frame.bind('<ButtonRelease-3>', displayFrameMenu) Frame.bind('<Enter>', lambda event : Frame.focus_set()) Frame.columnconfigure(0, weight=0) Frame.columnconfigure(1, weight=3) WIDGETS['frame'] = Frame # - Frame menu - FrameMenu = TK.Menu(Frame, tearoff=0) FrameMenu.add_command(label='Close', accelerator='Ctrl+c', command=hideApp) CTK.addPinMenu(FrameMenu, 'tkCamera') WIDGETS['frameMenu'] = FrameMenu #- VARS - # -0- posCam - V = TK.StringVar(win); V.set('(0., 0., 0.)'); VARS.append(V) # -1- posEye - V = TK.StringVar(win); V.set('(0., 0.; 0.)'); VARS.append(V) # -2- dirCam - V = TK.StringVar(win); V.set('(0., 0., 0.)'); VARS.append(V) # - posCam - B = TTK.Label(Frame, text="posCam: ") B.grid(row=0, column=0, columnspan=1, sticky=TK.EW) B = TTK.Entry(Frame, textvariable=VARS[0], background='White', width=15) B.grid(row=0, column=1, columnspan=1, sticky=TK.EW) B.bind('<Return>', setInfo) BB = CTK.infoBulle(parent=B, text='Camera position.') # - posEye - B = TTK.Label(Frame, text="posEye: ") B.grid(row=1, column=0, columnspan=1, sticky=TK.EW) B = TTK.Entry(Frame, textvariable=VARS[1], background='White', width=15) B.grid(row=1, column=1, columnspan=1, sticky=TK.EW) B.bind('<Return>', setInfo) BB = CTK.infoBulle(parent=B, text='Eye position.') # - dirCam - B = TTK.Label(Frame, text="dirCam: ") B.grid(row=2, column=0, columnspan=1, sticky=TK.EW) B = TTK.Entry(Frame, textvariable=VARS[2], background='White', width=15) B.grid(row=2, column=1, columnspan=1, sticky=TK.EW) B.bind('<Return>', setInfo) BB = CTK.infoBulle(parent=B, text='Camera direction.') # - get - B = TTK.Button(Frame, text="Get", command=getInfo) B.grid(row=3, column=1, columnspan=1, sticky=TK.EW) # - set - B = TTK.Button(Frame, text="Set", command=setInfo) B.grid(row=3, column=0, columnspan=1, sticky=TK.EW)
def createApp(win): # - Frame - Frame = TTK.LabelFrame(win, borderwidth=2, relief=CTK.FRAMESTYLE, text='tkProjection', font=CTK.FRAMEFONT, takefocus=1) #BB = CTK.infoBulle(parent=Frame, text='Project meshes on surface meshes.\nCtrl+c to close applet.', temps=0, btype=1) Frame.bind('<Control-c>', hideApp) Frame.bind('<ButtonRelease-3>', displayFrameMenu) Frame.bind('<Enter>', lambda event: Frame.focus_set()) Frame.columnconfigure(0, weight=2) Frame.columnconfigure(1, weight=1) WIDGETS['frame'] = Frame # - Frame menu - FrameMenu = TK.Menu(Frame, tearoff=0) FrameMenu.add_command(label='Close', accelerator='Ctrl+c', command=hideApp) CTK.addPinMenu(FrameMenu, 'tkProjection') WIDGETS['frameMenu'] = FrameMenu # - VARS - # -0- Projection surface - V = TK.StringVar(win) V.set('') VARS.append(V) # - Surface - B = TTK.Button(Frame, text="Proj. surf", command=setSurface, image=iconics.PHOTO[8], padx=0, pady=0, compound=TK.RIGHT) B.grid(row=0, column=1, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Set projection surfaces.') B = TTK.Entry(Frame, textvariable=VARS[0], background='White') B.grid(row=0, column=0, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Projection surfaces.') # - Orthogonal projection - B = TTK.Button(Frame, text="Ortho project", command=orthoProject) B.grid(row=1, column=0, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Project selection orthogonally on a surface.') # - Dir projection - B = TTK.Button(Frame, text="Dir project", command=dirProject) B.grid(row=1, column=1, sticky=TK.EW) BB = CTK.infoBulle( parent=B, text='Project selection following eye direction on a surface.')
def createApp(win): # - Frame - Frame = TTK.LabelFrame(win, borderwidth=2, relief=CTK.FRAMESTYLE, text='tkGhostCells', font=CTK.FRAMEFONT, takefocus=1) #BB = CTK.infoBulle(parent=Frame, text='My personal applet.\nCtrl+c to close applet.', temps=0, btype=1) Frame.bind('<Control-c>', hideApp) Frame.bind('<ButtonRelease-3>', displayFrameMenu) Frame.bind('<Enter>', lambda event: Frame.focus_set()) Frame.columnconfigure(0, weight=1) Frame.columnconfigure(1, weight=1) WIDGETS['frame'] = Frame # - Frame menu - FrameMenu = TK.Menu(Frame, tearoff=0) FrameMenu.add_command(label='Close', accelerator='Ctrl+c', command=hideApp) CTK.addPinMenu(FrameMenu, 'tkGhostCells') WIDGETS['frameMenu'] = FrameMenu # - VARS - # -0- number of layers of ghost cells - V = TK.StringVar(win) V.set('2') VARS.append(V) # -1- methode pour les coins - V = TK.StringVar(win) V.set('None') VARS.append(V) # - Number of ghost cell layers - B = TTK.Entry(Frame, textvariable=VARS[0], background='White', width=5) B.grid(row=0, column=0, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Number of ghost cell layers.') # - methode pour les coins - B = TTK.OptionMenu(Frame, VARS[1], 'None') B.grid(row=0, column=1, columnspan=1, sticky=TK.EW) # - add ghost cells - B = TTK.Button(Frame, text="Add", command=addGhostCells) B.grid(row=1, column=0, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Add layers of ghost cells.') # - rm ghost cells - B = TTK.Button(Frame, text="Rm", command=rmGhostCells) B.grid(row=1, column=1, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Rm layers of ghost cells.')
def createApp(win): # - Frame - Frame = TTK.LabelFrame(win, borderwidth=2, relief=CTK.FRAMESTYLE, text='tkPoint', font=CTK.FRAMEFONT, takefocus=1) #BB = CTK.infoBulle(parent=Frame, text='Generate points.\nCtrl+c to close applet.', temps=0, btype=1) Frame.bind('<Control-c>', hideApp) Frame.bind('<ButtonRelease-3>', displayFrameMenu) Frame.bind('<Enter>', lambda event: Frame.focus_set()) Frame.columnconfigure(0, weight=4) Frame.columnconfigure(1, weight=4) Frame.columnconfigure(2, weight=0) WIDGETS['frame'] = Frame # - Frame menu - FrameMenu = TK.Menu(Frame, tearoff=0) FrameMenu.add_command(label='Close', accelerator='Ctrl+c', command=hideApp) CTK.addPinMenu(FrameMenu, 'tkPoint') WIDGETS['frameMenu'] = FrameMenu # - VARS - # -0- point coordinates - V = TK.StringVar(win) V.set('0;0;0') VARS.append(V) # - Buttons - B = TTK.Entry(Frame, textvariable=VARS[0], background='White', width=15) B.bind('<Return>', createPoint) B.grid(row=0, column=0, columnspan=2, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Point coordinates (x;y;z).') B = TTK.Button(Frame, image=iconics.PHOTO[8], command=getPointCoordinates, padx=0) B.grid(row=0, column=2, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Get point coordinates from mouse.') B = TTK.Button(Frame, text="Create", command=createPoint) B.grid(row=1, column=0, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Create a point.') B = TTK.Button(Frame, text="Modify", command=modifyPoint) B.grid(row=1, column=1, columnspan=2, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Modify point coordinate.')
def createApp(win): # - Frame - Frame = TTK.LabelFrame(win, borderwidth=2, relief=CTK.FRAMESTYLE, text='tkNGon', font=CTK.FRAMEFONT, takefocus=1) #BB = CTK.infoBulle(parent=Frame, text='Manage Polyhedral (NGON) meshes.\nCtrl+c to close applet.', temps=0, btype=1) Frame.bind('<Control-c>', hideApp) Frame.bind('<ButtonRelease-3>', displayFrameMenu) Frame.bind('<Enter>', lambda event: Frame.focus_set()) Frame.columnconfigure(0, weight=1) Frame.columnconfigure(1, weight=1) WIDGETS['frame'] = Frame # - Frame menu - FrameMenu = TK.Menu(Frame, tearoff=0) FrameMenu.add_command(label='Close', accelerator='Ctrl+c', command=hideApp) CTK.addPinMenu(FrameMenu, 'tkNGon') WIDGETS['frameMenu'] = FrameMenu # - VARS - # - Convert2NGon - B = TTK.Button(Frame, text="Convert2NGon", command=convert2NGon) B.grid(row=0, column=0, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Convert selection to NGon.') # - Break Elements - B = TTK.Button(Frame, text="BreakElts", command=breakElts) B.grid(row=0, column=1, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Convert a NGon zone to basic elements.') # - Dual - B = TTK.Button(Frame, text="Dual", command=dual) B.grid(row=1, column=0, columnspan=1, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Compute the dual mesh of a NGon.') # - Conformize - B = TTK.Button(Frame, text="Conformize", command=conformize) B.grid(row=1, column=1, columnspan=1, sticky=TK.EW) BB = CTK.infoBulle( parent=B, text='Conformize a NGon (split faces to match hanging nodes).')
def createApp(win): # - Frame - Frame = TTK.LabelFrame(win, borderwidth=2, relief=CTK.FRAMESTYLE, text='tkBoolean', font=CTK.FRAMEFONT, takefocus=1) #BB = CTK.infoBulle(parent=Frame, text='Boolean operations\on surfaces.\nCtrl+c to close applet.', temps=0, btype=1) Frame.bind('<Control-c>', hideApp) Frame.bind('<ButtonRelease-3>', displayFrameMenu) Frame.bind('<Enter>', lambda event: Frame.focus_set()) Frame.columnconfigure(0, weight=1) Frame.columnconfigure(1, weight=2) WIDGETS['frame'] = Frame # - Frame menu - FrameMenu = TK.Menu(Frame, tearoff=0) FrameMenu.add_command(label='Close', accelerator='Ctrl+c', command=hideApp) CTK.addPinMenu(FrameMenu, 'tkBoolean') WIDGETS['frameMenu'] = FrameMenu # - VARS - # -0- tolerance - V = TK.StringVar(win) V.set('0.') VARS.append(V) # - Tolerance - B = TTK.Label(Frame, text='Tolerance') B.grid(row=0, column=0, sticky=TK.EW) B = TTK.Entry(Frame, textvariable=VARS[0], background='White', width=5) B.grid(row=0, column=1, sticky=TK.EW) BB = CTK.infoBulle( parent=B, text= 'Tolerance used in boolean operations.\n0. means automatic setting.') # - Union - B = TTK.Button(Frame, text="Union", command=union) B.grid(row=1, column=0, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Union of two surfaces.') # - Difference - B = TTK.Button(Frame, text="Difference", command=difference) B.grid(row=1, column=1, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Difference of two surfaces.') # - Intersection - B = TTK.Button(Frame, text="Intersection", command=intersection) B.grid(row=2, column=0, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Intersect two surfaces.') # - Rev. Difference - B = TTK.Button(Frame, text="Rev. Diff", command=difference2) B.grid(row=2, column=1, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Reversed difference of two surfaces.')
def rotate(): if CTK.t == []: return if not CTK.__BUSY__: bb = G.bbox(CTK.t) xc = 0.5 * (bb[3] + bb[0]) yc = 0.5 * (bb[4] + bb[1]) zc = 0.5 * (bb[5] + bb[2]) pos = CPlot.getState('posCam') posCam = [pos[0], pos[1], pos[2]] posEye = [xc, yc, zc] dirCam = [0, 0, 1] CTK.__BUSY__ = True TTK.sunkButton(WIDGETS['rotate']) CPlot.setState(cursor=2) i = 0 while CTK.__BUSY__: speed = WIDGETS['speed'].get() * 0.0006 / 100. cs = math.cos(speed * i * math.pi / 180) ss = math.sin(speed * i * math.pi / 180) px = cs * (posCam[0] - xc) + ss * (posCam[1] - yc) + xc py = -ss * (posCam[0] - xc) + cs * (posCam[1] - yc) + yc posCam[0] = px posCam[1] = py CPlot.setState(posCam=posCam) time.sleep(CPlot.__timeStep__) WIDGETS['rotate'].update() i += 1 CTK.__BUSY__ = False TTK.raiseButton(WIDGETS['rotate']) CPlot.setState(cursor=0) else: CTK.__BUSY__ = False TTK.raiseButton(WIDGETS['rotate']) CPlot.setState(cursor=0)
def measure(): if CTK.t == []: return prev = [] w = WIDGETS['button'] if CTK.__BUSY__ == False: CTK.__BUSY__ = True TTK.sunkButton(w) CPlot.setState(cursor=1) while CTK.__BUSY__: CPlot.unselectAllZones() l = [] while (l == []): l = CPlot.getActivePoint() time.sleep(CPlot.__timeStep__) w.update() if CTK.__BUSY__ == False: break if CTK.__BUSY__ == True: if prev == []: prev = l CTK.TXT.insert('START', 'Click second point...\n') elif prev != l: dist = (l[0]-prev[0])*(l[0]-prev[0])+\ (l[1]-prev[1])*(l[1]-prev[1])+\ (l[2]-prev[2])*(l[2]-prev[2]) dist = math.sqrt(dist) CTK.TXT.insert('START', 'dist= ' + str(dist) + '\n') time.sleep(CPlot.__timeStep__) prev = [] CTK.__BUSY__ = False TTK.raiseButton(w) CPlot.setState(cursor=0) else: CTK.__BUSY__ = False TTK.raiseButton(w) CPlot.setState(cursor=0)
def createApp(win): # - Frame - Frame = TTK.LabelFrame(win, borderwidth=2, relief=CTK.FRAMESTYLE, text='tkTetraMesher', font=CTK.FRAMEFONT, takefocus=1) Frame.bind('<Control-c>', hideApp) Frame.bind('<ButtonRelease-3>', displayFrameMenu) Frame.bind('<Enter>', lambda event: Frame.focus_set()) Frame.columnconfigure(0, weight=1) Frame.columnconfigure(1, weight=1) #Frame.columnconfigure(1, weight=1) WIDGETS['frame'] = Frame # - Frame menu - FrameMenu = TK.Menu(Frame, tearoff=0) FrameMenu.add_command(label='Close', accelerator='Ctrl+c', command=hideApp) FrameMenu.add_command(label='Save', command=saveApp) FrameMenu.add_command(label='Reset', command=resetApp) CTK.addPinMenu(FrameMenu, 'tkTetraMesher') WIDGETS['frameMenu'] = FrameMenu # - VARS - # -0- Mesher type - V = TK.StringVar(win) V.set('tetgen') VARS.append(V) if 'tkTetraMesherType' in CTK.PREFS: V.set(CTK.PREFS['tkTetraMesherType']) # - mesher menu - B = TTK.OptionMenu(Frame, VARS[0], 'netgen', 'tetgen') B.grid(row=0, column=1, columnspan=1, sticky=TK.EW) # - Run - B = TTK.Button(Frame, text="tetraMesher", command=tetraMesher) B.grid(row=0, column=0, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Mesh with TETRAs or TRIs.')
def createApp(win): # - Frame - Frame = TTK.LabelFrame(win, borderwidth=2, relief=CTK.FRAMESTYLE, text='tkDraw', font=CTK.FRAMEFONT, takefocus=1) #BB = CTK.infoBulle(parent=Frame, text='Drawing tools.\nCtrl+c to close applet.', temps=0, btype=1) Frame.bind('<Control-c>', hideApp) Frame.bind('<ButtonRelease-3>', displayFrameMenu) Frame.bind('<Enter>', lambda event : Frame.focus_set()) Frame.columnconfigure(0, weight=2) Frame.columnconfigure(1, weight=2) Frame.columnconfigure(2, weight=1) WIDGETS['frame'] = Frame # - Frame menu - FrameMenu = TK.Menu(Frame, tearoff=0) FrameMenu.add_command(label='Close', accelerator='Ctrl+c', command=hideApp) FrameMenu.add_command(label='Save', command=saveApp) FrameMenu.add_command(label='Reset', command=resetApp) CTK.addPinMenu(FrameMenu, 'tkDraw') WIDGETS['frameMenu'] = FrameMenu # - VARS - # -0- Figure type - V = TK.StringVar(win); V.set('Line'); VARS.append(V) if 'tkDrawType' in CTK.PREFS: V.set(CTK.PREFS['tkDrawType']) # -1- Npts - V = TK.StringVar(win); V.set('10'); VARS.append(V) if 'tkDrawNpts' in CTK.PREFS: V.set(CTK.PREFS['tkDrawNpts']) # -2- underlaying surface V = TK.StringVar(win); V.set(''); VARS.append(V) # - Surface - B = TTK.Button(Frame, text="Surf", command=setSurface, image=iconics.PHOTO[8], compound=TK.RIGHT, padx=0, pady=0) B.grid(row=0, column=2, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Set underlaying model surfaces (you draw onto).') B = TTK.Entry(Frame, textvariable=VARS[2], background='White') B.grid(row=0, column=0, columnspan=2, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Underlaying model surfaces.') # - Figure type - B = TTK.OptionMenu(Frame, VARS[0], 'Line', 'Circle', 'Circular arc', 'Rectangle', 'Polyline', 'Cubic', 'Free hand') BB = CTK.infoBulle(parent=B, text='Type of drawing.') B.grid(row=1, column=0, sticky=TK.EW) # - Npts - B = TTK.Entry(Frame, textvariable=VARS[1], background='White', width=7) B.grid(row=1, column=1, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Number of points.') # - Draw - B = TTK.Button(Frame, text="Draw", command=draw) B.grid(row=1, column=2, columnspan=1, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Click to start to draw. Click again to end.') WIDGETS['draw'] = B
def drawCubic(npts): global CURRENTZONE; global CURRENTPOLYLINE if (CTK.t == []): return w = WIDGETS['draw'] if (CTK.__BUSY__ == False): CPlot.unselectAllZones() CTK.saveTree() CTK.__BUSY__ = True TTK.sunkButton(w) CPlot.setState(cursor=1) while (CTK.__BUSY__ == True): l = [] while (l == []): l = CPlot.getActivePoint() CPlot.unselectAllZones() time.sleep(CPlot.__timeStep__) w.update() if (CTK.__BUSY__ == False): break if (CTK.__BUSY__ == True): CURRENTPOLYLINE.append((l[0],l[1],l[2])) if (CURRENTZONE == None): CTK.t = C.addBase2PyTree(CTK.t, 'CONTOURS', 1) base = Internal.getNodeFromName1(CTK.t, 'CONTOURS') nob = C.getNobOfBase(base, CTK.t) a = D.polyline(CURRENTPOLYLINE) CURRENTZONE = a CTK.add(CTK.t, nob, -1, a) ret = Internal.getParentOfNode(CTK.t, CURRENTZONE) noz = ret[1] else: a = D.polyline(CURRENTPOLYLINE) CURRENTZONE = a CTK.replace(CTK.t, nob, noz, a) (CTK.Nb, CTK.Nz) = CPlot.updateCPlotNumbering(CTK.t) CTK.TKTREE.updateApp() CPlot.render() CTK.__BUSY__ = False TTK.raiseButton(w) CPlot.setState(cursor=0) else: CTK.__BUSY__ = False ret = Internal.getParentOfNode(CTK.t, CURRENTZONE) a = D.polyline(CURRENTPOLYLINE) d = G.cart( (0,0,0), (1./(npts-1),1,1), (npts,1,1) ) a = G.map(a, d) surfaces = getSurfaces() if (surfaces != []): a = T.projectOrthoSmooth(a, surfaces) nob = C.getNobOfBase(ret[0], CTK.t) CTK.replace(CTK.t, nob, ret[1], a) #C._fillMissingVariables(CTK.t) (CTK.Nb, CTK.Nz) = CPlot.updateCPlotNumbering(CTK.t) CTK.TKTREE.updateApp() CPlot.render() CURRENTZONE = None CURRENTPOLYLINE = [] TTK.raiseButton(w) CPlot.setState(cursor=0)
def createApp(win): # - Frame - Frame = TTK.LabelFrame(win, borderwidth=2, relief=CTK.FRAMESTYLE, text='tkMeshQual', font=CTK.FRAMEFONT, takefocus=1) #BB = CTK.infoBulle(parent=Frame, text='Analyse mesh quality.\nCtrl+c to close applet.', temps=0, btype=1) Frame.bind('<Control-c>', hideApp) Frame.bind('<ButtonRelease-3>', displayFrameMenu) Frame.bind('<Enter>', lambda event : Frame.focus_set()) Frame.columnconfigure(0, weight=1) Frame.columnconfigure(1, weight=1) WIDGETS['frame'] = Frame # - Frame menu - FrameMenu = TK.Menu(Frame, tearoff=0) FrameMenu.add_command(label='Close', accelerator='Ctrl+c', command=hideApp) CTK.addPinMenu(FrameMenu, 'tkMeshQual') WIDGETS['frameMenu'] = FrameMenu # - VARS - # -0- Qual to compute - V = TK.StringVar(win); V.set('Volume map'); VARS.append(V) # -0- Filter for view - V = TK.StringVar(win); V.set('Mesh'); VARS.append(V) # - Compute - B = TTK.Button(Frame, text="Compute", command=computeQual) B.grid(row=0, column=0, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Compute this field. Tree is modified.') B = TTK.OptionMenu(Frame, VARS[0], 'Volume map', 'Orthogonality map', 'Regularity map') B.grid(row=0, column=1, sticky=TK.EW) # - View - B = TTK.Button(Frame, text="View", command=viewQual) B.grid(row=1, column=0, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='View this filter.') B = TTK.OptionMenu(Frame, VARS[1], 'Mesh', 'Neg. volume cells') B.grid(row=1, column=1, sticky=TK.EW)
def createApp(win): # - Frame - Frame = TTK.LabelFrame(win, borderwidth=2, relief=CTK.FRAMESTYLE, text='tkFilterSurfs', font=CTK.FRAMEFONT, takefocus=1) #BB = CTK.infoBulle(parent=Frame, text='Filter or offset a surface.\nCtrl+c to close applet.', temps=0, btype=1) Frame.bind('<Control-c>', hideApp) Frame.bind('<ButtonRelease-3>', displayFrameMenu) Frame.bind('<Enter>', lambda event : Frame.focus_set()) Frame.columnconfigure(0, weight=1) Frame.columnconfigure(1, weight=2) Frame.columnconfigure(2, weight=2) Frame.columnconfigure(3, weight=0) WIDGETS['frame'] = Frame # - Frame menu - FrameMenu = TK.Menu(Frame, tearoff=0) FrameMenu.add_command(label='Close', accelerator='Ctrl+c', command=hideApp) FrameMenu.add_command(label='Save', command=saveApp) FrameMenu.add_command(label='Reset', command=resetApp) CTK.addPinMenu(FrameMenu, 'tkFilterSurfs') WIDGETS['frameMenu'] = FrameMenu # - VARS - # -0- Point density - V = TK.StringVar(win); V.set('1.'); VARS.append(V) if 'tkFilterSurfsDensity' in CTK.PREFS: V.set(CTK.PREFS['tkFilterSurfsDensity']) # -1- Offset - V = TK.StringVar(win); V.set('0.'); VARS.append(V) if 'tkFilterSurfsOffset' in CTK.PREFS: V.set(CTK.PREFS['tkFilterSurfsOffset']) # -2- Algorithm cart/octree V = TK.StringVar(win); V.set('0'); VARS.append(V) if 'tkFilterSurfsType' in CTK.PREFS: V.set(CTK.PREFS['tkFilterSurfsType']) # - Point density - B = TTK.Label(Frame, text="density/offset") B.grid(row=0, column=0, sticky=TK.EW) B = TTK.Entry(Frame, textvariable=VARS[0], background='White', width=8) B.grid(row=0, column=1, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Point density (npts/length unit).') # - Offset - B = TTK.Entry(Frame, textvariable=VARS[1], background='White', width=8) B.grid(row=0, column=2, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Distance of surface offset.') # - Algorithm - B = TTK.Checkbutton(Frame, text='', variable=VARS[2]) B.grid(row=0, column=3, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Toggle octree algorithm.') # - Remap - B = TTK.Button(Frame, text="Filter/offset", command=remap) BB = CTK.infoBulle(parent=B, text='Remap/offset a surface with a given spacing.') B.grid(row=2, column=0, columnspan=4, sticky=TK.EW)
def drawLine(npts): CTK.t = C.addBase2PyTree(CTK.t, 'CONTOURS', 1) nodes = Internal.getNodesFromName1(CTK.t, 'CONTOURS') nob = C.getNobOfBase(nodes[0], CTK.t) CTK.TXT.insert('START', 'Click first point...\n') prev = [] if CTK.__BUSY__ == False: CTK.__BUSY__ = True TTK.sunkButton(WIDGETS['draw']) CPlot.setState(cursor=1) while CTK.__BUSY__: CPlot.unselectAllZones() CTK.saveTree() surfaces = getSurfaces() l = [] while l == []: l = CPlot.getActivePoint() time.sleep(CPlot.__timeStep__) WIDGETS['draw'].update() if CTK.__BUSY__ == False: break if CTK.__BUSY__: if prev == []: prev = l CTK.TXT.insert('START', 'Click second point...\n') elif (prev != l): line = D.line(prev, l, npts) if surfaces != []: line = T.projectOrthoSmooth(line, surfaces) CTK.add(CTK.t, nob, -1, line) CTK.TXT.insert('START', 'Line created.\n') CTK.__BUSY__ = False TTK.raiseButton(WIDGETS['draw']) #C._fillMissingVariables(CTK.t) (CTK.Nb, CTK.Nz) = CPlot.updateCPlotNumbering(CTK.t) CTK.TKTREE.updateApp() CPlot.render() CPlot.setState(cursor=0) prev = [] return CTK.__BUSY__ = False TTK.raiseButton(WIDGETS['draw']) CPlot.setState(cursor=0) else: CTK.__BUSY__ = False TTK.raiseButton(WIDGETS['draw']) CPlot.setState(cursor=0) return
def createApp(win): # - Frame - Frame = TTK.LabelFrame(win, borderwidth=2, relief=CTK.FRAMESTYLE, text='tkReorder', font=CTK.FRAMEFONT, takefocus=1) #BB = CTK.infoBulle(parent=Frame, text='Reorder blocks.\nCtrl+c to close applet.', temps=0, btype=1) Frame.bind('<Control-c>', hideApp) Frame.bind('<ButtonRelease-3>', displayFrameMenu) Frame.bind('<Enter>', lambda event : Frame.focus_set()) Frame.columnconfigure(0, weight=1) Frame.columnconfigure(1, weight=1) WIDGETS['frame'] = Frame # - Frame menu - FrameMenu = TK.Menu(Frame, tearoff=0) FrameMenu.add_command(label='Close', accelerator='Ctrl+c', command=hideApp) CTK.addPinMenu(FrameMenu, 'tkReorder') WIDGETS['frameMenu'] = FrameMenu # -0- Transformation de i - V = TK.StringVar(win); V.set('I -> I'); VARS.append(V) # -1- Transformation de j - V = TK.StringVar(win); V.set('J -> J'); VARS.append(V) # -2- Transformation de k - V = TK.StringVar(win); V.set('K -> K'); VARS.append(V) # - Index switch for structured grids B = TTK.OptionMenu(Frame, VARS[0], 'I -> I', 'I -> -I', 'I -> J', 'I -> -J', 'I -> K', 'I -> -K') B.grid(row=0, column=0, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Transformation of i index.') B = TTK.OptionMenu(Frame, VARS[1], 'J -> I', 'J -> -I', 'J -> J', 'J -> -J', 'J -> K', 'J -> -K') B.grid(row=0, column=1, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Transformation of j index.') B = TTK.OptionMenu(Frame, VARS[2], 'K -> I', 'K -> -I', 'K -> J', 'K -> -J', 'K -> K', 'K -> -K') B.grid(row=0, column=2, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Transformation of k index.') # - Bouton reorder - B = TTK.Button(Frame, text="Reorder", command=reorder) B.grid(row=1, column=0, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Reorder the numerotation of block.') # - Bouton reorderAll - B = TTK.Button(Frame, text="ReorderAll", command=reorderAll) BB = CTK.infoBulle(parent=B, text='Reorder all blocks even with overlaps.') B.grid(row=1, column=1, columnspan=1, sticky=TK.EW) # - Bouton makeDirect - B = TTK.Button(Frame, text="makeDirect", command=makeDirect) BB = CTK.infoBulle(parent=B, text='Make structured blocks direct.') B.grid(row=1, column=2, columnspan=1, sticky=TK.EW)
def createApp(win): # - Frame - Frame = TTK.LabelFrame(win, borderwidth=2, relief=CTK.FRAMESTYLE, text='tkCells', font=CTK.FRAMEFONT, takefocus=1) #BB = CTK.infoBulle(parent=Frame, text='Per cell operation\non meshes.\nCtrl+c to close applet.', temps=0, btype=1) Frame.bind('<Control-c>', hideApp) Frame.bind('<ButtonRelease-3>', displayFrameMenu) Frame.bind('<Enter>', lambda event: Frame.focus_set()) Frame.columnconfigure(0, weight=1) Frame.columnconfigure(1, weight=4) Frame.columnconfigure(2, weight=0) WIDGETS['frame'] = Frame # - Frame menu - FrameMenu = TK.Menu(Frame, tearoff=0) FrameMenu.add_command(label='Close', accelerator='Ctrl+c', command=hideApp) CTK.addPinMenu(FrameMenu, 'tkCells') WIDGETS['frameMenu'] = FrameMenu # - VARS - # -0- selection formula - V = TK.StringVar(win) V.set('') VARS.append(V) # -1- strict - V = TK.StringVar(win) V.set('0') VARS.append(V) # - Cells suppress/refine - B = TTK.Button(Frame, text="Suppress cell mode", command=suppressCells) B.grid(row=0, column=0, columnspan=3, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Suppress selected cell.') WIDGETS['suppress'] = B B = TTK.Button(Frame, text="Refine cell mode", command=refineCells) B.grid(row=1, column=0, columnspan=3, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Refine selected cell (TRI mesh only).') WIDGETS['refine'] = B # - Select cells - B = TTK.Button(Frame, text="SelectCells", command=selectCells) B.grid(row=2, column=0, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Select cells that matches formula.') B = TTK.Entry(Frame, textvariable=VARS[0], background='White') B.bind('<Return>', selectCells) BB = CTK.infoBulle(parent=B, text='Selection formula.') B.grid(row=2, column=1, sticky=TK.EW) B = TTK.Checkbutton(Frame, text='', variable=VARS[1]) BB = CTK.infoBulle(parent=B, text='Strict/not strict selection.') B.grid(row=2, column=2, sticky=TK.EW)
def orbite(): if CTK.t == []: return if not CTK.__BUSY__: name = VARS[0].get() names = name.split(';') # Get paths paths = [] for v in names: v = v.lstrip() v = v.rstrip() sname = v.split('/', 1) bases = Internal.getNodesFromName1(CTK.t, sname[0]) if bases != []: nodes = Internal.getNodesFromType1(bases[0], 'Zone_t') for z in nodes: if z[0] == sname[1]: paths.append(z) # Keep only 1D arrays path = [] for p in paths: dim = Internal.getZoneDim(p) if (dim[0] == 'Unstructured' and dim[3] == 'BAR'): path.append(p) if (dim[0] == 'Structured' and dim[2] == 1 and dim[3] == 1): path.append(C.convertArray2Tetra(p)) if path == []: return path = T.join(path) path = G.close(path) path = C.convertBAR2Struct(path) dim = Internal.getZoneDim(path) N = dim[1] CTK.__BUSY__ = True TTK.sunkButton(WIDGETS['orbite']) CPlot.setState(cursor=2) i = 0 while CTK.__BUSY__: speed = 100. - WIDGETS['speed'].get() time.sleep(CPlot.__timeStep__ * speed * 0.06) if i > N - 1: i = 0 if i + N / 10 > N - 1: inc = 1 else: inc = N / 10 posCam = C.getValue(path, Internal.__GridCoordinates__, i) posEye = C.getValue(path, Internal.__GridCoordinates__, i + inc) CPlot.setState(posCam=posCam, posEye=posEye) WIDGETS['orbite'].update() i += 1 CTK.__BUSY__ = False TTK.raiseButton(WIDGETS['orbite']) CPlot.setState(cursor=0) else: CTK.__BUSY__ = False TTK.raiseButton(WIDGETS['orbite']) CPlot.setState(cursor=0)
def createApp(win): # - Frame - Frame = TTK.LabelFrame(win, borderwidth=2, relief=CTK.FRAMESTYLE, text='tkPersonal', font=CTK.FRAMEFONT, takefocus=1) #BB = CTK.infoBulle(parent=Frame, text='My personal applet.\nCtrl+c to close applet.', temps=0, btype=1) Frame.bind('<Control-c>', hideApp) Frame.bind('<ButtonRelease-3>', displayFrameMenu) Frame.bind('<Enter>', lambda event: Frame.focus_set()) Frame.columnconfigure(0, weight=1) Frame.columnconfigure(1, weight=1) WIDGETS['frame'] = Frame # - Frame menu - FrameMenu = TK.Menu(Frame, tearoff=0) FrameMenu.add_command(label='Close', accelerator='Ctrl+c', command=hideApp) CTK.addPinMenu(FrameMenu, 'tkPersonalSample') WIDGETS['frameMenu'] = FrameMenu
def translateClick(): if CTK.t == []: return if CTK.__MAINTREE__ <= 0: CTK.TXT.insert('START', 'Fail on a temporary tree.\n') CTK.TXT.insert('START', 'Error: ', 'Error') return prev = [] w = WIDGETS['translate'] if CTK.__BUSY__ == False: CTK.__BUSY__ = True nzs = CPlot.getSelectedZones() CTK.TXT.insert('START', 'Click start point...\n') TTK.sunkButton(w) while CTK.__BUSY__: CPlot.unselectAllZones() l = [] while l == []: l = CPlot.getActivePoint() time.sleep(CPlot.__timeStep__) w.update() if CTK.__BUSY__ == False: break if CTK.__BUSY__: if prev == []: prev = l if nzs == []: nzs = CPlot.getSelectedZones() CTK.TXT.insert('START', 'Click end point...\n') elif prev != l: CTK.saveTree() vx = l[0] - prev[0] vy = l[1] - prev[1] vz = l[2] - prev[2] for nz in nzs: nob = CTK.Nb[nz] + 1 noz = CTK.Nz[nz] z = CTK.t[2][nob][2][noz] a = T.translate(z, (vx, vy, vz)) CTK.replace(CTK.t, nob, noz, a) CTK.TKTREE.updateApp() CTK.TXT.insert('START', 'Zones translated.\n') CPlot.render() prev = [] break CTK.__BUSY__ = False TTK.raiseButton(w) else: CTK.__BUSY__ = False TTK.raiseButton(w)
def fly(): if CTK.t == []: return if not CTK.__BUSY__: bb = G.bbox(CTK.t) xc = 0.5 * (bb[3] + bb[0]) yc = 0.5 * (bb[4] + bb[1]) zc = 0.5 * (bb[5] + bb[2]) pos = CPlot.getState('posCam') posCam = [pos[0], pos[1], pos[2]] step = 0.0001 sigma = 10 beta = 8 / 3 ro = 28 CTK.__BUSY__ = True TTK.sunkButton(WIDGETS['fly']) CPlot.setState(cursor=2) i = 0 while CTK.__BUSY__: speed = WIDGETS['speed'].get() / 50. CPlot.setState(posCam=posCam) time.sleep(CPlot.__timeStep__) x = posCam[0] - xc y = posCam[2] - yc z = posCam[1] - zc x = 10 * x / max((bb[3] - bb[0]), 1.e-10) y = 10 * y / max((bb[4] - bb[1]), 1.e-10) z = 30 * z / max((bb[5] - bb[2]), 1.e-10) xp = x + step * speed * sigma * (y - x) yp = y + step * speed * (ro * x - y - x * z) zp = z + step * speed * (x * y - beta * z) xp = xp * (bb[3] - bb[0]) * 0.1 + xc 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 WIDGETS['fly'].update() i += 1 CTK.__BUSY__ = False TTK.raiseButton(WIDGETS['fly']) CPlot.setState(cursor=0) else: CTK.__BUSY__ = False TTK.raiseButton(WIDGETS['fly']) CPlot.setState(cursor=0)
def refineCells(): if CTK.t == []: return if CTK.__MAINTREE__ <= 0: CTK.TXT.insert('START', 'Fail on a temporary tree.\n') CTK.TXT.insert('START', 'Error: ', 'Error') return W = WIDGETS['refine'] if CTK.__BUSY__ == False: CPlot.unselectAllZones() CTK.__BUSY__ = True TTK.sunkButton(W) CPlot.setState(cursor=1) while CTK.__BUSY__: l = [] while l == []: nz = CPlot.getSelectedZone() l = CPlot.getActivePointIndex() CPlot.unselectAllZones() time.sleep(CPlot.__timeStep__) W.update() if CTK.__BUSY__ == False: break if CTK.__BUSY__: nob = CTK.Nb[nz] + 1 noz = CTK.Nz[nz] CTK.saveTree() z = CTK.t[2][nob][2][noz] C._initVars(z, 'centers:__tag__', 0) C.setValue(z, 'centers:__tag__', l[1], 1) try: z = P.refine(z, '__tag__') CTK.replace(CTK.t, nob, noz, z) except: pass CTK.TKTREE.updateApp() CPlot.render() CTK.__BUSY__ = False TTK.raiseButton(W) CPlot.setState(cursor=0) else: CTK.__BUSY__ = False TTK.raiseButton(W) CPlot.setState(cursor=0)
def createApp(win): ttk = CTK.importTtk() # - Frame - Frame = TTK.LabelFrame(win, borderwidth=2, relief=CTK.FRAMESTYLE, text='tkIsoSurf', font=CTK.FRAMEFONT, takefocus=1) #BB = CTK.infoBulle(parent=Frame, text='Compute iso-surfaces.\nCtrl+c to close applet.', temps=0, btype=1) Frame.bind('<Control-c>', hideApp) Frame.bind('<ButtonRelease-3>', displayFrameMenu) Frame.bind('<Enter>', lambda event : Frame.focus_set()) Frame.columnconfigure(0, weight=1) Frame.columnconfigure(1, weight=1) Frame.columnconfigure(2, weight=0) WIDGETS['frame'] = Frame # - Frame menu - FrameMenu = TK.Menu(Frame, tearoff=0) FrameMenu.add_command(label='Close', accelerator='Ctrl+c', command=hideApp) FrameMenu.add_command(label='Save', command=saveApp) FrameMenu.add_command(label='Reset', command=resetApp) CTK.addPinMenu(FrameMenu, 'tkIsoSurf') WIDGETS['frameMenu'] = FrameMenu # - VARS - # -0- Field name - V = TK.StringVar(win); V.set('CoordinateX'); VARS.append(V) # -1- value - V = TK.StringVar(win); V.set('1.'); VARS.append(V) if 'tkIsoSurfValue' in CTK.PREFS: V.set(CTK.PREFS['tkIsoSurfValue']) # - field name - F = TTK.Frame(Frame, borderwidth=0) F.columnconfigure(0, weight=1) if ttk is None: B = TK.OptionMenu(F, VARS[0], '') B.grid(sticky=TK.EW) F.bind('<Enter>', updateVarNameList) F.grid(row=0, column=0, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Extracted field.') WIDGETS['field'] = B else: B = ttk.Combobox(F, textvariable=VARS[0], values=[], state='readonly', width=10) B.grid(sticky=TK.EW) F.bind('<Enter>', updateVarNameList2) F.grid(row=0, column=0, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Extracted field.') WIDGETS['field'] = B # - Value - B = TTK.Entry(Frame, textvariable=VARS[1], background='White', width=7) BB = CTK.infoBulle(parent=B, text='Extracted field value.') B.bind('<Return>', extractIsoSurf) B.grid(row=0, column=1, sticky=TK.EW) # - Get value from mouse - B = TTK.Button(Frame, image=iconics.PHOTO[8], command=getValueFromMouse, padx=0) B.grid(row=0, column=2, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Get value from mouse.') # - Extract - B = TTK.Button(Frame, text="Extract isosurf", command=extractIsoSurf) B.grid(row=1, column=0, columnspan=3, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Extract isosurf to SURFACES.')
def createApp(win): # - Frame - Frame = TTK.LabelFrame(win, borderwidth=2, relief=CTK.FRAMESTYLE, text='tkCanvas', font=CTK.FRAMEFONT, takefocus=1) #BB = CTK.infoBulle(parent=Frame, text='Manage a canvas\nfor drawing..\nCtrl+c to close applet.', temps=0, btype=1) Frame.bind('<Control-c>', hideApp) Frame.bind('<ButtonRelease-3>', displayFrameMenu) Frame.bind('<Enter>', lambda event: Frame.focus_set()) Frame.columnconfigure(0, weight=1) Frame.columnconfigure(1, weight=1) Frame.columnconfigure(2, weight=4) WIDGETS['frame'] = Frame # - Frame menu - FrameMenu = TK.Menu(Frame, tearoff=0) FrameMenu.add_command(label='Close', accelerator='Ctrl+c', command=hideApp) FrameMenu.add_command(label='Save', command=saveApp) FrameMenu.add_command(label='Reset', command=resetApp) CTK.addPinMenu(FrameMenu, 'tkCanvas') WIDGETS['frameMenu'] = FrameMenu # - VARS - # -0- Canvas dir V = TK.StringVar(win) V.set('None') VARS.append(V) # -1- Canvas pos V = TK.StringVar(win) V.set('0.') VARS.append(V) # -2- Canvas dir step V = TK.StringVar(win) V.set('0.1') VARS.append(V) if 'tkCanvasDirStep' in CTK.PREFS: V.set(CTK.PREFS['tkCanvasDirStep']) # -3- Canvas enlarge step V = TK.StringVar(win) V.set('1.') VARS.append(V) if 'tkCanvasEnlargeStep' in CTK.PREFS: V.set(CTK.PREFS['tkCanvasEnlargeStep']) # - Direction - B = TTK.OptionMenu(Frame, VARS[0], 'None', 'View', 'XY', 'XZ', 'YZ', command=initCanvas) B.grid(row=0, column=0, columnspan=1, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Create a canvas.') # - Refresh - B = TTK.Button(Frame, text="", command=initCanvas, image=iconics.PHOTO[8], padx=0, pady=2) B.grid(row=0, column=1, sticky=TK.EW) BB = CTK.infoBulle( parent=B, text= 'Refresh canvas.\nUpdate it to make it pass through selection point.') # - Position - B = TTK.Entry(Frame, textvariable=VARS[1], background='White', width=7) B.bind('<Return>', setCanvasPos) B.grid(row=0, column=2, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Canvas position.') # - Move canvas - B = TTK.Button(Frame, text="+", command=moveUp) B.grid(row=1, column=0, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Move canvas right.') B = TTK.Button(Frame, text="-", command=moveDown) B.grid(row=1, column=1, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Move canvas left.') B = TTK.Entry(Frame, textvariable=VARS[2], background='White', width=7) B.grid(row=1, column=2, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Canvas move step.') # - Enlarge / reduce - B = TTK.Button(Frame, text="Enlarge", command=enlarge) B.grid(row=2, column=0, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Enlarge canvas.') B = TTK.Button(Frame, text="Reduce", command=reduce) B.grid(row=2, column=1, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Reduce canvas.') B = TTK.Entry(Frame, textvariable=VARS[3], background='White', width=7) B.grid(row=2, column=2, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Canvas enlarge step.')
def createApp(win): # - Frame - Frame = TTK.LabelFrame(win, borderwidth=2, relief=CTK.FRAMESTYLE, text='tkExtrusion', font=CTK.FRAMEFONT, takefocus=1) #BB = CTK.infoBulle(parent=Frame, text='Extrude a mesh.\nCtrl+c to close applet.', temps=0, btype=1) Frame.bind('<Control-c>', hideApp) Frame.bind('<ButtonRelease-3>', displayFrameMenu) Frame.bind('<Enter>', lambda event: Frame.focus_set()) Frame.columnconfigure(0, weight=1) Frame.columnconfigure(1, weight=1) Frame.columnconfigure(2, weight=1) WIDGETS['frame'] = Frame # - Frame menu - FrameMenu = TK.Menu(Frame, tearoff=0) FrameMenu.add_command(label='Close', accelerator='Ctrl+c', command=hideApp) FrameMenu.add_command(label='Save', command=saveApp) FrameMenu.add_command(label='Reset', command=resetApp) CTK.addPinMenu(FrameMenu, 'tkExtrusion') WIDGETS['frameMenu'] = FrameMenu # - VARS - # -0- Hauteur de chaque maille - V = TK.StringVar(win) V.set('1.e-1') VARS.append(V) if 'tkExtrusionHeight' in CTK.PREFS: V.set(CTK.PREFS['tkExtrusionHeight']) # -1- Nombre de layers a ajouter V = TK.StringVar(win) V.set('1') VARS.append(V) if 'tkExtrusionNLayers' in CTK.PREFS: V.set(CTK.PREFS['tkExtrusionNLayers']) # -2- Nombre d'iterations de lissage V = TK.StringVar(win) V.set('50') VARS.append(V) if 'tkExtrusionSmooth' in CTK.PREFS: V.set(CTK.PREFS['tkExtrusionSmooth']) # -3- Driving curve V = TK.StringVar(win) V.set('') VARS.append(V) # -4- Axis for revolve V = TK.StringVar(win) V.set('') VARS.append(V) # -5- Angle for revolve V = TK.StringVar(win) V.set('360.') VARS.append(V) if 'tkExtrusionRevAngle' in CTK.PREFS: V.set(CTK.PREFS['tkExtrusionRevAngle']) # -6- Npts for revolve V = TK.StringVar(win) V.set('30') VARS.append(V) if 'tkExtrusionNpts' in CTK.PREFS: V.set(CTK.PREFS['tkExtrusionNpts']) # - AddNormalLayers - B = TTK.Entry(Frame, textvariable=VARS[0], background='White', width=5) B.grid(row=0, column=0, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Height of each layer.') B = TTK.Entry(Frame, textvariable=VARS[1], background='White', width=5) B.grid(row=0, column=1, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Number of layers.') B = TTK.Entry(Frame, textvariable=VARS[2], background='White', width=5) B.grid(row=0, column=2, columnspan=1, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Number of smoothing iterations.') B = TTK.Button(Frame, text="Add layers", command=addLayers) B.grid(row=1, column=0, columnspan=2, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Add normal layers to surface.') B = TTK.Button(Frame, text="Add k planes", command=addkplanes) B.grid(row=1, column=2, columnspan=1, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Add k planes.') # - Extrusion suivant une courbe - B = TTK.Button(Frame, text="Curve(s)", command=setCurve, image=iconics.PHOTO[8], padx=0, pady=0, compound=TK.RIGHT) B.grid(row=2, column=2, columnspan=1, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Set driving curve(s) for extrusion.') B = TTK.Entry(Frame, textvariable=VARS[3], background='White') B.grid(row=2, column=0, columnspan=2, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Driving curve(s) for extrusion.') B = TTK.Button(Frame, text="LineDrive", command=lineDrive) B.grid(row=3, column=0, columnspan=2, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Extrude following linearly curve(s).') B = TTK.Button(Frame, text="OrthoDrive", command=orthoDrive) B.grid(row=3, column=2, columnspan=1, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Extrude following orthogonally curve(s).') # - Revolve - B = TTK.Button(Frame, text="Axis", command=setAxis, image=iconics.PHOTO[8], padx=0, pady=0, compound=TK.RIGHT) B.grid(row=4, column=2, columnspan=1, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Set axis for revolve.') B = TTK.Entry(Frame, textvariable=VARS[4], background='White') B.grid(row=4, column=0, columnspan=2, sticky=TK.EW) BB = CTK.infoBulle( parent=B, text='Axis for revolve or\nAxis + rmod curve for revolve.') B = TTK.Entry(Frame, textvariable=VARS[5], background='White', width=5) B.grid(row=5, column=0, columnspan=1, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Angle for revolve.') B = TTK.Entry(Frame, textvariable=VARS[6], background='White', width=5) B.grid(row=5, column=1, columnspan=1, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Number of points in revolve.') B = TTK.Button(Frame, text="Revolve", command=revolve) B.grid(row=5, column=2, columnspan=1, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Revolve following axis.')
def createApp(win): # - Frame - Frame = TTK.LabelFrame(win, borderwidth=2, relief=CTK.FRAMESTYLE, text='tkCassiopeeSolver', font=CTK.FRAMEFONT, takefocus=1) #BB = CTK.infoBulle(parent=Frame, text='Export to Cassiopee \nCartesian solver.\nCtrl+c to close applet.', temps=0, btype=1) Frame.bind('<Control-c>', hideApp) Frame.bind('<ButtonRelease-3>', displayFrameMenu) Frame.bind('<Enter>', lambda event: Frame.focus_set()) Frame.columnconfigure(0, weight=0) Frame.columnconfigure(1, weight=1) WIDGETS['frame'] = Frame # - Frame menu - FrameMenu = TK.Menu(Frame, tearoff=0) FrameMenu.add_command(label='Close', accelerator='Ctrl+c', command=hideApp) CTK.addPinMenu(FrameMenu, 'tkCassiopeeSolver') WIDGETS['frameMenu'] = FrameMenu # - VARS - # -0- Integ - V = TK.StringVar(win) V.set('steady') VARS.append(V) # -1- Scheme - V = TK.StringVar(win) V.set('jameson') VARS.append(V) # -2- Inititer V = TK.StringVar(win) V.set('1') VARS.append(V) # -3- Niter V = TK.StringVar(win) V.set('10') VARS.append(V) # -4- Chimera option V = TK.StringVar(win) V.set('Solver performs hole cutting') VARS.append(V) # -5- double wall tolerance - V = TK.StringVar(win) V.set('10.') VARS.append(V) # -6- delta XRay - V = TK.StringVar(win) V.set('1.e-10') VARS.append(V) # -7- tolerance XRay - V = TK.StringVar(win) V.set('1.e-8') VARS.append(V) # -8- Cartesian option - V = TK.StringVar(win) V.set('No Cartesian generation') VARS.append(V) # -9- Dfar - V = TK.StringVar(win) V.set('10.') VARS.append(V) # - Integ - B = TTK.Label(Frame, text="Integ") B.grid(row=0, column=0, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Kind of integration.') B = TTK.OptionMenu(Frame, VARS[0], 'steady', 'unsteady', 'gear') B.grid(row=0, column=1, sticky=TK.EW) # - Scheme - B = TTK.Label(Frame, text="Scheme") B.grid(row=1, column=0, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Numerical scheme used.') B = TTK.OptionMenu(Frame, VARS[1], 'jameson', 'jameson_ho', 'jameson_ho5', 'roe', 'ausmppmiles', 'ausmpup') B.grid(row=1, column=1, sticky=TK.EW) # - Inititer - B = TTK.Label(Frame, text="Inititer") B.grid(row=2, column=0, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='First iteration of this computation.') B = TTK.Entry(Frame, textvariable=VARS[2]) B.grid(row=2, column=1, sticky=TK.EW) # - Niter - B = TTK.Label(Frame, text="Niter") B.grid(row=3, column=0, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Number of iterations of this computation.') B = TTK.Entry(Frame, textvariable=VARS[3]) B.grid(row=3, column=1, sticky=TK.EW) # - Chimera settings - B = TTK.OptionMenu(Frame, VARS[4], 'Solver performs hole cutting', 'Use OversetHole nodes') B.grid(row=4, column=0, columnspan=2, sticky=TK.EW) #- XRay settings - B = TTK.Label(Frame, text="XRay delta") B.grid(row=5, column=0, sticky=TK.EW) B = TTK.Entry(Frame, textvariable=VARS[6]) B.grid(row=5, column=1, sticky=TK.EW) # - Cartesian option - B = TTK.OptionMenu(Frame, VARS[8], 'Cartesian mesh generation', 'No Cartesian generation') B.grid(row=6, column=0, columnspan=2, sticky=TK.EW) #- Dfar settings - B = TTK.Label(Frame, text="Dfar") B.grid(row=7, column=0, sticky=TK.EW) B = TTK.Entry(Frame, textvariable=VARS[9]) B.grid(row=7, column=1, sticky=TK.EW) # - Run - B = TTK.Button(Frame, text="Run", command=run) B.grid(row=8, column=0, sticky=TK.EW) # - Write setup file - B = TTK.Button(Frame, text="Write setup", command=writeSetupFile) B.grid(row=8, column=1, sticky=TK.EW)
def createApp(win): ttk = CTK.importTtk() # - Frame - Frame = TTK.LabelFrame(win, borderwidth=2, relief=CTK.FRAMESTYLE, text='tkRenderSet', font=CTK.FRAMEFONT, takefocus=1) #BB = CTK.infoBulle(parent=Frame, text='Customize block rendering\n(render mode).\nCtrl+c to close applet.', temps=0, btype=1) Frame.bind('<Control-c>', hideApp) Frame.bind('<ButtonRelease-3>', displayFrameMenu) Frame.bind('<Enter>', lambda event: Frame.focus_set()) Frame.columnconfigure(0, weight=1) Frame.columnconfigure(1, weight=1) WIDGETS['frame'] = Frame # - Frame menu - FrameMenu = TK.Menu(Frame, tearoff=0) FrameMenu.add_command(label='Close', accelerator='Ctrl+c', command=hideApp) CTK.addPinMenu(FrameMenu, 'tkRenderSet') WIDGETS['frameMenu'] = FrameMenu # - VARS - # -0- Material - V = TK.StringVar(win) V.set('Solid') VARS.append(V) # -1- Color - V = TK.StringVar(win) V.set('White') VARS.append(V) # -2- Blending V = TK.StringVar(win) V.set('1.') VARS.append(V) # -3- Mesh overlay V = TK.StringVar(win) V.set('0') VARS.append(V) # -4- Shader parameter1 info bulle V = TK.StringVar(win) V.set('Shader parameter 1.') VARS.append(V) # -5- Shader parameter2 info bulle V = TK.StringVar(win) V.set('Shader parameter 2.') VARS.append(V) # -6- Blending info bulle V = TK.StringVar(win) V.set('Blending.') VARS.append(V) # - set Blending - B = TTK.Scale(Frame, from_=0, to=100, orient=TK.HORIZONTAL, command=setBlending, showvalue=0, borderwidth=1, value=100) WIDGETS['blending'] = B B.grid(row=0, column=0, sticky=TK.EW) BB = CTK.infoBulle(parent=B, textVariable=VARS[6]) # - set mesh overlay - B = TTK.Checkbutton(Frame, text='Mesh', variable=VARS[3], command=setMeshOverlay) BB = CTK.infoBulle(parent=B, text='Add underlaying mesh.') B.grid(row=0, column=1, sticky=TK.EW) # - set shader parameter 1 & 2- B = TTK.Scale(Frame, from_=0, to=100, orient=TK.HORIZONTAL, command=setShaderParameter, showvalue=0, borderwidth=1, value=50) WIDGETS['param1'] = B B.grid(row=1, column=0, sticky=TK.EW) BB = CTK.infoBulle(parent=B, textVariable=VARS[4]) # - set shader parameter 2 - B = TTK.Scale(Frame, from_=0, to=100, orient=TK.HORIZONTAL, command=setShaderParameter, showvalue=0, borderwidth=1, value=50) WIDGETS['param2'] = B B.grid(row=1, column=1, sticky=TK.EW) BB = CTK.infoBulle(parent=B, textVariable=VARS[5]) # - set Material - B = TTK.Button(Frame, text="Set Material", command=setMaterial) B.grid(row=2, column=0, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Set the material render property.') B = TTK.OptionMenu(Frame, VARS[0], *MATERIALS) B.grid(row=2, column=1, sticky=TK.EW) # - set Color - B = TTK.Button(Frame, text="Set Color", command=setColor) B.grid(row=3, column=0, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Set the color render property.') F = TTK.Frame(Frame, borderwidth=0) F.columnconfigure(0, weight=1) if ttk is None: B = TK.OptionMenu(F, VARS[1], '') B.grid(sticky=TK.EW) F.bind('<Enter>', updateVarNameList) F.grid(row=3, column=1, sticky=TK.EW) WIDGETS['colors'] = B else: B = ttk.Combobox(F, textvariable=VARS[1], values=[], state='readonly', height=11) B.bind('<<ComboboxSelected>>', setColorVar2) B.grid(sticky=TK.EW) F.bind('<Enter>', updateVarNameList2) F.grid(row=3, column=1, sticky=TK.EW) WIDGETS['colors'] = B # - set all properties - F = TTK.Frame(Frame, borderwidth=0) F.columnconfigure(0, weight=1) F.columnconfigure(1, weight=0) B = TTK.Button(F, text="Set all properties", command=setAll) B.grid(row=0, column=0, columnspan=1, sticky=TK.EW) BB = CTK.infoBulle(parent=B, text='Set all render properties.') B = TTK.Button(F, command=getData, image=iconics.PHOTO[8], padx=0, pady=0) BB = CTK.infoBulle(parent=B, text='Get data from selected zone.') B.grid(row=0, column=1, sticky=TK.EW) F.grid(row=4, column=0, columnspan=2, sticky=TK.EW)