static void draw_plane_marker_ex(SpaceClip *sc, Scene *scene, MovieTrackingPlaneTrack *plane_track,
                                 MovieTrackingPlaneMarker *plane_marker, bool is_active_track,
                                 bool draw_outline, int width, int height)
{
	bool tiny = (sc->flag & SC_SHOW_TINY_MARKER) != 0;
	bool is_selected_track = plane_track->flag & SELECT;
	bool draw_plane_quad = plane_track->image == NULL || plane_track->image_opacity == 0.0f;
	float px[2];

	if (draw_outline) {
		UI_ThemeColor(TH_MARKER_OUTLINE);
	}
	else {
		float color[3], selected_color[3];
		plane_track_colors(is_active_track, color, selected_color);
		if (is_selected_track) {
			glColor3fv(selected_color);
		}
		else {
			glColor3fv(color);
		}
	}

	px[0] = 1.0f / width / sc->zoom;
	px[1] = 1.0f / height / sc->zoom;

	/* Draw image */
	if (draw_outline == false) {
		draw_plane_marker_image(scene, plane_track, plane_marker);
	}

	if (draw_outline) {
		if (!tiny) {
			glLineWidth(3.0f);
		}
	}
	else if (tiny) {
		glLineStipple(3, 0xaaaa);
		glEnable(GL_LINE_STIPPLE);
	}

	if (draw_plane_quad) {
		/* Draw rectangle itself. */
		glBegin(GL_LINE_LOOP);
		glVertex2fv(plane_marker->corners[0]);
		glVertex2fv(plane_marker->corners[1]);
		glVertex2fv(plane_marker->corners[2]);
		glVertex2fv(plane_marker->corners[3]);
		glEnd();

		/* Draw axis. */
		if (!draw_outline) {
			float end_point[2];
			glPushAttrib(GL_COLOR_BUFFER_BIT | GL_CURRENT_BIT);

			getArrowEndPoint(width, height, sc->zoom, plane_marker->corners[0], plane_marker->corners[1], end_point);
			glColor3f(1.0, 0.0, 0.0f);
			glBegin(GL_LINES);
			glVertex2fv(plane_marker->corners[0]);
			glVertex2fv(end_point);
			glEnd();

			getArrowEndPoint(width, height, sc->zoom, plane_marker->corners[0], plane_marker->corners[3], end_point);
			glColor3f(0.0, 1.0, 0.0f);
			glBegin(GL_LINES);
			glVertex2fv(plane_marker->corners[0]);
			glVertex2fv(end_point);
			glEnd();

			glPopAttrib();
		}
	}

	/* Draw sliders. */
	if (is_selected_track) {
		int i;
		for (i = 0; i < 4; i++) {
			draw_marker_slide_square(plane_marker->corners[i][0], plane_marker->corners[i][1],
			                         3.0f * px[0], 3.0f * px[1], draw_outline, px);
		}
	}

	if (draw_outline) {
		if (!tiny) {
			glLineWidth(1.0f);
		}
	}
	else if (tiny) {
		glDisable(GL_LINE_STIPPLE);
	}
}
Beispiel #2
0
static void draw_plane_marker_ex(SpaceClip *sc, Scene *scene, MovieTrackingPlaneTrack *plane_track,
                                 MovieTrackingPlaneMarker *plane_marker, bool is_active_track,
                                 bool draw_outline, int width, int height)
{
	bool tiny = (sc->flag & SC_SHOW_TINY_MARKER) != 0;
	bool is_selected_track = (plane_track->flag & SELECT) != 0;
	const bool has_image = plane_track->image != NULL &&
	                       BKE_image_has_ibuf(plane_track->image, NULL);
	const bool draw_plane_quad = !has_image || plane_track->image_opacity == 0.0f;
	float px[2];

	if (draw_outline) {
		UI_ThemeColor(TH_MARKER_OUTLINE);
	}
	else {
		float color[3], selected_color[3];
		plane_track_colors(is_active_track, color, selected_color);
		if (is_selected_track) {
			glColor3fv(selected_color);
		}
		else {
			glColor3fv(color);
		}
	}

	px[0] = 1.0f / width / sc->zoom;
	px[1] = 1.0f / height / sc->zoom;

	/* Draw image */
	if (draw_outline == false) {
		draw_plane_marker_image(scene, plane_track, plane_marker);
	}

	if (draw_plane_quad) {

		const bool stipple = !draw_outline && tiny;
		const bool thick = draw_outline && !tiny;

		if (stipple) {
			GPU_basic_shader_bind_enable(GPU_SHADER_LINE | GPU_SHADER_STIPPLE);
			GPU_basic_shader_line_stipple(3, 0xAAAA);
		}
		else {
			GPU_basic_shader_bind_enable(GPU_SHADER_LINE);
		}

		GPU_basic_shader_line_width(thick ? 3.0f : 1.0f);

		/* Draw rectangle itself. */
		glBegin(GL_LINE_LOOP);
		glVertex2fv(plane_marker->corners[0]);
		glVertex2fv(plane_marker->corners[1]);
		glVertex2fv(plane_marker->corners[2]);
		glVertex2fv(plane_marker->corners[3]);
		glEnd();

		/* Draw axis. */
		if (!draw_outline) {
			float end_point[2];
			glPushAttrib(GL_COLOR_BUFFER_BIT | GL_CURRENT_BIT);

			glBegin(GL_LINES);

			getArrowEndPoint(width, height, sc->zoom, plane_marker->corners[0], plane_marker->corners[1], end_point);
			glColor3f(1.0, 0.0, 0.0f);
			glVertex2fv(plane_marker->corners[0]);
			glVertex2fv(end_point);

			getArrowEndPoint(width, height, sc->zoom, plane_marker->corners[0], plane_marker->corners[3], end_point);
			glColor3f(0.0, 1.0, 0.0f);
			glVertex2fv(plane_marker->corners[0]);
			glVertex2fv(end_point);

			glEnd();

			glPopAttrib();
		}

		if (stipple) {
			GPU_basic_shader_bind_disable(GPU_SHADER_LINE | GPU_SHADER_STIPPLE);
		}
		else {
			GPU_basic_shader_bind_disable(GPU_SHADER_LINE);
		}
	}

	/* Draw sliders. */
	if (is_selected_track) {
		int i;
		for (i = 0; i < 4; i++) {
			draw_marker_slide_square(plane_marker->corners[i][0], plane_marker->corners[i][1],
			                         3.0f * px[0], 3.0f * px[1], draw_outline, px);
		}
	}
}