Skip to content

Commit 2897ae4

Browse files
committed
constants: added panel IDs and other global const
1 parent 7c577da commit 2897ae4

File tree

18 files changed

+69
-62
lines changed

18 files changed

+69
-62
lines changed

.pylintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
max-line-length=88
55

66
[TYPECHECK]
7-
ignored-modules=qtpy.QtWidgets,qtpy.QtCore,qtpy.QtGui,qtpy.QtSvg,qtpy.QtPrintSupport,qtpy.QtDesigner,plotpy._scaler,plotpy.mandelbrot,plotpy.contour2d,plotpy.histogram2d
7+
ignored-modules=qtpy.QtWidgets,qtpy.QtCore,qtpy.QtGui,qtpy.QtSvg,qtpy.QtPrintSupport,qtpy.QtDesigner,plotpy._scaler,plotpy.mandelbrot,plotpy.contour2d,plotpy.histogram2d,PyQt5.QtWidgets
88

99
[MESSAGES CONTROL]
1010
disable=wrong-import-order

doc/features/panels/overview.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ Panels are objects inheriting from the :py:class:`.PanelWidget` class.
2020

2121
The built-in panels are:
2222

23-
* :py:data:`.ID_ITEMLIST`: `item list` panel
24-
* :py:data:`.ID_CONTRAST`: `contrast adjustment` panel
25-
* :py:data:`.ID_XCS`: `X-axis cross section` panel
26-
* :py:data:`.ID_YCS`: `Y-axis cross section` panel
27-
* :py:data:`.ID_OCS`: `oblique cross section` panel
23+
* :py:data:`plotpy.constants.ID_ITEMLIST`: `item list` panel
24+
* :py:data:`plotpy.constants.ID_CONTRAST`: `contrast adjustment` panel
25+
* :py:data:`plotpy.constants.ID_XCS`: `X-axis cross section` panel
26+
* :py:data:`plotpy.constants.ID_YCS`: `Y-axis cross section` panel
27+
* :py:data:`plotpy.constants.ID_OCS`: `oblique cross section` panel

plotpy/constants.py

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616

1717
from plotpy.config import _
1818

19-
# TODO: Move here other constants from around the codebase
19+
# ===============================================================================
20+
# Plot types
21+
# ===============================================================================
2022

2123

2224
class PlotType(enum.Enum):
@@ -44,13 +46,42 @@ class PlotType(enum.Enum):
4446
MANUAL = 4
4547

4648

49+
# ===============================================================================
50+
# Plot parameters
51+
# ===============================================================================
52+
4753
PARAMETERS_TITLE_ICON = {
4854
"grid": (_("Grid..."), "grid.png"),
4955
"axes": (_("Axes style..."), "axes.png"),
5056
"item": (_("Parameters..."), "settings.png"),
5157
}
5258

5359

60+
# ===============================================================================
61+
# Panels
62+
# ===============================================================================
63+
64+
#: ID of the `item list` panel
65+
ID_ITEMLIST = "itemlist"
66+
#: ID of the `contrast adjustment` panel
67+
ID_CONTRAST = "contrast"
68+
#: ID of the `X-axis cross section` panel
69+
ID_XCS = "x_cross_section"
70+
#: ID of the `Y-axis cross section` panel
71+
ID_YCS = "y_cross_section"
72+
#: ID of the `oblique averaged cross section` panel
73+
ID_OCS = "oblique_cross_section"
74+
75+
76+
# ===============================================================================
77+
# Plot items
78+
# ===============================================================================
79+
80+
# Shape Z offset used when adding shapes to the plot
81+
SHAPE_Z_OFFSET = 1000
82+
83+
84+
# Lookup table alpha functions for image items
5485
class LUTAlpha(enum.Enum):
5586
"""LUT Alpha functions"""
5687

@@ -86,3 +117,8 @@ def get_choices(self):
86117
(LUTAlpha.SIGMOID.value, _("Sigmoid")),
87118
(LUTAlpha.TANH.value, _("Hyperbolic tangent")),
88119
]
120+
121+
122+
# Lookup table size
123+
LUT_SIZE = 1024
124+
LUT_MAX = float(LUT_SIZE - 1)

