Пример #1
0
 def zoomAround(self, plt, objects, expansion=2):
     """Zoom the schematic around the specified objects"""
     positions = (self.langToMapCoords(obj.position) for obj in objects)
     x, y = zip(*positions)
     minx, maxx = findMinMax(x)
     miny, maxy = findMinMax(y)
     sx = expansion * (maxx - minx)
     sy = expansion * (maxy - miny)
     s = max(sx, sy, self.minimumZoomSize) / 2.0
     s += max(max(obj.width, obj.height) for obj in objects)  # TODO improve
     cx = (maxx + minx) / 2.0
     cy = (maxy + miny) / 2.0
     plt.xlim(cx - s, cx + s)
     plt.ylim(cy - s, cy + s)
Пример #2
0
 def zoomAround(self, plt, objects, expansion=1):
     """Zoom the schematic around the specified objects"""
     if not objects:
         return
     positions = (self.scenicToSchematicCoords(obj.position)
                  for obj in objects)
     x, y = zip(*positions)
     minx, maxx = findMinMax(x)
     miny, maxy = findMinMax(y)
     sx = expansion * max(self.minimumZoomSize, 2 * (maxx - minx))
     sy = expansion * max(self.minimumZoomSize, 2 * (maxy - miny))
     s = max(sx, sy) / 2.0
     s += max(max(obj.width, obj.length) for obj in objects)  # TODO improve
     cx = (maxx + minx) / 2.0
     cy = (maxy + miny) / 2.0
     plt.xlim(cx - s, cx + s)
     plt.ylim(cy - s, cy + s)
Пример #3
0
 def containsObject(self, obj):
     # TODO improve this procedure!
     # Fast check
     for c in obj.corners:
         if not self.containsPoint(c):
             return False
     # Slow check
     gps = [self.pointToGrid(corner) for corner in obj.corners]
     x, y = zip(*gps)
     minx, maxx = findMinMax(x)
     miny, maxy = findMinMax(y)
     for x in range(minx, maxx + 1):
         for y in range(miny, maxy + 1):
             p = self.gridToPoint((x, y))
             if self.grid[y, x] == 1 and obj.containsPoint(p):
                 return False
     return True
Пример #4
0
 def getAABB(self):
     xmin, xmax = findMinMax(p[0] for p in self.points)
     ymin, ymax = findMinMax(p[1] for p in self.points)
     return ((xmin, ymin), (xmax, ymax))
Пример #5
0
 def getAABB(self):
     x, y = zip(*self.corners)
     minx, maxx = findMinMax(x)
     miny, maxy = findMinMax(y)
     return ((minx, miny), (maxx, maxy))