added error reporting to edit mesh
authorShaul Kedem <shaul_kedem@yahoo.com>
Sat, 14 Feb 2009 21:31:34 +0000 (21:31 +0000)
committerShaul Kedem <shaul_kedem@yahoo.com>
Sat, 14 Feb 2009 21:31:34 +0000 (21:31 +0000)
source/blender/editors/mesh/editdeform.c
source/blender/editors/mesh/editmesh_add.c
source/blender/editors/mesh/editmesh_lib.c
source/blender/editors/mesh/editmesh_loop.c
source/blender/editors/mesh/editmesh_mods.c
source/blender/editors/mesh/editmesh_tools.c
source/blender/editors/mesh/mesh_intern.h
source/blender/editors/mesh/meshtools.c

index 845290660c7ae6201f35642bbfb63bb187dd56bf..65b0425f3f1200808771adeba29b5338e63726cc 100644 (file)
@@ -43,6 +43,7 @@
 #include "DNA_object_force.h"
 #include "DNA_scene_types.h"
 #include "DNA_particle_types.h"
+#include "DNA_windowmanager_types.h"
 
 #include "BLI_blenlib.h"
 #include "BLI_editVert.h"
index 969fceb41b0a4fa78128ae524fe613093d2421af..c5c30e32cd1c05106ec8c1a025eaff1a1c6ef226 100644 (file)
@@ -59,6 +59,7 @@
 #include "BKE_mesh.h"
 #include "BKE_object.h"
 #include "BKE_utildefines.h"
+#include "BKE_report.h"
 
 #include "BIF_retopo.h"
 
@@ -75,7 +76,6 @@
 /* bpymenu removed XXX */
 
 /* XXX */
-static void error() {}
 #define add_numbut(a, b, c, d, e, f, g) {}
 /* XXX */
 
@@ -245,7 +245,7 @@ void MESH_OT_dupli_extrude_cursor(wmOperatorType *ot)
 /* ********************** */
 
 /* selected faces get hidden edges */
-int make_fgon(EditMesh *em, int make)
+int make_fgon(EditMesh *em, wmOperator *op, int make)
 {
        EditFace *efa;
        EditEdge *eed;
@@ -317,13 +317,13 @@ int make_fgon(EditMesh *em, int make)
                if(eve->f1==1) break;
        }
        if(eve) {
-               error("Cannot make polygon with interior vertices");
+               BKE_report(op->reports, RPT_ERROR, "Cannot make a polygon with interior vertices");
                return 0;
        }
        
        // check for faces
        if(nor==NULL) {
-               error("No faces selected to make FGon");
+               BKE_report(op->reports, RPT_ERROR, "No faces were selected to make FGon");
                return 0;
        }
 
@@ -345,7 +345,7 @@ static int make_fgon_exec(bContext *C, wmOperator *op)
        Object *obedit= CTX_data_edit_object(C);
        EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
 
-       if( make_fgon(em, 1) ) {
+       if( make_fgon(em, op, 1) ) {
                DAG_object_flush_update(CTX_data_scene(C), obedit, OB_RECALC_DATA);     
        
                WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
@@ -374,7 +374,7 @@ static int clear_fgon_exec(bContext *C, wmOperator *op)
        Object *obedit= CTX_data_edit_object(C);
        EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
        
-       if( make_fgon(em, 0) ) {
+       if( make_fgon(em, op, 0) ) {
                DAG_object_flush_update(CTX_data_scene(C), obedit, OB_RECALC_DATA);     
                
                WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
@@ -664,7 +664,7 @@ void addfaces_from_edgenet(EditMesh *em)
 // XXX DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
 }
 
-static void addedgeface_mesh(EditMesh *em)
+static void addedgeface_mesh(EditMesh *em, wmOperator *op)
 {
        EditVert *eve, *neweve[4];
        EditEdge *eed;
@@ -698,7 +698,7 @@ static void addedgeface_mesh(EditMesh *em)
                return;
        }
        else if(amount<2) {
-               error("Incorrect number of vertices to make edge/face");
+               BKE_report(op->reports, RPT_ERROR, "More vertices are needed to make an edge/face");
                return;
        }
 
@@ -710,7 +710,7 @@ static void addedgeface_mesh(EditMesh *em)
                        efa= addfacelist(em, neweve[0], neweve[1], neweve[2], 0, NULL, NULL);
                        EM_select_face(efa, 1);
                }
-               else error("The selected vertices already form a face");
+               else BKE_report(op->reports, RPT_ERROR, "The selected vertices already form a face");
        }
        else if(amount==4) {
                /* this test survives when theres 2 triangles */
@@ -766,9 +766,9 @@ static void addedgeface_mesh(EditMesh *em)
                                        }
                                }
                        }
-                       else error("The selected vertices already form a face");
+                       else BKE_report(op->reports, RPT_ERROR, "The selected vertices already form a face");
                }
