[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18931] branches/blender2.5/blender/source /blender/editors: 2.5: Curve edit mode.

Brecht Van Lommel brecht at blender.org
Thu Feb 12 00:02:23 CET 2009


Revision: 18931
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18931
Author:   blendix
Date:     2009-02-12 00:02:21 +0100 (Thu, 12 Feb 2009)

Log Message:
-----------
2.5: Curve edit mode. Transform works again, and editcurve.c is
partly operatorized though nothing hooked up yet.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/curve/curve_intern.h
    branches/blender2.5/blender/source/blender/editors/curve/curve_ops.c
    branches/blender2.5/blender/source/blender/editors/curve/editcurve.c
    branches/blender2.5/blender/source/blender/editors/mesh/editmesh_mods.c
    branches/blender2.5/blender/source/blender/editors/mesh/editmesh_tools.c
    branches/blender2.5/blender/source/blender/editors/screen/screen_ops.c
    branches/blender2.5/blender/source/blender/editors/transform/transform_conversions.c
    branches/blender2.5/blender/source/blender/editors/transform/transform_generics.c

Modified: branches/blender2.5/blender/source/blender/editors/curve/curve_intern.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/curve/curve_intern.h	2009-02-11 19:16:14 UTC (rev 18930)
+++ branches/blender2.5/blender/source/blender/editors/curve/curve_intern.h	2009-02-11 23:02:21 UTC (rev 18931)
@@ -38,5 +38,38 @@
 /* editfont.c */
 void FONT_OT_textedit(struct wmOperatorType *ot);
 
+/* editcurve.c */
+void CURVE_OT_separate(struct wmOperatorType *ot);
+void CURVE_OT_switch_direction(struct wmOperatorType *ot);
+void CURVE_OT_set_weight(struct wmOperatorType *ot);
+void CURVE_OT_set_radius(struct wmOperatorType *ot);
+void CURVE_OT_smooth(struct wmOperatorType *ot);
+void CURVE_OT_smooth_curve_radius(struct wmOperatorType *ot);
+void CURVE_OT_de_select_first(struct wmOperatorType *ot);
+void CURVE_OT_de_select_last(struct wmOperatorType *ot);
+void CURVE_OT_de_select_all(struct wmOperatorType *ot);
+void CURVE_OT_hide(struct wmOperatorType *ot);
+void CURVE_OT_reveal(struct wmOperatorType *ot);
+void CURVE_OT_select_invert(struct wmOperatorType *ot);
+void CURVE_OT_subdivide(struct wmOperatorType *ot);
+void CURVE_OT_set_spline_type(struct wmOperatorType *ot);
+void CURVE_OT_make_segment(struct wmOperatorType *ot);
+void CURVE_OT_spin(struct wmOperatorType *ot);
+void CURVE_OT_add_vertex(struct wmOperatorType *ot);
+void CURVE_OT_extrude(struct wmOperatorType *ot);
+void CURVE_OT_make_cyclic(struct wmOperatorType *ot);
+void CURVE_OT_select_linked(struct wmOperatorType *ot);
+void CURVE_OT_select_row(struct wmOperatorType *ot);
+void CURVE_OT_select_next(struct wmOperatorType *ot);
+void CURVE_OT_select_previous(struct wmOperatorType *ot);
+void CURVE_OT_select_more(struct wmOperatorType *ot);
+void CURVE_OT_select_less(struct wmOperatorType *ot);
+void CURVE_OT_select_random(struct wmOperatorType *ot);
+void CURVE_OT_select_every_nth(struct wmOperatorType *ot);
+void CURVE_OT_add_duplicate(struct wmOperatorType *ot);
+void CURVE_OT_delete(struct wmOperatorType *ot);
+void CURVE_OT_set_smooth(struct wmOperatorType *ot);
+void CURVE_OT_clear_tilt(struct wmOperatorType *ot);
+
 #endif /* ED_UTIL_INTERN_H */
 

