[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [32671] branches/soc-2008-mxcurioni: Added support for dashed line in the Parameter Editor mode.
Tamito Kajiyama
rd6t-kjym at asahi-net.or.jp
Sat Oct 23 22:42:27 CEST 2010
Revision: 32671
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=32671
Author: kjym3
Date: 2010-10-23 22:42:26 +0200 (Sat, 23 Oct 2010)
Log Message:
-----------
Added support for dashed line in the Parameter Editor mode.
Modified Paths:
--------------
branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/parameter_editor.py
branches/soc-2008-mxcurioni/release/scripts/ui/properties_render.py
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 2010-10-23 16:32:19 UTC (rev 32670)
+++ branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/parameter_editor.py 2010-10-23 20:42:26 UTC (rev 32671)
@@ -392,6 +392,52 @@
stroke[-1].setPoint(p + d / d.length * caplen_beg)
stroke[-1].setAttribute(attr)
+# dashed line
+
+class DashedLineStartingUP0D(UnaryPredicate0D):
+ def __init__(self, controller):
+ UnaryPredicate0D.__init__(self)
+ self._controller = controller
+ def __call__(self, inter):
+ return self._controller.start()
+
+class DashedLineStoppingUP0D(UnaryPredicate0D):
+ def __init__(self, controller):
+ UnaryPredicate0D.__init__(self)
+ self._controller = controller
+ def __call__(self, inter):
+ return self._controller.stop()
+
+class DashedLineController:
+ def __init__(self, pattern, sampling):
+ self.sampling = float(sampling)
+ k = len(pattern) // 2
+ n = k * 2
+ self.start_pos = [pattern[i] + pattern[i+1] for i in range(0, n, 2)]
+ self.stop_pos = [pattern[i] for i in range(0, n, 2)]
+ self.init()
+ def init(self):
+ self.start_len = 0.0
+ self.start_idx = 0
+ self.stop_len = self.sampling
+ self.stop_idx = 0
+ def start(self):
+ self.start_len += self.sampling
+ if abs(self.start_len - self.start_pos[self.start_idx]) < self.sampling / 2.0:
+ self.start_len = 0.0
+ self.start_idx = (self.start_idx + 1) % len(self.start_pos)
+ return True
+ return False
+ def stop(self):
+ if self.start_len > 0.0:
+ self.init()
+ self.stop_len += self.sampling
+ if abs(self.stop_len - self.stop_pos[self.stop_idx]) < self.sampling / 2.0:
+ self.stop_len = self.sampling
+ self.stop_idx = (self.stop_idx + 1) % len(self.stop_pos)
+ return True
+ return False
+
# main function for parameter processing
def process(layer_name, lineset_name):
@@ -472,6 +518,24 @@
else:
chaining_iterator = ChainSilhouetteIterator()
Operators.bidirectionalChain(chaining_iterator, NotUP1D(upred))
+ # dashed line
+ if linestyle.use_dashed_line:
+ pattern = []
+ if linestyle.dash1 > 0 and linestyle.gap1 > 0:
+ pattern.append(linestyle.dash1)
+ pattern.append(linestyle.gap1)
+ if linestyle.dash2 > 0 and linestyle.gap2 > 0:
+ pattern.append(linestyle.dash2)
+ pattern.append(linestyle.gap2)
+ if linestyle.dash3 > 0 and linestyle.gap3 > 0:
+ pattern.append(linestyle.dash3)
+ pattern.append(linestyle.gap3)
+ if len(pattern) > 0:
+ sampling = 1.0
+ controller = DashedLineController(pattern, sampling)
+ Operators.sequentialSplit(DashedLineStartingUP0D(controller),
+ DashedLineStoppingUP0D(controller),
+ sampling)
# prepare a list of stroke shaders
color = linestyle.color
shaders_list = [
Modified: branches/soc-2008-mxcurioni/release/scripts/ui/properties_render.py
===================================================================
--- branches/soc-2008-mxcurioni/release/scripts/ui/properties_render.py 2010-10-23 16:32:19 UTC (rev 32670)
+++ branches/soc-2008-mxcurioni/release/scripts/ui/properties_render.py 2010-10-23 20:42:26 UTC (rev 32671)
@@ -412,9 +412,32 @@
elif linestyle.panel == "STROKES":
col.label(text="Chaining:")
col.prop(linestyle, "same_object")
+ col.separator()
col.label(text="Caps:")
sub = col.row(align=True)
sub.prop(linestyle, "caps", expand=True)
+ col.separator()
+ col.prop(linestyle, "use_dashed_line")
+ sub = col.row()
+ sub.enabled = linestyle.use_dashed_line
+ subsub = sub.column()
+ subsub.label(text="Dash")
+ subsub.prop(linestyle, "dash1", text="")
+ subsub = sub.column()
+ subsub.label(text="Gap")
+ subsub.prop(linestyle, "gap1", text="")
+ subsub = sub.column()
+ subsub.label(text="Dash")
+ subsub.prop(linestyle, "dash2", text="")
+ subsub = sub.column()
+ subsub.label(text="Gap")
+ subsub.prop(linestyle, "gap2", text="")
+ subsub = sub.column()
+ subsub.label(text="Dash")
+ subsub.prop(linestyle, "dash3", text="")
+ subsub = sub.column()
+ subsub.label(text="Gap")
+ subsub.prop(linestyle, "gap3", text="")
elif linestyle.panel == "DISTORT":
pass
elif linestyle.panel == "MISC":
Modified: branches/soc-2008-mxcurioni/source/blender/makesdna/DNA_linestyle_types.h
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/makesdna/DNA_linestyle_types.h 2010-10-23 16:32:19 UTC (rev 32670)
+++ branches/soc-2008-mxcurioni/source/blender/makesdna/DNA_linestyle_types.h 2010-10-23 20:42:26 UTC (rev 32671)
@@ -181,6 +181,7 @@
/* FreestyleLineStyle::flag */
#define LS_DS_EXPAND 1 /* for animation editors */
#define LS_SAME_OBJECT 2
+#define LS_DASHED_LINE 4
/* FreestyleLineStyle::caps */
#define LS_CAPS_BUTT 1
@@ -194,7 +195,9 @@
float r, g, b, alpha;
float thickness;
int flag, caps;
+ unsigned short dash1, gap1, dash2, gap2, dash3, gap3;
int panel; /* for UI */
+ int pad1;
ListBase color_modifiers;
ListBase alpha_modifiers;
Modified: branches/soc-2008-mxcurioni/source/blender/makesrna/intern/rna_linestyle.c
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/makesrna/intern/rna_linestyle.c 2010-10-23 16:32:19 UTC (rev 32670)
+++ branches/soc-2008-mxcurioni/source/blender/makesrna/intern/rna_linestyle.c 2010-10-23 20:42:26 UTC (rev 32671)
@@ -451,15 +451,56 @@
prop= RNA_def_property(srna, "same_object", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", LS_SAME_OBJECT);
- RNA_def_property_ui_text(prop, "Same Object", "if true, only feature edges of the same object are joined.");
+ 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_dashed_line", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", LS_DASHED_LINE);
+ RNA_def_property_ui_text(prop, "Dashed Line", "Enable or disable dashed line.");
+ RNA_def_property_update(prop, NC_SCENE, NULL);
+
prop= RNA_def_property(srna, "caps", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "caps");
RNA_def_property_enum_items(prop, cap_items);
RNA_def_property_ui_text(prop, "Cap", "Select the shape of both ends of strokes.");
RNA_def_property_update(prop, NC_SCENE, NULL);
+ prop= RNA_def_property(srna, "dash1", PROP_INT, PROP_UNSIGNED);
+ RNA_def_property_int_sdna(prop, NULL, "dash1");
+ RNA_def_property_range(prop, 0, USHRT_MAX);
+ RNA_def_property_ui_text(prop, "Dash #1", "Length of the 1st dash.");
+ RNA_def_property_update(prop, NC_SCENE, NULL);
+
+ prop= RNA_def_property(srna, "gap1", PROP_INT, PROP_UNSIGNED);
+ RNA_def_property_int_sdna(prop, NULL, "gap1");
+ RNA_def_property_range(prop, 0, USHRT_MAX);
+ RNA_def_property_ui_text(prop, "Gap #1", "Length of the 1st gap.");
+ RNA_def_property_update(prop, NC_SCENE, NULL);
+
+ prop= RNA_def_property(srna, "dash2", PROP_INT, PROP_UNSIGNED);
+ RNA_def_property_int_sdna(prop, NULL, "dash2");
+ RNA_def_property_range(prop, 0, USHRT_MAX);
+ RNA_def_property_ui_text(prop, "Dash #2", "Length of the 2nd dash.");
+ RNA_def_property_update(prop, NC_SCENE, NULL);
+
+ prop= RNA_def_property(srna, "gap2", PROP_INT, PROP_UNSIGNED);
+ RNA_def_property_int_sdna(prop, NULL, "gap2");
+ RNA_def_property_range(prop, 0, USHRT_MAX);
+ RNA_def_property_ui_text(prop, "Gap #2", "Length of the 2nd gap.");
+ RNA_def_property_update(prop, NC_SCENE, NULL);
+
+ prop= RNA_def_property(srna, "dash3", PROP_INT, PROP_UNSIGNED);
+ RNA_def_property_int_sdna(prop, NULL, "dash3");
+ RNA_def_property_range(prop, 0, USHRT_MAX);
+ RNA_def_property_ui_text(prop, "Dash #3", "Length of the 3rd dash.");
+ RNA_def_property_update(prop, NC_SCENE, NULL);
+
+ prop= RNA_def_property(srna, "gap3", PROP_INT, PROP_UNSIGNED);
+ RNA_def_property_int_sdna(prop, NULL, "gap3");
+ RNA_def_property_range(prop, 0, USHRT_MAX);
+ RNA_def_property_ui_text(prop, "Gap #3", "Length of the 3rd gap.");
+ RNA_def_property_update(prop, NC_SCENE, NULL);
+
}
void RNA_def_linestyle(BlenderRNA *brna)
More information about the Bf-blender-cvs
mailing list