[Bf-blender-cvs] [23c5eee2842] greasepencil-object: New Line Primitive
Antonio Vazquez
noreply at git.blender.org
Fri Apr 6 10:37:35 CEST 2018
Commit: 23c5eee284261368c4cb7875ec9ce2ca81a4a3e4
Author: Antonio Vazquez
Date: Fri Apr 6 10:11:04 2018 +0200
Branches: greasepencil-object
https://developer.blender.org/rB23c5eee284261368c4cb7875ec9ce2ca81a4a3e4
New Line Primitive
The straight lines could be done using Alt key while drawing, but it's better to have a simple primitive.
This has been requested by artists.
===================================================================
M release/scripts/startup/bl_ui/properties_grease_pencil_common.py
M release/scripts/startup/bl_ui/space_view3d_toolbar.py
M source/blender/editors/gpencil/gpencil_intern.h
M source/blender/editors/gpencil/gpencil_primitive.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
index d70f3cfa049..1e5656557d9 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -651,6 +651,7 @@ class GPENCIL_MT_gpencil_draw_specials(Menu):
layout.operator("gpencil.frame_clean_fill", text="Clean Boundary Strokes all Frames").mode = 'ALL'
layout.separator()
+ layout.operator("gpencil.primitive", text="Line", icon='IPO_CONSTANT').type = 'LINE'
layout.operator("gpencil.primitive", text="Rectangle", icon='UV_FACESEL').type = 'BOX'
layout.operator("gpencil.primitive", text="Circle", icon='ANTIALIASED').type = 'CIRCLE'
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 1a4e2caeb73..ad0c8c4a90c 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -2258,6 +2258,7 @@ class VIEW3D_PT_tools_grease_pencil_shapes(Panel):
layout = self.layout
col = layout.column(align=True)
+ col.operator("gpencil.primitive", text="Line", icon='IPO_CONSTANT').type = 'LINE'
col.operator("gpencil.primitive", text="Rectangle", icon='UV_FACESEL').type = 'BOX'
col.operator("gpencil.primitive", text="Circle", icon='ANTIALIASED').type = 'CIRCLE'
diff --git a/source/blender/editors/gpencil/gpencil_intern.h b/source/blender/editors/gpencil/gpencil_intern.h
index cd2b189eb14..274c1891d85 100644
--- a/source/blender/editors/gpencil/gpencil_intern.h
+++ b/source/blender/editors/gpencil/gpencil_intern.h
@@ -362,7 +362,8 @@ enum {
enum {
GP_STROKE_BOX = -1,
- GP_STROKE_CIRCLE = 1
+ GP_STROKE_LINE = 1,
+ GP_STROKE_CIRCLE = 2
};
diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c
index 489c0f4ee27..0c17728fdcc 100644
--- a/source/blender/editors/gpencil/gpencil_primitive.c
+++ b/source/blender/editors/gpencil/gpencil_primitive.c
@@ -78,7 +78,7 @@
#include "gpencil_intern.h"
-#define MIN_EDGES 3
+#define MIN_EDGES 2
#define MAX_EDGES 100
#define IDLE 0
@@ -207,7 +207,10 @@ static void gpencil_primitive_status_indicators(tGPDprimitive *tgpi)
char msg_str[UI_MAX_DRAW_STR];
if (tgpi->type == GP_STROKE_BOX) {
- BLI_strncpy(msg_str, IFACE_("GP Primitive: ESC/RMB to cancel, LMB set origin, Enter/LMB to confirm, Shift to square"), UI_MAX_DRAW_STR);
+ BLI_strncpy(msg_str, IFACE_("Rectangle: ESC/RMB to cancel, LMB set origin, Enter/LMB to confirm, Shift to square"), UI_MAX_DRAW_STR);
+ }
+ else if (tgpi->type == GP_STROKE_LINE) {
+ BLI_strncpy(msg_str, IFACE_("Line: ESC/RMB to cancel, LMB set origin, Enter/LMB to confirm"), UI_MAX_DRAW_STR);
}
else {
BLI_strncpy(msg_str, IFACE_("Circle: ESC/RMB to cancel, Enter/LMB to confirm, WHEEL to adjust edge number, Shift to square"), UI_MAX_DRAW_STR);
@@ -264,6 +267,18 @@ static void gp_primitive_rectangle(tGPDprimitive *tgpi, tGPspoint *points2D)
points2D[3].y = tgpi->bottom[1];
}
+/* create a line */
+static void gp_primitive_line(tGPDprimitive *tgpi, tGPspoint *points2D)
+{
+ BLI_assert(tgpi->tot_edges == 2);
+
+ points2D[0].x = tgpi->top[0];
+ points2D[0].y = tgpi->top[1];
+
+ points2D[1].x = tgpi->bottom[0];
+ points2D[1].y = tgpi->bottom[1];
+}
+
/* create a circle */
static void gp_primitive_circle(tGPDprimitive *tgpi, tGPspoint *points2D)
{
@@ -306,6 +321,9 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
case GP_STROKE_BOX:
gp_primitive_rectangle(tgpi, points2D);
break;
+ case GP_STROKE_LINE:
+ gp_primitive_line(tgpi, points2D);
+ break;
case GP_STROKE_CIRCLE:
gp_primitive_circle(tgpi, points2D);
break;
@@ -440,9 +458,12 @@ static void gpencil_primitive_init(bContext *C, wmOperator *op)
if (tgpi->type == GP_STROKE_CIRCLE) {
RNA_int_set(op->ptr, "edges", 32);
}
- else /* if (tgpi->type == GP_STROKE_RECTANGLE) */ {
+ else if(tgpi->type == GP_STROKE_BOX) {
RNA_int_set(op->ptr, "edges", 4);
}
+ else { /* LINE */
+ RNA_int_set(op->ptr, "edges", 2);
+ }
tgpi->tot_edges = RNA_int_get(op->ptr, "edges");
tgpi->flag = IDLE;
@@ -655,6 +676,7 @@ void GPENCIL_OT_primitive(wmOperatorType *ot)
{
static EnumPropertyItem primitive_type[] = {
{ GP_STROKE_BOX, "BOX", 0, "Box", "" },
+ { GP_STROKE_LINE, "LINE", 0, "Line", "" },
{ GP_STROKE_CIRCLE, "CIRCLE", 0, "Circle", "" },
{ 0, NULL, 0, NULL, NULL }
};
More information about the Bf-blender-cvs
mailing list