Updated pulse icons.

This commit is contained in:
jupfi 2023-07-30 13:21:32 +02:00
parent 44b8b84823
commit 55b5b5423a
6 changed files with 35 additions and 5 deletions

View file

@ -164,6 +164,16 @@ class Function:
logger.error("Could not convert %s to a float", end_x)
raise SyntaxError("Could not convert %s to a float" % end_x)
def get_pixmap(self):
"""This is the default pixmap for every function. If one wants to have a custom pixmap, this method has to be overwritten.
Returns:
QPixmap -- The default pixmap for every function"""
self_path = Path(__file__).parent
image_path = self_path / "resources/pulseparameter/TXCustom.png"
pixmap = QPixmap(str(image_path))
return pixmap
class Parameter:
def __init__(self, name: str, symbol: str, value: float) -> None:
@ -197,6 +207,12 @@ class RectFunction(Function):
expr = sympy.sympify("1")
super().__init__(expr)
def get_pixmap(self):
self_path = Path(__file__).parent
image_path = self_path / "resources/pulseparameter/TXRect.png"
pixmap = QPixmap(str(image_path))
return pixmap
class SincFunction(Function):
name = "Sinc"
@ -208,6 +224,12 @@ class SincFunction(Function):
self.start_x = -np.pi
self.end_x = np.pi
def get_pixmap(self):
self_path = Path(__file__).parent
image_path = self_path / "resources/pulseparameter/TXSinc.png"
pixmap = QPixmap(str(image_path))
return pixmap
class GaussianFunction(Function):
name = "Gaussian"
@ -220,6 +242,12 @@ class GaussianFunction(Function):
self.start_x = -np.pi
self.end_x = np.pi
def get_pixmap(self):
self_path = Path(__file__).parent
image_path = self_path / "resources/pulseparameter/TXGauss.png"
pixmap = QPixmap(str(image_path))
return pixmap
# class TriangleFunction(Function):
# def __init__(self) -> None:
@ -234,7 +262,6 @@ class CustomFunction(Function):
expr = sympy.sympify(" 2 * x**2 + 3 * x + 1")
super().__init__(expr)
class Option:
"""Defines options for the pulse parameters which can then be set accordingly."""
@ -307,6 +334,9 @@ class FunctionOption(Option):
obj.value = Function.from_json(data["value"])
return obj
def get_pixmap(self):
return self.value.get_pixmap()
class TXPulse(BaseSpectrometerModel.PulseParameter):
RELATIVE_AMPLITUDE = "Relative TX Amplitude"
@ -318,17 +348,17 @@ class TXPulse(BaseSpectrometerModel.PulseParameter):
self.add_option(NumericOption(self.RELATIVE_AMPLITUDE, 0))
self.add_option(NumericOption(self.TX_PHASE, 0))
self.add_option(
FunctionOption(self.TX_PULSE_SHAPE, [RectFunction(), SincFunction(), GaussianFunction()]),
FunctionOption(self.TX_PULSE_SHAPE, [RectFunction(), SincFunction(), GaussianFunction(), CustomFunction()]),
)
def get_pixmap(self):
self_path = Path(__file__).parent
if self.get_option_by_name(self.RELATIVE_AMPLITUDE).value > 0:
image_path = self_path / "resources/pulseparameter/TXOn.png"
return self.get_option_by_name(self.TX_PULSE_SHAPE).get_pixmap()
else:
image_path = self_path / "resources/pulseparameter/TXOff.png"
pixmap = QPixmap(str(image_path))
return pixmap
pixmap = QPixmap(str(image_path))
return pixmap
class RXReadout(BaseSpectrometerModel.PulseParameter):

Binary file not shown.

Before

Width:  |  Height:  |  Size: 342 B

After

Width:  |  Height:  |  Size: 315 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 346 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 356 B

View file

Before

Width:  |  Height:  |  Size: 277 B

After

Width:  |  Height:  |  Size: 277 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 387 B