77# from omc3_gui.segment_by_segment.segment_by_segment_ui import Ui_main_window
88from __future__ import annotations
99
10- from dataclasses import fields
11- from functools import partial
1210import logging
1311from collections .abc import Sequence
12+ from dataclasses import fields
13+ from functools import partial
1414
15- from omc3 .definitions .optics import PHASE_COLUMN , BETA_COLUMN , ALPHA_COLUMN , ColumnsAndLabels
15+ from omc3 .definitions .optics import (
16+ ALPHA_COLUMN ,
17+ BETA_COLUMN ,
18+ DISPERSION_COLUMN ,
19+ PHASE_COLUMN ,
20+ )
1621from qtpy import QtGui , QtWidgets
1722from qtpy .QtCore import QItemSelectionModel , QModelIndex , Qt , Signal , Slot
1823
19- from omc3_gui .plotting .classes import DualPlot
24+ from omc3_gui .plotting .classes import DualPlotWidget
2025from omc3_gui .segment_by_segment .main_model import (
2126 MeasurementListModel ,
2227 SegmentTableModel ,
2328)
2429from omc3_gui .segment_by_segment .measurement_model import OpticsMeasurement
30+ from omc3_gui .segment_by_segment .plotting import DualPlotDefinition
2531from omc3_gui .segment_by_segment .segment_model import SegmentItemModel
2632from omc3_gui .ui_components import colors
27- from omc3_gui .utils .counter import HorizontalGridLayoutFiller
28- from omc3_gui .utils .iteration_classes import IterClass
29- from omc3_gui .ui_components .styles import MONOSPACED_TOOLTIP
3033from omc3_gui .ui_components .base_classes_cvm import View
34+ from omc3_gui .ui_components .styles import MONOSPACED_TOOLTIP
3135from omc3_gui .ui_components .widgets import (
32- DefaultButton ,
3336 ChangeButton ,
37+ DefaultButton ,
3438 OpenButton ,
3539 RemoveButton ,
3640 RunButton ,
3741)
42+ from omc3_gui .utils .counter import HorizontalGridLayoutFiller
43+ from omc3_gui .utils .iteration_classes import IterClass
3844
3945ItemDataRole = Qt .ItemDataRole
4046LOGGER = logging .getLogger (__name__ )
4147
42- class Tabs (IterClass ):
43- PHASE : ColumnsAndLabels = PHASE_COLUMN
44- BETA : ColumnsAndLabels = BETA_COLUMN
45- ALPHA : ColumnsAndLabels = ALPHA_COLUMN
4648
49+ class Tabs (IterClass ):
50+ """ Define the Tabs and the things to plot in them. """
51+ PHASE : DualPlotDefinition = DualPlotDefinition .generate_xy ("Phase" , "phase" , PHASE_COLUMN )
52+ BETA : DualPlotDefinition = DualPlotDefinition .generate_xy ("Beta" , "beta_phase" , BETA_COLUMN )
53+ ALPHA : DualPlotDefinition = DualPlotDefinition .generate_xy ("Alpha" , "alpha_phase" , ALPHA_COLUMN )
54+ DISPERSION : DualPlotDefinition = DualPlotDefinition .generate_xy ("Dispersion" , "dispersion" , DISPERSION_COLUMN )
55+ F1001AP : DualPlotDefinition = DualPlotDefinition .generate_amplitude_phase ("f1001" )
56+ F1001RI : DualPlotDefinition = DualPlotDefinition .generate_real_imag ("f1001" )
57+ F1010AP : DualPlotDefinition = DualPlotDefinition .generate_amplitude_phase ("f1010" )
58+ F1010RI : DualPlotDefinition = DualPlotDefinition .generate_real_imag ("f1010" )
59+
4760
4861class SbSWindow (View ):
4962 WINDOW_TITLE = "OMC Segment-by-Segment"
@@ -125,7 +138,7 @@ def _handle_tab_changed(self):
125138 LOGGER .debug ("Tab changed." )
126139 self .sig_tab_changed .emit ()
127140
128- # GUI-Elements -------------------------------------------------------------
141+ # Menu -------- -------------------------------------------------------------
129142 def _add_menus (self ):
130143 # File ---
131144 file_menu : QtWidgets .QMenu = self .get_action_by_title ("File" ) # defined in View-class
@@ -212,6 +225,7 @@ def update_menu_settings(self, menu: str, settings: object, names: Sequence[str]
212225
213226 entry .setChecked (getattr (settings , field .name ))
214227
228+ # Build Main UI-------------------------------------------------------------
215229 def _build_gui (self ):
216230 self ._central = QtWidgets .QSplitter (Qt .Horizontal )
217231
@@ -331,7 +345,8 @@ def build_segment_buttons():
331345 def build_tabs_widget (): # --- Right Hand Side
332346 self ._tabs_widget = QtWidgets .QTabWidget ()
333347 for tab in Tabs .values ():
334- self ._tabs_widget .addTab (DualPlot (), tab .text_label .capitalize ())
348+ tab : DualPlotDefinition
349+ self ._tabs_widget .addTab (DualPlotWidget (), tab .name )
335350 return self ._tabs_widget
336351
337352 self ._central .addWidget (build_tabs_widget ())
@@ -341,8 +356,9 @@ def build_tabs_widget(): # --- Right Hand Side
341356 self ._central .setStretchFactor (1 , 3 )
342357
343358 self .setCentralWidget (self ._central )
344-
345- def get_current_tab (self ) -> tuple [ColumnsAndLabels , DualPlot ]:
359+
360+ # Interactors --------------------------------------------------------------
361+ def get_current_tab (self ) -> tuple [DualPlotDefinition , DualPlotWidget ]:
346362 widget = self ._tabs_widget .currentWidget ()
347363 index = self ._tabs_widget .currentIndex ()
348364 return list (Tabs .values ())[index ], widget
@@ -388,6 +404,7 @@ def get_selected_segments(self) -> tuple[SegmentItemModel]:
388404
389405
390406class MeasurementListView (QtWidgets .QListView ):
407+ """ Defines the view for the measurement list (on the top left). """
391408
392409 def __init__ (self ):
393410 super ().__init__ ()
@@ -398,6 +415,7 @@ def __init__(self):
398415
399416
400417class SegmentTableView (QtWidgets .QTableView ):
418+ """ Defines the view for the segment table (on the bottom left). """
401419
402420 def __init__ (self ):
403421 super ().__init__ ()
@@ -425,6 +443,7 @@ def __init__(self):
425443
426444
427445class ColoredItemDelegate (QtWidgets .QStyledItemDelegate ):
446+ """ Defines an ItemDelegate that uses a custom color for the text. """
428447
429448 COLOR_MAP = {
430449 MeasurementListModel .ColorIDs .NONE : colors .TEXT_DARK ,
0 commit comments