[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [41810] branches/soc-2008-mxcurioni: Added a new operator in the Parameter Editor mode to make a copy

Tamito Kajiyama rd6t-kjym at asahi-net.or.jp
Sun Nov 13 22:55:14 CET 2011


Revision: 41810
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=41810
Author:   kjym3
Date:     2011-11-13 21:55:13 +0000 (Sun, 13 Nov 2011)
Log Message:
-----------
Added a new operator in the Parameter Editor mode to make a copy
of the active line set.

Modified Paths:
--------------
    branches/soc-2008-mxcurioni/release/scripts/startup/bl_ui/properties_render.py
    branches/soc-2008-mxcurioni/source/blender/editors/render/render_intern.h
    branches/soc-2008-mxcurioni/source/blender/editors/render/render_ops.c
    branches/soc-2008-mxcurioni/source/blender/editors/render/render_shading.c
    branches/soc-2008-mxcurioni/source/blender/freestyle/FRS_freestyle.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp

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-11-13 20:20:50 UTC (rev 41809)
+++ branches/soc-2008-mxcurioni/release/scripts/startup/bl_ui/properties_render.py	2011-11-13 21:55:13 UTC (rev 41810)
@@ -175,6 +175,14 @@
         row.prop(rl, "exclude_refraction", text="")
 
 
+class RENDER_MT_lineset_specials(Menu):
+    bl_label = "Lineset Specials"
+
+    def draw(self, context):
+        layout = self.layout
+        layout.operator("scene.freestyle_lineset_copy", icon='ZOOMIN')
+
+
 class RENDER_PT_freestyle(RenderButtonsPanel, Panel):
     bl_label = "Freestyle"
     COMPAT_ENGINES = {'BLENDER_RENDER'}
@@ -218,6 +226,7 @@
             subsub = sub.column(align=True)
             subsub.operator("scene.freestyle_lineset_add", icon='ZOOMIN', text="")
             subsub.operator("scene.freestyle_lineset_remove", icon='ZOOMOUT', text="")
+            subsub.menu("RENDER_MT_lineset_specials", icon='DOWNARROW_HLT', text="")
             if lineset:
                 sub.separator()
                 subsub = sub.column(align=True)

Modified: branches/soc-2008-mxcurioni/source/blender/editors/render/render_intern.h
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/editors/render/render_intern.h	2011-11-13 20:20:50 UTC (rev 41809)
+++ branches/soc-2008-mxcurioni/source/blender/editors/render/render_intern.h	2011-11-13 21:55:13 UTC (rev 41810)
@@ -57,6 +57,7 @@
 void SCENE_OT_freestyle_module_remove(struct wmOperatorType *ot);
 void SCENE_OT_freestyle_module_move(struct wmOperatorType *ot);
 void SCENE_OT_freestyle_lineset_add(struct wmOperatorType *ot);
+void SCENE_OT_freestyle_lineset_copy(struct wmOperatorType *ot);
 void SCENE_OT_freestyle_lineset_remove(struct wmOperatorType *ot);
 void SCENE_OT_freestyle_lineset_move(struct wmOperatorType *ot);
 void SCENE_OT_freestyle_linestyle_new(struct wmOperatorType *ot);

Modified: branches/soc-2008-mxcurioni/source/blender/editors/render/render_ops.c
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/editors/render/render_ops.c	2011-11-13 20:20:50 UTC (rev 41809)
+++ branches/soc-2008-mxcurioni/source/blender/editors/render/render_ops.c	2011-11-13 21:55:13 UTC (rev 41810)
@@ -66,6 +66,7 @@
 	WM_operatortype_append(SCENE_OT_freestyle_module_remove);
 	WM_operatortype_append(SCENE_OT_freestyle_module_move);
 	WM_operatortype_append(SCENE_OT_freestyle_lineset_add);
+	WM_operatortype_append(SCENE_OT_freestyle_lineset_copy);
 	WM_operatortype_append(SCENE_OT_freestyle_lineset_remove);
 	WM_operatortype_append(SCENE_OT_freestyle_lineset_move);
 	WM_operatortype_append(SCENE_OT_freestyle_linestyle_new);

Modified: branches/soc-2008-mxcurioni/source/blender/editors/render/render_shading.c
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/editors/render/render_shading.c	2011-11-13 20:20:50 UTC (rev 41809)
+++ branches/soc-2008-mxcurioni/source/blender/editors/render/render_shading.c	2011-11-13 21:55:13 UTC (rev 41810)
@@ -722,6 +722,32 @@
 	return FRS_get_active_lineset(&srl->freestyleConfig) != NULL;
 }
 
