2.5
[blender-staging.git] / source / blender / editors / object / object_edit.c
index 8b749b3e82999302de5ccd79a9a18d7949c3b56c..c6cbbf90b79a5abc904f9049c379df65c853a764 100644 (file)
@@ -180,8 +180,8 @@ void ED_base_object_activate(bContext *C, Base *base)
        Base *tbase;
        
        /* activating a non-mesh, should end a couple of modes... */
-       //      if(base && base->object->type!=OB_MESH)
-       // XXX          exit_paint_modes();
+       if(base && base->object->type!=OB_MESH)
+               ED_view3d_exit_paint_modes(C);
        
        /* sets scene->basact */
        BASACT= base;
@@ -235,19 +235,6 @@ int object_data_is_libdata(Object *ob)
 
 
 
-void exit_paint_modes(void)
-{
-#if 0
-       if(G.f & G_VERTEXPAINT) set_vpaint();
-       if(G.f & G_TEXTUREPAINT) set_texturepaint();
-       if(G.f & G_WEIGHTPAINT) set_wpaint();
-       if(G.f & G_SCULPTMODE) set_sculptmode();
-       if(G.f & G_PARTICLEEDIT) PE_set_particle_edit();
-
-       G.f &= ~(G_VERTEXPAINT+G_TEXTUREPAINT+G_WEIGHTPAINT+G_SCULPTMODE+G_PARTICLEEDIT);
-#endif
-}
-
 /* exported */
 void ED_object_base_init_from_view(Scene *scene, View3D *v3d, Base *base)
 {
@@ -284,7 +271,7 @@ void add_object_draw(Scene *scene, View3D *v3d, int type)   /* for toolbox or menu
 {
        Object *ob;
        
-       exit_paint_modes();
+//     ED_view3d_exit_paint_modes(C);
 
 // XXX if (obedit) ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* freedata, and undo */
        ob= add_object(scene, type);
@@ -362,7 +349,7 @@ void delete_obj(Scene *scene, View3D *v3d, int ok)
                                }
                        }
                        
-                       exit_paint_modes();
+//                     ED_view3d_exit_paint_modes(C);
 
                        if(base->object->type==OB_LAMP) islamp= 1;
 
@@ -1639,36 +1626,77 @@ void OBJECT_OT_set_restrictview(wmOperatorType *ot)
        RNA_def_property_enum_items(prop, prop_set_restrictview_types);
        
 }
-/* ******************** **************** */
+/* ************* Slow Parent ******************* */
+static int object_set_slowparent_exec(bContext *C, wmOperator *op)
+{
 
-void reset_slowparents(Scene *scene, View3D *v3d)
+       CTX_DATA_BEGIN(C, Base*, base, visible_bases) {
+                               
+               if(base->object->parent) base->object->partype |= PARSLOW;
+               base->object->recalc |= OB_RECALC_OB;
+               
+       }
+       CTX_DATA_END;
+
+       ED_anim_dag_flush_update(C);    
+       ED_undo_push(C,"Set Slow Parent");
+       
+       WM_event_add_notifier(C, NC_SCENE, CTX_data_scene(C));
+       
+       return OPERATOR_FINISHED;
+}
+
+void OBJECT_OT_set_slowparent(wmOperatorType *ot)
 {
-       /* back to original locations */
-       Base *base;
+       
+       /* identifiers */
+       ot->name= "Set Slow Parent";
+       ot->idname= "OBJECT_OT_set_slow_parent";
+       
+       /* api callbacks */
+       ot->invoke= WM_operator_confirm;
+       ot->exec= object_set_slowparent_exec;
+       ot->poll= ED_operator_view3d_active;
+}
 