Modified: branches/blender2.5/blender/source/blender/editors/curve/curve_ops.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/curve/curve_ops.c	2009-02-11 19:16:14 UTC (rev 18930)
+++ branches/blender2.5/blender/source/blender/editors/curve/curve_ops.c	2009-02-11 23:02:21 UTC (rev 18931)
@@ -64,6 +64,38 @@
 void ED_operatortypes_curve(void)
 {
 	WM_operatortype_append(FONT_OT_textedit);
+
+	WM_operatortype_append(CURVE_OT_separate);
+	WM_operatortype_append(CURVE_OT_switch_direction);
+	WM_operatortype_append(CURVE_OT_set_weight);
+	WM_operatortype_append(CURVE_OT_set_radius);
+	WM_operatortype_append(CURVE_OT_smooth);
+	WM_operatortype_append(CURVE_OT_smooth_curve_radius);
+	WM_operatortype_append(CURVE_OT_de_select_first);
+	WM_operatortype_append(CURVE_OT_de_select_last);
+	WM_operatortype_append(CURVE_OT_de_select_all);
+	WM_operatortype_append(CURVE_OT_hide);
+	WM_operatortype_append(CURVE_OT_reveal);
+	WM_operatortype_append(CURVE_OT_select_invert);
+	WM_operatortype_append(CURVE_OT_subdivide);
+	WM_operatortype_append(CURVE_OT_set_spline_type);
+	WM_operatortype_append(CURVE_OT_make_segment);
+	WM_operatortype_append(CURVE_OT_spin);
+	WM_operatortype_append(CURVE_OT_add_vertex);
+	WM_operatortype_append(CURVE_OT_extrude);
+	WM_operatortype_append(CURVE_OT_make_cyclic);
+	WM_operatortype_append(CURVE_OT_select_linked);
+	WM_operatortype_append(CURVE_OT_select_row);
+	WM_operatortype_append(CURVE_OT_select_next);
+	WM_operatortype_append(CURVE_OT_select_previous);
+	WM_operatortype_append(CURVE_OT_select_more);
+	WM_operatortype_append(CURVE_OT_select_less);
+	WM_operatortype_append(CURVE_OT_select_random);
+	WM_operatortype_append(CURVE_OT_select_every_nth);
+	WM_operatortype_append(CURVE_OT_add_duplicate);
+	WM_operatortype_append(CURVE_OT_delete);
+	WM_operatortype_append(CURVE_OT_set_smooth);
+	WM_operatortype_append(CURVE_OT_clear_tilt);
 }
 
 void ED_keymap_curve(wmWindowManager *wm)
@@ -77,6 +109,5 @@
 	keymap= WM_keymap_listbase(wm, "Curve", 0, 0);
 	
 	WM_keymap_add_item(keymap, "OBJECT_OT_curve_add", AKEY, KM_PRESS, KM_SHIFT, 0);
-
 }
 

Modified: branches/blender2.5/blender/source/blender/editors/curve/editcurve.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/curve/editcurve.c	2009-02-11 19:16:14 UTC (rev 18930)
+++ branches/blender2.5/blender/source/blender/editors/curve/editcurve.c	2009-02-11 23:02:21 UTC (rev 18931)
@@ -59,11 +59,12 @@
 #include "BKE_curve.h"
 #include "BKE_depsgraph.h"
 #include "BKE_fcurve.h"
+#include "BKE_global.h"
 #include "BKE_key.h"
 #include "BKE_library.h"
-#include "BKE_global.h"
 #include "BKE_main.h"
 #include "BKE_object.h"
+#include "BKE_report.h"
 #include "BKE_utildefines.h"
 
 #include "WM_api.h"
@@ -72,10 +73,16 @@
 #include "ED_anim_api.h"
 #include "ED_keyframes_edit.h"
 #include "ED_object.h"
+#include "ED_screen.h"
 #include "ED_types.h"
 #include "ED_util.h"
 #include "ED_view3d.h"
 
+#include "UI_interface.h"
+
+#include "RNA_access.h"
+#include "RNA_define.h"
+
 /* still need to eradicate a few :( */
 #define callocstructN(x,y,name) (x*)MEM_callocN((y)* sizeof(x),name)
 
@@ -84,12 +91,8 @@
 
 /* XXX */
 static void BIF_undo_push() {}
-static void waitcursor() {}
-static void error() {}
 static int okee() {return 0;}
 static int pupmenu() {return 0;}
-static int button() {return 0;}
-static float fbutton() {return 0;}
 static void adduplicate() {}
 static void error_libdata() {}
 /* XXX */
@@ -373,9 +376,12 @@
 	}
 }
 
-void separate_nurb(Scene *scene)
+/******************** XXX separate operator ***********************/
+
+static int separate_exec(bContext *C, wmOperator *op)
 {
-	Object *obedit= scene->obedit; // XXX use context
+	Scene *scene= CTX_data_scene(C);
+	Object *obedit= CTX_data_edit_object(C);
 	ListBase *editnurb= curve_get_editcurve(obedit);
 	View3D *v3d= NULL; // XXX
 	Nurb *nu, *nu1;
@@ -384,17 +390,13 @@
 	Curve *cu;
 	ListBase editnurbo;
 
-	if( v3d==0 || (v3d->lay & obedit->lay)==0 ) return;
-
-	if(okee("Separate")==0) return;
-
-	waitcursor(1);
-	
 	cu= obedit->data;
 	if(cu->key) {
-		error("Can't separate a curve with vertex keys");
-		return;
+		BKE_report(op->reports, RPT_ERROR, "Can't separate a curve with vertex keys");
+		return OPERATOR_CANCELLED;
 	}
+
+	WM_cursor_wait(1);
 	
 	/* we are going to trick everything as follows:
 	 * 1. duplicate base: this is the new one,  remember old pointer
@@ -445,22 +447,39 @@
 	*editnurb= editnurbo;
 	
 	obedit= 0;	/* displists behave different in edit mode */
-	DAG_object_flush_update(scene, OBACT, OB_RECALC_DATA);	/* this is the separated one */
+	DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);	/* this is the separated one */
 	DAG_object_flush_update(scene, oldob, OB_RECALC_DATA);	/* this is the original one */
 	
 	obedit= oldob;
 	BASACT= oldbase;
 	BASACT->flag |= SELECT;
 	
