Skip to content

Commit

Permalink
Line chart color fix!
Browse files Browse the repository at this point in the history
  • Loading branch information
Griperis committed Apr 6, 2020
1 parent 3875e3f commit 568ffed
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
2 changes: 1 addition & 1 deletion data_vis/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class DV_LabelPropertyGroup(bpy.types.PropertyGroup):

class DV_ColorPropertyGroup(bpy.types.PropertyGroup):
use_shader: bpy.props.BoolProperty(
name='Use Shader',
name='Use Nodes',
default=True,
description='Uses Node Shading to color created objects. Not using this option may create material for every chart object when not using constant color type'
)
Expand Down
36 changes: 29 additions & 7 deletions data_vis/operators/line_chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from data_vis.operators.features.axis import AxisFactory
from data_vis.general import OBJECT_OT_GenericChart, DV_LabelPropertyGroup, DV_AxisPropertyGroup
from data_vis.data_manager import DataManager, DataType
from data_vis.colors import NodeShader, ColorGen, ColorType


class OBJECT_OT_LineChart(OBJECT_OT_GenericChart):
Expand Down Expand Up @@ -44,6 +45,20 @@ class OBJECT_OT_LineChart(OBJECT_OT_GenericChart):
options={'SKIP_SAVE'}
)

color_shade: bpy.props.FloatVectorProperty(
name='Base Color',
subtype='COLOR',
default=(0.0, 0.0, 1.0),
min=0.0,
max=1.0,
description='Base color shade to work with'
)

use_shader: bpy.props.BoolProperty(
name='Use Nodes',
default=False,
)

def __init__(self):
super().__init__()
self.only_2d = True
Expand All @@ -69,14 +84,14 @@ def poll(cls, context):
def draw(self, context):
super().draw(context)
layout = self.layout
box = layout.box()
if self.bevel_edges:
row = layout.row()
row.prop(self, 'rounded')
row = layout.row()
row.prop(self, 'bevel_edges')
if self.bevel_edges:
row = layout.row()
row.prop(self, 'rounded')
box.prop(self, 'rounded')
box.prop(self, 'bevel_edges')

box = layout.box()
box.prop(self, 'use_shader')
box.prop(self, 'color_shade')

def execute(self, context):
self.init_data()
Expand All @@ -100,6 +115,13 @@ def execute(self, context):

self.create_curve(normalized_vert_list, edges)
self.add_bevel_obj()
if self.use_shader:
mat = NodeShader(self.color_shade, location_z=self.container_object.location[2]).create_geometry_shader()
else:
mat = ColorGen(self.color_shade, ColorType.Constant, self.axis_settings.z_range).get_material()

self.curve_obj.data.materials.append(mat)
self.curve_obj.active_material = mat

if self.axis_settings.create:
AxisFactory.create(
Expand Down

0 comments on commit 568ffed

Please sign in to comment.