[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [49195] trunk/blender/source/blender/ editors: wip mask/image commit, mostly internal function & added some TODO' s

Campbell Barton ideasman42 at gmail.com
Wed Jul 25 12:39:54 CEST 2012


Revision: 49195
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=49195
Author:   campbellbarton
Date:     2012-07-25 10:39:54 +0000 (Wed, 25 Jul 2012)
Log Message:
-----------
wip mask/image commit, mostly internal function & added some TODO's

Modified Paths:
--------------
    trunk/blender/source/blender/editors/include/ED_clip.h
    trunk/blender/source/blender/editors/include/ED_image.h
    trunk/blender/source/blender/editors/mask/mask_edit.c
    trunk/blender/source/blender/editors/mask/mask_ops.c
    trunk/blender/source/blender/editors/mask/mask_select.c
    trunk/blender/source/blender/editors/space_image/image_edit.c

Modified: trunk/blender/source/blender/editors/include/ED_clip.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_clip.h	2012-07-25 10:37:31 UTC (rev 49194)
+++ trunk/blender/source/blender/editors/include/ED_clip.h	2012-07-25 10:39:54 UTC (rev 49195)
@@ -65,7 +65,7 @@
 void ED_clip_update_frame(const struct Main *mainp, int cfra);
 int ED_clip_view_selection(const struct bContext *C, struct ARegion *ar, int fit);
 
-void ED_clip_point_undistorted_pos(SpaceClip *sc, const float co[2], float r_co[2]);
+void ED_clip_point_undistorted_pos(struct SpaceClip *sc, const float co[2], float r_co[2]);
 void ED_clip_point_stable_pos(const struct bContext *C, float x, float y, float *xr, float *yr);
 void ED_clip_point_stable_pos__reverse(const struct bContext *C, const float co[2], float r_co[2]);
 void ED_clip_mouse_pos(const struct bContext *C, struct wmEvent *event, float co[2]);

Modified: trunk/blender/source/blender/editors/include/ED_image.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_image.h	2012-07-25 10:37:31 UTC (rev 49194)
+++ trunk/blender/source/blender/editors/include/ED_image.h	2012-07-25 10:39:54 UTC (rev 49195)
@@ -42,7 +42,9 @@
 
 /* image_edit.c, exported for transform */
 struct Image *ED_space_image(struct SpaceImage *sima);
-void ED_space_image_set(struct SpaceImage *sima, struct Scene *scene, struct Object *obedit, struct Image *ima);
+void          ED_space_image_set(struct SpaceImage *sima, struct Scene *scene, struct Object *obedit, struct Image *ima);
+struct Mask  *ED_space_image_get_mask(struct SpaceImage *sima);
+void          ED_space_image_set_mask(struct bContext *C, struct SpaceImage *sima, struct Mask *mask);
 
 struct ImBuf *ED_space_image_acquire_buffer(struct SpaceImage *sima, void **lock_r);
 void ED_space_image_release_buffer(struct SpaceImage *sima, void *lock);
@@ -65,6 +67,10 @@
 int ED_space_image_show_uvedit(struct SpaceImage *sima, struct Object *obedit);
 int ED_space_image_show_uvshadow(struct SpaceImage *sima, struct Object *obedit);
 
+int ED_space_image_check_show_maskedit(struct SpaceImage *sima);
+int ED_space_image_maskedit_poll(struct bContext *C);
+int ED_space_image_maskedit_mask_poll(struct bContext *C);
+
 /* UI level image (texture) updating... render calls own stuff (too) */
 void ED_image_update_frame(const struct Main *mainp, int cfra);
 

Modified: trunk/blender/source/blender/editors/mask/mask_edit.c
===================================================================
--- trunk/blender/source/blender/editors/mask/mask_edit.c	2012-07-25 10:37:31 UTC (rev 49194)
+++ trunk/blender/source/blender/editors/mask/mask_edit.c	2012-07-25 10:39:54 UTC (rev 49195)
@@ -63,6 +63,8 @@
 				return ED_space_clip_maskedit_poll(C);
 			case SPACE_SEQ:
 				return ED_space_sequencer_maskedit_poll(C);
+			case SPACE_IMAGE:
+				return ED_space_image_maskedit_poll(C);
 		}
 	}
 	return FALSE;
@@ -77,6 +79,8 @@
 				return ED_space_clip_maskedit_mask_poll(C);
 			case SPACE_SEQ:
 				return ED_space_sequencer_maskedit_mask_poll(C);
+			case SPACE_IMAGE:
+				return ED_space_sequencer_maskedit_mask_poll(C);
 		}
 	}
 	return FALSE;
@@ -86,14 +90,31 @@
 
 void ED_mask_mouse_pos(const bContext *C, wmEvent *event, float co[2])
 {
-	SpaceClip *sc = CTX_wm_space_clip(C);
-
-	if (sc) {
-		ED_clip_mouse_pos(C, event, co);
-		BKE_mask_coord_from_movieclip(sc->clip, &sc->user, co, co);
+	ScrArea *sa = CTX_wm_area(C);
+	if (sa) {
+		switch (sa->spacetype) {
+			case SPACE_CLIP:
+			{
+				SpaceClip *sc = sa->spacedata.first;
+				ED_clip_mouse_pos(C, event, co);
+				BKE_mask_coord_from_movieclip(sc->clip, &sc->user, co, co);
+				break;
+			}
+			case SPACE_SEQ:
+				zero_v2(co); /* MASKTODO */
+				break;
+			case SPACE_IMAGE:
+				zero_v2(co); /* MASKTODO */
+				break;
+			default:
+				/* possible other spaces from which mask editing is available */
+				BLI_assert(0);
+				zero_v2(co);
+				break;
+		}
 	}
 	else {
-		/* possible other spaces from which mask editing is available */
+		BLI_assert(0);
 		zero_v2(co);
 	}
 }
@@ -102,15 +123,33 @@
  * output: xr/yr - mask point space */
 void ED_mask_point_pos(const bContext *C, float x, float y, float *xr, float *yr)
 {
-	SpaceClip *sc = CTX_wm_space_clip(C);
+	ScrArea *sa = CTX_wm_area(C);
 	float co[2];
 
-	if (sc) {
-		ED_clip_point_stable_pos(C, x, y, &co[0], &co[1]);
-		BKE_mask_coord_from_movieclip(sc->clip, &sc->user, co, co);
+	if (sa) {
+		switch (sa->spacetype) {
+			case SPACE_CLIP:
+			{
+				SpaceClip *sc = sa->spacedata.first;
+				ED_clip_point_stable_pos(C, x, y, &co[0], &co[1]);
+				BKE_mask_coord_from_movieclip(sc->clip, &sc->user, co, co);
+				break;
+			}
+			case SPACE_SEQ:
+				zero_v2(co); /* MASKTODO */
+				break;
+			case SPACE_IMAGE:
+				zero_v2(co); /* MASKTODO */
+				break;
+			default:
+				/* possible other spaces from which mask editing is available */
+				BLI_assert(0);
+				zero_v2(co);
+				break;
+		}
 	}
 	else {
-		/* possible other spaces from which mask editing is available */
+		BLI_assert(0);
 		zero_v2(co);
 	}
 
@@ -120,19 +159,35 @@
 
 void ED_mask_point_pos__reverse(const bContext *C, float x, float y, float *xr, float *yr)
 {
-	SpaceClip *sc = CTX_wm_space_clip(C);
-	ARegion *ar = CTX_wm_region(C);
-
+	ScrArea *sa = CTX_wm_area(C);
 	float co[2];
 
-	if (sc && ar) {
-		co[0] = x;
-		co[1] = y;
-		BKE_mask_coord_to_movieclip(sc->clip, &sc->user, co, co);
-		ED_clip_point_stable_pos__reverse(C, co, co);
+	if (sa) {
+		switch (sa->spacetype) {
+			case SPACE_CLIP:
+			{
+				SpaceClip *sc = sa->spacedata.first;
+				co[0] = x;
+				co[1] = y;
+				BKE_mask_coord_to_movieclip(sc->clip, &sc->user, co, co);
+				ED_clip_point_stable_pos__reverse(C, co, co);
+				break;
+			}
+			case SPACE_SEQ:
+				zero_v2(co); /* MASKTODO */
+				break;
+			case SPACE_IMAGE:
+				zero_v2(co); /* MASKTODO */
+				break;
+			default:
+				/* possible other spaces from which mask editing is available */
+				BLI_assert(0);
+				zero_v2(co);
+				break;
+		}
 	}
 	else {
-		/* possible other spaces from which mask editing is available */
+		BLI_assert(0);
 		zero_v2(co);
 	}
 
@@ -148,40 +203,68 @@
 			case SPACE_CLIP:
 			{
 				ED_space_clip_get_size(C, width, height);
-				return;
+				break;
 			}
 			case SPACE_SEQ:
 			{
 				Scene *scene = CTX_data_scene(C);
 				*width = (scene->r.size * scene->r.xsch) / 100;
 				*height = (scene->r.size * scene->r.ysch) / 100;
-				return;
+				break;
 			}
 			case SPACE_IMAGE:
 			{
 				SpaceImage *sima = sa->spacedata.first;
 				ED_space_image_size(sima, width, height);
-				return;
+				break;
 			}
+			default:
+				/* possible other spaces from which mask editing is available */
+				BLI_assert(0);
+				*width = 0;
+				*height = 0;
+				break;
 		}
 	}
-
-	/* possible other spaces from which mask editing is available */
-	*width = 0;
-	*height = 0;
+	else {
+		BLI_assert(0);
+		*width = 0;
+		*height = 0;
+	}
 }
 
 void ED_mask_aspect(const bContext *C, float *aspx, float *aspy)
 {
-	SpaceClip *sc = CTX_wm_space_clip(C);
-
-	if (sc) {
-		ED_space_clip_get_aspect(sc, aspx, aspy);
+	ScrArea *sa = CTX_wm_area(C);
+	if (sa && sa->spacedata.first) {
+		switch (sa->spacetype) {
+			case SPACE_CLIP:
+			{
+				SpaceClip *sc = sa->spacedata.first;
+				ED_space_clip_get_aspect(sc, aspx, aspy);
+				break;
+			}
+			case SPACE_SEQ:
+			{
+				*aspx = *aspy = 1.0f;  /* MASKTODO - render aspect? */
+				break;
+			}
+			case SPACE_IMAGE:
+			{
+				// SpaceImage *sima = sa->spacedata.first;
+				*aspx = *aspy = 1.0f;  /* MASKTODO - image aspect? */
+				break;
+			}
+			default:
+				/* possible other spaces from which mask editing is available */
+				BLI_assert(0);
+				*aspx = *aspy = 1.0f;
+				break;
+		}
 	}
 	else {
-		/* possible other spaces from which mask editing is available */
-		*aspx = 1.0f;
-		*aspy = 1.0f;
+		BLI_assert(0);
+		*aspx = *aspy = 1.0f;
 	}
 }
 
@@ -189,6 +272,8 @@
 {
 	SpaceClip *sc = CTX_wm_space_clip(C);
 
+	/* MASKTODO */
+
 	if (sc) {
 		int width, height;
 		float zoomx, zoomy, aspx, aspy;

Modified: trunk/blender/source/blender/editors/mask/mask_ops.c
===================================================================
--- trunk/blender/source/blender/editors/mask/mask_ops.c	2012-07-25 10:37:31 UTC (rev 49194)
+++ trunk/blender/source/blender/editors/mask/mask_ops.c	2012-07-25 10:39:54 UTC (rev 49195)
@@ -45,10 +45,11 @@
 #include "WM_api.h"
 #include "WM_types.h"
 
-#include "ED_screen.h"
-#include "ED_mask.h"
 #include "ED_clip.h"
+#include "ED_image.h"
 #include "ED_keyframing.h"
+#include "ED_mask.h"
+#include "ED_screen.h"
 
 #include "RNA_access.h"
 #include "RNA_define.h"
@@ -255,7 +256,7 @@
 
 static int mask_new_exec(bContext *C, wmOperator *op)
 {
-	SpaceClip *sc = CTX_wm_space_clip(C);
+	ScrArea *sa = CTX_wm_area(C);
 	Mask *mask;
 	char name[MAX_ID_NAME - 2];
 
@@ -263,8 +264,27 @@
 
 	mask = BKE_mask_new(name);
 
-	if (sc)
-		ED_space_clip_set_mask(C, sc, mask);
+	if (sa && sa->spacedata.first) {
+		switch (sa->spacetype) {
+			case SPACE_CLIP:
+			{
+				SpaceClip *sc = sa->spacedata.first;
+				ED_space_clip_set_mask(C, sc, mask);
+				break;
+			}
+			case SPACE_SEQ:
+			{
+				/* do nothing */
+				break;
+			}
+			case SPACE_IMAGE:
+			{
+				SpaceImage *sima = sa->spacedata.first;
+				ED_space_image_set_mask(C, sima, mask);
+				break;
+			}
+		}
+	}
 
 	return OPERATOR_FINISHED;
 }

Modified: trunk/blender/source/blender/editors/mask/mask_select.c
===================================================================
--- trunk/blender/source/blender/editors/mask/mask_select.c	2012-07-25 10:37:31 UTC (rev 49194)
+++ trunk/blender/source/blender/editors/mask/mask_select.c	2012-07-25 10:39:54 UTC (rev 49195)
@@ -539,6 +539,7 @@
 	return OPERATOR_PASS_THROUGH;
 }
 
+/* MASKTODO - image space */
 void MASK_OT_select_lasso(wmOperatorType *ot)
 {
 	/* identifiers */
@@ -638,6 +639,7 @@
 	return OPERATOR_CANCELLED;
 }
 
+/* MASKTODO - image space */
 void MASK_OT_select_circle(wmOperatorType *ot)
 {
 	/* identifiers */

Modified: trunk/blender/source/blender/editors/space_image/image_edit.c
===================================================================
--- trunk/blender/source/blender/editors/space_image/image_edit.c	2012-07-25 10:37:31 UTC (rev 49194)
+++ trunk/blender/source/blender/editors/space_image/image_edit.c	2012-07-25 10:39:54 UTC (rev 49195)
@@ -28,13 +28,15 @@
  *  \ingroup spimage
  */
 
+#include "DNA_mask_types.h"
 #include "DNA_object_types.h"

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list