[Zope3-checkins] CVS: zopeproducts/pypgsqlda/interfaces - geometric.py:1.3.2.1
Christian 'Tiran' Heimes
heimes@faho.rwth-aachen.de
Thu, 20 Mar 2003 05:31:32 -0500
Update of /cvs-repository/zopeproducts/pypgsqlda/interfaces
In directory cvs.zope.org:/tmp/cvs-serv27638/interfaces
Modified Files:
Tag: tiran-pypgsql_types-branch
geometric.py
Log Message:
changed to 2d and 3d objects
=== zopeproducts/pypgsqlda/interfaces/geometric.py 1.3 => 1.3.2.1 ===
--- zopeproducts/pypgsqlda/interfaces/geometric.py:1.3 Wed Mar 19 05:16:03 2003
+++ zopeproducts/pypgsqlda/interfaces/geometric.py Thu Mar 20 05:31:30 2003
@@ -16,14 +16,73 @@
$Id$
"""
-from zope.interface import Interface, Attribute
+from zope.interface import Interface, Attribute
+
+class IGeometricInfinite(Interface):
+ """Represents an infinite geometric object
+ """
+ pass
+
+class IGeometric2d(Interface):
+ """A 2d geometric object"""
+ isClosed = Attribute("Is this object closed, e.g. a box or polygon")
+ isOpen = Attribute("Is this object open, e.g. a path or line")
+ coord = Attribute("x/y coordinates")
+ length = Attribute("Lenght of a line or circumference of a box")
+
+ def getClosed():
+ """
+ """
+
+ def getOpen():
+ """
+ """
+
+ def getLength():
+ """
+ """
+
+ def getCoord():
+ """Gets x/y coordinate as tuple of floats
+ """
+
+ def setCoord(x, y = None):
+ """Sets x/y coordinate
+
+ The first argument can be:
+ * a number, y must be given as number, too
+ * a tuple with two elements
+ * a list with two elements
+ * a dictionary with two keys named 'x' and 'y'
+ * a string '(x,y)' or '(x/y)'
+ """
+
+ def __str__():
+ """Prints coordinates
+ """
+
+class IGeometric3d(IGeometric2d):
+ """A 3d geometric object"""
+ coord = Attribute("x/y/z coordinates")
+ volume = Attribute("volume of the object")
+
+
+class IShape2d(IGeometric2d):
+ """An abstract interface for geometric shapes."""
+
+ area = Attribute("area of the shape as float (ro)")
+
+ def getArea():
+ """Return size of containing area
+
+ Must be overwritten by shape
+ """
-class IPoint(Interface):
+class IPoint2d(IGeometric2d):
"""A 2 dimensional point in cartesian representation."""
x = Attribute("x coordinate as float")
y = Attribute("y coordinate as float")
- coord = Attribute("x/y as tuple, input may be more")
def getX():
"""Gets x coordinate
@@ -41,80 +100,8 @@
"""Sets y coordinate
"""
- def getCoord():
- """Gets x/y coordinate as tuple of floats
- """
-
- def setCoord(x, y = None):
- """Sets x/y coordinate
-
- The first argument can be:
- * a number, y must be given as number, too
- * a tuple with two elements
- * a list with two elements
- * a dictionary with two keys named 'x' and 'y'
- * a string '(x,y)' or '(x/y)'
- """
-
- def __str__():
- """Prints coordinate as '(x,y)'
- """
-
- def __len__():
- """Distance from 0/0
-
- Return distance from 0/0 in euclidic norm:
-
- sqrt(x**2 + y**2)
-
- """
-
- def __cmp__(other):
- """Compare point with other points or length
-
- * Compare distance from 0/0 if other is a number
- * Compare distance using __len__() if other is a point
- """
-
- def __rcmp__(other):
- """See __cmp__
- """
-
-class IShape(Interface):
- """An abstract interface for geometric shapes."""
-
- area = Attribute("area of the shape as float (ro)")
- circumference = Attribute("circumference of the shape as float (ro)")
-
- def getArea():
- """Return size of containing area
-
- Must be overwritten by shape
- """
-
- def getCircumference():
- """Return lenght of circumference
-
- Must be overwritten by shape
- """
-
- def __len__():
- """Return area as size of shape
- """
-
- def __cmp__(other):
- """compare area to number or other shape
- """
-
- def _rcmp__(other):
- """
- """
-
- def __str__():
- """
- """
-class ICircle(IShape):
+class ICircle2d(IShape2d):
"""A circle. It is represented as a center point and a radius."""
center = Attribute("center as point coordinate")
@@ -135,15 +122,23 @@
def setRadius():
"""
+ """
+
+ def getCircle():
+ """
+ """
+
+ def setCircle():
+ """
"""
-class IBox(IShape):
+class IBox2d(IShape2d):
upperRight = Attribute("Upper right point of the box as point coordinate")
lowerLeft = Attribute("Lower left point of the box as point coordinate")
corners = Attribute("upper right and lower left point together")
-class IPath(Interface):
+class IPath2d(IGeometric2d):
"""A path is an ordered set of points. A path can be closed, which means
that the end point is connected to the start point. A special kind of
path is the line, which only has to points and is open."""