[Bf-blender-cvs] [0c346fa] GPencil_EditStrokes: Added a "select" property to GPencil strokes

Joshua Leung noreply at git.blender.org
Sun Sep 28 17:26:52 CEST 2014


Commit: 0c346fab2cd951852af00a0fcd675403877a5f47
Author: Joshua Leung
Date:   Sat Sep 27 00:11:21 2014 +1200
Branches: GPencil_EditStrokes
https://developer.blender.org/rB0c346fab2cd951852af00a0fcd675403877a5f47

Added a "select" property to GPencil strokes

This property doesn't serve much purpose yet, but will soon be used to tag strokes
for modification by "in-viewport" stroke editing tools.

As a temporary visualisation hack, this uses the abandoned "debug" drawing mode
code, which plots out all the points of the stroke. We might want to replace this
with something nicer later, but this will do for now.

===================================================================

M	source/blender/editors/gpencil/drawgpencil.c
M	source/blender/makesdna/DNA_gpencil_types.h
M	source/blender/makesrna/intern/rna_gpencil.c

===================================================================

diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c
index 5a838d7..0b59c80 100644
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@ -200,7 +200,7 @@ static void gp_draw_stroke_point(bGPDspoint *points, short thickness, short dfla
 }
 
 /* draw a given stroke in 3d (i.e. in 3d-space), using simple ogl lines */
-static void gp_draw_stroke_3d(bGPDspoint *points, int totpoints, short thickness, short debug)
+static void gp_draw_stroke_3d(bGPDspoint *points, int totpoints, short thickness, short debug, short sflag)
 {
 	bGPDspoint *pt;
 	float curpressure = points[0].pressure;
@@ -233,7 +233,8 @@ static void gp_draw_stroke_3d(bGPDspoint *points, int totpoints, short thickness
 	glEnd();
 	
 	/* draw debug points of curve on top? */
-	if (debug) {
+	/* XXX: for now, we represent "selected" strokes in the same way as debug, which isn't used anymore */
+	if ((debug) || (sflag & GP_STROKE_SELECT)) {
 		glBegin(GL_POINTS);
 		for (i = 0, pt = points; i < totpoints && pt; i++, pt++)
 			glVertex3fv(&pt->x);
@@ -442,7 +443,8 @@ static void gp_draw_stroke(bGPDspoint *points, int totpoints, short thickness_s,
 	}
 	
 	/* draw debug points of curve on top? (original stroke points) */
-	if (debug) {
+	/* XXX: for now, we represent "selected" strokes in the same way as debug, which isn't used anymore */
+	if ((debug) || (sflag & GP_STROKE_SELECT)) {
 		bGPDspoint *pt;
 		int i;
 		
@@ -519,7 +521,7 @@ static void gp_draw_strokes(bGPDframe *gpf, int offsx, int offsy, int winx, int
 				gp_draw_stroke_point(gps->points, lthick, dflag, gps->flag, offsx, offsy, winx, winy);
 			}
 			else {
-				gp_draw_stroke_3d(gps->points, gps->totpoints, lthick, debug);
+				gp_draw_stroke_3d(gps->points, gps->totpoints, lthick, debug, gps->flag);
 			}
 			
 			if (no_xray) {
diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h
index 2bf874d..80cdf0b 100644
--- a/source/blender/makesdna/DNA_gpencil_types.h
+++ b/source/blender/makesdna/DNA_gpencil_types.h
@@ -67,6 +67,8 @@ typedef struct bGPDstroke {
 #define GP_STROKE_2DSPACE		(1<<1)
 	/* stroke is in 2d-space (but with special 'image' scaling) */
 #define GP_STROKE_2DIMAGE		(1<<2)
+	/* stroke is selected */
+#define GP_STROKE_SELECT		(1<<3)
 	/* only for use with stroke-buffer (while drawing eraser) */
 #define GP_STROKE_ERASER		(1<<15)
 
diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c
index cdedb35..39d37b8 100644
--- a/source/blender/makesrna/intern/rna_gpencil.c
+++ b/source/blender/makesrna/intern/rna_gpencil.c
@@ -336,12 +336,18 @@ static void rna_def_gpencil_stroke(BlenderRNA *brna)
 	RNA_def_property_struct_type(prop, "GPencilStrokePoint");
 	RNA_def_property_ui_text(prop, "Stroke Points", "Stroke data points");
 	rna_def_gpencil_stroke_points_api(brna, prop);
-
+	
+	/* Settings */
 	prop = RNA_def_property(srna, "draw_mode", PROP_ENUM, PROP_NONE);
 	RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
 	RNA_def_property_enum_items(prop, stroke_draw_mode_items);
 	RNA_def_property_ui_text(prop, "Draw Mode", "");
 	RNA_def_property_update(prop, 0, "rna_GPencil_update");
+	
+	prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_STROKE_SELECT);
+	RNA_def_property_ui_text(prop, "Select", "Stroke is selected for viewport editing");
+	RNA_def_property_update(prop, 0, "rna_GPencil_update");
 }
 
 static void rna_def_gpencil_strokes_api(BlenderRNA *brna, PropertyRNA *cprop)




More information about the Bf-blender-cvs mailing list