[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [20401] branches/soc-2009-chingachgook/ source/blender: Added "Collada Export" menu.

Chingiz Dyussenov chingiz.ds at gmail.com
Mon May 25 14:41:35 CEST 2009


Revision: 20401
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20401
Author:   chingachgook
Date:     2009-05-25 14:41:35 +0200 (Mon, 25 May 2009)

Log Message:
-----------
Added "Collada Export" menu. Put it in wm_operators.c temporarily. 
Will discuss placement of this code on Sunday meeting.

Modified Paths:
--------------
    branches/soc-2009-chingachgook/source/blender/collada/collada.cpp
    branches/soc-2009-chingachgook/source/blender/editors/space_info/info_header.c
    branches/soc-2009-chingachgook/source/blender/windowmanager/intern/wm_operators.c

Modified: branches/soc-2009-chingachgook/source/blender/collada/collada.cpp
===================================================================
--- branches/soc-2009-chingachgook/source/blender/collada/collada.cpp	2009-05-25 11:42:14 UTC (rev 20400)
+++ branches/soc-2009-chingachgook/source/blender/collada/collada.cpp	2009-05-25 12:41:35 UTC (rev 20401)
@@ -1,3 +1,4 @@
+#include <stdio.h>
 #include "BKE_scene.h"
 
 extern "C"
@@ -9,6 +10,7 @@
 
 	int collada_export(Scene *sce, const char *filepath)
 	{
+		fprintf(stderr, "Hello, world! %s\n", filepath);
 		return 1;
 	}
 }

Modified: branches/soc-2009-chingachgook/source/blender/editors/space_info/info_header.c
===================================================================
--- branches/soc-2009-chingachgook/source/blender/editors/space_info/info_header.c	2009-05-25 11:42:14 UTC (rev 20400)
+++ branches/soc-2009-chingachgook/source/blender/editors/space_info/info_header.c	2009-05-25 12:41:35 UTC (rev 20401)
@@ -276,6 +276,11 @@
 	uiLayoutContext(layout, WM_OP_INVOKE_AREA);
 	uiItemO(layout, NULL, 0, "WM_OT_save_as_mainfile"); 
 
+	// XXX: these should move
+	uiItemS(layout);
+	uiLayoutContext(layout, WM_OP_INVOKE_AREA);
+	uiItemO(layout, NULL, 0, "WM_OT_collada_export"); 
+
 #if 0
 	if(U.flag & USER_FILECOMPRESS) {
 		uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Compress File",	 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 35, "Enable file compression");

Modified: branches/soc-2009-chingachgook/source/blender/windowmanager/intern/wm_operators.c
===================================================================
--- branches/soc-2009-chingachgook/source/blender/windowmanager/intern/wm_operators.c	2009-05-25 11:42:14 UTC (rev 20400)
+++ branches/soc-2009-chingachgook/source/blender/windowmanager/intern/wm_operators.c	2009-05-25 12:41:35 UTC (rev 20401)
@@ -599,6 +599,64 @@
 }
 
 
+
+
+
+/* XXX: move these to a more appropriate place */
+#include "../../collada/collada.h"
+
+static int wm_collada_export_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+	//char name[FILE_MAX];
+	//BLI_strncpy(name, G.sce, FILE_MAX);
+	//untitled(name);
+
+	// XXX: temporary
+	RNA_string_set(op->ptr, "filename", "/tmp/test.dae");
+	
+	WM_event_add_fileselect(C, op);
+
+	return OPERATOR_RUNNING_MODAL;
+}
+
+/* function used for WM_OT_save_mainfile too */
+static int wm_collada_export_exec(bContext *C, wmOperator *op)
+{
+	char filename[FILE_MAX];
+	
+	if(RNA_property_is_set(op->ptr, "filename"))
+		RNA_string_get(op->ptr, "filename", filename);
+	else {
+		BLI_strncpy(filename, G.sce, FILE_MAX);
+		untitled(filename);
+	}
+	
+	//WM_write_file(C, filename, op->reports);
+	collada_export(CTX_data_scene(C), filename);
+	
+	WM_event_add_notifier(C, NC_WM|ND_FILESAVE, NULL);
+
+	return 0;
+}
+
+static void WM_OT_collada_export(wmOperatorType *ot)
+{
+	ot->name= "Collada Export";
+	ot->idname= "WM_OT_collada_export";
+	
+	ot->invoke= wm_collada_export_invoke;
+	ot->exec= wm_collada_export_exec;
+	ot->poll= WM_operator_winactive;
+	
+	ot->flag= 0;
+	
+	RNA_def_property(ot->srna, "filename", PROP_STRING, PROP_FILEPATH);
+}
+
+
+
+
+
 /* *********************** */
 
 static void WM_OT_window_fullscreen_toggle(wmOperatorType *ot)
@@ -1437,6 +1495,9 @@
 	WM_operatortype_append(WM_OT_save_mainfile);
 	WM_operatortype_append(WM_OT_ten_timer);
 	WM_operatortype_append(WM_OT_debug_menu);
+
+	/* XXX: move these */
+	WM_operatortype_append(WM_OT_collada_export);
 }
 
 /* default keymap for windows and screens, only call once per WM */





More information about the Bf-blender-cvs mailing list