[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [38732] branches/soc-2011-onion/source/ blender/editors: smart stitch
Antony Riakiotakis
kalast at gmail.com
Tue Jul 26 17:27:58 CEST 2011
Revision: 38732
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38732
Author: psy-fi
Date: 2011-07-26 15:27:57 +0000 (Tue, 26 Jul 2011)
Log Message:
-----------
smart stitch
============================
- weight export tool: Select directory to export to.
Modified Paths:
--------------
branches/soc-2011-onion/source/blender/editors/include/ED_view3d.h
branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_image.c
branches/soc-2011-onion/source/blender/editors/space_view3d/view3d_draw.c
Modified: branches/soc-2011-onion/source/blender/editors/include/ED_view3d.h
===================================================================
--- branches/soc-2011-onion/source/blender/editors/include/ED_view3d.h 2011-07-26 14:28:25 UTC (rev 38731)
+++ branches/soc-2011-onion/source/blender/editors/include/ED_view3d.h 2011-07-26 15:27:57 UTC (rev 38732)
@@ -275,7 +275,7 @@
struct ImBuf *ED_view3d_draw_offscreen_imbuf(struct Scene *scene, struct View3D *v3d, struct ARegion *ar, int sizex, int sizey, unsigned int flag, char err_out[256]);
struct ImBuf *ED_view3d_draw_offscreen_imbuf_simple(struct Scene *scene, struct Object *camera, int width, int height, unsigned int flag, int drawtype, char err_out[256]);
-int view3d_weight_offscreen_draw(struct Scene *scene, struct View3D *v3d, struct ARegion *ar, struct Object *ob, int w, int h);
+int view3d_weight_offscreen_draw(struct Scene *scene, struct View3D *v3d, struct ARegion *ar, struct Object *ob, int w, int h, const char *directory);
struct Base *ED_view3d_give_base_under_cursor(struct bContext *C, const int mval[2]);
Modified: branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_image.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_image.c 2011-07-26 14:28:25 UTC (rev 38731)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_image.c 2011-07-26 15:27:57 UTC (rev 38732)
@@ -5594,7 +5594,7 @@
* We really don't need all checks + we need to draw only the selected object */
static int weight_layers_images_from_view_exec(bContext *C, wmOperator *op)
{
- char filename[FILE_MAX];
+ char directory[FILE_MAXDIR];
Scene *scene= CTX_data_scene(C);
View3D *v3d = CTX_wm_view3d(C);
ARegion *ar = CTX_wm_region(C);
@@ -5604,23 +5604,29 @@
int w= settings->imapaint.screen_grab_size[0];
int h= settings->imapaint.screen_grab_size[1];
- if(view3d_weight_offscreen_draw(scene, v3d, ar, ob, w, h))
+ RNA_string_get(op->ptr, "directory", directory);
+
+ if(view3d_weight_offscreen_draw(scene, v3d, ar, ob, w, h, directory))
return OPERATOR_FINISHED;
else return OPERATOR_CANCELLED;
+}
- RNA_string_get(op->ptr, "filepath", filename);
-
-
+static int weight_layers_images_from_view_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)){
+ if(RNA_property_is_set(op->ptr, "directory"))
+ return weight_layers_images_from_view_exec(C, op);
+ WM_event_add_fileselect(C, op);
+ return OPERATOR_RUNNING_MODAL;
}
void PAINT_OT_weight_layers_images_from_view(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Weight layers image from View";
+ ot->name= "Select Export Directory";
ot->idname= "PAINT_OT_weight_layers_images_from_view";
ot->description= "Make multiple png images from vertex group of the active object as seen from the current view";
/* api callbacks */
+ ot->invoke = weight_layers_images_from_view_invoke;
ot->exec= weight_layers_images_from_view_exec;
ot->poll= ED_operator_region_view3d_active;
@@ -5628,7 +5634,7 @@
ot->flag= OPTYPE_REGISTER;
/* Copied from above, may come in handy */
- RNA_def_string_file_name(ot->srna, "filepath", "", FILE_MAX, "File Path", "Name of the file");
+ WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_DIRECTORY|WM_FILESEL_RELPATH);
}
@@ -5645,14 +5651,12 @@
ToolSettings *settings= scene->toolsettings;
int w= settings->imapaint.screen_grab_size[0];
int h= settings->imapaint.screen_grab_size[1];
+ RNA_string_get(op->ptr, "directory", filename);
- if(view3d_weight_offscreen_draw(scene, v3d, ar, ob, w, h))
+ //if(view3d_weight_offscreen_draw(scene, v3d, ar, ob, w, h))
return OPERATOR_FINISHED;
- else return OPERATOR_CANCELLED;
+ //else return OPERATOR_CANCELLED;
- RNA_string_get(op->ptr, "filepath", filename);
-
-
}
void PAINT_OT_weight_layers_to_uv_images(wmOperatorType *ot)
@@ -5669,6 +5673,5 @@
/* flags */
ot->flag= OPTYPE_REGISTER;
- /* Copied from above, may come in handy */
- RNA_def_string_file_name(ot->srna, "filepath", "", FILE_MAX, "File Path", "Name of the file");
+ WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_DIRECTORY|WM_FILESEL_RELPATH);
}
Modified: branches/soc-2011-onion/source/blender/editors/space_view3d/view3d_draw.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/space_view3d/view3d_draw.c 2011-07-26 14:28:25 UTC (rev 38731)
+++ branches/soc-2011-onion/source/blender/editors/space_view3d/view3d_draw.c 2011-07-26 15:27:57 UTC (rev 38732)
@@ -2691,7 +2691,7 @@
v3d->flag |= V3D_INVALID_BACKBUF;
}
-int view3d_weight_offscreen_draw(Scene *scene, View3D *v3d, ARegion *ar, Object *ob, int w, int h)
+int view3d_weight_offscreen_draw(Scene *scene, View3D *v3d, ARegion *ar, Object *ob, int w, int h, const char *directory)
{
GPUOffScreen *ofs;
int maxsize;
@@ -2835,7 +2835,7 @@
/* Do this for each vertex group */
for(defgrp = ob->defbase.first; defgrp; defgrp = defgrp->next, defnum++){
- char filename[FILE_MAX], imagefile[1024] ;
+ char imagefile[FILE_MAX];
/* Fill the Weight buffer */
for(i = 0; i < numOfVerts; i++){
@@ -2850,15 +2850,13 @@
glReadPixels(0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
- BLI_strncpy(filename, G.main->name, 1024);
- BLI_parent_dir(filename);
- BLI_cleanup_dir(NULL, filename);
+ BLI_cleanup_dir(NULL, directory);
i = 0;
do{
if(i)
- BLI_snprintf(imagefile, 1024, "%s%s_%s.%d.png",filename, ob->id.name, defgrp->name, i-1);
+ BLI_snprintf(imagefile, 1024, "%s%s_%s.%d.png", directory, ob->id.name, defgrp->name, i-1);
else
- BLI_snprintf(imagefile, 1024, "%s%s_%s.png",filename, ob->id.name, defgrp->name);
+ BLI_snprintf(imagefile, 1024, "%s%s_%s.png", directory, ob->id.name, defgrp->name);
i++;
}while(BLI_exists(imagefile));
/* cleanup the name so that it contains no illegal characters*/
More information about the Bf-blender-cvs
mailing list