+static int freestyle_lineset_copy_exec(bContext *C, wmOperator *op)
+{
+	Scene *scene= CTX_data_scene(C);
+	SceneRenderLayer *srl = (SceneRenderLayer*) BLI_findlink(&scene->r.layers, scene->r.actlay);
+
+	FRS_copy_active_lineset(&srl->freestyleConfig);
+
+	WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene);
+	
+	return OPERATOR_FINISHED;
+}
+
+void SCENE_OT_freestyle_lineset_copy(wmOperatorType *ot)
+{
+	/* identifiers */
+	ot->name= "Copy Line Set";
+	ot->idname= "SCENE_OT_freestyle_lineset_copy";
+	ot->description="Create a copy of the active line set";
+	
+	/* api callbacks */
+	ot->exec= freestyle_lineset_copy_exec;
+	ot->poll= freestyle_active_lineset_poll;
+
+	/* flags */
+	ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
 static int freestyle_lineset_remove_exec(bContext *C, wmOperator *UNUSED(op))
 {
 	Scene *scene= CTX_data_scene(C);

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/FRS_freestyle.h
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/FRS_freestyle.h	2011-11-13 20:20:50 UTC (rev 41809)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/FRS_freestyle.h	2011-11-13 21:55:13 UTC (rev 41810)
@@ -65,7 +65,8 @@
 	void FRS_move_module_up(FreestyleConfig *config, FreestyleModuleConfig *module_conf);
 	void FRS_move_module_down(FreestyleConfig *config, FreestyleModuleConfig *module_conf);
 	
-	void FRS_add_lineset(FreestyleConfig *config);
+	FreestyleLineSet *FRS_add_lineset(FreestyleConfig *config);
+	void FRS_copy_active_lineset(FreestyleConfig *config);
 	void FRS_delete_active_lineset(FreestyleConfig *config);
 	void FRS_move_active_lineset_up(FreestyleConfig *config);
 	void FRS_move_active_lineset_down(FreestyleConfig *config);

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp	2011-11-13 20:20:50 UTC (rev 41809)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp	2011-11-13 21:55:13 UTC (rev 41810)
@@ -542,7 +542,7 @@
 		BLI_insertlinkafter(&config->modules, module_conf->next, module_conf);
 	}
 
-	void FRS_add_lineset(FreestyleConfig *config)
+	FreestyleLineSet *FRS_add_lineset(FreestyleConfig *config)
 	{
 		int lineset_index = BLI_countlist(&config->linesets);
 
@@ -563,8 +563,32 @@
 		else
 			strcpy(lineset->name, "LineSet");
 		BLI_uniquename(&config->linesets, lineset, "FreestyleLineSet", '.', offsetof(FreestyleLineSet, name), sizeof(lineset->name));
+
+		return lineset;
 	}
 
+	void FRS_copy_active_lineset(FreestyleConfig *config)
+	{
+		FreestyleLineSet *lineset = FRS_get_active_lineset(config);
+
+		if (lineset) {
+			FreestyleLineSet *new_lineset = FRS_add_lineset(config);
+			new_lineset->linestyle = lineset->linestyle;
+			new_lineset->linestyle->id.us++;
+			new_lineset->flags = lineset->flags;
+			new_lineset->selection = lineset->selection;
+			new_lineset->qi = lineset->qi;
+			new_lineset->qi_start = lineset->qi_start;
+			new_lineset->qi_end = lineset->qi_end;
+			new_lineset->edge_types = lineset->edge_types;
+			if (lineset->group) {
+				new_lineset->group = lineset->group;
+				new_lineset->group->id.us++;
+			}
+			new_lineset->flags |= FREESTYLE_LINESET_CURRENT;
+		}
+	}
+
 	void FRS_delete_active_lineset(FreestyleConfig *config)
 	{
 		FreestyleLineSet *lineset = FRS_get_active_lineset(config);




More information about the Bf-blender-cvs mailing list