@@ -361,15 +361,19 @@ def _overlapInfo(self, id):
361361 label2 = self ._cellLabel (cell2 )
362362 return f"OVERLAP: Universe { universe } , Cells { label1 } and { label2 } "
363363
364- def _undefinedInfo (self , event ):
365- """Status-bar text for an undefined (not-found) pixel, if classified ."""
364+ def _isUndefinedInternal (self , event ):
365+ """Whether the pixel under the event is an internal undefined region ."""
366366 if self .model .undefined_internal is None :
367- return ""
367+ return False
368368 xPos , yPos = self .getDataIndices (event )
369369 cv = self .model .currentView
370370 if not (0 <= yPos < cv .v_res and 0 <= xPos < cv .h_res ):
371- return ""
372- if self .model .undefined_internal [yPos , xPos ]:
371+ return False
372+ return bool (self .model .undefined_internal [yPos , xPos ])
373+
374+ def _undefinedInfo (self , event ):
375+ """Status-bar text for an undefined (not-found) pixel, if classified."""
376+ if self ._isUndefinedInternal (event ):
373377 return "WARNING: undefined internal region"
374378 return ""
375379
@@ -580,7 +584,16 @@ def contextMenuEvent(self, event):
580584
581585 if cv .colorby not in _MODEL_PROPERTIES :
582586 self .menu .addSeparator ()
583- if int (id ) == _NOT_FOUND :
587+ if int (id ) == _NOT_FOUND and self ._isUndefinedInternal (event ):
588+ undefColorAction = self .menu .addAction (
589+ 'Edit Undefined Color...' )
590+ undefColorAction .setToolTip ('Edit undefined color' )
591+ undefColorAction .setStatusTip (
592+ 'Edit plot undefined region color' )
593+ connector = partial (self .main_window .editUndefinedColor ,
594+ apply = True )
595+ undefColorAction .triggered .connect (connector )
596+ elif int (id ) == _NOT_FOUND :
584597 bgColorAction = self .menu .addAction (
585598 'Edit Background Color...' )
586599 bgColorAction .setToolTip ('Edit background color' )
@@ -610,6 +623,7 @@ def contextMenuEvent(self, event):
610623 self .menu .addAction (self .main_window .maskingAction )
611624 self .menu .addAction (self .main_window .highlightingAct )
612625 self .menu .addAction (self .main_window .overlapAct )
626+ self .menu .addAction (self .main_window .undefinedAct )
613627 self .menu .addSeparator ()
614628 self .menu .addAction (self .main_window .dockAction )
615629
@@ -1145,10 +1159,8 @@ def createGeneralTab(self):
11451159 self .undefinedColorButton = QPushButton ()
11461160 self .undefinedColorButton .setCursor (QtCore .Qt .PointingHandCursor )
11471161 self .undefinedColorButton .setFixedWidth (button_width )
1148- self .undefinedColorButton .setFixedHeight (
1149- self .font_metric .height () * 1.5 )
1150- self .undefinedColorButton .clicked .connect (
1151- main_window .editUndefinedColor )
1162+ self .undefinedColorButton .setFixedHeight (self .font_metric .height () * 1.5 )
1163+ self .undefinedColorButton .clicked .connect (main_window .editUndefinedColor )
11521164
11531165 self .colorResetButton = QPushButton ("&Reset Colors" )
11541166 self .colorResetButton .setCursor (QtCore .Qt .PointingHandCursor )
@@ -1415,8 +1427,8 @@ def updateOverlap(self):
14151427
14161428 def updateUndefinedColor (self ):
14171429 color = self .model .activeView .undefined_color
1418- style = "border-radius: 8px;background-color: rgb%s "
1419- self . undefinedColorButton . setStyleSheet ( style % str (color ))
1430+ self . undefinedColorButton . setStyleSheet ( "border-radius: 8px;"
1431+ "background-color: rgb%s" % ( str (color ) ))
14201432
14211433 def updateUndefined (self ):
14221434 colorby = self .model .activeView .colorby
0 commit comments