[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21651] branches/bmesh/blender/source/ blender/editors/animation/fmodifier_ui.c: more compiling stuff

Joseph Eagar joeedh at gmail.com
Fri Jul 17 06:27:40 CEST 2009


Revision: 21651
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21651
Author:   joeedh
Date:     2009-07-17 06:27:40 +0200 (Fri, 17 Jul 2009)

Log Message:
-----------
more compiling stuff

Added Paths:
-----------
    branches/bmesh/blender/source/blender/editors/animation/fmodifier_ui.c

Added: branches/bmesh/blender/source/blender/editors/animation/fmodifier_ui.c
===================================================================
--- branches/bmesh/blender/source/blender/editors/animation/fmodifier_ui.c	                        (rev 0)
+++ branches/bmesh/blender/source/blender/editors/animation/fmodifier_ui.c	2009-07-17 04:27:40 UTC (rev 21651)
@@ -0,0 +1,679 @@
+/**
+ * $Id:
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. 
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2009 Blender Foundation.
+ * All rights reserved.
+ *
+ * 
+ * Contributor(s): Blender Foundation, Joshua Leung
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/* User-Interface Stuff for F-Modifiers:
+ * This file defines the (C-Coded) templates + editing callbacks needed 
+ * by the interface stuff or F-Modifiers, as used by F-Curves in the Graph Editor,
+ * and NLA-Strips in the NLA Editor.
+ */
+ 
+#include <string.h>
+#include <stdio.h>
+#include <math.h>
+#include <float.h>
+
+#include "DNA_anim_types.h"
+#include "DNA_action_types.h"
+#include "DNA_object_types.h"
+#include "DNA_space_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_screen_types.h"
+#include "DNA_userdef_types.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_arithb.h"
+#include "BLI_blenlib.h"
+#include "BLI_editVert.h"
+#include "BLI_rand.h"
+
+#include "BKE_animsys.h"
+#include "BKE_action.h"
+#include "BKE_context.h"
+#include "BKE_curve.h"
+#include "BKE_customdata.h"
+#include "BKE_depsgraph.h"
+#include "BKE_fcurve.h"
+#include "BKE_object.h"
+#include "BKE_global.h"
+#include "BKE_nla.h"
+#include "BKE_scene.h"
+#include "BKE_screen.h"
+#include "BKE_utildefines.h"
+
+#include "BIF_gl.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "RNA_access.h"
+#include "RNA_define.h"
+
+#include "ED_anim_api.h"
+#include "ED_keyframing.h"
+#include "ED_screen.h"
+#include "ED_types.h"
+#include "ED_util.h"
+
+#include "UI_interface.h"
+#include "UI_resources.h"
+#include "UI_view2d.h"
+
+// XXX! --------------------------------
+/* temporary definition for limits of float number buttons (FLT_MAX tends to infinity with old system) */
+#define UI_FLT_MAX 	10000.0f
+
+/* ********************************************** */
+
+#define B_REDR 					1
+#define B_FMODIFIER_REDRAW		20
+
+/* macro for use here to draw background box and set height */
+// XXX for now, roundbox has it's callback func set to NULL to not intercept events
+#define DRAW_BACKDROP(height) \
+	{ \
+		uiDefBut(block, ROUNDBOX, B_REDR, "", -3, yco-height, width+3, height-1, NULL, 5.0, 0.0, 12.0, (float)rb_col, ""); \
+	}
+
+/* callback to verify modifier data */
+static void validate_fmodifier_cb (bContext *C, void *fcm_v, void *dummy)
+{
+	FModifier *fcm= (FModifier *)fcm_v;
+	FModifierTypeInfo *fmi= fmodifier_get_typeinfo(fcm);
+	
+	/* call the verify callback on the modifier if applicable */
+	if (fmi && fmi->verify_data)
+		fmi->verify_data(fcm);
+}
+
+/* callback to set the active modifier */
+static void activate_fmodifier_cb (bContext *C, void *fmods_v, void *fcm_v)
+{
+	ListBase *modifiers = (ListBase *)fmods_v;
+	FModifier *fcm= (FModifier *)fcm_v;
+	
+	/* call API function to set the active modifier for active modifier-stack */
+	set_active_fmodifier(modifiers, fcm);
+}
+
+/* callback to remove the given modifier  */
+static void delete_fmodifier_cb (bContext *C, void *fmods_v, void *fcm_v)
+{
+	ListBase *modifiers = (ListBase *)fmods_v;
+	FModifier *fcm= (FModifier *)fcm_v;
+	
+	/* remove the given F-Modifier from the active modifier-stack */
+	remove_fmodifier(modifiers, fcm);
+}
+
+/* --------------- */
+	
+/* draw settings for generator modifier */
+static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, short width)
+{
+	FMod_Generator *data= (FMod_Generator *)fcm->data;
+	uiLayout *col, *row;
+	uiBlock *block;
+	uiBut *but;
+	PointerRNA ptr;
+	
+	/* init the RNA-pointer */
+	RNA_pointer_create(id, &RNA_FModifierFunctionGenerator, fcm, &ptr);
+	
+	/* basic settings (backdrop + mode selector + some padding) */
+	col= uiLayoutColumn(layout, 1);
+	block= uiLayoutGetBlock(layout);
+	uiBlockBeginAlign(block);
+		but= uiDefButR(block, MENU, B_FMODIFIER_REDRAW, NULL, 0, 0, width-30, UI_UNIT_Y, &ptr, "mode", -1, 0, 0, -1, -1, NULL);
+		uiButSetFunc(but, validate_fmodifier_cb, fcm, NULL);
+		
+		uiDefButR(block, TOG, B_FMODIFIER_REDRAW, NULL, 0, 0, width-30, UI_UNIT_Y, &ptr, "additive", -1, 0, 0, -1, -1, NULL);
+	uiBlockEndAlign(block);
+	
+	/* now add settings for individual modes */
+	switch (data->mode) {
+		case FCM_GENERATOR_POLYNOMIAL: /* polynomial expression */
+		{
+			float *cp = NULL;
+			char xval[32];
+			unsigned int i;
+			
+			/* draw polynomial order selector */
+			row= uiLayoutRow(layout, 0);
+			block= uiLayoutGetBlock(row);
+				but= uiDefButI(block, NUM, B_FMODIFIER_REDRAW, "Poly Order: ", 10,0,width-30,19, &data->poly_order, 1, 100, 0, 0, "'Order' of the Polynomial - for a polynomial with n terms, 'order' is n-1");
+				uiButSetFunc(but, validate_fmodifier_cb, fcm, NULL);
+			
+			
+			/* draw controls for each coefficient and a + sign at end of row */
+			row= uiLayoutRow(layout, 1);
+			block= uiLayoutGetBlock(row);
+				uiDefBut(block, LABEL, 1, "y = ", 0, 0, 50, 20, NULL, 0.0, 0.0, 0, 0, "");
+			
+			cp= data->coefficients;
+			for (i=0; (i < data->arraysize) && (cp); i++, cp++) {
+				/* coefficient */
+				uiDefButF(block, NUM, B_FMODIFIER_REDRAW, "", 0, 0, 150, 20, cp, -UI_FLT_MAX, UI_FLT_MAX, 10, 3, "Coefficient for polynomial");
+				
+				/* 'x' param (and '+' if necessary) */
+				if (i) {
+					if (i == 1)
+						strcpy(xval, "x");
+					else
+						sprintf(xval, "x^%d", i);
+					uiDefBut(block, LABEL, 1, xval, 0, 0, 50, 20, NULL, 0.0, 0.0, 0, 0, "Power of x");
+				}
+				
+				if ( (i != (data->arraysize - 1)) || ((i==0) && data->arraysize==2) ) {
+					uiDefBut(block, LABEL, 1, "+", 0,0 , 30, 20, NULL, 0.0, 0.0, 0, 0, "");
+					
+					/* next coefficient on a new row */
+					row= uiLayoutRow(layout, 1);
+					block= uiLayoutGetBlock(row);
+				}
+			}
+		}
+			break;
+		
+		case FCM_GENERATOR_POLYNOMIAL_FACTORISED: /* factorised polynomial expression */
+		{
+			float *cp = NULL;
+			unsigned int i;
+			
+			/* draw polynomial order selector */
+			row= uiLayoutRow(layout, 0);
+			block= uiLayoutGetBlock(row);
+				but= uiDefButI(block, NUM, B_FMODIFIER_REDRAW, "Poly Order: ", 0,0,width-30,19, &data->poly_order, 1, 100, 0, 0, "'Order' of the Polynomial - for a polynomial with n terms, 'order' is n-1");
+				uiButSetFunc(but, validate_fmodifier_cb, fcm, NULL);
+			
+			
+			/* draw controls for each pair of coefficients */
+			row= uiLayoutRow(layout, 1);
+			block= uiLayoutGetBlock(row);
+				uiDefBut(block, LABEL, 1, "y=", 0, 0, 50, 20, NULL, 0.0, 0.0, 0, 0, "");
+			
+			cp= data->coefficients;
+			for (i=0; (i < data->poly_order) && (cp); i++, cp+=2) {
+				/* opening bracket */
+				uiDefBut(block, LABEL, 1, "(", 0, 0, 20, 20, NULL, 0.0, 0.0, 0, 0, "");
+				
+				/* coefficients */
+				uiDefButF(block, NUM, B_FMODIFIER_REDRAW, "", 0, 0, 100, 20, cp, -UI_FLT_MAX, UI_FLT_MAX, 10, 3, "Coefficient of x");
+				
+				uiDefBut(block, LABEL, 1, "x+", 0, 0, 40, 20, NULL, 0.0, 0.0, 0, 0, "");
+				
+				uiDefButF(block, NUM, B_FMODIFIER_REDRAW, "", 0, 0, 100, 20, cp+1, -UI_FLT_MAX, UI_FLT_MAX, 10, 3, "Second coefficient");
+				
+				/* closing bracket and '+' sign */
+				if ( (i != (data->poly_order - 1)) || ((i==0) && data->poly_order==2) ) {
+					uiDefBut(block, LABEL, 1, ") +", 0, 0, 30, 20, NULL, 0.0, 0.0, 0, 0, "");
+					
+					/* set up new row for the next pair of coefficients*/
+					row= uiLayoutRow(layout, 1);
+					block= uiLayoutGetBlock(row);
+				}
+				else 
+					uiDefBut(block, LABEL, 1, ")", 0, 0, 20, 20, NULL, 0.0, 0.0, 0, 0, "");
+			}
+		}
+			break;
+	}
+}
+
+/* --------------- */
+
+/* draw settings for noise modifier */
+static void draw_modifier__fn_generator(uiLayout *layout, ID *id, FModifier *fcm, short width)
+{
+	uiLayout *col;
+	PointerRNA ptr;
+	
+	/* init the RNA-pointer */
+	RNA_pointer_create(id, &RNA_FModifierFunctionGenerator, fcm, &ptr);
+	
+	/* add the settings */
+	col= uiLayoutColumn(layout, 1);
+		uiItemR(col, "", 0, &ptr, "type", 0, 0, 0);
+		uiItemR(col, NULL, 0, &ptr, "additive", 0, 0, 1);
+	
+	col= uiLayoutColumn(layout, 0); // no grouping for now
+		uiItemR(col, NULL, 0, &ptr, "amplitude", 0, 0, 0);
+		uiItemR(col, NULL, 0, &ptr, "phase_multiplier", 0, 0, 0);
+		uiItemR(col, NULL, 0, &ptr, "phase_offset", 0, 0, 0);
+		uiItemR(col, NULL, 0, &ptr, "value_offset", 0, 0, 0);
+}
+
+/* --------------- */
+
+/* draw settings for cycles modifier */
+static void draw_modifier__cycles(uiLayout *layout, ID *id, FModifier *fcm, short width)
+{
+	uiLayout *split, *col;
+	PointerRNA ptr;
+	
+	/* init the RNA-pointer */
+	RNA_pointer_create(id, &RNA_FModifierCycles, fcm, &ptr);
+	
+	/* split into 2 columns 
+	 * NOTE: the mode comboboxes shouldn't get labels, otherwise there isn't enough room
+	 */
+	split= uiLayoutSplit(layout, 0.5f);
+	
+	/* before range */
+	col= uiLayoutColumn(split, 1);
+	uiItemL(col, "Before:", 0);
+	uiItemR(col, "", 0, &ptr, "before_mode", 0, 0, 0);
+	uiItemR(col, NULL, 0, &ptr, "before_cycles", 0, 0, 0);
+		
+	/* after range */
+	col= uiLayoutColumn(split, 1);
+	uiItemL(col, "After:", 0);
+	uiItemR(col, "", 0, &ptr, "after_mode", 0, 0, 0);
+	uiItemR(col, NULL, 0, &ptr, "after_cycles", 0, 0, 0);
+}
+
+/* --------------- */
+
+/* draw settings for noise modifier */
+static void draw_modifier__noise(uiLayout *layout, ID *id, FModifier *fcm, short width)
+{
+	uiLayout *split, *col;
+	PointerRNA ptr;
+	
+	/* init the RNA-pointer */
+	RNA_pointer_create(id, &RNA_FModifierNoise, fcm, &ptr);
+	
+	/* blending mode */
+	uiItemR(layout, NULL, 0, &ptr, "modification", 0, 0, 0);
+	

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list