def add_label(self, woodpiece): self.labels.append( { 'id': woodpiece.id, 'label': woodpiece.label, 'material': woodpiece.material, 'thickness': carpentryfractions.measurable_fraction(woodpiece.thickness), 'length': carpentryfractions.measurable_fraction(woodpiece.length), 'width': carpentryfractions.measurable_fraction(woodpiece.width), 'comments': woodpiece.comments, } )
def build_raphael(self): if len(self.shelves) > 0: div_padding = 1.1 scale_factor = 10 x_axis_offset = 10 # Main Container raphael_script_text = "var paper_{0}_{1} = new Raphael(document.getElementById('cutlist_canvas_container_{0}_{1}'), {2}, {3});\n".format( self.set_id, self.id, (self.length + x_axis_offset) * scale_factor * div_padding, self.height * scale_factor * div_padding ) # Sheet Representation raphael_script_text += "var sheet_{0}_{1} = paper_{0}_{1}.rect({2}, {3}, {4}, {5}).attr({{'stroke-width': 3}});\n".format( self.set_id, self.id, x_axis_offset * scale_factor, 0, self.length * scale_factor, self.height * scale_factor ) # Shelves shelf_y_offset = 0.0 for cur_shelf in self.shelves: # Shelf Cut Line raphael_script_text += "var line_{0}_{1}_{2} = paper_{0}_{1}.path('M{3},{4} L{5},{6}').attr({{'stroke-width': 2, 'stroke' : '#FF0000'}});\n".format( self.set_id, self.id, cur_shelf.id, (0 + x_axis_offset - 2) * scale_factor, self.real_y_value(shelf_y_offset + cur_shelf.height) * scale_factor, (self.length + x_axis_offset) * scale_factor, self.real_y_value(shelf_y_offset + cur_shelf.height) * scale_factor ) # Shelf Cut Dimension Text raphael_script_text += "var text_dimension_{0}_{1}_{2} = paper_{0}_{1}.text({3}, {4}, '{5}');\n".format( self.set_id, self.id, cur_shelf.id, (x_axis_offset * scale_factor) / 2, self.real_y_value(shelf_y_offset + cur_shelf.height) * scale_factor, carpentryfractions.measurable_fraction(cur_shelf.height) + ' "' ) # Actual Piece Cuts shelf_x_offset = 0.0 for cur_item in cur_shelf.pieces: # Piece Box raphael_script_text += "var piece_{0}_{1}_{2}_{3} = paper_{0}_{1}.rect({4}, {5}, {6}, {7});\n".format( self.set_id, self.id, cur_shelf.id, cur_item.id, (x_axis_offset + shelf_x_offset) * scale_factor, self.real_y_value(shelf_y_offset + cur_shelf.height) * scale_factor, cur_item.length * scale_factor, cur_item.width * scale_factor ) # Piece Labels raphael_script_text += "var piece_label_{0}_{1}_{2}_{3} = paper_{0}_{1}.text({4}, {5}, '{6}');\n".format( self.set_id, self.id, cur_shelf.id, cur_item.id, (x_axis_offset + shelf_x_offset + (cur_item.length/2)) * scale_factor, self.real_y_value(shelf_y_offset + cur_shelf.height - (cur_shelf.height/5)) * scale_factor, str(cur_item.id).upper() ) raphael_script_text += "var piece_label_{0}_{1}_{2}_{3} = paper_{0}_{1}.text({4}, {5}, '{6}');\n".format( self.set_id, self.id, cur_shelf.id, cur_item.id, (x_axis_offset + shelf_x_offset + (cur_item.length/2)) * scale_factor, self.real_y_value(shelf_y_offset + cur_shelf.height - (cur_shelf.height/5*2)) * scale_factor, cur_item.label ) raphael_script_text += "var piece_dims_{0}_{1}_{2}_{3} = paper_{0}_{1}.text({4}, {5}, '{6}');\n".format( self.set_id, self.id, cur_shelf.id, cur_item.id, (x_axis_offset + shelf_x_offset + (cur_item.length/2)) * scale_factor, self.real_y_value(shelf_y_offset + cur_shelf.height - (cur_shelf.height/5*3)) * scale_factor, carpentryfractions.measurable_fraction(cur_item.length) + ' " x ' + carpentryfractions.measurable_fraction(cur_item.width) + ' "' ) raphael_script_text += "var piece_dims_{0}_{1}_{2}_{3} = paper_{0}_{1}.text({4}, {5}, '{6}');\n".format( self.set_id, self.id, cur_shelf.id, cur_item.id, (x_axis_offset + shelf_x_offset + (cur_item.length/2)) * scale_factor, self.real_y_value(shelf_y_offset + cur_shelf.height - (cur_shelf.height/5*4)) * scale_factor, cur_item.comments ) shelf_x_offset = shelf_x_offset + cur_item.length shelf_y_offset += cur_shelf.height self.raphael_script = raphael_script_text