Skip to content

Commit

Permalink
qtpy - issue #25 - extended the fix to other clickable objects
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon committed Jul 31, 2023
1 parent 51eaff2 commit 55bfb79
Showing 1 changed file with 32 additions and 23 deletions.
55 changes: 32 additions & 23 deletions main/PyQtGUI/gui/GUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -1478,7 +1478,6 @@ def axisScale(self, ax, index):
if self.currentPlot.h_log[index]:
if (DEBUG):
print("needs to become log...")
print("needs to become log...")
if (self.currentPlot.h_dict[index]["dim"] == 1) :
if ax.get_yscale() == "linear":
ymin, ymax = ax.get_ylim()
Expand All @@ -1495,12 +1494,10 @@ def axisScale(self, ax, index):
zmin = math.log10(zmin)
zmax = math.log10(self.maxZ)
self.currentPlot.h_lst[index].set_clim(vmin=zmin, vmax=zmax)
print("Simon - h_lst index - ",index,self.currentPlot.h_lst[index])
else:
if (DEBUG):
print("needs to become linear...")
print(self.currentPlot.h_limits)
print("needs to become linear...")
if (self.currentPlot.h_dict[index]["dim"] == 1) :
if ax.get_yscale() == "log":
ax.set_yscale("linear")
Expand Down Expand Up @@ -1563,7 +1560,7 @@ def zoom(self, ax, index, flag):
if (DEBUG):
print("new ymax", ymax)
ax.set_ylim((ax.get_ylim())[0],ymax)
else:
elif self.currentPlot.h_lst[index] is not None:
zmax = self.currentPlot.h_lst[index].get_clim()[1]
if (DEBUG):
print("zmax",zmax)
Expand Down Expand Up @@ -1596,11 +1593,11 @@ def zoomIn(self, canvas):
self.zoom(ax, index, "in")

#Simon - added lines - save axis limits for updates
x_range, y_range = self.getAxisProperties(index)
self.currentPlot.h_limits[index]["x"] = x_range
self.currentPlot.h_limits[index]["y"] = y_range
self.currentPlot.isZoomInOut = True

if index in self.currentPlot.h_limits:
x_range, y_range = self.getAxisProperties(index)
self.currentPlot.h_limits[index]["x"] = x_range
self.currentPlot.h_limits[index]["y"] = y_range
self.currentPlot.isZoomInOut = True

canvas.draw()

Expand All @@ -1625,10 +1622,11 @@ def zoomOut(self, canvas):
self.zoom(ax, index, "out")

#Simon - added lines - save axis limits for updates
x_range, y_range = self.getAxisProperties(index)
self.currentPlot.h_limits[index]["x"] = x_range
self.currentPlot.h_limits[index]["y"] = y_range
self.currentPlot.isZoomInOut = True
if index in self.currentPlot.h_limits:
x_range, y_range = self.getAxisProperties(index)
self.currentPlot.h_limits[index]["x"] = x_range
self.currentPlot.h_limits[index]["y"] = y_range
self.currentPlot.isZoomInOut = True

canvas.draw()

Expand Down Expand Up @@ -1839,7 +1837,11 @@ def check_index(self):
# for index, value in self.currentPlot.h_dict.items():
# values.append(value["name"])

values = [value["name"] for value in self.currentPlot.h_dict.values()]
try:
values = [value["name"] for value in self.currentPlot.h_dict.values()]
except TypeError as err:
print(err)
return

if (DEBUG):
print(keys, values)
Expand Down Expand Up @@ -2113,13 +2115,14 @@ def addPlot(self):

if (DEBUG):
print("Adding plot at index ", index)

print("self.currentPlot.h_dict", currentPlot.h_dict)
print("self.currentPlot.h_dict_geo", currentPlot.h_dict_geo)
print("self.currentPlot.h_dim", currentPlot.h_dim)

# updating histogram dictionary for fast access to information via get_histo_xxx
currentPlot.h_dict[index] = self.update_spectrum_info()
if currentPlot.h_dict[index] is None:
return
currentPlot.h_dict_geo[index] = (currentPlot.h_dict[index])["name"]
currentPlot.h_dim[index] = (currentPlot.h_dict[index])["dim"]
currentPlot.h_limits[index] = {}
Expand Down Expand Up @@ -2255,6 +2258,8 @@ def clearPlot(self):
print("self.currentPlot.h_dict", self.currentPlot.h_dict)
# Simon - added following lines to avoid None plot index
index = self.autoIndex()
if index is None:
return

if self.currentPlot.h_dict[index]["name"] != "empty" :
a = self.select_plot(index)
Expand All @@ -2275,13 +2280,15 @@ def updatePlot(self):
print("self.currentPlot.h_setup", self.currentPlot.h_setup)
print("verification tab index", self.wTab.currentIndex())

# try:
a = None
#Simon - self.currentPlot.selected_plot_index replaced index from by following lines
#Simon - because selected_plot_index comes from on_press which in zoom mode is always 0
name = str(self.wConf.histo_list.currentText())
index = self.autoIndex()
if index is None:
return
try:
a = None
#Simon - self.currentPlot.selected_plot_index replaced index from by following lines
#Simon - because selected_plot_index comes from on_press which in zoom mode is always 0
name = str(self.wConf.histo_list.currentText())
index = self.autoIndex()

#x_range, y_range = self.getAxisProperties(index)
if self.currentPlot.isZoomed:
#Simon - sca for zoom feature when multiple tabs
Expand Down Expand Up @@ -3306,8 +3313,10 @@ def closeCopy(self):
def copyPopup(self):
if self.copyAttr.isVisible():
self.copyAttr.close()

self.updatePlotLimits()
try:
self.updatePlotLimits()
except:
return
index = self.currentPlot.selected_plot_index
name = self.currentPlot.h_dict_geo[index]

Expand Down

0 comments on commit 55bfb79

Please sign in to comment.