Commit b871e9a5 authored by Daniel Brown's avatar Daniel Brown
Browse files

removing print outputs

parent d9f9af21
......@@ -23,17 +23,37 @@ class NodeGaussSetter:
if not isinstance(component, Component):
raise pkex.BasePyKatException("Value passed is not a Component")
if not isinstance(node, Node):
if not isinstance(node, pykat.node_network.Node):
raise pkex.BasePyKatException("Value passed is not a Node")
self._comp = component
self._node = node
self.__comp = component
self.__node = node
@property
def node(self): return self.__node
@property
def q(self): return self.__node.qx
@q.setter
def q(self, value):
node.setGauss(self.__comp, value)
@property
def qx(self): return self.__node.qx
@qx.setter
def qx(self, value):
node.setGauss(self.__comp, value)
@property
def qy(self): return self.__node.qy
@qy.setter
def qy(self, value):
node.setGauss(self.__comp, self.qx, value)
class Component(object) :
def __init__(self, name):
self.__name = name
self._svgItem = None
self._nodes = None
self._requested_node_names = []
self._kat = None
self.tag = None
......@@ -59,32 +79,34 @@ class Component(object) :
def __on_node_change(self):
# need to update the node gauss parameter setter members
#self.__update_node_setters()
return
self.__update_node_setters()
def __update_node_setters(self):
# check if any node setters have already been added. If so we
# need to remove them. This function should get called if the nodes
# are updated, either by some function call or the GUI
key_rm = [k for k in self.__dict__ if k.startswith("__nodesetter_", 0, 13)]
# now we have a list of which to remove
for key in key_rm:
ns = self.__dict__[key]
detattr(self, '__nodesetter_' + ns._node.name)
delattr(self.__class__, ns._node.name)
delattr(self, ns._node.name)
for node in self.nodes:
self.__add_node_setter(NodeGaussSetter(self, node))
if type(node) != pykat.node_network.DumpNode:
ns = NodeGaussSetter(self, node)
self.__add_node_setter(ns)
def __add_node_setter(self, ns):
if not isinstance(ns, NodeGaussSetter):
raise exceptions.ValueError("Argument is not of type NodeGaussSetter")
name = ns.__class__.__name__
name = ns.node.name
fget = lambda self: self.__get_node_setter(name)
setattr(self.__class__, name, property(fget))
setattr(self, name, property(fget))
setattr(self, '__nodesetter_' + name, ns)
def __get_node_setter(self, name):
......
......@@ -141,7 +141,7 @@ class NodeNetwork(object):
name = node.name
fget = lambda self: self.__get_node_attr(name)
setattr(self.__class__, name, property(fget))
setattr(self, name, property(fget))
setattr(self, '__node_' + name, node)
def __remove_node_attr(self, node):
......@@ -150,23 +150,21 @@ class NodeNetwork(object):
name = node.name
detattr(self, '__node_' + name)
delattr(self.__class__, name)
delattr(self, name)
def __get_node_attr(self, name):
return getattr(self, '__node_' + name)
class Node(object):
class gauss_version:
w0_z = 1
z_zR = 2
def __init__(self, name, network, id):
self._detectors = []
self.__name = name
self._item = None
self._network = network
self.__gauss = None
self.__gauss_version = None
self.__q_x = None
self.__q_y = None
self.__q_comp = None
self.__id = id
@property
......@@ -179,25 +177,46 @@ class Node(object):
def components(self): return self._network.getNodeComponents(self)
@property
def gauss(self): return self.__gauss
def q(self):
if self.__q_x == self.__q_y:
return self.__q_x
else:
return (self.__q_x, self.__q_y)
@property
def qx(self): return self.__q_x
@property
def qy(self): return self.__q_y
def removeGauss():
self.__gauss_version = None
self.__gauss = None
def gauss_w0_z(self, w0, z, w0y=None, zy=None):
self.__gauss = []
self.__gauss.append(w0)
self.__gauss.append(z)
self.__q_x = None
self.__q_y = None
self.__q_comp = None
def setGauss(self, component, *args):
self.__q_comp = component
if len(args) == 1:
self.__q_x = args[0]
self.__q_y = args[0]
elif len(args) == 2:
self.__q_x = args[0]
self.__q_y = args[1]
else:
raise pkex.BasePyKatException("Must specify either 1 Gaussian beam parameter or 2 for astigmatic beams")
if w0y != None and zy != None:
self.__gauss.append(w0y)
self.__gauss.append(zy)
def getFinesseText(self):
if self.__q_x is None or self.__q_y is None or self.__q_comp is None:
return []
self.__gauss_version = Node.gauss_version.w0_z
rtn = []
def getFinesseText(self):
return []
if self.__q_x == self.__q_y:
rtn.append("gauss* g_{node} {comp} {node} {z} {zr}".format(node=self.name, comp=self.__q_comp.name, z=self.__q_x.real, zr=self.__q_x.imag))
else:
rtn.append("gauss* g_{node} {comp} {node} {zx} {zrx} {zy} {zry}".format(node=self.name, comp=self.__q_comp.name, zx=self.__q_x.real, zrx=self.__q_x.imag, zy=self.__q_y.real, zry=self.__q_y.imag))
return rtn
def isConnected(self):
if (self.components[0] is not None) and (self.self.components[1] is not None):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment