[Bf-committers] [Bf-blender-cvs] SVN commit: /data/svn/bf-blender [28923] trunk/blender:

Michael Fox mfoxdogg at gmail.com
Sun May 23 04:15:20 CEST 2010


Crap log message didn't go through :S

anyway this commit is to make the add_curve operator more atomic/modular
to be inline with the add mesh operators, this also allows for add_curve
addons to be un the curve menu instead of add mesh

the old operator is still there until all addons scripts are ported to
the new operators then it can be saftly removed

On Sun, 2010-05-23 at 04:02 +0200, Michael Fox wrote:
> Revision: 28923
>           http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=28923
> Author:   mfoxdogg
> Date:     2010-05-23 04:02:04 +0200 (Sun, 23 May 2010)
> 
> Log Message:
> -----------
> 
> 
> Modified Paths:
> --------------
>     trunk/blender/release/scripts/ui/space_info.py
>     trunk/blender/source/blender/editors/curve/curve_intern.h
>     trunk/blender/source/blender/editors/curve/curve_ops.c
>     trunk/blender/source/blender/editors/curve/editcurve.c
> 
> Modified: trunk/blender/release/scripts/ui/space_info.py
> ===================================================================
> --- trunk/blender/release/scripts/ui/space_info.py	2010-05-23 00:09:56 UTC (rev 28922)
> +++ trunk/blender/release/scripts/ui/space_info.py	2010-05-23 02:02:04 UTC (rev 28923)
> @@ -199,7 +199,19 @@
>          layout.operator("mesh.primitive_grid_add", icon='MESH_GRID', text="Grid")
>          layout.operator("mesh.primitive_monkey_add", icon='MESH_MONKEY', text="Monkey")
>  
> +class INFO_MT_curve_add(bpy.types.Menu):
> +    bl_idname = "INFO_MT_curve_add"
> +    bl_label = "Curve"
>  
> +    def draw(self, context):
> +        layout = self.layout
> +        layout.operator_context = 'INVOKE_REGION_WIN'
> +        layout.operator("curve.primitive_bezier_add", icon='CURVE_BEZCURVE', text="Bezier")
> +        layout.operator("curve.primitive_bezier_circle_add", icon='CURVE_BEZCIRCLE', text="Circle")
> +        layout.operator("curve.primitive_nurbs_curve_add", icon='CURVE_NCURVE', text="Nurbs Curve")
> +        layout.operator("curve.primitive_nurbs_circle_add", icon='CURVE_NCIRCLE', text="Nurbs Circle")
> +        layout.operator("curve.primitive_curve_path_add", icon='CURVE_PATH', text="Path")
> +
>  class INFO_MT_armature_add(bpy.types.Menu):
>      bl_idname = "INFO_MT_armature_add"
>      bl_label = "Armature"
> @@ -221,7 +233,8 @@
>          #layout.operator_menu_enum("object.mesh_add", "type", text="Mesh", icon='OUTLINER_OB_MESH')
>          layout.menu("INFO_MT_mesh_add", icon='OUTLINER_OB_MESH')
>  
> -        layout.operator_menu_enum("object.curve_add", "type", text="Curve", icon='OUTLINER_OB_CURVE')
> +        #layout.operator_menu_enum("object.curve_add", "type", text="Curve", icon='OUTLINER_OB_CURVE')
> +        layout.menu("INFO_MT_curve_add", icon='OUTLINER_OB_CURVE')
>          layout.operator_menu_enum("object.surface_add", "type", text="Surface", icon='OUTLINER_OB_SURFACE')
>          layout.operator_menu_enum("object.metaball_add", "type", text="Metaball", icon='OUTLINER_OB_META')
>          layout.operator("object.text_add", text="Text", icon='OUTLINER_OB_FONT')
> @@ -416,6 +429,7 @@
>      INFO_MT_file_external_data,
>      INFO_MT_add,
>      INFO_MT_mesh_add,
> +    INFO_MT_curve_add,
>      INFO_MT_armature_add,
>      INFO_MT_game,
>      INFO_MT_render,
> 
> Modified: trunk/blender/source/blender/editors/curve/curve_intern.h
> ===================================================================
> --- trunk/blender/source/blender/editors/curve/curve_intern.h	2010-05-23 00:09:56 UTC (rev 28922)
> +++ trunk/blender/source/blender/editors/curve/curve_intern.h	2010-05-23 02:02:04 UTC (rev 28923)
> @@ -85,6 +85,12 @@
>  void CURVE_OT_smooth(struct wmOperatorType *ot);
>  void CURVE_OT_smooth_radius(struct wmOperatorType *ot);
>  
> +void CURVE_OT_primitive_bezier_add(struct wmOperatorType *ot);
> +void CURVE_OT_primitive_bezier_circle_add(struct wmOperatorType *ot);
> +void CURVE_OT_primitive_nurbs_curve_add(struct wmOperatorType *ot);
> +void CURVE_OT_primitive_nurbs_circle_add(struct wmOperatorType *ot);
> +void CURVE_OT_primitive_curve_path_add(struct wmOperatorType *ot);
> +
>  void CURVE_OT_de_select_first(struct wmOperatorType *ot);
>  void CURVE_OT_de_select_last(struct wmOperatorType *ot);
>  void CURVE_OT_select_all(struct wmOperatorType *ot);
> 
> Modified: trunk/blender/source/blender/editors/curve/curve_ops.c
> ===================================================================
> --- trunk/blender/source/blender/editors/curve/curve_ops.c	2010-05-23 00:09:56 UTC (rev 28922)
> +++ trunk/blender/source/blender/editors/curve/curve_ops.c	2010-05-23 02:02:04 UTC (rev 28923)
> @@ -96,6 +96,12 @@
>  	WM_operatortype_append(CURVE_OT_shade_smooth);
>  	WM_operatortype_append(CURVE_OT_shade_flat);
>  	WM_operatortype_append(CURVE_OT_tilt_clear);
> +	
> +	WM_operatortype_append(CURVE_OT_primitive_bezier_add);
> +	WM_operatortype_append(CURVE_OT_primitive_bezier_circle_add);
> +	WM_operatortype_append(CURVE_OT_primitive_nurbs_curve_add);
> +	WM_operatortype_append(CURVE_OT_primitive_nurbs_circle_add);
> +	WM_operatortype_append(CURVE_OT_primitive_curve_path_add);
>  
>  	WM_operatortype_append(CURVE_OT_smooth);
>  	WM_operatortype_append(CURVE_OT_smooth_radius);
> 
> Modified: trunk/blender/source/blender/editors/curve/editcurve.c
> ===================================================================
> --- trunk/blender/source/blender/editors/curve/editcurve.c	2010-05-23 00:09:56 UTC (rev 28922)
> +++ trunk/blender/source/blender/editors/curve/editcurve.c	2010-05-23 02:02:04 UTC (rev 28923)
> @@ -4886,7 +4886,6 @@
>  }
>  
>  /************ add primitive, used by object/ module ****************/
> -
>  Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newname)
>  {
>  	static int xzproj= 0;	/* this function calls itself... */
> @@ -5257,7 +5256,170 @@
>  	
>  	return nu;
>  }
> +static int curve_prim_add(bContext *C, wmOperator *op,int type){
> +	
> +	Object *obedit= CTX_data_edit_object(C);
> +	ListBase *editnurb;
> +	Nurb *nu;
> +	int newob= 0;//, type= RNA_enum_get(op->ptr, "type");
> +	int enter_editmode;
> +	unsigned int layer;
> +	float loc[3], rot[3];
> +	float mat[4][4];
> +	
> +	//object_add_generic_invoke_options(C, op); // XXX these props don't get set right when only exec() is called
> +	ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer);
> +	
> +	if(obedit==NULL || obedit->type!=OB_CURVE) {
> +		Curve *cu;
> +		obedit= ED_object_add_type(C, OB_CURVE, loc, rot, TRUE, layer);
> +		newob = 1;
>  
> +		cu= (Curve*)obedit->data;
> +		cu->flag |= CU_DEFORM_FILL;
> +		if(type & CU_PRIM_PATH)
> +			cu->flag |= CU_PATH|CU_3D;
> +	}
> +	else DAG_id_flush_update(&obedit->id, OB_RECALC_DATA);
> +	
> +	ED_object_new_primitive_matrix(C, loc, rot, mat);
> +	
> +	nu= add_nurbs_primitive(C, mat, type, newob);
> +	editnurb= curve_get_editcurve(obedit);
> +	BLI_addtail(editnurb, nu);
> +	
> +	/* userdef */
> +	if (newob && !enter_editmode) {
> +		ED_object_exit_editmode(C, EM_FREEDATA);
> +	}
> +	
> +	WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, obedit);
> +	
> +	return OPERATOR_FINISHED;
> +}
> +
> +static int add_primitive_bezier_exec(bContext *C, wmOperator *op)
> +{
> +	if (curve_prim_add(C,op,CU_BEZIER|CU_PRIM_CURVE))
> +		return OPERATOR_FINISHED;
> +}
> +
> +void CURVE_OT_primitive_bezier_add(wmOperatorType *ot)
> +{
> +	/* identifiers */
> +	ot->name= "Add Bezier";
> +	ot->description= "Construct a Bezier Curve";
> +	ot->idname= "CURVE_OT_primitive_bezier_add";
> +	
> +	/* api callbacks */
> +	ot->invoke= ED_object_add_generic_invoke;
> +	ot->exec= add_primitive_bezier_exec;
> +	ot->poll= ED_operator_scene_editable;
> +	
> +	/* flags */
> +	ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
> +
> +	ED_object_add_generic_props(ot, TRUE);
> +}
> +
> +static int add_primitive_bezier_circle_exec(bContext *C, wmOperator *op)
> +{
> +	if(curve_prim_add(C,op,CU_BEZIER|CU_PRIM_CIRCLE))
> +		return OPERATOR_FINISHED;
> +}
> +
> +void CURVE_OT_primitive_bezier_circle_add(wmOperatorType *ot)
> +{
> +	/* identifiers */
> +	ot->name= "Add Circle";
> +	ot->description= "Construct a Bezier Circle";
> +	ot->idname= "CURVE_OT_primitive_bezier_circle_add";
> +	
> +	/* api callbacks */
> +	ot->invoke= ED_object_add_generic_invoke;
> +	ot->exec= add_primitive_bezier_circle_exec;
> +	ot->poll= ED_operator_scene_editable;
> +	
> +	/* flags */
> +	ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
> +
> +	ED_object_add_generic_props(ot, TRUE);
> +}
> +
> +static int add_primitive_nurbs_curve_exec(bContext *C, wmOperator *op)
> +{
> +	if(curve_prim_add(C,op,CU_NURBS|CU_PRIM_CURVE))
> +		return OPERATOR_FINISHED;
> +}
> +
> +void CURVE_OT_primitive_nurbs_curve_add(wmOperatorType *ot)
> +{
> +	/* identifiers */
> +	ot->name= "Add Nurbs Curve";
> +	ot->description= "Construct a Nurbs Curve";
> +	ot->idname= "CURVE_OT_primitive_nurbs_curve_add";
> +	
> +	/* api callbacks */
> +	ot->invoke= ED_object_add_generic_invoke;
> +	ot->exec= add_primitive_nurbs_curve_exec;
> +	ot->poll= ED_operator_scene_editable;
> +	
> +	/* flags */
> +	ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
> +
> +	ED_object_add_generic_props(ot, TRUE);
> +}
> +
> +static int add_primitive_nurbs_circle_exec(bContext *C, wmOperator *op)
> +{
> +	if(curve_prim_add(C,op,CU_NURBS|CU_PRIM_CIRCLE))
> +		return OPERATOR_FINISHED;
> +}
> +
> +void CURVE_OT_primitive_nurbs_circle_add(wmOperatorType *ot)
> +{
> +	/* identifiers */
> +	ot->name= "Add Nurbs Circle";
> +	ot->description= "Construct a Nurbs Circle";
> +	ot->idname= "CURVE_OT_primitive_nurbs_circle_add";
> +	
> +	/* api callbacks */
> +	ot->invoke= ED_object_add_generic_invoke;
> +	ot->exec= add_primitive_nurbs_circle_exec;
> +	ot->poll= ED_operator_scene_editable;
> +	
> +	/* flags */
> +	ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
> +
> +	ED_object_add_generic_props(ot, TRUE);
> +}
> +
> +static int add_primitive_curve_path_exec(bContext *C, wmOperator *op)
> +{
> +	if(curve_prim_add(C,op,CU_NURBS|CU_PRIM_PATH))
> +		return OPERATOR_FINISHED;
> +}
> +
> +void CURVE_OT_primitive_curve_path_add(wmOperatorType *ot)
> +{
> +	/* identifiers */
> +	ot->name= "Add Path";
> +	ot->description= "Construct a Path";
> +	ot->idname= "CURVE_OT_primitive_curve_path_add";
> +	
> +	/* api callbacks */
> +	ot->invoke= ED_object_add_generic_invoke;
> +	ot->exec= add_primitive_curve_path_exec;
> +	ot->poll= ED_operator_scene_editable;
> +	
> +	/* flags */
> +	ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
> +
> +	ED_object_add_generic_props(ot, TRUE);
> +}
> +
> +
> +
>  /***************** clear tilt operator ********************/
>  
>  static int clear_tilt_exec(bContext *C, wmOperator *op)
> 
> 
> _______________________________________________
> Bf-blender-cvs mailing list
> Bf-blender-cvs at blender.org
> http://lists.blender.org/mailman/listinfo/bf-blender-cvs


-- 
Michael Fox 
Developer and user of Blender3d
www.blender.org
http://mfoxdogg.googlepages.com

mfoxdogg at gmail.com



More information about the Bf-committers mailing list