-               else error("The selected vertices already form a face");
+               else BKE_report(op->reports, RPT_ERROR, "The selected vertices already form a face");
        }
        
        if(efa) {
@@ -785,7 +785,7 @@ static int addedgeface_mesh_exec(bContext *C, wmOperator *op)
        Object *obedit= CTX_data_edit_object(C);
        EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
        
-       addedgeface_mesh(em);
+       addedgeface_mesh(em, op);
        
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
        
index 738cdd7a77f83e6fa4439841bc54b96dc055a382..83613987b6f13a08fc6ac8460433298ef7fadb19 100644 (file)
@@ -44,6 +44,7 @@ editmesh_lib: generic (no UI, no menus) operations/evaluators for editmesh data
 #include "DNA_modifier_types.h"
 #include "DNA_object_types.h"
 #include "DNA_scene_types.h"
+#include "DNA_windowmanager_types.h"
 
 #include "BLI_blenlib.h"
 #include "BLI_arithb.h"
index d93ceaf07b873794953e646ab15047c6ffe3fc6f..2860c915ee439bd30c2ee13b5dc9b4cb2807de89 100644 (file)
@@ -46,6 +46,7 @@ editmesh_loop: tools with own drawing subloops, select, knife, subdiv
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"
 #include "DNA_view3d_types.h"
+#include "DNA_windowmanager_types.h"
 
 #include "BLI_blenlib.h"
 #include "BLI_arithb.h"
@@ -198,7 +199,7 @@ static void edgering_sel(EditMesh *em, EditEdge *startedge, int select, int prev
                }
        }
 }