-       for(base= FIRSTBASE; base; base= base->next) {
+static int object_clear_slowparent_exec(bContext *C, wmOperator *op)
+{
+       Scene *scene= CTX_data_scene(C);
+
+       CTX_DATA_BEGIN(C, Base*, base, visible_bases) {
                if(base->object->parent) {
                        if(base->object->partype & PARSLOW) {
                                base->object->partype -= PARSLOW;
                                where_is_object(scene, base->object);
                                base->object->partype |= PARSLOW;
+                               base->object->recalc |= OB_RECALC_OB;
                        }
                }
+               
        }
-}
-void set_slowparent(Scene *scene, View3D *v3d)
-{
-       Base *base;
+       CTX_DATA_END;
 
-       if( okee("Set slow parent")==0 ) return;
+       ED_anim_dag_flush_update(C);    
+       ED_undo_push(C,"Clear Slow Parent");
+       
+       WM_event_add_notifier(C, NC_SCENE, CTX_data_scene(C));
+       
+       return OPERATOR_FINISHED;
+}
 
-       for(base= FIRSTBASE; base; base= base->next) {
-               if(TESTBASELIB(v3d, base)) {
-                       if(base->object->parent) base->object->partype |= PARSLOW;
-               }
-       }
-       BIF_undo_push("Slow parent");
+void OBJECT_OT_clear_slowparent(wmOperatorType *ot)
+{
+       
+       /* identifiers */
+       ot->name= "Clear Slow Parent";
+       ot->idname= "OBJECT_OT_clear_slow_parent";
+       
+       /* api callbacks */
+       ot->invoke= WM_operator_confirm;
+       ot->exec= object_clear_slowparent_exec;
+       ot->poll= ED_operator_view3d_active;
 }
+/* ******************** **************** */
 
 // XXX
 #define BEZSELECTED_HIDDENHANDLES(bezt)   ((G.f & G_HIDDENHANDLES) ? (bezt)->f2 & SELECT : BEZSELECTED(bezt))
@@ -6308,55 +6336,3 @@ void hookmenu(Scene *scene, View3D *v3d)
                allqueue(REDRAWBUTSEDIT, 0);
        }       
 }
-
-void hide_objects(Scene *scene, View3D *v3d, int select)
-{
-       Base *base;
-       short changed = 0, changed_act = 0;
-       for(base = FIRSTBASE; base; base=base->next){
-               if ((base->lay & v3d->lay) && TESTBASELIB(v3d, base)==select) {
-                       base->flag &= ~SELECT;
-                       base->object->flag = base->flag;
-                       base->object->restrictflag |= OB_RESTRICT_VIEW;
-                       changed = 1;
-                       if (base==BASACT) {
-                               BASACT= NULL;
-                               changed_act = 1;
-                       }
-               }
-       }
-       if (changed) {
-               if(select) BIF_undo_push("Hide Selected Objects");
-               else if(select) BIF_undo_push("Hide Unselected Objects");
-               DAG_scene_sort(scene);
-               allqueue(REDRAWVIEW3D,0);
-               allqueue(REDRAWOOPS,0);
-               allqueue(REDRAWDATASELECT,0);
-               if (changed_act) { /* these spaces depend on the active object */
-                       allqueue(REDRAWBUTSALL,0);
-                       allqueue(REDRAWIPO,0);
-                       allqueue(REDRAWACTION,0);
-               }
-       }
-}
-
-void show_objects(Scene *scene, View3D *v3d)
-{
-       Base *base;
-       int changed = 0;
-       
-       for(base = FIRSTBASE; base; base=base->next){
-               if((base->lay & v3d->lay) && base->object->restrictflag & OB_RESTRICT_VIEW) {
-                       base->flag |= SELECT;
-                       base->object->flag = base->flag;
-                       base->object->restrictflag &= ~OB_RESTRICT_VIEW; 
-                       changed = 1;
-               }
-       }
-       if (changed) {
-               BIF_undo_push("Unhide Objects");
-               DAG_scene_sort(scene);
-               allqueue(REDRAWVIEW3D,0);
-               allqueue(REDRAWOOPS,0);
-       }
-}