[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [24476] trunk/blender/source/blender: Grease Pencil for Nodes Editor:

Joshua Leung aligorith at gmail.com
Wed Nov 11 09:12:55 CET 2009


Revision: 24476
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24476
Author:   aligorith
Date:     2009-11-11 09:12:54 +0100 (Wed, 11 Nov 2009)

Log Message:
-----------
Grease Pencil for Nodes Editor:

This commit restores Grease Pencil functionality for the Nodes Editor. Grease Pencil data is now stored at the NodeTree level, which means that annotations remain with the NodeTree they were made for. 

Possible TODO's:
* In future, it may be worth investigating attaching Grease Pencil data to individual nodes, to allow annotations to stay attached to nodes as they are moved
* Include the settings for the 'active node' in a panel in the new NKEY region where the Grease Pencil buttons appear.

Modified Paths:
--------------
    trunk/blender/source/blender/blenloader/intern/readfile.c
    trunk/blender/source/blender/editors/gpencil/drawgpencil.c
    trunk/blender/source/blender/editors/gpencil/gpencil_edit.c
    trunk/blender/source/blender/editors/gpencil/gpencil_paint.c
    trunk/blender/source/blender/editors/include/ED_gpencil.h
    trunk/blender/source/blender/editors/space_node/node_draw.c
    trunk/blender/source/blender/editors/space_node/node_intern.h
    trunk/blender/source/blender/editors/space_node/node_ops.c
    trunk/blender/source/blender/editors/space_node/space_node.c
    trunk/blender/source/blender/editors/space_view3d/view3d_draw.c
    trunk/blender/source/blender/makesdna/DNA_node_types.h
    trunk/blender/source/blender/makesrna/intern/rna_nodetree.c

Added Paths:
-----------
    trunk/blender/source/blender/editors/space_node/node_buttons.c

Modified: trunk/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/readfile.c	2009-11-11 06:01:42 UTC (rev 24475)
+++ trunk/blender/source/blender/blenloader/intern/readfile.c	2009-11-11 08:12:54 UTC (rev 24476)
@@ -1983,6 +1983,8 @@
 	
 	if(ntree->adt) lib_link_animdata(fd, &ntree->id, ntree->adt);
 	
+	ntree->gpd= newlibadr_us(fd, id->lib, ntree->gpd);
+	
 	for(node= ntree->nodes.first; node; node= node->next)
 		node->id= newlibadr_us(fd, id->lib, node->id);
 }

Modified: trunk/blender/source/blender/editors/gpencil/drawgpencil.c
===================================================================
--- trunk/blender/source/blender/editors/gpencil/drawgpencil.c	2009-11-11 06:01:42 UTC (rev 24475)
+++ trunk/blender/source/blender/editors/gpencil/drawgpencil.c	2009-11-11 08:12:54 UTC (rev 24476)
@@ -765,31 +765,4 @@
 	draw_gpencil_3dview_ext(scene, ar, only3d);
 }
 
-/* draw grease-pencil sketches to opengl render window assuming that matrices are already set correctly */
-// XXX porting note, ogl render will probably be a window with one 3d region
-void draw_gpencil_oglrender (bContext *C)
-{
-	ScrArea *sa= CTX_wm_area(C);
-	View3D *v3d= (View3D *)sa->spacedata.first;
-	ARegion *ar= CTX_wm_region(C);
-	Scene *scene= CTX_data_scene(C);
-	bGPdata *gpd;
-	
-	/* assume gpencil data comes from v3d */
-	if (v3d == NULL) return;
-	gpd= gpencil_data_get_active(C);
-	if (gpd == NULL) return;
-	
-	/* pass 1: draw 3d-strokes ------------ > */
-	gp_draw_data(gpd, 0, 0, ar->winx, ar->winy, CFRA, (GP_DRAWDATA_NOSTATUS|GP_DRAWDATA_ONLY3D));
-	
-	/* pass 2: draw 2d-strokes ------------ > */
-		/* adjust view matrices */
-	wmOrtho2(-0.375f, (float)(ar->winx)-0.375f, -0.375f, (float)(ar->winy)-0.375f); // XXX may not be correct anymore
-	glLoadIdentity();
-	
-		/* draw it! */
-	gp_draw_data(gpd, 0, 0, ar->winx, ar->winy, CFRA, GP_DRAWDATA_NOSTATUS);
-}
-
 /* ************************************************** */

