Exemple #1
0
static void rna_CurveMap_remove_point(CurveMap *cuma, ReportList *reports, PointerRNA *point_ptr)
{
	CurveMapPoint *point = point_ptr->data;
	if (curvemap_remove_point(cuma, point) == false) {
		BKE_report(reports, RPT_ERROR, "Unable to remove curve point");
		return;
	}

	RNA_POINTER_INVALIDATE(point_ptr);
}
Exemple #2
0
static void rna_KeyMap_remove(wmKeyConfig *keyconfig, ReportList *reports, PointerRNA *keymap_ptr)
{
  wmKeyMap *keymap = keymap_ptr->data;

  if (WM_keymap_remove(keyconfig, keymap) == false) {
    BKE_reportf(reports, RPT_ERROR, "KeyConfig '%s' cannot be removed", keymap->idname);
    return;
  }

  RNA_POINTER_INVALIDATE(keymap_ptr);
}
Exemple #3
0
static void rna_KeyConfig_remove(wmWindowManager *wm, ReportList *reports, PointerRNA *keyconf_ptr)
{
  wmKeyConfig *keyconf = keyconf_ptr->data;

  if (WM_keyconfig_remove(wm, keyconf) == false) {
    BKE_reportf(reports, RPT_ERROR, "KeyConfig '%s' cannot be removed", keyconf->idname);
    return;
  }

  RNA_POINTER_INVALIDATE(keyconf_ptr);
}
Exemple #4
0
static void rna_ColorRampElement_remove(struct ColorBand *coba, ReportList *reports, PointerRNA *element_ptr)
{
	CBData *element = element_ptr->data;
	int index = (int)(element - coba->data);
	if (colorband_element_remove(coba, index) == false) {
		BKE_report(reports, RPT_ERROR, "Element not found in element collection or last element");
		return;
	}

	RNA_POINTER_INVALIDATE(element_ptr);
}
Exemple #5
0
static void rna_KeyMap_item_remove(wmKeyMap *km, ReportList *reports, PointerRNA *kmi_ptr)
{
	wmKeyMapItem *kmi = kmi_ptr->data;

	if (WM_keymap_remove_item(km, kmi) == false) {
		BKE_reportf(reports, RPT_ERROR, "KeyMapItem '%s' cannot be removed from '%s'", kmi->idname, km->idname);
		return;
	}

	RNA_POINTER_INVALIDATE(kmi_ptr);
}
Exemple #6
0
static void rna_Action_pose_markers_remove(bAction *act, ReportList *reports, PointerRNA *marker_ptr)
{
    TimeMarker *marker = marker_ptr->data;
    if (!BLI_remlink_safe(&act->markers, marker)) {
        BKE_reportf(reports, RPT_ERROR, "Timeline marker '%s' not found in action '%s'", marker->name, act->id.name + 2);
        return;
    }

    MEM_freeN(marker);
    RNA_POINTER_INVALIDATE(marker_ptr);
}
Exemple #7
0
static void rna_GPencil_frame_remove(bGPDlayer *layer, ReportList *reports, PointerRNA *frame_ptr)
{
	bGPDframe *frame = frame_ptr->data;
	if (BLI_findindex(&layer->frames, frame) == -1) {
		BKE_report(reports, RPT_ERROR, "Frame not found in grease pencil layer");
		return;
	}

	gpencil_layer_delframe(layer, frame);
	RNA_POINTER_INVALIDATE(frame_ptr);

	WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL);
}
static void rna_Mask_layers_remove(Mask *mask, ReportList *reports, PointerRNA *masklay_ptr)
{
	MaskLayer *masklay = masklay_ptr->data;
	if (BLI_findindex(&mask->masklayers, masklay) == -1) {
		BKE_reportf(reports, RPT_ERROR, "Mask layer '%s' not found in mask '%s'", masklay->name, mask->id.name + 2);
		return;
	}

	BKE_mask_layer_remove(mask, masklay);
	RNA_POINTER_INVALIDATE(masklay_ptr);

	WM_main_add_notifier(NC_MASK | NA_EDITED, mask);
}
Exemple #9
0
static void rna_GPencil_layer_remove(bGPdata *gpd, ReportList *reports, PointerRNA *layer_ptr)
{
	bGPDlayer *layer = layer_ptr->data;
	if (BLI_findindex(&gpd->layers, layer) == -1) {
		BKE_report(reports, RPT_ERROR, "Layer not found in grease pencil data");
		return;
	}

	gpencil_layer_delete(gpd, layer);
	RNA_POINTER_INVALIDATE(layer_ptr);

	WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
}
Exemple #10
0
static void rna_NlaStrip_remove(NlaTrack *track, bContext *C, ReportList *reports, PointerRNA *strip_ptr)
{
	NlaStrip *strip = strip_ptr->data;
	if (BLI_findindex(&track->strips, strip) == -1) {
		BKE_reportf(reports, RPT_ERROR, "NLA strip '%s' not found in track '%s'", strip->name, track->name);
		return;
	}

	BKE_nlastrip_free(&track->strips, strip);
	RNA_POINTER_INVALIDATE(strip_ptr);

	WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_REMOVED, NULL);
}
Exemple #11
0
static void rna_GPencil_stroke_remove(bGPDframe *frame, ReportList *reports, PointerRNA *stroke_ptr)
{
	bGPDstroke *stroke = stroke_ptr->data;
	if (BLI_findindex(&frame->strokes, stroke) == -1) {
		BKE_report(reports, RPT_ERROR, "Stroke not found in grease pencil frame");
		return;
	}

	BLI_freelinkN(&frame->strokes, stroke);
	RNA_POINTER_INVALIDATE(stroke_ptr);

	WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL);
}
static void rna_MaskLayer_spline_remove(ID *id, MaskLayer *mask_layer, ReportList *reports, PointerRNA *spline_ptr)
{
	Mask *mask = (Mask *) id;
	MaskSpline *spline = spline_ptr->data;

	if (BKE_mask_spline_remove(mask_layer, spline) == FALSE) {
		BKE_reportf(reports, RPT_ERROR, "Mask layer '%s' does not contain spline given", mask_layer->name);
		return;
	}

	RNA_POINTER_INVALIDATE(spline_ptr);

	DAG_id_tag_update(&mask->id, OB_RECALC_DATA);
}
Exemple #13
0
static void rna_NlaTrack_remove(AnimData *adt, bContext *C, ReportList *reports, PointerRNA *track_ptr)
{
	NlaTrack *track = track_ptr->data;

	if (BLI_findindex(&adt->nla_tracks, track) == -1) {
		BKE_reportf(reports, RPT_ERROR, "NlaTrack '%s' cannot be removed", track->name);
		return;
	}

	free_nlatrack(&adt->nla_tracks, track);
	RNA_POINTER_INVALIDATE(track_ptr);

	WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_REMOVED, NULL);
}
Exemple #14
0
static void rna_Sequences_remove(ID *id, Editing *ed, ReportList *reports, PointerRNA *seq_ptr)
{
	Sequence *seq = seq_ptr->data;
	Scene *scene = (Scene *)id;

	if (BLI_remlink_safe(&ed->seqbase, seq) == false) {
		BKE_reportf(reports, RPT_ERROR, "Sequence '%s' not in scene '%s'", seq->name + 2, scene->id.name + 2);
		return;
	}

	BKE_sequence_free(scene, seq);
	RNA_POINTER_INVALIDATE(seq_ptr);

	WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, scene);
}
static void rna_Armature_edit_bone_remove(bArmature *arm, ReportList *reports, PointerRNA *ebone_ptr)
{
	EditBone *ebone = ebone_ptr->data;
	if (arm->edbo == NULL) {
		BKE_reportf(reports, RPT_ERROR, "Armature '%s' not in edit mode, cannot remove an editbone", arm->id.name + 2);
		return;
	}

	if (BLI_findindex(arm->edbo, ebone) == -1) {
		BKE_reportf(reports, RPT_ERROR, "Armature '%s' does not contain bone '%s'", arm->id.name + 2, ebone->name);
		return;
	}

	ED_armature_edit_bone_remove(arm, ebone);
	RNA_POINTER_INVALIDATE(ebone_ptr);
}
Exemple #16
0
static void rna_MetaBall_elements_remove(MetaBall *mb, ReportList *reports, PointerRNA *ml_ptr)
{
	MetaElem *ml = ml_ptr->data;

	if (BLI_remlink_safe(&mb->elems, ml) == FALSE) {
		BKE_reportf(reports, RPT_ERROR, "Metaball '%s' does not contain spline given", mb->id.name + 2);
		return;
	}

	MEM_freeN(ml);
	RNA_POINTER_INVALIDATE(ml_ptr);

	/* cheating way for importers to avoid slow updates */
	if (mb->id.us > 0) {
		DAG_id_tag_update(&mb->id, 0);
		WM_main_add_notifier(NC_GEOM | ND_DATA, &mb->id);
	}
}
Exemple #17
0
static void rna_KeyingSet_paths_remove(KeyingSet *keyingset, ReportList *reports, PointerRNA *ksp_ptr)
{
	KS_Path *ksp = ksp_ptr->data;

	/* if data is valid, call the API function for this */
	if ((keyingset && ksp) == FALSE) {
		BKE_report(reports, RPT_ERROR, "Keying set path could not be removed");
		return;
	}

	/* remove the active path from the KeyingSet */
	BKE_keyingset_free_path(keyingset, ksp);
	RNA_POINTER_INVALIDATE(ksp_ptr);

	/* the active path number will most likely have changed */
	/* TODO: we should get more fancy and actually check if it was removed, but this will do for now */
	keyingset->active_path = 0;
}
Exemple #18
0
static void rna_Object_shape_key_remove(
        Object *ob, Main *bmain, ReportList *reports,
        PointerRNA *kb_ptr)
{
	KeyBlock *kb = kb_ptr->data;
	Key *key = BKE_key_from_object(ob);

	if ((key == NULL) || BLI_findindex(&key->block, kb) == -1) {
		BKE_reportf(reports, RPT_ERROR, "ShapeKey not found");
		return;
	}

	if (!BKE_object_shapekey_remove(bmain, ob, kb)) {
		BKE_reportf(reports, RPT_ERROR, "Could not remove ShapeKey");
		return;
	}

	DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
	WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);

	RNA_POINTER_INVALIDATE(kb_ptr);
}
static void rna_MaskSpline_point_remove(ID *id, MaskSpline *spline, ReportList *reports, PointerRNA *point_ptr)
{
	Mask *mask = (Mask *) id;
	MaskSplinePoint *point = point_ptr->data;
	MaskSplinePoint *new_point_array;
	MaskLayer *layer;
	int active_point_index = -1;
	int point_index;

	for (layer = mask->masklayers.first; layer; layer = layer->next) {
		if (BLI_findindex(&layer->splines, spline) != -1) {
			break;
		}
	}

	if (!layer) {
		/* Shall not happen actually */
		BKE_report(reports, RPT_ERROR, "Mask layer not found for given spline");
		return;
	}

	if (point < spline->points || point >= spline->points + spline->tot_point) {
		BKE_report(reports, RPT_ERROR, "Point is not found in given spline");
		return;
	}

	if (layer->act_spline == spline) {
		active_point_index = layer->act_point - spline->points;
	}

	point_index = point - spline->points;

	new_point_array = MEM_mallocN(sizeof(MaskSplinePoint) * (spline->tot_point - 1), "remove mask point");

	memcpy(new_point_array, spline->points, sizeof(MaskSplinePoint) * point_index);
	memcpy(new_point_array + point_index, spline->points + point_index + 1,
	       sizeof(MaskSplinePoint) * (spline->tot_point - point_index - 1));

	MEM_freeN(spline->points);
	spline->points = new_point_array;
	spline->tot_point--;

	if (active_point_index >= 0) {
		if (active_point_index == point_index) {
			layer->act_point = NULL;
		}
		else if (active_point_index < point_index) {
			layer->act_point = spline->points + active_point_index;
		}
		else {
			layer->act_point = spline->points + active_point_index - 1;
		}
	}

	BKE_mask_layer_shape_changed_remove(layer, BKE_mask_layer_shape_spline_to_index(layer, spline) + point_index, 1);

	WM_main_add_notifier(NC_MASK | ND_DATA, mask);
	DAG_id_tag_update(&mask->id, 0);

	RNA_POINTER_INVALIDATE(point_ptr);
}