[Bf-blender-cvs] [fc62d38ce10] master: Python API: Expose CurveProfile Reset View function

Patrick Busch noreply at git.blender.org
Thu Mar 18 22:25:44 CET 2021


Commit: fc62d38ce105857f1c3400ba67271db7f2873a29
Author: Patrick Busch
Date:   Thu Mar 18 17:25:36 2021 -0400
Branches: master
https://developer.blender.org/rBfc62d38ce105857f1c3400ba67271db7f2873a29

Python API: Expose CurveProfile Reset View function

Allow python access to the `reset_view` functionality which before
was only available through the menu. This was suggested for
consistency after D10561.

Differential Revision: https://developer.blender.org/D10595

===================================================================

M	source/blender/blenkernel/BKE_curveprofile.h
M	source/blender/blenkernel/intern/curveprofile.c
M	source/blender/editors/interface/interface_templates.c
M	source/blender/makesrna/intern/rna_curveprofile.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_curveprofile.h b/source/blender/blenkernel/BKE_curveprofile.h
index 67f9095924a..501ae70ecdb 100644
--- a/source/blender/blenkernel/BKE_curveprofile.h
+++ b/source/blender/blenkernel/BKE_curveprofile.h
@@ -66,6 +66,8 @@ void BKE_curveprofile_selected_handle_set(struct CurveProfile *profile, int type
 
 void BKE_curveprofile_reverse(struct CurveProfile *profile);
 
+void BKE_curveprofile_reset_view(struct CurveProfile *profile);
+
 void BKE_curveprofile_reset(struct CurveProfile *profile);
 
 void BKE_curveprofile_create_samples(struct CurveProfile *profile,
diff --git a/source/blender/blenkernel/intern/curveprofile.c b/source/blender/blenkernel/intern/curveprofile.c
index b7017253be1..752e0d4dfcf 100644
--- a/source/blender/blenkernel/intern/curveprofile.c
+++ b/source/blender/blenkernel/intern/curveprofile.c
@@ -435,6 +435,14 @@ static void curveprofile_build_steps(CurveProfile *profile)
   }
 }
 
+/**
+ * Reset the view to the clipping rectangle.
+ */
+void BKE_curveprofile_reset_view(CurveProfile *profile)
+{
+  profile->view_rect = profile->clip_rect;
+}
+
 /**
  * Resets the profile to the current preset.
  *
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 0a625cc2b56..f3a545d5df5 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -4694,7 +4694,7 @@ static void CurveProfile_tools_dofunc(bContext *C, void *profile_v, int event)
       BKE_curveprofile_update(profile, PROF_UPDATE_NONE);
       break;
     case UIPROFILE_FUNC_RESET_VIEW: /* reset view to clipping rect */
-      profile->view_rect = profile->clip_rect;
+      BKE_curveprofile_reset_view(profile);
       break;
   }
   ED_undo_push(C, "CurveProfile tools");
diff --git a/source/blender/makesrna/intern/rna_curveprofile.c b/source/blender/makesrna/intern/rna_curveprofile.c
index 25f0c5fb9b4..bb54d55f8bd 100644
--- a/source/blender/makesrna/intern/rna_curveprofile.c
+++ b/source/blender/makesrna/intern/rna_curveprofile.c
@@ -281,6 +281,9 @@ static void rna_def_curveprofile(BlenderRNA *brna)
   func = RNA_def_function(srna, "update", "rna_CurveProfile_update");
   RNA_def_function_ui_description(func, "Refresh internal data, remove doubles and clip points");
 
+  func = RNA_def_function(srna, "reset_view", "BKE_curveprofile_reset_view");
+  RNA_def_function_ui_description(func, "Reset the curve profile grid to its clipping size");
+
   func = RNA_def_function(srna, "initialize", "rna_CurveProfile_initialize");
   parm = RNA_def_int(func,
                      "totsegments",



More information about the Bf-blender-cvs mailing list