Modified: trunk/blender/source/blender/editors/gpencil/gpencil_edit.c
===================================================================
--- trunk/blender/source/blender/editors/gpencil/gpencil_edit.c	2009-11-11 06:01:42 UTC (rev 24475)
+++ trunk/blender/source/blender/editors/gpencil/gpencil_edit.c	2009-11-11 08:12:54 UTC (rev 24476)
@@ -45,6 +45,7 @@
 #include "DNA_curve_types.h"
 #include "DNA_gpencil_types.h"
 #include "DNA_object_types.h"
+#include "DNA_node_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"
 #include "DNA_space_types.h"
@@ -113,9 +114,18 @@
 			
 			case SPACE_NODE: /* Nodes Editor */
 			{
-				//SpaceNode *snode= (SpaceNode *)CTX_wm_space_data(C);
+				SpaceNode *snode= (SpaceNode *)CTX_wm_space_data(C);
 				
 				/* return the GP data for the active node block/node */
+				if (snode && snode->nodetree) {
+					/* for now, as long as there's an active node tree, default to using that in the Nodes Editor */
+					if (ptr) RNA_id_pointer_create(&snode->nodetree->id, ptr);
+					return &snode->nodetree->gpd;
+				}
+				else {
+					/* even when there is no node-tree, don't allow this to flow to scene */
+					return NULL;
+				}
 			}
 				break;
 				

Modified: trunk/blender/source/blender/editors/gpencil/gpencil_paint.c
===================================================================
--- trunk/blender/source/blender/editors/gpencil/gpencil_paint.c	2009-11-11 06:01:42 UTC (rev 24475)
+++ trunk/blender/source/blender/editors/gpencil/gpencil_paint.c	2009-11-11 08:12:54 UTC (rev 24476)
@@ -808,16 +808,17 @@
 #endif
 		}
 			break;
-#if 0 // XXX these other spaces will come over time...
+
 		case SPACE_NODE:
 		{
-			SpaceNode *snode= curarea->spacedata.first;
+			//SpaceNode *snode= curarea->spacedata.first;
 			
 			/* set current area */
 			p->sa= curarea;
 			p->ar= ar;
 			p->v2d= &ar->v2d;
 			
+#if 0 // XXX will this sort of antiquated stuff be restored?
 			/* check that gpencil data is allowed to be drawn */
 			if ((snode->flag & SNODE_DISPGP)==0) {
 				p->status= GP_STATUS_ERROR;
@@ -825,8 +826,10 @@
 					printf("Error: In active view, Grease Pencil not shown \n");
 				return;
 			}
+#endif
 		}
 			break;
+#if 0 // XXX these other spaces will come over time...
 		case SPACE_SEQ:
 		{
 			SpaceSeq *sseq= curarea->spacedata.first;
@@ -983,12 +986,13 @@
 				p->gpd->sbuffer_sflag |= GP_STROKE_3DSPACE;
 			}
 				break;
-#if 0 // XXX other spacetypes to be restored in due course
+			
 			case SPACE_NODE:
 			{
 				p->gpd->sbuffer_sflag |= GP_STROKE_2DSPACE;
 			}
 				break;