-void CutEdgeloop(Object *obedit, EditMesh *em, int numcuts)
+void CutEdgeloop(Object *obedit, wmOperator *op, EditMesh *em, int numcuts)
 {
        ViewContext vc; // XXX
        EditEdge *nearest=NULL, *eed;
@@ -375,9 +376,9 @@ void CutEdgeloop(Object *obedit, EditMesh *em, int numcuts)
        /* if this was a single cut, enter edgeslide mode */
        if(numcuts == 1 && hasHidden == 0){
                if(cuthalf)
-                       EdgeSlide(em, 1,0.0);
+                       EdgeSlide(em, op, 1,0.0);
                else {
-                       if(EdgeSlide(em, 0,0.0) == -1){
+                       if(EdgeSlide(em, op, 0,0.0) == -1){
                                BIF_undo();
                        }
                }
@@ -476,7 +477,7 @@ static float seg_intersect(EditEdge *e, CutCurve *c, int len, char mode, struct
        float  threshold;
        int  i;
        
-       //threshold = 0.000001; /*tolerance for vertex intersection*/
+       threshold = 0.000001; /*tolerance for vertex intersection*/
        // XXX  threshold = scene->toolsettings->select_thresh / 100;
        
        /* Get screen coords of verts */
index d98d5731236b979f85061690b417e82a7c685d41..915809c6569fceccaa2dcae371cce2cd35e30f7b 100644 (file)
@@ -67,6 +67,7 @@ editmesh_mods.c, UI level access, no geometry changes
 #include "BKE_material.h"
 #include "BKE_texture.h"
 #include "BKE_utildefines.h"
+#include "BKE_report.h"
 
 #include "IMB_imbuf_types.h"
 #include "IMB_imbuf.h"
@@ -92,7 +93,6 @@ editmesh_mods.c, UI level access, no geometry changes
 
 /* XXX */
 static void waitcursor() {}
-static void error() {}
 static int pupmenu() {return 0;}
 
 /* ****************************** MIRROR **************** */
@@ -1379,7 +1379,7 @@ void EM_mesh_copy_edge(EditMesh *em, short type)
        }
 }
 
-void EM_mesh_copy_face(EditMesh *em, short type)
+void EM_mesh_copy_face(EditMesh *em, wmOperator *op, short type)
 {
        short change=0;
        
@@ -1405,7 +1405,7 @@ void EM_mesh_copy_face(EditMesh *em, short type)
                break;
        case 2: /* copy image */
                if (!tf_act) {
-                       error("mesh has no uv/image layers");
+                       BKE_report(op->reports, RPT_ERROR, "mesh has no uv/image layers");
                        return;
                }
                for(efa=em->faces.first; efa; efa=efa->next) {
@@ -1426,7 +1426,7 @@ void EM_mesh_copy_face(EditMesh *em, short type)
 
        case 3: /* copy UV's */
                if (!tf_act) {
-                       error("mesh has no uv/image layers");
+                       BKE_report(op->reports, RPT_ERROR, "mesh has no uv/image layers");
                        return;
                }
                for(efa=em->faces.first; efa; efa=efa->next) {
@@ -1439,7 +1439,7 @@ void EM_mesh_copy_face(EditMesh *em, short type)
                break;
        case 4: /* mode's */
                if (!tf_act) {
-                       error("mesh has no uv/image layers");
+                       BKE_report(op->reports, RPT_ERROR, "mesh has no uv/image layers");
                        return;
                }
                for(efa=em->faces.first; efa; efa=efa->next) {
@@ -1452,7 +1452,7 @@ void EM_mesh_copy_face(EditMesh *em, short type)
                break;
        case 5: /* copy transp's */
                if (!tf_act) {
-                       error("mesh has no uv/image layers");
+                       BKE_report(op->reports, RPT_ERROR, "mesh has no uv/image layers");
                        return;
                }
                for(efa=em->faces.first; efa; efa=efa->next) {
@@ -1466,7 +1466,7 @@ void EM_mesh_copy_face(EditMesh *em, short type)
 
        case 6: /* copy vcols's */
                if (!mcol_act) {
-                       error("mesh has no color layers");
+                       BKE_report(op->reports, RPT_ERROR, "mesh has no color layers");
                        return;
                } else {
                        /* guess the 4th color if needs be */
@@ -1508,7 +1508,7 @@ void EM_mesh_copy_face(EditMesh *em, short type)
 }
 
 
-void EM_mesh_copy_face_layer(EditMesh *em, short type) 
+void EM_mesh_copy_face_layer(EditMesh *em, wmOperator *op, short type) 
 {
        short change=0;
        
@@ -1523,7 +1523,7 @@ void EM_mesh_copy_face_layer(EditMesh *em, short type)
        case 8:
        case 9:
                if (CustomData_number_of_layers(&em->fdata, CD_MTFACE)<2) {
-                       error("mesh does not have multiple uv/image layers");
+                       BKE_report(op->reports, RPT_ERROR, "mesh does not have multiple uv/image layers");
                        return;
                } else {
                        int layer_orig_idx, layer_idx;
@@ -1550,7 +1550,7 @@ void EM_mesh_copy_face_layer(EditMesh *em, short type)
 
        case 10: /* select vcol layers - make sure this stays in sync with above code */
                if (CustomData_number_of_layers(&em->fdata, CD_MCOL)<2) {
-                       error("mesh does not have multiple color layers");
+                       BKE_report(op->reports, RPT_ERROR, "mesh does not have multiple color layers");
                        return;
                } else {
                        int layer_orig_idx, layer_idx;
@@ -1639,7 +1639,7 @@ void EM_mesh_copy_face_layer(EditMesh *em, short type)
 
 
 /* ctrl+c in mesh editmode */
-void mesh_copy_menu(EditMesh *em)
+void mesh_copy_menu(EditMesh *em, wmOperator *op)
 {
        EditSelection *ese;
        int ret;
@@ -1671,9 +1671,9 @@ void mesh_copy_menu(EditMesh *em)
                if (ret<1) return;
                
                if (ret<=6) {
-                       EM_mesh_copy_face(em, ret);
+                       EM_mesh_copy_face(em, op, ret);
                } else {
-                       EM_mesh_copy_face_layer(em, ret);
+                       EM_mesh_copy_face_layer(em, op, ret);
                }
        }
 }
@@ -2725,7 +2725,7 @@ void MESH_OT_reveal(wmOperatorType *ot)
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 }
 
-void select_faces_by_numverts(EditMesh *em, int numverts)
+void select_faces_by_numverts(EditMesh *em, wmOperator *op, int numverts)
 {
        EditFace *efa;
 
@@ -2737,7 +2737,7 @@ void select_faces_by_numverts(EditMesh *em, int numverts)
        if(numverts==5)
                EM_set_flag_all(em, SELECT);
        else if(em->selectmode!=SCE_SELECT_FACE) {
-               error("Only works in face selection mode");
+               BKE_report(op->reports, RPT_ERROR, "Only works in face selection mode");
                return;
        }
        
@@ -2772,7 +2772,7 @@ static int select_sharp_edges_exec(bContext *C, wmOperator *op)
        /* 'standard' behaviour - check if selected, then apply relevant selection */
        
        if(em->selectmode==SCE_SELECT_FACE) {
-               error("Doesn't work in face selection mode");
+               BKE_report(op->reports, RPT_ERROR, "Doesn't work in face selection mode");
                return OPERATOR_CANCELLED;
        }
 
@@ -2872,7 +2872,7 @@ void MESH_OT_select_sharp_edges(wmOperatorType *ot)
 }
 
 
-static void select_linked_flat_faces(EditMesh *em, float sharpness)
+static void select_linked_flat_faces(EditMesh *em, wmOperator *op, float sharpness)
 {
        /* Find faces that are linked to selected faces that are 
         * relatively flat (angle between faces is higher than
@@ -2886,7 +2886,7 @@ static void select_linked_flat_faces(EditMesh *em, float sharpness)
        float fsharpness;
        
        if(em->selectmode!=SCE_SELECT_FACE) {
-               error("Only works in face selection mode");
+               BKE_report(op->reports, RPT_ERROR, "Only works in face selection mode");
                return;
        }
 
@@ -3013,7 +3013,7 @@ static int select_linked_flat_faces_exec(bContext *C, wmOperator *op)
        Object *obedit= CTX_data_edit_object(C);
        EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
        
-       select_linked_flat_faces(em, RNA_float_get(op->ptr, "sharpness"));
+       select_linked_flat_faces(em, op, RNA_float_get(op->ptr, "sharpness"));
        
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
        return OPERATOR_FINISHED;       
@@ -3036,7 +3036,7 @@ void MESH_OT_select_linked_flat_faces(wmOperatorType *ot)
        RNA_def_float(ot->srna, "sharpness", 0.0f, 0.0f, FLT_MAX, "sharpness", "", 0.0f, 180.0f);
 }
 
-void select_non_manifold(EditMesh *em)
+void select_non_manifold(EditMesh *em, wmOperator *op )
 {
        EditVert *eve;
        EditEdge *eed;
@@ -3047,7 +3047,7 @@ void select_non_manifold(EditMesh *em)
         */
        
        if(em->selectmode==SCE_SELECT_FACE) {
-               error("Doesn't work in face selection mode");
+               BKE_report(op->reports, RPT_ERROR, "Doesn't work in face selection mode");
                return;
        }
 
@@ -3111,7 +3111,7 @@ static int select_non_manifold_exec(bContext *C, wmOperator *op)
        Object *obedit= CTX_data_edit_object(C);
        EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
        
-       select_non_manifold(em);
+       select_non_manifold(em, op);
        
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
        return OPERATOR_FINISHED;       
@@ -4086,7 +4086,7 @@ static int mface_is_selected(MFace *mf)
         * which would use same as vertices method), then added
         * to interface! Hoera! - zr
         */
-void faceselect_align_view_to_selected(View3D *v3d, RegionView3D *rv3d, Mesh *me, int axis)
+void faceselect_align_view_to_selected(View3D *v3d, RegionView3D *rv3d, Mesh *me, wmOperator *op,  int axis)
 {
        float norm[3];
        int i, totselected = 0;
@@ -4117,7 +4117,7 @@ void faceselect_align_view_to_selected(View3D *v3d, RegionView3D *rv3d, Mesh *me
        }
 
        if (totselected == 0)
-               error("No faces selected.");
+               BKE_report(op->reports, RPT_ERROR, "No faces selected.");
        else
                view3d_align_axis_to_vector(v3d, rv3d, axis, norm);
 }
@@ -4143,13 +4143,13 @@ static void face_getnormal_obspace(Object *obedit, EditFace *efa, float *fno)
 }
 
 
-void editmesh_align_view_to_selected(Object *obedit, EditMesh *em, View3D *v3d, RegionView3D *rv3d, int axis)
+void editmesh_align_view_to_selected(Object *obedit, EditMesh *em, wmOperator *op, View3D *v3d, RegionView3D *rv3d, int axis)
 {
        int nselverts= EM_nvertices_selected(em);
        float norm[3]={0.0, 0.0, 0.0}; /* used for storing the mesh normal */
        
        if (nselverts==0) {
-               error("No faces or vertices selected.");
+               BKE_report(op->reports, RPT_ERROR, "No faces or vertices selected.");
        } 
        else if (EM_nfaces_selected(em)) {
                EditFace *efa;
index 03b2c6fe983a8725bad346c95738aa4778bd726e..f33d2bf2a4803978c107280f1797c524a171930f 100644 (file)
@@ -74,6 +74,7 @@ editmesh_tool.c: UI called tools for editmesh, geometry changes here, otherwise
 #include "BKE_object.h"
 #include "BKE_utildefines.h"
 #include "BKE_bmesh.h"
+#include "BKE_report.h"
 
 #include "BIF_gl.h"
 #include "BIF_glutil.h"
@@ -95,7 +96,6 @@ editmesh_tool.c: UI called tools for editmesh, geometry changes here, otherwise
 /* XXX */
 static int extern_qread() {return 0;}
 static void waitcursor() {}
-static void error() {}
 static int pupmenu() {return 0;}
 static int qtest() {return 0;}
 #define add_numbut(a, b, c, d, e, f, g) {}
@@ -107,7 +107,7 @@ static int snap_to_center() {return 0;}
 
 /* local prototypes ---------------*/
 static void free_tagged_edges_faces(EditMesh *em, EditEdge *eed, EditFace *efa);
-int EdgeLoopDelete(EditMesh *em);
+int EdgeLoopDelete(EditMesh *em, wmOperator *op);
 
 /********* qsort routines *********/
 
@@ -488,8 +488,15 @@ static int removedoublesflag_exec(bContext *C, wmOperator *op)
        Object *obedit= CTX_data_edit_object(C);
        Scene *scene = CTX_data_scene(C);
        EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       char msg[100];
 
-       removedoublesflag(em,1,0,scene->toolsettings->doublimit);
+       int cnt = removedoublesflag(em,1,0,scene->toolsettings->doublimit);
+
+       if(cnt)
+       {
+               sprintf(msg, "Removed %d vertices", cnt);
+               BKE_report(op->reports, RPT_INFO, msg);
+       }
                
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
        
@@ -615,7 +622,7 @@ void hashvert_flag(EditMesh *em, int flag)
 }
 
 /* generic extern called extruder */
-void extrude_mesh(Object *obedit, EditMesh *em)
+void extrude_mesh(Object *obedit, EditMesh *em, wmOperator *op)
 {
        Scene *scene= NULL;             // XXX CTX!
        float nor[3]= {0.0, 0.0, 0.0};
@@ -656,7 +663,7 @@ void extrude_mesh(Object *obedit, EditMesh *em)
        else transmode= extrudeflag_face_indiv(em, SELECT, nor);
        
        if(transmode==0) {
-               error("No valid selection");
+               BKE_report(op->reports, RPT_ERROR, "Not a valid selection for extrude");
        }
        else {
                EM_fgon_flags(em);
@@ -695,7 +702,7 @@ static int mesh_extrude_exec(bContext *C, wmOperator *op)
        Object *obedit= CTX_data_edit_object(C);
        EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
 
-       extrude_mesh(obedit,em);
+       extrude_mesh(obedit,em, op);
                
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
        
@@ -813,7 +820,7 @@ void MESH_OT_extrude_repeat(wmOperatorType *ot)
        RNA_def_int(ot->srna, "steps", 10, 0, 180, "Steps", "", 0, INT_MAX);
 }
        
-void spin_mesh(View3D *v3d, Object *obedit, EditMesh *em, int steps, float degr, float *dvec, int mode)
+void spin_mesh(View3D *v3d, Object *obedit, EditMesh *em, wmOperator *op, int steps, float degr, float *dvec, int mode)
 {
        Scene *scene= NULL; // XXX from context!
        RegionView3D *rv3d= NULL; // XXX from context
@@ -867,7 +874,7 @@ void spin_mesh(View3D *v3d, Object *obedit, EditMesh *em, int steps, float degr,
                if(mode==0) ok= extrudeflag(obedit, em, SELECT, nor);
                else adduplicateflag(em, SELECT);
                if(ok==0) {
-                       error("No valid vertices are selected");
+                       BKE_report(op->reports, RPT_ERROR, "No valid vertices are selected");
                        break;
                }
                rotateflag(em, SELECT, cent, bmat);
@@ -897,7 +904,7 @@ void spin_mesh(View3D *v3d, Object *obedit, EditMesh *em, int steps, float degr,
 
 }
 
-void screw_mesh(Object *obedit, EditMesh *em, int steps, int turns)
+void screw_mesh(Object *obedit, EditMesh *em, wmOperator *op, int steps, int turns)
 {
        View3D *v3d= NULL; // XXX
        EditVert *eve,*v1=0,*v2=0;
@@ -936,7 +943,7 @@ void screw_mesh(Object *obedit, EditMesh *em, int steps, int turns)
                eve= eve->next;
        }
        if(v1==0 || v2==0) {
-               error("You have to select a string of connected vertices too");
+               BKE_report(op->reports, RPT_ERROR, "You have to select a string of connected vertices too");
                return;
        }
 
@@ -953,7 +960,7 @@ void screw_mesh(Object *obedit, EditMesh *em, int steps, int turns)
                dvec[2]= -dvec[2];
        }
 
-       spin_mesh(v3d, obedit, em, turns*steps, turns*360, dvec, 0);
+       spin_mesh(v3d, obedit, em, op, turns*steps, turns*360, dvec, 0);
 
 }
 
@@ -1004,7 +1011,7 @@ static void erase_vertices(EditMesh *em, ListBase *l)
        }
 }
 
-void delete_mesh(Object *obedit, EditMesh *em, int event)
+void delete_mesh(Object *obedit, EditMesh *em, wmOperator *op, int event)
 {
        EditFace *efa, *nextvl;
        EditVert *eve,*nextve;
@@ -1022,7 +1029,7 @@ void delete_mesh(Object *obedit, EditMesh *em, int event)
                erase_vertices(em, &em->verts);
        } 
        else if(event==6) {
-               if(!EdgeLoopDelete(em))
+               if(!EdgeLoopDelete(em, op))
                        return;
 
                str= "Erase Edge Loop";
@@ -1160,7 +1167,7 @@ static int delete_mesh_exec(bContext *C, wmOperator *op)
        Object *obedit= CTX_data_edit_object(C);
        EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
        
-       delete_mesh(obedit,em,RNA_enum_get(op->ptr, "type"));
+       delete_mesh(obedit,em, op,RNA_enum_get(op->ptr, "type"));
        
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
        
@@ -3596,7 +3603,7 @@ void edge_flip(EditMesh *em)
 
 }
 
-static void edge_rotate(EditMesh *em, EditEdge *eed,int dir)
+static void edge_rotate(EditMesh *em, wmOperator *op, EditEdge *eed,int dir)
 {
        EditVert **verts[2];
        EditFace *face[2], *efa, *newFace[2];
@@ -3681,7 +3688,7 @@ static void edge_rotate(EditMesh *em, EditEdge *eed,int dir)
 
        hiddenedges = MEM_mallocN(sizeof(EditVert*)*numhidden+1, "RotateEdgeHiddenVerts");
        if(!hiddenedges) {
-        error("Malloc Was not happy!");
+        BKE_report(op->reports, RPT_ERROR, "Memory allocation failed");
         return;   
     }
 
@@ -3810,14 +3817,14 @@ static int edge_rotate_selected(bContext *C, wmOperator *op)
                if(edgeCount==1) {
                        for(eed= em->edges.first; eed; eed= eed->next) {
                                if(eed->f1==2) {
-                                       edge_rotate(em, eed,dir);
+                                       edge_rotate(em, op, eed,dir);
                                        break;
                                }
                        }
                }
                else 
                {
-                       error("Select one edge or two adjacent faces");
+                       BKE_report(op->reports, RPT_ERROR, "Select one edge or two adjacent faces");
                        return OPERATOR_CANCELLED;
                }
        }
@@ -3825,14 +3832,14 @@ static int edge_rotate_selected(bContext *C, wmOperator *op)
                for(eed= em->edges.first; eed; eed= eed->next) {
                        if(eed->f & SELECT) {
                                EM_select_edge(eed, 0);
-                               edge_rotate(em, eed,dir);
+                               edge_rotate(em, op, eed,dir);
                                break;
                        }
                }
        }
        else 
        {       
-               error("Select one edge or two adjacent faces");
+               BKE_report(op->reports, RPT_ERROR, "Select one edge or two adjacent faces");
                return OPERATOR_CANCELLED;
        }
        
@@ -3956,7 +3963,7 @@ typedef struct SlideVert {
        EditVert origvert;
 } SlideVert;
 
-int EdgeSlide(EditMesh *em, short immediate, float imperc)
+int EdgeSlide(EditMesh *em, wmOperator *op, short immediate, float imperc)
 {
 //     NumInput num; XXX
        Mesh *me= NULL; // XXX
@@ -4011,7 +4018,7 @@ int EdgeSlide(EditMesh *em, short immediate, float imperc)
                        ct++;
                        efa->e1->f1++;
                        if(efa->e1->f1 > 2) {
-                               error("3+ face edge");
+                               BKE_report(op->reports, RPT_ERROR, "3+ face edge");
                                return 0;                                
                        }
                }
@@ -4019,7 +4026,7 @@ int EdgeSlide(EditMesh *em, short immediate, float imperc)
                        ct++;
                        efa->e2->f1++;
                        if(efa->e2->f1 > 2) {
-                               error("3+ face edge");
+                               BKE_report(op->reports, RPT_ERROR, "3+ face edge");
                                return 0;                                
                        }
                }
@@ -4027,7 +4034,7 @@ int EdgeSlide(EditMesh *em, short immediate, float imperc)
                        ct++;
                        efa->e3->f1++;
                        if(efa->e3->f1 > 2) {
-                               error("3+ face edge");
+                               BKE_report(op->reports, RPT_ERROR, "3+ face edge");
                                return 0;                                
                        }
                }
@@ -4035,13 +4042,13 @@ int EdgeSlide(EditMesh *em, short immediate, float imperc)
                        ct++;
                        efa->e4->f1++;
                        if(efa->e4->f1 > 2) {
-                               error("3+ face edge");
+                               BKE_report(op->reports, RPT_ERROR, "3+ face edge");
                                return 0;                                
                        }
                }       
                // Make sure loop is not 2 edges of same face   
                if(ct > 1) {
-                  error("loop crosses itself");
+                  BKE_report(op->reports, RPT_ERROR, "Loop crosses itself");
                   return 0;   
                }
        }          
@@ -4052,7 +4059,7 @@ int EdgeSlide(EditMesh *em, short immediate, float imperc)
           
        // Test for multiple segments
        if(vertsel > numsel+1) {
-               error("Was not a single edge loop");
+               BKE_report(op->reports, RPT_ERROR, "Please choose a single edge loop");
                return 0;                  
        }  
        
@@ -4088,7 +4095,7 @@ int EdgeSlide(EditMesh *em, short immediate, float imperc)
                // It looks like there was an unexpected case - Hopefully should not happen
                if(timesthrough >= numsel*2) {
                        BLI_linklist_free(edgelist,NULL); 
-                       error("could not order loop");
+                       BKE_report(op->reports, RPT_ERROR, "Could not order loop");
                        return 0;   
                }
        }
@@ -4231,7 +4238,7 @@ int EdgeSlide(EditMesh *em, short immediate, float imperc)
                tempsv  = BLI_ghash_lookup(vertgh,(EditVert*)look->link);
                
                if(!tempsv->up || !tempsv->down) {
-                       error("Missing rails");
+                       BKE_report(op->reports, RPT_ERROR, "Missing rails");
                        BLI_ghash_free(vertgh, NULL, (GHashValFreeFP)MEM_freeN);
                        BLI_linklist_free(vertlist,NULL); 
                        BLI_linklist_free(edgelist,NULL); 
@@ -4738,7 +4745,7 @@ int EdgeSlide(EditMesh *em, short immediate, float imperc)
        return 1;
 }
 
-int EdgeLoopDelete(EditMesh *em) 
+int EdgeLoopDelete(EditMesh *em, wmOperator *op
 {
        
        /* temporal flag setting so we keep UVs when deleting edge loops,
@@ -4746,7 +4753,7 @@ int EdgeLoopDelete(EditMesh *em)
        //      short uvcalc_flag_orig = 0; // XXX scene->toolsettings->uvcalc_flag; 
        //      scene->toolsettings->uvcalc_flag |= UVCALC_TRANSFORM_CORRECT;
        
-       if(!EdgeSlide(em, 1, 1)) {
+       if(!EdgeSlide(em, op, 1, 1)) {
                return 0;
        }
        
@@ -4884,7 +4891,7 @@ static void mesh_rip_setface(EditMesh *em, EditFace *sefa)
 }
 
 /* based on mouse cursor position, it defines how is being ripped */
-void mesh_rip(EditMesh *em)
+void mesh_rip(EditMesh *em, wmOperator *op)
 {
        extern void faceloop_select(EditEdge *startedge, int select);
        EditVert *eve, *nextve;
@@ -4929,11 +4936,11 @@ void mesh_rip(EditMesh *em)
        }
        
        if(efa) {
-               error("Can't perform ripping with faces selected this way");
+               BKE_report(op->reports, RPT_ERROR, "Can't perform ripping with faces selected this way");
                return;
        }
        if(sefa==NULL) {
-               error("No proper selection or faces included");
+               BKE_report(op->reports, RPT_ERROR, "No proper selection or faces included");
                return;
        }
        
@@ -4997,7 +5004,7 @@ void mesh_rip(EditMesh *em)
        }
        
        if(seed==NULL) {        // never happens?
-               error("No proper edge found to start");
+               BKE_report(op->reports, RPT_ERROR, "No proper edge found to start");
                return;
        }
        
@@ -5088,7 +5095,7 @@ void mesh_rip(EditMesh *em)
 // XXX scene->proportional = prop;
 }
 
-void shape_propagate(Scene *scene, Object *obedit, EditMesh *em)
+void shape_propagate(Scene *scene, Object *obedit, EditMesh *em, wmOperator *op)
 {
        EditVert *ev = NULL;
        Mesh* me = (Mesh*)obedit->data;
@@ -5100,7 +5107,7 @@ void shape_propagate(Scene *scene, Object *obedit, EditMesh *em)
        if(me->key){
                ky = me->key;
        } else {
-               error("Object Has No Key");     
+               BKE_report(op->reports, RPT_ERROR, "Object Has No Key");        
                return;
        }       
 
@@ -5115,7 +5122,7 @@ void shape_propagate(Scene *scene, Object *obedit, EditMesh *em)
                        }               
                }                                               
        } else {
-               error("Object Has No Blendshapes");     
+               BKE_report(op->reports, RPT_ERROR, "Object Has No Blendshapes");        
                return;                 
        }
        
