Changeset 3247
- Timestamp:
- 07/13/07 05:49:56 (1 year ago)
- Files:
-
- trunk/dabo/ui/uiwx/dPemMixin.py (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/dabo/ui/uiwx/dPemMixin.py
r3244 r3247 1242 1242 1243 1243 def drawCircle(self, xPos, yPos, rad, penColor="black", penWidth=1, 1244 fillColor=None, lineStyle=None, hatchStyle=None, mode=None, 1244 fillColor=None, lineStyle=None, hatchStyle=None, mode=None, 1245 1245 persist=True): 1246 1246 """Draws a circle of the specified radius around the specified point. 1247 1247 1248 You can set the color and thickness of the line, as well as the 1249 color and hatching style of the fill. Normally, when persist=True, 1250 the circle will be re-drawn on paint events, but if you pass False, 1248 You can set the color and thickness of the line, as well as the 1249 color and hatching style of the fill. Normally, when persist=True, 1250 the circle will be re-drawn on paint events, but if you pass False, 1251 1251 it will be drawn once only. 1252 1253 A drawing object is returned, or None if persist=False. You can 1254 'remove' the drawing by setting the Visible property of the 1252 1253 A drawing object is returned, or None if persist=False. You can 1254 'remove' the drawing by setting the Visible property of the 1255 1255 returned object to False. You can also manipulate the position, size, 1256 1256 color, and fill by changing the various properties of the object. … … 1262 1262 obj = self._addToDrawnObjects(obj, persist) 1263 1263 return obj 1264 1265 1266 def draw Rectangle(self, xPos, yPos, width, height, penColor="black",1264 1265 1266 def drawArc(self, xPos, yPos, rad, startAngle, endAngle, penColor="black", 1267 1267 penWidth=1, fillColor=None, lineStyle=None, hatchStyle=None, 1268 1268 mode=None, persist=True): 1269 """Draws a rectangle of the specified size beginning at the specified 1270 point. 1269 """Draws an arc (pie slice) of a circle centered around the specified point, 1270 starting from 'startAngle' degrees, and sweeping counter-clockwise 1271 until 'endAngle' is reached. 1271 1272 1272 1273 See the 'drawCircle()' method above for more details. 1273 1274 """ 1274 1275 obj = DrawObject(self, FillColor=fillColor, PenColor=penColor, 1275 PenWidth=penWidth, LineStyle=lineStyle, HatchStyle=hatchStyle, 1276 Shape="rect", Xpos=xPos, Ypos=yPos, Width=width, Height=height, 1276 PenWidth=penWidth, Radius=rad, StartAngle=startAngle, 1277 EndAngle=endAngle, LineStyle=lineStyle, HatchStyle=hatchStyle, 1278 Shape="arc", Xpos=xPos, Ypos=yPos, DrawMode=mode) 1279 # Add it to the list of drawing objects 1280 obj = self._addToDrawnObjects(obj, persist) 1281 return obj 1282 1283 1284 def drawEllipse(self, xPos, yPos, width, height, penColor="black", 1285 penWidth=1, fillColor=None, lineStyle=None, hatchStyle=None, 1286 mode=None, persist=True): 1287 """Draws an ellipse contained within the rectangular space defined by 1288 the position and size coordinates 1289 1290 See the 'drawCircle()' method above for more details. 1291 """ 1292 obj = DrawObject(self, FillColor=fillColor, PenColor=penColor, 1293 PenWidth=penWidth, LineStyle=lineStyle, HatchStyle=hatchStyle, 1294 Shape="ellipse", Xpos=xPos, Ypos=yPos, Width=width, Height=height, 1277 1295 DrawMode=mode) 1278 1296 # Add it to the list of drawing objects … … 1281 1299 1282 1300 1283 def drawPolygon(self, points, penColor="black", penWidth=1, 1284 fillColor=None, lineStyle=None, hatchStyle=None, 1301 def drawEllipticArc(self, xPos, yPos, width, height, startAngle, endAngle, 1302 penColor="black", penWidth=1, fillColor=None, lineStyle=None, 1303 hatchStyle=None, mode=None, persist=True): 1304 """Draws an arc (pie slice) of a ellipse contained by the specified 1305 dimensions, starting from 'startAngle' degrees, and sweeping 1306 counter-clockwise until 'endAngle' is reached. 1307 1308 See the 'drawCircle()' method above for more details. 1309 """ 1310 obj = DrawObject(self, FillColor=fillColor, PenColor=penColor, 1311 PenWidth=penWidth, StartAngle=startAngle, 1312 EndAngle=endAngle, LineStyle=lineStyle, HatchStyle=hatchStyle, 1313 Shape="ellipticarc", Xpos=xPos, Ypos=yPos, Width=width, 1314 Height=height, DrawMode=mode) 1315 # Add it to the list of drawing objects 1316 obj = self._addToDrawnObjects(obj, persist) 1317 return obj 1318 1319 1320 def drawRectangle(self, xPos, yPos, width, height, penColor="black", 1321 penWidth=1, fillColor=None, lineStyle=None, hatchStyle=None, 1322 mode=None, persist=True): 1323 """Draws a rectangle of the specified size beginning at the specified 1324 point. 1325 1326 See the 'drawCircle()' method above for more details. 1327 """ 1328 obj = DrawObject(self, FillColor=fillColor, PenColor=penColor, 1329 PenWidth=penWidth, LineStyle=lineStyle, HatchStyle=hatchStyle, 1330 Shape="rect", Xpos=xPos, Ypos=yPos, Width=width, Height=height, 1331 DrawMode=mode) 1332 # Add it to the list of drawing objects 1333 obj = self._addToDrawnObjects(obj, persist) 1334 return obj 1335 1336 1337 def drawPolygon(self, points, penColor="black", penWidth=1, 1338 fillColor=None, lineStyle=None, hatchStyle=None, 1285 1339 mode=None, persist=True): 1286 1340 """Draws a polygon defined by the specified points. 1287 1341 1288 The 'points' parameter should be a tuple of (x,y) pairs defining the 1342 The 'points' parameter should be a tuple of (x,y) pairs defining the 1289 1343 polygon. 1290 1344 … … 1299 1353 1300 1354 1301 def drawPolyLines(self, points, penColor="black", penWidth=1, 1355 def drawPolyLines(self, points, penColor="black", penWidth=1, 1302 1356 lineStyle=None, mode=None, persist=True): 1303 1357 """Draws a series of connected line segments defined by the specified points. … … 1305 1359 The 'points' parameter should be a tuple of (x,y) pairs defining the shape. Lines 1306 1360 are drawn connecting the points sequentially, but a segment from the last 1307 point to the first is not drawn, leaving an 'open' polygon. As a result, there is no 1361 point to the first is not drawn, leaving an 'open' polygon. As a result, there is no 1308 1362 FillColor or HatchStyle defined for this. 1309 1363 1310 1364 See the 'drawCircle()' method above for more details. 1311 1365 """ 1312 obj = DrawObject(self, PenColor=penColor, PenWidth=penWidth, LineStyle=lineStyle, 1366 obj = DrawObject(self, PenColor=penColor, PenWidth=penWidth, LineStyle=lineStyle, 1313 1367 Shape="polylines", Points=points, DrawMode=mode) 1314 1368 # Add it to the list of drawing objects … … 2581 2635 self._points = None 2582 2636 self._radius = None 2637 self._startAngle = None 2638 self._endAngle = None 2583 2639 self._shape = None 2584 2640 self._visible = True … … 2715 2771 dc.DrawCircle(x, y, self.Radius) 2716 2772 self._width = self._height = self.Radius * 2 2717 elif self.Shape == "rect": 2773 elif self.Shape == "arc": 2774 xc, yc = self.Xpos, self.Ypos 2775 x1 = xc + (math.cos(math.radians(self.StartAngle)) * self.Radius) 2776 y1 = yc - (math.sin(math.radians(self.StartAngle)) * self.Radius) 2777 x2 = xc + (math.cos(math.radians(self.EndAngle)) * self.Radius) 2778 y2 = yc - (math.sin(math.radians(self.EndAngle)) * self.Radius) 2779 dc.DrawArc(x1, y1, x2, y2, xc, yc) 2780 elif self.Shape == "ellipticarc": 2781 dc.DrawEllipticArc(self.Xpos, self.Ypos, self.Width, self.Height, self.StartAngle, self.EndAngle) 2782 elif self.Shape in ("rect", "ellipse"): 2718 2783 w, h = self.Width, self.Height 2719 2784 # If any of these values is -1, use the parent object's size … … 2722 2787 if h < 0: 2723 2788 h = self.Parent.Height 2724 dc.DrawRectangle(x, y, w, h) 2789 if self.Shape == "rect": 2790 dc.DrawRectangle(x, y, w, h) 2791 else: 2792 dc.DrawEllipse(x, y, w, h) 2725 2793 elif self.Shape in ("polygon", "polylines"): 2726 2794 if self.Shape == "polygon": … … 2910 2978 2911 2979 2980 def _getEndAngle(self): 2981 return self._endAngle 2982 2983 def _setEndAngle(self, val): 2984 if self._endAngle != val: 2985 self._endAngle = val 2986 self.update() 2987 2988 2912 2989 def _getFillColor(self): 2913 2990 return self._fillColor … … 3134 3211 3135 3212 3213 def _getStartAngle(self): 3214 return self._startAngle 3215 3216 def _setStartAngle(self, val): 3217 if self._startAngle != val: 3218 self._startAngle = val 3219 self.update() 3220 3221 3136 3222 def _getText(self): 3137 3223 return self._text … … 3185 3271 3186 3272 Angle = property(_getAngle, _setAngle, None, 3187 _("Angle to draw text (int)"))3273 _("Angle (in degrees) to draw text (int)")) 3188 3274 3189 3275 BackColor = property(_getBackColor, _setBackColor, None, … … 3213 3299 """)) 3214 3300 3301 EndAngle = property(_getEndAngle, _setEndAngle, None, 3302 _("Angle (in degrees) used to end drawing a circular arc (int)")) 3303 3215 3304 FillColor = property(_getFillColor, _setFillColor, None, 3216 3305 _("Background color for the shape (color)")) … … 3289 3378 _("Type of shape to draw (str)")) 3290 3379 3380 StartAngle = property(_getStartAngle, _setStartAngle, None, 3381 _("Angle (in degrees) used to start drawing a circular arc (int)")) 3382 3291 3383 Text = property(_getText, _setText, None, 3292 3384 _("Text to be drawn (str)"))
