Undo for lattice editmode added.
authorTon Roosendaal <ton@blender.org>
Sun, 7 Nov 2004 21:14:21 +0000 (21:14 +0000)
committerTon Roosendaal <ton@blender.org>
Sun, 7 Nov 2004 21:14:21 +0000 (21:14 +0000)
source/blender/include/BIF_editlattice.h
source/blender/src/editlattice.c
source/blender/src/space.c

index c882013576ddcb88e78d9e1435ae2122c2a5ab4c..c7cf6c570ac42ab060bdff48fb512703d101de6b 100644 (file)
@@ -39,6 +39,7 @@ void load_editLatt(void);
 void remake_editLatt(void);
 void deselectall_Latt(void);
 void mouse_lattice(void);
+void undo_push_lattice(char *name);
 
 #endif
 
index 18bed249da47a980e9a29410af55ea43d746aa55..581278809d8e550fbd093d437747008310bd05d2 100644 (file)
@@ -32,6 +32,7 @@
  */
 
 #include <stdlib.h>
+#include <string.h>
 #include <math.h>
 
 #ifdef HAVE_CONFIG_H
 #include "BKE_lattice.h"
 #include "BKE_global.h"
 
-#include "BIF_toolbox.h"
 #include "BIF_space.h"
 #include "BIF_screen.h"
 #include "BIF_editlattice.h"
+#include "BIF_editmode_undo.h"
 #include "BIF_editkey.h"
+#include "BIF_toolbox.h"
 
 #include "BSE_edit.h"
 
@@ -130,10 +132,10 @@ void make_editLatt(void)
        }
 
        editLatt= MEM_dupallocN(lt);
-       
        editLatt->def= MEM_dupallocN(lt->def);
        
        setflagsLatt(0);
+       BIF_undo_push("original");
 }
 
 
@@ -199,6 +201,8 @@ void remake_editLatt(void)
        make_editLatt();
        allqueue(REDRAWVIEW3D, 0);
        allqueue(REDRAWBUTSEDIT, 0);
+
+       BIF_undo_push("Reload original");
 }
 
 
@@ -217,12 +221,15 @@ void deselectall_Latt(void)
                if(bp->hide==0) {
                        if(bp->f1) {
                                setflagsLatt(0);
+                               BIF_undo_push("(De)select all");
                                return;
                        }
                }
                bp++;
        }
        setflagsLatt(1);
+
+       BIF_undo_push("(De)select all");
 }
 
 
@@ -285,8 +292,52 @@ void mouse_lattice(void)
                }
 
                countall();
+               BIF_undo_push("Select");
        }
 
        rightmouse_transform();
        
 }
+
+
+/* **************** undo for lattice object ************** */
+
+static void undoLatt_to_editLatt(void *defv)
+{
+       Base *base;
+       int a= editLatt->pntsu*editLatt->pntsv*editLatt->pntsw;
+
+       memcpy(editLatt->def, defv, a*sizeof(BPoint));
+       
+       base= FIRSTBASE;
+       while(base) {
+               if(base->lay & G.vd->lay) {
+                       if(base->object->parent==G.obedit) {
+                               makeDispList(base->object);
+                       }
+               }
+               base= base->next;
+       }
+       allqueue(REDRAWVIEW3D, 0);
+}
+
+static void *editLatt_to_undoLatt(void)
+{
+       
+       return MEM_dupallocN(editLatt->def);
+}
+
+static void free_undoLatt(void *defv)
+{
+       MEM_freeN(defv);
+}
+
+/* and this is all the undo system needs to know */
+void undo_push_lattice(char *name)
+{
+       undo_editmode_push(name, free_undoLatt, undoLatt_to_editLatt, editLatt_to_undoLatt);
+}
+
+
+
+/***/
index 6229e17af191360ca05edfbd2f2e4f918fdf5e5d..fa5a762d56c821d3b26158fd100f19fe5fd33262 100644 (file)
@@ -636,6 +636,8 @@ void BIF_undo_push(char *str)
                        undo_push_font(str);
                else if (G.obedit->type==OB_MBALL)
                        undo_push_mball(str);
+               else if (G.obedit->type==OB_LATTICE)
+                       undo_push_lattice(str);
        }
        else {
                if(U.uiflag & USER_GLOBALUNDO) 
@@ -646,7 +648,7 @@ void BIF_undo_push(char *str)
 void BIF_undo(void)
 {      
        if(G.obedit) {
-               if ELEM5(G.obedit->type, OB_MESH, OB_FONT, OB_CURVE, OB_SURF, OB_MBALL)
+               if ELEM6(G.obedit->type, OB_MESH, OB_FONT, OB_CURVE, OB_SURF, OB_MBALL, OB_LATTICE)
                        undo_editmode_step(1);
        }
        else {
@@ -664,7 +666,7 @@ void BIF_undo(void)
 void BIF_redo(void)
 {
        if(G.obedit) {
-               if ELEM5(G.obedit->type, OB_MESH, OB_FONT, OB_CURVE, OB_SURF, OB_MBALL)
+               if ELEM6(G.obedit->type, OB_MESH, OB_FONT, OB_CURVE, OB_SURF, OB_MBALL, OB_LATTICE)
                        undo_editmode_step(-1);
        }
        else {
@@ -682,13 +684,8 @@ void BIF_redo(void)
 void BIF_undo_menu(void)
 {
        if(G.obedit) {
-               if(G.obedit->type==OB_MESH)
-                       undo_editmode_menu();
-               else if ELEM(G.obedit->type, OB_CURVE, OB_SURF)
-                       undo_editmode_menu();
-               else if (G.obedit->type==OB_MBALL)
+               if ELEM6(G.obedit->type, OB_MESH, OB_FONT, OB_CURVE, OB_SURF, OB_MBALL, OB_LATTICE)
                        undo_editmode_menu();
-               
                allqueue(REDRAWALL, 0);
        }
        else {
@@ -1516,13 +1513,11 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                        }
                                        else if(G.obedit->type==OB_ARMATURE)
                                                remake_editArmature();
-                                       else if ELEM(G.obedit->type, OB_CURVE, OB_SURF) {
+                                       else if ELEM4(G.obedit->type, OB_CURVE, OB_SURF, OB_MBALL, OB_LATTICE) {
                                                if(G.qual==0) BIF_undo(); else BIF_redo();
                                        }
-                                       else if(G.obedit->type==OB_LATTICE)
-                                               remake_editLatt();
                                }
-                               else if((G.qual==0)){
+                               else if((G.qual==0)) {
                                        if (G.f & G_FACESELECT)
                                                uv_autocalc_tface();
                                        else if(G.f & G_WEIGHTPAINT)