Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2010-11-21 21:50:53 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2010-11-21 21:50:53 +0300
commite006d187f4d1c84e78d47c98df577e9165dddf82 (patch)
tree23686fc4f0f1da44bf479216f229656a5ecc06ce /source/blender/editors/curve
parentd016f52c21ec303c9d6729d7ef819e367965c36c (diff)
Applying patch #24822: Select linked for curves as for meshes, CTRL + L version
With some own changes: - Select pick moved to invoke() - Used editsurfcurve_region_view3d as poll function for this operator due to ogl dependency Thanks to Elia Sarti (vekoon)!
Diffstat (limited to 'source/blender/editors/curve')
-rw-r--r--source/blender/editors/curve/curve_intern.h1
-rw-r--r--source/blender/editors/curve/curve_ops.c6
-rw-r--r--source/blender/editors/curve/editcurve.c115
3 files changed, 93 insertions, 29 deletions
diff --git a/source/blender/editors/curve/curve_intern.h b/source/blender/editors/curve/curve_intern.h
index 2567494ddf3..171659a70df 100644
--- a/source/blender/editors/curve/curve_intern.h
+++ b/source/blender/editors/curve/curve_intern.h
@@ -106,6 +106,7 @@ void CURVE_OT_de_select_last(struct wmOperatorType *ot);
void CURVE_OT_select_all(struct wmOperatorType *ot);
void CURVE_OT_select_inverse(struct wmOperatorType *ot);
void CURVE_OT_select_linked(struct wmOperatorType *ot);
+void CURVE_OT_select_linked_pick(struct wmOperatorType *ot);
void CURVE_OT_select_row(struct wmOperatorType *ot);
void CURVE_OT_select_next(struct wmOperatorType *ot);
void CURVE_OT_select_previous(struct wmOperatorType *ot);
diff --git a/source/blender/editors/curve/curve_ops.c b/source/blender/editors/curve/curve_ops.c
index 80582c7f1b0..1b3e5130c2d 100644
--- a/source/blender/editors/curve/curve_ops.c
+++ b/source/blender/editors/curve/curve_ops.c
@@ -117,6 +117,7 @@ void ED_operatortypes_curve(void)
WM_operatortype_append(CURVE_OT_select_all);
WM_operatortype_append(CURVE_OT_select_inverse);
WM_operatortype_append(CURVE_OT_select_linked);
+ WM_operatortype_append(CURVE_OT_select_linked_pick);
WM_operatortype_append(CURVE_OT_select_row);
WM_operatortype_append(CURVE_OT_select_next);
WM_operatortype_append(CURVE_OT_select_previous);
@@ -201,8 +202,9 @@ void ED_keymap_curve(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "CURVE_OT_select_row", RKEY, KM_PRESS, KM_SHIFT, 0);
WM_keymap_add_item(keymap, "CURVE_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "CURVE_OT_select_less", PADMINUS, KM_PRESS, KM_CTRL, 0);
- WM_keymap_add_item(keymap, "CURVE_OT_select_linked", LKEY, KM_PRESS, 0, 0);
- RNA_boolean_set(WM_keymap_add_item(keymap, "CURVE_OT_select_linked", LKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "deselect", 1);
+ WM_keymap_add_item(keymap, "CURVE_OT_select_linked", LKEY, KM_PRESS, KM_CTRL, 0);
+ WM_keymap_add_item(keymap, "CURVE_OT_select_linked_pick", LKEY, KM_PRESS, 0, 0);
+ RNA_boolean_set(WM_keymap_add_item(keymap, "CURVE_OT_select_linked_pick", LKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "deselect", 1);
WM_keymap_add_item(keymap, "CURVE_OT_separate", PKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "CURVE_OT_extrude", EKEY, KM_PRESS, 0, 0);
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index ceb1ace849e..be095cd8025 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -4457,24 +4457,99 @@ void CURVE_OT_cyclic_toggle(wmOperatorType *ot)
/***************** select linked operator ******************/
-static int select_linked_exec(bContext *C, wmOperator *op)
+static int select_linked_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *obedit= CTX_data_edit_object(C);
- RegionView3D *rv3d= ED_view3d_context_rv3d(C);
+ Curve *cu= (Curve*)obedit->data;
+ EditNurb *editnurb= cu->editnurb;
+ ListBase *nurbs= &editnurb->nurbs;
+ Nurb *nu;
+ BezTriple *bezt;
+ BPoint *bp;
+ int a;
+
+ for(nu= nurbs->first; nu; nu= nu->next) {
+ if(nu->type == CU_BEZIER) {
+ bezt= nu->bezt;
+ a= nu->pntsu;
+ while(a--) {
+ if( (bezt->f1 & SELECT) || (bezt->f2 & SELECT) || (bezt->f3 & SELECT) ) {
+ a= nu->pntsu;
+ bezt= nu->bezt;
+ while(a--) {
+ select_beztriple(bezt, SELECT, 1, VISIBLE);
+ bezt++;
+ }
+ break;
+ }
+ bezt++;
+ }
+ }
+ else {
+ bp= nu->bp;
+ a= nu->pntsu*nu->pntsv;
+ while(a--) {
+ if( bp->f1 & 1 ) {
+ a= nu->pntsu*nu->pntsv;
+ bp= nu->bp;
+ while(a--) {
+ select_bpoint(bp, SELECT, 1, VISIBLE);
+ bp++;
+ }
+ break;
+ }
+ bp++;
+ }
+ }
+ }
+
+ WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
+
+ return OPERATOR_FINISHED;
+}
+
+static int select_linked_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
+{
+ return select_linked_exec(C, op);
+}
+
+void CURVE_OT_select_linked(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Select Linked All";
+ ot->idname= "CURVE_OT_select_linked";
+
+ /* api callbacks */
+ ot->exec= select_linked_exec;
+ ot->invoke= select_linked_invoke;
+ ot->poll= ED_operator_editsurfcurve;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+
+ /* properties */
+}
+
+
+/***************** select linked pick operator ******************/
+
+static int select_linked_pick_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+ Object *obedit= CTX_data_edit_object(C);
+ ARegion *ar= CTX_wm_region(C);
ViewContext vc;
Nurb *nu;
BezTriple *bezt;
BPoint *bp;
int a, location[2], deselect;
- if(!rv3d)
- return OPERATOR_CANCELLED;
-
deselect= RNA_boolean_get(op->ptr, "deselect");
- RNA_int_get_array(op->ptr, "location", location);
-
+ location[0]= event->x - ar->winrct.xmin;
+ location[1]= event->y - ar->winrct.ymin;
+
view3d_operator_needs_opengl(C);
view3d_set_viewcontext(C, &vc);
+
findnearestNurbvert(&vc, 1, location, &nu, &bezt, &bp);
if(bezt) {
@@ -4497,39 +4572,25 @@ static int select_linked_exec(bContext *C, wmOperator *op)
}
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
-
- return OPERATOR_FINISHED;
-}
-
-static int select_linked_invoke(bContext *C, wmOperator *op, wmEvent *event)
-{
- ARegion *ar= CTX_wm_region(C);
- int location[2];
-
- location[0]= event->x - ar->winrct.xmin;
- location[1]= event->y - ar->winrct.ymin;
- RNA_int_set_array(op->ptr, "location", location);
- return select_linked_exec(C, op);
+ return OPERATOR_FINISHED;
}
-void CURVE_OT_select_linked(wmOperatorType *ot)
+void CURVE_OT_select_linked_pick(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Select Linked";
- ot->idname= "CURVE_OT_select_linked";
-
+ ot->idname= "CURVE_OT_select_linked_pick";
+
/* api callbacks */
- ot->exec= select_linked_exec;
- ot->invoke= select_linked_invoke;
- ot->poll= ED_operator_editsurfcurve;
+ ot->invoke= select_linked_pick_invoke;
+ ot->poll= ED_operator_editsurfcurve_region_view3d;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
RNA_def_boolean(ot->srna, "deselect", 0, "Deselect", "Deselect linked control points rather than selecting them.");
- RNA_def_int_vector(ot->srna, "location", 2, NULL, 0, INT_MAX, "Location", "", 0, 16384);
}
/***************** select row operator **********************/