@@ -5212,7 +5219,7 @@ void shape_copy_from_lerp(EditMesh *em, KeyBlock* thisBlock, KeyBlock* fromBlock
 
 
 
-void shape_copy_select_from(Object *obedit, EditMesh *em)
+void shape_copy_select_from(Object *obedit, EditMesh *em, wmOperator *op)
 {
        Mesh* me = (Mesh*)obedit->data;
        EditVert *ev = NULL;
@@ -5226,7 +5233,7 @@ void shape_copy_select_from(Object *obedit, EditMesh *em)
        if(me->key){
                ky = me->key;
        } else {
-               error("Object Has No Key");     
+               BKE_report(op->reports, RPT_ERROR, "Object Has No Key");        
                return;
        }
        
@@ -5251,7 +5258,7 @@ void shape_copy_select_from(Object *obedit, EditMesh *em)
 // XXX         nr = pupmenu_col(menu, 20);
                MEM_freeN(menu);                
        } else {
-               error("Object Has No Blendshapes");     
+               BKE_report(op->reports, RPT_ERROR, "Object Has No Blendshapes");        
                return;                 
        }
        
@@ -5265,7 +5272,7 @@ void shape_copy_select_from(Object *obedit, EditMesh *em)
                        }
                        
                        if(me->totvert != totverts){
-                               error("Shape Has had Verts Added/Removed, please cycle editmode before copying");
+                               BKE_report(op->reports, RPT_ERROR, "Shape Has had Verts Added/Removed, please cycle editmode before copying");
                                return; 
                        }
                        shape_copy_from_lerp(em, thisBlock,kb);         
