From 0f5c19c32c058a861efb7018e145278ac6beda2b Mon Sep 17 00:00:00 2001 From: Tamito Kajiyama Date: Sun, 27 Jun 2010 00:03:34 +0000 Subject: [PATCH] More on the new GUI for the Parameter Editor mode. This is a WIP commit. * Moved render layer-specific Freestyle options to a separate "Freestyle" tab (in addition to the "Freestyle: Line Style" tab that has been introduced in the previous commit). * Added UI controls for specifying feature edge selection criteria in the Parameter Editor mode. Feature edge selection starts with a set of all feature edges in the view map. Each line set specifies edge selection criteria (e.g., to select only visible crease edges) by enabling appropriate UI controls (e.g., by turning on the "Crease" and "Visibility" toggle buttons). Selected criteria are combined by logical conjunction. Logical disjunction (e.g., "crease edges or contours") is represented by two or more line sets. * Slightly rearranged several UI controls in the Python Scripting mode. --- release/scripts/ui/properties_render.py | 171 +++++++++++------- source/blender/blenkernel/intern/linestyle.c | 7 +- .../blender_interface/FRS_freestyle.cpp | 14 +- source/blender/makesdna/DNA_freestyle_types.h | 26 ++- source/blender/makesrna/intern/rna_scene.c | 100 +++++++++- 5 files changed, 245 insertions(+), 73 deletions(-) diff --git a/release/scripts/ui/properties_render.py b/release/scripts/ui/properties_render.py index ab77a550598..8e357298bae 100644 --- a/release/scripts/ui/properties_render.py +++ b/release/scripts/ui/properties_render.py @@ -69,27 +69,6 @@ class RENDER_PT_render(RenderButtonsPanel): layout.prop(rd, "display_mode", text="Display") -class RENDER_PT_freestyle_linestyle(RenderButtonsPanel): - bl_label = "Freestyle Line Style" - COMPAT_ENGINES = {'BLENDER_RENDER'} - - def poll(self, context): - rd = context.scene.render - rl = rd.layers[rd.active_layer_index] - return rl and rl.freestyle and rl.freestyle_settings.active_lineset - - def draw(self, context): - layout = self.layout - - rd = context.scene.render - rl = rd.layers[rd.active_layer_index] - linestyle = rl.freestyle_settings.active_lineset.linestyle - - split = layout.split() - col = split.column() - col.prop(linestyle, "name") - - class RENDER_PT_layers(RenderButtonsPanel): bl_label = "Layers" bl_default_closed = True @@ -195,63 +174,126 @@ class RENDER_PT_layers(RenderButtonsPanel): row.prop(rl, "pass_refraction") row.prop(rl, "pass_refraction_exclude", text="") - if rl.freestyle: - layout.separator() - split = layout.split() +class RENDER_PT_freestyle(RenderButtonsPanel): + bl_label = "Freestyle" + COMPAT_ENGINES = {'BLENDER_RENDER'} - col = split.column() - col.label(text="Freestyle:") - freestyle = rl.freestyle_settings - col.prop(freestyle, "mode", text="Control Mode") - if freestyle.mode == "EDITOR": + def poll(self, context): + rd = context.scene.render + rl = rd.layers[rd.active_layer_index] + return rl and rl.freestyle - lineset = freestyle.active_lineset + def draw(self, context): + layout = self.layout - col.label(text="Line Sets:") + rd = context.scene.render + rl = rd.layers[rd.active_layer_index] + freestyle = rl.freestyle_settings + + split = layout.split() + + col = split.column() + col.prop(freestyle, "mode", text="Control Mode") + + if freestyle.mode == "EDITOR": + + lineset = freestyle.active_lineset + + col.label(text="Line Sets:") + row = col.row() + rows = 2 + if lineset: + rows = 5 + # FIXME: scrollbar does not work correctly + row.template_list(freestyle, "linesets", freestyle, "active_lineset_index", rows=rows) + + sub = row.column() + subsub = sub.column(align=True) + subsub.operator("scene.freestyle_lineset_add", icon='ZOOMIN', text="") + subsub.operator("scene.freestyle_lineset_remove", icon='ZOOMOUT', text="") + if lineset: + sub.separator() + subsub = sub.column(align=True) + subsub.operator("scene.freestyle_lineset_move", icon='TRIA_UP', text="").direction = 'UP' + subsub.operator("scene.freestyle_lineset_move", icon='TRIA_DOWN', text="").direction = 'DOWN' + + if lineset: + col.prop(lineset, "name") row = col.row() - rows = 2 - if lineset: - rows = 5 - # FIXME: scrollbar does not work correctly - row.template_list(freestyle, "linesets", freestyle, "active_lineset_index", rows=rows) - sub = row.column() + sub.prop(lineset, "select_silhouette") + sub.prop(lineset, "select_border") + sub.prop(lineset, "select_crease") + sub.prop(lineset, "select_ridge") + sub.prop(lineset, "select_valley") + sub.prop(lineset, "select_suggestive_contour") + sub.prop(lineset, "select_material_boundary") + sub = row.column() + sub.prop(lineset, "select_contour") + sub.prop(lineset, "select_external_contour") + sub.prop(lineset, "select_visibility") + col.prop(lineset, "crease_angle") + col.prop(lineset, "sphere_radius") + if lineset.select_suggestive_contour: + col.label(text="Suggestive Contours:") + col.prop(lineset, "dkr_epsilon") + if lineset.select_visibility: + col.label(text="Visibility:") + sub = col.row(align=True) + sub.prop(lineset, "visibility", expand=True) + if lineset.visibility == "RANGE": + sub = col.row(align=True) + sub.prop(lineset, "qi_start") + sub.prop(lineset, "qi_end") - subsub = sub.column(align=True) - subsub.operator("scene.freestyle_lineset_add", icon='ZOOMIN', text="") - subsub.operator("scene.freestyle_lineset_remove", icon='ZOOMOUT', text="") + else: # freestyle.mode == "SCRIPT" - if lineset: - sub.separator() + col.prop(freestyle, "crease_angle") + col.prop(freestyle, "sphere_radius") + col.prop(freestyle, "ridges_and_valleys") + col.prop(freestyle, "suggestive_contours") + sub = col.row() + sub.prop(freestyle, "dkr_epsilon") + sub.active = freestyle.suggestive_contours + col.prop(freestyle, "material_boundaries") + col.operator("scene.freestyle_module_add") - subsub = sub.column(align=True) - subsub.operator("scene.freestyle_lineset_move", icon='TRIA_UP', text="").direction = 'UP' - subsub.operator("scene.freestyle_lineset_move", icon='TRIA_DOWN', text="").direction = 'DOWN' + for i, module in enumerate(freestyle.modules): + box = layout.box() + box.set_context_pointer("freestyle_module", module) + row = box.row(align=True) + row.prop(module, "is_displayed", text="") + row.prop(module, "module_path", text="") + row.operator("scene.freestyle_module_remove", icon='X', text="") + row.operator("scene.freestyle_module_move", icon='TRIA_UP', text="").direction = 'UP' + row.operator("scene.freestyle_module_move", icon='TRIA_DOWN', text="").direction = 'DOWN' - col.prop(lineset, "name") - col.template_ID(lineset, "linestyle", new="scene.freestyle_linestyle_new") - else: - col.prop(freestyle, "crease_angle", text="Crease Angle") - col.prop(freestyle, "sphere_radius", text="Sphere Radius") - col.prop(freestyle, "ridges_and_valleys", text="Ridges and Valleys") - col.prop(freestyle, "suggestive_contours", text="Suggestive Contours") - col.prop(freestyle, "material_boundaries", text="Material Boundaries") - col.prop(freestyle, "dkr_epsilon", text="Dkr Epsilon") +class RENDER_PT_freestyle_linestyle(RenderButtonsPanel): + bl_label = "Freestyle: Line Style" + COMPAT_ENGINES = {'BLENDER_RENDER'} - col.operator("scene.freestyle_module_add", text="Add Style Module") + def poll(self, context): + rd = context.scene.render + rl = rd.layers[rd.active_layer_index] + if rl and rl.freestyle: + freestyle = rl.freestyle_settings + return freestyle.mode == "EDITOR" and freestyle.active_lineset + return False - for i, module in enumerate(freestyle.modules): - box = layout.box() - box.set_context_pointer("freestyle_module", module) - row = box.row(align=True) - row.prop(module, "is_displayed", text="") - row.prop(module, "module_path", text="") - row.operator("scene.freestyle_module_remove", icon='X', text="") - row.operator("scene.freestyle_module_move", icon='TRIA_UP', text="").direction = 'UP' - row.operator("scene.freestyle_module_move", icon='TRIA_DOWN', text="").direction = 'DOWN' + def draw(self, context): + layout = self.layout + + rd = context.scene.render + rl = rd.layers[rd.active_layer_index] + lineset = rl.freestyle_settings.active_lineset + linestyle = lineset.linestyle + + split = layout.split() + col = split.column() + col.template_ID(lineset, "linestyle", new="scene.freestyle_linestyle_new") class RENDER_PT_shading(RenderButtonsPanel): @@ -757,6 +799,7 @@ classes = [ RENDER_MT_ffmpeg_presets, RENDER_PT_render, RENDER_PT_layers, + RENDER_PT_freestyle, RENDER_PT_freestyle_linestyle, RENDER_PT_dimensions, RENDER_PT_antialiasing, diff --git a/source/blender/blenkernel/intern/linestyle.c b/source/blender/blenkernel/intern/linestyle.c index 0abf83fe422..1f768fee0ec 100644 --- a/source/blender/blenkernel/intern/linestyle.c +++ b/source/blender/blenkernel/intern/linestyle.c @@ -38,6 +38,11 @@ #include "BKE_linestyle.h" #include "BKE_main.h" +static void default_linestyle_settings(FreestyleLineStyle *linestyle) +{ + +} + FreestyleLineStyle *FRS_new_linestyle(char *name, struct Main *main) { FreestyleLineStyle *linestyle; @@ -47,7 +52,7 @@ FreestyleLineStyle *FRS_new_linestyle(char *name, struct Main *main) linestyle = (FreestyleLineStyle *)alloc_libblock(&main->linestyle, ID_LS, name); - /* todo: default parameter settings */ + default_linestyle_settings(linestyle); return linestyle; } diff --git a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp index 3aa399f4af3..13e5fcc7715 100644 --- a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp +++ b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp @@ -317,9 +317,9 @@ extern "C" { config->modules.first = config->modules.last = NULL; config->flags = 0; - config->sphere_radius = 1.0; - config->dkr_epsilon = 0.001; - config->crease_angle = 134.43; + config->sphere_radius = 1.0f; + config->dkr_epsilon = 0.001f; + config->crease_angle = 134.43f; config->linesets.first = config->linesets.last = NULL; } @@ -372,6 +372,14 @@ extern "C" { lineset->linestyle = FRS_new_linestyle("LineStyle", NULL); lineset->flags |= FREESTYLE_LINESET_ENABLED; + lineset->selection = 0; + lineset->crease_angle = 134.43f; + lineset->sphere_radius = 1.0f; + lineset->dkr_epsilon = 0.001f; + lineset->qi = FREESTYLE_QI_VISIBLE; + lineset->qi_start = 0; + lineset->qi_end = 100; + lineset->objects.first = lineset->objects.last = NULL; if (lineset_index > 0) sprintf(lineset->name, "LineSet %i", lineset_index+1); else diff --git a/source/blender/makesdna/DNA_freestyle_types.h b/source/blender/makesdna/DNA_freestyle_types.h index 8444f6bd29a..2fcfdd40cf6 100644 --- a/source/blender/makesdna/DNA_freestyle_types.h +++ b/source/blender/makesdna/DNA_freestyle_types.h @@ -17,6 +17,23 @@ #define FREESTYLE_LINESET_CURRENT 1 #define FREESTYLE_LINESET_ENABLED 2 +/* FreestyleLineSet::selection */ +#define FREESTYLE_SEL_SILHOUETTE 1 +#define FREESTYLE_SEL_BORDER 2 +#define FREESTYLE_SEL_CREASE 4 +#define FREESTYLE_SEL_RIDGE 8 +#define FREESTYLE_SEL_VALLEY 16 +#define FREESTYLE_SEL_SUGGESTIVE_CONTOUR 32 +#define FREESTYLE_SEL_MATERIAL_BOUNDARY 64 +#define FREESTYLE_SEL_CONTOUR 128 +#define FREESTYLE_SEL_EXTERNAL_CONTOUR 256 +#define FREESTYLE_SEL_VISIBILITY 512 + +/* FreestyleLineSet::qi */ +#define FREESTYLE_QI_VISIBLE 1 +#define FREESTYLE_QI_HIDDEN 2 +#define FREESTYLE_QI_RANGE 3 + typedef struct FreestyleLineStyle { ID id; @@ -27,7 +44,14 @@ typedef struct FreestyleLineSet { char name[32]; /* line set name */ int flags; - int pad; + int selection; /* feature edge selection */ + + float crease_angle; + float sphere_radius; + float dkr_epsilon; + short qi; /* quantitative invisibility */ + short pad; + int qi_start, qi_end; FreestyleLineStyle *linestyle; /* line style */ diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 66784f6cbfc..0b4bb260013 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -1540,6 +1540,12 @@ static void rna_def_freestyle_settings(BlenderRNA *brna) {FREESTYLE_CONTROL_EDITOR_MODE, "EDITOR", 0, "Parameter Editor Mode", "Basic mode for interactive style parameter editing"}, {0, NULL, 0, NULL, NULL}}; + static EnumPropertyItem visibility_items[] ={ + {FREESTYLE_QI_VISIBLE, "VISIBLE", 0, "Visible", "Select visible edges."}, + {FREESTYLE_QI_HIDDEN, "HIDDEN", 0, "Hidden", "Select hidden edges."}, + {FREESTYLE_QI_RANGE, "RANGE", 0, "QI Range", "Select edges within a range of quantitative invisibility (QI) values."}, + {0, NULL, 0, NULL, NULL}}; + /* FreestyleLineSet */ srna= RNA_def_struct(brna, "FreestyleLineSet", NULL); @@ -1568,7 +1574,93 @@ static void rna_def_freestyle_settings(BlenderRNA *brna) prop= RNA_def_property(srna, "objects", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "objects", NULL); RNA_def_property_struct_type(prop, "Object"); - RNA_def_property_ui_text(prop, "Target objects", "A list of objects on which stylized lines are drawn."); + RNA_def_property_ui_text(prop, "Target Objects", "A list of objects on which stylized lines are drawn."); + + prop= RNA_def_property(srna, "select_silhouette", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "selection", FREESTYLE_SEL_SILHOUETTE); + RNA_def_property_ui_text(prop, "Silhouette", "Select silhouette edges."); + RNA_def_property_update(prop, NC_SCENE, NULL); + + prop= RNA_def_property(srna, "select_border", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "selection", FREESTYLE_SEL_BORDER); + RNA_def_property_ui_text(prop, "Border", "Select border edges."); + RNA_def_property_update(prop, NC_SCENE, NULL); + + prop= RNA_def_property(srna, "select_crease", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "selection", FREESTYLE_SEL_CREASE); + RNA_def_property_ui_text(prop, "Crease", "Select crease edges."); + RNA_def_property_update(prop, NC_SCENE, NULL); + + prop= RNA_def_property(srna, "select_ridge", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "selection", FREESTYLE_SEL_RIDGE); + RNA_def_property_ui_text(prop, "Ridge", "Select ridges."); + RNA_def_property_update(prop, NC_SCENE, NULL); + + prop= RNA_def_property(srna, "select_valley", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "selection", FREESTYLE_SEL_VALLEY); + RNA_def_property_ui_text(prop, "Valley", "Select valleys."); + RNA_def_property_update(prop, NC_SCENE, NULL); + + prop= RNA_def_property(srna, "select_suggestive_contour", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "selection", FREESTYLE_SEL_SUGGESTIVE_CONTOUR); + RNA_def_property_ui_text(prop, "Suggestive Contour", "Select suggestive contours."); + RNA_def_property_update(prop, NC_SCENE, NULL); + + prop= RNA_def_property(srna, "select_material_boundary", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "selection", FREESTYLE_SEL_MATERIAL_BOUNDARY); + RNA_def_property_ui_text(prop, "Material Boundary", "Select edges at material boundaries."); + RNA_def_property_update(prop, NC_SCENE, NULL); + + prop= RNA_def_property(srna, "select_contour", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "selection", FREESTYLE_SEL_CONTOUR); + RNA_def_property_ui_text(prop, "Contour", "Select contours."); + RNA_def_property_update(prop, NC_SCENE, NULL); + + prop= RNA_def_property(srna, "select_external_contour", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "selection", FREESTYLE_SEL_EXTERNAL_CONTOUR); + RNA_def_property_ui_text(prop, "External Contour", "Select external contours."); + RNA_def_property_update(prop, NC_SCENE, NULL); + + prop= RNA_def_property(srna, "select_visibility", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "selection", FREESTYLE_SEL_VISIBILITY); + RNA_def_property_ui_text(prop, "Visibility", "Select edges based on visibility."); + RNA_def_property_update(prop, NC_SCENE, NULL); + + prop= RNA_def_property(srna, "crease_angle", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "crease_angle"); + RNA_def_property_range(prop, 0.0, 180.0); + RNA_def_property_ui_text(prop, "Crease Angle", "Angular threshold in degrees (between 0 and 180) for detecting crease edges."); + RNA_def_property_update(prop, NC_SCENE, NULL); + + prop= RNA_def_property(srna, "sphere_radius", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "sphere_radius"); + RNA_def_property_range(prop, 0.0, 1000.0); + RNA_def_property_ui_text(prop, "Sphere Radius", "Sphere radius for computing curvatures."); + RNA_def_property_update(prop, NC_SCENE, NULL); + + prop= RNA_def_property(srna, "dkr_epsilon", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "dkr_epsilon"); + RNA_def_property_range(prop, 0.0, 1000.0); + RNA_def_property_ui_text(prop, "Kr Derivative Epsilon", "Kr derivative epsilon for computing suggestive contours."); + RNA_def_property_update(prop, NC_SCENE, NULL); + + prop= RNA_def_property(srna, "visibility", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "qi"); + RNA_def_property_enum_items(prop, visibility_items); + RNA_def_property_ui_text(prop, "Visibility", "Select edges based on visibility."); + RNA_def_property_update(prop, NC_SCENE, NULL); + + prop= RNA_def_property(srna, "qi_start", PROP_INT, PROP_UNSIGNED); + RNA_def_property_int_sdna(prop, NULL, "qi_start"); + RNA_def_property_range(prop, 0, INT_MAX); + RNA_def_property_ui_text(prop, "Start", "First QI value of the QI range"); + RNA_def_property_update(prop, NC_SCENE, NULL); + + prop= RNA_def_property(srna, "qi_end", PROP_INT, PROP_UNSIGNED); + RNA_def_property_int_sdna(prop, NULL, "qi_end"); + RNA_def_property_range(prop, 0, INT_MAX); + RNA_def_property_ui_text(prop, "End", "Last QI value of the QI range"); + RNA_def_property_update(prop, NC_SCENE, NULL); /* FreestyleModuleSettings */ @@ -1616,19 +1708,19 @@ static void rna_def_freestyle_settings(BlenderRNA *brna) prop= RNA_def_property(srna, "material_boundaries", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", FREESTYLE_MATERIAL_BOUNDARIES_FLAG); - RNA_def_property_ui_text(prop, "Material boundaries", "Enable material boundaries."); + RNA_def_property_ui_text(prop, "Material Boundaries", "Enable material boundaries."); RNA_def_property_update(prop, NC_SCENE, NULL); prop= RNA_def_property(srna, "sphere_radius", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "sphere_radius"); RNA_def_property_range(prop, 0.0, 1000.0); - RNA_def_property_ui_text(prop, "Sphere Radius", "*TBD*"); + RNA_def_property_ui_text(prop, "Sphere Radius", "Sphere radius for computing curvatures."); RNA_def_property_update(prop, NC_SCENE, NULL); prop= RNA_def_property(srna, "dkr_epsilon", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "dkr_epsilon"); RNA_def_property_range(prop, 0.0, 1000.0); - RNA_def_property_ui_text(prop, "Dkr Epsilon", "*TBD*"); + RNA_def_property_ui_text(prop, "Kr Derivative Epsilon", "Kr derivative epsilon for computing suggestive contours."); RNA_def_property_update(prop, NC_SCENE, NULL); prop= RNA_def_property(srna, "crease_angle", PROP_FLOAT, PROP_NONE);