[HELP]About pick cells. #862
Answered
by
marcomusy
ZiguoAtGitHub
asked this question in
Q&A
-
Hi Marco, from vedo import *
import tkinter as tk
import tkinter.filedialog as fdlg
import tkinter.ttk as ttk
import tkinter.messagebox as msgbox
class MainGUI(tk.Frame):
def __init__(self, master=None):
tk.Frame.__init__(self, master)
self.grid()
scrwidth = self.winfo_screenwidth()
scrheight = self.winfo_screenheight()
self.Plot_But=ttk.Button(self,text='显示',command=self.plot)
self.Plot_But.grid(row=0,column=0)
#~~
self.plt= Plotter(axes=4)
self.plt.add_callback("mouse click", self.vedo_pick_cell)
# ======================================================
def vedo_pick_cell(self,evt):
msh = evt.actor
itemp=10
if not msh:return
pt = evt.picked3d
idcell = msh.closest_point(pt, return_cell_id=True)
msh.cellcolors[idcell] = [255,0,0,255] # red, opaque
#----------------------------------------------------------
def plot(self):
self.plt.clear(deep=True, render=False)
self.plt.actors.clear()
line_cell=[((-5000,-5000,0),(-4000,-4000,5000)),((-5000,-5000,0),(-4000,4000,5000)),((-5000,-5000,0),(4000,-4000,5000)),
((-5000,5000,0),(-4000,4000,5000)),((-5000,5000,0),(-4000,-4000,5000)),((-5000,5000,0),(4000,4000,5000)),
((5000,-5000,0),(4000,-4000,5000)),((5000,-5000,0),(4000,4000,5000)),((5000,-5000,0),(-4000,-4000,5000)),
((5000,5000,0),(4000,4000,5000)),((5000,5000,0),(4000,-4000,5000)),((5000,5000,0),(-4000,4000,5000)),
((-4000,-4000,5000),(-3000,-3000,10000)),((-4000,-4000,5000),(-3000,3000,10000)),((-4000,-4000,5000),(3000,-3000,10000)),
((-4000,4000,5000),(-3000,3000,10000)),((-4000,4000,5000),(-3000,-3000,10000)),((-4000,4000,5000),(3000,3000,10000)),
((4000,-4000,5000),(3000,-3000,10000)),((4000,-4000,5000),(3000,3000,10000)),((4000,-4000,5000),(-3000,-3000,10000)),
((4000,4000,5000),(3000,3000,10000)),((4000,4000,5000),(3000,-3000,10000)),((4000,4000,5000),(-3000,3000,10000)),
((-3000,-3000,10000),(-2000,-2000,15000)),((-3000,-3000,10000),(-2000,2000,15000)),((-3000,-3000,10000),(2000,-2000,15000)),
((-3000,3000,10000),(-2000,2000,15000)),((-3000,3000,10000),(-2000,-2000,15000)),((-3000,3000,10000),(2000,2000,15000)),
((3000,-3000,10000),(2000,-2000,15000)),((3000,-3000,10000),(2000,2000,15000)),((3000,-3000,10000),(-2000,-2000,15000)),
((3000,3000,10000),(2000,2000,15000)),((3000,3000,10000),(2000,-2000,15000)),((3000,3000,10000),(-2000,2000,15000))
]
line_cell2=[((-2000,-2000,15000),(-1000,-1000,20000)),((-2000,-2000,15000),(-1000,1000,20000)),((-2000,-2000,15000),(1000,-1000,20000)),
((-2000,2000,15000),(-1000,1000,20000)),((-2000,2000,15000),(-1000,-1000,20000)),((-2000,2000,15000),(1000,1000,20000)),
((2000,-2000,15000),(1000,-1000,20000)),((2000,-2000,15000),(1000,1000,20000)),((2000,-2000,15000),(-1000,-1000,20000)),
((2000,2000,15000),(1000,1000,20000)),((2000,2000,15000),(1000,-1000,20000)),((2000,2000,15000),(-1000,1000,20000)),
((-4000,-4000,5000),(4000,-4000,5000)),((-4000,4000,5000),(4000,4000,5000)),((-4000,-4000,5000),(-4000,4000,5000)),
((4000,-4000,5000),(4000,4000,5000)),((-3000,-3000,10000),(3000,-3000,10000)),((-3000,3000,10000),(3000,3000,10000)),
((-3000,-3000,10000),(-3000,3000,10000)),((3000,-3000,10000),(3000,3000,10000)),((-2000,-2000,15000),(2000,-2000,15000)),
((-2000,2000,15000),(2000,2000,15000)),((-2000,-2000,15000),(-2000,2000,15000)),((2000,-2000,15000),(2000,2000,15000)),
((-1000,-1000,20000),(1000,-1000,20000)),((-1000,1000,20000),(1000,1000,20000)),((-1000,-1000,20000),(-1000,1000,20000)),
((1000,-1000,20000),(1000,1000,20000)),((-4000,4000,5000),(4000,-4000,5000)),((-4000,-4000,5000),(4000,4000,5000)),
((-3000,3000,10000),(3000,-3000,10000)),((-3000,-3000,10000),(3000,3000,10000)),((-2000,2000,15000),(2000,-2000,15000)),
((-2000,-2000,15000),(2000,2000,15000)),((-1000,1000,20000),(1000,-1000,20000)),((-1000,-1000,20000),(1000,1000,20000))
]
self.plt+=Lines(line_cell,c='blue',lw=2,alpha=0.8)
#elf.plt+=Lines(line_cell2,c='gray',lw=2,alpha=1)
self.plt.show(viewup="z", axes=4, interactive=False, title="XStructure")
myApp = MainGUI()
myApp.mainloop() |
Beta Was this translation helpful? Give feedback.
Answered by
marcomusy
May 17, 2023
Replies: 1 comment 1 reply
-
Hi this has been fixed in the master, try:
also change
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
ZiguoAtGitHub
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi this has been fixed in the master, try:
also change