@@ -5843,7 +5850,7 @@ typedef struct PathEdge{
        float w;
 } PathEdge;
 
-void pathselect(EditMesh *em)
+void pathselect(EditMesh *em, wmOperator *op)
 {
        EditVert *eve, *s, *t;
        EditEdge *eed;
@@ -5995,7 +6002,7 @@ void pathselect(EditMesh *em)
                }
        }
        else{
-               error("Path Selection requires that exactly two vertices be selected");
+               BKE_report(op->reports, RPT_ERROR, "Path Selection requires that exactly two vertices be selected");
                return;
        }
 }
@@ -6247,7 +6254,7 @@ static int mesh_rotate_uvs(bContext *C, wmOperator *op)
        int shift = 0; // XXX
 
        if (!EM_texFaceCheck(em)) {
-               error("mesh has no uv/image layers");
+               BKE_report(op->reports, RPT_ERROR, "mesh has no uv/image layers");
                return OPERATOR_CANCELLED;
        }
        
@@ -6319,7 +6326,7 @@ static int mesh_mirror_uvs(bContext *C, wmOperator *op)
        int shift= 0; // XXX
        
        if (!EM_texFaceCheck(em)) {
-               error("mesh has no uv/image layers");
+               BKE_report(op->reports, RPT_ERROR, "mesh has no uv/image layers");
                return OPERATOR_CANCELLED;
        }
        
