Esempio n. 1
0
PyObject *pyrna_callback_remove(BPy_StructRNA *self, PyObject *args)
{
	PyObject *py_handle;
	void *handle;
	void *customdata;

	if (!PyArg_ParseTuple(args, "O!:callback_remove", &PyCapsule_Type, &py_handle))
		return NULL;

	handle = PyCapsule_GetPointer(py_handle, RNA_CAPSULE_ID);

	if (handle == NULL) {
		PyErr_SetString(PyExc_ValueError, "callback_remove(handle): NULL handle given, invalid or already removed");
		return NULL;
	}

	if (RNA_struct_is_a(self->ptr.type, &RNA_Region)) {
		customdata = ED_region_draw_cb_customdata(handle);
		Py_DECREF((PyObject *)customdata);

		ED_region_draw_cb_exit(((ARegion *)self->ptr.data)->type, handle);
	}
	else {
		PyErr_SetString(PyExc_TypeError, "callback_remove(): type does not support callbacks");
		return NULL;
	}

	/* don't allow reuse */
	PyCapsule_SetName(py_handle, RNA_CAPSULE_ID_INVALID);

	Py_RETURN_NONE;
}
Esempio n. 2
0
static void edbm_bevel_exit(bContext *C, wmOperator *op)
{
  BevelData *opdata = op->customdata;

  ScrArea *sa = CTX_wm_area(C);

  if (sa) {
    ED_area_status_text(sa, NULL);
  }

  if (opdata->is_modal) {
    View3D *v3d = CTX_wm_view3d(C);
    ARegion *ar = CTX_wm_region(C);
    for (uint ob_index = 0; ob_index < opdata->ob_store_len; ob_index++) {
      EDBM_redo_state_free(&opdata->ob_store[ob_index].mesh_backup, NULL, false);
    }
    ED_region_draw_cb_exit(ar->type, opdata->draw_handle_pixel);
    if (v3d) {
      v3d->gizmo_flag = opdata->gizmo_flag;
    }
    G.moving = 0;
  }
  MEM_SAFE_FREE(opdata->ob_store);
  MEM_SAFE_FREE(op->customdata);
  op->customdata = NULL;
}
Esempio n. 3
0
static int flyEnd(bContext *C, FlyInfo *fly)
{
	wmWindow *win;
	RegionView3D *rv3d;

	if (fly->state == FLY_RUNNING)
		return OPERATOR_RUNNING_MODAL;

#ifdef NDOF_FLY_DEBUG
	puts("\n-- fly end --");
#endif

	win = CTX_wm_window(C);
	rv3d = fly->rv3d;

	WM_event_remove_timer(CTX_wm_manager(C), win, fly->timer);

	ED_region_draw_cb_exit(fly->ar->type, fly->draw_handle_pixel);

	ED_view3d_cameracontrol_release(fly->v3d_camera_control, fly->state == FLY_CANCEL);

	rv3d->rflag &= ~RV3D_NAVIGATING;

	if (fly->ndof)
		MEM_freeN(fly->ndof);

	if (fly->state == FLY_CONFIRM) {
		MEM_freeN(fly);
		return OPERATOR_FINISHED;
	}

	MEM_freeN(fly);
	return OPERATOR_CANCELLED;
}
static void sample_exit(bContext *C, wmOperator *op)
{
	ImageSampleInfo *info = op->customdata;

	ED_region_draw_cb_exit(info->art, info->draw_handle);
	ED_area_tag_redraw(CTX_wm_area(C));
	MEM_freeN(info);
}
Esempio n. 5
0
static int walkEnd(bContext *C, WalkInfo *walk)
{
	wmWindow *win;
	RegionView3D *rv3d;

	if (walk->state == WALK_RUNNING)
		return OPERATOR_RUNNING_MODAL;

#ifdef NDOF_WALK_DEBUG
	puts("\n-- walk end --");
#endif

	win = CTX_wm_window(C);
	rv3d = walk->rv3d;

	WM_event_remove_timer(CTX_wm_manager(C), win, walk->timer);

	ED_region_draw_cb_exit(walk->ar->type, walk->draw_handle_pixel);

	ED_transform_snap_object_context_destroy(walk->snap_context);

	ED_view3d_cameracontrol_release(walk->v3d_camera_control, walk->state == WALK_CANCEL);

	rv3d->rflag &= ~RV3D_NAVIGATING;

	if (walk->ndof)
		MEM_freeN(walk->ndof);

	/* restore the cursor */
	WM_cursor_modal_restore(win);

#ifdef USE_TABLET_SUPPORT
	if (walk->is_cursor_absolute == false)
#endif
	{
		/* center the mouse */
		WM_cursor_warp(
		        win,
		        walk->ar->winrct.xmin + walk->center_mval[0],
		        walk->ar->winrct.ymin + walk->center_mval[1]);
	}

	if (walk->state == WALK_CONFIRM) {
		MEM_freeN(walk);
		return OPERATOR_FINISHED;
	}

	MEM_freeN(walk);
	return OPERATOR_CANCELLED;
}
Esempio n. 6
0
static void depthdropper_exit(bContext *C, wmOperator *op)
{
	WM_cursor_modal_restore(CTX_wm_window(C));

	if (op->customdata) {
		DepthDropper *ddr = (DepthDropper *)op->customdata;

		if (ddr->art) {
			ED_region_draw_cb_exit(ddr->art, ddr->draw_handle_pixel);
		}

		MEM_freeN(op->customdata);

		op->customdata = NULL;
	}
}
Esempio n. 7
0
static void edbm_bevel_exit(bContext *C, wmOperator *op)
{
	BevelData *opdata = op->customdata;

	ScrArea *sa = CTX_wm_area(C);

	if (sa) {
		ED_area_headerprint(sa, NULL);
	}

	if (opdata->is_modal) {
		View3D *v3d = CTX_wm_view3d(C);
		ARegion *ar = CTX_wm_region(C);
		EDBM_redo_state_free(&opdata->mesh_backup, NULL, false);
		ED_region_draw_cb_exit(ar->type, opdata->draw_handle_pixel);
		v3d->twtype = opdata->twtype;
		G.moving = 0;
	}
	MEM_freeN(opdata);
	op->customdata = NULL;
}
Esempio n. 8
0
/* free, use for both cancel and finish */
static void view3d_ruler_end(const struct bContext *UNUSED(C), RulerInfo *ruler_info)
{
	ED_region_draw_cb_exit(ruler_info->ar->type, ruler_info->draw_handle_pixel);
}
Esempio n. 9
0
PyObject *pyrna_callback_classmethod_remove(PyObject *UNUSED(self), PyObject *args)
{
	PyObject *cls;
	PyObject *py_handle;
	void *handle;
	void *customdata;
	StructRNA *srna;
	char *cb_regiontype_str;
	int cb_regiontype;

	if (PyTuple_GET_SIZE(args) < 2) {
		PyErr_SetString(PyExc_ValueError, "callback_remove(handle): expected at least 2 args");
		return NULL;
	}

	cls = PyTuple_GET_ITEM(args, 0);
	if (!(srna = pyrna_struct_as_srna(cls, false, "callback_remove"))) {
		return NULL;
	}
	py_handle = PyTuple_GET_ITEM(args, 1);
	handle = PyCapsule_GetPointer(py_handle, RNA_CAPSULE_ID);
	if (handle == NULL) {
		PyErr_SetString(PyExc_ValueError, "callback_remove(handle): NULL handle given, invalid or already removed");
		return NULL;
	}

	if (RNA_struct_is_a(srna, &RNA_Space)) {
		if (!PyArg_ParseTuple(args, "OO!s:Space.draw_handler_remove",
		                      &cls, &PyCapsule_Type, &py_handle,  /* already assigned, no matter */
		                      &cb_regiontype_str))
		{
			return NULL;
		}

		customdata = ED_region_draw_cb_customdata(handle);
		Py_DECREF((PyObject *)customdata);

		if (pyrna_enum_value_from_id(region_type_items, cb_regiontype_str, &cb_regiontype, "bpy_struct.callback_remove()") == -1) {
			return NULL;
		}
		else {
			const eSpace_Type spaceid = rna_Space_refine_reverse(srna);
			if (spaceid == -1) {
				PyErr_Format(PyExc_TypeError, "unknown space type '%.200s'", RNA_struct_identifier(srna));
				return NULL;
			}
			else {
				SpaceType *st = BKE_spacetype_from_id(spaceid);
				ARegionType *art = BKE_regiontype_from_id(st, cb_regiontype);

				ED_region_draw_cb_exit(art, handle);
			}
		}
	}
	else {
		PyErr_SetString(PyExc_TypeError, "callback_remove(): type does not support callbacks");
		return NULL;
	}

	/* don't allow reuse */
	PyCapsule_SetName(py_handle, RNA_CAPSULE_ID_INVALID);

	Py_RETURN_NONE;
}
Esempio n. 10
0
static int flyEnd(bContext *C, FlyInfo *fly)
{
	RegionView3D *rv3d = fly->rv3d;
	View3D *v3d = fly->v3d;

	float upvec[3];

	if (fly->state == FLY_RUNNING)
		return OPERATOR_RUNNING_MODAL;

#ifdef NDOF_FLY_DEBUG
	puts("\n-- fly end --");
#endif

	WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), fly->timer);

	ED_region_draw_cb_exit(fly->ar->type, fly->draw_handle_pixel);

	rv3d->dist = fly->dist_backup;
	if (fly->state == FLY_CANCEL) {
		/* Revert to original view? */
		if (fly->persp_backup == RV3D_CAMOB) { /* a camera view */
			Object *ob_back;
			ob_back = (fly->root_parent) ? fly->root_parent : fly->v3d->camera;

			/* store the original camera loc and rot */
			BKE_object_tfm_restore(ob_back, fly->obtfm);

			DAG_id_tag_update(&ob_back->id, OB_RECALC_OB);
		}
		else {
			/* Non Camera we need to reset the view back to the original location bacause the user canceled*/
			copy_qt_qt(rv3d->viewquat, fly->rot_backup);
			rv3d->persp = fly->persp_backup;
		}
		/* always, is set to zero otherwise */
		copy_v3_v3(rv3d->ofs, fly->ofs_backup);
	}
	else if (fly->persp_backup == RV3D_CAMOB) { /* camera */
		DAG_id_tag_update(fly->root_parent ? &fly->root_parent->id : &v3d->camera->id, OB_RECALC_OB);
		
		/* always, is set to zero otherwise */
		copy_v3_v3(rv3d->ofs, fly->ofs_backup);
	}
	else { /* not camera */

		/* Apply the fly mode view */
		/* restore the dist */
		float mat[3][3];
		upvec[0] = upvec[1] = 0;
		upvec[2] = fly->dist_backup; /* x and y are 0 */
		copy_m3_m4(mat, rv3d->viewinv);
		mul_m3_v3(mat, upvec);
		add_v3_v3(rv3d->ofs, upvec);
		/* Done with correcting for the dist */
	}

	if (fly->is_ortho_cam) {
		((Camera *)fly->v3d->camera->data)->type = CAM_ORTHO;
	}

	rv3d->rflag &= ~RV3D_NAVIGATING;
//XXX2.5	BIF_view3d_previewrender_signal(fly->sa, PR_DBASE|PR_DISPRECT); /* not working at the moment not sure why */

	if (fly->obtfm)
		MEM_freeN(fly->obtfm);
	if (fly->ndof)
		MEM_freeN(fly->ndof);

	if (fly->state == FLY_CONFIRM) {
		MEM_freeN(fly);
		return OPERATOR_FINISHED;
	}

	MEM_freeN(fly);
	return OPERATOR_CANCELLED;
}