From d1711b39729230aeb09f824a44c9303eb07d9363 Mon Sep 17 00:00:00 2001 From: Jiri Hnidek Date: Fri, 8 Jun 2007 14:17:13 +0000 Subject: [PATCH] =?UTF-8?q?Patch=20[#6729]=20from=20Juho=20Veps=C3=A4l?= =?UTF-8?q?=C3=A4inen.=20It=20adds=20inverse=20and=20random=20select=20for?= =?UTF-8?q?=20metaelems.=20I=20simplified=20random=20select=20a=20little.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/blender/include/BDR_editmball.h | 2 ++ source/blender/include/BSE_headerbuttons.h | 1 + source/blender/src/editmball.c | 39 ++++++++++++++++++++++ source/blender/src/header_view3d.c | 14 +++++++- source/blender/src/toolbox.c | 11 +++++- 5 files changed, 65 insertions(+), 2 deletions(-) diff --git a/source/blender/include/BDR_editmball.h b/source/blender/include/BDR_editmball.h index c3e9eaaf66c..e2b529acaf8 100644 --- a/source/blender/include/BDR_editmball.h +++ b/source/blender/include/BDR_editmball.h @@ -42,6 +42,8 @@ void load_editMball(void); */ void add_primitiveMball(int); void deselectall_mball(void); +void selectinverse_mball(void); +void selectrandom_mball(void); void mouse_mball(void); void adduplicate_mball(void); void delete_mball(void); diff --git a/source/blender/include/BSE_headerbuttons.h b/source/blender/include/BSE_headerbuttons.h index b0daf106ca8..112517dbe7f 100644 --- a/source/blender/include/BSE_headerbuttons.h +++ b/source/blender/include/BSE_headerbuttons.h @@ -141,6 +141,7 @@ void do_view3d_select_object_typemenu(void *arg, int event); void do_view3d_select_faceselmenu(void *arg, int event); void do_view3d_select_meshmenu(void *arg, int event); void do_view3d_select_curvemenu(void *arg, int event); +void do_view3d_select_metaballmenu(void *arg, int event); void do_view3d_edit_snapmenu(void *arg, int event); void do_view3d_edit_mirrormenu(void *arg, int event); void do_view3d_transform_moveaxismenu(void *arg, int event); diff --git a/source/blender/src/editmball.c b/source/blender/src/editmball.c index 91f0f25ec60..06b2e8b5dd7 100644 --- a/source/blender/src/editmball.c +++ b/source/blender/src/editmball.c @@ -30,6 +30,7 @@ * ***** END GPL/BL DUAL LICENSE BLOCK ***** */ +#include #include #ifdef HAVE_CONFIG_H @@ -40,6 +41,7 @@ #include "BLI_blenlib.h" #include "BLI_arithb.h" +#include "BLI_rand.h" #include "DNA_screen_types.h" #include "DNA_space_types.h" @@ -251,6 +253,43 @@ void deselectall_mball() BIF_undo_push("Deselect MetaElem"); } +/* inverts metaball selection */ +void selectinverse_mball() +{ + MetaElem *ml; + + ml= editelems.first; + while(ml) { + if(ml->flag & SELECT) ml->flag &= ~SELECT; + else ml->flag |= SELECT; + ml= ml->next; + } + + allqueue(REDRAWVIEW3D, 0); + countall(); + BIF_undo_push("Invert MetaElem"); +} + +/* select random metaball selection */ +void selectrandom_mball() +{ + MetaElem *ml; + static short randfac= 50; + + if(!button(&randfac,0, 100,"Percentage:")) return; + + ml= editelems.first; + BLI_srand( BLI_rand() ); /* random seed */ + while(ml) { + if((BLI_frand() * 100) < randfac) ml->flag |= SELECT; + ml= ml->next; + } + + allqueue(REDRAWVIEW3D, 0); + countall(); + BIF_undo_push("Random MetaElem"); +} + /* select MetaElement with mouse click (user can select radius circle or * stiffness circle) */ void mouse_mball() diff --git a/source/blender/src/header_view3d.c b/source/blender/src/header_view3d.c index 39797ce7f46..21683920bf8 100644 --- a/source/blender/src/header_view3d.c +++ b/source/blender/src/header_view3d.c @@ -1181,7 +1181,7 @@ static uiBlock *view3d_select_curvemenu(void *arg_unused) return block; } -static void do_view3d_select_metaballmenu(void *arg, int event) +void do_view3d_select_metaballmenu(void *arg, int event) { switch(event) { @@ -1191,6 +1191,12 @@ static void do_view3d_select_metaballmenu(void *arg, int event) case 2: /* Select/Deselect all */ deselectall_mball(); break; + case 3: /* Inverse */ + selectinverse_mball(); + break; + case 4: /* Select Random */ + selectrandom_mball(); + break; } allqueue(REDRAWVIEW3D, 0); } @@ -1209,7 +1215,13 @@ static uiBlock *view3d_select_metaballmenu(void *arg_unused) uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select/Deselect All|A", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, ""); + + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Inverse", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, ""); + uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); + + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Random...", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, ""); + if(curarea->headertype==HEADERTOP) { uiBlockSetDirection(block, UI_DOWN); } diff --git a/source/blender/src/toolbox.c b/source/blender/src/toolbox.c index 15193c1b460..1ef328272d6 100644 --- a/source/blender/src/toolbox.c +++ b/source/blender/src/toolbox.c @@ -960,6 +960,15 @@ static TBitem tb_curve_select[]= { { 0, "Less|Ctrl NumPad -", 10, NULL}, { -1, "", 0, do_view3d_select_curvemenu}}; +static TBitem tb_mball_select[]= { +{ 0, "Border Select|B", 0, NULL}, +{ 0, "SEPR", 0, NULL}, +{ 0, "(De)select All|A", 2, NULL}, +{ 0, "Inverse", 3, NULL}, +{ 0, "SEPR", 0, NULL}, +{ 0, "Random...", 4, NULL}, +{ -1, "", 0, do_view3d_select_metaballmenu}}; + static TBitem tb__select[]= { { 0, "Border Select|B", 'b', NULL}, { 0, "(De)select All|A", 'a', NULL}, @@ -2019,7 +2028,7 @@ void toolbox_n(void) case OB_MBALL: menu1= addmenu_meta; menu2= tb_edit; - menu3= tb__select; + menu3= tb_mball_select; menu4= tb_transform_editmode2; menu5= tb_obdata; str5= "Meta"; break;