def createLegendObject(obj_location, value): text_location = (obj_location[0], obj_location[1]+y_difference, obj_location[2]) bpy.ops.mesh.primitive_cube_add(radius=1, location= obj_location) obj = bpy.context.object obj.scale = scale bpy.ops.object.text_add(location=text_location, rotation=(1.5708,0,1.5708)) obj_text = bpy.context.object obj_text.data.size = text_size obj_text.data.body = "{0:.2f}".format(value) + " " + unit obj_material = bpy.data.materials.new("material") obj_material.diffuse_color = JetColorMap.getColorTuple(value) obj.active_material = obj_material obj_text.active_material = obj_material
def __init__(self, datafr, name, unit, text_location, text_size, showValue): self.datafr = datafr self.name = name self.unit = unit self.text_location = text_location self.state_value = self.datafr[self.name].tolist()[0] self.showValue = showValue # Material erstellen self.material = bpy.data.materials.new(self.name + ".material") self.material.diffuse_color = JetColorMap.getColorTuple(self.state_value) if self.text_location: bpy.ops.object.text_add(location=text_location, rotation=(1.5708,0,1.5708)) self.text = bpy.context.object self.text.data.size = text_size self.text.active_material = self.material self.setText() # sich selbst zur Liste all_objects hinzufügen State.all_objects.append(self)
def setColor(self): self.material.diffuse_color = JetColorMap.getColorTuple(self.state_value)
def setTextColor(self): self.text.active_material.diffuse_color = JetColorMap.getColorTuple(self.state_value)
def setColorBounds(down_bound, up_bound): JetColorMap.setBounds(down_bound, up_bound)