77 QModelIndex ,
88 QObject ,
99 QPoint ,
10+ QRect ,
1011 QSize ,
1112 Qt ,
1213)
2324 QWidget ,
2425)
2526
27+ from ert .ensemble_evaluator import state
2628from ert .gui .model .real_list import RealListModel
2729from ert .gui .model .snapshot import (
2830 CallbackStatusMessageRole ,
2931 FMStepColorHint ,
3032 MemoryUsageRole ,
3133 RealIens ,
34+ StatusRole ,
3235)
3336from ert .shared .status .utils import byte_with_unit
3437
@@ -40,7 +43,7 @@ def __init__(self, it: int, parent: QWidget | None = None) -> None:
4043 super ().__init__ (parent )
4144
4245 self ._iter = it
43- self ._delegate_size = QSize (90 , 90 )
46+ self ._delegate_size = QSize (70 , 70 )
4447
4548 self ._real_view = QListView (self )
4649 self ._real_view .setViewMode (QListView .ViewMode .IconMode )
@@ -95,66 +98,81 @@ def refresh_current_selection(self) -> None:
9598
9699
97100class RealizationDelegate (QStyledItemDelegate ):
101+ _DOT_DIAMETER = 32
102+ _ARC_MARGIN = 4
103+ _ARC_WIDTH = 5
104+
98105 def __init__ (self , size : QSize , parent : QObject ) -> None :
99106 super ().__init__ (parent )
100107 self ._size = size
101108 parent .installEventFilter (self )
102- self .adjustment_point_for_job_rect_margin = QPoint (- 20 , - 20 )
103- self ._color_black = QColor (0 , 0 , 0 , 180 )
104- self ._color_progress = QColor (50 , 173 , 230 , 200 )
105- self ._color_lightgray = QColor ("LightGray" ).lighter (120 )
106- self ._pen_black = QPen (self ._color_black , 2 , Qt .PenStyle .SolidLine )
109+ self .adjustment_point_for_job_rect_margin = QPoint (- 12 , - 12 )
110+ self ._color_track = QColor (0 , 0 , 0 , 35 )
111+ self ._pen_outline = QPen (QColor (0 , 0 , 0 , 45 ), 1 , Qt .PenStyle .SolidLine )
107112
108113 @override
109114 def paint (
110115 self , painter : QPainter | None , option : QStyleOptionViewItem , index : QModelIndex
111116 ) -> None :
112117 if painter is None :
113118 return
114- text = index .data (RealIens )
115- selected_color , finished_count , total_count = tuple (index .data (FMStepColorHint ))
119+ realization_label = index .data (RealIens )
120+ status = index .data (StatusRole )
121+ status_color , completed_step_count , total_step_count = tuple (
122+ index .data (FMStepColorHint )
123+ )
116124
117125 painter .save ()
118126 painter .setRenderHint (QPainter .RenderHint .TextAntialiasing , True )
119127 painter .setRenderHint (QPainter .RenderHint .Antialiasing , True )
120128
121- percentage_done = (
122- 100 if total_count < 1 else int ((finished_count * 100.0 ) / total_count )
123- )
124-
125- painter .setPen (self ._pen_black )
126- adjusted_rect = option .rect .adjusted (2 , 2 , - 2 , - 2 )
127-
128- painter .setBrush (
129- self ._color_progress if percentage_done == 100 else self ._color_lightgray
129+ if option .state & QStyle .StateFlag .State_Selected :
130+ highlight = QColor (option .palette .color (QPalette .ColorRole .Highlight ))
131+ highlight .setAlpha (60 )
132+ painter .setPen (Qt .PenStyle .NoPen )
133+ painter .setBrush (highlight )
134+ painter .drawRoundedRect (option .rect .adjusted (2 , 2 , - 2 , - 2 ), 6 , 6 )
135+
136+ status_dot_rect = QRect (
137+ option .rect .center ().x () - self ._DOT_DIAMETER // 2 ,
138+ option .rect .top () + 8 ,
139+ self ._DOT_DIAMETER ,
140+ self ._DOT_DIAMETER ,
130141 )
131- painter .drawEllipse (adjusted_rect )
132-
133- if 0 < percentage_done < 100 :
134- painter .setBrush (self ._color_progress )
135- painter .drawPie (adjusted_rect , 1440 , - int (percentage_done * 57.6 ))
136142
137- if option .state & QStyle .StateFlag .State_Selected :
138- factor : int = (
139- 125
140- if selected_color .lighter (125 ).getRgb () != (255 , 255 , 255 , 255 )
141- else 110
143+ if status == state .REALIZATION_STATE_RUNNING and total_step_count > 0 :
144+ progress_ring_rect = status_dot_rect .adjusted (
145+ - self ._ARC_MARGIN ,
146+ - self ._ARC_MARGIN ,
147+ self ._ARC_MARGIN ,
148+ self ._ARC_MARGIN ,
149+ )
150+ painter .setBrush (Qt .BrushStyle .NoBrush )
151+ painter .setPen (QPen (self ._color_track , self ._ARC_WIDTH ))
152+ painter .drawEllipse (progress_ring_rect )
153+ progress_pen = QPen (status_color , self ._ARC_WIDTH )
154+ progress_pen .setCapStyle (Qt .PenCapStyle .RoundCap )
155+ painter .setPen (progress_pen )
156+ painter .drawArc (
157+ progress_ring_rect ,
158+ 90 * 16 ,
159+ - int (360 * 16 * completed_step_count / total_step_count ),
142160 )
143- selected_color = selected_color .lighter (factor )
144-
145- painter .setBrush (selected_color )
146- adjusted_rect = option .rect .adjusted (7 , 7 , - 7 , - 7 )
147- painter .drawEllipse (adjusted_rect )
148161
149- font = painter .font ()
150- font .setBold (True )
151- painter .setFont (font )
162+ painter .setPen (self ._pen_outline )
163+ if status == state .REALIZATION_STATE_WAITING :
164+ painter .setBrush (Qt .BrushStyle .NoBrush )
165+ painter .setPen (QPen (status_color , 2 ))
166+ painter .drawEllipse (status_dot_rect .adjusted (1 , 1 , - 1 , - 1 ))
167+ else :
168+ painter .setBrush (status_color )
169+ painter .drawEllipse (status_dot_rect )
152170
153- adj_rect = option .rect .adjusted (0 , 20 , 0 , 0 )
154- painter .drawText (adj_rect , Qt .AlignmentFlag .AlignHCenter , text )
155- adj_rect = option .rect .adjusted (0 , 45 , 0 , 0 )
171+ painter .setPen (option .palette .color (QPalette .ColorRole .Text ))
156172 painter .drawText (
157- adj_rect , Qt .AlignmentFlag .AlignHCenter , f"{ finished_count } / { total_count } "
173+ option .rect .adjusted (0 , self ._DOT_DIAMETER + 14 , 0 , 0 ),
174+ Qt .AlignmentFlag .AlignHCenter ,
175+ realization_label ,
158176 )
159177
160178 painter .restore ()
0 commit comments