[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15890] branches/soc-2008-mxcurioni/source /blender: soc-2008-mxcurioni: added a Freestyle panel to select a style at run-time, by specifying its pathname.

Maxime Curioni maxime.curioni at gmail.com
Thu Jul 31 13:20:31 CEST 2008


Revision: 15890
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15890
Author:   mxcurioni
Date:     2008-07-31 13:20:30 +0200 (Thu, 31 Jul 2008)

Log Message:
-----------
soc-2008-mxcurioni: added a Freestyle panel to select a style at run-time, by specifying its pathname. By default, it is loaded with the contour.py path.

Modified Paths:
--------------
    branches/soc-2008-mxcurioni/source/blender/blenkernel/intern/scene.c
    branches/soc-2008-mxcurioni/source/blender/freestyle/FRS_freestyle.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/api.cpp
    branches/soc-2008-mxcurioni/source/blender/include/butspace.h
    branches/soc-2008-mxcurioni/source/blender/src/SConscript
    branches/soc-2008-mxcurioni/source/blender/src/buttons_scene.c

Modified: branches/soc-2008-mxcurioni/source/blender/blenkernel/intern/scene.c
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/blenkernel/intern/scene.c	2008-07-31 08:50:12 UTC (rev 15889)
+++ branches/soc-2008-mxcurioni/source/blender/blenkernel/intern/scene.c	2008-07-31 11:20:30 UTC (rev 15890)
@@ -271,6 +271,7 @@
 	strcpy(sce->r.backbuf, "//backbuf");
 	strcpy(sce->r.pic, U.renderdir);
 
+
 	BLI_init_rctf(&sce->r.safety, 0.1f, 0.9f, 0.1f, 0.9f);
 	sce->r.osa= 8;
 

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/FRS_freestyle.h
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/FRS_freestyle.h	2008-07-31 08:50:12 UTC (rev 15889)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/FRS_freestyle.h	2008-07-31 11:20:30 UTC (rev 15890)
@@ -5,6 +5,9 @@
 extern "C" {
 #endif	
 	
+	extern char style_module[255];
+	
+	void FRS_initialize();
 	void FRS_prepare(Render* re);
 	void FRS_execute(Render* re, int render_in_layer);
 

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/api.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/api.cpp	2008-07-31 08:50:12 UTC (rev 15889)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/api.cpp	2008-07-31 11:20:30 UTC (rev 15890)
@@ -30,7 +30,8 @@
 	static Controller *controller = NULL;
 	static AppGLWidget *view = NULL;
 
-	
+	char style_module[255] = "";
+
 	void FRS_initialize(){
 		
 		if( pathconfig == NULL )
@@ -42,8 +43,14 @@
 		if( view == NULL )
 			view = new AppGLWidget;
 		
+		controller->setView(view);
 		controller->Clear();
-		controller->setView(view);
+		
+		if( strlen(style_module) == 0 ){
+			string path( pathconfig->getProjectDir() +  Config::DIR_SEP + "style_modules_blender" + Config::DIR_SEP + "contour.py" );
+			strcpy( style_module, path.c_str() );
+		}
+		
 	}
 
 
@@ -114,10 +121,8 @@
 		}
 		
 		// add style module
-		string style_module = pathconfig->getProjectDir() + 
-								Config::DIR_SEP + "style_modules_blender" + 
-								Config::DIR_SEP + "contour.py";
-		controller->InsertStyleModule( 0, const_cast<char *>(style_module.c_str()) 	 );
+		cout << "Module: " << style_module << endl;
+		controller->InsertStyleModule( 0, style_module );
 		controller->toggleLayer(0, true);
 		
 		// compute view map

Modified: branches/soc-2008-mxcurioni/source/blender/include/butspace.h
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/include/butspace.h	2008-07-31 08:50:12 UTC (rev 15889)
+++ branches/soc-2008-mxcurioni/source/blender/include/butspace.h	2008-07-31 11:20:30 UTC (rev 15890)
@@ -318,6 +318,8 @@
 #define B_FS_PIC		1601
 #define B_FS_BACKBUF	1602
 
+#define B_FS_FRS 1603
+
 #define B_FS_FTYPE		1604 /* FTYPE is no more */
 #define B_DORENDER		1605
 #define B_DOANIM		1606