plotpy/items/image/base.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
_scale_rect,
2727
)
2828
from plotpy.config import _
29-
from plotpy.constants import LUTAlpha
29+
from plotpy.constants import LUT_MAX, LUT_SIZE, LUTAlpha
3030
from plotpy.coords import pixelround
3131
from plotpy.interfaces import (
3232
IBaseImageItem,
@@ -58,9 +58,6 @@
5858
from plotpy.items import RectangleShape
5959
from plotpy.styles.base import ItemParameters
6060

61-
LUT_SIZE = 1024
62-
LUT_MAX = float(LUT_SIZE - 1)
63-
6461

6562
class BaseImageItem(QwtPlotItem):
6663
"""Base class for image items

plotpy/panels/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22

33
# pylint: disable=unused-import
4-
from .base import ID_CONTRAST, ID_ITEMLIST, ID_OCS, ID_XCS, ID_YCS, PanelWidget
4+
from .base import PanelWidget
55
from .contrastadjustment import ContrastAdjustment
66
from .csection import ObliqueCrossSection, XCrossSection, YCrossSection
77
from .itemlist import PlotItemList

plotpy/panels/base.py

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
class from which all panels must derived from) and identifiers for each kind
1212
of panel.
1313
14-
.. autodata:: ID_ITEMLIST
15-
.. autodata:: ID_CONTRAST
16-
.. autodata:: ID_XCS
17-
.. autodata:: ID_YCS
18-
.. autodata:: ID_OCS
14+
.. autodata:: plotpy.constants.ID_ITEMLIST
15+
.. autodata:: plotpy.constants.ID_CONTRAST
16+
.. autodata:: plotpy.constants.ID_XCS
17+
.. autodata:: plotpy.constants.ID_YCS
18+
.. autodata:: plotpy.constants.ID_OCS
1919
2020
.. autoclass:: PanelWidget
2121
:members:
@@ -25,25 +25,6 @@ class from which all panels must derived from) and identifiers for each kind
2525
from guidata.widgets.dockable import DockableWidget
2626
from qtpy import QtCore as QC
2727

28-
# ===============================================================================
29-
# Panel IDs
30-
# ===============================================================================
31-
32-
#: ID of the `item list` panel
33-
ID_ITEMLIST = "itemlist"
34-
35-
#: ID of the `contrast adjustment` panel
36-
ID_CONTRAST = "contrast"
37-
38-
#: ID of the `X-axis cross section` panel
39-
ID_XCS = "x_cross_section"
40-
41-
#: ID of the `Y-axis cross section` panel
42-
ID_YCS = "y_cross_section"
43-
44-
#: ID of the `oblique averaged cross section` panel
45-
ID_OCS = "oblique_cross_section"
46-
4728

4829
# ===============================================================================
4930
# Base Panel Widget class

plotpy/panels/contrastadjustment.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@
2727
from qtpy import QtWidgets as QW
2828

2929
from plotpy.config import CONF, _
30-
from plotpy.constants import PlotType
30+
from plotpy.constants import ID_CONTRAST, PlotType
3131
from plotpy.interfaces import IPanel, IVoiImageItemType
3232
from plotpy.items import HistogramItem, XRangeSelection
3333
from plotpy.lutrange import lut_range_threshold
34-
from plotpy.panels.base import ID_CONTRAST, PanelWidget
34+
from plotpy.panels.base import PanelWidget
3535
from plotpy.plot.base import BasePlot, BasePlotOptions
3636
from plotpy.styles import CurveParam, HistogramParam
3737
from plotpy.tools import AntiAliasingTool, BasePlotMenuTool, SelectPointTool, SelectTool

plotpy/panels/csection/csplot.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@
99
from qtpy import QtWidgets as QW
1010

1111
from plotpy.config import CONF, _
12-
from plotpy.constants import PlotType
12+
from plotpy.constants import LUT_MAX, PlotType
1313
from plotpy.interfaces import ICSImageItemType
14-
from plotpy.items.image.base import LUT_MAX
1514
from plotpy.panels.csection.csitem import (
1615
ObliqueCrossSectionItem,
1716
XCrossSectionItem,

plotpy/panels/csection/cswidget.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
from qtpy import QtWidgets as QW
88

99
from plotpy.config import _
10+
from plotpy.constants import ID_OCS, ID_XCS, ID_YCS
1011
from plotpy.interfaces import IPanel
11-
from plotpy.panels.base import ID_OCS, ID_XCS, ID_YCS, PanelWidget
12+
from plotpy.panels.base import PanelWidget
1213
from plotpy.panels.csection.csplot import (
1314
CrossSectionPlot,
1415
ObliqueCrossSectionPlot,

plotpy/panels/itemlist.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717
from qtpy import QtWidgets as QW
1818

1919
from plotpy.config import _
20+
from plotpy.constants import ID_ITEMLIST
2021
from plotpy.interfaces import IPanel
21-
from plotpy.panels.base import ID_ITEMLIST, PanelWidget
22+
from plotpy.panels.base import PanelWidget
2223

2324

2425
class ItemListWidget(QW.QListWidget):

0 commit comments

Comments
 (0)