From 55b5b5423a08b28cf35a957fdb251c238865819e Mon Sep 17 00:00:00 2001 From: jupfi Date: Sun, 30 Jul 2023 13:21:32 +0200 Subject: [PATCH] Updated pulse icons. --- src/nqrduck_spectrometer/pulseparameters.py | 40 +++++++++++++++--- .../resources/pulseparameter/RXOn.png | Bin 342 -> 315 bytes .../resources/pulseparameter/TXCustom.png | Bin 0 -> 346 bytes .../resources/pulseparameter/TXGauss.png | Bin 0 -> 356 bytes .../pulseparameter/{TXOn.png => TXRect.png} | Bin .../resources/pulseparameter/TXSinc.png | Bin 0 -> 387 bytes 6 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 src/nqrduck_spectrometer/resources/pulseparameter/TXCustom.png create mode 100644 src/nqrduck_spectrometer/resources/pulseparameter/TXGauss.png rename src/nqrduck_spectrometer/resources/pulseparameter/{TXOn.png => TXRect.png} (100%) create mode 100644 src/nqrduck_spectrometer/resources/pulseparameter/TXSinc.png diff --git a/src/nqrduck_spectrometer/pulseparameters.py b/src/nqrduck_spectrometer/pulseparameters.py index b4f7976..e4aa4f5 100644 --- a/src/nqrduck_spectrometer/pulseparameters.py +++ b/src/nqrduck_spectrometer/pulseparameters.py @@ -163,6 +163,16 @@ class Function: except: 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: @@ -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" @@ -207,6 +223,12 @@ class SincFunction(Function): self.add_parameter(Function.Parameter("Scale Factor", "l", 2)) 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): @@ -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.""" @@ -306,6 +333,9 @@ class FunctionOption(Option): obj = cls(data["name"], functions) obj.value = Function.from_json(data["value"]) return obj + + def get_pixmap(self): + return self.value.get_pixmap() class TXPulse(BaseSpectrometerModel.PulseParameter): @@ -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): diff --git a/src/nqrduck_spectrometer/resources/pulseparameter/RXOn.png b/src/nqrduck_spectrometer/resources/pulseparameter/RXOn.png index d9d57f3f9e0fc94f02b3527904f9424c06cf031a..527f8fd4ab930c657810310a2f58708cb7bef627 100644 GIT binary patch literal 315 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=jKx9jP7LeL$-D$|zIwVihE&XX zd+Q=^lYxZm!z7swNtyOWnRdxL9`kDy4_;dG;pmrn*RyOb|0M{|^wNB9WMHnlz>|SE zyz~35jL7HnU!Om|I&=Qs>({SEpJe%R@58G6b>cG_bT>S;R=nM5ncdVjzk%ff)2z(M z=gaEbv&(;8`+n7;>g{#A`hFjWmtSfe-V4XnvFa%?ZfSV7Y4U@M*_HW!*Hj<;AUuH~ p%Hi@`nGfrE>=`*1u$mBy<;yqPRPy@iY5)U(!PC{xWt~$(6989NcYgo? delta 303 zcmdnZbd70(K|P~@r;B4q#hkY@P759~;9=!;c3jz56eI9-2b)#XIr=kmTJIaM&rh1c`1(4F!2wGrDFy8<(1gM=^g zTjq&mIU6|0I^=S&tzh0F@poG%<12=}mR80DCs+k5^1U)-00K`}KbLh*2~7af)Oof5 diff --git a/src/nqrduck_spectrometer/resources/pulseparameter/TXCustom.png b/src/nqrduck_spectrometer/resources/pulseparameter/TXCustom.png new file mode 100644 index 0000000000000000000000000000000000000000..09d822fa2235d12d5d9ffff81dd68ff436ef8c0f GIT binary patch literal 346 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=jKx9jP7LeL$-D%zMLb;`Ln`LH zov~M_$v}XudGXr*!@sZF@#(gPY4RLyncv+#`L3Vpr=8_7b9gkDmcN=IE!*J6Si&I1 zdVw)R#DRT5AOjA8S=Cp>&tCrV_1DLm++F+1Vpo5i`OZ4QL*2jiy4J?;e_#C0U;3Mm zV>Y8|plF`&ci93-#?K~tWs_{@%Re<@(wKF&VegZffqq|K#4bL`3zy~=HIx{bj?Vhpkj zXN5~2CEu^>yMA4I(&9ag-7N8}CC^PSs!cI(V0B=35H@3us*V>nD9h$*GBK|D;V$O%%H) zXcVbxxJNr@SCrF_loP2}T|WF}xPDa_?39PqO^WF=B|x6w-7n5zd%I-=!wZItL+J-t m_e;%YnZdX@;2s0mi|m(IM^rGYI9UUOjlt8^&t;ucLK6UgqJu^N literal 0 HcmV?d00001 diff --git a/src/nqrduck_spectrometer/resources/pulseparameter/TXOn.png b/src/nqrduck_spectrometer/resources/pulseparameter/TXRect.png similarity index 100% rename from src/nqrduck_spectrometer/resources/pulseparameter/TXOn.png rename to src/nqrduck_spectrometer/resources/pulseparameter/TXRect.png diff --git a/src/nqrduck_spectrometer/resources/pulseparameter/TXSinc.png b/src/nqrduck_spectrometer/resources/pulseparameter/TXSinc.png new file mode 100644 index 0000000000000000000000000000000000000000..49adb3d6224907004a63c250c7659991d29fccd6 GIT binary patch literal 387 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=jKx9jP7LeL$-D%zZ9QEaLn`LH zoqdq6SwX;M#>0?%#M zJ+Ja5w@SD8H-Pvc3E$0($M=PW|B(A4WnROiH=nua-R-}-zs765egA5wVhz(Kwt(#2 z=J#w4sXtiFR*}8NM0D%h>aUNtZr|#}Y4I&Izg;;vhWQ`sRR-scjGs4!&fS)EJNR*% zzr(l42Wwa@&Fh~=9+>U^gC!-uBf#9O>hW3S8m3wIxht~IY|~!4W&gD$K&78`4OfMM ztxsXlZE$0|z?4zqo%15Y+y%r0iKYF}D_ErOme&MxHSad=JFO7^&NA