def create_collection(self):
        collection = CPolylineCollection()
        p1 = CPolyline( name = "POLY1" , init_points = [(0,10) , (1,11) , (2,12)])
        p2 = CPolyline( name = "POLY2" , init_points = [(0,100) , (10,110) , (20,120)])
        collection.addPolyline( p1 )
        collection.addPolyline( p2 )

        tail  = p1[-1]
        self.assertEqual( tail , (2,12))
        self.assertEqual(p1.getName() , "POLY1")
        
        tail  = p2[-1]
        self.assertEqual( tail , (20,120))
        self.assertEqual(p2.getName() , "POLY2")
        
        return collection
示例#2
0
    def create_collection(self):
        collection = CPolylineCollection()
        p1 = CPolyline( name = "POLY1" , init_points = [(0,10) , (1,11) , (2,12)])
        p2 = CPolyline( name = "POLY2" , init_points = [(0,100) , (10,110) , (20,120)])
        collection.addPolyline( p1 )
        collection.addPolyline( p2 )

        tail  = p1[-1]
        self.assertEqual( tail , (2,12))
        self.assertEqual(p1.getName() , "POLY1")
        
        tail  = p2[-1]
        self.assertEqual( tail , (20,120))
        self.assertEqual(p2.getName() , "POLY2")
        
        return collection
示例#3
0
    def addPolyline(self , polyline , name = None):
        if not isinstance(polyline , CPolyline):
            polyline = CPolyline( init_points = polyline , name = name)
        else:
            if not name is None:
                raise ValueError("The name keyword argument can only be supplied when add not CPOlyline object")

        name = polyline.getName()
        if name and name in self:
            raise KeyError("The polyline collection already has an object:%s" % name)

        if polyline.isReference():
            self._add_polyline( polyline , False)
        else:
            polyline.convertToCReference( self )
            self._add_polyline( polyline , True)
示例#4
0
    def addPolyline(self, polyline, name=None):
        if not isinstance(polyline, CPolyline):
            polyline = CPolyline(init_points=polyline, name=name)
        else:
            if not name is None:
                raise ValueError(
                    "The name keyword argument can only be supplied when add not CPOlyline object"
                )

        name = polyline.getName()
        if name and name in self:
            raise KeyError("The polyline collection already has an object:%s" %
                           name)

        if polyline.isReference():
            self._add_polyline(polyline, False)
        else:
            polyline.convertToCReference(self)
            self._add_polyline(polyline, True)
示例#5
0
    def test_name(self):
        p1 = CPolyline()
        self.assertTrue(p1.getName() is None)

        p2 = CPolyline(name="Poly2")
        self.assertEqual(p2.getName(), "Poly2")
示例#6
0
    def test_name(self):
        p1 = CPolyline()
        self.assertTrue( p1.getName() is None )

        p2 = CPolyline( name = "Poly2" )
        self.assertEqual( p2.getName() , "Poly2")