Skip to content

Commit 1595484

Browse files
committed
Y-cross section: fixed auto spacer size issue
1 parent e3893c9 commit 1595484

File tree

2 files changed

+34
-12
lines changed

2 files changed

+34
-12
lines changed

plotpy/panels/csection/cswidget.py

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# -*- coding: utf-8 -*-
2+
23
from guidata.configtools import get_icon
34
from guidata.qthelpers import add_actions, create_action
45
from guidata.utils.misc import assert_interfaces_valid
@@ -18,8 +19,13 @@
1819

1920

2021
class CrossSectionWidget(PanelWidget):
21-
""" """
22+
"""Base class for cross section panels
23+
24+
Args:
25+
parent: parent widget
26+
"""
2227

28+
SIG_RESIZED = QC.Signal() # emitted when the widget is resized
2329
PANEL_ID = None
2430
PANEL_TITLE = _("Cross section tool")
2531
PANEL_ICON = "csection.png"
@@ -53,6 +59,15 @@ def __init__(self, parent=None):
5359

5460
self.setup_widget()
5561

62+
# Reimplement Qt method for sending a signal when the widget is resized
63+
def resizeEvent(self, event):
64+
"""
65+
66+
:param event:
67+
"""
68+
super().resizeEvent(event)
69+
self.SIG_RESIZED.emit()
70+
5671
def set_options(self, autoscale=None, autorefresh=None, lockscales=None):
5772
"""
5873
@@ -193,7 +208,11 @@ def update_plot(self, obj=None):
193208

194209

195210
class XCrossSection(CrossSectionWidget):
196-
"""X-axis cross section widget"""
211+
"""X-axis cross section panel
212+
213+
Args:
214+
parent: parent widget
215+
"""
197216

198217
PANEL_ID = ID_XCS
199218
OTHER_PANEL_ID = ID_YCS
@@ -319,10 +338,12 @@ def setup_actions(self):
319338

320339

321340
class YCrossSection(XCrossSection):
322-
"""
323-
Y-axis cross section widget
324-
parent (QWidget): parent widget
325-
position (string): "left" or "right"
341+
"""Y-axis cross section panel
342+
343+
Args:
344+
parent: parent widget
345+
position: position of the panel ('left' or 'right')
346+
xsection_pos: position of the cross section plot ('top' or 'bottom')
326347
"""
327348

328349
PANEL_ID = ID_YCS
@@ -360,7 +381,11 @@ def adjust_height(self, height):
360381

361382
# Oblique cross section panel
362383
class ObliqueCrossSection(CrossSectionWidget):
363-
"""Oblique averaged cross section widget"""
384+
"""Oblique averaged cross section panel
385+
386+
Args:
387+
parent: parent widget
388+
"""
364389

365390
PANEL_ID = ID_OCS
366391
CrossSectionPlotKlass = ObliqueCrossSectionPlot

plotpy/plot/plotwidget.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,7 @@ def __set_image_layout(self) -> None:
160160

161161
# Avoid circular import
162162
# pylint: disable=import-outside-toplevel
163-
from plotpy.panels.csection.cswidget import (XCrossSection,
164-
YCrossSection)
163+
from plotpy.panels.csection.cswidget import XCrossSection, YCrossSection
165164

166165
self.ycsw = YCrossSection(
167166
self,
@@ -174,6 +173,7 @@ def __set_image_layout(self) -> None:
174173
self.xcsw.setVisible(self.options.show_xsection)
175174

176175
self.xcsw.SIG_VISIBILITY_CHANGED.connect(self.__xcsw_is_visible)
176+
self.xcsw.SIG_RESIZED.connect(self.__adjust_ycsw_height)
177177

178178
self.xcsw_splitter = QW.QSplitter(QC.Qt.Orientation.Vertical, self)
179179
if self.options.xsection_pos == "top":
@@ -182,9 +182,6 @@ def __set_image_layout(self) -> None:
182182
else:
183183
self.xcsw_splitter.addWidget(self.plot)
184184
self.xcsw_splitter.addWidget(self.xcsw)
185-
self.xcsw_splitter.splitterMoved.connect(
186-
lambda pos, index: self.__adjust_ycsw_height()
187-
)
188185

189186
self.ycsw_splitter = QW.QSplitter(QC.Qt.Orientation.Horizontal, self)
190187
if self.options.ysection_pos == "left":

0 commit comments

Comments
 (0)