Source code for viiapackage.results.result_functions.picture_colours

[docs]def _viia_picture_colours(project: 'ViiaProject', colour_type: str): """ Method of 'Pictures' class to create a list with colours to be used for the shapes and the reinforcements. The type is selected in the set_picture_dictionary functions in 'Views' class. The type destermines which shapes and reinforcements will get the same colour. Input: - project (obj): Project object containing collections and of fem objects and project variables. - colour_type (str): Selection of colours for different shapes and reinforcements. Currently available are: - Material: all shapes and reinforcements of the same material get the same colour. - Reinforcement: all reinforcements are coloured red and the shapes have background colour. - Floor: all floors are coloured based on their material and thickness, the other shapes have background colour. - Wall: all walls are coloured based on their material and thickness, the other shapes have background colour. - Beam: all beams and colours are coloured based on their geometry name, the other shapes have background colour. - Soil: all soil shapes are coloured based on their layer, the other shapes have background colour. - Single: all shapes and reinforcements have single background colour. Output: - A list in attribute 'shapecolours' is created with colours for each shape that is active in the picture. It has the same length as the list in attribute 'shapes'. - A list in attribute 'reinforcementcolours' is created with colours for each reinforcement that is active in the picture. It has the same length as the list in attribute 'reinforcements'. """ raise NotImplementedError('Code needs to be updated') # colours of shapes and reinforcements is based on the material if colour_type == 'Material': j = 0 materials_in_picture = {} for shape_name in self.shapes: for shape_object in project.collections.shapes: if shape_name == shape_object.name: break if shape_object.material not in materials_in_picture: materials_in_picture[shape_object.material] = project.colours[j] j += 1 # Check if the end of the colour list in 'project' has not reach the end, otherwise restart # at first colour. if j == len(project.colours): j = 0 self.shapecolours.append(materials_in_picture[shape_object.material]) for shape_name in self.reinforcements: for shape_object in project.collections.shapes: if shape_name == shape_object.name: break if shape_object.material not in materials_in_picture: materials_in_picture[shape_object.material] = project.colours[j] j += 1 # Check if the end of the colour list in 'project' has not reach the end, otherwise restart # at first colour. if j == len(project.colours): j = 0 self.reinforcement_colours.append(materials_in_picture[shape_object.material]) # colours of shapes are based on the floor material and thickness elif colour_type == 'Floor': for shape_name in self.shapes: if self.name in shape_name: for floor_object in project.collections.floors: if floor_object.name == shape_name: thickness = 0.1 for geometry in project.collections.geometries: if geometry.name == floor_object.geometry: thickness = geometry.thickness break self.shapecolours.append(project.floor_colour_dictionary[floor_object.material][thickness]) pass else: # Non floor shapes and reinforcements are coloured with selected 'background' colour self.shapecolours.append(project.OtherShapescolourModelPics) # colours of shapes are based on the wall material and thickness elif colour_type == 'Wall': for shape_name in self.shapes: if self.name in shape_name: checkBool = False for wall_object in project.collections.walls: if wall_object.name == shape_name: thickness = 0.1 checkBool = True for geometry in project.collections.geometries: if geometry.name == wall_object.geometry: thickness = geometry.thickness break self.shapecolours.append(project.wall_colour_dictionary[wall_object.material][thickness]) break if not checkBool: self.shapecolours.append(project.OtherShapescolourModelPics) else: self.shapecolours.append(project.OtherShapescolourModelPics) # colours of shapes are based on the geometry name elif colour_type == 'Beam': for shape_name in self.shapes: if self.name in shape_name or self.name.split('-')[0] + '-KOLOMMEN' in shape_name: for line_object in project.collections.lines: if line_object.name == shape_name: self.shapecolours.append( project.beam_colour_dictionary[line_object.material][line_object.geometry]) pass else: self.shapecolours.append(project.OtherShapescolourModelPics) # colours of shapes are based on the soil layer elif colour_type == 'Soil': for shape_name in self.shapes: if 'GROND' in shape_name and not ('TYING' in shape_name or 'GRONDVEER' in shape_name or 'MASSA' in shape_name): if 'A' in shape_name.split('-')[-2]: soilLayer = int(shape_name.split('-')[-1].split('A')[0]) else: soilLayer = int(shape_name.split('-')[-2]) self.shapecolours.append(project.colours[soilLayer]) elif 'GRONDMASSA' in shape_name: self.shapecolours.append(project.colourDict['Red']) else: self.shapecolours.append(project.OtherShapescolourModelPics) for shape_name in self.reinforcements: self.reinforcement_colours.append(project.Reinforcementcolour) # colour of reinforcement in pictures with reinforcement of top layer elif colour_type == 'Reinforcement': for shape_name in self.shapes: self.shapecolours.append(project.OtherShapescolourModelPics) for shape_name in self.reinforcements: self.reinforcement_colours.append(project.Reinforcementcolour) # Single colour for all shapes and reinforcements that are present. elif colour_type == 'Single': for shape_name in self.shapes: self.shapecolours.append(project.OtherShapescolourModelPics) for shape_name in self.reinforcements: self.reinforcement_colours.append(project.OtherShapescolourModelPics) if len(self.shapes) != len(self.shapecolours) or len(self.reinforcements) != len(self.reinforcement_colours): fem_write_log("ERROR: The colours have not been assigned correctly.", True)