/usr/share/tpclient-pywx/extra/wxFloatCanvas/ArcObject.py is in tpclient-pywx 0.3.1.1-3.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | #!/usr/bin/env python
"""
A FloatCanvas arc Object, and a test for it
"""
from FloatCanvas import *
import numpy as N
# define the new Object:
class ArcPoint(XYObjectMixin, LineAndFillMixin, DrawObject):
def __init__(self,
StartXY,
EndXY,
CenterXY,
LineColor = "Black",
LineStyle = "Solid",
LineWidth = 1,
FillColor = None,
FillStyle = "Solid",
InForeground = False):
"""
ArcPoint(self, Point StartXY, Point EndXY, Point CenterXY)
Draws an arc of a circle, centered on point CenterXY, from
the first point (StartXY) to the second (EndXY).
The arc is drawn in an anticlockwise direction from the start point to
the end point.
"""
DrawObject.__init__(self, InForeground)
# There is probably a more elegant way to do this next section
# The bounding box just gets set to the WH of a circle, with center at CenterXY
# This is suitable for a pie chart as it will be a circle anyway
radius = N.sqrt( (StartXY[0]-CenterXY[0])**2 + (StartXY[1]-CenterXY[1])**2 )
minX = CenterXY[0]-radius
minY = CenterXY[1]-radius
maxX = CenterXY[0]+radius
maxY = CenterXY[1]+radius
XY = [minX,minY]
WH = [maxX-minX,maxY-minY]
self.XY = N.asarray( XY, N.float).reshape((2,))
self.WH = N.asarray( WH, N.float).reshape((2,))
self.StartXY = N.asarray(StartXY, N.float).reshape((2,))
self.CenterXY = N.asarray(CenterXY, N.float).reshape((2,))
self.EndXY = N.asarray(EndXY, N.float).reshape((2,))
#self.BoundingBox = array((self.XY, (self.XY + self.WH)), Float)
self.CalcBoundingBox()
#Finish the setup; allocate color,style etc.
self.LineColor = LineColor
self.LineStyle = LineStyle
self.LineWidth = LineWidth
self.FillColor = FillColor
self.FillStyle = FillStyle
self.HitLineWidth = max(LineWidth,self.MinHitLineWidth)
self.SetPen(LineColor, LineStyle, LineWidth)
self.SetBrush(FillColor, FillStyle) #Why isn't this working ???
def _Draw(self, dc , WorldToPixel, ScaleWorldToPixel, HTdc=None):
self.SetUpDraw(dc , WorldToPixel, ScaleWorldToPixel, HTdc)
StartXY = WorldToPixel(self.StartXY)
EndXY = WorldToPixel(self.EndXY)
CenterXY = WorldToPixel(self.CenterXY)
dc.DrawArcPoint(StartXY, EndXY, CenterXY)
if HTdc and self.HitAble:
HTdc.DrawArcPoint(StartXY, EndXY, CenterXY)
def CalcBoundingBox(self):
self.BoundingBox = N.array((self.XY, (self.XY + self.WH) ), N.float)
#self._Canvas.BoundingBoxDirty = True #um set an error ?
if self._Canvas:
self._Canvas.BoundingBoxDirty = True
class ArcPoint2(XYObjectMixin, LineAndFillMixin, DrawObject):
def __init__(self,
StartXY,
EndXY,
CenterXY,
LineColor = "Black",
LineStyle = "Solid",
LineWidth = 1,
FillColor = None,
FillStyle = "Solid",
InForeground = False):
"""
This is a non-resizing
ArcPoint(self, Point StartXY, Point EndXY, Point CenterXY)
Draws an arc of a circle, centered on point CenterXY, from
the first point (StartXY) to the second (EndXY).
The arc is drawn in an anticlockwise direction from the start point to
the end point.
"""
DrawObject.__init__(self, InForeground)
# There is probably a more elegant way to do this next section
# The bounding box just gets set to the WH of a circle, with center at CenterXY
# This is suitable for a pie chart as it will be a circle anyway
# FIXME: This doesn't work correctly...
radius = N.sqrt( (StartXY[0]-CenterXY[0])**2 + (StartXY[1]-CenterXY[1])**2 )
minX = CenterXY[0]-radius
minY = CenterXY[1]-radius
maxX = CenterXY[0]+radius
maxY = CenterXY[1]+radius
XY = [minX,minY]
WH = [maxX-minX,maxY-minY]
self.XY = N.asarray( XY, N.float).reshape((2,))
self.WH = N.asarray( WH, N.float).reshape((2,))
self.StartXY = N.asarray(StartXY, N.float).reshape((2,))
self.CenterXY = N.asarray(CenterXY, N.float).reshape((2,))
self.EndXY = N.asarray(EndXY, N.float).reshape((2,))
#self.BoundingBox = array((self.XY, (self.XY + self.WH)), Float)
self.CalcBoundingBox()
#Finish the setup; allocate color,style etc.
self.LineColor = LineColor
self.LineStyle = LineStyle
self.LineWidth = LineWidth
self.FillColor = FillColor
self.FillStyle = FillStyle
self.HitLineWidth = max(LineWidth,self.MinHitLineWidth)
self.SetPen(LineColor, LineStyle, LineWidth)
self.SetBrush(FillColor, FillStyle) #Why isn't this working ???
def _Draw(self, dc , WorldToPixel, ScaleWorldToPixel, HTdc=None):
self.SetUpDraw(dc , WorldToPixel, ScaleWorldToPixel, HTdc)
CenterXY = WorldToPixel(self.CenterXY)
StartXY = self.StartXY+CenterXY
EndXY = self.EndXY +CenterXY
dc.DrawArcPoint(StartXY, EndXY, CenterXY)
if HTdc and self.HitAble:
HTdc.DrawArcPoint(StartXY, EndXY, CenterXY)
|