Пример #1
0
    def _init_primitives_trans(self):
        self.init_primitives()  # must be implemented in every subclass
        dr_origin = DSimplePolygon([DPoint(0, 0)])
        if (self.DCplxTrans_init is not None):
            # constructor trans displacement
            dCplxTrans_temp = DCplxTrans(1, 0, False,
                                         self.DCplxTrans_init.disp)
            for element in self.primitives.values():
                element.make_trans(dCplxTrans_temp)
            dr_origin.transform(dCplxTrans_temp)
            self._update_connections(dCplxTrans_temp)
            self._update_alpha(dCplxTrans_temp)

            # rest of the constructor trans functions
            dCplxTrans_temp = self.DCplxTrans_init.dup()
            dCplxTrans_temp.disp = DPoint(0, 0)
            for element in self.primitives.values():
                element.make_trans(dCplxTrans_temp)
            dr_origin.transform(dCplxTrans_temp)
            self._update_connections(dCplxTrans_temp)
            self._update_alpha(dCplxTrans_temp)

        dCplxTrans_temp = DCplxTrans(1, 0, False, self.origin)
        for element in self.primitives.values():
            element.make_trans(dCplxTrans_temp)  # move to the origin
        self._update_connections(dCplxTrans_temp)
        self._update_alpha(dCplxTrans_temp)
        self.origin += dr_origin.point(0)

        # FOLLOWING CYCLE GIVES WRONG INFO ABOUT FILLED AND ERASED AREAS
        for element in self.primitives.values():
            self.metal_region += element.metal_region
            self.empty_region += element.empty_region
 def _update_alpha( self, dCplxTrans ):
     if( dCplxTrans is not None ):
         dCplxTrans_temp = dCplxTrans.dup()
         dCplxTrans_temp.disp = DPoint(0,0)
         
         for i,alpha in enumerate(self.angle_connections):
             poly_temp = DSimplePolygon( [DPoint( cos(alpha), sin(alpha) )] )
             poly_temp.transform( dCplxTrans_temp )
             pt = poly_temp.point( 0 )
             self.angle_connections[i] = atan2( pt.y, pt.x )
 def _update_connections( self, dCplxTrans ):       
     if( dCplxTrans is not None ):
         # the problem is, if k construct polygon with multiple points
         # their order in poly_temp.each_point() doesn't coinside with the 
         # order of the list that was passed to the polygon constructor
         # so, when k perform transformation and try to read new values through poly_temp.each_point()
         # they values are rearranged
         # solution is: k need to create polygon for each point personally, and the initial order presists
         for i,pt in enumerate(self.connections):
             poly_temp = DSimplePolygon( [pt] )
             poly_temp.transform( dCplxTrans )
             self.connections[i] = poly_temp.point( 0 )
 def _init_regions_trans( self ):
     self.init_regions()         # must be implemented in every subclass
     dr_origin = DSimplePolygon( [DPoint(0,0)] )
     if( self.DCplxTrans_init is not None ):
         # constructor trans displacement
         dCplxTrans_temp = DCplxTrans( 1,0,False, self.DCplxTrans_init.disp )
         self.make_trans( dCplxTrans_temp )
         dr_origin.transform( dCplxTrans_temp )
         
         # rest of the constructor trans functions
         dCplxTrans_temp = self.DCplxTrans_init.dup()
         dCplxTrans_temp.disp = DPoint(0,0)
         self.make_trans( dCplxTrans_temp )
         dr_origin.transform( dCplxTrans_temp )                  
         
     # translation to the old origin (self.connections are alredy contain proper values)
     self.make_trans( DCplxTrans( 1,0,False, self.origin ) ) # move to the origin
     self.origin += dr_origin.point( 0 )
 def _update_origin( self, dCplxTrans ):
     if( dCplxTrans is not None ):     
         poly_temp = DSimplePolygon( [self.origin] )
         poly_temp.transform( dCplxTrans )
         self.origin = poly_temp.point( 0 )