@@ -6404,7 +6411,7 @@ static int mesh_rotate_colors(bContext *C, wmOperator *op)
        int shift= 0; // XXX
        
        if (!EM_vertColorCheck(em)) {
-               error("mesh has no color layers");
+               BKE_report(op->reports, RPT_ERROR, "mesh has no color layers");
                return OPERATOR_CANCELLED;
        }
        
@@ -6459,7 +6466,7 @@ static int mesh_mirror_colors(bContext *C, wmOperator *op)
        int shift= 0; // XXX
        
        if (!EM_vertColorCheck(em)) {
-               error("mesh has no color layers");
+               BKE_report(op->reports, RPT_ERROR, "Mesh has no color layers");
                return OPERATOR_CANCELLED;
        }
        
index 0e54e10793cf6e6b62831763a16e574567fb4f5e..4333dc3e75db4a947f977bd7af12f49772ffaa79 100644 (file)
@@ -199,7 +199,7 @@ extern EditVert *findnearestvert(ViewContext *vc, int *dist, short sel, short st
 void join_triangles(EditMesh *em);
 int removedoublesflag(EditMesh *em, short flag, short automerge, float limit);         /* return amount */
 void esubdivideflag(Object *obedit, EditMesh *em, int flag, float rad, int beauty, int numcuts, int seltype);
-int EdgeSlide(EditMesh *em, short immediate, float imperc);
+int EdgeSlide(EditMesh *em, wmOperator *op, short immediate, float imperc);
 
 void MESH_OT_subdivs(struct wmOperatorType *ot);
 void MESH_OT_subdivide(struct wmOperatorType *ot);
index aef22bb7e83f7608368674b60f3b68249e97d1dc..22857b0718b54b52d1d590725b0e9f618b4b61a2 100644 (file)
@@ -47,6 +47,7 @@
 #include "DNA_space_types.h"
 #include "DNA_view3d_types.h"
 #include "DNA_world_types.h"
+#include "DNA_windowmanager_types.h"
 
 #include "BLI_arithb.h"
 #include "BLI_blenlib.h"
@@ -67,6 +68,7 @@
 #include "BKE_material.h"
 #include "BKE_object.h"
 #include "BKE_utildefines.h"
+#include "BKE_report.h"
 
 #include "RE_pipeline.h"
 #include "RE_shader_ext.h"
@@ -103,7 +105,7 @@ static int pupmenu() {return 0;}
 
 /* join selected meshes into the active mesh, context sensitive
 return 0 if no join is made (error) and 1 of the join is done */
-int join_mesh(Scene *scene, View3D *v3d)
+int join_mesh(Scene *scene, View3D *v3d, wmOperator *op)
 {
        Base *base, *nextb;
        Object *ob;
@@ -154,11 +156,11 @@ int join_mesh(Scene *scene, View3D *v3d)
        }
        
        if(haskey) {
-               error("Can't join meshes with vertex keys");
+               BKE_report(op->reports, RPT_ERROR, "Can't join meshes with vertex keys");
                return 0;
        }
        if(hasmulti) {
-               error("Can't join meshes with Multires");
+               BKE_report(op->reports, RPT_ERROR, "Can't join meshes with Multires");
                return 0;
        }
        /* that way the active object is always selected */