1313 :members:
1414"""
1515
16- from .plot import QwtPlotItem
16+ from .plot import QwtPlot , QwtPlotItem
1717from .text import QwtText
1818from .painter import QwtPainter
1919from .graphic import QwtGraphic
@@ -76,6 +76,93 @@ def __init__(self, title=None):
7676 self .__data = QwtPlotMarker_PrivateData ()
7777 self .setZ (30.0 )
7878
79+ @classmethod
80+ def make (
81+ cls ,
82+ xvalue = None ,
83+ yvalue = None ,
84+ title = None ,
85+ label = None ,
86+ symbol = None ,
87+ plot = None ,
88+ z = None ,
89+ x_axis = None ,
90+ y_axis = None ,
91+ align = None ,
92+ orientation = None ,
93+ spacing = None ,
94+ linestyle = None ,
95+ color = None ,
96+ width = None ,
97+ style = None ,
98+ antialiased = False ,
99+ ):
100+ """
101+ Create and setup a new `QwtPlotMarker` object (convenience function).
102+
103+ :param xvalue: x position (optional, default: None)
104+ :type xvalue: float or None
105+ :param yvalue: y position (optional, default: None)
106+ :type yvalue: float or None
107+ :param title: Marker title
108+ :type title: qwt.text.QwtText or str or None
109+ :param label: Label text
110+ :type label: qwt.text.QwtText or str or None
111+ :param symbol: New symbol
112+ :type symbol: qwt.symbol.QwtSymbol or None
113+ :param plot: Plot to attach the curve to
114+ :type plot: qwt.plot.QwtPlot or None
115+ :param z: Z-value
116+ :type z: float or None
117+ :param int x_axis: curve X-axis (default: QwtPlot.yLeft)
118+ :param int y_axis: curve Y-axis (default: QwtPlot.xBottom)
119+ :param align: Alignment of the label
120+ :type align: Qt.Alignment or None
121+ :param orientation: Orientation of the label
122+ :type orientation: Qt.Orientation or None
123+ :param spacing: Spacing (distance between the position and the label)
124+ :type spacing: int or None
125+ :param int linestyle: Line style
126+ :param QColor color: Pen color
127+ :param float width: Pen width
128+ :param Qt.PenStyle style: Pen style
129+ :param bool antialiased: if True, enable antialiasing rendering
130+
131+ .. seealso::
132+
133+ :py:meth:`setData()`, :py:meth:`setPen()`, :py:meth:`attach()`
134+ """
135+ item = cls (title )
136+ if z is not None :
137+ item .setZ (z )
138+ if symbol is not None :
139+ item .setSymbol (symbol )
140+ if xvalue is not None :
141+ item .setXValue (xvalue )
142+ if yvalue is not None :
143+ item .setYValue (yvalue )
144+ if label is not None :
145+ item .setLabel (label )
146+ x_axis = QwtPlot .xBottom if x_axis is None else x_axis
147+ y_axis = QwtPlot .yLeft if y_axis is None else y_axis
148+ item .setAxes (x_axis , y_axis )
149+ if align is not None :
150+ item .setLabelAlignment (align )
151+ if orientation is not None :
152+ item .setLabelOrientation (orientation )
153+ if spacing is not None :
154+ item .setSpacing (spacing )
155+ color = Qt .black if color is None else color
156+ width = 1.0 if width is None else width
157+ style = Qt .SolidLine if style is None else style
158+ item .setLinePen (QPen (color , width , style ))
159+ item .setRenderHint (cls .RenderAntialiased , antialiased )
160+ if linestyle is not None :
161+ item .setLineStyle (linestyle )
162+ if plot is not None :
163+ item .attach (plot )
164+ return item
165+
79166 def rtti (self ):
80167 """:return: `QwtPlotItem.Rtti_PlotMarker`"""
81168 return QwtPlotItem .Rtti_PlotMarker
@@ -338,6 +425,8 @@ def setLabel(self, label):
338425
339426 :py:meth:`label()`
340427 """
428+ if not isinstance (label , QwtText ):
429+ label = QwtText (label )
341430 if label != self .__data .label :
342431 self .__data .label = label
343432 self .itemChanged ()
@@ -444,7 +533,7 @@ def setLinePen(self, *args):
444533 """
445534 Build and/or assigna a line pen, depending on the arguments.
446535
447- .. py:method:: setPen (color, width, style)
536+ .. py:method:: setLinePen (color, width, style)
448537
449538 Build and assign a line pen
450539
@@ -456,7 +545,7 @@ def setLinePen(self, *args):
456545 :param float width: Pen width
457546 :param Qt.PenStyle style: Pen style
458547
459- .. py:method:: setPen (pen)
548+ .. py:method:: setLinePen (pen)
460549
461550 Specify a pen for the line.
462551
0 commit comments