14
14
from guidata .utils .misc import assert_interfaces_valid
15
15
from qtpy import QtCore as QC
16
16
from qtpy import QtGui as QG
17
- from qwt import QwtPlotItem
17
+ from qwt import QwtLinearScaleEngine , QwtPlotItem
18
18
19
19
from plotpy import io
20
20
from plotpy ._scaler import (
55
55
from qtpy .QtGui import QColor , QPainter
56
56
57
57
from plotpy .interfaces import IItemType
58
+ from plotpy .plot import BasePlot
58
59
from plotpy .styles .base import ItemParameters
59
60
from plotpy .widgets .colormap .widget import EditableColormap
60
61
@@ -582,6 +583,29 @@ def draw_border(
582
583
"""
583
584
self .border_rect .draw (painter , xMap , yMap , canvasRect )
584
585
586
+ def warn_if_non_linear_scale (self , painter : QPainter , canvasRect : QRectF ) -> bool :
587
+ """Warn if non-linear scale
588
+
589
+ Args:
590
+ painter: Painter
591
+ canvasRect: Canvas rectangle
592
+
593
+ Returns:
594
+ True if non-linear scale
595
+ """
596
+ plot : BasePlot = self .plot ()
597
+ if not isinstance (
598
+ plot .axisScaleEngine (plot .X_BOTTOM ), QwtLinearScaleEngine
599
+ ) or not isinstance (plot .axisScaleEngine (plot .Y_LEFT ), QwtLinearScaleEngine ):
600
+ painter .setPen (QC .Qt .red )
601
+ painter .drawText (
602
+ canvasRect ,
603
+ QC .Qt .AlignCenter ,
604
+ _ ("Non-linear scales are not supported for image items" ),
605
+ )
606
+ return True
607
+ return False
608
+
585
609
def draw_image (
586
610
self ,
587
611
painter : QPainter ,
@@ -601,6 +625,8 @@ def draw_image(
601
625
xMap: X axis scale map
602
626
yMap: Y axis scale map
603
627
"""
628
+ if self .warn_if_non_linear_scale (painter , canvasRect ):
629
+ return
604
630
dest = _scale_rect (
605
631
self .data , src_rect , self ._offscreen , dst_rect , self .lut , self .interpolate
606
632
)
0 commit comments