Merging r41597 through r41607 from trunk into soc-2011-tomato
[blender.git] / source / blender / editors / transform / transform_generics.c
index 76c81662ce801553944c01cd9f80648210d090aa..53e379a2d270a345d34718dded9d67b86a27f4bf 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * $Id$
- *
  * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or
@@ -49,6 +47,7 @@
 #include "DNA_meshdata_types.h"
 #include "DNA_view3d_types.h"
 #include "DNA_modifier_types.h"
+#include "DNA_movieclip_types.h"
 
 #include "RNA_access.h"
 
@@ -72,6 +71,7 @@
 #include "BKE_mesh.h"
 #include "BKE_nla.h"
 #include "BKE_context.h"
+#include "BKE_tracking.h"
 
 #include "ED_anim_api.h"
 #include "ED_armature.h"
@@ -84,7 +84,8 @@
 #include "ED_space_api.h"
 #include "ED_uvedit.h"
 #include "ED_view3d.h"
-#include "ED_curve.h" /* for ED_curve_editnurbs */
+#include "ED_curve.h" /* for curve_editnurbs */
+#include "ED_clip.h"
 
 //#include "BDR_unwrapper.h"
 
@@ -626,7 +627,7 @@ static void recalcData_view3d(TransInfo *t)
        if (t->obedit) {
                if ELEM(t->obedit->type, OB_CURVE, OB_SURF) {
                        Curve *cu= t->obedit->data;
-                       ListBase *nurbs= ED_curve_editnurbs(cu);
+                       ListBase *nurbs= curve_editnurbs(cu);
                        Nurb *nu= nurbs->first;
                        
                        if(t->state != TRANS_CANCEL) {
@@ -865,6 +866,48 @@ void recalcData(TransInfo *t)
        else if (t->spacetype == SPACE_VIEW3D) {
                recalcData_view3d(t);
        }
+       else if (t->spacetype == SPACE_CLIP) {
+               SpaceClip *sc= t->sa->spacedata.first;
+               MovieClip *clip= ED_space_clip(sc);
+               MovieTrackingTrack *track;
+
+               if(t->state == TRANS_CANCEL) {
+                       track= clip->tracking.tracks.first;
+                       while(track) {
+                               if(TRACK_VIEW_SELECTED(sc, track)) {
+                                       MovieTrackingMarker *marker= BKE_tracking_ensure_marker(track, sc->user.framenr);
+
+                                       marker->flag= track->transflag;
+                               }
+
+                               track= track->next;
+                       }
+               }
+
+               flushTransTracking(t);
+
+               track= clip->tracking.tracks.first;
+               while(track) {
+                       if(TRACK_VIEW_SELECTED(sc, track)) {
+                               if (t->mode == TFM_TRANSLATION) {
+                                       if(TRACK_AREA_SELECTED(track, TRACK_AREA_PAT))
+                                               BKE_tracking_clamp_track(track, CLAMP_PAT_POS);
+                                       if(TRACK_AREA_SELECTED(track, TRACK_AREA_SEARCH))
+                                               BKE_tracking_clamp_track(track, CLAMP_SEARCH_POS);
+                               }
+                               else if (t->mode == TFM_RESIZE) {
+                                       if(TRACK_AREA_SELECTED(track, TRACK_AREA_PAT))
+                                               BKE_tracking_clamp_track(track, CLAMP_PAT_DIM);
+                                       if(TRACK_AREA_SELECTED(track, TRACK_AREA_SEARCH))
+                                               BKE_tracking_clamp_track(track, CLAMP_SEARCH_DIM);
+                               }
+                       }
+
+                       track= track->next;
+               }
+
+               DAG_id_tag_update(&clip->id, 0);
+       }
 }
 
 void drawLine(TransInfo *t, float *center, float *dir, char axis, short options)
@@ -943,7 +986,7 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
        
        if (event)
        {
-               VECCOPY2D(t->imval, event->mval);
+               copy_v2_v2_int(t->imval, event->mval);
                t->event_type = event->type;
        }
        else
@@ -1187,6 +1230,12 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
                t->options |= CTX_NO_PET;
        }
        
+       // Mirror is not supported with PET, turn it off.
+       if (t->flag & T_PROP_EDIT)
+       {
+               t->flag &= ~T_MIRROR;
+       }
+
        setTransformViewMatrices(t);
        initNumInput(&t->num);
        
@@ -1270,7 +1319,8 @@ void applyTransObjects(TransInfo *t)
        recalcData(t);
 }
 
-static void restoreElement(TransData *td) {
+static void restoreElement(TransData *td)
+{
        /* TransData for crease has no loc */
        if (td->loc) {
                copy_v3_v3(td->loc, td->iloc);
@@ -1294,7 +1344,7 @@ static void restoreElement(TransData *td) {
                        copy_v3_v3(td->ext->size, td->ext->isize);
                }
                if (td->ext->quat) {
-                       QUATCOPY(td->ext->quat, td->ext->iquat);
+                       copy_qt_qt(td->ext->quat, td->ext->iquat);
                }
        }
        
@@ -1666,13 +1716,13 @@ void calculatePropRatio(TransInfo *t)
                        strcpy(t->proptext, "(Random)");
                        break;
                default:
-                       strcpy(t->proptext, "");
+                       t->proptext[0]= '\0';
                }
        }
        else {
                for(i = 0 ; i < t->total; i++, td++) {
                        td->factor = 1.0;
                }
-               strcpy(t->proptext, "");
+               t->proptext[0]= '\0';
        }
 }