def draw_callback( self ) : #print("Got clipp value: ",self.master.isClipped.get()) if self.master.m_ModelData is None : self.master.statusBar_frame.set( 'No model loaded.' ) return width = int( self.master.ob_canvas_frame.canvas.cget( "width" ) ) height = int( self.master.ob_canvas_frame.canvas.cget( "height" ) ) w = self.master.m_ModelData.getWindow() v = self.master.m_ModelData.getViewport() ( ax, ay, sx, sy ) = constructTransform( w, v, width, height ) self.master.m_ModelData.specifyTransform( ax, ay, sx, sy, self.master.m_distance ) #tx,ty,tz = self.master.m_ModelData.getCenter() #Converting angles from degrees to radians. self.master.m_ModelData.specifyEuler(math.radians(self.master.m_roll), math.radians(self.master.m_pitch), math.radians(self.master.m_yaw)) #print( '---Draw' ) #print( f'Canvas size : ({width}, {height})' ) #print( f'Transform : ax {ax:.3f} ay {ay:.3f} sx {sx:.3f} sy {sy:.3f}' ) self.master.ob_world.create_graphic_objects( self.master.ob_canvas_frame.canvas, self.master.m_ModelData, self.master.isClipped.get(), self.master.isPerspective.get(), self.master.isEuler.get(), self.master.m_resolution ) vxMin = v[0] * width vxMax = v[2] * width vyMin = v[1] * height vyMax = v[3] * height self.master.ob_canvas_frame.canvas.create_line(vxMin, vyMin, vxMin, vyMax, vxMax, vyMax, vxMax, vyMin, vxMin, vyMin ) self.master.statusBar_frame.set( 'Draw callback' ) degree = '\u00b0' self.master.statusBar_frame.set(f'Resolution: {self.master.m_resolution} Distance : {self.master.m_distance} φ : {self.master.m_roll}{degree} θ: {self.master.m_pitch}{degree} ψ: {self.master.m_yaw}{degree} ' )
def draw_callback(self): if self.master.m_ModelData is None: self.master.statusBar_frame.set('No model loaded.') return width = int(self.master.ob_canvas_frame.canvas.cget("width")) height = int(self.master.ob_canvas_frame.canvas.cget("height")) w = self.master.m_ModelData.getWindow() v = self.master.m_ModelData.getViewport() (ax, ay, sx, sy) = constructTransform(w, v, width, height) self.master.m_ModelData.specifyTransform(ax, ay, sx, sy) print('---Draw') print(f'Canvas size : ({width}, {height})') print( f'Transform : ax {ax:.3f} ay {ay:.3f} sx {sx:.3f} sy {sy:.3f}') self.master.ob_world.create_graphic_objects( self.master.ob_canvas_frame.canvas, self.master.m_ModelData) vxMin = v[0] * width vxMax = v[2] * width vyMin = v[1] * height vyMax = v[3] * height self.master.ob_canvas_frame.canvas.create_line(vxMin, vyMin, vxMin, vyMax, vxMax, vyMax, vxMax, vyMin, vxMin, vyMin) self.master.statusBar_frame.set('Draw callback')
def draw_callback(self): if self.master.m_ModelData is None: self.master.statusBar_frame.set('No model loaded.') return clip = self.master.Clip.get() == 1 perpective = self.master.Perspective.get() == 1 euler = self.master.Euler.get() == 1 roll = self.master.m_roll pitch = self.master.m_pitch yaw = self.master.m_yaw distance = self.master.m_distance phi = (roll * math.pi) / 180 theta = (pitch * math.pi) / 180 psi = (yaw * math.pi) / 180 print(phi) print(theta) print(psi) width = int(self.master.ob_canvas_frame.canvas.cget("width")) height = int(self.master.ob_canvas_frame.canvas.cget("height")) w = self.master.m_ModelData.getWindow() v = self.master.m_ModelData.getViewport() (ax, ay, sx, sy) = constructTransform(w, v, width, height) self.master.m_ModelData.specifyEuler(phi, theta, psi) self.master.m_ModelData.specifyTransform(ax, ay, sx, sy, distance) print('---Draw') print(f'Canvas size : ({width}, {height})') print( f'Transform : ax {ax:.3f} ay {ay:.3f} sx {sx:.3f} sy {sy:.3f}') self.master.ob_world.create_graphic_objects( self.master.ob_canvas_frame.canvas, self.master.m_ModelData, clip, perpective, euler) vxMin = v[0] * width vxMax = v[2] * width vyMin = v[1] * height vyMax = v[3] * height self.master.ob_canvas_frame.canvas.create_line(vxMin, vyMin, vxMin, vyMax, vxMax, vyMax, vxMax, vyMin, vxMin, vyMin) d = str(float(distance)) p = str(float(roll)) t = str(float(pitch)) ps = str(float(yaw)) dg = '\u02da' self.master.statusBar_frame.set('distance ' + d + ',' + ' ' + 'φ ' + p + dg + ' ' + 'θ ' + t + dg + ' ' + 'ψ ' + ps + dg)
def draw_callback( self ) : if self.master.model == 0 : self.master.statusBar_frame.set( 'Mesh not loaded' ) else : width = int(self.master.ob_canvas_frame.canvas.cget('width')) height = int(self.master.ob_canvas_frame.canvas.cget('height')) w = self.master.model.getWindow() v = self.master.model.getViewport() ax, ay, sx, sy = constructTransform(w, v, width, height) self.master.model.specifyTransform(ax, ay, sx, sy) self.master.ob_world.create_graphic_objects( self.master.ob_canvas_frame.canvas, self.master.model) self.master.statusBar_frame.set( 'Draw callback' )
def draw_callback(self): if self.master.m_ModelData is None: self.master.statusBar_frame.set('No model loaded.') return width = int(self.master.ob_canvas_frame.canvas.cget("width")) height = int(self.master.ob_canvas_frame.canvas.cget("height")) w = self.master.m_ModelData.getWindow() v = self.master.m_ModelData.getViewport() (ax, ay, sx, sy) = constructTransform(w, v, width, height) distance = self.master.m_Distance resolution = self.master.resolution self.master.m_ModelData.specifyTransform(ax, ay, sx, sy, distance) self.master.m_ModelData.specifyEuler(self.master.phi, self.master.theta, self.master.psi) print('---Draw') print(f'Canvas size : ({width}, {height})') print( f'Transform : ax {ax:.3f} ay {ay:.3f} sx {sx:.3f} sy {sy:.3f}') clip = self.master.var.get() == 1 perspective = self.master.m_Perspective.get() == 1 euler = self.master.m_Euler.get() == 1 self.master.ob_world.create_graphic_objects( self.master.ob_canvas_frame.canvas, self.master.m_ModelData, clip, perspective, euler, resolution) vxMin = v[0] * width vxMax = v[2] * width vyMin = v[1] * height vyMax = v[3] * height self.master.ob_canvas_frame.canvas.create_line(vxMin, vyMin, vxMin, vyMax, vxMax, vyMax, vxMax, vyMin, vxMin, vyMin) self.master.statusBar_frame.set('Draw callback')
def draw_callback( self ) : if self.mdl is None: self.master.statusBar_frame.set( 'Mesh load error' ) else: wid=int(self.master.ob_canvas_frame.canvas.cget( 'width' )) height=int(self.master.ob_canvas_frame.canvas.cget( 'height' )) window=self.mdl.getWindow() viewport=self.mdl.getViewport() transformValues = constructTransform.constructTransform( window, viewport, wid, height ) self.mdl.specifyEuler(self.phi,self.theta,self.psi) self.mdl.specifyTransform(transformValues[0],transformValues[1],transformValues[2],transformValues[3],self.f) self.master.ob_world.create_graphic_objects( self.master.ob_canvas_frame.canvas,self.mdl,self.master.checkVar.get(),self.master.perVar.get(),self.master.eulVar.get(),self.res) self.master.statusBar_frame.set(f'resolution{self.res} ,distance {self.f}, φ{self.phi}° θ{self.theta}° ψ{self.psi}°')
def draw_callback(self): if self.master.m_ModelData is None: self.master.statusBar_frame.set('No model loaded.') return width = int(self.master.ob_canvas_frame.canvas.cget("width")) height = int(self.master.ob_canvas_frame.canvas.cget("height")) w = self.master.m_ModelData.getWindow() v = self.master.m_ModelData.getViewport() d = self.master.dist r = self.master.res angles = self.master.angle (ax, ay, sx, sy) = constructTransform(w, v, width, height) self.master.m_ModelData.specifyTransform(ax, ay, sx, sy, d) self.master.m_ModelData.specifyEuler(angles[0], angles[1], angles[2]) print('---Draw') print(f'Canvas size : ({width}, {height})') print( f'Transform : ax {ax:.3f} ay {ay:.3f} sx {sx:.3f} sy {sy:.3f}') doClip = self.master.var.get() doEuler = self.master.euler.get() vxMin = v[0] * width vxMax = v[2] * width vyMin = v[1] * height vyMax = v[3] * height self.master.ob_canvas_frame.canvas.create_line(vxMin, vyMin, vxMin, vyMax, vxMax, vyMax, vxMax, vyMin, vxMin, vyMin) doPerspective = self.master.per.get() self.master.ob_world.create_graphic_objects( self.master.ob_canvas_frame.canvas, self.master.m_ModelData, doClip, doPerspective, doEuler, r) self.master.statusBar_frame.set('Draw callback')
def draw_callback( self ) : width=int(self.master.ob_canvas_frame.canvas.cget('width')) height=int(self.master.ob_canvas_frame.canvas.cget('height')) print(self.master.var.get()) if(len(self.fName)!=0): model= ModelData.ModelData(self.fName) w = model.getWindow() v = model.getViewport() vNumber = model.getVertices() faces = model.getFaces() values=constructTransform.constructTransform( w,v, width, height ) ax, ay, sx, sy = values model.specifyTransform(ax, ay, sx, sy) Tvertex=model.getTransformedVertex(vNumber) self.master.ob_world.create_graphic_objects( self.master.ob_canvas_frame.canvas, Tvertex,faces) self.master.statusBar_frame.set( 'Draw callback' )
def draw_callback(self): if (self.master.mesh == None): self.master.statusBar_frame.set('No File Loaded') else: width = int(self.master.ob_canvas_frame.canvas.cget('width')) height = int(self.master.ob_canvas_frame.canvas.cget('height')) w = self.master.mesh.getWindow() v = self.master.mesh.getViewport() ax, ay, sx, sy = constructTransform(w, v, width, height) self.master.mesh.specifyTransform(ax, ay, sx, sy) self.master.ob_world.create_graphic_objects( self.master.ob_canvas_frame.canvas, self.master.mesh) xmin = v[0] * width ymin = v[1] * height xmax = v[2] * width ymax = v[3] * height self.master.ob_canvas_frame.canvas.create_rectangle( width * v[0], height * v[1], width * v[2], height * v[3], outline="black") self.master.statusBar_frame.set('Draw callback')