[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [37572] branches/soc-2011-onion/source/ blender/editors/uvedit/uvedit_ops.c: Modal operator for stitching.
Ryakiotakis Antonis
kalast at gmail.com
Fri Jun 17 00:29:05 CEST 2011
Revision: 37572
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37572
Author: psy-fi
Date: 2011-06-16 22:29:04 +0000 (Thu, 16 Jun 2011)
Log Message:
-----------
Modal operator for stitching. Still a lot todo
Modified Paths:
--------------
branches/soc-2011-onion/source/blender/editors/uvedit/uvedit_ops.c
Modified: branches/soc-2011-onion/source/blender/editors/uvedit/uvedit_ops.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/uvedit/uvedit_ops.c 2011-06-16 20:16:50 UTC (rev 37571)
+++ branches/soc-2011-onion/source/blender/editors/uvedit/uvedit_ops.c 2011-06-16 22:29:04 UTC (rev 37572)
@@ -1123,6 +1123,19 @@
int count;
} UVVertAverage;
+static int stitch_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
+{
+ ScrArea *sa= CTX_wm_area(C);
+
+ if(sa) {
+ char str[] = "V(ertices): E(dges): P(review): L(imit): S(nap): Wheel(limit adjust):";
+ ED_area_headerprint(sa, str);
+ }
+ WM_event_add_modal_handler(C, op);
+ return OPERATOR_RUNNING_MODAL;
+}
+
+
static int stitch_exec(bContext *C, wmOperator *op)
{
SpaceImage *sima;
@@ -1289,6 +1302,75 @@
return OPERATOR_FINISHED;
}
+
+static int stitch_modal(bContext *C, wmOperator *op, wmEvent *event)
+{
+ float limit;
+ int returnValue;
+ ScrArea *sa= CTX_wm_area(C);;
+
+ switch(event->type){
+ /* Cancel */
+ case ESCKEY:
+ if(sa)
+ ED_area_headerprint(sa, NULL);
+ return OPERATOR_CANCELLED;
+
+ /* Select verts/edges*/
+ case RIGHTMOUSE:
+ return OPERATOR_RUNNING_MODAL;
+
+ case LEFTMOUSE:
+ case PADENTER:
+ returnValue = stitch_exec(C, op);
+ if(sa)
+ ED_area_headerprint(sa, NULL);
+ return returnValue;
+
+ /* Increase limit */
+ case PADPLUSKEY:
+ case WHEELUPMOUSE:
+ limit = RNA_float_get(op->ptr, "limit");
+ limit += 0.01;
+ RNA_float_set(op->ptr, "limit", limit);
+ return OPERATOR_RUNNING_MODAL;
+
+ /* Decrease limit */
+ case PADMINUS:
+ case WHEELDOWNMOUSE:
+ limit = RNA_float_get(op->ptr, "limit");
+ limit -= 0.01;
+ RNA_float_set(op->ptr, "limit", limit);
+ return OPERATOR_RUNNING_MODAL;
+
+ /* Use Limit (Default off)*/
+ case LKEY:
+ returnValue = RNA_boolean_get(op->ptr, "use_limit");
+ RNA_boolean_set(op->ptr, "use_limit", !returnValue);
+ return OPERATOR_RUNNING_MODAL;
+
+ /* Use Edge selection */
+ case EKEY:
+ return OPERATOR_RUNNING_MODAL;
+
+ /* Use vertex selection */
+ case VKEY:
+ return OPERATOR_RUNNING_MODAL;
+
+ /* turn preview on/off */
+ case PKEY:
+ return OPERATOR_RUNNING_MODAL;
+
+ /* snap islands on/off */
+ case SKEY:
+ return OPERATOR_RUNNING_MODAL;
+
+ default:
+ return OPERATOR_RUNNING_MODAL;
+ }
+}
+
+
static void UV_OT_stitch(wmOperatorType *ot)
{
/* identifiers */
@@ -1298,11 +1380,13 @@
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
/* api callbacks */
+ ot->invoke = stitch_invoke;
+ ot->modal = stitch_modal;
ot->exec= stitch_exec;
ot->poll= ED_operator_uvedit;
/* properties */
- RNA_def_boolean(ot->srna, "use_limit", 1, "Use Limit", "Stitch UVs within a specified limit distance.");
+ RNA_def_boolean(ot->srna, "use_limit", 0, "Use Limit", "Stitch UVs within a specified limit distance.");
RNA_def_float(ot->srna, "limit", 0.01f, 0.0f, FLT_MAX, "Limit", "Limit distance in normalized coordinates.", -FLT_MAX, FLT_MAX);
}
More information about the Bf-blender-cvs
mailing list