def start(self): say("start sensor") mw = QtGui.qApp ef = EventFilter(self.obj2) FreeCAD.keyfilter = ef mw.installEventFilter(ef)
def start(self): say("start sensor") mw=QtGui.qApp ef=EventFilter(self.obj2) FreeCAD.keyfilter=ef mw.installEventFilter(ef)
def stop(self): say("stop sensor") mw = QtGui.qApp ef = FreeCAD.keyfilter mw.removeEventFilter(ef) say("stopped")
def stop(self): say("stop sensor") mw=QtGui.qApp ef=FreeCAD.keyfilter mw.removeEventFilter(ef) say("stopped")
def main(self): anz=self.obj2.countSlices pb=createProgressBar("calculate Points") xc=self.obj2.dimU yc=self.obj2.dimV zc=anz # point index self.ptsl=np.arange(xc*yc*zc).reshape(zc,xc,yc) # anfangsgeschwindigkeiten der Teilchen self.pvs=np.zeros(xc*yc*3) # self.pvs += 1 self.pvs=self.pvs.reshape(xc,yc,3) # self.pvs[:,:] += [0,0,10] self.ptslix=np.zeros(xc*yc*zc*3).reshape(xc*yc*zc,3) bb=self.obj2.boundBox.Shape.BoundBox print "bounds ",bb self.xmax=bb.XMax self.ymax=bb.YMax self.zmax=bb.ZMax self.xmin=bb.XMin self.ymin=bb.YMin self.zmin=bb.ZMin createStartPtsV2(self) # self.obj2.forceMethod="myforce" reload(flowlib) force=eval("flowlib."+self.obj2.methodForce) self.force=force damper=eval("flowlib."+self.obj2.methodDamper) self.damper=damper ts=time.time() for i in range(anz-1): createStepPtsV2(self,i) pb.pb.setValue(i*100/(anz-2)) te=time.time() createFCOs(self,anz,1) say(("create points all ",i,"timee",round(te-ts,3))) showAll() Gui.SendMsgToActiveView("ViewFit") hideAll() pb.hide()
def update(self): say("update ") import math time=self.obj2.time say(str(time)) pl=self.path[time] self.obj2.target.Placement=pl self.obj2.Placement=pl
def update(self): say("update ") import math time = self.obj2.time say(str(time)) pl = self.path[time] self.obj2.target.Placement = pl self.obj2.Placement = pl
def main(self): anz=self.obj2.countSlices pb=createProgressBar("calculate Points") xc=self.obj2.dimU yc=self.obj2.dimV zc=anz # point index self.ptsl=np.arange(xc*yc*zc).reshape(zc,xc,yc) # anfangsgeschwindigkeiten der Teilchen self.pvs=np.zeros(xc*yc*3) # self.pvs += 1 self.pvs=self.pvs.reshape(xc,yc,3) # self.pvs[:,:] += [0,0,10] self.ptslix=np.zeros(xc*yc*zc*3).reshape(xc*yc*zc,3) bb=self.obj2.boundBox.Shape.BoundBox self.xmax=bb.XMax self.ymax=bb.YMax self.zmax=bb.ZMax self.xmin=bb.XMin self.ymin=bb.YMin self.zmin=bb.ZMin createStartPtsV2(self) # self.obj2.forceMethod="myforce" reload(flowlib) force=eval("flowlib."+self.obj2.methodForce) self.force=force damper=eval("flowlib."+self.obj2.methodDamper) self.damper=damper ts=time.time() for i in range(anz-1): createStepPtsV2(self,i) pb.pb.setValue(i*100/(anz-2)) te=time.time() createFCOs(self,anz,1) say(("create points all ",i,"timee",round(te-ts,3))) showAll() Gui.SendMsgToActiveView("ViewFit") hideAll() pb.hide()
def attach(self,vobj): self.emenu=[["start",self.start],["stop",self.stop]] self.cmenu=self.emenu say("attach " + str(vobj.Object.Label)) self.Object = vobj.Object self.obj2=self.Object self.Object.Proxy.Lock=False self.Object.Proxy.Changed=False return
def onBeforeChange(self,obj,prop): say("** on Before Changed " ) FreeCAD.animationLock=False # say(obj) say(prop) FreeCAD.animation={} oldval=obj.getPropertyByName(prop) FreeCAD.animation['changed'] =[obj,prop,oldval] pass
def attach(self, vobj): self.emenu = [["start", self.start], ["stop", self.stop]] self.cmenu = self.emenu say("attach " + str(vobj.Object.Label)) self.Object = vobj.Object self.obj2 = self.Object self.Object.Proxy.Lock = False self.Object.Proxy.Changed = False return
def onBeforeChange(self, obj, prop): say("** on Before Changed ") FreeCAD.animationLock = False # say(obj) say(prop) FreeCAD.animation = {} oldval = obj.getPropertyByName(prop) FreeCAD.animation['changed'] = [obj, prop, oldval] pass
def attach(self,vobj): self.emenu=[["Show Path",self.showpath]] self.cmenu=[] say("attach " + str(vobj.Object.Label)) self.Object = vobj.Object self.obj2=self.Object self.Object.Proxy.Lock=False self.Object.Proxy.Changed=False return
def attach(self,vobj): say("attach " + str(vobj.Object.Label)) self.emenu=[["Reload Track",self.loadtrack],["Show Track",self.showtrack]] self.cmenu=[] self.Object = vobj.Object self.obj2=self.Object self.Object.Proxy.Lock=False self.Object.Proxy.Changed=False return
def attach(self,vobj): self.emenu=[["Show Path Data",self.Object.Proxy.show],["Generate Path",self.Object.Proxy.gen]] self.cmenu=self.emenu say("attach " + str(vobj.Object.Label)) self.Object = vobj.Object self.obj2=self.Object self.Object.Proxy.Lock=False self.Object.Proxy.Changed=False return
def step(self, now): say("Kardan step!" + str(now)) FreeCAD.R = self if now < self.obj2.start or now >= self.obj2.end: say("ausserhalb") pass else: if not self.obj2.obj: errorDialog("kein Sketch zugeordnet") raise Exception(' self.obj2.obj nicht definiert') # alpha=60 alpha = self.obj2.angleZenit phi = 1 # testfall phi = 10 # achse 1 fa1 = self.obj2.objAxis1 p0 = fa1.Placement phi0 = p0.Rotation.Angle / pi * 180 # say("phi0 Basis " + str(phi0)) p1 = FreeCAD.Placement(App.Vector(0, 0, 0), App.Rotation(App.Vector(0, 0, 1), phi)) r1 = p1.multiply(p0) fa1.Placement = r1 phi20 = arctan( tan(phi0 * pi / 180) * cos(alpha * pi / 180)) * 180 / pi phi21 = arctan( tan((phi0 + phi) * pi / 180) * cos(alpha * pi / 180)) * 180 / pi say("phi20 " + str(phi20)) say("phi21 " + str(phi21)) # achse 2 timepos = now - self.obj2.start if 90 / phi - 1 <= timepos and timepos < 270 / phi - 1: phi21 = 180 + phi21 say("*************** ! phi21 =" + str(phi21) + " now:" + str(now)) fa2 = self.obj2.objAxis2 p1 = FreeCAD.Placement(App.Vector(0, 0, 0), App.Rotation(App.Vector(0, 0, 1), phi21)) p2 = FreeCAD.Placement(App.Vector(0, 0, 0), App.Rotation(App.Vector(0, 1, 0), alpha)) r3 = p2.multiply(p1) fa2.Placement = r3 # kreuz f = self.obj2.objCross rotcross(f, alpha, phi0 + phi) FreeCAD.activeDocument().recompute()
def showpath(self): ''' path as Part.polygon ''' FreeCAD.s=self points=self.Object.Proxy.path for p in self.Object.Proxy.path: say(str(p)) pp=Part.makePolygon(points) Part.show(pp) FreeCAD.ActiveDocument.recompute() return FreeCAD.activeDocument().ActiveObject
def attach(self, vobj): self.emenu = [["Show Path Data", self.Object.Proxy.show], ["Generate Path", self.Object.Proxy.gen]] self.cmenu = self.emenu say("attach " + str(vobj.Object.Label)) self.Object = vobj.Object self.obj2 = self.Object self.Object.Proxy.Lock = False self.Object.Proxy.Changed = False return
def createFCOs(self,anz,step=1): pb=createProgressBar("create FreeCAD objects") ts=time.time() for i in range(anz-1): if i%step == 0: createStepFC(self,i) pb.pb.setValue(i*100/(anz-2)) Gui.updateGui() te=time.time() say(("createFCOs ",round(te-ts,3)))
def attach(self, vobj): say("attach " + str(vobj.Object.Label)) self.emenu = [["Reload Track", self.loadtrack], ["Show Track", self.showtrack]] self.cmenu = [] self.Object = vobj.Object self.obj2 = self.Object self.Object.Proxy.Lock = False self.Object.Proxy.Changed = False return
def dialer(self): ''' shows the position at the dialer time''' self.obj2.time=float(self.widget.dial.value())/100 say("dialer self time:" + str(self.obj2.time)) try: say(self.obj2.Proxy.path[round(self.obj2.time,2)]) self.obj2.target.Placement=self.obj2.Proxy.path[round(self.obj2.time,2)] except: pass FreeCAD.ActiveDocument.recompute()
def dialer(self): ''' shows the position at the dialer time''' self.obj2.time = float(self.widget.dial.value()) / 100 say("dialer self time:" + str(self.obj2.time)) try: say(self.obj2.Proxy.path[round(self.obj2.time, 2)]) self.obj2.target.Placement = self.obj2.Proxy.path[round( self.obj2.time, 2)] except: pass FreeCAD.ActiveDocument.recompute()
def attach(self, vobj): say("VO attach " + str(vobj.Object.Label)) vobj.Proxy = self self.Object = vobj.Object self.obj2 = self.Object self.Object.Proxy.Lock = False self.Object.Proxy.Changed = False icon = '/icons/controlpanel.png' self.iconpath = __dir__ + icon self.vers = __vers__ return
def attach(self,vobj): say("VO attach " + str(vobj.Object.Label)) vobj.Proxy = self self.Object = vobj.Object self.obj2=self.Object self.Object.Proxy.Lock=False self.Object.Proxy.Changed=False icon='/icons/controlpanel.png' self.iconpath = __dir__ + icon self.vers=__vers__ return
def attach(self, vobj): self.emenu = [] self.cmenu = [] say("attach " + str(vobj.Object.Label)) self.Object = vobj.Object self.obj2 = self.Object self.Object.Proxy.Lock = False self.Object.Proxy.Changed = False icon = '/icons/combiner.png' self.iconpath = __dir__ + icon self.vers = __vers__ return
def update(self): say("update ") import math time=self.obj2.time/100 say(str(time)) if self.obj2.mode=='cartesian': pl=FreeCAD.Vector((time*self.xmax)+self.xmin,self.obj2.a*self.fx(time)+self.obj2.b) if self.obj2.mode=='polar': # pl=FreeCAD.Vector((time*self.xmax)+self.xmin,self.fx(time)) pl=FreeCAD.Vector(np.cos(np.pi*time*2),np.sin(np.pi*time*2),0)*(self.obj2.a*self.fx(time)+self.obj2.b) if self.obj2.target != None: self.obj2.target.Placement.Base=pl self.obj2.target.purgeTouched()
def update(self): time=self.obj2.time try: say("update time=" + str(time) + ", "+ self.obj2.Label) except: say("update (ohne Label)") objs=pclgroup().OutList for u in objs: u.ViewObject.hide() u.ViewObject.ShapeColor=(1.0,0.0,0.0) i=int(round(time*(len(objs)-1))) try:objs[i].ViewObject.show() except: pass
def execute(self, obj): # obj.end=obj.start+obj.duration obj.setEditorMode("end", 1) #ro # obj.setEditorMode("obj", 1) #ro obj.setEditorMode("color", 2) #hidden say("execute _Gearing") if hasattr(self, 'ignore'): if self.ignore: say("ignore") return # wenn noch keine zuordnung erfolgt ist App = FreeCAD
def execute(self,obj): # obj.end=obj.start+obj.duration obj.setEditorMode("end", 1) #ro # obj.setEditorMode("obj", 1) #ro obj.setEditorMode("color", 2) #hidden say("execute _Gearing") if hasattr(self,'ignore'): if self.ignore: say("ignore") return # wenn noch keine zuordnung erfolgt ist App=FreeCAD
def step(self,now): say("Kardan step!" + str(now)) FreeCAD.R=self if now<self.obj2.start or now>=self.obj2.end: say("ausserhalb") pass else: if not self.obj2.obj: errorDialog("kein Sketch zugeordnet") raise Exception(' self.obj2.obj nicht definiert') # alpha=60 alpha=self.obj2.angleZenit phi=1 # testfall phi=10 # achse 1 fa1=self.obj2.objAxis1 p0=fa1.Placement phi0=p0.Rotation.Angle/pi*180 # say("phi0 Basis " + str(phi0)) p1=FreeCAD.Placement(App.Vector(0,0,0),App.Rotation(App.Vector(0,0,1),phi)) r1=p1.multiply(p0) fa1.Placement=r1 phi20=arctan(tan(phi0*pi/180)*cos(alpha*pi/180))*180/pi phi21=arctan(tan((phi0+phi)*pi/180)*cos(alpha*pi/180))*180/pi say("phi20 "+str(phi20)) say("phi21 "+str(phi21)) # achse 2 timepos=now-self.obj2.start if 90/phi-1<=timepos and timepos<270/phi-1: phi21=180+phi21 say("*************** ! phi21 ="+str(phi21) + " now:" + str(now)) fa2=self.obj2.objAxis2 p1=FreeCAD.Placement(App.Vector(0,0,0),App.Rotation(App.Vector(0,0,1),phi21)) p2=FreeCAD.Placement(App.Vector(0,0,0),App.Rotation(App.Vector(0,1,0),alpha)) r3=p2.multiply(p1) fa2.Placement=r3 # kreuz f=self.obj2.objCross rotcross(f,alpha,phi0+phi) FreeCAD.activeDocument().recompute()
def execute(self, obj): if self.Changed: say("self changed") self.Changed = False return if not self.Lock: self.obj2 = obj self.Lock = True try: self.update() except: sayexc('update') self.Lock = False
def execute(self,obj): if self.Changed: say("self changed") self.Changed=False return if not self.Lock: self.obj2=obj self.Lock=True try: self.update() except: sayexc('update') self.Lock=False
def update(self): time=self.obj2.time try: say("update time=" + str(time) + ", "+ self.obj2.Label) except: say("update (ohne Label)") objs=pclgroup().OutList for u in objs: u.ViewObject.hide() u.ViewObject.ShapeColor=(1.0,0.0,0.0) i=int(round(time*(len(objs)-1))) print i try:objs[i].ViewObject.show() except: pass
def step(self,now): if now==0: sufi='' else: sufi= "%03d" % (now) if now > 0: try: ob=self.last ob.ViewObject.Visibility=False except: pass ob=FreeCAD.activeDocument().getObject(self.obj2.seqname + sufi) say(ob.Name) ob.ViewObject.Visibility=True self.last=ob
def step(self, now): if now == 0: sufi = '' else: sufi = "%03d" % (now) if now > 0: try: ob = self.last ob.ViewObject.Visibility = False except: pass ob = FreeCAD.activeDocument().getObject(self.obj2.seqname + sufi) say(ob.Name) ob.ViewObject.Visibility = True self.last = ob
def attach(self,vobj): # items for edit dialog and contextmenue self.emenu=[['A',self.funA],['B',self.funB]] self.cmenu=[['AC',self.funA],['BC',self.funB]] say("VO attach " + str(vobj.Object.Label)) vobj.Proxy = self self.Object = vobj.Object self.obj2=self.Object self.Object.Proxy.Lock=False self.Object.Proxy.Changed=False self.touchTarget=True icon='/icons/placer.png' self.iconpath = __dir__ + icon return
def attach(self, vobj): # items for edit dialog and contextmenue self.emenu = [['A', self.funA], ['B', self.funB]] self.cmenu = [['AC', self.funA], ['BC', self.funB]] say("VO attach " + str(vobj.Object.Label)) vobj.Proxy = self self.Object = vobj.Object self.obj2 = self.Object self.Object.Proxy.Lock = False self.Object.Proxy.Changed = False self.touchTarget = True icon = '/icons/placer.png' self.iconpath = __dir__ + icon return
def step(self,now): say("Gearing step!" + str(now)) FreeCAD.R=self self.ignore=True if now<self.obj2.start or now>self.obj2.end: sayd("ausserhalb") pass else: if not self.obj2.obj: errorDialog("kein Sketch zugeordnet") raise Exception(' self.obj2.obj nicht definiert') sys=self.obj2.obj s=sys.Links[0] pm=sys.Links[1] p=pm.Links[0] m=pm.Links[1] #say("sonne "+ s.Label) #say("planet "+ p.Label) #say("moinde" + m.Label) if now==self.obj2.start: s.Placement.Rotation.Axis=FreeCAD.Vector(0,0,1) p.Placement.Rotation.Axis=FreeCAD.Vector(0,0,1) m.Placement.Rotation.Axis=FreeCAD.Vector(0,0,1) # Eigenachsen Rotationen print(s.Placement.Rotation.Angle) an=s.Placement.Rotation.Angle ax=s.Placement.Rotation.Axis day_star=self.obj2.dayStar day_planet=self.obj2.dayPlanet day_moon=self.obj2.dayMoon rotstep(s,day_star) rotstep(p,day_planet) rotstep(m,day_moon) #p.Placement.Rotation.Angle += math.pi * 2/day_planet #m.Placement.Rotation.Angle += math.pi * 2/day_moon # Schenkel Rotationen sys.Placement.Rotation.Angle += 0 pm.Placement.Rotation.Angle += 0 FreeCAD.activeDocument().recompute() self.ignore=False
def update(self): say("update ") import math time = self.obj2.time / 100 say(str(time)) if self.obj2.mode == 'cartesian': pl = FreeCAD.Vector((time * self.xmax) + self.xmin, self.obj2.a * self.fx(time) + self.obj2.b) if self.obj2.mode == 'polar': # pl=FreeCAD.Vector((time*self.xmax)+self.xmin,self.fx(time)) pl = FreeCAD.Vector( np.cos(np.pi * time * 2), np.sin(np.pi * time * 2), 0) * (self.obj2.a * self.fx(time) + self.obj2.b) if self.obj2.target != None: self.obj2.target.Placement.Base = pl self.obj2.target.purgeTouched()
def step(self, now): say("Gearing step!" + str(now)) FreeCAD.R = self self.ignore = True if now < self.obj2.start or now > self.obj2.end: sayd("ausserhalb") pass else: if not self.obj2.obj: errorDialog("kein Sketch zugeordnet") raise Exception(' self.obj2.obj nicht definiert') sys = self.obj2.obj s = sys.Links[0] pm = sys.Links[1] p = pm.Links[0] m = pm.Links[1] #say("sonne "+ s.Label) #say("planet "+ p.Label) #say("moinde" + m.Label) if now == self.obj2.start: s.Placement.Rotation.Axis = FreeCAD.Vector(0, 0, 1) p.Placement.Rotation.Axis = FreeCAD.Vector(0, 0, 1) m.Placement.Rotation.Axis = FreeCAD.Vector(0, 0, 1) # Eigenachsen Rotationen print(s.Placement.Rotation.Angle) an = s.Placement.Rotation.Angle ax = s.Placement.Rotation.Axis day_star = self.obj2.dayStar day_planet = self.obj2.dayPlanet day_moon = self.obj2.dayMoon rotstep(s, day_star) rotstep(p, day_planet) rotstep(m, day_moon) #p.Placement.Rotation.Angle += math.pi * 2/day_planet #m.Placement.Rotation.Angle += math.pi * 2/day_moon # Schenkel Rotationen sys.Placement.Rotation.Angle += 0 pm.Placement.Rotation.Angle += 0 FreeCAD.activeDocument().recompute() self.ignore = False
def createStepFC(self,i): ts=time.time() objs=pclgroup() (la,lb)=self.ptsl[i].shape # pts=[tuple(self.ptslix[self.ptsl[i][a][b]]) for a in range(la) for b in range(lb)] pts=[] for a in range(la): for b in range(lb): t=tuple(self.ptslix[self.ptsl[i][a][b]]) if np.isnan(t[0]) or np.isnan(t[1]) or np.isnan(t[2]): ##debug print "found error ", t # print (a,b) pass # ignore zero points elif abs(t[0])<10 and abs(t[1])<20: ##debug print "ignore inner point ",t pass else: pts.append(t) pcl=Points.Points(pts) Points.show(pcl) App.activeDocument().recompute() if i%25==0: Gui.SendMsgToActiveView("ViewFit") obj=App.ActiveDocument.ActiveObject obj.ViewObject.ShapeColor=(random.random(),random.random(),random.random()) if len(objs.OutList)==0: obj.Placement=self.obj2.startPosition else: #movePosition=FreeCAD.Placement() #movePosition.Rotation=FreeCAD.Rotation(FreeCAD.Vector(0,0,1),10) movePosition=self.obj2.deltaPosition obj.Placement=objs.OutList[-1].Placement.multiply(movePosition) objs.addObject(obj) te=time.time() say(("createStepFC ",i,"timee",round(te-ts,3))) return obj
def createStepFC(self,i): ts=time.time() objs=pclgroup() (la,lb)=self.ptsl[i].shape # pts=[tuple(self.ptslix[self.ptsl[i][a][b]]) for a in range(la) for b in range(lb)] pts=[] for a in range(la): for b in range(lb): t=tuple(self.ptslix[self.ptsl[i][a][b]]) if np.isnan(t[0]) or np.isnan(t[1]) or np.isnan(t[2]): pass elif abs(t[0])<10 and abs(t[1])<20: pass else: pts.append(t) pcl=Points.Points(pts) Points.show(pcl) App.activeDocument().recompute() if i%25==0: Gui.SendMsgToActiveView("ViewFit") obj=App.ActiveDocument.ActiveObject obj.ViewObject.ShapeColor=(random.random(),random.random(),random.random()) if len(objs.OutList)==0: obj.Placement=self.obj2.startPosition else: #movePosition=FreeCAD.Placement() #movePosition.Rotation=FreeCAD.Rotation(FreeCAD.Vector(0,0,1),10) movePosition=self.obj2.deltaPosition obj.Placement=objs.OutList[-1].Placement.multiply(movePosition) objs.addObject(obj) te=time.time() say(("createStepFC ",i,"timee",round(te-ts,3))) return obj
def step(self, now): try: # https://github.com/hamish2014/FreeCAD_assembly2/issues/73 import assembly2lib assembly2lib.debugPrint.level = 0 #the default is 2 assembly2lib.debugPrint.level = self.obj2.debugLevel import assembly2solver try: constraintSystem = assembly2solver.solveConstraints( FreeCAD.ActiveDocument, showFailureErrorDialog=False, printErrors=self.obj2.printErrors) if constraintSystem == None: sayErr('Solver failed to satisfy specified constraints') else: say("Solver step done " + str(now)) except: sayErr( "problem assembly2solver.solveConstraints(App.ActiveDocument)" ) except: sayErr("problem no assembly2 available") pass
def run(self, s): say(s.Label) print s.Shape say(s.Shape.Vertexes) i = 0 for v in s.Shape.Vertexes: i += 1 if i > 5: break say(["Point: ", v.Point]) FreeCADGui.updateGui() self.addpoint(v.Point)
def run(self,s): say(s.Label) print(s.Shape) say(s.Shape.Vertexes) i=0 for v in s.Shape.Vertexes: i += 1 if i > 5: break say(["Point: ", v.Point]) FreeCADGui.updateGui() self.addpoint(v.Point)
def step(self,now): say("step "+str(now) + str(self)) self.obj2.time=float(now)/100
def funA(self): say("ich bin FunA touch target") FreeCAD.ActiveDocument.recompute() self.obj2.target.touch() FreeCAD.ActiveDocument.recompute() say("ich war FunA")
def __init__(self,vobj): say(self) Animation._ViewProviderActor.__init__(self,vobj) self.attach(vobj)
def eventFilter(self, o, e): z = str(e.type()) try: # not used events if z == 'PySide.QtCore.QEvent.Type.ChildAdded' or \ z == 'PySide.QtCore.QEvent.Type.ChildRemoved'or \ z == 'PySide.QtCore.QEvent.Type.User' or \ z == 'PySide.QtCore.QEvent.Type.Paint' or \ z == 'PySide.QtCore.QEvent.Type.LayoutRequest' or\ z == 'PySide.QtCore.QEvent.Type.UpdateRequest' : return QtGui.QWidget.eventFilter(self, o, e) if z == 'PySide.QtCore.QEvent.Type.HoverMove': self.pos = e.pos() if z == 'PySide.QtCore.QEvent.Type.KeyPress': # ignore editors if self.editmode: return QtGui.QWidget.eventFilter(self, o, e) # only first time key pressed if not self.keypressed: text = e.text() if 0 or text <> '': self.keypressed = True key = '' if e.modifiers() & QtCore.Qt.SHIFT: #FreeCAD.Console.PrintMessage("SHIFT ") key += "SHIFT+" if e.modifiers() & QtCore.Qt.CTRL: #FreeCAD.Console.PrintMessage("CTRL ") key += "CTRL+" if e.modifiers() & QtCore.Qt.ALT: #FreeCAD.Console.PrintMessage("ALT ") key += "ALT+" key += PySide.QtGui.QKeySequence(e.key()).toString() FreeCAD.Console.PrintMessage(" " + str(key) + " \n") pos = self.pos #if e.key()== QtCore.Qt.Key_F10: # key += "F10#" if pos: if self.debug: FreeCAD.Console.PrintMessage( key + " at mouse position: " + str(pos) + "\n") say(pos.x()) say(pos.y()) step = 1 if key == 'F': self.V.Placement.Base.x -= step elif key == 'G': self.V.Placement.Base.x += step elif key == 'T': self.V.Placement.Base.y += step elif key == 'V': self.V.Placement.Base.y -= step elif key == 'Z': self.V.Placement.Base.x += step self.V.Placement.Base.y += step elif key == 'R': self.V.Placement.Base.x -= step self.V.Placement.Base.y += step elif key == 'B': self.V.Placement.Base.x += step self.V.Placement.Base.y -= step elif key == 'C': self.V.Placement.Base.x -= step self.V.Placement.Base.y -= step elif key == 'H': s = Gui.Selection.getSelection() try: ll = Gui.Selection.getSelectionEx() pts = ll[0].PickedPoints V.Placement.Base.x = pts[0].x V.Placement.Base.y = pts[0].y except: try: say("error 11") self.V.Placement.Base.x = s[ 0].Placement.Base.x self.V.Placement.Base.y = s[ 0].Placement.Base.y except: say("error 2") pass self.ctl.Placement = self.V.Placement App.ActiveDocument.recompute() else: self.keypressed = False if z == 'PySide.QtCore.QEvent.Type.KeyRelease': if self.keypressed: pass self.keypressed = False except: sayexc() try: return QtGui.QWidget.eventFilter(self, o, e) except: return None
def funB(self): say("ich bin FunB tozch target") self.touchTarget=not self.touchTarget say(self.touchTarget)
def edit(self): say(self) self.dialog=controlPanelWidget(self.Object) self.dialog.show()
def update(self): time=self.obj2.time try: say("update time=" + str(time) + ", "+ self.obj2.Label) except: say("update (ohne Label)") # get the parameters x0=self.obj2.x0 x1=self.obj2.x1 y0=self.obj2.y0 y1=self.obj2.y1 z0=self.obj2.z0 z1=self.obj2.z1 arc0=self.obj2.arc0 arc1=self.obj2.arc1 if self.obj2.target: if self.obj2.target.__class__.__name__ == 'GroupExtension': t=self.obj2.target.Group[0] else: t=self.obj2.target x=t.Placement.Base.x y=t.Placement.Base.y z=t.Placement.Base.z rx=t.Placement.Rotation.Axis.x ry=t.Placement.Rotation.Axis.y rz=t.Placement.Rotation.Axis.z arc=t.Placement.Rotation.Angle try: sx=self.obj2.src.Placement.Base.x sy=self.obj2.src.Placement.Base.y sz=self.obj2.src.Placement.Base.z srx=self.obj2.src.Placement.Rotation.Axis.x sry=self.obj2.src.Placement.Rotation.Axis.y srz=self.obj2.src.Placement.Rotation.Axis.z sarc=self.obj2.src.Placement.Rotation.Angle except: pass # saye("keine src festgelegt") # compute the new placement xv=eval(self.obj2.x) yv=eval(self.obj2.y) zv=eval(self.obj2.z) arcv=eval(self.obj2.arc) rot=FreeCAD.Rotation(self.obj2.RotAxis,arcv) # say(self.obj2.target.Label) # say("Vorgabe arcv " + str(arcv) +" ->Rotation ..." + str(rot.Axis) + "winkel " + str(rot.Angle)) pl=FreeCAD.Placement(FreeCAD.Vector(xv,yv,zv),rot,self.obj2.RotCenter) #say(pl) if self.obj2.target!=None: if self.obj2.target.__class__.__name__ == 'GroupExtension': for t in self.obj2.target.Group: if str(t.TypeId) == 'App::Annotation': t.Position=(xv,yv,zv) else: pl2=pl.multiply(self.obj2.prePlacement) t.Placement=pl2 else: if str(self.obj2.target.TypeId) == 'App::Annotation': self.obj2.target.Position=(xv,yv,zv) else: pl2=pl.multiply(self.obj2.prePlacement) self.obj2.target.Placement=pl2 for t in self.obj2.Group: if str(t.TypeId) == 'App::Annotation': t.Position=(xv,yv,zv) else: pl2=pl.multiply(self.obj2.prePlacement) t.Placement=pl2 self.obj2.Placement=pl if self.obj2.followers: for f in self.obj2.followers: # FreeCAD.ActiveDocument.Ergebnis.Proxy.execute(FreeCAD.ActiveDocument.Ergebnis) f.Proxy.execute(f)
def eventFilter(self, o, e): z=str(e.type()) try: # not used events if z == 'PySide.QtCore.QEvent.Type.ChildAdded' or \ z == 'PySide.QtCore.QEvent.Type.ChildRemoved'or \ z == 'PySide.QtCore.QEvent.Type.User' or \ z == 'PySide.QtCore.QEvent.Type.Paint' or \ z == 'PySide.QtCore.QEvent.Type.LayoutRequest' or\ z == 'PySide.QtCore.QEvent.Type.UpdateRequest' : return QtGui.QWidget.eventFilter(self, o, e) if z == 'PySide.QtCore.QEvent.Type.HoverMove' : self.pos=e.pos() if z == 'PySide.QtCore.QEvent.Type.KeyPress': # ignore editors if self.editmode: return QtGui.QWidget.eventFilter(self, o, e) # only first time key pressed if not self.keypressed: text=e.text() if 0 or text !='': self.keypressed=True key='' if e.modifiers() & QtCore.Qt.SHIFT: #FreeCAD.Console.PrintMessage("SHIFT ") key +="SHIFT+" if e.modifiers() & QtCore.Qt.CTRL: #FreeCAD.Console.PrintMessage("CTRL ") key +="CTRL+" if e.modifiers() & QtCore.Qt.ALT: #FreeCAD.Console.PrintMessage("ALT ") key +="ALT+" key +=PySide.QtGui.QKeySequence(e.key()).toString() FreeCAD.Console.PrintMessage(" "+str(key) +" \n" ) pos=self.pos #if e.key()== QtCore.Qt.Key_F10: # key += "F10#" if pos: if self.debug: FreeCAD.Console.PrintMessage( key + " at mouse position: " +str(pos) + "\n") say(pos.x()) say(pos.y()) step=1 if key == 'F': self.V.Placement.Base.x -= step elif key == 'G': self.V.Placement.Base.x += step elif key == 'T': self.V.Placement.Base.y += step elif key == 'V': self.V.Placement.Base.y -= step elif key == 'Z': self.V.Placement.Base.x += step self.V.Placement.Base.y += step elif key == 'R': self.V.Placement.Base.x -= step self.V.Placement.Base.y += step elif key == 'B': self.V.Placement.Base.x += step self.V.Placement.Base.y -= step elif key == 'C': self.V.Placement.Base.x -= step self.V.Placement.Base.y -= step elif key == 'H': s=Gui.Selection.getSelection() try: ll=Gui.Selection.getSelectionEx() pts=ll[0].PickedPoints V.Placement.Base.x=pts[0].x V.Placement.Base.y=pts[0].y except: try: say("error 11") self.V.Placement.Base.x=s[0].Placement.Base.x self.V.Placement.Base.y=s[0].Placement.Base.y except: say("error 2") pass self.ctl.Placement=self.V.Placement App.ActiveDocument.recompute() else: self.keypressed=False if z == 'PySide.QtCore.QEvent.Type.KeyRelease': if self.keypressed: pass self.keypressed=False except: sayexc() try: return QtGui.QWidget.eventFilter(self, o, e) except: return None
def update(self): time = self.obj2.time try: say("update time=" + str(time) + ", " + self.obj2.Label) except: say("update (ohne Label)") # get the parameters x0 = self.obj2.x0 x1 = self.obj2.x1 y0 = self.obj2.y0 y1 = self.obj2.y1 z0 = self.obj2.z0 z1 = self.obj2.z1 arc0 = self.obj2.arc0 arc1 = self.obj2.arc1 if self.obj2.target: x = self.obj2.target.Placement.Base.x y = self.obj2.target.Placement.Base.y z = self.obj2.target.Placement.Base.z rx = self.obj2.target.Placement.Rotation.Axis.x ry = self.obj2.target.Placement.Rotation.Axis.y rz = self.obj2.target.Placement.Rotation.Axis.z arc = self.obj2.target.Placement.Rotation.Angle try: sx = self.obj2.src.Placement.Base.x sy = self.obj2.src.Placement.Base.y sz = self.obj2.src.Placement.Base.z srx = self.obj2.src.Placement.Rotation.Axis.x sry = self.obj2.src.Placement.Rotation.Axis.y srz = self.obj2.src.Placement.Rotation.Axis.z sarc = self.obj2.src.Placement.Rotation.Angle except: pass # saye("keine src festgelegt") # compute the new placement xv = eval(self.obj2.x) yv = eval(self.obj2.y) zv = eval(self.obj2.z) arcv = eval(self.obj2.arc) rot = FreeCAD.Rotation(self.obj2.RotAxis, arcv) say(self.obj2.target.Label) say("Vorgabe arcv " + str(arcv) + " ->Rotation ..." + str(rot.Axis) + "winkel " + str(rot.Angle)) pl = FreeCAD.Placement(FreeCAD.Vector(xv, yv, zv), rot, self.obj2.RotCenter) #say(pl) if str(self.obj2.target.TypeId) == 'App::Annotation': self.obj2.target.Position = (xv, yv, zv) else: pl2 = pl.multiply(self.obj2.prePlacement) self.obj2.target.Placement = pl2 self.obj2.Placement = pl if self.obj2.followers: for f in self.obj2.followers: # FreeCAD.ActiveDocument.Ergebnis.Proxy.execute(FreeCAD.ActiveDocument.Ergebnis) f.Proxy.execute(f)
def funB(self): say("ich bin FunB tozch target") self.touchTarget = not self.touchTarget say(self.touchTarget)
def __init__(self, vobj): say(self) Animation._ViewProviderActor.__init__(self, vobj) self.attach(vobj)