Skip to content
Snippets Groups Projects
Commit 1b8c14b4 authored by Tamito Kajiyama's avatar Tamito Kajiyama
Browse files

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.
parent 2676f2d5
No related branches found
No related tags found
No related merge requests found
...@@ -180,7 +180,8 @@ class RENDER_MT_lineset_specials(Menu): ...@@ -180,7 +180,8 @@ class RENDER_MT_lineset_specials(Menu):
def draw(self, context): def draw(self, context):
layout = self.layout 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): class RENDER_PT_freestyle(RenderButtonsPanel, Panel):
......
...@@ -58,6 +58,7 @@ void SCENE_OT_freestyle_module_remove(struct wmOperatorType *ot); ...@@ -58,6 +58,7 @@ void SCENE_OT_freestyle_module_remove(struct wmOperatorType *ot);
void SCENE_OT_freestyle_module_move(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_add(struct wmOperatorType *ot);
void SCENE_OT_freestyle_lineset_copy(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_remove(struct wmOperatorType *ot);
void SCENE_OT_freestyle_lineset_move(struct wmOperatorType *ot); void SCENE_OT_freestyle_lineset_move(struct wmOperatorType *ot);
void SCENE_OT_freestyle_linestyle_new(struct wmOperatorType *ot); void SCENE_OT_freestyle_linestyle_new(struct wmOperatorType *ot);
......
...@@ -67,6 +67,7 @@ void ED_operatortypes_render(void) ...@@ -67,6 +67,7 @@ void ED_operatortypes_render(void)
WM_operatortype_append(SCENE_OT_freestyle_module_move); WM_operatortype_append(SCENE_OT_freestyle_module_move);
WM_operatortype_append(SCENE_OT_freestyle_lineset_add); WM_operatortype_append(SCENE_OT_freestyle_lineset_add);
WM_operatortype_append(SCENE_OT_freestyle_lineset_copy); 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_remove);
WM_operatortype_append(SCENE_OT_freestyle_lineset_move); WM_operatortype_append(SCENE_OT_freestyle_lineset_move);
WM_operatortype_append(SCENE_OT_freestyle_linestyle_new); WM_operatortype_append(SCENE_OT_freestyle_linestyle_new);
......
...@@ -718,7 +718,7 @@ void SCENE_OT_freestyle_lineset_copy(wmOperatorType *ot) ...@@ -718,7 +718,7 @@ void SCENE_OT_freestyle_lineset_copy(wmOperatorType *ot)
/* identifiers */ /* identifiers */
ot->name= "Copy Line Set"; ot->name= "Copy Line Set";
ot->idname= "SCENE_OT_freestyle_lineset_copy"; 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 */ /* api callbacks */
ot->exec= freestyle_lineset_copy_exec; ot->exec= freestyle_lineset_copy_exec;
...@@ -727,6 +727,34 @@ void SCENE_OT_freestyle_lineset_copy(wmOperatorType *ot) ...@@ -727,6 +727,34 @@ void SCENE_OT_freestyle_lineset_copy(wmOperatorType *ot)
/* flags */ /* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; 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)) static int freestyle_lineset_remove_exec(bContext *C, wmOperator *UNUSED(op))
{ {
Scene *scene= CTX_data_scene(C); Scene *scene= CTX_data_scene(C);
......
...@@ -67,6 +67,7 @@ extern "C" { ...@@ -67,6 +67,7 @@ extern "C" {
FreestyleLineSet *FRS_add_lineset(FreestyleConfig *config); FreestyleLineSet *FRS_add_lineset(FreestyleConfig *config);
void FRS_copy_active_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_delete_active_lineset(FreestyleConfig *config);
void FRS_move_active_lineset_up(FreestyleConfig *config); void FRS_move_active_lineset_up(FreestyleConfig *config);
void FRS_move_active_lineset_down(FreestyleConfig *config); void FRS_move_active_lineset_down(FreestyleConfig *config);
......
...@@ -40,6 +40,10 @@ extern "C" { ...@@ -40,6 +40,10 @@ extern "C" {
static Controller *controller = NULL; static Controller *controller = NULL;
static AppView *view = NULL; static AppView *view = NULL;
// line set buffer for copy & paste
static FreestyleLineSet lineset_buffer;
static bool lineset_copied = false;
// camera information // camera information
float freestyle_viewpoint[3]; float freestyle_viewpoint[3];
float freestyle_mv[4][4]; float freestyle_mv[4][4];
...@@ -66,6 +70,7 @@ extern "C" { ...@@ -66,6 +70,7 @@ extern "C" {
controller->setView(view); controller->setView(view);
controller->Clear(); controller->Clear();
freestyle_scene = NULL; freestyle_scene = NULL;
lineset_copied = false;
default_module_path = pathconfig->getProjectDir() + Config::DIR_SEP + "style_modules" + Config::DIR_SEP + "contour.py"; default_module_path = pathconfig->getProjectDir() + Config::DIR_SEP + "style_modules" + Config::DIR_SEP + "contour.py";
...@@ -542,6 +547,11 @@ extern "C" { ...@@ -542,6 +547,11 @@ extern "C" {
BLI_insertlinkafter(&config->modules, module_conf->next, module_conf); 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) FreestyleLineSet *FRS_add_lineset(FreestyleConfig *config)
{ {
int lineset_index = BLI_countlist(&config->linesets); int lineset_index = BLI_countlist(&config->linesets);
...@@ -557,12 +567,13 @@ extern "C" { ...@@ -557,12 +567,13 @@ extern "C" {
lineset->qi_start = 0; lineset->qi_start = 0;
lineset->qi_end = 100; lineset->qi_end = 100;
lineset->edge_types = FREESTYLE_FE_SILHOUETTE | FREESTYLE_FE_BORDER | FREESTYLE_FE_CREASE; lineset->edge_types = FREESTYLE_FE_SILHOUETTE | FREESTYLE_FE_BORDER | FREESTYLE_FE_CREASE;
lineset->exclude_edge_types = 0;
lineset->group = NULL; lineset->group = NULL;
if (lineset_index > 0) if (lineset_index > 0)
sprintf(lineset->name, "LineSet %i", lineset_index+1); sprintf(lineset->name, "LineSet %i", lineset_index+1);
else else
strcpy(lineset->name, "LineSet"); strcpy(lineset->name, "LineSet");
BLI_uniquename(&config->linesets, lineset, "FreestyleLineSet", '.', offsetof(FreestyleLineSet, name), sizeof(lineset->name)); unique_lineset_name(config, lineset);
return lineset; return lineset;
} }
...@@ -572,20 +583,49 @@ extern "C" { ...@@ -572,20 +583,49 @@ extern "C" {
FreestyleLineSet *lineset = FRS_get_active_lineset(config); FreestyleLineSet *lineset = FRS_get_active_lineset(config);
if (lineset) { if (lineset) {
FreestyleLineSet *new_lineset = FRS_add_lineset(config); lineset_buffer.linestyle = lineset->linestyle;
new_lineset->linestyle = lineset->linestyle; lineset_buffer.flags = lineset->flags;
new_lineset->linestyle->id.us++; lineset_buffer.selection = lineset->selection;
new_lineset->flags = lineset->flags; lineset_buffer.qi = lineset->qi;
new_lineset->selection = lineset->selection; lineset_buffer.qi_start = lineset->qi_start;
new_lineset->qi = lineset->qi; lineset_buffer.qi_end = lineset->qi_end;
new_lineset->qi_start = lineset->qi_start; lineset_buffer.edge_types = lineset->edge_types;
new_lineset->qi_end = lineset->qi_end; lineset_buffer.exclude_edge_types = lineset->exclude_edge_types;
new_lineset->edge_types = lineset->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) { if (lineset->group) {
new_lineset->group = lineset->group; lineset->group->id.us--;
new_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;
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment