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
|
#
# Copyright (c) 2002, 2003, 2004, 2005, 2006 Art Haas
#
# This file is part of PythonCAD.
#
# PythonCAD is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# PythonCAD is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with PythonCAD; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#
# construction line/circle base class
#
# These variables provide the defaults for
# the construction line style attributes
#
from PythonCAD.Generic import graphicobject
from PythonCAD.Generic import style
from PythonCAD.Generic import linetype
from PythonCAD.Generic import color
from PythonCAD.Generic import tolerance
from PythonCAD.Generic import point
class ConstructionObject(graphicobject.GraphicObject):
"""A base class for construction lines and circles.
This class is meant to provide the most basic bits for
construction lines and circles. All construction lines
and circles will share a common Style object style, meaning
all instances will be drawn with the same linetype, have
the same color, and be the same thickness. Construction
entities should never be plotted out, however.
"""
# static class variables
__defstyle = None
def __init__(self, **kw):
super(ConstructionObject, self).__init__(ConstructionObject.__defstyle, **kw)
def getDefaultStyle(cls):
if cls.__defstyle is None:
_s = style.Style(u'Default Construction Object Style',
linetype.Linetype(u'Construction Line', [2,2]),
color.Color(255, 0, 0),
0.0)
cls.__defstyle = _s
return cls.__defstyle
getDefaultStyle = classmethod(getDefaultStyle)
def setDefaultStyle(cls, s):
if not isinstance(s, style.Style):
raise TypeError, "Invalid style: " + `type(s)`
cls.__defstyle = s
setDefaultStyle = classmethod(setDefaultStyle)
def finish(self):
super(ConstructionObject, self).finish()
def getStyle(self):
return self.getDefaultStyle()
def setStyle(self, s):
pass
def getColor(self):
return self.getDefaultStyle().getColor()
def setColor(self, c):
pass
def getLinetype(self):
return self.getDefaultStyle().getLinetype()
def setLinetype(self, l):
pass
def getThickness(self):
return self.getDefaultStyle().getThickness()
def setThickness(self, t):
pass
#
# ConstructionObject history class
#
class ConstructionObjectLog(graphicobject.GraphicObjectLog):
def __init__(self, obj):
if not isinstance(obj, ConstructionObject):
raise TypeError, "Invalid ConstructionObject: " + `obj`
super(ConstructionObjectLog, self).__init__(obj)
|