Revision: 42025
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=42025
Author:   kjym3
Date:     2011-11-20 23:44:50 +0000 (Sun, 20 Nov 2011)
Log Message:
-----------
Replaced the changes in revision 41810 with a better implementation
of copy/paste functionality.  Instead of making a copy of the active
line set, now the settings of the active line set are copied to and
pasted from a buffer.  This allows for copying and pasting line set
settings among different scenes and render layers.

Revision Links:
--------------
    
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=41810

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-20 21:02:12 UTC (rev 42024)
+++ 
branches/soc-2008-mxcurioni/release/scripts/startup/bl_ui/properties_render.py  
    2011-11-20 23:44:50 UTC (rev 42025)
@@ -180,7 +180,8 @@
 
     def draw(self, context):
         layout = self.layout
-        layout.operator("scene.freestyle_lineset_copy", icon='ZOOMIN')
+        layout.operator("scene.freestyle_lineset_copy", icon='COPYDOWN')
+        layout.operator("scene.freestyle_lineset_paste", icon='PASTEDOWN')
 
 
 class RENDER_PT_freestyle(RenderButtonsPanel, Panel):

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-20 21:02:12 UTC (rev 42024)
+++ branches/soc-2008-mxcurioni/source/blender/editors/render/render_intern.h   
2011-11-20 23:44:50 UTC (rev 42025)
@@ -58,6 +58,7 @@
 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_paste(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-20 21:02:12 UTC (rev 42024)
+++ branches/soc-2008-mxcurioni/source/blender/editors/render/render_ops.c      
2011-11-20 23:44:50 UTC (rev 42025)
@@ -67,6 +67,7 @@
        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_paste);
        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-20 21:02:12 UTC (rev 42024)
+++ branches/soc-2008-mxcurioni/source/blender/editors/render/render_shading.c  
2011-11-20 23:44:50 UTC (rev 42025)
@@ -718,7 +718,7 @@
        /* identifiers */
        ot->name= "Copy Line Set";
        ot->idname= "SCENE_OT_freestyle_lineset_copy";
-       ot->description="Create a copy of the active line set";
+       ot->description="Copy the active line set to a buffer";
        
        /* api callbacks */
        ot->exec= freestyle_lineset_copy_exec;
@@ -727,6 +727,34 @@
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 }
+
+static int freestyle_lineset_paste_exec(bContext *C, wmOperator *op)
+{
+       Scene *scene= CTX_data_scene(C);
+       SceneRenderLayer *srl = (SceneRenderLayer*) 
BLI_findlink(&scene->r.layers, scene->r.actlay);
+
+       FRS_paste_active_lineset(&srl->freestyleConfig);
+
+       WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene);
+       
+       return OPERATOR_FINISHED;
+}
+
+void SCENE_OT_freestyle_lineset_paste(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Paste Line Set";
+       ot->idname= "SCENE_OT_freestyle_lineset_paste";
+       ot->description="Paste the buffer content to the active line set";
+       
+       /* api callbacks */
+       ot->exec= freestyle_lineset_paste_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-20 21:02:12 UTC (rev 42024)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/FRS_freestyle.h        
2011-11-20 23:44:50 UTC (rev 42025)
@@ -67,6 +67,7 @@
        
        FreestyleLineSet *FRS_add_lineset(FreestyleConfig *config);
        void FRS_copy_active_lineset(FreestyleConfig *config);
+       void FRS_paste_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-20 21:02:12 UTC (rev 42024)
+++ 
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
     2011-11-20 23:44:50 UTC (rev 42025)
@@ -40,6 +40,10 @@
        static Controller *controller = NULL;
        static AppView *view = NULL;
 
+       // line set buffer for copy & paste
+       static FreestyleLineSet lineset_buffer;
+       static bool lineset_copied = false;
+
        // camera information
        float freestyle_viewpoint[3];
        float freestyle_mv[4][4];
@@ -66,6 +70,7 @@
                controller->setView(view);
                controller->Clear();
                freestyle_scene = NULL;
+               lineset_copied = false;
                        
                default_module_path = pathconfig->getProjectDir() + 
Config::DIR_SEP + "style_modules" + Config::DIR_SEP + "contour.py";
                        
@@ -542,6 +547,11 @@
                BLI_insertlinkafter(&config->modules, module_conf->next, 
module_conf);
        }
 
