Curve Selection Tool Refactor:

This commit refactors curve selection system to use certain curve selections
functions that encapsulate setting of selection flags. New function to select
adjacent control points was introduced too. Refactoring made it possible to 
simplify certain existing selection functions quite a bit. 
New functionality was delivered as well. Select more/less works now with NURBS 
as expected. Also two new curve selection functions were added: Select Every Nth 
and Select Random. 

See http://wiki.blender.org/index.php/BlenderDev/Curve_Selection_Tools for 
further information.
This commit is contained in:
Juho Vepsalainen 2007-06-14 14:36:27 +00:00
parent 0ed2e0e706
commit a499da7192
8 changed files with 527 additions and 456 deletions

View File

@ -55,6 +55,7 @@ short curve_type( struct Curve *cu);
void test_curve_type( struct Object *ob);
void tex_space_curve( struct Curve *cu);
int count_curveverts( struct ListBase *nurb);
int count_curveverts_without_handles( struct ListBase *nurb);
void freeNurb( struct Nurb *nu);
void freeNurblist( struct ListBase *lb);
struct Nurb *duplicateNurb( struct Nurb *nu);

View File

@ -324,7 +324,20 @@ int count_curveverts(ListBase *nurb)
return tot;
}
int count_curveverts_without_handles(ListBase *nurb)
{
Nurb *nu;
int tot=0;
nu= nurb->first;
while(nu) {
if(nu->bezt) tot+= nu->pntsu;
else if(nu->bp) tot+= nu->pntsu*nu->pntsv;
nu= nu->next;
}
return tot;
}
/* **************** NURBS ROUTINES ******************** */

View File

@ -78,11 +78,13 @@ void extrude_nurb(void);
void makecyclicNurb(void);
void selectconnected_nurb(void);
void selectrow_nurb(void);
void selectends_nurb(int selFirst);
void selectend_nurb(short selfirst, short doswap, short selstatus);
void select_more_nurb(void);
void select_less_nurb(void);
void select_next_nurb(void);
void select_prev_nurb(void);
void select_random_nurb(void);
void select_every_nth_nurb(void);
void adduplicate_nurb(void);
void delNurb(void);
void nurb_set_smooth(short event);
@ -98,4 +100,3 @@ int bezt_compare (const void *e1, const void *e2);
extern void undo_push_curve(char *name);
#endif /* BDR_EDITCURVE_H */

View File

@ -87,13 +87,16 @@
#endif
#define SELECT 1
#define HIDDEN 1
#define FIRST 1
#define ACTIVE 2
/*#ifdef WITH_VERSE*/
#define VERSE 3
/*#endif*/
#define DESELECT 0
#define NOT_YET 0
#define VISIBLE 0
#define LAST 0
#define TESTBASE(base) ( ((base)->flag & SELECT) && ((base)->lay & G.vd->lay) && (((base)->object->restrictflag & OB_RESTRICT_VIEW)==0) )
#define TESTBASELIB(base) ( ((base)->flag & SELECT) && ((base)->lay & G.vd->lay) && ((base)->object->id.lib==0) && (((base)->object->restrictflag & OB_RESTRICT_VIEW)==0))

File diff suppressed because it is too large Load Diff

View File

@ -1104,17 +1104,17 @@ void do_view3d_select_curvemenu(void *arg, int event)
/* select connected control points */
/*case 4:
G.qual |= LR_CTRLKEY;
selectconnected_nurb();
select_connected_nurb();
G.qual &= ~LR_CTRLKEY;
break;*/
case 5: /* select row (nurb) */
selectrow_nurb();
break;
case 7: /* select/deselect first */
selectends_nurb(1);
selectend_nurb(FIRST, 1, DESELECT);
break;
case 8: /* select/deselect last */
selectends_nurb(0);
selectend_nurb(LAST, 1, DESELECT);
break;
case 9: /* select more */
select_more_nurb();
@ -1128,6 +1128,12 @@ void do_view3d_select_curvemenu(void *arg, int event)
case 12: /* select previous */
select_prev_nurb();
break;
case 13: /* select random */
select_random_nurb();
break;
case 14: /* select every nth */
select_every_nth_nurb();
break;
}
allqueue(REDRAWVIEW3D, 0);
}
@ -1147,6 +1153,8 @@ static uiBlock *view3d_select_curvemenu(void *arg_unused)
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, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Random...", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 13, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Every Nth", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 14, "");
if (OBACT->type == OB_SURF) {
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");

View File

@ -2501,11 +2501,9 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
else if ( (G.qual==LR_CTRLKEY)
&& (G.obedit) && (G.obedit->type==OB_CURVE) )
select_less_nurb();
/*
else if ( (G.qual==LR_CTRLKEY)
&& (G.obedit) && (G.obedit->type==OB_SURF) )
select_less_nurb();
*/
else {
persptoetsen(event);
doredraw= 1;
@ -2519,11 +2517,9 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
else if ( (G.qual==LR_CTRLKEY)
&& (G.obedit) && (G.obedit->type==OB_CURVE) )
select_more_nurb();
/*
else if ( (G.qual==LR_CTRLKEY)
&& (G.obedit) && (G.obedit->type==OB_SURF) )
select_more_nurb();
*/
else {
persptoetsen(event);
doredraw= 1;

View File

@ -949,7 +949,9 @@ static TBitem tb_curve_select[]= {
{ 0, "SEPR", 0, NULL},
{ 0, "(De)select All|A", 2, NULL},
{ 0, "Inverse", 3, NULL},
{ 0, "Row|Shift R", 5, NULL},
{ 0, "Random...", 13, NULL},
{ 0, "Every Nth", 14, NULL},
{ 0, "Row|Shift R", 5, NULL}, /* shouldn't be visible in case of bezier curves*/
{ 0, "SEPR", 0, NULL},
{ 0, "(De)select First", 7, NULL},
{ 0, "(De)select Last", 8, NULL},