コード例 #1
0
    def getGridsCutByWidthBrandColor(self,
                                     width=100,
                                     brand='kokos',
                                     color='naturel'):
        grids = []
        query = {}
        if brand != 'all':
            query["brand"] = brand
        if color != 'all':
            query["color"] = color
        if grid_width != 'all':
            query["grid_width"] = grid_width

        cursor = self.grids_collection.find(query)
        for document in cursor:
            grid = Grid(width=document['width'],
                        height=document['height'],
                        article_name=document['article_name'],
                        material=document['material'],
                        brand=document['brand'],
                        color=document['color'],
                        name=document['name'],
                        is_cut=document['isCut'])
            rectangles = self.getRectangles(grid)
            grid.setStackedRectangles(rectangles)

            if grid.isCut():
                print("Loaded grid " + str(document["name"]) +
                      " from database")

                grids.append(grid)

        return grids
コード例 #2
0
    def getGridsNotCut(self, sort=False):
        grids = []

        cursor = self.grids_collection.find({})
        for document in cursor:
            print("getGridsNotCut material = " + str(document['material']))
            grid = Grid(width=document['width'],
                        height=document['height'],
                        name=document['name'],
                        article_name=document['article_name'],
                        material=document['material'],
                        color=document['color'],
                        brand=document['brand'],
                        is_cut=document['isCut'])
            rectangles = self.getRectangles(grid)
            grid.setStackedRectangles(rectangles)

            if not grid.isCut():
                print("Loaded grid " + str(document["name"]) +
                      " from database")
                grids.append(grid)

        if sort == True:
            grids = sorted(grids, key=lambda g: g.getWidth(), reverse=True)

        print("Grid widths are " + str([grid.getWidth() for grid in grids]))
        print("Grid heights are " + str([grid.getHeight() for grid in grids]))

        return grids
コード例 #3
0
    def getGridsCut(self):
        grids = []

        cursor = self.grids_collection.find({})
        for document in cursor:
            grid = Grid(width=document['width'],
                        height=document['height'],
                        brand=document['brand'],
                        article_name=document['article_name'],
                        material=document['material'],
                        color=document['color'],
                        name=document['name'],
                        is_cut=document['isCut'])
            rectangles = self.getRectangles(grid)
            grid.setStackedRectangles(rectangles)

            if grid.isCut():
                print("Loaded grid " + str(document["name"]) +
                      " from database")

                grids.append(grid)

        return grids