tbapi.api.bases.drawing
1from __future__ import annotations 2from typing import TYPE_CHECKING 3import clr 4from tbapi.common.decorators import tb_class, tb_interface 5from tbapi.common.converters import to_python_datetime, to_net_datetime 6from datetime import datetime 7from Tickblaze.Scripts.Api.Bases import Drawing as _Drawing 8from typing import Any, overload 9from abc import ABC, abstractmethod 10from tbapi.api.bases.symbol_script import SymbolScript 11from tbapi.api.interfaces.ichart_object import IChartObject 12from tbapi.api.enums.ztype import ZType 13from Tickblaze.Scripts.Api.Enums import ZType as _ZType 14from tbapi.api.interfaces.idrawing_context import IDrawingContext 15if TYPE_CHECKING: 16 from tbapi.api.interfaces.ichart import IChart 17 from tbapi.api.interfaces.ichart_points import IChartPoints 18 from tbapi.api.interfaces.ichart_scale import IChartScale 19 from tbapi.api.interfaces.isymbol import ISymbol 20 21@tb_interface(_Drawing) 22class Drawing(SymbolScript, IChartObject): 23 """Represents a base class for drawing objects that can be rendered on the chart.""" 24 25 @staticmethod 26 def new(*args, **kwargs): 27 """Generic factory method for Drawing. Use overloads for IDE type hints.""" 28 return Drawing(*args, **kwargs) 29 30 @property 31 def points_count(self) -> int: 32 """Gets the number of points in the drawing.""" 33 val = self._value.PointsCount 34 return val 35 @property 36 def is_created(self) -> bool: 37 """Indicates whether the drawing object has been created.""" 38 val = self._value.IsCreated 39 return val 40 @is_created.setter 41 def is_created(self, val: bool): 42 tmp = self._value 43 tmp.IsCreated = val 44 self._value = tmp 45 @property 46 def is_selected(self) -> bool: 47 """Indicates whether the drawing is selected.""" 48 val = self._value.IsSelected 49 return val 50 @is_selected.setter 51 def is_selected(self, val: bool): 52 tmp = self._value 53 tmp.IsSelected = val 54 self._value = tmp 55 @property 56 def is_updating(self) -> bool: 57 """Indicates whether the drawing anchors are updating.""" 58 val = self._value.IsUpdating 59 return val 60 @is_updating.setter 61 def is_updating(self, val: bool): 62 tmp = self._value 63 tmp.IsUpdating = val 64 self._value = tmp 65 @property 66 def chart(self) -> IChart: 67 from tbapi.api.interfaces.ichart import IChart 68 val = self._value.Chart 69 return IChart(_existing=val) 70 @chart.setter 71 def chart(self, val: IChart): 72 tmp = self._value 73 tmp.Chart = val._value 74 self._value = tmp 75 @property 76 def points(self) -> IChartPoints: 77 from tbapi.api.interfaces.ichart_points import IChartPoints 78 val = self._value.Points 79 return IChartPoints(_existing=val) 80 @points.setter 81 def points(self, val: IChartPoints): 82 tmp = self._value 83 tmp.Points = val._value 84 self._value = tmp 85 @property 86 def chart_scale(self) -> IChartScale: 87 from tbapi.api.interfaces.ichart_scale import IChartScale 88 val = self._value.ChartScale 89 return IChartScale(_existing=val) 90 @chart_scale.setter 91 def chart_scale(self, val: IChartScale): 92 tmp = self._value 93 tmp.ChartScale = val._value 94 self._value = tmp 95 @property 96 def symbol(self) -> ISymbol: 97 from tbapi.api.interfaces.isymbol import ISymbol 98 val = self._value.Symbol 99 return ISymbol(_existing=val) 100 @symbol.setter 101 def symbol(self, val: ISymbol): 102 tmp = self._value 103 tmp.Symbol = val._value 104 self._value = tmp 105 @property 106 def show_on_chart(self) -> bool: 107 val = self._value.ShowOnChart 108 return val 109 @show_on_chart.setter 110 def show_on_chart(self, val: bool): 111 tmp = self._value 112 tmp.ShowOnChart = val 113 self._value = tmp 114 @property 115 def ztype(self) -> ZType: 116 val = int(self._value.ZType) 117 return ZType(val) 118 @ztype.setter 119 def ztype(self, val: ZType): 120 tmp = self._value 121 tmp.ZType = _ZType(val.value if hasattr(val, "value") else int(val)) 122 self._value = tmp 123 @property 124 def snap_to_bar(self) -> bool: 125 """Gets or sets a value indicating whether the drawing is snapped to the bar.""" 126 val = self._value.SnapToBar 127 return val 128 @snap_to_bar.setter 129 def snap_to_bar(self, val: bool): 130 tmp = self._value 131 tmp.SnapToBar = val 132 self._value = tmp 133 @property 134 def pending_additional_data_download(self) -> bool: 135 val = self._value.PendingAdditionalDataDownload 136 return val 137 @pending_additional_data_download.setter 138 def pending_additional_data_download(self, val: bool): 139 tmp = self._value 140 tmp.PendingAdditionalDataDownload = val 141 self._value = tmp 142 143 144 @clr.clrmethod(None, [Any, Any, int]) 145 def set_point(self, x_data_value: Any, y_data_value: Any, index: int) -> None: 146 """Sets a point on the drawing at the specified index. The x data value of the point. The y data value of the point. The index of the point to set.""" 147 ... 148 149 @clr.clrmethod(None, [None]) 150 def on_created(self) -> None: 151 """Performs actions when the drawing is created.""" 152 ... 153 154 @clr.clrmethod(None, [Any]) 155 def on_render(self, context: IDrawingContext) -> None: 156 ...
29@tb_interface(_Drawing) 30class Drawing(SymbolScript, IChartObject): 31 """Represents a base class for drawing objects that can be rendered on the chart.""" 32 33 @staticmethod 34 def new(*args, **kwargs): 35 """Generic factory method for Drawing. Use overloads for IDE type hints.""" 36 return Drawing(*args, **kwargs) 37 38 @property 39 def points_count(self) -> int: 40 """Gets the number of points in the drawing.""" 41 val = self._value.PointsCount 42 return val 43 @property 44 def is_created(self) -> bool: 45 """Indicates whether the drawing object has been created.""" 46 val = self._value.IsCreated 47 return val 48 @is_created.setter 49 def is_created(self, val: bool): 50 tmp = self._value 51 tmp.IsCreated = val 52 self._value = tmp 53 @property 54 def is_selected(self) -> bool: 55 """Indicates whether the drawing is selected.""" 56 val = self._value.IsSelected 57 return val 58 @is_selected.setter 59 def is_selected(self, val: bool): 60 tmp = self._value 61 tmp.IsSelected = val 62 self._value = tmp 63 @property 64 def is_updating(self) -> bool: 65 """Indicates whether the drawing anchors are updating.""" 66 val = self._value.IsUpdating 67 return val 68 @is_updating.setter 69 def is_updating(self, val: bool): 70 tmp = self._value 71 tmp.IsUpdating = val 72 self._value = tmp 73 @property 74 def chart(self) -> IChart: 75 from tbapi.api.interfaces.ichart import IChart 76 val = self._value.Chart 77 return IChart(_existing=val) 78 @chart.setter 79 def chart(self, val: IChart): 80 tmp = self._value 81 tmp.Chart = val._value 82 self._value = tmp 83 @property 84 def points(self) -> IChartPoints: 85 from tbapi.api.interfaces.ichart_points import IChartPoints 86 val = self._value.Points 87 return IChartPoints(_existing=val) 88 @points.setter 89 def points(self, val: IChartPoints): 90 tmp = self._value 91 tmp.Points = val._value 92 self._value = tmp 93 @property 94 def chart_scale(self) -> IChartScale: 95 from tbapi.api.interfaces.ichart_scale import IChartScale 96 val = self._value.ChartScale 97 return IChartScale(_existing=val) 98 @chart_scale.setter 99 def chart_scale(self, val: IChartScale): 100 tmp = self._value 101 tmp.ChartScale = val._value 102 self._value = tmp 103 @property 104 def symbol(self) -> ISymbol: 105 from tbapi.api.interfaces.isymbol import ISymbol 106 val = self._value.Symbol 107 return ISymbol(_existing=val) 108 @symbol.setter 109 def symbol(self, val: ISymbol): 110 tmp = self._value 111 tmp.Symbol = val._value 112 self._value = tmp 113 @property 114 def show_on_chart(self) -> bool: 115 val = self._value.ShowOnChart 116 return val 117 @show_on_chart.setter 118 def show_on_chart(self, val: bool): 119 tmp = self._value 120 tmp.ShowOnChart = val 121 self._value = tmp 122 @property 123 def ztype(self) -> ZType: 124 val = int(self._value.ZType) 125 return ZType(val) 126 @ztype.setter 127 def ztype(self, val: ZType): 128 tmp = self._value 129 tmp.ZType = _ZType(val.value if hasattr(val, "value") else int(val)) 130 self._value = tmp 131 @property 132 def snap_to_bar(self) -> bool: 133 """Gets or sets a value indicating whether the drawing is snapped to the bar.""" 134 val = self._value.SnapToBar 135 return val 136 @snap_to_bar.setter 137 def snap_to_bar(self, val: bool): 138 tmp = self._value 139 tmp.SnapToBar = val 140 self._value = tmp 141 @property 142 def pending_additional_data_download(self) -> bool: 143 val = self._value.PendingAdditionalDataDownload 144 return val 145 @pending_additional_data_download.setter 146 def pending_additional_data_download(self, val: bool): 147 tmp = self._value 148 tmp.PendingAdditionalDataDownload = val 149 self._value = tmp 150 151 152 @clr.clrmethod(None, [Any, Any, int]) 153 def set_point(self, x_data_value: Any, y_data_value: Any, index: int) -> None: 154 """Sets a point on the drawing at the specified index. The x data value of the point. The y data value of the point. The index of the point to set.""" 155 ... 156 157 @clr.clrmethod(None, [None]) 158 def on_created(self) -> None: 159 """Performs actions when the drawing is created.""" 160 ... 161 162 @clr.clrmethod(None, [Any]) 163 def on_render(self, context: IDrawingContext) -> None: 164 ...
Represents a base class for drawing objects that can be rendered on the chart.
33 @staticmethod 34 def new(*args, **kwargs): 35 """Generic factory method for Drawing. Use overloads for IDE type hints.""" 36 return Drawing(*args, **kwargs)
Generic factory method for Drawing. Use overloads for IDE type hints.
38 @property 39 def points_count(self) -> int: 40 """Gets the number of points in the drawing.""" 41 val = self._value.PointsCount 42 return val
Gets the number of points in the drawing.
43 @property 44 def is_created(self) -> bool: 45 """Indicates whether the drawing object has been created.""" 46 val = self._value.IsCreated 47 return val
Indicates whether the drawing object has been created.
53 @property 54 def is_selected(self) -> bool: 55 """Indicates whether the drawing is selected.""" 56 val = self._value.IsSelected 57 return val
Indicates whether the drawing is selected.
63 @property 64 def is_updating(self) -> bool: 65 """Indicates whether the drawing anchors are updating.""" 66 val = self._value.IsUpdating 67 return val
Indicates whether the drawing anchors are updating.
73 @property 74 def chart(self) -> IChart: 75 from tbapi.api.interfaces.ichart import IChart 76 val = self._value.Chart 77 return IChart(_existing=val)
The chart to which this object belongs.
93 @property 94 def chart_scale(self) -> IChartScale: 95 from tbapi.api.interfaces.ichart_scale import IChartScale 96 val = self._value.ChartScale 97 return IChartScale(_existing=val)
The scale used by this object on the chart.
131 @property 132 def snap_to_bar(self) -> bool: 133 """Gets or sets a value indicating whether the drawing is snapped to the bar.""" 134 val = self._value.SnapToBar 135 return val
Gets or sets a value indicating whether the drawing is snapped to the bar.
Method decorator for exposing python methods to .NET. The argument and return types must be specified as arguments to clrmethod.
e.g.::
class X(object):
@clrmethod(int, [str])
def test(self, x):
return len(x)
Methods decorated this way can be called from .NET, e.g.::
dynamic x = getX(); // get an instance of X declared in Python
int z = x.test("hello"); // calls into python and returns len("hello")
Method decorator for exposing python methods to .NET. The argument and return types must be specified as arguments to clrmethod.
e.g.::
class X(object):
@clrmethod(int, [str])
def test(self, x):
return len(x)
Methods decorated this way can be called from .NET, e.g.::
dynamic x = getX(); // get an instance of X declared in Python
int z = x.test("hello"); // calls into python and returns len("hello")
Method decorator for exposing python methods to .NET. The argument and return types must be specified as arguments to clrmethod.
e.g.::
class X(object):
@clrmethod(int, [str])
def test(self, x):
return len(x)
Methods decorated this way can be called from .NET, e.g.::
dynamic x = getX(); // get an instance of X declared in Python
int z = x.test("hello"); // calls into python and returns len("hello")