diff options
Diffstat (limited to 'source/blender/src/header_view3d.c')
-rw-r--r-- | source/blender/src/header_view3d.c | 269 |
1 files changed, 244 insertions, 25 deletions
diff --git a/source/blender/src/header_view3d.c b/source/blender/src/header_view3d.c index 099a016c698..f212a467b99 100644 --- a/source/blender/src/header_view3d.c +++ b/source/blender/src/header_view3d.c @@ -72,6 +72,7 @@ #include "BKE_main.h" #include "BKE_mesh.h" #include "BKE_modifier.h" +#include "BKE_particle.h" #include "BKE_utildefines.h" /* for VECCOPY */ #ifdef WITH_VERSE @@ -98,6 +99,7 @@ #include "BIF_editlattice.h" #include "BIF_editarmature.h" +#include "BIF_editparticle.h" #include "BIF_editconstraint.h" #include "BIF_editdeform.h" #include "BIF_editfont.h" @@ -150,6 +152,7 @@ #define V3D_TEXTUREPAINTMODE_SEL ICON_TPAINT_HLT #define V3D_WEIGHTPAINTMODE_SEL ICON_WPAINT_HLT #define V3D_POSEMODE_SEL ICON_POSE_HLT +#define V3D_PARTICLEEDITMODE_SEL ICON_ANIM #define TEST_EDITMESH if(G.obedit==0) return; \ if( (G.vd->lay & G.obedit->lay)==0 ) return; @@ -4548,6 +4551,184 @@ static uiBlock *view3d_faceselmenu(void *arg_unused) return block; } +void do_view3d_select_particlemenu(void *arg, int event) +{ + /* events >= 6 are registered bpython scripts */ + if (event >= 6) BPY_menu_do_python(PYMENU_FACESELECT, event - 6); + + switch(event) { + case 0: + PE_borderselect(); + break; + case 1: + PE_deselectall(); + break; + case 2: + PE_select_root(); + break; + case 3: + PE_select_tip(); + break; + case 4: + PE_select_more(); + break; + case 5: + PE_select_less(); + break; + case 7: + PE_select_linked(); + break; + } + allqueue(REDRAWVIEW3D, 0); +} + +static uiBlock *view3d_select_particlemenu(void *arg_unused) +{ + uiBlock *block; + short yco= 0, menuwidth=120; + + block= uiNewBlock(&curarea->uiblocks, "view3d_select_particlemenu", UI_EMBOSSP, UI_HELV, curarea->headwin); + uiBlockSetButmFunc(block, do_view3d_select_particlemenu, NULL); + + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Border Select|B", + 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, ""); + + 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, 1, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select Linked|L", + 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 7, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select Last|W, 4", + 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select First|W, 3", + 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, ""); + + uiDefBut(block, SEPR, 0, "", + 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); + + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "More|Ctrl NumPad +", + 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Less|Ctrl NumPad -", + 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, ""); + + + if(curarea->headertype==HEADERTOP) { + uiBlockSetDirection(block, UI_DOWN); + } + else { + uiBlockSetDirection(block, UI_TOP); + uiBlockFlipOrder(block); + } + + uiTextBoundsBlock(block, 50); + return block; +} + +void do_view3d_particle_showhidemenu(void *arg, int event) +{ + switch(event) { + case 1: /* show hidden */ + PE_hide(0); + break; + case 2: /* hide selected */ + PE_hide(2); + break; + case 3: /* hide deselected */ + PE_hide(1); + break; + } + allqueue(REDRAWVIEW3D, 0); +} + +static uiBlock *view3d_particle_showhidemenu(void *arg_unused) +{ + uiBlock *block; + short yco = 20, menuwidth = 120; + + block= uiNewBlock(&curarea->uiblocks, "view3d_particle_showhidemenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin); + uiBlockSetButmFunc(block, do_view3d_particle_showhidemenu, NULL); + + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Show Hidden|Alt H", + 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Hide Selected|H", + 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Hide Deselected|Shift H", + 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, ""); + + uiBlockSetDirection(block, UI_RIGHT); + uiTextBoundsBlock(block, 60); + return block; +} + +void do_view3d_particlemenu(void *arg, int event) +{ + ParticleEditSettings *pset= PE_settings(); + + switch(event) { + case 1: + add_blockhandler(curarea, VIEW3D_HANDLER_OBJECT, UI_PNL_UNSTOW); + break; + case 2: + if(button(&pset->totrekey, 2, 100, "Number of Keys:")==0) return; + PE_rekey(); + break; + case 3: + PE_subdivide(); + break; + case 4: + PE_delete_particle(); + break; + case 5: + PE_mirror_x(0); + break; + case 6: + pset->flag ^= PE_X_MIRROR; + break; + } + + allqueue(REDRAWVIEW3D, 0); +} + +uiBlock *view3d_particlemenu(void *arg_unused) +{ + uiBlock *block; + ParticleEditSettings *pset= PE_settings(); + short yco= 0, menuwidth= 120; + + block= uiNewBlock(&curarea->uiblocks, "view3d_particlemenu", UI_EMBOSSP, UI_HELV, curarea->headwin); + uiBlockSetButmFunc(block, do_view3d_particlemenu, NULL); + + uiDefIconTextBut(block, BUTM, 1, ICON_MENU_PANEL, "Particle Edit Properties|N", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, ""); + uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); + + uiDefIconTextBut(block, BUTM, 1, (pset->flag & PE_X_MIRROR)? ICON_CHECKBOX_HLT: ICON_CHECKBOX_DEHLT, "X-Axis Mirror Editing", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 6, ""); + + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Mirror|Ctrl M", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, ""); + uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); + + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Delete...|X", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, ""); + if(G.scene->selectmode & SCE_SELECT_POINT) + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Subdivide|W, 2", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Rekey|W, 1", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, ""); + uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); + + uiDefIconTextBlockBut(block, view3d_particle_showhidemenu, NULL, ICON_RIGHTARROW_THIN, "Show/Hide Particles", 0, yco-=20, menuwidth, 19, ""); + + if(curarea->headertype==HEADERTOP) { + uiBlockSetDirection(block, UI_DOWN); + } + else { + uiBlockSetDirection(block, UI_TOP); + uiBlockFlipOrder(block); + } + + uiTextBoundsBlock(block, 50); + + return block; +} + static char *view3d_modeselect_pup(void) { @@ -4584,7 +4765,11 @@ static char *view3d_modeselect_pup(void) if (ob->type==OB_ARMATURE) { str += sprintf(str, formatstr, "Pose Mode", V3D_POSEMODE_SEL, ICON_POSE_HLT); } - + + if (ob->particlesystem.first) { + str += sprintf(str, formatstr, "Particle Mode", V3D_PARTICLEEDITMODE_SEL, ICON_PHYSICS); + } + return (string); } @@ -4708,21 +4893,14 @@ void do_view3d_buttons(short event) if (G.vd->modeselect == V3D_OBJECTMODE_SEL) { G.vd->flag &= ~V3D_MODE; - if(G.f & G_SCULPTMODE) set_sculptmode(); /* Switch off sculptmode */ - if(G.f & G_VERTEXPAINT) set_vpaint(); /* Switch off vertex paint */ - if(G.f & G_TEXTUREPAINT) set_texturepaint(); /* Switch off tex paint */ - if(G.f & G_WEIGHTPAINT) set_wpaint(); /* Switch off weight paint */ + exit_paint_modes(); if(ob) exit_posemode(); /* exit posemode for active object */ if(G.obedit) exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* exit editmode and undo */ } else if (G.vd->modeselect == V3D_EDITMODE_SEL) { if(!G.obedit) { G.vd->flag &= ~V3D_MODE; - if(G.f & G_SCULPTMODE) set_sculptmode(); /* Switch off sculptmode */ - if(G.f & G_VERTEXPAINT) set_vpaint(); /* Switch off vertex paint */ - if(G.f & G_TEXTUREPAINT) set_texturepaint(); /* Switch off tex paint */ - if(G.f & G_WEIGHTPAINT) set_wpaint(); /* Switch off weight paint */ - + exit_paint_modes(); enter_editmode(EM_WAITCURSOR); BIF_undo_push("Original"); /* here, because all over code enter_editmode is abused */ } @@ -4730,9 +4908,7 @@ void do_view3d_buttons(short event) else if (G.vd->modeselect == V3D_SCULPTMODE_SEL) { if (!(G.f & G_SCULPTMODE)) { G.vd->flag &= ~V3D_MODE; - if(G.f & G_VERTEXPAINT) set_vpaint(); /* Switch off vertex paint */ - if(G.f & G_TEXTUREPAINT) set_texturepaint(); /* Switch off tex paint */ - if(G.f & G_WEIGHTPAINT) set_wpaint(); /* Switch off weight paint */ + exit_paint_modes(); if(G.obedit) exit_editmode(2); /* exit editmode and undo */ set_sculptmode(); @@ -4741,9 +4917,7 @@ void do_view3d_buttons(short event) else if (G.vd->modeselect == V3D_VERTEXPAINTMODE_SEL) { if (!(G.f & G_VERTEXPAINT)) { G.vd->flag &= ~V3D_MODE; - if(G.f & G_SCULPTMODE) set_sculptmode(); /* Switch off sculptmode */ - if(G.f & G_TEXTUREPAINT) set_texturepaint(); /* Switch off tex paint */ - if(G.f & G_WEIGHTPAINT) set_wpaint(); /* Switch off weight paint */ + exit_paint_modes(); if(G.obedit) exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* exit editmode and undo */ set_vpaint(); @@ -4752,9 +4926,7 @@ void do_view3d_buttons(short event) else if (G.vd->modeselect == V3D_TEXTUREPAINTMODE_SEL) { if (!(G.f & G_TEXTUREPAINT)) { G.vd->flag &= ~V3D_MODE; - if(G.f & G_SCULPTMODE) set_sculptmode(); /* Switch off sculptmode */ - if(G.f & G_VERTEXPAINT) set_vpaint(); /* Switch off vertex paint */ - if(G.f & G_WEIGHTPAINT) set_wpaint(); /* Switch off weight paint */ + exit_paint_modes(); if(G.obedit) exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* exit editmode and undo */ set_texturepaint(); @@ -4763,9 +4935,7 @@ void do_view3d_buttons(short event) else if (G.vd->modeselect == V3D_WEIGHTPAINTMODE_SEL) { if (!(G.f & G_WEIGHTPAINT) && (ob && ob->type == OB_MESH) ) { G.vd->flag &= ~V3D_MODE; - if(G.f & G_SCULPTMODE) set_sculptmode(); /* Switch off sculptmode */ - if(G.f & G_VERTEXPAINT) set_vpaint(); /* Switch off vertex paint */ - if(G.f & G_TEXTUREPAINT) set_texturepaint(); /* Switch off tex paint */ + exit_paint_modes(); if(G.obedit) exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* exit editmode and undo */ set_wpaint(); @@ -4780,6 +4950,15 @@ void do_view3d_buttons(short event) enter_posemode(); } } + else if(G.vd->modeselect == V3D_PARTICLEEDITMODE_SEL){ + if (!(G.f & G_PARTICLEEDIT)) { + G.vd->flag &= ~V3D_MODE; + exit_paint_modes(); + if(G.obedit) exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* exit editmode and undo */ + + PE_set_particle_edit(); + } + } allqueue(REDRAWVIEW3D, 1); break; @@ -4823,6 +5002,22 @@ void do_view3d_buttons(short event) allqueue(REDRAWVIEW3D, 1); allqueue(REDRAWIMAGE, 0); /* only needed in cases where mesh and UV selection are in sync */ break; + + case B_SEL_PATH: + G.scene->selectmode= SCE_SELECT_PATH; + BIF_undo_push("Selectmode Set: Path"); + allqueue(REDRAWVIEW3D, 1); + break; + case B_SEL_POINT: + G.scene->selectmode = SCE_SELECT_POINT; + BIF_undo_push("Selectmode Set: Point"); + allqueue(REDRAWVIEW3D, 1); + break; + case B_SEL_END: + G.scene->selectmode = SCE_SELECT_END; + BIF_undo_push("Selectmode Set: End point"); + allqueue(REDRAWVIEW3D, 1); + break; case B_MAN_TRANS: if( (G.qual & LR_SHIFTKEY)==0 || G.vd->twtype==0) @@ -4928,6 +5123,8 @@ static void view3d_header_pulldowns(uiBlock *block, short *xcoord) } } else if ((G.f & G_VERTEXPAINT) || (G.f & G_TEXTUREPAINT) || (G.f & G_WEIGHTPAINT)) { uiDefBut(block, LABEL,0,"", xco, 0, xmax, 20, 0, 0, 0, 0, 0, ""); + } else if (G.f & G_PARTICLEEDIT) { + uiDefPulldownBut(block, view3d_select_particlemenu, NULL, "Select", xco,-2, xmax-3, 24, ""); } else { if (ob && (ob->flag & OB_POSEMODE)) @@ -4995,7 +5192,13 @@ static void view3d_header_pulldowns(uiBlock *block, short *xcoord) uiDefPulldownBut(block, view3d_faceselmenu, NULL, "Face", xco,-2, xmax-3, 24, ""); xco+= xmax; } - } else { + } + else if(G.f & G_PARTICLEEDIT) { + xmax= GetButStringLength("Particle"); + uiDefPulldownBut(block, view3d_particlemenu, NULL, "Particle", xco,-2, xmax-3, 24, ""); + xco+= xmax; + } + else { if (ob && (ob->flag & OB_POSEMODE)) { xmax= GetButStringLength("Pose"); uiDefPulldownBut(block, view3d_pose_armaturemenu, NULL, "Pose", xco,-2, xmax-3, 24, ""); @@ -5058,6 +5261,7 @@ void view3d_buttons(void) else if (G.f & G_VERTEXPAINT) G.vd->modeselect = V3D_VERTEXPAINTMODE_SEL; else if (G.f & G_TEXTUREPAINT) G.vd->modeselect = V3D_TEXTUREPAINTMODE_SEL; /*else if(G.f & G_FACESELECT) G.vd->modeselect = V3D_FACESELECTMODE_SEL;*/ + else if(G.f & G_PARTICLEEDIT) G.vd->modeselect = V3D_PARTICLEEDITMODE_SEL; G.vd->flag &= ~V3D_MODE; @@ -5173,7 +5377,7 @@ void view3d_buttons(void) } /* proportional falloff */ - if(G.obedit && (G.obedit->type == OB_MESH || G.obedit->type == OB_CURVE || G.obedit->type == OB_SURF || G.obedit->type == OB_LATTICE)) { + if((G.obedit && (G.obedit->type == OB_MESH || G.obedit->type == OB_CURVE || G.obedit->type == OB_SURF || G.obedit->type == OB_LATTICE)) || G.f & G_PARTICLEEDIT) { uiBlockBeginAlign(block); uiDefIconTextButS(block, ICONTEXTROW,B_REDR, ICON_PROP_OFF, "Proportional %t|Off %x0|On %x1|Connected %x2", xco,0,XIC+10,YIC, &(G.scene->proportional), 0, 1.0, 0, 0, "Proportional Edit Falloff (Hotkeys: O, Alt O) "); @@ -5220,7 +5424,22 @@ void view3d_buttons(void) } xco+= 20; } - + else if(G.f & G_PARTICLEEDIT) { + uiBlockBeginAlign(block); + uiDefIconButBitS(block, TOG, SCE_SELECT_PATH, B_SEL_PATH, ICON_EDGESEL, xco,0,XIC,YIC, &G.scene->selectmode, 1.0, 0.0, 0, 0, "Path edit mode (Ctrl Tab 1)"); + xco+= XIC; + uiDefIconButBitS(block, TOG, SCE_SELECT_POINT, B_SEL_POINT, ICON_VERTEXSEL, xco,0,XIC,YIC, &G.scene->selectmode, 1.0, 0.0, 0, 0, "Point select mode (Ctrl Tab 2)"); + xco+= XIC; + uiDefIconButBitS(block, TOG, SCE_SELECT_END, B_SEL_END, ICON_FACESEL, xco,0,XIC,YIC, &G.scene->selectmode, 1.0, 0.0, 0, 0, "Tip select mode (Ctrl Tab 3)"); + xco+= XIC; + uiBlockEndAlign(block); + if(G.vd->drawtype > OB_WIRE) { + uiDefIconButBitS(block, TOG, V3D_ZBUF_SELECT, B_REDR, ICON_ORTHO, xco,0,XIC,YIC, &G.vd->flag, 1.0, 0.0, 0, 0, "Limit selection to visible (clipped with depth buffer)"); + xco+= XIC; + } + xco+= 20; + } + uiDefIconBut(block, BUT, B_VIEWRENDER, ICON_SCENE_DEHLT, xco,0,XIC,YIC, NULL, 0, 1.0, 0, 0, "Render this window (hold CTRL for anim)"); if (ob && (ob->flag & OB_POSEMODE)) { |