[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [40335] branches/soc-2008-mxcurioni: Added new line style options for selecting chains by min/max 2D lengths.
Tamito Kajiyama
rd6t-kjym at asahi-net.or.jp
Mon Sep 19 00:59:52 CEST 2011
Revision: 40335
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=40335
Author: kjym3
Date: 2011-09-18 22:59:51 +0000 (Sun, 18 Sep 2011)
Log Message:
-----------
Added new line style options for selecting chains by min/max 2D lengths.
Modified Paths:
--------------
branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/parameter_editor.py
branches/soc-2008-mxcurioni/release/scripts/startup/bl_ui/properties_render.py
branches/soc-2008-mxcurioni/source/blender/blenkernel/intern/linestyle.c
branches/soc-2008-mxcurioni/source/blender/makesdna/DNA_linestyle_types.h
branches/soc-2008-mxcurioni/source/blender/makesrna/intern/rna_linestyle.c
Modified: branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/parameter_editor.py
===================================================================
--- branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/parameter_editor.py 2011-09-18 17:10:28 UTC (rev 40334)
+++ branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/parameter_editor.py 2011-09-18 22:59:51 UTC (rev 40335)
@@ -736,6 +736,23 @@
def __call__(self, i1, i2):
return self.__pred1(i1, i2) and self.__pred2(i1, i2)
+# predicates for selection
+
+class LengthThresholdUP1D(UnaryPredicate1D):
+ def __init__(self, min_length=None, max_length=None):
+ UnaryPredicate1D.__init__(self)
+ self._min_length = min_length
+ self._max_length = max_length
+ def getName(self):
+ return "LengthThresholdUP1D"
+ def __call__(self, inter):
+ length = inter.getLength2D()
+ if self._min_length is not None and length < self._min_length:
+ return False
+ if self._max_length is not None and length > self._max_length:
+ return False
+ return True
+
# predicates for splitting
class MaterialBoundaryUP0D(UnaryPredicate0D):
@@ -858,16 +875,24 @@
ymin, ymax = 0.0, float(h)
upred = WithinImageBorderUP1D(xmin, xmax, ymin, ymax)
selection_criteria.append(upred)
- # do feature edge selection
+ # select feature edges
upred = join_unary_predicates(selection_criteria, AndUP1D)
if upred is None:
upred = TrueUP1D()
Operators.select(upred)
- # join feature edges
+ # join feature edges to form chains
bpred = AngleLargerThanBP1D(1.0) # XXX temporary fix for occasional unexpected long lines
if linestyle.same_object:
bpred = AndBP1D(bpred, SameShapeIdBP1D())
Operators.bidirectionalChain(ChainPredicateIterator(upred, bpred), NotUP1D(upred))
+ # split chains
+ if linestyle.material_boundary:
+ Operators.sequentialSplit(MaterialBoundaryUP0D())
+ # select chains
+ if linestyle.use_min_length or linestyle.use_max_length:
+ min_length = linestyle.min_length if linestyle.use_min_length else None
+ max_length = linestyle.max_length if linestyle.use_max_length else None
+ Operators.select(LengthThresholdUP1D(min_length, max_length))
# dashed line
if linestyle.use_dashed_line:
pattern = []
@@ -886,9 +911,6 @@
Operators.sequentialSplit(DashedLineStartingUP0D(controller),
DashedLineStoppingUP0D(controller),
sampling)
- # split chains of feature edges
- if linestyle.material_boundary:
- Operators.sequentialSplit(MaterialBoundaryUP0D())
# prepare a list of stroke shaders
shaders_list = []
for m in linestyle.geometry_modifiers:
Modified: branches/soc-2008-mxcurioni/release/scripts/startup/bl_ui/properties_render.py
===================================================================
--- branches/soc-2008-mxcurioni/release/scripts/startup/bl_ui/properties_render.py 2011-09-18 17:10:28 UTC (rev 40334)
+++ branches/soc-2008-mxcurioni/release/scripts/startup/bl_ui/properties_render.py 2011-09-18 22:59:51 UTC (rev 40335)
@@ -511,14 +511,31 @@
row = layout.row(align=True)
row.prop(linestyle, "panel", expand=True)
if linestyle.panel == "STROKES":
+ # Chaining
col = layout.column()
col.label(text="Chaining:")
col.prop(linestyle, "same_object")
+ # Splitting
col = layout.column()
col.label(text="Splitting:")
row = col.row(align=True)
row.prop(linestyle, "material_boundary")
+ # Selection
col = layout.column()
+ col.label(text="Selection:")
+ sub = col.row()
+ subcol = sub.column()
+ subcol.prop(linestyle, "use_min_length", text="Min Length")
+ subsub = subcol.split()
+ subsub.prop(linestyle, "min_length", text="")
+ subsub.enabled = linestyle.use_min_length
+ subcol = sub.column()
+ subcol.prop(linestyle, "use_max_length", text="Max Length")
+ subsub = subcol.split()
+ subsub.prop(linestyle, "max_length", text="")
+ subsub.enabled = linestyle.use_max_length
+ # Caps
+ col = layout.column()
col.label(text="Caps:")
row = col.row(align=True)
row.prop(linestyle, "caps", expand=True)
Modified: branches/soc-2008-mxcurioni/source/blender/blenkernel/intern/linestyle.c
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/blenkernel/intern/linestyle.c 2011-09-18 17:10:28 UTC (rev 40334)
+++ branches/soc-2008-mxcurioni/source/blender/blenkernel/intern/linestyle.c 2011-09-18 22:59:51 UTC (rev 40335)
@@ -69,6 +69,8 @@
linestyle->r = linestyle->g = linestyle->b = 0.0;
linestyle->alpha = 1.0;
linestyle->thickness = 1.0;
+ linestyle->min_length = 0.0f;
+ linestyle->max_length = 10000.0f;
linestyle->color_modifiers.first = linestyle->color_modifiers.last = NULL;
linestyle->alpha_modifiers.first = linestyle->alpha_modifiers.last = NULL;
Modified: branches/soc-2008-mxcurioni/source/blender/makesdna/DNA_linestyle_types.h
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/makesdna/DNA_linestyle_types.h 2011-09-18 17:10:28 UTC (rev 40334)
+++ branches/soc-2008-mxcurioni/source/blender/makesdna/DNA_linestyle_types.h 2011-09-18 22:59:51 UTC (rev 40335)
@@ -319,6 +319,8 @@
#define LS_SAME_OBJECT 2
#define LS_DASHED_LINE 4
#define LS_MATERIAL_BOUNDARY 8
+#define LS_MIN_2D_LENGTH 16
+#define LS_MAX_2D_LENGTH 32
/* FreestyleLineStyle::caps */
#define LS_CAPS_BUTT 1
@@ -332,6 +334,7 @@
float r, g, b, alpha;
float thickness;
int flag, caps;
+ float min_length, max_length;
unsigned short dash1, gap1, dash2, gap2, dash3, gap3;
int panel; /* for UI */
int pad1;
Modified: branches/soc-2008-mxcurioni/source/blender/makesrna/intern/rna_linestyle.c
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/makesrna/intern/rna_linestyle.c 2011-09-18 17:10:28 UTC (rev 40334)
+++ branches/soc-2008-mxcurioni/source/blender/makesrna/intern/rna_linestyle.c 2011-09-18 22:59:51 UTC (rev 40335)
@@ -733,6 +733,28 @@
RNA_def_property_ui_text(prop, "Same Object", "If true, only feature edges of the same object are joined.");
RNA_def_property_update(prop, NC_SCENE, NULL);
+ prop= RNA_def_property(srna, "use_min_length", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", LS_MIN_2D_LENGTH);
+ RNA_def_property_ui_text(prop, "Use Min 2D Length", "Enable the selection of chains by a minimum 2D length.");
+ RNA_def_property_update(prop, NC_SCENE, NULL);
+
+ prop= RNA_def_property(srna, "min_length", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "min_length");
+ RNA_def_property_range(prop, 0.0f, 10000.0f);
+ RNA_def_property_ui_text(prop, "Min 2D Length", "Minimum 2D length for the selection of chains.");
+ RNA_def_property_update(prop, NC_SCENE, NULL);
+
+ prop= RNA_def_property(srna, "use_max_length", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", LS_MAX_2D_LENGTH);
+ RNA_def_property_ui_text(prop, "Use Max 2D Length", "Enable the selection of chains by a maximum 2D length.");
+ RNA_def_property_update(prop, NC_SCENE, NULL);
+
+ prop= RNA_def_property(srna, "max_length", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "max_length");
+ RNA_def_property_range(prop, 0.0f, 10000.0f);
+ RNA_def_property_ui_text(prop, "Max 2D Length", "Maximum 2D length for the selection of chains.");
+ RNA_def_property_update(prop, NC_SCENE, NULL);
+
prop= RNA_def_property(srna, "material_boundary", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", LS_MATERIAL_BOUNDARY);
RNA_def_property_ui_text(prop, "Material Boundary", "If true, chains of feature edges are split at material boundaries.");
More information about the Bf-blender-cvs
mailing list