Merging r39717 through r39983 from trunk into soc-2011-tomato
[blender.git] / source / blender / editors / transform / transform_generics.c
index a43fc6a31e5d7d3835d4f2542ced827e7b0f17bf..00272905c5942f1e8654bcc450cbb64f0575ff67 100644 (file)
@@ -49,6 +49,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 +73,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"
@@ -85,6 +87,7 @@
 #include "ED_uvedit.h"
 #include "ED_view3d.h"
 #include "ED_curve.h" /* for ED_curve_editnurbs */
+#include "ED_clip.h"
 
 //#include "BDR_unwrapper.h"
 
@@ -865,6 +868,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)
@@ -911,6 +956,7 @@ void resetTransRestrictions(TransInfo *t)
        t->flag &= ~T_ALL_RESTRICTIONS;
 }
 
+/* the *op can be NULL */
 int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
 {
        Scene *sce = CTX_data_scene(C);
@@ -1039,7 +1085,7 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
                }
 
                /* initialize UV transform from */
-               if (RNA_struct_find_property(op->ptr, "correct_uv")) {
+               if (op && RNA_struct_find_property(op->ptr, "correct_uv")) {
                        if(RNA_property_is_set(op->ptr, "correct_uv")) {
                                if(RNA_boolean_get(op->ptr, "correct_uv")) {
                                        t->settings->uvcalc_flag |= UVCALC_TRANSFORM_CORRECT;
@@ -1188,7 +1234,6 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
        
        setTransformViewMatrices(t);
        initNumInput(&t->num);
-       initNDofInput(&t->ndof);
        
        return 1;
 }