Context parameter for Transform.
authorMartin Poirier <theeth@yahoo.com>
Sun, 27 Mar 2005 21:25:15 +0000 (21:25 +0000)
committerMartin Poirier <theeth@yahoo.com>
Sun, 27 Mar 2005 21:25:15 +0000 (21:25 +0000)
For tex space edit, crease (soon) and future use.

Manipulator assumes no context.

source/blender/include/BIF_transform.h
source/blender/src/editmesh_tools.c
source/blender/src/editobject.c
source/blender/src/space.c
source/blender/src/toolbox.c
source/blender/src/transform.c
source/blender/src/transform.h

index 6f1c0506e8e017a6d26c51d32ac693caa3e73807..431202e28821b9ec37c5087079876e8e5f8a975b 100755 (executable)
 #define TFM_LAMP_ENERGY                10
 #define TFM_TRACKBALL          11
 
-       // not sure if adding modes is the right way... context detecting could be done different (ton)
-#define TFM_TEX                                32
-#define TFM_TEX_TRANSLATION    33
-#define TFM_TEX_ROTATION       34
-#define TFM_TEX_RESIZE         35
-
+/* TRANSFORM CONTEXTS */
+#define CTX_NONE               0
+#define CTX_TEXTURE            1
+#define CTX_EDGE               2
 
+/* TRANSFORM PROPORTIONAL FALLOFF MODES */
 #define PROP_SHARP             0
 #define PROP_SMOOTH            1
 #define PROP_ROOT              2
 #define PROP_LIN               3
 #define PROP_CONST             4
 
-void Transform(int mode);
+void Transform(int mode, int context);
 
 
 struct TransInfo;
index 422480b4de6efba3b15a018f117c4ec305960bdc..b0f96f30ef6e1b1ca714051103fe2d4ece3565fe 100644 (file)
@@ -561,7 +561,7 @@ void extrude_mesh(void)
                
                /* individual faces? */
                if(nr==2) {
-                       Transform(TFM_SHRINKFATTEN);
+                       Transform(TFM_SHRINKFATTEN, CTX_NONE);
                }
                else {
                        if(transmode=='n') {
@@ -569,7 +569,7 @@ void extrude_mesh(void)
                                VecSubf(nor, nor, G.obedit->obmat[3]);
                                BIF_setSingleAxisConstraint(nor, NULL);
                        }
-                       Transform(TFM_TRANSLATION);
+                       Transform(TFM_TRANSLATION, CTX_NONE);
                }
        }
 
index 999173e288f2d4d7c5c9e916812ace82eadcea16..78d50143575745e5e3028c3d3acbc1212242e93f 100644 (file)
@@ -6749,7 +6749,7 @@ void std_rmouse_transform(void (*xf_func)(int))
                getmouseco_areawin(mval);
                if(abs(mval[0]-xo)+abs(mval[1]-yo) > 10) {
                        if(curarea->spacetype==SPACE_VIEW3D)
-                               Transform(TFM_TRANSLATION);
+                               Transform(TFM_TRANSLATION, CTX_NONE);
                        else
                                xf_func('g');
 
@@ -7615,7 +7615,7 @@ void adduplicate(float *dtrans)
        clear_id_newpoins();
        
        countall();
-       if(dtrans==0) Transform(TFM_TRANSLATION);
+       if(dtrans==0) Transform(TFM_TRANSLATION, CTX_NONE);
        
        set_active_base(BASACT);
        
@@ -7963,9 +7963,9 @@ void texspace_edit(void)
 
        //transmode= TRANS_TEX;
        
-       if(nr==1) Transform(TFM_TEX_TRANSLATION);
-       else if(nr==2) Transform(TFM_TEX_RESIZE);
-       else if(nr==3) Transform(TFM_TEX_ROTATION);
+       if(nr==1) Transform(TFM_TRANSLATION, CTX_TEXTURE);
+       else if(nr==2) Transform(TFM_RESIZE, CTX_TEXTURE);
+       else if(nr==3) Transform(TFM_ROTATION, CTX_TEXTURE);
        
        //transmode= 0;
 }
index 0515e0124c94a4a97b783b412699da648562db52..97e82321b16898becb7dcd7990e294bf254e9019 100644 (file)
@@ -1225,7 +1225,7 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                                clear_object('g');
                                        }
                                } else if((G.qual==0)) {
-                                       Transform(TFM_TRANSLATION);
+                                       Transform(TFM_TRANSLATION, CTX_NONE);
                                }
                                break;
                        case HKEY:
@@ -1483,28 +1483,28 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                                        loopoperations(LOOP_CUT);
                                        }
                                        else if((G.qual==0)) {
-                                               Transform(TFM_ROTATION);
+                                               Transform(TFM_ROTATION, CTX_NONE);
                                        }
                                }
                                else if((G.qual==0)) {
-                                       Transform(TFM_ROTATION);
+                                       Transform(TFM_ROTATION, CTX_NONE);
                                }
                                break;
                        case SKEY:
                                if(G.obedit) {
                                        if(G.qual==LR_ALTKEY)
-                                               Transform(TFM_SHRINKFATTEN);
+                                               Transform(TFM_SHRINKFATTEN, CTX_NONE);
                                        else if(G.qual==LR_CTRLKEY)
-                                               Transform(TFM_SHEAR);
+                                               Transform(TFM_SHEAR, CTX_NONE);
                                        else if(G.qual==(LR_CTRLKEY|LR_ALTKEY))
-                                               Transform(TFM_SHEAR);
+                                               Transform(TFM_SHEAR, CTX_NONE);
                                        else if(G.qual==LR_SHIFTKEY)
                                                snapmenu();
                                        else if(G.qual==0) {
-                                               Transform(TFM_RESIZE);
+                                               Transform(TFM_RESIZE, CTX_NONE);
                                        }
                                        else if(G.qual==(LR_SHIFTKEY|LR_CTRLKEY)){
-                                               Transform(TFM_TOSPHERE);
+                                               Transform(TFM_TOSPHERE, CTX_NONE);
                                        }
                                        
                                }