+#if 0 // XXX other spacetypes to be restored in due course
 			case SPACE_SEQ:
 			{
 				SpaceSeq *sseq= (SpaceSeq *)p->sa->spacedata.first;
@@ -1298,12 +1302,15 @@
 	tGPsdata *p = NULL;
 	wmWindow *win= CTX_wm_window(C);
 	
-	//printf("GPencil - Starting Drawing \n");
+	if (G.f & G_DEBUG)
+		printf("GPencil - Starting Drawing \n");
 	
 	/* try to initialise context data needed while drawing */
 	if (!gpencil_draw_init(C, op)) {
-		if (op->customdata) MEM_freeN(op->customdata);
-		printf("\tGP - no valid data \n");
+		if (op->customdata) 
+			MEM_freeN(op->customdata);
+		if (G.f & G_DEBUG)
+			printf("\tGP - no valid data \n");
 		return OPERATOR_CANCELLED;
 	}
 	else

Modified: trunk/blender/source/blender/editors/include/ED_gpencil.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_gpencil.h	2009-11-11 06:01:42 UTC (rev 24475)
+++ trunk/blender/source/blender/editors/include/ED_gpencil.h	2009-11-11 08:12:54 UTC (rev 24476)
@@ -73,7 +73,6 @@
 void draw_gpencil_2dview(struct bContext *C, short onlyv2d);
 void draw_gpencil_3dview(struct bContext *C, short only3d);
 void draw_gpencil_3dview_ext(struct Scene *scene, struct ARegion *ar, short only3d);
-void draw_gpencil_oglrender(struct bContext *C);
 
 void gpencil_panel_standard(const struct bContext *C, struct Panel *pa);
 

Added: trunk/blender/source/blender/editors/space_node/node_buttons.c
===================================================================
--- trunk/blender/source/blender/editors/space_node/node_buttons.c	                        (rev 0)
+++ trunk/blender/source/blender/editors/space_node/node_buttons.c	2009-11-11 08:12:54 UTC (rev 24476)
@@ -0,0 +1,138 @@
+/**
+ * $Id:
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. 
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2009 Blender Foundation.
+ * All rights reserved.
+ *
+ * 
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include <string.h>
+#include <stdio.h>
+#include <math.h>
+#include <float.h>
+
+#include "DNA_ID.h"
+#include "DNA_gpencil_types.h"
+#include "DNA_node_types.h"
+#include "DNA_space_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_screen_types.h"
+#include "DNA_userdef_types.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_math.h"
+#include "BLI_blenlib.h"
+#include "BLI_rand.h"
+
+#include "BKE_context.h"
+#include "BKE_depsgraph.h"
+#include "BKE_idprop.h"
+#include "BKE_object.h"
+#include "BKE_global.h"
+#include "BKE_scene.h"
+#include "BKE_screen.h"
+#include "BKE_utildefines.h"
+
+#include "BIF_gl.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "RNA_access.h"
+#include "RNA_define.h"
+
+#include "ED_gpencil.h"
+#include "ED_screen.h"
+#include "ED_types.h"
+#include "ED_util.h"
+
+#include "UI_interface.h"
+#include "UI_resources.h"
+#include "UI_view2d.h"
+
+#include "node_intern.h"	// own include
+
+
+/* ******************* node space & buttons ************** */
+#define B_NOP		1
+#define B_REDR		2
+
+#if 0 // XXX not used...
+static void do_node_region_buttons(bContext *C, void *arg, int event)
+{
+	//SpaceNode *snode= CTX_wm_space_node(C);
+	
+	switch(event) {
+	case B_REDR:
+		ED_area_tag_redraw(CTX_wm_area(C));
+		return; /* no notifier! */
+	}
+}
+#endif
+
+/* ******************* node buttons registration ************** */
+
+void node_buttons_register(ARegionType *art)
+{
+	PanelType *pt;
+	
+	// XXX active node
+	
+	pt= MEM_callocN(sizeof(PanelType), "spacetype node panel gpencil");
+	strcpy(pt->idname, "NODE_PT_gpencil");
+	strcpy(pt->label, "Grease Pencil");
+	pt->draw= gpencil_panel_standard;
+	BLI_addtail(&art->paneltypes, pt);
+}
+
+static int node_properties(bContext *C, wmOperator *op)
+{
+	ScrArea *sa= CTX_wm_area(C);
+	ARegion *ar= node_has_buttons_region(sa);
+	
+	if(ar)
+		ED_region_toggle_hidden(C, ar);
+
+	return OPERATOR_FINISHED;
+}
+
+/* non-standard poll operator which doesn't care if there are any nodes */
+static int node_properties_poll(bContext *C)
+{
+	ScrArea *sa= CTX_wm_area(C);
+	return (sa && (sa->spacetype == SPACE_NODE));
+}
+
+void NODE_OT_properties(wmOperatorType *ot)
+{
+	ot->name= "Properties";
+	ot->description= "Toggles the properties panel display.";
+	ot->idname= "NODE_OT_properties";
+	
+	ot->exec= node_properties;
+	ot->poll= node_properties_poll;
+	
+	/* flags */
+	ot->flag= 0;
+}

Modified: trunk/blender/source/blender/editors/space_node/node_draw.c
===================================================================
--- trunk/blender/source/blender/editors/space_node/node_draw.c	2009-11-11 06:01:42 UTC (rev 24475)
+++ trunk/blender/source/blender/editors/space_node/node_draw.c	2009-11-11 08:12:54 UTC (rev 24476)
@@ -66,14 +66,13 @@
 #include "BKE_text.h"
 #include "BKE_utildefines.h"
 
-/* #include "BDR_gpencil.h" XXX */
-
 #include "BIF_gl.h"
 #include "BIF_glutil.h"
 
 #include "WM_api.h"
 #include "WM_types.h"
 
+#include "ED_gpencil.h"
 #include "ED_screen.h"
 #include "ED_util.h"
 #include "ED_types.h"
@@ -1102,38 +1101,16 @@
 	}
 	
 	/* draw grease-pencil ('canvas' strokes) */
-	/*if ((snode->flag & SNODE_DISPGP) && (snode->nodetree))
-		draw_gpencil_2dview(sa, 1);*/

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list