(no commit message)
authorMichael Fox <mfoxdogg@gmail.com>
Sun, 23 May 2010 02:02:04 +0000 (02:02 +0000)
committerMichael Fox <mfoxdogg@gmail.com>
Sun, 23 May 2010 02:02:04 +0000 (02:02 +0000)
release/scripts/ui/space_info.py
source/blender/editors/curve/curve_intern.h
source/blender/editors/curve/curve_ops.c
source/blender/editors/curve/editcurve.c

index 4c504cd69c952fd6a0b30041e8f95c49245c1ee0..8339a5b25f97992d3fd9f56f39f5a0998f17167e 100644 (file)
@@ -199,6 +199,18 @@ class INFO_MT_mesh_add(bpy.types.Menu):
         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"
@@ -221,7 +233,8 @@ class INFO_MT_add(bpy.types.Menu):
         #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 @@ classes = [
     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,
index a9f9aac70d51cd3151772ad05e3f8792441a6cc7..bbbab8113b6d4d8daaa23f7055b42fbf385ea298 100644 (file)
@@ -85,6 +85,12 @@ void CURVE_OT_tilt_clear(struct wmOperatorType *ot);
 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);
index fa341ee19ef80cac9d9186c19652e8126d82c0ac..0daa3535f6e59eaa4f53d5baba16bd419be320df 100644 (file)
@@ -96,6 +96,12 @@ void ED_operatortypes_curve(void)
        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);
index 5c64b82ec873450265db5ebd7f03b26d93c0591f..309ed9dadb5e6c2ffb3a9697586a5e70018aaf20 100644 (file)
@@ -4886,7 +4886,6 @@ int join_curve_exec(bContext *C, wmOperator *op)
 }
 
 /************ 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,6 +5256,169 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newname)
        
        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 ********************/