From 2cea35626f9e88b55b933b5af35ff87e9f80e491 Mon Sep 17 00:00:00 2001 From: Andreas Freise <adf@star.bham.ac.uk> Date: Wed, 18 Dec 2013 21:36:44 +0000 Subject: [PATCH] starting to add scale as attribute for detectors. --- pykat/detectors.py | 10 ++++++++++ pykat/param.py | 21 +++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/pykat/detectors.py b/pykat/detectors.py index a24d4d9..149b7a3 100644 --- a/pykat/detectors.py +++ b/pykat/detectors.py @@ -10,6 +10,8 @@ import pykat.gui.resources from pykat.utils import * from pykat.gui.graphics import * from pykat.node_network import * +from pykat.param import Param, ScaleParam + class Detector(object) : def __init__(self, name,node): @@ -22,6 +24,7 @@ class Detector(object) : self.__node = None self._params = [] self._mask = {} + self.__scale = ScaleParam("scale", self, SIfloat(1.0)) if node.find('*'): self._alternate_beam = True @@ -46,6 +49,13 @@ class Detector(object) : def getQGraphicsItem(self): return None + + @property + def scale(self): return self.__scale + @scale.setter + def sclae(self, value): + self.__scale = SIfloat(value) + @property def node(self): return self.__node @node.setter diff --git a/pykat/param.py b/pykat/param.py index 058a533..f535d88 100644 --- a/pykat/param.py +++ b/pykat/param.py @@ -165,3 +165,24 @@ class AttrParam(Param): rtn.extend(super(AttrParam, self).getFinesseText()) return rtn + +class ScaleParam(Param): + """ + The scale parameter of a detector is set using the Finesse `scale` command. + + This inherits directly from a Param object so can be set whether this attribute + is putable or a putter. + + If the value pf the parameter is not 1.0 the scale command will be printed. + """ + def getFinesseText(self): + rtn = [] + + if self.value != 1.0: + rtn.append("scale {0} {1}".format(self._owner.name, self.value)) + + rtn.extend(super(ScaleParam, self).getFinesseText()) + + return rtn + + -- GitLab