@@ -372,6 +374,7 @@
 #define B_SEQ_BUT_RELOAD_FILE   1696
 #define B_SEQ_BUT_REBUILD_PROXY 1697
 #define B_SEQ_SEL_PROXY_DIR     1698
+
 /* *********************** */
 #define B_ARMATUREBUTS		1800
 #define	B_POSE			1701

Modified: branches/soc-2008-mxcurioni/source/blender/src/SConscript
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/src/SConscript	2008-07-31 08:50:12 UTC (rev 15889)
+++ branches/soc-2008-mxcurioni/source/blender/src/SConscript	2008-07-31 11:20:30 UTC (rev 15890)
@@ -27,8 +27,8 @@
 incs += ' ../../kernel/gen_system #/intern/SoundSystem ../readstreamglue ../nodes'
 incs += ' ../quicktime #/intern/elbeem/extern'
 incs += ' #/intern/ghost #/intern/opennl/extern #/extern/glew/include'
+incs += ' ../freestyle'
 
-
 incs += ' ' + env['BF_PYTHON_INC']
 incs += ' ' + env['BF_SDL_INC']
 incs += ' ' + env['BF_OPENGL_INC']

Modified: branches/soc-2008-mxcurioni/source/blender/src/buttons_scene.c
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/src/buttons_scene.c	2008-07-31 08:50:12 UTC (rev 15889)
+++ branches/soc-2008-mxcurioni/source/blender/src/buttons_scene.c	2008-07-31 11:20:30 UTC (rev 15890)
@@ -120,6 +120,8 @@
 
 #endif
 
+#include "FRS_freestyle.h"
+
 /* here the calls for scene buttons
    - render
    - world
@@ -1362,6 +1364,15 @@
 	BIF_undo_push("Change background picture");
 }
 
+static void freestyle_module(char *name)
+{
+	strcpy(style_module, name);
+	allqueue(REDRAWBUTSSCENE, 0);
+	BIF_undo_push("Change style module");
+}
+
+
+
 static void run_playanim(char *file) 
 {
 	extern char bprogname[];	/* usiblender.c */
@@ -1463,6 +1474,13 @@
 			activate_fileselect(FILE_SPECIAL, "SELECT BACKBUF PICTURE", G.scene->r.backbuf, backbuf_pic);
 		break;
 	
+	case B_FS_FRS:
+		sa= closest_bigger_area();
+		areawinset(sa->win);
+		activate_fileselect(FILE_SPECIAL, "SELECT STYLE MODULE", style_module, freestyle_module);
+		break;
+		
+	
 	case B_PR_PAL:
 		G.scene->r.xsch= 720;
 		G.scene->r.ysch= 576;
@@ -3235,6 +3253,26 @@
 }
 #endif /* disable yafray stuff */
 
+static void render_panel_freestyle()
+{
+	uiBlock *block;
+
+	if( strlen(style_module) == 0 )
+		FRS_initialize();
+
+	block= uiNewBlock(&curarea->uiblocks, "render_panel_freestyle", UI_EMBOSS, UI_HELV, curarea->win);
+	uiNewPanelTabbed("Render", "Render");
+	if(uiNewPanel(curarea, block, "Freestyle", "Render", 320, 0, 318, 204)==0) return;
+
+	// label to force a boundbox for buttons not to be centered
+	uiBlockBeginAlign(block);
+	uiDefIconBut(block, BUT, B_FS_FRS, ICON_FILESEL, 10, 190, 20, 20, 0, 0, 0, 0, 0, "Open Fileselect to get style module");
+	uiDefBut(block, TEX,0,"", 31, 190, 279, 20, style_module, 0.0,79.0, 0, 0, "Style module path name");
+	uiBlockEndAlign(block);
+
+
+}
+
 static void layer_copy_func(void *lay_v, void *lay_p)
 {
 	unsigned int *lay= lay_p;
@@ -3453,6 +3491,11 @@
 	}
 #endif
 
+	if (G.scene->r.renderer==R_FREESTYLE) {
+		render_panel_freestyle();
+	}
+
+
 }
 
 /* --------------------------------------------- */





More information about the Bf-blender-cvs mailing list