[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [46066] trunk/blender: Camera tracking: backport refactoring made in local branches with masking and dopesheet view into trunk

Sergey Sharybin sergey.vfx at gmail.com
Sun Apr 29 14:32:26 CEST 2012


Revision: 46066
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=46066
Author:   nazgul
Date:     2012-04-29 12:32:26 +0000 (Sun, 29 Apr 2012)
Log Message:
-----------
Camera tracking: backport refactoring made in local branches with masking and dopesheet view into trunk

Mostly related on changes in poll functions for tracking operators and some changes
to how interface is initializing for different view types.

Modified Paths:
--------------
    trunk/blender/release/scripts/startup/bl_ui/space_clip.py
    trunk/blender/source/blender/editors/include/ED_clip.h
    trunk/blender/source/blender/editors/space_clip/clip_buttons.c
    trunk/blender/source/blender/editors/space_clip/clip_editor.c
    trunk/blender/source/blender/editors/space_clip/clip_graph_draw.c
    trunk/blender/source/blender/editors/space_clip/clip_graph_ops.c
    trunk/blender/source/blender/editors/space_clip/clip_intern.h
    trunk/blender/source/blender/editors/space_clip/clip_toolbar.c
    trunk/blender/source/blender/editors/space_clip/clip_utils.c
    trunk/blender/source/blender/editors/space_clip/space_clip.c
    trunk/blender/source/blender/editors/space_clip/tracking_ops.c
    trunk/blender/source/blender/editors/transform/transform.c
    trunk/blender/source/blender/editors/transform/transform_conversions.c
    trunk/blender/source/blender/editors/transform/transform_generics.c
    trunk/blender/source/blender/makesdna/DNA_space_types.h
    trunk/blender/source/blender/makesrna/intern/rna_space.c

Modified: trunk/blender/release/scripts/startup/bl_ui/space_clip.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/space_clip.py	2012-04-29 12:20:06 UTC (rev 46065)
+++ trunk/blender/release/scripts/startup/bl_ui/space_clip.py	2012-04-29 12:32:26 UTC (rev 46066)
@@ -829,7 +829,11 @@
 
     def draw(self, context):
         layout = self.layout
+        sc = context.space_data
 
+        layout.prop(sc, "show_seconds")
+        layout.separator()
+
         layout.operator("clip.properties", icon='MENU_PANEL')
         layout.operator("clip.tools", icon='MENU_PANEL')
         layout.separator()

Modified: trunk/blender/source/blender/editors/include/ED_clip.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_clip.h	2012-04-29 12:20:06 UTC (rev 46065)
+++ trunk/blender/source/blender/editors/include/ED_clip.h	2012-04-29 12:32:26 UTC (rev 46066)
@@ -41,6 +41,9 @@
 
 /* clip_editor.c */
 int ED_space_clip_poll(struct bContext *C);
+int ED_space_clip_tracking_poll(struct bContext *C);
+int ED_space_clip_tracking_size_poll(struct bContext *C);
+int ED_space_clip_tracking_frame_poll(struct bContext *C);
 
 void ED_space_clip_set(struct bContext *C, struct SpaceClip *sc, struct MovieClip *clip);
 struct MovieClip *ED_space_clip(struct SpaceClip *sc);
@@ -58,6 +61,8 @@
 void ED_clip_point_stable_pos(struct bContext *C, float x, float y, float *xr, float *yr);
 void ED_clip_mouse_pos(struct bContext *C, struct wmEvent *event, float co[2]);
 
+int ED_space_clip_show_trackedit(struct SpaceClip *sc);
+
 /* clip_ops.c */
 void ED_operatormacros_clip(void);
 

Modified: trunk/blender/source/blender/editors/space_clip/clip_buttons.c
===================================================================
--- trunk/blender/source/blender/editors/space_clip/clip_buttons.c	2012-04-29 12:20:06 UTC (rev 46065)
+++ trunk/blender/source/blender/editors/space_clip/clip_buttons.c	2012-04-29 12:32:26 UTC (rev 46066)
@@ -63,6 +63,13 @@
 
 /* Panels */
 
+static int clip_grease_pencil_panel_poll(const bContext *C, PanelType *UNUSED(pt))
+{
+	SpaceClip *sc = CTX_wm_space_clip(C);
+
+	return TRUE;
+}
+
 void ED_clip_buttons_register(ARegionType *art)
 {
 	PanelType *pt;
@@ -72,6 +79,7 @@
 	strcpy(pt->label, "Grease Pencil");
 	pt->draw = gpencil_panel_standard;
 	pt->flag |= PNL_DEFAULT_CLOSED;
+	pt->poll = clip_grease_pencil_panel_poll;
 	BLI_addtail(&art->paneltypes, pt);
 }
 

Modified: trunk/blender/source/blender/editors/space_clip/clip_editor.c
===================================================================
--- trunk/blender/source/blender/editors/space_clip/clip_editor.c	2012-04-29 12:20:06 UTC (rev 46065)
+++ trunk/blender/source/blender/editors/space_clip/clip_editor.c	2012-04-29 12:32:26 UTC (rev 46066)
@@ -35,6 +35,7 @@
 #include "BKE_movieclip.h"
 #include "BKE_context.h"
 #include "BKE_tracking.h"
+
 #include "DNA_object_types.h"	/* SELECT */
 
 #include "BLI_utildefines.h"
@@ -55,6 +56,8 @@
 
 #include "clip_intern.h"	// own include
 
+/* ******** operactor poll functions ******** */
+
 int ED_space_clip_poll(bContext *C)
 {
 	SpaceClip *sc = CTX_wm_space_clip(C);
@@ -65,6 +68,51 @@
 	return FALSE;
 }
 
+int ED_space_clip_tracking_poll(bContext *C)
+{
+	SpaceClip *sc= CTX_wm_space_clip(C);
+
+	if (sc && sc->clip)
+		return ED_space_clip_show_trackedit(sc);
+
+	return FALSE;
+}
+
+int ED_space_clip_tracking_size_poll(bContext *C)
+{
+	if (ED_space_clip_tracking_poll(C)) {
+		MovieClip *clip = CTX_data_edit_movieclip(C);
+
+		if (clip) {
+			SpaceClip *sc = CTX_wm_space_clip(C);
+			int width, height;
+
+			BKE_movieclip_get_size(clip, &sc->user, &width, &height);
+
+			return width > 0 && height > 0;
+		}
+	}
+
+	return FALSE;
+}
+
+int ED_space_clip_tracking_frame_poll(bContext *C)
+{
+	if (ED_space_clip_tracking_poll(C)) {
+		MovieClip *clip = CTX_data_edit_movieclip(C);
+
+		if (clip) {
+			SpaceClip *sc = CTX_wm_space_clip(C);
+
+			return BKE_movieclip_has_frame(clip, &sc->user);
+		}
+	}
+
+	return FALSE;
+}
+
+/* ******** editing functions ******** */
+
 void ED_space_clip_set(bContext *C, SpaceClip *sc, MovieClip *clip)
 {
 	sc->clip = clip;
@@ -314,3 +362,12 @@
 {
 	ED_clip_point_stable_pos(C, event->mval[0], event->mval[1], &co[0], &co[1]);
 }
+
+int ED_space_clip_show_trackedit(SpaceClip *sc)
+{
+	if (sc) {
+		return ELEM3(sc->mode, SC_MODE_TRACKING, SC_MODE_RECONSTRUCTION, SC_MODE_DISTORTION);
+	}
+
+	return FALSE;
+}

Modified: trunk/blender/source/blender/editors/space_clip/clip_graph_draw.c
===================================================================
--- trunk/blender/source/blender/editors/space_clip/clip_graph_draw.c	2012-04-29 12:20:06 UTC (rev 46065)
+++ trunk/blender/source/blender/editors/space_clip/clip_graph_draw.c	2012-04-29 12:32:26 UTC (rev 46066)
@@ -87,60 +87,6 @@
 	glPopMatrix();
 }
 
-static void draw_graph_cfra(SpaceClip *sc, ARegion *ar, Scene *scene)
-{
-	View2D *v2d = &ar->v2d;
-	float xscale, yscale;
-	float vec[2];
-
-	/* Draw a light green line to indicate current frame */
-	vec[0] = (float)(sc->user.framenr * scene->r.framelen);
-
-	UI_ThemeColor(TH_CFRAME);
-	glLineWidth(2.0);
-
-	glBegin(GL_LINE_STRIP);
-		vec[1] = v2d->cur.ymin;
-		glVertex2fv(vec);
-
-		vec[1] = v2d->cur.ymax;
-		glVertex2fv(vec);
-	glEnd();
-
-	glLineWidth(1.0);
-
-	UI_view2d_view_orthoSpecial(ar, v2d, 1);
-
-	/* because the frame number text is subject to the same scaling as the contents of the view */
-	UI_view2d_getscale(v2d, &xscale, &yscale);
-	glScalef(1.0f/xscale, 1.0f, 1.0f);
-
-	clip_draw_curfra_label(sc, (float)sc->user.framenr * xscale, 18);
-
-	/* restore view transform */
-	glScalef(xscale, 1.0, 1.0);
-}
-
-static void draw_graph_sfra_efra(Scene *scene, View2D *v2d)
-{
-	UI_view2d_view_ortho(v2d);
-
-	/* currently clip editor supposes that editing clip length is equal to scene frame range */
-	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-	glEnable(GL_BLEND);
-		glColor4f(0.0f, 0.0f, 0.0f, 0.4f);
-
-		glRectf(v2d->cur.xmin, v2d->cur.ymin, (float)SFRA, v2d->cur.ymax);
-		glRectf((float)EFRA, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
-	glDisable(GL_BLEND);
-
-	UI_ThemeColorShade(TH_BACK, -60);
-
-	/* thin lines where the actual frames are */
-	fdrawline((float)SFRA, v2d->cur.ymin, (float)SFRA, v2d->cur.ymax);
-	fdrawline((float)EFRA, v2d->cur.ymin, (float)EFRA, v2d->cur.ymax);
-}
-
 static void tracking_segment_point_cb(void *UNUSED(userdata), MovieTrackingTrack *UNUSED(track),
 			MovieTrackingMarker *marker, int UNUSED(coord), float val)
 {
@@ -280,8 +226,8 @@
 	}
 
 	/* frame range */
-	draw_graph_sfra_efra(scene, v2d);
+	clip_draw_sfra_efra(v2d, scene);
 
 	/* current frame */
-	draw_graph_cfra(sc, ar, scene);
+	clip_draw_cfra(sc, ar, scene);
 }

Modified: trunk/blender/source/blender/editors/space_clip/clip_graph_ops.c
===================================================================
--- trunk/blender/source/blender/editors/space_clip/clip_graph_ops.c	2012-04-29 12:20:06 UTC (rev 46065)
+++ trunk/blender/source/blender/editors/space_clip/clip_graph_ops.c	2012-04-29 12:32:26 UTC (rev 46066)
@@ -63,15 +63,13 @@
 
 static int ED_space_clip_graph_poll(bContext *C)
 {
-	SpaceClip *sc = CTX_wm_space_clip(C);
-
-	if (sc && sc->clip) {
+	if (ED_space_clip_tracking_poll(C)) {
 		ARegion *ar = CTX_wm_region(C);
 
 		return ar->regiontype == RGN_TYPE_PREVIEW;
 	}
 
-	return 0;
+	return FALSE;
 }
 
 typedef struct {
@@ -486,7 +484,7 @@
 	/* api callbacks */
 	ot->invoke = WM_operator_confirm;
 	ot->exec = delete_curve_exec;
-	ot->poll = ED_space_clip_poll;
+	ot->poll = ED_space_clip_tracking_poll;
 
 	/* flags */
 	ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;

Modified: trunk/blender/source/blender/editors/space_clip/clip_intern.h
===================================================================
--- trunk/blender/source/blender/editors/space_clip/clip_intern.h	2012-04-29 12:20:06 UTC (rev 46065)
+++ trunk/blender/source/blender/editors/space_clip/clip_intern.h	2012-04-29 12:32:26 UTC (rev 46066)
@@ -38,6 +38,7 @@
 struct MovieTrackingMarker;
 struct MovieTrackingTrack;
 struct Scene;
+struct ScrArea;
 struct SpaceClip;
 struct wmOperatorType;
 
@@ -81,6 +82,7 @@
 void CLIP_OT_mode_set(struct wmOperatorType *ot);
 
 /* clip_toolbar.c */
+struct ARegion *ED_clip_has_properties_region(struct ScrArea *sa);
 void CLIP_OT_tools(struct wmOperatorType *ot);
 void CLIP_OT_properties(struct wmOperatorType *ot);
 void ED_clip_tool_props_register(struct ARegionType *art);
@@ -104,6 +106,9 @@
 
 void clip_view_center_to_point(struct SpaceClip *sc, float x, float y);
 
+void clip_draw_cfra(struct SpaceClip *sc, struct ARegion *ar, struct Scene *scene);
+void clip_draw_sfra_efra(struct View2D *v2d, struct Scene *scene);
+
 /* tracking_ops.c */
 void CLIP_OT_select(struct wmOperatorType *ot);
 void CLIP_OT_select_all(struct wmOperatorType *ot);

Modified: trunk/blender/source/blender/editors/space_clip/clip_toolbar.c
===================================================================
--- trunk/blender/source/blender/editors/space_clip/clip_toolbar.c	2012-04-29 12:20:06 UTC (rev 46065)
+++ trunk/blender/source/blender/editors/space_clip/clip_toolbar.c	2012-04-29 12:32:26 UTC (rev 46066)
@@ -56,7 +56,7 @@
 
 /************************** properties ******************************/
 
-static ARegion *clip_has_properties_region(ScrArea *sa)
+ARegion *ED_clip_has_properties_region(ScrArea *sa)
 {
 	ARegion *ar, *arnew;
 
@@ -90,9 +90,9 @@
 static int properties_exec(bContext *C, wmOperator *UNUSED(op))
 {
 	ScrArea *sa = CTX_wm_area(C);
-	ARegion *ar = clip_has_properties_region(sa);
+	ARegion *ar = ED_clip_has_properties_region(sa);
 
-	if (ar)
+	if (ar && ar->alignment != RGN_ALIGN_NONE)
 		ED_region_toggle_hidden(C, ar);
 
 	return OPERATOR_FINISHED;
@@ -167,7 +167,7 @@
 	ScrArea *sa = CTX_wm_area(C);
 	ARegion *ar = clip_has_tools_region(sa);
 
-	if (ar)
+	if (ar && ar->alignment != RGN_ALIGN_NONE)
 		ED_region_toggle_hidden(C, ar);
 
 	return OPERATOR_FINISHED;

Modified: trunk/blender/source/blender/editors/space_clip/clip_utils.c
===================================================================
--- trunk/blender/source/blender/editors/space_clip/clip_utils.c	2012-04-29 12:20:06 UTC (rev 46065)
+++ trunk/blender/source/blender/editors/space_clip/clip_utils.c	2012-04-29 12:32:26 UTC (rev 46066)
@@ -29,6 +29,7 @@
  *  \ingroup spclip
  */
 
+#include "DNA_scene_types.h"
 #include "DNA_object_types.h"	/* SELECT */
 
 #include "MEM_guardedalloc.h"

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list