-	waitcursor(0);
+	set_actNurb(obedit, NULL);
 
-	set_actNurb(obedit, NULL);
+	WM_cursor_wait(0);
+
+	// XXX notifier
+
+	return OPERATOR_FINISHED;
 }
 
+void CURVE_OT_separate(wmOperatorType *ot)
+{
+	/* identifiers */
+	ot->name= "Separate";
+	ot->idname= "CURVE_OT_separate";
+	
+	/* api callbacks */
+	ot->exec= separate_exec;
+	ot->poll= ED_operator_editcurve;
+	
+	/* flags */
+	ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
 /* ******************* FLAGS ********************* */
 
-
-short isNurbselUV(Nurb *nu, int *u, int *v, int flag)
+static short isNurbselUV(Nurb *nu, int *u, int *v, int flag)
 {
 	/* return u!=-1:     1 row in u-direction selected. U has value between 0-pntsv 
      * return v!=-1: 1 collumn in v-direction selected. V has value between 0-pntsu 
@@ -501,7 +520,7 @@
 	return 0;
 }
 
-void setflagsNurb(ListBase *editnurb, short flag)
+static void setflagsNurb(ListBase *editnurb, short flag)
 {
 	Nurb *nu;
 	BezTriple *bezt;
@@ -528,7 +547,7 @@
 	}
 }
 
-void rotateflagNurb(ListBase *editnurb, short flag, float *cent, float rotmat[][3])
+static void rotateflagNurb(ListBase *editnurb, short flag, float *cent, float rotmat[][3])
 {
 	/* all verts with (flag & 'flag') rotate */
 	Nurb *nu;
@@ -556,8 +575,7 @@
 	}
 }
 
-
-void translateflagNurb(ListBase *editnurb, short flag, float *vec)
+static void translateflagNurb(ListBase *editnurb, short flag, float *vec)
 {
 	/* all verts with ('flag' & flag) translate */
 	Nurb *nu;
@@ -589,7 +607,7 @@
 	}
 }
 
-void weightflagNurb(ListBase *editnurb, short flag, float w, int mode)	/* mode==0: replace, mode==1: multiply */
+static void weightflagNurb(ListBase *editnurb, short flag, float w, int mode)	/* mode==0: replace, mode==1: multiply */
 {
 	Nurb *nu;
 	BPoint *bp;
@@ -610,9 +628,9 @@
 	}
 }
 
-void deleteflagNurb(Scene *scene, short flag)
+static int deleteflagNurb(bContext *C, wmOperator *op, int flag)
 {
-	Object *obedit= scene->obedit; // XXX use context
+	Object *obedit= CTX_data_edit_object(C);
 	Curve *cu= obedit->data;
 	ListBase *editnurb= curve_get_editcurve(obedit);
 	Nurb *nu, *next;
@@ -620,7 +638,7 @@
 	int a, b, newu, newv, sel;
 
 	if(obedit && obedit->type==OB_SURF);
-	else return;
+	else return OPERATOR_CANCELLED;
 
 	cu->lastselbp= NULL;
 
@@ -727,10 +745,12 @@
 		}
 		nu= next;
 	}
+
+	return OPERATOR_FINISHED;
 }
 
 /* only for OB_SURF */
-short extrudeflagNurb(ListBase *editnurb, int flag)
+static short extrudeflagNurb(ListBase *editnurb, int flag)
 {
 	Nurb *nu;
 	BPoint *bp, *bpn, *newbp;
@@ -847,9 +867,8 @@
 	return ok;
 }
 
-void adduplicateflagNurb(Scene *scene, short flag)
+static void adduplicateflagNurb(Object *obedit, short flag)
 {
-	Object *obedit= scene->obedit; // XXX context
 	ListBase *editnurb= curve_get_editcurve(obedit);
 	Nurb *nu, *newnu;
 	BezTriple *bezt, *bezt1;
@@ -1018,139 +1037,153 @@
 	/* actnu changed */
 }
 
+/**************** switch direction operator ***************/
 
-void switchdirectionNurb2(Scene *scene)
+static int switch_direction_exec(bContext *C, wmOperator *op)
 {
-	Object *obedit= scene->obedit; // XXX use context
+	Object *obedit= CTX_data_edit_object(C);
 	ListBase *editnurb= curve_get_editcurve(obedit);
-	View3D *v3d= NULL; // XXX
 	Nurb *nu;
 	
-	if(v3d==0 || !(obedit->lay & v3d->lay))
-		return;
+	for(nu= editnurb->first; nu; nu= nu->next)
+		if(isNurbsel(nu))
+			switchdirectionNurb(nu);
 	

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list