+       static void unique_lineset_name(FreestyleConfig *config, 
FreestyleLineSet *lineset)
+       {
+               BLI_uniquename(&config->linesets, lineset, "FreestyleLineSet", 
'.', offsetof(FreestyleLineSet, name), sizeof(lineset->name));
+       }
+
        FreestyleLineSet *FRS_add_lineset(FreestyleConfig *config)
        {
                int lineset_index = BLI_countlist(&config->linesets);
@@ -557,12 +567,13 @@
                lineset->qi_start = 0;
                lineset->qi_end = 100;
                lineset->edge_types = FREESTYLE_FE_SILHOUETTE | 
FREESTYLE_FE_BORDER | FREESTYLE_FE_CREASE;
+               lineset->exclude_edge_types = 0;
                lineset->group = NULL;
                if (lineset_index > 0)
                        sprintf(lineset->name, "LineSet %i", lineset_index+1);
                else
                        strcpy(lineset->name, "LineSet");
-               BLI_uniquename(&config->linesets, lineset, "FreestyleLineSet", 
'.', offsetof(FreestyleLineSet, name), sizeof(lineset->name));
+               unique_lineset_name(config, lineset);
 
                return lineset;
        }
@@ -572,20 +583,49 @@
                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;
+                       lineset_buffer.linestyle = lineset->linestyle;
+                       lineset_buffer.flags = lineset->flags;
+                       lineset_buffer.selection = lineset->selection;
+                       lineset_buffer.qi = lineset->qi;
+                       lineset_buffer.qi_start = lineset->qi_start;
+                       lineset_buffer.qi_end = lineset->qi_end;
+                       lineset_buffer.edge_types = lineset->edge_types;
+                       lineset_buffer.exclude_edge_types = 
lineset->exclude_edge_types;
+                       lineset_buffer.group = lineset->group;
+                       strcpy(lineset_buffer.name, lineset->name);
+                       lineset_copied = true;
+               }
+       }
+
+       void FRS_paste_active_lineset(FreestyleConfig *config)
+       {
+               if (!lineset_copied)
+                       return;
+
+               FreestyleLineSet *lineset = FRS_get_active_lineset(config);
+
+               if (lineset) {
+                       lineset->linestyle->id.us--;
+                       lineset->linestyle = lineset_buffer.linestyle;
+                       lineset->linestyle->id.us++;
+                       lineset->flags = lineset_buffer.flags;
+                       lineset->selection = lineset_buffer.selection;
+                       lineset->qi = lineset_buffer.qi;
+                       lineset->qi_start = lineset_buffer.qi_start;
+                       lineset->qi_end = lineset_buffer.qi_end;
+                       lineset->edge_types = lineset_buffer.edge_types;
+                       lineset->exclude_edge_types = 
lineset_buffer.exclude_edge_types;
                        if (lineset->group) {
-                               new_lineset->group = lineset->group;
-                               new_lineset->group->id.us++;
+                               lineset->group->id.us--;
+                               lineset->group = NULL;
                        }
-                       new_lineset->flags |= FREESTYLE_LINESET_CURRENT;
+                       if (lineset_buffer.group) {
+                               lineset->group = lineset_buffer.group;
+                               lineset->group->id.us++;
+                       }
+                       strcpy(lineset->name, lineset_buffer.name);
+                       unique_lineset_name(config, lineset);
+                       lineset->flags |= FREESTYLE_LINESET_CURRENT;
                }
        }
 

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to