File size: 6,468 Bytes
be4d336 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | from plotly.utils import _list_repr_elided
class InputDeviceState:
def __init__(
self, ctrl=None, alt=None, shift=None, meta=None, button=None, buttons=None, **_
):
self._ctrl = ctrl
self._alt = alt
self._meta = meta
self._shift = shift
self._button = button
self._buttons = buttons
def __repr__(self):
return """\
InputDeviceState(
ctrl={ctrl},
alt={alt},
shift={shift},
meta={meta},
button={button},
buttons={buttons})""".format(
ctrl=repr(self.ctrl),
alt=repr(self.alt),
meta=repr(self.meta),
shift=repr(self.shift),
button=repr(self.button),
buttons=repr(self.buttons),
)
@property
def alt(self):
"""
Whether alt key pressed
Returns
-------
bool
"""
return self._alt
@property
def ctrl(self):
"""
Whether ctrl key pressed
Returns
-------
bool
"""
return self._ctrl
@property
def shift(self):
"""
Whether shift key pressed
Returns
-------
bool
"""
return self._shift
@property
def meta(self):
"""
Whether meta key pressed
Returns
-------
bool
"""
return self._meta
@property
def button(self):
"""
Integer code for the button that was pressed on the mouse to trigger
the event
- 0: Main button pressed, usually the left button or the
un-initialized state
- 1: Auxiliary button pressed, usually the wheel button or the middle
button (if present)
- 2: Secondary button pressed, usually the right button
- 3: Fourth button, typically the Browser Back button
- 4: Fifth button, typically the Browser Forward button
Returns
-------
int
"""
return self._button
@property
def buttons(self):
"""
Integer code for which combination of buttons are pressed on the
mouse when the event is triggered.
- 0: No button or un-initialized
- 1: Primary button (usually left)
- 2: Secondary button (usually right)
- 4: Auxilary button (usually middle or mouse wheel button)
- 8: 4th button (typically the "Browser Back" button)
- 16: 5th button (typically the "Browser Forward" button)
Combinations of buttons are represented as the decimal form of the
bitmask of the values above.
For example, pressing both the primary (1) and auxilary (4) buttons
will result in a code of 5
Returns
-------
int
"""
return self._buttons
class Points:
def __init__(self, point_inds=[], xs=[], ys=[], trace_name=None, trace_index=None):
self._point_inds = point_inds
self._xs = xs
self._ys = ys
self._trace_name = trace_name
self._trace_index = trace_index
def __repr__(self):
return """\
Points(point_inds={point_inds},
xs={xs},
ys={ys},
trace_name={trace_name},
trace_index={trace_index})""".format(
point_inds=_list_repr_elided(
self.point_inds, indent=len("Points(point_inds=")
),
xs=_list_repr_elided(self.xs, indent=len(" xs=")),
ys=_list_repr_elided(self.ys, indent=len(" ys=")),
trace_name=repr(self.trace_name),
trace_index=repr(self.trace_index),
)
@property
def point_inds(self):
"""
List of selected indexes into the trace's points
Returns
-------
list[int]
"""
return self._point_inds
@property
def xs(self):
"""
List of x-coordinates of selected points
Returns
-------
list[float]
"""
return self._xs
@property
def ys(self):
"""
List of y-coordinates of selected points
Returns
-------
list[float]
"""
return self._ys
@property
def trace_name(self):
"""
Name of the trace
Returns
-------
str
"""
return self._trace_name
@property
def trace_index(self):
"""
Index of the trace in the figure
Returns
-------
int
"""
return self._trace_index
class BoxSelector:
def __init__(self, xrange=None, yrange=None, **_):
self._type = "box"
self._xrange = xrange
self._yrange = yrange
def __repr__(self):
return """\
BoxSelector(xrange={xrange},
yrange={yrange})""".format(xrange=self.xrange, yrange=self.yrange)
@property
def type(self):
"""
The selector's type
Returns
-------
str
"""
return self._type
@property
def xrange(self):
"""
x-axis range extents of the box selection
Returns
-------
(float, float)
"""
return self._xrange
@property
def yrange(self):
"""
y-axis range extents of the box selection
Returns
-------
(float, float)
"""
return self._yrange
class LassoSelector:
def __init__(self, xs=None, ys=None, **_):
self._type = "lasso"
self._xs = xs
self._ys = ys
def __repr__(self):
return """\
LassoSelector(xs={xs},
ys={ys})""".format(
xs=_list_repr_elided(self.xs, indent=len("LassoSelector(xs=")),
ys=_list_repr_elided(self.ys, indent=len(" ys=")),
)
@property
def type(self):
"""
The selector's type
Returns
-------
str
"""
return self._type
@property
def xs(self):
"""
list of x-axis coordinates of each point in the lasso selection
boundary
Returns
-------
list[float]
"""
return self._xs
@property
def ys(self):
"""
list of y-axis coordinates of each point in the lasso selection
boundary
Returns
-------
list[float]
"""
return self._ys
|