Package theia :: Package rendering :: Module features
[hide private]
[frames] | no frames]

Source Code for Module theia.rendering.features

 1  '''Features module or theia, to represent objects as FreeCAD Python features.''' 
 2   
 3  # Provides: 
 4  #   class FCObject 
 5  #   class FCMirror 
 6  #   class FCLens 
 7  #   class FCBeamDump 
 8  #   class FCBeam 
 9   
10  import Part 
11  from FreeCAD import Base 
12  from ..helpers import settings 
13   
14 -class FCObject(object):
15 '''Mother class for all FeaturePython objects. 16 17 This is to define the mandatory execute method, which is ran for every 18 object of the document on the recompute function. 19 20 fact: Factor to compensate for unit difference with FreeCAD. [float] 21 ''' 22 fact = 0.001#settings.FCFactor #factor for units in CAD
23 - def __init__(self, obj):
24 '''Custom properties of the object. 25 ''' 26 obj.Proxy = self
27
28 - def execute(self, fp):
29 '''We're not doing anything on recompute yet. 30 ''' 31 pass
32
33 -class FCMirror(FCObject):
34 - def __init__(self, obj, mirror):
35 super(FCMirror, self).__init__(obj) 36 obj.addProperty("App::PropertyAngle", "Wedge", "Mirror", 37 "Wedge of the mirror").Wedge = mirror.Wedge 38 obj.addProperty("App::PropertyString", "HRK", "Mirror", 39 "HR curvature").HRK = str(mirror.HRK) + ' m^-1' 40 obj.addProperty("App::PropertyString", "ARK", "Mirror", 41 "AR curvature").ARK = str(mirror.ARK) + ' m^-1' 42 obj.addProperty("App::PropertyDistance", "Thick", "Mirror", 43 "Thickness of mirror").Thick = mirror.Thick/self.fact 44 obj.addProperty("App::PropertyFloat", "N", "Mirror", 45 "Optical index").N = mirror.N 46 obj.addProperty("App::PropertyDistance", "Dia", "Mirror", 47 "Diameter").Dia = mirror.Dia/.001
48
49 -class FCLens(FCObject):
50 - def __init__(self, obj, lens):
51 super(FCLens, self).__init__(obj) 52 if lens.Name == "ThinLens": 53 obj.addProperty("App::PropertyDistance", "Focal", "Lens", 54 "FocalLength").Focal = lens.Focal/self.fact 55 else: 56 obj.addProperty("App::PropertyString", "K1", "Lens", 57 "K1 curvature").K1 = str(lens.HRK) + ' m^-1' 58 obj.addProperty("App::PropertyString", "K2", "Lens", 59 "K2 curvature").K2 = str(lens.ARK) + ' m^-1' 60 obj.addProperty("App::PropertyDistance", "Thick", "Lens", 61 "Thickness of lens").Thick = lens.Thick/self.fact 62 obj.addProperty("App::PropertyFloat", "N", "Lens", 63 "Optical index").N = lens.N 64 65 obj.addProperty("App::PropertyDistance", "Dia", "Lens", 66 "Diameter").Dia = lens.Dia/self.fact
67
68 -class FCBeamDump(FCObject):
69 - def __init__(self, obj, beamDump):
70 super(FCBeamDump, self).__init__(obj) 71 obj.addProperty("App::PropertyDistance", "Thick", "BeamDump", 72 "Thickness of beamdump").Thick = beamDump.Thick/self.fact 73 obj.addProperty("App::PropertyDistance", "Dia", "BeamDump", 74 "Diameter").Dia = beamDump.Dia/self.fact
75
76 -class FCBeam(FCObject):
77 - def __init__(self, obj, beam):
78 super(FCBeam, self).__init__(obj) 79 obj.addProperty("App::PropertyString", "Order", "Beam", 80 "Order of the beam").Order = str(beam.StrayOrder) 81 obj.addProperty("App::PropertyString", "P", "Beam", 82 "Power of the beam").P = str(beam.P/self.fact) + 'mW' 83 obj.addProperty("App::PropertyDistance", "WDx", "Beam", 84 "Waist distance X").WDx = beam.waistPos()[0]/self.fact 85 obj.addProperty("App::PropertyDistance", "WDy", "Beam", 86 "Waist distance Y").WDy = beam.waistPos()[1]/self.fact 87 obj.addProperty("App::PropertyDistance", "Wx", "Beam", 88 "Waist on X").Wx = beam.waistSize()[0]/self.fact 89 obj.addProperty("App::PropertyDistance", "Wy", "Beam", 90 "Waist on Y").Wy = beam.waistSize()[1]/self.fact
91