@@ -1517,12 +1517,12 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                        snapmenu();
                                }
                                else if((G.qual==0)) {
-                                       Transform(TFM_RESIZE);
+                                       Transform(TFM_RESIZE, CTX_NONE);
                                }
                                else if(G.qual==(LR_SHIFTKEY|LR_CTRLKEY))
-                                       Transform(TFM_TOSPHERE);
+                                       Transform(TFM_TOSPHERE, CTX_NONE);
                                else if(G.qual==(LR_CTRLKEY|LR_ALTKEY))
-                                       Transform(TFM_SHEAR);
+                                       Transform(TFM_SHEAR, CTX_NONE);
                                break;
                        case TKEY:
                                if(G.obedit){
@@ -1537,7 +1537,7 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                                        clear_tilt();
                                                }
                                                else if (G.qual==0) {
-                                                       Transform(TFM_TILT);
+                                                       Transform(TFM_TILT, CTX_NONE);
                                                }
                                        }
                                }
@@ -1603,7 +1603,7 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                break;
                        case WKEY:
                                if((G.qual==LR_SHIFTKEY)) {
-                                       Transform(TFM_WARP);
+                                       Transform(TFM_WARP, CTX_NONE);
                                }
                                else if(G.qual==LR_ALTKEY) {
                                        /* if(G.obedit && G.obedit->type==OB_MESH) write_videoscape(); */
index fe0f1fbcba5297c55e611fc38a3ba3cc8664b415..79bfeebbf672d56f029eb0d1e273488bcdf7e659 100644 (file)
@@ -1991,13 +1991,13 @@ static void tb_do_transform(void *arg, int event)
        switch(event)
        {
                case 0: /* Grab/move */
-                       Transform(TFM_TRANSLATION);
+                       Transform(TFM_TRANSLATION, CTX_NONE);
                        break;
                case 1: /* Rotate */
-                       Transform(TFM_ROTATION);
+                       Transform(TFM_ROTATION, CTX_NONE);
                        break;
                case 2: /* Scale */
-                       Transform(TFM_RESIZE);
+                       Transform(TFM_RESIZE,CTX_NONE);
                        break;
                case 3: /* transform properties */
                        add_blockhandler(curarea, VIEW3D_HANDLER_OBJECT, UI_PNL_UNSTOW);
@@ -2009,7 +2009,7 @@ static void tb_do_transform(void *arg, int event)
                        transform('N');
                        break;
                case 6: /* Shear */
-                       Transform(TFM_SHEAR);
+                       Transform(TFM_SHEAR, CTX_NONE);
                        break;
                case 7: /* Warp */
                        transform('w');
index 889c2c682ee112f9de5beaf7818854a7bc6e7e73..338460ef4209fcb1a008e9756b037b1a0de99d46 100755 (executable)
@@ -1226,10 +1226,9 @@ static void createTransObject(void)
 
 static void createTransData(TransInfo *t) 
 {
-       if( t->mode & TFM_TEX) {
+       if (t->context == CTX_TEXTURE) {
                t->flag |= T_TEXTURE;
                createTransTexspace();
-               t->mode &= ~TFM_TEX;    // now becoming normal grab/rot/scale
        }
        else if (G.obpose) {
                t->flag |= T_POSE;
@@ -1278,7 +1277,7 @@ static void createTransData(TransInfo *t)
 
 /* ************************** TRANSFORMATIONS **************************** */
 
-void Transform(int mode) 
+void Transform(int mode, int context
 {
        int ret_val = 0;
        short pmval[2] = {0, 0}, mval[2], val;
@@ -1305,6 +1304,8 @@ void Transform(int mode)
        else {
                LastMode = mode;
        }
+
+       Trans.context = context;
        
        initTransModeFlags(&Trans, mode);       // modal settings in struct Trans
 
@@ -1616,6 +1617,8 @@ void ManipulatorTransform(int mode)
        }
        /* END */
 
+       Trans.context = CTX_NONE;
+
        initTransModeFlags(&Trans, mode);       // modal settings in struct Trans
 
        initTrans(&Trans);                                      // internal data, mouse, vectors
@@ -2457,7 +2460,6 @@ int Rotation(TransInfo *t, short mval[2])
                sprintf(str, "Rot: %.2f %s", 180.0*final/M_PI, t->proptext);
        }
 
-       //printf("Axis %f %f %f\n", axis[0], axis[1], axis[2]);
        VecRotToMat3(axis, final * td->factor, mat);
 
        t->val = final;                         // used in manipulator
index bf99f3ccfe7a46a6b8976648144ff8ec4cef1a56..bb5317a8618cb1efd8a534cd21163024a48e44ef 100755 (executable)
@@ -107,6 +107,7 @@ typedef struct TransData {
 
 typedef struct TransInfo {
     int         mode;           /* current mode                         */
+    int         context;        /* current context                      */
     int       (*transform)(struct TransInfo *, short *);
                                 /* transform function pointer           */
     char        redraw;         /* redraw flag                          */